Implementation of 0021757: EDF 1829 : Activate bring to front action on simple selection of an object

This commit is contained in:
mpa 2013-08-06 14:37:17 +00:00
parent dde31f0675
commit e688f2b77f
8 changed files with 75 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 94 KiB

View File

@ -44,6 +44,8 @@ predefined materials.</li>
<li><b>Isolines width</b> - allows to define default width of the isolines.</li>
<li><b>Preview edges width</b> - allows to define width of the edges for preview.</li>
<li><b>Measures line width</b> - allows to define lines width of measurements tools.</li>
<li><b>Automatic bring to front</b> - when option is ON: the objects selected by the user will be automatically
made "top-level".</li>
</ul>
</ul>

View File

@ -41,6 +41,7 @@
#include <SUIT_Desktop.h>
#include <SUIT_ViewWindow.h>
#include <SUIT_ViewManager.h>
#include <SUIT_ResourceMgr.h>
#include <SALOME_Prs.h>
#include <SALOME_InteractiveObject.hxx>
@ -159,6 +160,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
v = isVectorsMode( idx );
else if ( p == "topLevel" )
v = topLevel( idx );
else if ( p == "autoBringToFront" )
v = autoBringToFront( idx );
else if ( p == "hasChildren" )
v = hasChildren( idx );
else if ( p == "nbChildren" )
@ -352,6 +355,11 @@ QString GEOMGUI_Selection::displayMode( const int index ) const
return res;
}
bool GEOMGUI_Selection::autoBringToFront( const int /*index*/ ) const
{
return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" );
}
bool GEOMGUI_Selection::isVectorsMode( const int index ) const
{
#ifdef USE_VISUAL_PROP_MAP

View File

@ -73,6 +73,7 @@ private:
bool hasDisclosedChildren( const int ) const;
bool compoundOfVertices( const int ) const;
bool topLevel( const int ) const;
bool autoBringToFront( const int ) const;
bool isPhysicalMaterial( const int ) const;
bool isComponent( const int ) const;

View File

@ -3236,6 +3236,10 @@ Please, select face, shell or solid and try again</translation>
<source>PREF_MEASURES_LINE_WIDTH</source>
<translation>Measures lines width</translation>
</message>
<message>
<source>PREF_AUTO_BRING_TO_FRONT</source>
<translation>Automatic bring to front</translation>
</message>
<message>
<source>PREF_ISOS</source>
<translation>Number of isolines</translation>

View File

@ -3242,6 +3242,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>PREF_MEASURES_LINE_WIDTH</source>
<translation>Epaisseur des traits de mesure</translation>
</message>
<message>
<source>PREF_AUTO_BRING_TO_FRONT</source>
<translation>Afficher au premier plan automatiquement</translation>
</message>
<message>
<source>PREF_ISOS</source>
<translation>Nombre d&apos;isolignes</translation>

View File

@ -1292,10 +1292,10 @@ void GeometryGUI::initialize( CAM_Application* app )
//QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and (selcount>0) and isOCC=true and topLevel=false";
QString bringRule = clientOCCorOB + " and ($component={'GEOM'}) and isFolder=false and (selcount>0) and isOCC=true";
mgr->insert( action(GEOMOp::OpBringToFront ), -1, -1 ); // bring to front
mgr->setRule(action(GEOMOp::OpBringToFront), bringRule, QtxPopupMgr::VisibleRule );
mgr->setRule(action(GEOMOp::OpBringToFront), bringRule + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
mgr->setRule(action(GEOMOp::OpBringToFront), "topLevel=true", QtxPopupMgr::ToggleRule );
mgr->insert( action(GEOMOp::OpClsBringToFront ), -1, -1 ); // clear bring to front
mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC, QtxPopupMgr::VisibleRule );
mgr->setRule( action(GEOMOp::OpClsBringToFront ), clientOCC + " and autoBringToFront = false", QtxPopupMgr::VisibleRule );
#endif
mgr->insert( separator(), -1, -1 ); // -----------
dispmodeId = mgr->insert( tr( "MEN_DISPLAY_MODE" ), -1, -1 ); // display mode menu
@ -1474,6 +1474,8 @@ bool GeometryGUI::activateModule( SUIT_Study* study )
LightApp_SelectionMgr* sm = getApp()->selectionMgr();
connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( onAutoBringToFront() ));
if ( !myCreationInfoWdg )
myCreationInfoWdg = new GEOMGUI_CreationInfoWdg( getApp() );
getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
@ -1755,6 +1757,54 @@ void GeometryGUI::updateCreationInfo()
}
}
void GeometryGUI::onAutoBringToFront()
{
bool isAutoBringToFront = SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" );
if( !isAutoBringToFront )
return;
SUIT_ViewWindow* SUIT_window = application()->desktop()->activeWindow();
if ( !SUIT_window || SUIT_window->getViewManager()->getType() != OCCViewer_Viewer::Type() )
return;
SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( getApp()->activeStudy() );
if (!appStudy) return;
GEOM_Displayer displayer( appStudy );
SALOME_View* window = displayer.GetActiveView();
if ( !window ) return;
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
SALOME_ListIO selected;
getApp()->selectionMgr()->selectedObjects( selected );
SALOME_ListIO allObjects;
window->GetVisible( allObjects );
for ( SALOME_ListIteratorOfListIO It( allObjects ); It.More(); It.Next() ) {
Handle( SALOME_InteractiveObject ) io = It.Value();
bool isSelected = false;
for( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
Handle( SALOME_InteractiveObject ) ioSelected = It.Value();
if( io->isSame( ioSelected ) )
isSelected = true;
}
QVariant v = appStudy->getObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), QVariant() );
bool isTopLevel = v.isValid() ? v.toBool() : false;
if( isSelected && !isTopLevel ) {
appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), true );
if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
}
else if( !isSelected ) {
appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), false );
if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
}
}
displayer.UpdateViewer();
GeometryGUI::Modified();
}
QString GeometryGUI::engineIOR() const
{
if ( !CORBA::is_nil( GetGeomGen() ) )
@ -1961,6 +2011,9 @@ void GeometryGUI::createPreferences()
setPreferenceProperty( wd[i], "max", 5 );
}
addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
setPreferenceProperty( isoGroup, "columns", 2 );
int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,

View File

@ -168,6 +168,7 @@ private slots:
void OnSetMaterial( const QString& );
void updateMaterials();
void updateCreationInfo();
void onAutoBringToFront();
signals :
void SignalDeactivateActiveDialog();