Salome HOME
updated copyright message
[modules/shaper.git] / src / Model / Model_ResultPart.h
1 // Copyright (C) 2014-2023  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef Model_ResultPart_H_
21 #define Model_ResultPart_H_
22
23 #include "Model.h"
24 #include <ModelAPI_ResultPart.h>
25 #include <TopoDS_Shape.hxx>
26 #include <gp_Trsf.hxx>
27
28 /**\class Model_ResultPart
29  * \ingroup DataModel
30  * \brief The Part document, result of a creation of new part feature.
31  *
32  * This result leaves without feature: no parametricity for this element,
33  * only add/remove, undo/redo.
34  */
35 class Model_ResultPart : public ModelAPI_ResultPart
36 {
37   /// shape of this part created from bodies (updated only of Part deactivation)
38   TopoDS_Shape myShape;
39   /// if it is just copy of original shape, keep just transformation
40   std::shared_ptr<gp_Trsf> myTrsf;
41  public:
42
43   /// the reference to the base result document, may be null if this is the root,
44   /// others make sequence of references
45   inline static const std::string& BASE_REF_ID()
46   {
47     static const std::string MY_BASE_REF("BaseReference");
48     return MY_BASE_REF;
49   }
50   /// Request for initialization of data model of the result: adding all attributes
51   virtual void initAttributes();
52   /// Returns the part-document of this result
53   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> partDoc();
54
55   /// Returns the original part result: for transformation features results this is
56   /// the original Part feature result
57   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> original();
58
59   /// Sets this document as current and if it is not loaded yet, loads it
60   MODEL_EXPORT virtual void activate();
61
62   /// disable all feature of the part on disable of the part result
63   MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
64     const bool theFlag);
65
66   /// Result shape of part document is compound of bodies inside of this part
67   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
68
69   /// Returns the name of the shape inside of the part
70   /// \param theShape selected shape in this document
71   /// \param theIndex is returned as one-based index if selection was required, "0" otherwise
72   /// \returns empty name is selection is not correct
73   MODEL_EXPORT virtual std::wstring nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape,
74     int& theIndex);
75
76   /// Updates the selection inside of the part by the selection index
77   MODEL_EXPORT virtual bool updateInPart(const int theIndex);
78   /// Returns the shape by the name in the part
79   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shapeInPart(
80     const std::wstring& theName, const std::string& theType, int& theIndex);
81   /// Updates the selection inside of the part as a geometrical selection
82   MODEL_EXPORT virtual bool combineGeometrical(const int theIndex, std::wstring& theNewName);
83   /// Updates the shape-result of the part (called on Part feature execution)
84   MODEL_EXPORT virtual void updateShape();
85   /// Applies the additional transformation of the part
86   MODEL_EXPORT virtual void setTrsf(std::shared_ptr<ModelAPI_Result> theThis,
87     const std::shared_ptr<GeomAPI_Trsf>& theTransformation);
88   /// Returns the summary transformations of all references to the origin
89   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Trsf> summaryTrsf();
90
91   /// Returns the parameters of color definition in the resources config manager
92   MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
93                                             std::string& theDefault);
94
95   /// Returns the shape selected in the selection index
96   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> selectionValue(const int theIndex);
97
98   /// Loading the part from file
99   MODEL_EXPORT virtual void loadPart();
100
101 protected:
102   /// makes a result on a temporary feature (an action)
103   Model_ResultPart();
104
105   /// returns sum of transformations of the whole sequence of transformation-parts
106   gp_Trsf sumTrsf();
107
108   /// Returns true if document is activated (loaded into the memory)
109   virtual bool isActivated();
110
111   friend class Model_Objects;
112 };
113
114 #endif