Salome HOME
Issue #1474: Fix the error
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchCreator.h
index 8ccb24b25df4c4397b739c0f07d0912f2c834a1f..57ba50ecaf5507ac377d891ce416b1c353bf854c 100644 (file)
@@ -12,7 +12,6 @@
 #include <ModuleBase_WidgetSelector.h>
 
 class QLabel;
-class QLineEdit;
 class PartSet_Module;
 class ModelAPI_Tools;
 class ModuleBase_Operation;
@@ -56,7 +55,7 @@ public:
   /// This value should be processed in the widget according to the needs
   /// \param theValues the wrapped selection values
   /// \param theToValidate a validation of the values flag
-  virtual bool setSelection(QList<ModuleBase_ViewerPrs>& theValues,
+  virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
                             const bool theToValidate);
 
   /// Editing mode depends on mode of current operation. This value is defined by it.
@@ -68,18 +67,21 @@ public:
   /// restored.The valid/invalid value is cashed.
   /// \param theValue a selected presentation in the view
   /// \return a boolean value
-  virtual bool isValidSelection(const ModuleBase_ViewerPrs& theValue);
-
-  /// Check if the current and the parent operations are a composite. If the parent operation contains
-  /// attribute selection list, the method returns false if it is invalid in this attibute validator
-  /// \param theWorkshop a current workshop
-  /// \return boolean value
-  static bool canCommitCurrentSketch(ModuleBase_IWorkshop* theWorkshop);
+  virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
 
 protected:
+  /// If there is no operation in current session, start operation for modify parameters
+  /// \return true if the operation was not opened
+  void openExtrusionTransaction();
+
+  /// Checks whether the selection presentation contains preview planes
+  /// \param theValue a selection information
+  /// \return a boolean value
+  virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
+
   /// Saves the internal parameters to the given feature
   /// \return True in success
-  virtual bool storeValueCustom() const;
+  virtual bool storeValueCustom();
 
   virtual bool restoreValueCustom();
 
@@ -114,6 +116,10 @@ private:
   /// \return boolean value
   bool isSelectionMode() const;
 
+  /// Returns true if the current composite feature contains at least one sub-object
+  /// \return boolean value
+  bool hasSubObjects() const;
+
 private slots:
   void onResumed(ModuleBase_Operation* theOp);
 
@@ -121,7 +127,21 @@ private:
   /// Append new Sketch, set the selected plane for the sketch and start Edit operation.
   /// \param theValues a selection list
   /// \return true if the sketch is started
-  bool startSketchOperation(const QList<ModuleBase_ViewerPrs>& theValues);
+  bool startSketchOperation(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
+
+  /// Sets the sub-object to list of base.
+  static void setSketchObjectToList(const CompositeFeaturePtr& theFeature,
+                                    const AttributePtr& theAttribute);
+
+  /// Calls validator for attribute list and warn if it is not valid
+  /// \return true if validation succeed
+  bool validateSelectionList() const;
+
+  /// Change enable state of controls in the model widget by the attribute identifier
+  /// \param theModelWidget a model widget
+  /// \param theEnabled a state if the controls should be enabled/disabled
+  void setEnabledModelWidget(ModuleBase_ModelWidget* theModelWidget,
+                             const bool theEnabled);
 
 private:
   std::string myAttributeListID;
@@ -135,9 +155,6 @@ private:
   /// Label of the widget
   QLabel* myLabel;
 
-  /// Input control of the widget
-  QLineEdit* myTextLine;
-
   /// List of accepting shapes types
   QStringList myShapeTypes;