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;
21 /// \ingroup PartSet_SketcherReetntrantMgr
22 /// It provides reentrant create operations in sketch, that is when all inputs are valid,
23 /// automatic validation of the creation and switch the created entity to edit mode
24 /// ('internal' edit operation),
25 /// with the ability to simultaneously create the next entity of same type (re-entrance of the operation).
26 /// OK valids the current edition and exits from the operation (no re-entrance).
27 /// Cancel removes (undo) the entity currently edited and exits from the operation (no re-entrance).
28 class PARTSET_EXPORT PartSet_SketcherReetntrantMgr : public QObject
32 /// Enumeration to specify the restart operation properties.
34 RM_None, /// the operation should not be restarted
35 RM_Forbided, /// the operation should not be restarted after there is no active widget
36 RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
37 RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
42 /// \param theParent a parent object
43 PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop);
44 virtual ~PartSet_SketcherReetntrantMgr();
47 /// If the internal edit operation is started, this is the first widget of the operation
48 ModuleBase_ModelWidget* activeWidget() const;
50 /// Restarts sketcher operation automatically. If the commited operation is created, it starts
51 /// an 'internal' edit operation for the created feature. If an 'internal' operation is committed,
52 /// a create operation for a new feature with the current feature kind is started.
53 /// Some internal flags are taken into accout, such as whether the previous feature should be
54 /// used for initialization of created one or whether the restart of operation is forbidden.
55 /// \param theOperation a committed operation
56 /// \return true if an operation restarted
57 bool operationCommitted(ModuleBase_Operation* theOperation);
59 /// \param theOperation a committed operation
60 void operationAborted(ModuleBase_Operation* theOperation);
62 /// Return true if the manager processes the mouse move event
63 /// It happens if the current operation is an internal edit operation and the first
64 /// control can be filled by the mouse move event. The operation is committed.
65 /// \return true if operation is committed.
66 bool processMouseMoved();
68 /// Return true if the manager processes the mouse press event
69 /// \return true if the current operation is an internal edit operation.
70 bool processMousePressed();
72 /// Return true if the manager processes the mouse enter event
73 /// It happens if the current operation is an internal edit operation.
74 /// The operation is committed.
75 /// \return true if operation is committed.
76 bool processMouseReleased();
78 /// Activates the operation widgets relatively the internal reentrant flags
79 void propertyPanelDefined(ModuleBase_Operation* theOperation);
81 /// It is called by no more widget signal emitted by property panel
82 /// Set a specific flag to restart the sketcher operation
83 void noMoreWidgets(const std::string& thePreviousAttributeID);
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 void onInternalActivateFirstWidgetSelection();
100 /// Returns true if the current operation is a sketch or a nested sketch operation
101 bool isActiveMgr() const;
103 /// Breaks sequense of automatically resterted operations
104 void breakOperationSequence();
106 /// Returns the workshop
107 XGUI_Workshop* workshop() const;
109 /// Returns the workshop module
110 PartSet_Module* module() const;
113 ModuleBase_IWorkshop* myWorkshop; /// the workshop
115 bool myIsInternalEditOperation; /// true when the 'internal' edit is started
117 std::string myLastOperationId;
118 FeaturePtr myLastFeature;
120 std::string myPreviousAttributeID;
121 RestartingMode myRestartingMode; /// Automatical restarting mode flag