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