Salome HOME
High level objects history implementation for Intersection and Compound features...
[modules/shaper.git] / src / Model / Model_ResultConstruction.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 Model_ResultConstruction_H_
22 #define Model_ResultConstruction_H_
23
24 #include "Model.h"
25 #include <ModelAPI_ResultConstruction.h>
26 #include <vector>
27
28 class ModelAPI_Document;
29 class TDF_Label;
30
31 /**\class Model_ResultConstruction
32  * \ingroup DataModel
33  * \brief The construction element result of a feature.
34  *
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.
37  */
38 class Model_ResultConstruction : public ModelAPI_ResultConstruction
39 {
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  public:
43   /// Retuns the parameters of color definition in the resources config manager
44   MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
45                                             std::string& theDefault);
46
47   /// By default object is displayed in the object browser.
48   MODEL_EXPORT virtual bool isInHistory();
49   /// Sets the result
50   MODEL_EXPORT virtual void setShape(std::shared_ptr<GeomAPI_Shape> theShape);
51   /// Returns the shape-result produced by this feature
52   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
53
54   /// Sets the flag that it must be displayed in history (default is true)
55   MODEL_EXPORT virtual void setIsInHistory(const bool myIsInHistory);
56
57   /// if the construction result may be used as faces, this method returns not zero number of faces
58   /// \param theUpdateNaming is false of keeping the naming structure untouched (on load)
59   MODEL_EXPORT virtual int facesNum(const bool theUpdateNaming = true);
60   /// if the construction result may be used as faces, this method returns face by zero based index
61   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Face> face(const int theIndex);
62
63   /// By default object is not infinite.
64   MODEL_EXPORT virtual bool isInfinite();
65   /// Sets the flag that it is infinite
66   MODEL_EXPORT virtual void setInfinite(const bool theInfinite);
67   /// The construction element is never concealed
68   MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
69
70   /// Updates the shape taking the current value from the data structure, returns true
71   /// if update has been correctly done
72   MODEL_EXPORT virtual bool updateShape();
73
74  protected:
75   /// Makes a body on the given feature
76   Model_ResultConstruction();
77
78   /// Stores shape in the data structure to allow identification it by the naming
79   void storeShape(std::shared_ptr<GeomAPI_Shape> theShape);
80
81   friend class Model_Objects;
82 };
83
84 #endif