Salome HOME
Edit arc by dragging
[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 #include <ModuleBase_Definitions.h>
18
19 #include <GeomAPI_Pln.h>
20 #include <SelectMgr_IndexedMapOfOwner.hxx>
21
22 #include <QObject>
23 #include <QList>
24
25 class PartSet_Module;
26 class ModuleBase_IViewWindow;
27 class ModuleBase_Operation;
28 class QMouseEvent;
29
30
31 /**
32 * A class for management of sketch operations
33 */
34 class PARTSET_EXPORT PartSet_SketcherMgr : public QObject
35 {
36   Q_OBJECT
37 public:
38   PartSet_SketcherMgr(PartSet_Module* theModule);
39
40   virtual ~PartSet_SketcherMgr();
41
42   static QStringList sketchOperationIdList();
43
44   /// Launches the operation from current highlighting
45   void launchEditing();
46
47   // Returns current Sketch feature/ Returns NULL if there is no launched sketch operation
48   CompositeFeaturePtr activeSketch() const { return myCurrentSketch; }
49
50   /// Starts sketch operation
51   void startSketch(ModuleBase_Operation* theOperation);
52
53   /// Stops sketch operation
54   void stopSketch(ModuleBase_Operation* theOperation);
55
56 public slots:
57   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
58
59
60 private slots:
61   void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*);
62   void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*);
63   void onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*);
64   void onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*);
65
66 private:
67    /// Converts mouse position to 2d coordinates. 
68    /// Member myCurrentSketch has to be correctly defined
69   void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
70                   double& theX, double& theY);
71
72   /// Obtains the current selection of the object in the workshop viewer 
73   /// It includes the selection in all modes of activation, even local context - vertexes, edges
74   /// The result is a list of attributes of the feature of the object
75   /// In addition, it retuns a list of selection modes, where the object is activated
76   /// \param theObject a feature or result object
77   /// \param theSketch a current sketch feature
78   /// \param theWorkshop a workshop to have an access to AIS context and displayer
79   /// \param theSelectedAttributes an out list of selected attributes
80   static void getCurrentSelection(const ObjectPtr& theObject,
81                                   const FeaturePtr& theSketch,
82                                   ModuleBase_IWorkshop* theWorkshop,
83                                   std::list<AttributePtr>& theSelectedAttributes);
84
85   /// Applyes the current selection to the object in the workshop viewer 
86   /// It includes the selection in all modes of activation, even local context - vertexes, edges
87   /// The result is a list of attributes of the feature of the object
88   /// In addition, it retuns a list of selection modes, where the object is activated
89   /// \param theObject a feature or result object
90   /// \param theSketch a current sketch feature
91   /// \param theWorkshop a workshop to have an access to AIS context and displayer
92   /// \param theSelectedAttributes an out list of selected attributes
93   static void getSelectionOwners(const ObjectPtr& theObject,
94                                   const FeaturePtr& theSketch,
95                                   ModuleBase_IWorkshop* theWorkshop,
96                                   const std::list<AttributePtr>& theSelectedAttributes,
97                                   SelectMgr_IndexedMapOfOwner& anOwnersToSelect);
98
99 private:
100   PartSet_Module* myModule;
101
102   bool myIsDragging;
103   bool myDragDone;
104   double myCurX, myCurY;
105
106   CompositeFeaturePtr myCurrentSketch;
107   QList<FeaturePtr> myEditingFeatures;
108   QList<AttributePtr> myEditingAttr;
109
110   Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
111 };
112
113
114 #endif