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>
15 #include <ModelAPI_Result.h>
17 #include <ModuleBase_ViewerFilters.h>
18 #include <ModuleBase_Definitions.h>
20 #include <GeomAPI_Pln.h>
21 #include <SelectMgr_IndexedMapOfOwner.hxx>
27 class ModuleBase_IViewWindow;
28 class ModuleBase_Operation;
33 * A class for management of sketch operations
35 class PARTSET_EXPORT PartSet_SketcherMgr : public QObject
39 PartSet_SketcherMgr(PartSet_Module* theModule);
41 virtual ~PartSet_SketcherMgr();
43 static QStringList sketchOperationIdList();
45 /// Launches the operation from current highlighting
48 // Returns current Sketch feature/ Returns NULL if there is no launched sketch operation
49 CompositeFeaturePtr activeSketch() const { return myCurrentSketch; }
51 /// Starts sketch operation
52 void startSketch(ModuleBase_Operation* theOperation);
54 /// Stops sketch operation
55 void stopSketch(ModuleBase_Operation* theOperation);
58 void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
62 void onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*);
63 void onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*);
64 void onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*);
65 void onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*);
68 /// Converts mouse position to 2d coordinates.
69 /// Member myCurrentSketch has to be correctly defined
70 void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
71 double& theX, double& theY);
73 /// Obtains the current selection of the object in the workshop viewer
74 /// It includes the selection in all modes of activation, even local context - vertexes, edges
75 /// The result is a list of attributes of the feature of the object
76 /// In addition, it retuns a list of selection modes, where the object is activated
77 /// \param theObject a feature or result object
78 /// \param theSketch a current sketch feature
79 /// \param theWorkshop a workshop to have an access to AIS context and displayer
80 /// \param theSelectedAttributes an out list of selected attributes
81 /// \param theSelectedAttributes an out list of selected results
82 static void getCurrentSelection(const ObjectPtr& theObject,
83 const FeaturePtr& theSketch,
84 ModuleBase_IWorkshop* theWorkshop,
85 std::list<AttributePtr>& theSelectedAttributes,
86 std::list<ResultPtr>& theSelectedResults);
88 /// Applyes the current selection to the object in the workshop viewer
89 /// It includes the selection in all modes of activation, even local context - vertexes, edges
90 /// The result is a list of attributes of the feature of the object
91 /// In addition, it retuns a list of selection modes, where the object is activated
92 /// \param theObject a feature or result object
93 /// \param theSketch a current sketch feature
94 /// \param theWorkshop a workshop to have an access to AIS context and displayer
95 /// \param theSelectedAttributes an out list of selected attributes
96 static void getSelectionOwners(const ObjectPtr& theObject,
97 const FeaturePtr& theSketch,
98 ModuleBase_IWorkshop* theWorkshop,
99 const std::list<AttributePtr>& theSelectedAttributes,
100 const std::list<ResultPtr>& theSelectedResults,
101 SelectMgr_IndexedMapOfOwner& anOwnersToSelect);
104 PartSet_Module* myModule;
108 double myCurX, myCurY;
110 CompositeFeaturePtr myCurrentSketch;
111 QList<FeaturePtr> myEditingFeatures;
112 QList<AttributePtr> myEditingAttr;
114 Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;