Check case: activate NewGeom, activate GEOM, activate NewGeom, start sketch, create a line. The plane's eges/points should not be selectable.
\r
virtual ~ModuleBase_IModule() {}\r
\r
+ // Add default selection filters of the module to the current viewer\r
+ virtual void activateSelectionFilters() {};\r
+\r
+ // Remove default selection filters of the module from the current viewer\r
+ virtual void deactivateSelectionFilters() {};\r
+\r
/// Reads description of features from XML file \r
virtual void createFeatures();\r
\r
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) {
setMenuShown(false);
setToolShown(false);
+ myWorkshop->deactivateModule();
+
QObject* aObj = myWorkshop->objectBrowser()->parent();
QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
if (aObjDoc) {
#include "PartSet_SketcherMgr.h"
#include "PartSet_MenuMgr.h"
+#include "PartSet_Filters.h"
+#include "PartSet_FilterInfinite.h"
+
#include <PartSetPlugin_Remove.h>
#include <PartSetPlugin_Part.h>
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomDataAPI_Dir.h>
+#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
+
#ifdef _DEBUG
#include <QDebug>
#endif
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()
#define PartSet_Module_H
#include "PartSet.h"
-#include "PartSet_Filters.h"
#include "PartSet_DocumentDataModel.h"
-#include "PartSet_FilterInfinite.h"
#include <ModuleBase_IModule.h>
#include <ModuleBase_Definitions.h>
//#include <StdSelect_FaceFilter.hxx>
#include <TopoDS_Shape.hxx>
+#include <SelectMgr_ListOfFilter.hxx>
#include <QMap>
#include <QMenu>
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);
/// 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
// 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;
// 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();
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()
{
}
//******************************************************
-bool XGUI_Workshop::activateModule()
+bool XGUI_Workshop::createModule()
{
Config_ModuleReader aModuleReader;
QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
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;
}
//! 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
{
/// \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