Salome HOME
updated copyright message
[modules/shaper.git] / src / PartSet / PartSet_SketcherReentrantMgr.h
index b430c2389479bcef9a2c1a283dc38d60e28b405c..220120e56844b2a5416d60d84b1ff0543eeb1ac8 100644 (file)
@@ -1,4 +1,21 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #ifndef PartSet_SketcherReentrantMgr_H
 #define PartSet_SketcherReentrantMgr_H
@@ -8,6 +25,7 @@
 #include <ModelAPI_Feature.h>
 
 #include <string>
+#include <memory>
 
 #include <QObject>
 
@@ -22,6 +40,10 @@ class QMouseEvent;
 
 class XGUI_Workshop;
 class PartSet_Module;
+class ModuleBase_ViewerPrs;
+class Events_Message;
+class ModelAPI_Attribute;
+class GeomAPI_Pnt2d;
 
 /// \ingroup PartSet_SketcherReentrantMgr
 /// It provides reentrant create operations in sketch, that is when all inputs are valid,
@@ -51,10 +73,6 @@ public:
   virtual ~PartSet_SketcherReentrantMgr();
 
 public:
-  /// Returns a first widget of the current opeation if the internal edit operation is active
-  /// or return null. If the current widget of the operation is a viewer selector, it returns null.
-  ModuleBase_ModelWidget* internalActiveWidget() const;
-
   /// Return true if the current edit operation is an internal
   bool isInternalEditActive() const;
 
@@ -101,14 +119,33 @@ public:
   /// Returns false if the reentrant mode of the operation is not empty.
   bool canBeCommittedByPreselection();
 
-  /// returns true if an internal edit operation is started
-  /// \return boolean value
-  bool isInternalEditStarted() const;
+  /// Fills reentrant message during restarting operation
+  /// \param theMessage reentrant message
+  void setReentrantMessage(const std::shared_ptr<Events_Message>& theMessage)
+  { myReentrantMessage = theMessage; }
+
+  /// Returnss reentrant message
+  std::shared_ptr<Events_Message> reentrantMessage() const { return myReentrantMessage; }
+
+  /// Put current selection into reentrant message
+  /// \param theMessage a message of reentrant operation
+  void setReentrantPreSelection(const std::shared_ptr<Events_Message>& theMessage);
+
+  bool isAutoConstraints() const { return myIsAutoConstraints; }
+
+
+  bool isLastAutoConstraint(const ObjectPtr& theObj) const;
+
+public slots:
+  /// The slot is called when user checks "Automatic constraints" button
+  /// \param isOn a state of the check box
+  void onAutoConstraints(bool isOn);
+
 
 private slots:
   /// SLOT, that is called by a widget activating in the property panel
   /// If the 'internal' edit operation is started, it activates the first widget selection
-  void onWidgetActivated();
+  //void onWidgetActivated();
 
   /// SLOT, that is called by no more widget signal emitted by property panel
   /// Start an internal edit operation or, if the internal flag is forbided, commits
@@ -162,7 +199,7 @@ private:
   /// \param theSourceFeature a source feature
   /// \param theNewFeature a new feature
   /// \param theSketch an active sketch
-  /// \param isTemporary is used to do not create additional features(e.g. coicidence for line)
+  /// \param isTemporary is used to do not create additional features(e.g. coincidence for line)
   /// \return true is something is copied
   static bool copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
                                       const FeaturePtr& theNewFeature,
@@ -183,19 +220,30 @@ private:
   /// Returns the workshop module
   PartSet_Module* module() const;
 
+  void setInternalActiveWidget(ModuleBase_ModelWidget* theWidget);
+
+  void addConstraints(const FeaturePtr& theFeature);
+
 private:
   ModuleBase_IWorkshop* myWorkshop; /// the workshop
 
   RestartingMode myRestartingMode;  /// automatical restarting mode flag
   bool myIsFlagsBlocked; /// true when reset of flags should not be perfromed
   bool myIsInternalEditOperation; /// true when the 'internal' edit is started
-  bool myIsValueChangedBlocked; /// blocked flag to avoid circling by value changed
 
   FeaturePtr myPreviousFeature; /// feature of the previous operation, which is restarted
   FeaturePtr myInternalFeature;
   QWidget* myInternalWidget;
-  ModuleBase_ModelWidget* myInternalActiveWidget;
   std::string myNoMoreWidgetsAttribute;
+
+  std::shared_ptr<Events_Message> myReentrantMessage; /// message obtained by operation restart
+  ObjectPtr mySelectedObject; /// cashed selected object
+  std::shared_ptr<ModelAPI_Attribute> mySelectedAttribute; /// cashed selected attribute
+  std::shared_ptr<GeomAPI_Pnt2d> myClickedSketchPoint; /// cashed clicked point
+
+  bool myIsAutoConstraints;
+  void* myLastAutoConstraint; //< Stores address of last automatic constraint.
+                              //< Cannot be used as a pointer!!!
 };
 
 #endif