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);
84 /// It is called by no more widget signal emitted by property panel
85 /// Set a specific flag to restart the sketcher operation
86 void noMoreWidgets(const std::string& thePreviousAttributeID);
88 /// Processing of vertex selected, if the feature is line, save flags to stop reentrant operation
89 void vertexSelected();
91 /// It is called by enter key released
92 /// Set a specific type of restarting the current operation
95 /// It is called by the current operation filling with the preselection.
96 /// Returns false if the reentrant mode of the operation is not empty.
97 bool canBeCommittedByPreselection();
100 void onInternalActivateFirstWidgetSelection();
103 /// Returns true if the current operation is a sketch or a nested sketch operation
104 bool isActiveMgr() const;
106 /// Breaks sequense of automatically resterted operations
107 void breakOperationSequence();
109 /// Returns the workshop
110 XGUI_Workshop* workshop() const;
112 /// Returns the workshop module
113 PartSet_Module* module() const;
116 ModuleBase_IWorkshop* myWorkshop; /// the workshop
118 bool myIsInternalEditOperation; /// true when the 'internal' edit is started
120 std::string myLastOperationId;
121 FeaturePtr myLastFeature;
123 std::string myPreviousAttributeID;
124 RestartingMode myRestartingMode; /// Automatical restarting mode flag