Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[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_Filters.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 <StdSelect_FaceFilter.hxx>
16 #include <TopoDS_Shape.hxx>
17
18 #include <QMap>
19 #include <QMenu>
20 #include <QObject>
21
22 #include <string>
23
24 #include <memory>
25
26 class ModuleBase_Operation;
27 class ModuleBase_IViewWindow;
28 class PartSet_MenuMgr;
29 class PartSet_SketcherMgr;
30
31 class QAction;
32
33 /**
34 * \ingroup Modules
35 * Implementation of Partset module
36 */
37 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
38 {
39 Q_OBJECT
40
41 /// Enumeration to specify the restart operation properties.
42 enum RestartingMode {
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
47 };
48
49 public:
50   /// Constructor
51   /// \param theWshop a pointer to a workshop
52   PartSet_Module(ModuleBase_IWorkshop* theWshop);
53   virtual ~PartSet_Module();
54
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);
58
59   /// Call back forlast tuning of property panel before operation performance
60   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
61
62
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);
67
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);
72
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);
77
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);
82
83   /// Realizes some functionality by an operation start
84   /// \param theOperation a started operation
85   virtual ModuleBase_Operation* currentOperation() const;
86
87   /// Returns True if there are available Undos and the sketch manager allows undo
88   /// \return the boolean result
89   virtual bool canUndo() const;
90
91   //! Returns True if there are available Redos and the sketch manager allows redo
92   /// \return the boolean result
93   virtual bool canRedo() const;
94
95   /// Returns whether the object can be displayed at the bounds of the active operation.
96   /// Display only current operation results for usual operation and ask the sketcher manager
97   /// if it is a sketch operation
98   /// \param theObject a model object
99   virtual bool canDisplayObject(const ObjectPtr& theObject) const;
100
101   /// Add menu atems for viewer into the given menu
102   /// \param theMenu a popup menu to be shown in the viewer
103   /// \param theStdActions a map of standard actions
104   /// \return true if items are added and there is no necessity to provide standard menu
105   virtual bool addViewerItems(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const;
106
107   /// Returns whether the mouse enter the viewer's window
108   /// \return true if items are added and there is no necessity to provide standard menu
109   bool isMouseOverWindow();
110
111   PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; }
112
113 public slots:
114   /// SLOT, that is called by no more widget signal emitted by property panel
115   /// Set a specific flag to restart the sketcher operation
116   void onNoMoreWidgets();
117
118   /// Slolt called on object display
119   /// \param theObject a data object
120   /// \param theAIS a presentation object
121   virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS);
122
123 protected slots:
124   /// Called when previous operation is finished
125   virtual void onSelectionChanged();
126
127   /// SLOT, that is called by key release in the viewer.
128   /// \param theWnd a view window
129   /// \param theEvent the key event
130   void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
131
132   /// SLOT, that is called by enter key released
133   /// Set a specific type of restarting the current operation
134   void onEnterReleased();
135
136   /// SLOT, that is called by the current operation filling with the preselection.
137   /// It commits the operation of it is can be committed
138   void onOperationActivatedByPreselection();
139
140  protected:
141   /// Register validators for this module
142   virtual void registerValidators();
143
144   /// Register selection filters for this module
145   virtual void registerFilters();
146
147   /// Register properties of this module
148   virtual void registerProperties();
149
150  private slots:
151    /// Processing of vertex selected
152    void onVertexSelected();
153
154    /// Called on transformation in current viewer
155    /// \param theTrsfType type of tranformation
156    void onViewTransformed(int theTrsfType = 2);
157
158  private:
159   /// Breaks sequense of automatically resterted operations
160   void breakOperationSequence();
161
162   //! Delete features
163   virtual bool deleteObjects();
164
165  private:
166    QString myLastOperationId;
167    FeaturePtr myLastFeature;
168
169    // Automatical restarting mode flag
170    RestartingMode myRestartingMode;
171
172   /// A filter which provides selection within a current document or whole PartSet
173   Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
174
175   PartSet_SketcherMgr* mySketchMgr;
176
177   PartSet_MenuMgr* myMenuMgr;
178
179   int myVisualLayerId;
180 };
181
182 #endif