Salome HOME
Updated copyright comment
[modules/shaper.git] / src / ModelAPI / ModelAPI_ResultField.h
1 // Copyright (C) 2014-2024  CEA, EDF
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_ResultField_H_
21 #define ModelAPI_ResultField_H_
22
23 #include "ModelAPI_Result.h"
24 #include <GeomAPI_Shape.h>
25 #include <memory>
26 #include <string>
27
28 /**\class ModelAPI_ResultField
29  * \ingroup DataModel
30  * \brief The fields result.
31  *
32  * Provides a compound of selected elements, without storage, one the fly.
33  */
34 class ModelAPI_ResultField : public ModelAPI_Result
35 {
36 public:
37
38   class ModelAPI_FieldStep : public ModelAPI_Object
39   {
40   public:
41     virtual ModelAPI_ResultField* field() const = 0;
42
43     virtual int id() const = 0;
44
45     /// Returns the group identifier of this result
46     inline static std::string group()
47     {
48       static std::string MY_GROUP = "FieldRersultStep";
49       return MY_GROUP;
50     }
51
52     /// Returns the group identifier of this object
53     virtual std::string groupName() { return group(); }
54
55     /// Request for initialization of data model of the object: adding all attributes
56     virtual void initAttributes() {}
57
58     /// Returns the feature is disabled or not.
59     virtual bool isDisabled() { return false; }
60
61     /// Returns true if object must be displayed in the viewer: flag is stored in the
62     /// data model, so on undo/redo, open/save or recreation of object by history-playing it keeps
63     /// the original state in the current transaction.
64     virtual bool isDisplayed() { return myIsDisplayed; }
65
66     /// Sets the displayed/hidden state of the object. If it is changed, sends the "redisplay"
67     /// signal.
68     MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
69
70     /// Returns a GUI name of this step
71     MODELAPI_EXPORT virtual std::wstring name() = 0;
72
73   protected:
74     /// This method is called just after creation of the object: it must initialize
75     /// all fields, normally initialized in the constructor
76     MODELAPI_EXPORT virtual void init() {}
77
78   private:
79     bool myIsDisplayed;
80   };
81
82   MODELAPI_EXPORT virtual ~ModelAPI_ResultField();
83   /// Returns the group identifier of this result
84   MODELAPI_EXPORT virtual std::string groupName();
85
86   /// Returns the group identifier of this result
87   inline static std::string group()
88   {
89     static std::string MY_GROUP = "Fields";
90     return MY_GROUP;
91   }
92
93   /// default color for a result body
94   inline static const std::string& DEFAULT_COLOR()
95   {
96     static const std::string RESULT_GROUP_COLOR("150,150,180");
97     return RESULT_GROUP_COLOR;
98   }
99
100   /// Returns number of steps
101   virtual int stepsSize() const = 0;
102
103   /// Returns a text line by its number
104   /// \param theLine a number of line
105   virtual std::string textLine(int theLine) const = 0;
106
107   /// Returns step object
108   /// \param theId an id of the object
109   virtual std::shared_ptr<ModelAPI_ResultField::ModelAPI_FieldStep> step(int theId) const = 0;
110
111   /// Sets the displayed/hidden state of the object. If it is changed, sends the "redisplay"
112   /// signal.
113   MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
114
115   /// To refresh the steps of a field
116   MODELAPI_EXPORT virtual void updateSteps() = 0;
117 };
118
119 //! Pointer on feature object
120 typedef std::shared_ptr<ModelAPI_ResultField> ResultFieldPtr;
121 typedef std::shared_ptr<ModelAPI_ResultField::ModelAPI_FieldStep> FieldStepPtr;
122
123 #endif