1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 #ifndef PartSet_SketcherReetntrantMgr_H
4 #define PartSet_SketcherReetntrantMgr_H
8 #include <ModelAPI_Feature.h>
14 class ModuleBase_IWorkshop;
15 class ModuleBase_Operation;
16 class ModuleBase_ModelWidget;
17 class ModuleBase_IViewWindow;
24 /// \ingroup PartSet_SketcherReetntrantMgr
25 /// It provides reentrant create operations in sketch, that is when all inputs are valid,
26 /// automatic validation of the creation and switch the created entity to edit mode
27 /// ('internal' edit operation),
28 /// with the ability to simultaneously create the next entity of same type (re-entrance of the operation).
29 /// OK valids the current edition and exits from the operation (no re-entrance).
30 /// Cancel removes (undo) the entity currently edited and exits from the operation (no re-entrance).
31 class PARTSET_EXPORT PartSet_SketcherReetntrantMgr : public QObject
35 /// Enumeration to specify the restart operation properties.
37 RM_None, /// the operation should not be restarted
38 RM_Forbided, /// the operation should not be restarted after there is no active widget
39 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
40 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
45 /// \param theParent a parent object
46 PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop);
47 virtual ~PartSet_SketcherReetntrantMgr();
50 /// If the internal edit operation is started, this is the first widget of the operation
51 ModuleBase_ModelWidget* activeWidget() const;
53 /// Restarts sketcher operation automatically. If the commited operation is created, it starts
54 /// an 'internal' edit operation for the created feature. If an 'internal' operation is committed,
55 /// a create operation for a new feature with the current feature kind is started.
56 /// Some internal flags are taken into accout, such as whether the previous feature should be
57 /// used for initialization of created one or whether the restart of operation is forbidden.
58 /// \param theOperation a committed operation
59 /// \return true if an operation restarted
60 bool operationCommitted(ModuleBase_Operation* theOperation);
62 /// \param theOperation a committed operation
63 void operationAborted(ModuleBase_Operation* theOperation);
65 /// Return true if the manager processes the mouse move event
66 /// It happens if the current operation is an internal edit operation and the first
67 /// control can be filled by the mouse move event. The operation is committed.
68 /// \return true if operation is committed.
69 bool processMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
71 /// Return true if the manager processes the mouse press event
72 /// \return true if the current operation is an internal edit operation.
73 bool processMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
75 /// Return true if the manager processes the mouse enter event
76 /// It happens if the current operation is an internal edit operation.
77 /// The operation is committed.
78 /// \return true if operation is committed.
79 bool processMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
81 /// Activates the operation widgets relatively the internal reentrant flags
82 void propertyPanelDefined(ModuleBase_Operation* theOperation);
85 /// Processing of vertex selected, if the feature is line, save flags to stop reentrant operation
86 void vertexSelected();
88 /// It is called by enter key released
89 /// Set a specific type of restarting the current operation
92 /// It is called by the current operation filling with the preselection.
93 /// Returns false if the reentrant mode of the operation is not empty.
94 bool canBeCommittedByPreselection();
97 /// SLOT, that is called by a widget activating in the property panel
98 /// If the 'internal' edit operation is started, it activates the first control selection
99 void onWidgetActivated();
101 /// SLOT, that is called by no more widget signal emitted by property panel
102 /// Set a specific flag to restart the sketcher operation
103 void onNoMoreWidgets(const std::string& thePreviousAttributeID);
105 /// Processing of vertex selected
106 void onVertexSelected();
109 /// Returns true if the current operation is a sketch or a nested sketch operation
110 bool isActiveMgr() const;
112 /// Breaks sequense of automatically resterted operations
113 void breakOperationSequence();
115 /// Returns the workshop
116 XGUI_Workshop* workshop() const;
118 /// Returns the workshop module
119 PartSet_Module* module() const;
122 ModuleBase_IWorkshop* myWorkshop; /// the workshop
124 bool myIsInternalEditOperation; /// true when the 'internal' edit is started
126 std::string myLastOperationId;
127 FeaturePtr myLastFeature;
129 std::string myPreviousAttributeID;
130 RestartingMode myRestartingMode; /// Automatical restarting mode flag