Salome HOME
Fix crashes in Boolean operations
[modules/shaper.git] / src / ModelAPI / ModelAPI_Result.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_Result_H_
22 #define ModelAPI_Result_H_
23
24 #include "ModelAPI_Object.h"
25
26 class GeomAPI_Shape;
27 class ModelAPI_Feature;
28
29 /**\class ModelAPI_Result
30  * \ingroup DataModel
31  * \brief The result of a feature.
32  *
33  * A generic class that .
34  */
35 class ModelAPI_Result : public ModelAPI_Object
36 {
37   bool myIsConcealed; ///< the result is concealed from the data tree (referenced by other objects)
38  protected:
39   bool myIsDisabled; ///< the result is disabled: removed for the user, but keeps the general info
40  public:
41
42   /// Reference to the color of the result.
43   /// The integer array is used. It contains tree values for red green and blue values.
44   /// The values are in [0, 255] range
45   inline static const std::string& COLOR_ID()
46   {
47     static const std::string MY_COLOR_ID("Color");
48     return MY_COLOR_ID;
49   }
50
51   /// Reference to the deflection of the result.
52   /// The double value is used. The value is in [0, 1] range
53   inline static const std::string& DEFLECTION_ID()
54   {
55     static const std::string MY_DEFLECTION_ID("Deflection");
56     return MY_DEFLECTION_ID;
57   }
58
59   /// Reference to the transparency of the result.
60   /// The double value is used. The value is in [0, 1] range
61   inline static const std::string& TRANSPARENCY_ID()
62   {
63     static const std::string MY_TRANSPARENCY_ID("Transparency");
64     return MY_TRANSPARENCY_ID;
65   }
66
67   /// Returns true if the result is concealed from the data tree (referenced by other objects)
68   MODELAPI_EXPORT virtual bool isConcealed();
69
70   /// Sets the result as concealed in the data tree (referenced by other objects)
71   MODELAPI_EXPORT virtual void setIsConcealed(const bool theValue);
72
73   /// Enables/disables the result. The disabled result does not participate in any calculation
74   /// and visualization: like it was removed. But it keeps the general parameters: colors,
75   /// visibility, etc.
76   /// \param theThis pointer to this object, needed to generate all events if it is necessary
77   /// \param theFlag makes disabled if it is true
78   /// \returns true if state is really changed
79   MODELAPI_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
80     const bool theFlag);
81
82   /// Returns the result is disabled or not.
83   MODELAPI_EXPORT virtual bool isDisabled();
84
85   /// Request for initialization of data model of the result: adding all attributes
86   MODELAPI_EXPORT virtual void initAttributes();
87
88   /// To virtually destroy the fields of successors
89   MODELAPI_EXPORT virtual ~ModelAPI_Result();
90
91   /// Returns the shape-result produced by this feature (or null if no shapes)
92   MODELAPI_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
93
94   /// On change of attribute of the result update presentation of this result:
95   /// for the current moment there are only presentation attributes assigned to results
96   MODELAPI_EXPORT virtual void attributeChanged(const std::string& theID);
97
98 protected:
99   /// This method is called just after creation of the object: it must initialize
100   /// all fields, normally initialized in the constructor
101   MODELAPI_EXPORT virtual void init();
102
103 friend class Model_Objects;
104 };
105
106 //! Pointer on feature object
107 typedef std::shared_ptr<ModelAPI_Result> ResultPtr;
108
109 #endif