Salome HOME
Issue #2622: Weak naming
[modules/shaper.git] / src / Model / Model_AttributeSelection.h
index 12a0003ffb3f8b13495cf66601704f2a7a482f71..cafa6ea379ac2cb52855309641faef2eba8e3c79 100644 (file)
 #include <ModelAPI_AttributeSelection.h>
 #include <TDF_LabelMap.hxx>
 #include <TopoDS_Shape.hxx>
+#include <TopTools_ListOfShape.hxx>
 
 class Model_AttributeSelectionList;
+class Model_Document;
 
 /**\class Model_AttributeSelection
  * \ingroup DataModel
@@ -51,17 +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 ResultPtr& theContext, const std::shared_ptr<GeomAPI_Edge>& theEdge,
+    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();
 
@@ -71,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);
 
@@ -96,6 +108,13 @@ public:
   MODEL_EXPORT virtual void selectSubShape(const std::string& theType,
                                            const std::string& theSubShapeName);
 
+  /// Selects sub-shape by its inner point
+  MODEL_EXPORT virtual void selectSubShape(const std::string& theType,
+                                           const std::shared_ptr<GeomAPI_Pnt>& thePoint);
+  /// Selects sub-shape by weak naming index
+  MODEL_EXPORT virtual void selectSubShape(const std::string& theType,
+    const std::string& theContextName, const int theIndex);
+
   /// Returns true if attribute was  initialized by some value
   MODEL_EXPORT virtual bool isInitialized();
 
@@ -151,6 +170,16 @@ protected:
   /// Splits theNewShape into sub-shapes of theType type (for the list parent of this attribute)
   void split(ResultPtr theContext, TopoDS_Shape theNewShape, TopAbs_ShapeEnum theType);
 
+  /// When group position is updated, searches the new context and new values
+  bool searchNewContext(std::shared_ptr<Model_Document> theDoc, const TopoDS_Shape theContShape,
+                        ResultPtr theContext, TopoDS_Shape theValShape, TDF_Label theAccessLabel,
+                        std::list<ResultPtr>& theResults, TopTools_ListOfShape& theValShapes);
+
+  /// computes theShapes list - shapes that were generated/modified/deleted the theValShape
+  /// during creation from new to old context
+  void computeValues(ResultPtr theOldContext, ResultPtr theNewContext, TopoDS_Shape theValShape,
+    TopTools_ListOfShape& theShapes);
+
   friend class Model_Data;
   friend class Model_AttributeSelectionList;
 };