]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.h
Salome HOME
Bug #619: Sketch plane rotation.
[modules/shaper.git] / src / PartSet / PartSet_Module.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #ifndef PartSet_Module_H
4 #define PartSet_Module_H
5
6 #include "PartSet.h"
7 #include "PartSet_DocumentDataModel.h"
8
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>
14
15 #include <Events_Listener.h>
16
17 //#include <StdSelect_FaceFilter.hxx>
18 #include <TopoDS_Shape.hxx>
19 #include <SelectMgr_ListOfFilter.hxx>
20
21 #include <QMap>
22 #include <QMenu>
23 #include <QObject>
24
25 #include <string>
26
27 #include <memory>
28
29 class ModuleBase_Operation;
30 class ModuleBase_IViewWindow;
31 class PartSet_MenuMgr;
32 class PartSet_SketcherMgr;
33
34 class QAction;
35
36 /**
37 * \ingroup Modules
38 * Implementation of Partset module
39 */
40 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule, public Events_Listener
41 {
42 Q_OBJECT
43
44 /// Enumeration to specify the restart operation properties.
45 enum RestartingMode {
46   RM_None, /// the operation should not be restarted
47   RM_Forbided, /// the operation should not be restarted after there is no active widget
48   RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
49   RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
50 };
51
52 public:
53
54   /// Constructor
55   /// \param theWshop a pointer to a workshop
56   PartSet_Module(ModuleBase_IWorkshop* theWshop);
57   virtual ~PartSet_Module();
58
59   // Add default selection filters of the module to the current viewer
60   virtual void activateSelectionFilters();
61   // Remove default selection filters of the module from the current viewer
62   virtual void deactivateSelectionFilters();
63
64   /// Creates custom widgets for property panel
65   virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
66                                                      Config_WidgetAPI* theWidgetApi, std::string theParentId);
67
68   /// Call back forlast tuning of property panel before operation performance
69   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
70
71   /// Realizes some functionality by an operation start
72   /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
73   /// \param theOperation a started operation
74   virtual void onOperationStarted(ModuleBase_Operation* theOperation);
75
76   /// Realizes some functionality by an operation commit
77   /// Restarts sketcher operation automatically of it is necessary
78   /// \param theOperation a committed operation
79   virtual void onOperationCommitted(ModuleBase_Operation* theOperation);
80
81   /// Realizes some functionality by an operation abort
82   /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
83   /// \param theOperation an aborted operation
84   virtual void onOperationAborted(ModuleBase_Operation* theOperation);
85
86   /// Realizes some functionality by an operation stop
87   /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
88   /// \param theOperation a stopped operation
89   virtual void onOperationStopped(ModuleBase_Operation* theOperation);
90
91   /// Returns current operation
92   virtual ModuleBase_Operation* currentOperation() const;
93
94   /// Returns True if there are available Undos and the sketch manager allows undo
95   /// \return the boolean result
96   virtual bool canUndo() const;
97
98   //! Returns True if there are available Redos and the sketch manager allows redo
99   /// \return the boolean result
100   virtual bool canRedo() const;
101
102   /// Returns True if the current operation can be committed. Asks the sketch manager.
103   /// \return a boolean value
104   virtual bool canCommitOperation() const;
105
106   /// Returns whether the object can be displayed at the bounds of the active operation.
107   /// Display only current operation results for usual operation and ask the sketcher manager
108   /// if it is a sketch operation
109   /// \param theObject a model object
110   virtual bool canDisplayObject(const ObjectPtr& theObject) const;
111
112   /// Returns true if selection for the object can be activate.
113   /// For sketch operation allow the selection activation if the operation is edit, for other
114   /// operation uses the default result
115   /// \param theObject a model object
116   virtual bool canActivateSelection(const ObjectPtr& theObject) const;
117
118   /// Add menu atems for object browser into the given menu
119   /// \param theMenu a popup menu to be shown in the object browser
120   virtual void addObjectBrowserMenu(QMenu* theMenu) const;
121
122   /// Add menu atems for viewer into the given menu
123   /// \param theMenu a popup menu to be shown in the viewer
124   /// \param theStdActions a map of standard actions
125   /// \return true if items are added and there is no necessity to provide standard menu
126   virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
127
128   /// Returns a list of modes, where the AIS objects should be activated
129   /// \param theModes a list of modes
130   virtual void activeSelectionModes(QIntList& theModes);
131
132   /// Returns whether the mouse enter the viewer's window
133   /// \return true if items are added and there is no necessity to provide standard menu
134   bool isMouseOverWindow();
135
136   PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
137
138   /// Returns data model object for representation of data tree in Object browser
139   virtual ModuleBase_IDocumentDataModel* dataModel() const { return myDataModel; }
140
141   /// Event Listener method
142   /// \param theMessage an event message
143   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
144
145   /// This method is called on object browser creation for customisation of module specific features
146   /// \param theObjectBrowser a pinter on Object Browser widget
147   virtual void customizeObjectBrowser(QWidget* theObjectBrowser);
148
149 public slots:
150   /// SLOT, that is called by no more widget signal emitted by property panel
151   /// Set a specific flag to restart the sketcher operation
152   void onNoMoreWidgets();
153
154   /// Redefines the parent method in order to customize the next case:
155   /// If the sketch nested operation is active and the presentation is not visualized in the viewer,
156   /// the operation should be always aborted.
157   virtual void onFeatureTriggered();
158
159   /// Slolt called on object display
160   /// \param theObject a data object
161   /// \param theAIS a presentation object
162   virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
163
164   /// Called on transformation in current viewer
165   /// \param theTrsfType type of tranformation
166   void onViewTransformed(int theTrsfType = 2);
167
168 protected slots:
169   /// Called when previous operation is finished
170   virtual void onSelectionChanged();
171
172   /// SLOT, that is called by key release in the viewer.
173   /// \param theWnd a view window
174   /// \param theEvent the key event
175   void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
176
177   /// SLOT, that is called by enter key released
178   /// Set a specific type of restarting the current operation
179   void onEnterReleased();
180
181   /// SLOT, that is called by the current operation filling with the preselection.
182   /// It commits the operation of it is can be committed
183   void onOperationActivatedByPreselection();
184
185  protected:
186   /// Register validators for this module
187   virtual void registerValidators();
188
189   /// Register selection filters for this module
190   virtual void registerFilters();
191
192   /// Register properties of this module
193   virtual void registerProperties();
194
195  private slots:
196    /// Processing of vertex selected
197    void onVertexSelected();
198
199    void onTreeViewDoubleClick(const QModelIndex&);
200
201  private:
202   /// Breaks sequense of automatically resterted operations
203   void breakOperationSequence();
204
205   //! Delete features
206   virtual bool deleteObjects();
207
208  private:
209    QString myLastOperationId;
210    FeaturePtr myLastFeature;
211
212    // Automatical restarting mode flag
213    RestartingMode myRestartingMode;
214
215   SelectMgr_ListOfFilter mySelectionFilters;
216
217   PartSet_SketcherMgr* mySketchMgr;
218
219   PartSet_MenuMgr* myMenuMgr;
220
221   int myVisualLayerId;
222
223   PartSet_DocumentDataModel* myDataModel;
224 };
225
226 #endif