]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.h
Salome HOME
1837a2c8ab20a46f61075997d92dd11d1fe3d62f
[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 <QObject>
20
21 #include <string>
22
23 #include <memory>
24
25 class ModuleBase_Operation;
26 class ModuleBase_IViewWindow;
27
28 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
29 {
30 Q_OBJECT
31
32 /// Enumeration to specify the restart operation properties.
33 enum RestartingMode {
34   RM_None, /// the operation should not be restarted
35   RM_Forbided, /// the operation should not be restarted after there is no active widget
36   RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
37   RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
38 };
39
40 public:
41   PartSet_Module(ModuleBase_IWorkshop* theWshop);
42   virtual ~PartSet_Module();
43
44   /// Creates custom widgets for property panel
45   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
46                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,
47                                       QList<ModuleBase_ModelWidget*>& theModelWidgets);
48
49   /// Call back forlast tuning of property panel before operation performance
50   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
51
52   QStringList sketchOperationIdList() const;
53
54 public slots:
55   /// SLOT, that is called by no more widget signal emitted by property panel
56   /// Set a specific flag to restart the sketcher operation
57   void onNoMoreWidgets();
58
59 protected slots:
60   /// Called when previous operation is finished
61   virtual void onOperationComitted(ModuleBase_Operation* theOperation);
62
63   virtual void onOperationAborted(ModuleBase_Operation* theOperation);
64
65   virtual void onOperationStarted(ModuleBase_Operation* theOperation);
66
67   virtual void onOperationStopped(ModuleBase_Operation* theOperation);
68
69   /// Called when previous operation is finished
70   virtual void onSelectionChanged();
71
72   /// SLOT, that is called by mouse press in the viewer.
73   /// \param theWnd - the window where the event happens
74   /// \param theEvent the mouse event
75   void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
76
77   /// SLOT, that is called by mouse release in the viewer.
78   /// \param theWnd - the window where the event happens
79   /// \param theEvent the mouse event
80   void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
81   
82   /// SLOT, that is called by mouse move in the viewer.
83   /// \param theWnd - the window where the event happens
84   /// \param theEvent the mouse event
85   void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
86
87   /// SLOT, that is called by mouse double click in the viewer.
88   /// \param theWnd - the window where the event happens
89   /// \param theEvent the mouse event
90   void onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
91
92   /// SLOT, that is called by key release in the viewer.
93   /// The mouse moved point is sent to the current operation to be processed.
94   /// \param theEvent the key event
95   void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
96
97   /// SLOT, that is called by enter key released
98   /// Set a specific type of restarting the current operation
99   void onEnterReleased();
100
101   /// SLOT, that is called by the current operation filling with the preselection.
102   /// It commits the operation of it is can be committed
103   void onOperationActivatedByPreselection();
104
105   /// Launches the operation from current highlighting
106   void launchEditing();
107
108  protected:
109   /// Returns new instance of operation object (used in createOperation for customization)
110   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
111
112   /// Register validators for this module
113   virtual void registerValidators();
114
115   /// Register selection filters for this module
116   virtual void registerFilters();
117
118  private slots:
119    void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
120
121    void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
122
123  private:
124    /// Converts mouse position to 2d coordinates. 
125    /// Member myCurrentSketch has to be correctly defined
126   void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
127                   double& theX, double& theY);
128
129   /// Breaks sequense of automatically resterted operations
130   void breakOperationSequence();
131
132  private:
133    QString myLastOperationId;
134    FeaturePtr myLastFeature;
135
136    bool myIsDragging;
137    bool myDragDone;
138
139    // Automatical restarting mode flag
140    RestartingMode myRestartingMode;
141
142    double myCurX, myCurY;
143    CompositeFeaturePtr myCurrentSketch;
144    QList<FeaturePtr> myEditingFeatures;
145    QList<AttributePtr> myEditingAttr;
146
147    Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
148   /// A filter which provides selection within a current document or whole PartSet
149   Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
150 };
151
152 #endif