Salome HOME
Issue #1863: Edit multi-lines
[modules/shaper.git] / src / PartSet / PartSet_SketcherReetntrantMgr.h
index 2bdeb8617b18635a05c104bd28e8baeb8b7045ac..647d214eed91f79f0bdac0ac078eea7567c0086c 100755 (executable)
@@ -16,6 +16,8 @@ class ModuleBase_Operation;
 class ModuleBase_ModelWidget;
 class ModuleBase_IViewWindow;
 
+class ModelAPI_CompositeFeature;
+
 class QMouseEvent;
 
 class XGUI_Workshop;
@@ -27,7 +29,8 @@ class PartSet_Module;
 /// ('internal' edit operation), with the ability to simultaneously create the next entity
 /// of same type (re-entrance of the operation).
 /// OK valids the current edition and exits from the operation (no re-entrance).
-/// Cancel removes (undo) the entity currently edited and exits from the operation (no re-entrance).
+/// Cancel removes (undo) the entity currently edited and 
+/// exits from the operation (no re-entrance).
 class PARTSET_EXPORT PartSet_SketcherReetntrantMgr : public QObject
 {
 Q_OBJECT
@@ -36,13 +39,14 @@ Q_OBJECT
 enum RestartingMode {
   RM_None, /// the operation should not be restarted
   RM_Forbided, /// the operation should not be restarted after there is no active widget
-  RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
+  RM_LastFeatureUsed, /// the operation is restarted and use 
+                      /// the previous feature for own initialization
   RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
 };
 
 public:
   /// Constructor
-  /// \param theParent a parent object
+  /// \param theWorkshop a workshop instance
   PartSet_SketcherReetntrantMgr(ModuleBase_IWorkshop* theWorkshop);
   virtual ~PartSet_SketcherReetntrantMgr();
 
@@ -54,6 +58,9 @@ public:
   /// Return true if the current edit operation is an internal
   bool isInternalEditActive() const;
 
+  /// Stop internal edit if the operation feature is invalid
+  void updateInternalEditActiveState();
+
   /// if the internal flags allow it and the manager is active, it starts an internal edit operation
   /// for the created operation.
   /// \param thePreviousAttributeID an index of the previous active attribute
@@ -94,6 +101,10 @@ 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;
+
 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
@@ -120,7 +131,8 @@ private:
   /// Sets the focus to the last control of the property panel and activates selection
   /// of the first widget to can select first value of the next create operation
   /// \param thePreviousAttributeID an index of the previous attribute to set focus to this widget
-  void startInternalEdit(const std::string& thePreviousAttributeID);
+  /// \return true if it is started
+  bool startInternalEdit(const std::string& thePreviousAttributeID);
 
   /// Disconnects this manager from operation signals, deactivate selection of the first control
   /// in the viewer.
@@ -129,9 +141,35 @@ private:
   /// Commits the current operation and launches a new with the commited operation feature index
   void restartOperation();
 
+  /// Creates an internal feature and controls to process it
+  void createInternalFeature();
+
+  /// A pair method for an internal creation to remove it and clear all created controls
+  void deleteInternalFeature();
+
   /// Breaks sequense of automatically resterted operations
   void resetFlags();
 
+  /// Copy some feature specific attributes from the source to a new feature
+  /// This is type for Circle and Arc features
+  /// \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)
+  /// \return true is something is copied
+  static bool copyReetntrantAttributes(const FeaturePtr& theSourceFeature,
+                                      const FeaturePtr& theNewFeature,
+                                      const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
+                                      const bool isTemporary = false);
+
+  /// Checks whethe the feature of the given operation has kind an arc and the arc type is tangent
+  bool isTangentArc(ModuleBase_Operation* theOperation,
+                    const std::shared_ptr<ModelAPI_CompositeFeature>& /*theSketch*/) const;
+
+  /// Accept All action is enabled if an internal edit is started. 
+  /// It updates the state of the button
+  void updateAcceptAllAction();
+
   /// Returns the workshop
   XGUI_Workshop* workshop() const;
 
@@ -144,6 +182,12 @@ private:
   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
+
+  FeaturePtr myPreviousFeature; /// feature of the previous operation, which is restarted
+  FeaturePtr myInternalFeature;
+  QWidget* myInternalWidget;
+  ModuleBase_ModelWidget* myInternalActiveWidget;
+  std::string myNoMoreWidgetsAttribute;
 };
 
 #endif