Salome HOME
Issue #2602: Check selection with validators before its using.
[modules/shaper.git] / src / Model / Model_AttributeSelection.h
index c2a65b535e31cb6f868d62b9b6e16608ff590787..9267748a7d33a4e182726643cbb3d2404f94f320 100644 (file)
@@ -29,6 +29,7 @@
 #include <TopTools_ListOfShape.hxx>
 
 class Model_AttributeSelectionList;
+class Model_Document;
 
 /**\class Model_AttributeSelection
  * \ingroup DataModel
@@ -42,6 +43,8 @@ class Model_AttributeSelection : public ModelAPI_AttributeSelection
   ResultPtr myTmpContext;
   /// temporarily storages to avoid keeping in the data structure if not needed
   std::shared_ptr<GeomAPI_Shape> myTmpSubShape;
+  /// temporarily storages to avoid keeping in the data structure if not needed
+  CenterType myTmpCenterType;
   /// Reference to the partent attribute, if any (to split selection compounds in issue 1799)
   Model_AttributeSelectionList* myParent;
 public:
@@ -50,10 +53,22 @@ public:
   /// \param theSubShape selected sub-shape (if null, the whole context is selected)
   /// \param theTemporarily if it is true, do not store and name the added in the data framework
   ///           (used to remove immideately, without the following updates)
-  MODEL_EXPORT virtual void setValue(
-    const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
+  /// \returns true if attribute was updated
+  MODEL_EXPORT virtual bool setValue(
+    const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape,
+    const bool theTemporarily = false);
+
+  /// Same as SetValue, but it takes an edge (on circular or elliptical curve)
+  /// and stores the vertex of the central point (for ellipse the first or the second focus point)
+  MODEL_EXPORT virtual void setValueCenter(
+    const ObjectPtr& theContext, const std::shared_ptr<GeomAPI_Edge>& theEdge,
+    const CenterType theCenterType,
     const bool theTemporarily = false);
 
+  /// Makes this selection attribute selects the same as in theSource selection
+  MODEL_EXPORT virtual void selectValue(
+    const std::shared_ptr<ModelAPI_AttributeSelection>& theSource);
+
   /// Reset temporary stored values
   virtual void removeTemporaryValues();
 
@@ -63,6 +78,11 @@ public:
   /// Returns the context of the selection (the whole shape owner)
   MODEL_EXPORT virtual ResultPtr context();
 
+  /// Returns the context of the selection if the whole feature was selected
+  MODEL_EXPORT virtual FeaturePtr contextFeature();
+  /// Returns the context of the selection : result or feature
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Object> contextObject();
+
   /// Sets the feature object
   MODEL_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
 
@@ -102,6 +122,13 @@ protected:
   /// Objects are created for features automatically
   MODEL_EXPORT Model_AttributeSelection(TDF_Label& theLabel);
 
+  /// Returns the selected subshape, internal method that works without knowledge
+  /// about special selection of circle and ellipse focuses (for that the public value
+  /// method calls this and makes additional processing).
+  /// Returns theType type of the center, or NOT_CENTER if it is not.
+  std::shared_ptr<GeomAPI_Shape> internalValue(CenterType& theType);
+
+
   /// Performs the selection for the body result (TNaming Selection)
 
   /// Performs the selection for the body result (TNaming selection)