1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_SketcherMgr.h
4 // Created: 19 Dec 2014
5 // Author: Vitaly SMETANNIKOV
7 #ifndef PartSet_SketcherMgr_H
8 #define PartSet_SketcherMgr_H
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Attribute.h>
14 #include <ModelAPI_CompositeFeature.h>
16 #include <ModuleBase_ViewerFilters.h>
17 #include <ModuleBase_Definitions.h>
19 #include <GeomAPI_Pln.h>
20 #include <SelectMgr_IndexedMapOfOwner.hxx>
26 class ModuleBase_IViewWindow;
27 class ModuleBase_Operation;
32 * A class for management of sketch operations
34 class PARTSET_EXPORT PartSet_SketcherMgr : public QObject
38 PartSet_SketcherMgr(PartSet_Module* theModule);
40 virtual ~PartSet_SketcherMgr();
42 static QStringList sketchOperationIdList();
44 /// Launches the operation from current highlighting
47 // Returns current Sketch feature/ Returns NULL if there is no launched sketch operation
48 CompositeFeaturePtr activeSketch() const { return myCurrentSketch; }
50 /// Starts sketch operation
51 void startSketch(ModuleBase_Operation* theOperation);
53 /// Stops sketch operation
54 void stopSketch(ModuleBase_Operation* theOperation);
57 void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
61 void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*);
62 void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*);
63 void onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*);
64 void onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*);
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);
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);
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);
100 PartSet_Module* myModule;
104 double myCurX, myCurY;
106 CompositeFeaturePtr myCurrentSketch;
107 QList<FeaturePtr> myEditingFeatures;
108 QList<AttributePtr> myEditingAttr;
110 Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;