Salome HOME
Fix for the issue #1733 : collect all the transformations in part-transformation...
[modules/shaper.git] / src / Model / Model_ResultPart.h
index fe00a84bd0654dbf6b2237b594911593be9a75cc..e42df61e8f6726c171dc4bf6bde032fe9543f216 100644 (file)
@@ -10,6 +10,7 @@
 #include "Model.h"
 #include <ModelAPI_ResultPart.h>
 #include <TopoDS_Shape.hxx>
+#include <gp_Trsf.hxx>
 
 /**\class Model_ResultPart
  * \ingroup DataModel
 class Model_ResultPart : public ModelAPI_ResultPart
 {
   TopoDS_Shape myShape; ///< shape of this part created from bodies (updated only of Part deactivation)
+  std::shared_ptr<gp_Trsf> myTrsf; ///< if it is just copy of original shape, keep just transformation
  public:
+
+  /// the reference to the base result document, may be null if this is the root, others make sequence of references
+  inline static const std::string& BASE_REF_ID()
+  {
+    static const std::string MY_BASE_REF("BaseReference");
+    return MY_BASE_REF;
+  }
+  /// Request for initialization of data model of the result: adding all attributes
+  virtual void initAttributes();
   /// Returns the part-document of this result
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> partDoc();
-  /// Part has no stored feature: this method returns NULL
-  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> owner();
+
+  /// Returns the original part result: for transfomration features results this is 
+  /// the original Part feature result
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> original();
 
   /// Sets this document as current and if it is not loaded yet, loads it
   MODEL_EXPORT virtual void activate();
@@ -38,20 +51,36 @@ class Model_ResultPart : public ModelAPI_ResultPart
   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
 
   /// Returns the name of the shape inside of the part
-  MODEL_EXPORT virtual std::string nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape);
+  /// \param theShape selected shape in this document
+  /// \param theIndex is returned as one-based index if selection was required, "0" otherwise
+  /// \returns empty name is selection is not correct
+  MODEL_EXPORT virtual std::string nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape,
+    int& theIndex);
+
+  /// Updates the selection inside of the part by the selection index
+  MODEL_EXPORT virtual bool updateInPart(const int theIndex);
   /// Returns the shape by the name in the part
-  MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shapeInPart(const std::string& theName);
+  MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shapeInPart(
+    const std::string& theName, const std::string& theType, int& theIndex);
+  /// Updates the shape-result of the part (called on Part feature execution)
+  MODEL_EXPORT virtual void updateShape();
+  /// Applies the additional transformation of the part
+  MODEL_EXPORT virtual void setTrsf(std::shared_ptr<ModelAPI_Result> theThis, 
+    const std::shared_ptr<GeomAPI_Trsf>& theTransformation);
 
   /// Returns the parameters of color definition in the resources config manager
   MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
                                             std::string& theDefault);
 
+  /// Returns the shape selected in the selection index
+  MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> selectionValue(const int theIndex);
+
 protected:
   /// makes a result on a temporary feature (an action)
   Model_ResultPart();
 
-  /// Sets the data manager of an object (document does), here also attributes are initialized
-  virtual void setData(std::shared_ptr<ModelAPI_Data> theData);
+  /// returns sum of transformations of the whole sequence of transformation-parts
+  gp_Trsf sumTrsf();
 
   /// Returns true if document is activated (loaded into the memory)
   virtual bool isActivated();