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