]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.h
Salome HOME
Issue #283 All sketcher commands are disabled until sketcher plane is selected
[modules/shaper.git] / src / PartSet / PartSet_Module.h
1 #ifndef PartSet_Module_H
2 #define PartSet_Module_H
3
4 #include "PartSet.h"
5
6 #include <ModuleBase_IModule.h>
7 #include <ModuleBase_Definitions.h>
8 #include <ModuleBase_ViewerFilters.h>
9 #include <XGUI_Command.h>
10 #include <ModelAPI_Feature.h>
11 #include <ModelAPI_CompositeFeature.h>
12
13 #include <StdSelect_FaceFilter.hxx>
14 #include <TopoDS_Shape.hxx>
15
16 #include <QMap>
17 #include <QObject>
18
19 #include <string>
20
21 #include <memory>
22
23 class ModuleBase_Operation;
24 class ModuleBase_IViewWindow;
25
26 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
27 {
28 Q_OBJECT
29
30  public:
31   PartSet_Module(ModuleBase_IWorkshop* theWshop);
32   virtual ~PartSet_Module();
33
34   /// Creates custom widgets for property panel
35   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
36                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,
37                                       QList<ModuleBase_ModelWidget*>& theModelWidgets);
38
39   /// Call back forlast tuning of property panel before operation performance
40   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
41
42   QStringList sketchOperationIdList() const;
43
44 protected slots:
45   /// Called when previous operation is finished
46   virtual void onOperationComitted(ModuleBase_Operation* theOperation);
47
48   virtual void onOperationAborted(ModuleBase_Operation* theOperation);
49
50   virtual void onOperationStarted(ModuleBase_Operation* theOperation);
51
52   virtual void onOperationStopped(ModuleBase_Operation* theOperation);
53
54   /// Called when previous operation is finished
55   virtual void onSelectionChanged();
56
57   /// SLOT, that is called by mouse press in the viewer.
58   /// The mouse released point is sent to the current operation to be processed.
59   /// \param theEvent the mouse event
60   void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
61
62   /// SLOT, that is called by mouse release in the viewer.
63   /// The mouse released point is sent to the current operation to be processed.
64   /// \param theEvent the mouse event
65   virtual void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
66   
67   /// SLOT, that is called by mouse move in the viewer.
68   /// The mouse moved point is sent to the current operation to be processed.
69   /// \param theEvent the mouse event
70   virtual void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
71
72   /// Launches the operation from current highlighting
73   void launchEditing();
74
75  protected:
76   /// Returns new instance of operation object (used in createOperation for customization)
77   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
78
79   /// Register validators for this module
80   virtual void registerValidators();
81
82  private slots:
83    void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
84
85  private:
86    /// Converts mouse position to 2d coordinates. 
87    /// Member myCurrentSketch has to be correctly defined
88   void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
89                   double& theX, double& theY);
90
91   /// Breaks sequense of automatically resterted operations
92   void breakOperationSequence();
93
94  private:
95    QString myLastOperationId;
96    FeaturePtr myLastFeature;
97
98    bool myIsDragging;
99    bool myDragDone;
100
101    // Automatical restarting mode flag
102    bool myRestartingMode;
103
104    double myCurX, myCurY;
105    CompositeFeaturePtr myCurrentSketch;
106    QList<FeaturePtr> myEditingFeatures;
107 };
108
109 #endif