SHAPER  9.12.0
PartSet_SketcherReentrantMgr.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef PartSet_SketcherReentrantMgr_H
21 #define PartSet_SketcherReentrantMgr_H
22 
23 #include "PartSet.h"
24 
25 #include <ModelAPI_Feature.h>
26 
27 #include <string>
28 #include <memory>
29 
30 #include <QObject>
31 
36 
38 
39 class QMouseEvent;
40 
41 class XGUI_Workshop;
42 class PartSet_Module;
44 class Events_Message;
45 class ModelAPI_Attribute;
46 class GeomAPI_Pnt2d;
47 
56 class PARTSET_EXPORT PartSet_SketcherReentrantMgr : public QObject
57 {
58 Q_OBJECT
59 
61 enum RestartingMode {
62  RM_None,
63  RM_Forbided,
64  RM_LastFeatureUsed,
66  RM_EmptyFeatureUsed
67 };
68 
69 public:
74 
75 public:
77  bool isInternalEditActive() const;
78 
80  void updateInternalEditActiveState();
81 
85  //bool restartOperation(const std::string& thePreviousAttributeID);
86  bool processEnter(const std::string& thePreviousAttributeID);
87 
90  void operationStarted(ModuleBase_Operation* theOperation);
91 
95  bool operationCommitted(ModuleBase_Operation* theOperation);
96 
99  void operationAborted(ModuleBase_Operation* theOperation);
100 
105  bool processMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
106 
109  bool processMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
110 
116  bool processMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
117 
120  bool canBeCommittedByPreselection();
121 
124  void setReentrantMessage(const std::shared_ptr<Events_Message>& theMessage)
125  { myReentrantMessage = theMessage; }
126 
128  std::shared_ptr<Events_Message> reentrantMessage() const { return myReentrantMessage; }
129 
132  void setReentrantPreSelection(const std::shared_ptr<Events_Message>& theMessage);
133 
134  bool isAutoConstraints() const { return myIsAutoConstraints; }
135 
136 
137  bool isLastAutoConstraint(const ObjectPtr& theObj) const;
138 
139 public slots:
142  void onAutoConstraints(bool isOn);
143 
144 
145 private slots:
148  //void onWidgetActivated();
149 
154  void onNoMoreWidgets(const std::string& thePreviousAttributeID);
155 
158  void onVertexSelected();
159 
165  void onAfterValuesChangedInPropertyPanel();
166 
169  void onBeforeStopped();
170 
171 private:
173  bool isActiveMgr() const;
174 
179  bool startInternalEdit(const std::string& thePreviousAttributeID);
180 
183  void beforeStopInternalEdit();
184 
186  void restartOperation();
187 
189  void createInternalFeature();
190 
192  void deleteInternalFeature();
193 
195  void resetFlags();
196 
204  static bool copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
205  const FeaturePtr& theNewFeature,
206  const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
207  const bool isTemporary = false);
208 
210  bool isTangentArc(ModuleBase_Operation* theOperation,
211  const std::shared_ptr<ModelAPI_CompositeFeature>& /*theSketch*/) const;
212 
215  void updateAcceptAllAction();
216 
218  XGUI_Workshop* workshop() const;
219 
221  PartSet_Module* module() const;
222 
223  void setInternalActiveWidget(ModuleBase_ModelWidget* theWidget);
224 
225  void addConstraints(const FeaturePtr& theFeature);
226 
227 private:
228  ModuleBase_IWorkshop* myWorkshop;
229 
230  RestartingMode myRestartingMode;
231  bool myIsFlagsBlocked;
232  bool myIsInternalEditOperation;
233 
234  FeaturePtr myPreviousFeature;
235  FeaturePtr myInternalFeature;
236  QWidget* myInternalWidget;
237  std::string myNoMoreWidgetsAttribute;
238 
239  std::shared_ptr<Events_Message> myReentrantMessage;
240  ObjectPtr mySelectedObject;
241  std::shared_ptr<ModelAPI_Attribute> mySelectedAttribute;
242  std::shared_ptr<GeomAPI_Pnt2d> myClickedSketchPoint;
243 
244  bool myIsAutoConstraints;
245  void* myLastAutoConstraint; //< Stores address of last automatic constraint.
246  //< Cannot be used as a pointer!!!
247 };
248 
249 #endif
Message for communication between sender and listener of event.
Definition: Events_Message.h:65
2D point defined by two coordinates
Definition: GeomAPI_Pnt2d.h:36
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34
Feature that consists of other features: like sketcher with edges inside.
Definition: ModelAPI_CompositeFeature.h:33
Interface to ViewWindow object which contains 3d scene.
Definition: ModuleBase_IViewWindow.h:34
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
An abstract custom widget class.
Definition: ModuleBase_ModelWidget.h:60
Base class for all operations.
Definition: ModuleBase_Operation.h:53
Presentation.
Definition: ModuleBase_ViewerPrs.h:37
Implementation of Partset module.
Definition: PartSet_Module.h:69
It provides reentrant create operations in sketch, that is when all inputs are valid,...
Definition: PartSet_SketcherReentrantMgr.h:57
std::shared_ptr< Events_Message > reentrantMessage() const
Returnss reentrant message.
Definition: PartSet_SketcherReentrantMgr.h:128
void setReentrantMessage(const std::shared_ptr< Events_Message > &theMessage)
Fills reentrant message during restarting operation.
Definition: PartSet_SketcherReentrantMgr.h:124
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:82
XGUI_Workshop * workshop(ModuleBase_IWorkshop *theWorkshop)
Definition: XGUI_Tools.cpp:244