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"
9 #include <ModuleBase_IModule.h>
10 #include <ModuleBase_Definitions.h>
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_Attribute.h>
13 #include <ModelAPI_CompositeFeature.h>
15 //#include <StdSelect_FaceFilter.hxx>
16 #include <TopoDS_Shape.hxx>
26 class ModuleBase_Operation;
27 class ModuleBase_IViewWindow;
28 class PartSet_MenuMgr;
29 class PartSet_SketcherMgr;
35 * Implementation of Partset module
37 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
41 /// Enumeration to specify the restart operation properties.
43 RM_None, /// the operation should not be restarted
44 RM_Forbided, /// the operation should not be restarted after there is no active widget
45 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
46 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
51 /// \param theWshop a pointer to a workshop
52 PartSet_Module(ModuleBase_IWorkshop* theWshop);
53 virtual ~PartSet_Module();
55 /// Creates custom widgets for property panel
56 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
57 Config_WidgetAPI* theWidgetApi, std::string theParentId);
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 current operation
84 virtual ModuleBase_Operation* currentOperation() const;
86 /// Returns True if there are available Undos and the sketch manager allows undo
87 /// \return the boolean result
88 virtual bool canUndo() const;
90 //! Returns True if there are available Redos and the sketch manager allows redo
91 /// \return the boolean result
92 virtual bool canRedo() const;
94 /// Returns whether the object can be displayed at the bounds of the active operation.
95 /// Display only current operation results for usual operation and ask the sketcher manager
96 /// if it is a sketch operation
97 /// \param theObject a model object
98 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
100 /// Add menu atems for viewer into the given menu
101 /// \param theMenu a popup menu to be shown in the viewer
102 /// \param theStdActions a map of standard actions
103 /// \return true if items are added and there is no necessity to provide standard menu
104 virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
106 /// Returns whether the mouse enter the viewer's window
107 /// \return true if items are added and there is no necessity to provide standard menu
108 bool isMouseOverWindow();
110 PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
113 /// SLOT, that is called by no more widget signal emitted by property panel
114 /// Set a specific flag to restart the sketcher operation
115 void onNoMoreWidgets();
117 /// Slolt called on object display
118 /// \param theObject a data object
119 /// \param theAIS a presentation object
120 virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
123 /// Called when previous operation is finished
124 virtual void onSelectionChanged();
126 /// SLOT, that is called by key release in the viewer.
127 /// \param theWnd a view window
128 /// \param theEvent the key event
129 void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
131 /// SLOT, that is called by enter key released
132 /// Set a specific type of restarting the current operation
133 void onEnterReleased();
135 /// SLOT, that is called by the current operation filling with the preselection.
136 /// It commits the operation of it is can be committed
137 void onOperationActivatedByPreselection();
140 /// Register validators for this module
141 virtual void registerValidators();
143 /// Register selection filters for this module
144 virtual void registerFilters();
146 /// Register properties of this module
147 virtual void registerProperties();
150 /// Processing of vertex selected
151 void onVertexSelected();
153 /// Called on transformation in current viewer
154 /// \param theTrsfType type of tranformation
155 void onViewTransformed(int theTrsfType = 2);
158 /// Breaks sequense of automatically resterted operations
159 void breakOperationSequence();
162 virtual bool deleteObjects();
165 QString myLastOperationId;
166 FeaturePtr myLastFeature;
168 // Automatical restarting mode flag
169 RestartingMode myRestartingMode;
171 /// A filter which provides selection within a current document or whole PartSet
172 Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
174 PartSet_SketcherMgr* mySketchMgr;
176 PartSet_MenuMgr* myMenuMgr;