Salome HOME
Debug : use plane for symmetry.
[modules/shaper.git] / src / Model / Model_ResultPart.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_ResultPart.hxx
4 // Created:     07 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_ResultPart_H_
8 #define Model_ResultPart_H_
9
10 #include "Model.h"
11 #include <ModelAPI_ResultPart.h>
12 #include <TopoDS_Shape.hxx>
13 #include <gp_Trsf.hxx>
14
15 /**\class Model_ResultPart
16  * \ingroup DataModel
17  * \brief The Part document, result of a creation of new part feature.
18  *
19  * This result leaves without feature: no parametricity for this element,
20  * only add/remove, undo/redo.
21  */
22 class Model_ResultPart : public ModelAPI_ResultPart
23 {
24   /// shape of this part created from bodies (updated only of Part deactivation)
25   TopoDS_Shape myShape;
26   /// if it is just copy of original shape, keep just transformation
27   std::shared_ptr<gp_Trsf> myTrsf;
28  public:
29
30   /// the reference to the base result document, may be null if this is the root,
31   /// others make sequence of references
32   inline static const std::string& BASE_REF_ID()
33   {
34     static const std::string MY_BASE_REF("BaseReference");
35     return MY_BASE_REF;
36   }
37   /// Request for initialization of data model of the result: adding all attributes
38   virtual void initAttributes();
39   /// Returns the part-document of this result
40   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> partDoc();
41
42   /// Returns the original part result: for transfomration features results this is
43   /// the original Part feature result
44   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> original();
45
46   /// Sets this document as current and if it is not loaded yet, loads it
47   MODEL_EXPORT virtual void activate();
48
49   /// disable all feature of the part on disable of the part result
50   MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
51     const bool theFlag);
52
53   /// Result shape of part document is compound of bodies inside of this part
54   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
55
56   /// Returns the name of the shape inside of the part
57   /// \param theShape selected shape in this document
58   /// \param theIndex is returned as one-based index if selection was required, "0" otherwise
59   /// \returns empty name is selection is not correct
60   MODEL_EXPORT virtual std::string nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape,
61     int& theIndex);
62
63   /// Updates the selection inside of the part by the selection index
64   MODEL_EXPORT virtual bool updateInPart(const int theIndex);
65   /// Returns the shape by the name in the part
66   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shapeInPart(
67     const std::string& theName, const std::string& theType, int& theIndex);
68   /// Updates the shape-result of the part (called on Part feature execution)
69   MODEL_EXPORT virtual void updateShape();
70   /// Applies the additional transformation of the part
71   MODEL_EXPORT virtual void setTrsf(std::shared_ptr<ModelAPI_Result> theThis,
72     const std::shared_ptr<GeomAPI_Trsf>& theTransformation);
73
74   /// Returns the parameters of color definition in the resources config manager
75   MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
76                                             std::string& theDefault);
77
78   /// Returns the shape selected in the selection index
79   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> selectionValue(const int theIndex);
80
81 protected:
82   /// makes a result on a temporary feature (an action)
83   Model_ResultPart();
84
85   /// returns sum of transformations of the whole sequence of transformation-parts
86   gp_Trsf sumTrsf();
87
88   /// Returns true if document is activated (loaded into the memory)
89   virtual bool isActivated();
90
91   friend class Model_Objects;
92 };
93
94 #endif