Salome HOME
418e2d9d9f3aed4d8bda51447a0d4c511ee61b14
[modules/shaper.git] / src / ModelAPI / ModelAPI_ResultPart.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModelAPI_ResultPart_H_
22 #define ModelAPI_ResultPart_H_
23
24 #include "ModelAPI_Result.h"
25 class GeomAPI_Trsf;
26
27 #include <string>
28
29 /**\class ModelAPI_ResultPart
30  * \ingroup DataModel
31  * \brief The Part document, result of a creation of new part feature.
32  *
33  * This result leaves without feature: no parametricity for this element,
34  * only add/remove, undo/redo.
35  */
36 class ModelAPI_ResultPart : public ModelAPI_Result
37 {
38  public:
39   /// Returns the group identifier of this result
40   MODELAPI_EXPORT virtual std::string groupName();
41
42   /// Returns the group identifier of this result
43   inline static std::string group()
44   {
45     static std::string MY_GROUP = "Parts";
46     return MY_GROUP;
47   }
48
49   /// part document reference attribute
50   inline static const std::string& DOC_REF()
51   {
52     static const std::string MY_DOC_REF("PartDocument");
53     return MY_DOC_REF;
54   }
55
56   /// default color for a result body
57   inline static const std::string& DEFAULT_COLOR()
58   {
59     static const std::string RESULT_BODY_COLOR("96,157,255");
60     return RESULT_BODY_COLOR;
61   }
62
63   /// Returns the part-document of this result
64   virtual std::shared_ptr<ModelAPI_Document> partDoc() = 0;
65
66   /// Returns the original part result: for transformation features results this is
67   /// the original Part feature result
68   virtual std::shared_ptr<ModelAPI_ResultPart> original() = 0;
69
70   /// Sets this document as current and if it is not loaded yet, loads it
71   virtual void activate() = 0;
72
73   /// Returns true if document is activated (loaded into the memory)
74   virtual bool isActivated() = 0;
75
76   /// Returns the name of the shape inside of the part
77   virtual std::string nameInPart(const std::shared_ptr<GeomAPI_Shape>& theShape,
78     int& theIndex) = 0;
79   /// Updates the selection inside of the part by the selection index
80   virtual bool updateInPart(const int theIndex) = 0;
81
82   /// Applies the additional transformation of the part
83   virtual void setTrsf(std::shared_ptr<ModelAPI_Result> theThis,
84     const std::shared_ptr<GeomAPI_Trsf>& theTransformation) = 0;
85
86   /// Returns the shape by the name in the part
87   virtual std::shared_ptr<GeomAPI_Shape> shapeInPart(
88     const std::string& theName, const std::string& theType, int& theIndex) = 0;
89
90   /// Returns the shape selected in the selection index
91   virtual std::shared_ptr<GeomAPI_Shape> selectionValue(const int theIndex) = 0;
92
93   /// Updates the shape-result of the part (called on Part feature execution)
94   virtual void updateShape() = 0;
95 };
96
97 //! Pointer on feature object
98 typedef std::shared_ptr<ModelAPI_ResultPart> ResultPartPtr;
99
100 #endif