]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_SketcherReetntrantMgr.h
Salome HOME
1. Circle creation - when 'internal' edit operation is active, the first click should...
[modules/shaper.git] / src / PartSet / PartSet_SketcherReetntrantMgr.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 #ifndef PartSet_SketcherReetntrantMgr_H
4 #define PartSet_SketcherReetntrantMgr_H
5
6 #include "PartSet.h"
7
8 #include <ModelAPI_Feature.h>
9
10 #include <string>
11
12 #include <QObject>
13
14 class ModuleBase_IWorkshop;
15 class ModuleBase_Operation;
16 class ModuleBase_ModelWidget;
17 class ModuleBase_IViewWindow;
18
19 class QMouseEvent;
20
21 class XGUI_Workshop;
22 class PartSet_Module;
23
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
32 {
33 Q_OBJECT
34
35 /// Enumeration to specify the restart operation properties.
36 enum RestartingMode {
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
41 };
42
43 public:
44   /// Constructor
45   /// \param theParent a parent object
46   PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop);
47   virtual ~PartSet_SketcherReetntrantMgr();
48
49 public:
50   /// If the internal edit operation is started, this is the first widget of the operation
51   ModuleBase_ModelWidget* activeWidget() const;
52
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);
61
62   /// \param theOperation a committed operation
63   void operationAborted(ModuleBase_Operation* theOperation);
64
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);
70
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);
74
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);
80
81   /// Activates the operation widgets relatively the internal reentrant flags
82   void propertyPanelDefined(ModuleBase_Operation* theOperation);
83
84
85   /// Processing of vertex selected, if the feature is line, save flags to stop reentrant operation
86   void vertexSelected();
87
88   /// It is called by enter key released
89   /// Set a specific type of restarting the current operation
90   void enterReleased();
91
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();
95
96 private slots:
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();
100
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);
104
105   /// Processing of vertex selected
106   void onVertexSelected();
107
108 private:
109   /// Returns true if the current operation is a sketch or a nested sketch operation
110   bool isActiveMgr() const;
111
112   /// Breaks sequense of automatically resterted operations
113   void breakOperationSequence();
114
115   /// Returns the workshop
116   XGUI_Workshop* workshop() const;
117
118   /// Returns the workshop module
119   PartSet_Module* module() const;
120
121 private:
122   ModuleBase_IWorkshop* myWorkshop; /// the workshop
123
124   bool myIsInternalEditOperation; /// true when the 'internal' edit is started
125
126   std::string myLastOperationId;
127   FeaturePtr myLastFeature;
128
129   std::string myPreviousAttributeID;
130   RestartingMode myRestartingMode;  /// Automatical restarting mode flag
131 };
132
133 #endif