Salome HOME
A sketcher operations manager is created
[modules/shaper.git] / src / PartSet / PartSet_SketcherMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        PartSet_SketcherMgr.h
4 // Created:     19 Dec 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef PartSet_SketcherMgr_H
8 #define PartSet_SketcherMgr_H
9
10 #include "PartSet.h"
11
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Attribute.h>
14 #include <ModelAPI_CompositeFeature.h>
15
16 #include <ModuleBase_ViewerFilters.h>
17
18 #include <GeomAPI_Pln.h>
19
20 #include <QObject>
21 #include <QList>
22
23 class PartSet_Module;
24 class ModuleBase_IViewWindow;
25 class ModuleBase_Operation;
26 class QMouseEvent;
27
28
29 /**
30 * A class for management of sketch operations
31 */
32 class PARTSET_EXPORT PartSet_SketcherMgr : public QObject
33 {
34   Q_OBJECT
35 public:
36   PartSet_SketcherMgr(PartSet_Module* theModule);
37
38   virtual ~PartSet_SketcherMgr();
39
40   static QStringList sketchOperationIdList();
41
42   /// Launches the operation from current highlighting
43   void launchEditing();
44
45   // Returns current Sketch feature/ Returns NULL if there is no launched sketch operation
46   CompositeFeaturePtr activeSketch() const { return myCurrentSketch; }
47
48   /// Starts sketch operation
49   void startSketch(ModuleBase_Operation* theOperation);
50
51   /// Stops sketch operation
52   void stopSketch(ModuleBase_Operation* theOperation);
53
54 public slots:
55   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
56
57
58 private slots:
59   void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*);
60   void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*);
61   void onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*);
62   void onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*);
63
64 private:
65    /// Converts mouse position to 2d coordinates. 
66    /// Member myCurrentSketch has to be correctly defined
67   void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
68                   double& theX, double& theY);
69
70
71 private:
72   PartSet_Module* myModule;
73
74   bool myIsDragging;
75   bool myDragDone;
76   double myCurX, myCurY;
77
78   CompositeFeaturePtr myCurrentSketch;
79   QList<FeaturePtr> myEditingFeatures;
80   QList<AttributePtr> myEditingAttr;
81
82   Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
83 };
84
85
86 #endif