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