]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.h
Salome HOME
afefc6a0af6e6afccb4c93a763e200103f8f2a83
[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 #include "PartSet_SketcherMgr.h"
9
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>
15
16 //#include <StdSelect_FaceFilter.hxx>
17 #include <TopoDS_Shape.hxx>
18
19 #include <QMap>
20 #include <QObject>
21
22 #include <string>
23
24 #include <memory>
25
26 class ModuleBase_Operation;
27 class ModuleBase_IViewWindow;
28
29 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
30 {
31 Q_OBJECT
32
33 /// Enumeration to specify the restart operation properties.
34 enum RestartingMode {
35   RM_None, /// the operation should not be restarted
36   RM_Forbided, /// the operation should not be restarted after there is no active widget
37   RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
38   RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
39 };
40
41 public:
42   PartSet_Module(ModuleBase_IWorkshop* theWshop);
43   virtual ~PartSet_Module();
44
45   /// Creates custom widgets for property panel
46   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
47                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,
48                                       QList<ModuleBase_ModelWidget*>& theModelWidgets);
49
50   /// Call back forlast tuning of property panel before operation performance
51   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
52
53
54   /// Realizes some functionality by an operation start
55   /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
56   /// \param theOperation a started operation
57   virtual void operationStarted(ModuleBase_Operation* theOperation);
58
59   /// Realizes some functionality by an operation commit
60   /// Restarts sketcher operation automatically of it is necessary
61   /// \param theOperation a committed operation
62   virtual void operationCommitted(ModuleBase_Operation* theOperation);
63
64   /// Realizes some functionality by an operation abort
65   /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
66   /// \param theOperation an aborted operation
67   virtual void operationAborted(ModuleBase_Operation* theOperation);
68
69   /// Realizes some functionality by an operation stop
70   /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
71   /// \param theOperation a stopped operation
72   virtual void operationStopped(ModuleBase_Operation* theOperation);
73
74   /// Returns whether the object can be displayed at the bounds of the active operation.
75   /// Display only current operation results for usual operation and ask the sketcher manager
76   /// if it is a sketch operation
77   /// \param theObject a model object
78   virtual bool canDisplayObject(const ObjectPtr& theObject) const;
79
80 public slots:
81   /// SLOT, that is called by no more widget signal emitted by property panel
82   /// Set a specific flag to restart the sketcher operation
83   void onNoMoreWidgets();
84
85 protected slots:
86   /// Called when previous operation is finished
87   virtual void onSelectionChanged();
88
89   /// SLOT, that is called by mouse press in the viewer.
90   /// \param theWnd - the window where the event happens
91   /// \param theEvent the mouse event
92   //void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
93
94   /// SLOT, that is called by mouse release in the viewer.
95   /// \param theWnd - the window where the event happens
96   /// \param theEvent the mouse event
97   //void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
98   
99   /// SLOT, that is called by mouse move in the viewer.
100   /// \param theWnd - the window where the event happens
101   /// \param theEvent the mouse event
102   //void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
103
104   /// SLOT, that is called by mouse double click in the viewer.
105   /// \param theWnd - the window where the event happens
106   /// \param theEvent the mouse event
107   //void onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
108
109   /// SLOT, that is called by key release in the viewer.
110   /// The mouse moved point is sent to the current operation to be processed.
111   /// \param theEvent the key event
112   void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
113
114   /// SLOT, that is called by enter key released
115   /// Set a specific type of restarting the current operation
116   void onEnterReleased();
117
118   /// SLOT, that is called by the current operation filling with the preselection.
119   /// It commits the operation of it is can be committed
120   void onOperationActivatedByPreselection();
121
122
123  protected:
124   /// Register validators for this module
125   virtual void registerValidators();
126
127   /// Register selection filters for this module
128   virtual void registerFilters();
129
130  private slots:
131    void onVertexSelected();
132
133
134  private:
135
136   /// Breaks sequense of automatically resterted operations
137   void breakOperationSequence();
138
139  private:
140    QString myLastOperationId;
141    FeaturePtr myLastFeature;
142
143    // Automatical restarting mode flag
144    RestartingMode myRestartingMode;
145
146   /// A filter which provides selection within a current document or whole PartSet
147   Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
148
149   PartSet_SketcherMgr* mySketchMgr;
150 };
151
152 #endif