1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef Model_ResultConstruction_H_
22 #define Model_ResultConstruction_H_
25 #include <ModelAPI_ResultConstruction.h>
28 class ModelAPI_Document;
31 /**\class Model_ResultConstruction
33 * \brief The construction element result of a feature.
35 * Provides a shape that may be displayed in the viewer.
36 * Intermediate, light result that in many cases produces a result on the fly.
38 class Model_ResultConstruction : public ModelAPI_ResultConstruction
40 std::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
41 std::shared_ptr<GeomAPI_Shape> myShape; ///< shape of this result created "on the fly"
42 bool myFacesUpToDate; ///< is true if faces in myuFaces are computed and up to date
43 /// stores the up to date faces if they exist
44 std::vector<std::shared_ptr<GeomAPI_Face> > myFaces;
48 /// Retuns the parameters of color definition in the resources config manager
49 MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
50 std::string& theDefault);
52 /// By default object is displayed in the object browser.
53 MODEL_EXPORT virtual bool isInHistory()
59 MODEL_EXPORT virtual void setShape(std::shared_ptr<GeomAPI_Shape> theShape);
60 /// Returns the shape-result produced by this feature
61 MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
63 /// Sets the flag that it must be displayed in history (default is true)
64 MODEL_EXPORT virtual void setIsInHistory(const bool myIsInHistory);
66 /// if the construction result may be used as faces, this method returns not zero number of faces
67 MODEL_EXPORT virtual int facesNum();
68 /// if the construction result may be used as faces, this method returns face by zero based index
69 MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Face> face(const int theIndex);
71 /// By default object is not infinite.
72 MODEL_EXPORT virtual bool isInfinite();
73 /// Sets the flag that it is infinite
74 MODEL_EXPORT virtual void setInfinite(const bool theInfinite);
75 /// The construction element is never concealed
76 MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
78 // methods related to selection of sub-shapes in construction, used by SelectionAttribute
80 /// Selects theSubShape in the construction. Returns an index of the selected sub-shape.
81 /// Puts the selected shape with a needed BRepNaming sub-structure to the data tree of result.
82 /// If theSubShape is null, it selects the whole construction and returns zero index.
83 /// If theIndex is not -1, it re-selects over the existing data (used for update selection).
84 /// If theExtDoc is document where this selection is needed, if it differs from this,
85 /// naming structures will be located there.
86 int select(const std::shared_ptr<GeomAPI_Shape>& theSubShape,
87 const std::shared_ptr<ModelAPI_Document> theExtDoc, const int theIndex = -1);
89 /// Returns already selected shape by the given index. Zero index means the whole construction,
90 /// so, the returned shape in this case is null.
91 /// If theExtDoc is document where this selection is needed, if it differs from this,
92 /// naming structures will be located there.
93 std::shared_ptr<GeomAPI_Shape> shape(const int theIndex,
94 const std::shared_ptr<ModelAPI_Document> theExtDoc);
96 /// Updates the existing selection by the index.
97 /// Returns false if update is failed. Returns theModified true if the selection was updated.
98 /// If theExtDoc is document where this selection is needed, if it differs from this,
99 /// naming structures will be updated there.
100 bool update(const int theIndex, const std::shared_ptr<ModelAPI_Document> theExtDoc,
104 /// Makes a body on the given feature
105 Model_ResultConstruction();
107 /// Searchies for the working label selection/update will start from
108 /// Returns true if this is label of the external document.
109 /// theExtDoc is document where this selection is required
110 TDF_Label startLabel(const std::shared_ptr<ModelAPI_Document> theExtDoc, bool& theExternal);
112 friend class Model_Objects;