1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #ifndef PartSet_Module_H
4 #define PartSet_Module_H
7 #include "PartSet_Filters.h"
8 #include "PartSet_SketcherMgr.h"
10 #include <ModuleBase_IModule.h>
11 #include <ModuleBase_Definitions.h>
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Attribute.h>
14 #include <ModelAPI_CompositeFeature.h>
16 //#include <StdSelect_FaceFilter.hxx>
17 #include <TopoDS_Shape.hxx>
27 class ModuleBase_Operation;
28 class ModuleBase_IViewWindow;
34 * Implementation of Partset module
36 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
40 /// Enumeration to specify the restart operation properties.
42 RM_None, /// the operation should not be restarted
43 RM_Forbided, /// the operation should not be restarted after there is no active widget
44 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
45 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
50 /// \param theWshop a pointer to a workshop
51 PartSet_Module(ModuleBase_IWorkshop* theWshop);
52 virtual ~PartSet_Module();
54 /// Creates custom widgets for property panel
55 virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
56 Config_WidgetAPI* theWidgetApi, std::string theParentId,
57 QList<ModuleBase_ModelWidget*>& theModelWidgets);
59 /// Call back forlast tuning of property panel before operation performance
60 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
63 /// Realizes some functionality by an operation start
64 /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
65 /// \param theOperation a started operation
66 virtual void operationStarted(ModuleBase_Operation* theOperation);
68 /// Realizes some functionality by an operation commit
69 /// Restarts sketcher operation automatically of it is necessary
70 /// \param theOperation a committed operation
71 virtual void operationCommitted(ModuleBase_Operation* theOperation);
73 /// Realizes some functionality by an operation abort
74 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
75 /// \param theOperation an aborted operation
76 virtual void operationAborted(ModuleBase_Operation* theOperation);
78 /// Realizes some functionality by an operation stop
79 /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
80 /// \param theOperation a stopped operation
81 virtual void operationStopped(ModuleBase_Operation* theOperation);
83 /// Returns whether the object can be displayed at the bounds of the active operation.
84 /// Display only current operation results for usual operation and ask the sketcher manager
85 /// if it is a sketch operation
86 /// \param theObject a model object
87 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
88 /// Add menu atems for viewer into the given menu
89 /// \param theMenu a popup menu to be shown in the viewer
90 virtual void addViewerItems(QMenu* theMenu) const;
93 /// SLOT, that is called by no more widget signal emitted by property panel
94 /// Set a specific flag to restart the sketcher operation
95 void onNoMoreWidgets();
97 /// Processes the context menu action click
98 /// \param isChecked a state of toggle if the action is checkable
99 void onAction(bool isChecked);
102 /// Called when previous operation is finished
103 virtual void onSelectionChanged();
105 /// SLOT, that is called by key release in the viewer.
106 /// \param theWnd a view window
107 /// \param theEvent the key event
108 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
110 /// SLOT, that is called by enter key released
111 /// Set a specific type of restarting the current operation
112 void onEnterReleased();
114 /// SLOT, that is called by the current operation filling with the preselection.
115 /// It commits the operation of it is can be committed
116 void onOperationActivatedByPreselection();
120 /// Register validators for this module
121 virtual void registerValidators();
123 /// Register selection filters for this module
124 virtual void registerFilters();
127 /// Processing of vertex selected
128 void onVertexSelected();
131 /// Breaks sequense of automatically resterted operations
132 void breakOperationSequence();
134 /// Check whether there is active opeation and it is the sketch one
135 /// \return boolean result
136 bool isSketchOperationActive() const;
138 /// Create all actions for context menus. It is called on creation of module
139 /// Put the created actions into an internal map
140 void createActions();
142 /// Returns action according to the given ID
143 /// \param theId an action identifier, it should be uniqued in the bounds of the module
144 QAction* action(const QString& theId) const;
146 /// Add action to the internal map
147 /// \param theId - string ID of the item
148 /// \param theAction - action to add
149 void addAction(const QString& theId, QAction* theAction);
152 void deleteObjects();
155 QString myLastOperationId;
156 FeaturePtr myLastFeature;
158 // Automatical restarting mode flag
159 RestartingMode myRestartingMode;
161 /// A filter which provides selection within a current document or whole PartSet
162 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
164 PartSet_SketcherMgr* mySketchMgr;
166 QMap<QString, QAction*> myActions; // the popup menu actions