From: vsr Date: Tue, 18 Aug 2009 05:41:44 +0000 (+0000) Subject: Issue 20099: Hide children X-Git-Tag: V5_1_3rc1~51 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3e98d95f4140fee28550e14ff36bc55f000ed4b9;p=modules%2Fgeom.git Issue 20099: Hide children Add Show/Hide chidren menu command for GEOM module objects --- diff --git a/doc/salome/gui/GEOM/images/ob_popup_menu.png b/doc/salome/gui/GEOM/images/ob_popup_menu.png new file mode 100644 index 000000000..1adb3bebb Binary files /dev/null and b/doc/salome/gui/GEOM/images/ob_popup_menu.png differ diff --git a/doc/salome/gui/GEOM/input/viewing_geom_obj.doc b/doc/salome/gui/GEOM/input/viewing_geom_obj.doc index ce710f35e..3787aed92 100644 --- a/doc/salome/gui/GEOM/input/viewing_geom_obj.doc +++ b/doc/salome/gui/GEOM/input/viewing_geom_obj.doc @@ -2,12 +2,13 @@ \page view_geom_obj_page Viewing geometrical objects -\n Newly created geometrical objects are automatically displayed in +Newly created geometrical objects are automatically displayed in the OCC 3D Viewer. -\n OCC 3D Viewer is described in the documentation on GUI +OCC 3D Viewer is described in the documentation on GUI module. -\n After the object has appeared in the Viewer, you can select it with + +After the object has appeared in the Viewer, you can select it with left mouse click to change its presentation parameters and access to other useful options by right-clicking on the selected object. @@ -32,27 +33,47 @@ sub-shapes of the selected geometrical object are automatically coloured by the unique colors. TUI Commands : go.SetAutoColor(enable), enabled = go.GetAutoColor()
  • Hide - allows to hide the selected geometrical object from the -viewer. TUI Command : sg.EraseOnly(ID) -\n \image html image18.png -
  • +viewer. TUI Command : sg.EraseOnly(ID) + +\image html image18.png +
  • Hide all - allows to hide all objects from the viewer. TUI -Command: sg.EraseAll() -\n \image html image26.png -
  • +Command: sg.EraseAll() + +\image html image26.png +
  • Show Only - allows to display only the selected -geometrical object. TUI Command: sg.DisplayOnly(ID) -\n \image html image33.png -
  • +geometrical object. TUI Command: sg.DisplayOnly(ID) + +\image html image33.png +
  • Dump view - exports an object from the viewer in bmp, png, jpg or jpeg image format.
  • Change background - allows to redefine the background -color. By default it is black. -\n\n Some of these functionalities are available through right-clicking +color. By default it is black.
  • + + +Some of these functionalities are available through right-clicking on the viewer background: -\image html image22.png
    +\image html image22.png
    + +The Object browser's popup menu can include some other commands: + +\image html ob_popup_menu.png
    + + + */ diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index 1cff7b460..593d80550 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -89,6 +89,10 @@ QVariant GEOMGUI_Selection::parameter( const int ind, const QString& p ) const return QVariant( isAutoColor( ind ) ); else if ( p == "isVectorsMode" ) return QVariant( isVectorsMode( ind ) ); + else if ( p == "hasHiddenChildren" ) + return QVariant( hasHiddenChildren( ind ) ); + else if ( p == "hasShownChildren" ) + return QVariant( hasShownChildren( ind ) ); else return LightApp_Selection::parameter( ind, p ); } @@ -219,6 +223,70 @@ bool GEOMGUI_Selection::isVectorsMode( const int index ) const return ret; } +bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj ) +{ + bool ok = false; + if ( obj ) { + _PTR(ChildIterator) it ( obj->GetStudy()->NewChildIterator( obj ) ); + for ( ; it->More() && !ok; it->Next() ) { + _PTR(SObject) child = it->Value(); + if ( child ) { + _PTR(SObject) refObj; + if ( child->ReferencedObject( refObj ) ) continue; // omit references + if ( child->GetName() != "" ) ok = true; + } + } + } + return ok; +} + +bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj ) +{ + bool exp = true; + _PTR(GenericAttribute) anAttr; + if ( obj && obj->FindAttribute( anAttr, "AttributeExpandable" ) ) { + _PTR(AttributeExpandable) aAttrExp = anAttr; + exp = aAttrExp->IsExpandable(); + } + return exp; +} + +bool GEOMGUI_Selection::hasHiddenChildren( const int index ) const +{ + bool OK = false; + SalomeApp_Study* appStudy = dynamic_cast + (SUIT_Session::session()->activeApplication()->activeStudy()); + + if ( appStudy && index >= 0 && index < count() ) { + _PTR(Study) study = appStudy->studyDS(); + QString anEntry = entry( index ); + + if ( study && !anEntry.isEmpty() ) { + _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) ); + OK = !expandable( aSO ) && hasChildren( aSO ); + } + } + return OK; +} + +bool GEOMGUI_Selection::hasShownChildren( const int index ) const +{ + bool OK = false; + SalomeApp_Study* appStudy = dynamic_cast + (SUIT_Session::session()->activeApplication()->activeStudy()); + + if ( appStudy && index >= 0 && index < count() ) { + _PTR(Study) study = appStudy->studyDS(); + QString anEntry = entry( index ); + + if ( study && !anEntry.isEmpty() ) { + _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) ); + OK = expandable( aSO ) && hasChildren( aSO ); + } + } + return OK; +} + bool GEOMGUI_Selection::isComponent( const int index ) const { SalomeApp_Study* appStudy = dynamic_cast diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h index d03570ec0..d6b4dabf0 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.h +++ b/src/GEOMGUI/GEOMGUI_Selection.h @@ -28,6 +28,7 @@ #include "GEOM_GEOMGUI.hxx" #include +#include #include #include CORBA_SERVER_HEADER(GEOM_Gen) @@ -50,6 +51,11 @@ private: QString displayMode( const int ) const; QString selectionMode() const; bool isVectorsMode( const int ) const; + bool hasHiddenChildren( const int ) const; + bool hasShownChildren( const int ) const; + + static bool hasChildren( const _PTR(SObject)& ); + static bool expandable( const _PTR(SObject)& ); bool isComponent( const int ) const; GEOM::GEOM_Object_ptr getObject( const int ) const; diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index c30b27932..9abfa6421 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -2323,6 +2323,14 @@ Please, select face, shell or solid and try again MEN_POP_CREATE_GROUP Create Group + + MEN_POP_SHOW_CHILDREN + Show Children + + + MEN_POP_HIDE_CHILDREN + Hide Children + MEN_POP_ISOS Isos @@ -2863,6 +2871,14 @@ Please, select face, shell or solid and try again STB_POP_CREATE_GROUP Create Group + + STB_POP_SHOW_CHILDREN + Show child objects + + + STB_POP_HIDE_CHILDREN + Hide child objects + STB_POP_ISOS Isolines @@ -3335,6 +3351,14 @@ Please, select face, shell or solid and try again TOP_POP_CREATE_GROUP Create Group + + TOP_POP_SHOW_CHILDREN + Show Children + + + TOP_POP_HIDE_CHILDREN + Hide Children + TOP_POP_ISOS Isolines diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 7706ad9d6..86ef36d17 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -386,6 +386,8 @@ void GeometryGUI::OnGUIEvent( int id ) id == 8034 || // POPUP VIEWER - ISOS id == 8035 || // POPUP VIEWER - AUTO COLOR id == 8036 || // POPUP VIEWER - DISABLE AUTO COLOR + id == 8037 || // POPUP VIEWER - SHOW CHILDREN + id == 8038 || // POPUP VIEWER - HIDE CHILDREN id == 804 || // POPUP VIEWER - ADD IN STUDY id == 901 || // OBJECT BROWSER - RENAME id == 9024 ) { // OBJECT BROWSER - OPEN @@ -904,6 +906,8 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 8035, "POP_AUTO_COLOR" ); createGeomAction( 8036, "POP_DISABLE_AUTO_COLOR" ); createGeomAction( 8001, "POP_CREATE_GROUP" ); + createGeomAction( 8037, "POP_SHOW_CHILDREN" ); + createGeomAction( 8038, "POP_HIDE_CHILDREN" ); // make wireframe-shading items to be exclusive (only one at a time is selected) //QActionGroup* dispModeGr = new QActionGroup( this, "", true ); @@ -1145,6 +1149,10 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule( action( 33 ), QString("$type in {'Shape' 'Group'} and selcount>0"), QtxPopupMgr::VisibleRule ); mgr->insert( action( 8001 ), -1, -1 ); // create group mgr->setRule( action( 8001 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule ); + mgr->insert( action( 8037 ), -1, -1 ); // show children + mgr->setRule( action( 8037 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasHiddenChildren=true"), QtxPopupMgr::VisibleRule ); + mgr->insert( action( 8038 ), -1, -1 ); // hide children + mgr->setRule( action( 8038 ), QString("client='ObjectBrowser' and type='Shape' and selcount=1 and hasShownChildren=true"), QtxPopupMgr::VisibleRule ); mgr->insert( action( 801 ), -1, -1 ); // edit group mgr->setRule( action( 801 ), QString("client='ObjectBrowser' and type='Group' and selcount=1 and isOCC=true"), QtxPopupMgr::VisibleRule ); mgr->insert( separator(), -1, -1 ); // ----------- diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index 34dd0d2cc..a076bccf5 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -401,6 +401,12 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) OnDisableAutoColor(); break; } + case 8037: // SHOW CHILDREN - POPUP VIEWER + case 8038: // HIDE CHILDREN - POPUP VIEWER + { + OnShowHideChildren( theCommandID == 8037 ); + break; + } case 9024 : // OPEN - OBJBROSER POPUP { OnOpen(); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index 3ae7e7808..91d8db559 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI.h @@ -71,7 +71,8 @@ private: void OnNbIsos(); void OnOpen(); void OnSelectOnly(int mode); - + void OnShowHideChildren( bool ); + // Recursive deletion of object with children void removeObjectWithChildren( _PTR(SObject), _PTR(Study), diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index a996e25ef..bc7e8fd23 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -606,3 +606,42 @@ void GEOMToolsGUI::OnSelectOnly(int mode) getGeometryGUI()->setLocalSelectionMode(mode); } } + +void GEOMToolsGUI::OnShowHideChildren( bool show ) +{ + SALOME_ListIO selected; + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( app ) { + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + if ( aSelMgr && appStudy ) { + aSelMgr->selectedObjects( selected ); + if ( !selected.IsEmpty() ) { + _PTR(Study) aStudy = appStudy->studyDS(); + _PTR(StudyBuilder) B = aStudy->NewBuilder(); + + bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked(); + if ( aLocked ) { + SUIT_MessageBox::warning( app->desktop(), + QObject::tr( "WRN_WARNING" ), + QObject::tr( "WRN_STUDY_LOCKED" ) ); + return; + } + + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + + _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) ); + _PTR(GenericAttribute) anAttr; + if ( obj ) { + _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" ); + aExp->SetExpandable( show ); + } // if ( obj ) + } // iterator + } + } + app->updateObjectBrowser( false ); + app->updateActions(); + } +}