From: nds Date: Tue, 23 Jun 2015 06:54:35 +0000 (+0300) Subject: Activate/deactivate selection filter by module activation/deactivation. X-Git-Tag: V_1.3.0~213 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e6b36d512dd0990c548af88ea84c0214d7e8d91a;p=modules%2Fshaper.git Activate/deactivate selection filter by module activation/deactivation. Check case: activate NewGeom, activate GEOM, activate NewGeom, start sketch, create a line. The plane's eges/points should not be selectable. --- diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 1d10eeb13..ba082667e 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -40,6 +40,12 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject virtual ~ModuleBase_IModule() {} + // Add default selection filters of the module to the current viewer + virtual void activateSelectionFilters() {}; + + // Remove default selection filters of the module from the current viewer + virtual void deactivateSelectionFilters() {}; + /// Reads description of features from XML file virtual void createFeatures(); diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index 8265e654c..f5927a5ef 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -159,6 +159,8 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) mySelector = createSelector(OCCViewManagers.first()); } } + // it should be pefromed after the selector creation in order to have AISContext + myWorkshop->activateModule(); //action(myEraseAll)->setEnabled(false); if (myIsOpened) { @@ -223,6 +225,8 @@ bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy) setMenuShown(false); setToolShown(false); + myWorkshop->deactivateModule(); + QObject* aObj = myWorkshop->objectBrowser()->parent(); QDockWidget* aObjDoc = dynamic_cast(aObj); if (aObjDoc) { diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 45e3f2d43..483e34ade 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -15,6 +15,9 @@ #include "PartSet_SketcherMgr.h" #include "PartSet_MenuMgr.h" +#include "PartSet_Filters.h" +#include "PartSet_FilterInfinite.h" + #include #include @@ -90,6 +93,8 @@ #include #include +#include + #ifdef _DEBUG #include #endif @@ -128,21 +133,38 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) Events_Loop* aLoop = Events_Loop::loop(); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)); - if (myDocumentShapeFilter.IsNull()) - myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop); - myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter); - - if (myFilterInfinite.IsNull()) - myFilterInfinite = new PartSet_FilterInfinite(); - myWorkshop->viewer()->addSelectionFilter(myFilterInfinite); + mySelectionFilters.Append(new PartSet_GlobalFilter(myWorkshop)); + mySelectionFilters.Append(new PartSet_FilterInfinite()); } PartSet_Module::~PartSet_Module() { - if (!myDocumentShapeFilter.IsNull()) - myDocumentShapeFilter.Nullify(); - if (!myFilterInfinite.IsNull()) - myFilterInfinite.Nullify(); + SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters); + for (; aIt.More(); aIt.Next()) { + Handle(SelectMgr_Filter) aFilter = aIt.Value(); + if (!aFilter.IsNull()) + aFilter.Nullify(); + } +} + +void PartSet_Module::activateSelectionFilters() +{ + SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters); + for (; aIt.More(); aIt.Next()) { + Handle(SelectMgr_Filter) aFilter = aIt.Value(); + if (!aFilter.IsNull()) + myWorkshop->viewer()->addSelectionFilter(aFilter); + } +} + +void PartSet_Module::deactivateSelectionFilters() +{ + SelectMgr_ListIteratorOfListOfFilter aIt(mySelectionFilters); + for (; aIt.More(); aIt.Next()) { + Handle(SelectMgr_Filter) aFilter = aIt.Value(); + if (!aFilter.IsNull()) + myWorkshop->viewer()->removeSelectionFilter(aFilter); + } } void PartSet_Module::registerValidators() diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 8a469e9bd..46012ad16 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -4,9 +4,7 @@ #define PartSet_Module_H #include "PartSet.h" -#include "PartSet_Filters.h" #include "PartSet_DocumentDataModel.h" -#include "PartSet_FilterInfinite.h" #include #include @@ -18,6 +16,7 @@ //#include #include +#include #include #include @@ -57,6 +56,11 @@ public: PartSet_Module(ModuleBase_IWorkshop* theWshop); virtual ~PartSet_Module(); + // Add default selection filters of the module to the current viewer + virtual void activateSelectionFilters(); + // Remove default selection filters of the module from the current viewer + virtual void deactivateSelectionFilters(); + /// Creates custom widgets for property panel virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent, Config_WidgetAPI* theWidgetApi, std::string theParentId); @@ -64,7 +68,6 @@ public: /// Call back forlast tuning of property panel before operation performance virtual void propertyPanelDefined(ModuleBase_Operation* theOperation); - /// Realizes some functionality by an operation start /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters /// \param theOperation a started operation @@ -205,9 +208,7 @@ protected slots: // Automatical restarting mode flag RestartingMode myRestartingMode; - /// A filter which provides selection within a current document or whole PartSet - Handle(PartSet_GlobalFilter) myDocumentShapeFilter; - Handle(PartSet_FilterInfinite) myFilterInfinite; + SelectMgr_ListOfFilter mySelectionFilters; PartSet_SketcherMgr* mySketchMgr; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 828a42655..203e2a897 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -176,7 +176,7 @@ void XGUI_Workshop::startApplication() // Calling of loadCustomProps before activating module is required // by Config_PropManger to restore user-defined path to plugins ModuleBase_Preferences::loadCustomProps(); - activateModule(); + createModule(); if (myMainWindow) { myMainWindow->show(); updateCommandStatus(); @@ -187,6 +187,29 @@ void XGUI_Workshop::startApplication() emit applicationStarted(); } +void XGUI_Workshop::activateModule() +{ + myModule->activateSelectionFilters(); + + connect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)), + myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr))); + connect(myDisplayer, SIGNAL(beforeObjectErase(ObjectPtr, AISObjectPtr)), + myModule, SLOT(onBeforeObjectErase(ObjectPtr, AISObjectPtr))); + + myActionsMgr->update(); + +} + +void XGUI_Workshop::deactivateModule() +{ + myModule->deactivateSelectionFilters(); + + disconnect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)), + myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr))); + disconnect(myDisplayer, SIGNAL(beforeObjectErase(ObjectPtr, AISObjectPtr)), + myModule, SLOT(onBeforeObjectErase(ObjectPtr, AISObjectPtr))); +} + //****************************************************** void XGUI_Workshop::initMenu() { @@ -1051,7 +1074,7 @@ ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule) } //****************************************************** -bool XGUI_Workshop::activateModule() +bool XGUI_Workshop::createModule() { Config_ModuleReader aModuleReader; QString moduleName = QString::fromStdString(aModuleReader.getModuleName()); @@ -1059,13 +1082,13 @@ bool XGUI_Workshop::activateModule() if (!myModule) return false; - connect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)), - myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr))); - connect(myDisplayer, SIGNAL(beforeObjectErase(ObjectPtr, AISObjectPtr)), - myModule, SLOT(onBeforeObjectErase(ObjectPtr, AISObjectPtr))); + //connect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)), + // myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr))); + //connect(myDisplayer, SIGNAL(beforeObjectErase(ObjectPtr, AISObjectPtr)), + // myModule, SLOT(onBeforeObjectErase(ObjectPtr, AISObjectPtr))); myModule->createFeatures(); - myActionsMgr->update(); + //myActionsMgr->update(); return true; } diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index f6d1cb7c8..fccb8575d 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -67,6 +67,12 @@ Q_OBJECT //! Starting of the application void startApplication(); + // Activates the module controls. Should be called after module creation + void activateModule(); + + // Deactivates the module controls. Should be called after module creation + void deactivateModule(); + //! Returns main window (Desktop) of the application AppElements_MainWindow* mainWindow() const { @@ -380,8 +386,8 @@ signals: /// \param theModule name of the module ModuleBase_IModule* loadModule(const QString& theModule); - /// Activate module - bool activateModule(); + /// Create module + bool createModule(); /// Create object browser widget /// \param theParent a parent of widget