From: rnv Date: Tue, 27 Feb 2007 07:04:38 +0000 (+0000) Subject: Implementation of PAL13455 (GEOM : PAL EDF 293 Selection filter). X-Git-Tag: V3_2_6a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ae2f3f9d444b2ee8cef75f194ed628d90358b5d0;p=modules%2Fgeom.git Implementation of PAL13455 (GEOM : PAL EDF 293 Selection filter). --- diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 44a5ccf1f..460b77b52 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -105,9 +105,13 @@ GEOMBase_Helper::~GEOMBase_Helper() erasePreview(); if ( hasCommand() ) abortCommand(); - - globalSelection( GEOM_ALLOBJECTS, true ); - + SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) { + GeometryGUI* aGeomGUI = dynamic_cast( app->module( "Geometry" ) ); + if(aGeomGUI) + globalSelection(aGeomGUI->getLocalSelectionMode() , true ); + } + if (myDisplayer) delete myDisplayer; } diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index f4a15ea35..7af013b20 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -23,6 +23,7 @@ #include "GEOM_Displayer.h" #include +#include #include #include @@ -66,7 +67,9 @@ GEOMGUI_Selection::~GEOMGUI_Selection() QtxValue GEOMGUI_Selection::globalParam( const QString& p ) const { if ( p == "isOCC" ) return QtxValue( activeViewType() == OCCViewer_Viewer::Type() ); - + if ( p == "selectionmode" ){ + return QtxValue(selectionMode()); + } return LightApp_Selection::globalParam( p ); } @@ -201,3 +204,24 @@ GEOM::GEOM_Object_ptr GEOMGUI_Selection::getObject( const int index ) const } return GEOM::GEOM_Object::_nil(); } + +QString GEOMGUI_Selection:: selectionMode() const +{ + SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) { + GeometryGUI* aGeomGUI = dynamic_cast( app->module( "Geometry" ) ); + if(aGeomGUI) + switch(aGeomGUI->getLocalSelectionMode()) + { + case GEOM_POINT : return "VERTEX"; + case GEOM_EDGE : return "EDGE"; + case GEOM_WIRE : return "WIRE"; + case GEOM_FACE : return "FACE"; + case GEOM_SHELL : return "SHELL"; + case GEOM_SOLID : return "SOLID"; + case GEOM_COMPOUND : return "COMPOUND"; + case GEOM_ALLOBJECTS : return "ALL"; + default: return ""; + } + } +} diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h index b7a2912cf..eb8c54ed8 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.h +++ b/src/GEOMGUI/GEOMGUI_Selection.h @@ -47,6 +47,7 @@ private: bool isVisible( const int ) const; QString typeName( const int ) const; QString displayMode( const int ) const; + QString selectionMode() const; bool isComponent( const int ) const; GEOM::GEOM_Object_ptr getObject( const int ) const; diff --git a/src/GEOMGUI/GEOM_images.po b/src/GEOMGUI/GEOM_images.po index e8e8119a1..8e2749eee 100644 --- a/src/GEOMGUI/GEOM_images.po +++ b/src/GEOMGUI/GEOM_images.po @@ -766,3 +766,24 @@ msgstr "erase.png" msgid "ICO_POP_CREATE_GROUP" msgstr "group_new.png" + +msgid "ICO_VERTEX_SEL_ONLY" +msgstr "point2.png" + +msgid "ICO_EDGE_SEL_ONLY" +msgstr "build_edge.png" + +msgid "ICO_WIRE_SEL_ONLY" +msgstr "build_wire.png" + +msgid "ICO_FACE_SEL_ONLY" +msgstr "build_face.png" + +msgid "ICO_SHELL_SEL_ONLY" +msgstr "build_shell.png" + +msgid "ICO_SOLID_SEL_ONLY" +msgstr "build_solid.png" + +msgid "ICO_COMPOUND_SEL_ONLY" +msgstr "build_compound.png" \ No newline at end of file diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index 051772917..763bd7c7a 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -3000,3 +3000,54 @@ msgstr "Object of incorrect type selected!\nPlease, select face, shell or solid msgid "DEP_OBJECT" msgstr "Selected object has been used to create another one\n It can't be deleted " + +msgid "MEN_SELECT_ONLY" +msgstr "Select Only" + +msgid "STB_VERTEX_SEL_ONLY" +msgstr "Select only a Points" + +msgid "STB_EDGE_SEL_ONLY" +msgstr "Select only a Edges" + +msgid "STB_WIRE_SEL_ONLY" +msgstr "Select only a Wires" + +msgid "STB_FACE_SEL_ONLY" +msgstr "Select only a Faces" + +msgid "STB_SHELL_SEL_ONLY" +msgstr "Select only a Shells" + +msgid "STB_SOLID_SEL_ONLY" +msgstr "Select only a Solids" + +msgid "STB_COMPOUND_SEL_ONLY" +msgstr "Select only a Compounds" + +msgid "STB_ALL_SEL_ONLY" +msgstr "Select all Objects" + +msgid "MEN_VERTEX_SEL_ONLY" +msgstr "Vertex" + +msgid "MEN_EDGE_SEL_ONLY" +msgstr "Edge" + +msgid "MEN_WIRE_SEL_ONLY" +msgstr "Wire" + +msgid "MEN_FACE_SEL_ONLY" +msgstr "Face" + +msgid "MEN_SHELL_SEL_ONLY" +msgstr "Shell" + +msgid "MEN_SOLID_SEL_ONLY" +msgstr "Solid" + +msgid "MEN_COMPOUND_SEL_ONLY" +msgstr "Compound" + +msgid "MEN_ALL_SEL_ONLY" +msgstr "Select All" diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 1362269dc..18022605d 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -190,6 +190,7 @@ GeometryGUI::GeometryGUI() : myVTKSelectors.setAutoDelete( true ); myDisplayer = 0; + myLocalSelectionMode = GEOM_ALLOBJECTS; } //======================================================================= @@ -369,6 +370,14 @@ void GeometryGUI::OnGUIEvent( int id ) id == 121 || // MENU FILE - EXPORT BREP id == 122 || // MENU FILE - EXPORT IGES id == 123 || // MENU FILE - EXPORT STEP + id == 2171 || // POPUP VIEWER - SELECT ONLY - VERTEX + id == 2172 || // POPUP VIEWER - SELECT ONLY - EDGE + id == 2173 || // POPUP VIEWER - SELECT ONLY - WIRE + id == 2174 || // POPUP VIEWER - SELECT ONLY - FACE + id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL + id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID + id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND + id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL id == 31 || // MENU EDIT - COPY id == 33 || // MENU EDIT - DELETE id == 411 || // MENU SETTINGS - ADD IN STUDY @@ -855,6 +864,14 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 212, "DISPLAY_ALL" ); createGeomAction( 214, "ERASE_ALL" ); createGeomAction( 216, "DISPLAY" ); + createGeomAction( 2171, "VERTEX_SEL_ONLY" ,"", 0, true ); + createGeomAction( 2172, "EDGE_SEL_ONLY", "", 0, true ); + createGeomAction( 2173, "WIRE_SEL_ONLY", "", 0, true ); + createGeomAction( 2174, "FACE_SEL_ONLY", "", 0, true ); + createGeomAction( 2175, "SHELL_SEL_ONLY", "", 0, true ); + createGeomAction( 2176, "SOLID_SEL_ONLY", "", 0, true ); + createGeomAction( 2177, "COMPOUND_SEL_ONLY", "", 0, true ); + createGeomAction( 2178, "ALL_SEL_ONLY", "", 0, true ); createGeomAction( 213, "DISPLAY_ONLY" ); createGeomAction( 215, "ERASE" ); @@ -1116,6 +1133,35 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action( 214 ), -1, -1 ); // erase All mgr->setRule( action( 214 ), clientOCCorVTK, true ); + QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)"; + + int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu + mgr->insert( action(2171), selectolnyId, -1); //Vertex + mgr->setRule(action(2171), selectOnly, true); + mgr->setRule(action(2171), selectOnly + " and selectionmode='VERTEX'", false); + mgr->insert( action(2172), selectolnyId, -1); //Edge + mgr->setRule(action(2172), selectOnly, true); + mgr->setRule(action(2172), selectOnly + " and selectionmode='EDGE'", false); + mgr->insert( action(2173), selectolnyId, -1); //Wire + mgr->setRule(action(2173), selectOnly, true); + mgr->setRule(action(2173), selectOnly + " and selectionmode='WIRE'", false); + mgr->insert( action(2174), selectolnyId, -1); //Face + mgr->setRule(action(2174), selectOnly, true); + mgr->setRule(action(2174), selectOnly + " and selectionmode='FACE'", false); + mgr->insert( action(2175), selectolnyId, -1); //Shell + mgr->setRule(action(2175), selectOnly, true); + mgr->setRule(action(2175), selectOnly + " and selectionmode='SHELL'", false); + mgr->insert( action(2176), selectolnyId, -1); //Solid + mgr->setRule(action(2176), selectOnly, true); + mgr->setRule(action(2176), selectOnly + " and selectionmode='SOLID'", false); + mgr->insert( action(2177), selectolnyId, -1); //Compound + mgr->setRule(action(2177), selectOnly, true); + mgr->setRule(action(2177), selectOnly + " and selectionmode='COMPOUND'", false); + mgr->insert( separator(), selectolnyId, -1); + mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter + mgr->setRule(action(2178), selectOnly, true); + mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", false); + mgr->insert( action( 213 ), -1, -1 ); // display only mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), true ); mgr->insert( separator(), -1, -1 ); @@ -1759,3 +1805,12 @@ LightApp_Displayer* GeometryGUI::displayer() myDisplayer = new GEOM_Displayer( dynamic_cast( getApp()->activeStudy() ) ); return myDisplayer; } + +void GeometryGUI::setLocalSelectionMode(const int mode) +{ + myLocalSelectionMode = mode; +} +int GeometryGUI::getLocalSelectionMode() const +{ + return myLocalSelectionMode; +} diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index f2902c6bc..ed301fe3c 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -136,7 +136,8 @@ public: virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& ); virtual void createPreferences(); virtual void preferencesChanged( const QString&, const QString& ); - + int getLocalSelectionMode() const; + void setLocalSelectionMode(const int mode); public slots: virtual bool deactivateModule( SUIT_Study* ); @@ -186,6 +187,7 @@ private: QPtrList myVTKSelectors; LightApp_Displayer* myDisplayer; + int myLocalSelectionMode; //Select Only friend class DisplayGUI; }; diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index c42e6c700..39022be14 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -154,6 +155,46 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) Export(); break; } + case 2171: // POPUP VIEWER - SELECT ONLY - VERTEX + { + OnSelectOnly( GEOM_POINT ); + break; + } + case 2172: // POPUP VIEWER - SELECT ONLY - EDGE + { + OnSelectOnly( GEOM_EDGE ); + break; + } + case 2173: // POPUP VIEWER - SELECT ONLY - WIRE + { + OnSelectOnly( GEOM_WIRE ); + break; + } + case 2174: // POPUP VIEWER - SELECT ONLY - FACE + { + OnSelectOnly( GEOM_FACE ); + break; + } + case 2175: // POPUP VIEWER - SELECT ONLY - SHELL + { + OnSelectOnly( GEOM_SHELL ); + break; + } + case 2176: // POPUP VIEWER - SELECT ONLY - SOLID + { + OnSelectOnly( GEOM_SOLID ); + break; + } + case 2177: // POPUP VIEWER - SELECT ONLY - COMPOUND + { + OnSelectOnly( GEOM_COMPOUND ); + break; + } + case 2178: // POPUP VIEWER - SELECT ONLY - SELECT ALL + { + OnSelectOnly( GEOM_ALLOBJECTS ); + break; + } case 411: // SETTINGS - ADD IN STUDY { // SAN -- TO BE REMOVED !!! @@ -702,6 +743,21 @@ bool GEOMToolsGUI::CheckSubObjectInUse(_PTR(SObject) checkobj, return false; } +//================================================================================= +// function : deactivate() +// purpose : Called when GEOM component is deactivated +//================================================================================= +void GEOMToolsGUI::deactivate() +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( app ) { + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + GEOM_Displayer aDisp (appStudy); + aDisp.GlobalSelection(); + getGeometryGUI()->setLocalSelectionMode(GEOM_ALLOBJECTS); + } +} + //===================================================================================== // EXPORTED METHODS //===================================================================================== diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index 2486bfa93..e2751c3de 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI.h @@ -58,6 +58,7 @@ public : ~GEOMToolsGUI(); bool OnGUIEvent( int theCommandID, SUIT_Desktop* parent ); + virtual void deactivate(); private: // Import and export topology methods @@ -78,7 +79,8 @@ private: void OnTransparency(); void OnNbIsos(); void OnOpen(); - + void OnSelectOnly(int mode); + // returns name of Module (Component) of given objects (usually selected objects) // if objects belong to different Components, a NULL string is returned. QString getParentComponent( _PTR( Study ), const SALOME_ListIO& ); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index 5ef3c0188..2becab38d 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -437,3 +437,14 @@ void GEOMToolsGUI::OnOpen() } */ } + +void GEOMToolsGUI::OnSelectOnly(int mode) +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( app ) { + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + GEOM_Displayer aDisp (appStudy); + aDisp.GlobalSelection(mode); + getGeometryGUI()->setLocalSelectionMode(mode); + } +}