SHAPER 9.16.0
ModelAPI_Object.h
1// Copyright (C) 2014-2026 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_Object_H_
21#define ModelAPI_Object_H_
22
23#include "ModelAPI.h"
24#include "ModelAPI_Data.h"
25#include "ModelAPI_Entity.h"
26
27#include <memory>
28
29class ModelAPI_Data;
31
32// sometimes it is useful for debug to see name of each object (bad for memory and performance)
33//#define DEBUG_NAMES
34
45{
46 std::shared_ptr<ModelAPI_Data> myData;
47 std::shared_ptr<ModelAPI_Document> myDoc;
48 public:
49#ifdef DEBUG_NAMES
50 std::wstring myName; // name of this object
51#endif
53 MODELAPI_EXPORT virtual bool isInHistory();
54
58 MODELAPI_EXPORT virtual void setInHistory(
59 const std::shared_ptr<ModelAPI_Object> theObject, const bool theFlag);
60
62 MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
63
65 MODELAPI_EXPORT virtual bool isSame(const std::shared_ptr<ModelAPI_Object>& theObject);
66
68 MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() const;
69
71 virtual std::string groupName() = 0;
72
74 virtual void initAttributes() = 0;
75
77 virtual bool isDisabled() = 0;
78
80 virtual void colorConfigInfo(std::string& /*theSection*/,
81 std::string& /*theName*/,
82 std::string& /*theDefault*/) {}
83
86 MODELAPI_EXPORT virtual void attributeChanged(const std::string& theID);
87
89 MODELAPI_EXPORT ModelAPI_Object();
90
92 MODELAPI_EXPORT virtual ~ModelAPI_Object();
93
97 MODELAPI_EXPORT virtual bool isDisplayed();
98
101 MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
102
103 MODELAPI_EXPORT virtual bool hasTexture()
104 {
105 return false;
106 }
107
108 protected:
111 MODELAPI_EXPORT virtual void init() = 0;
112
114 MODELAPI_EXPORT virtual void setData(std::shared_ptr<ModelAPI_Data> theData);
115
117 MODELAPI_EXPORT virtual void setDoc(std::shared_ptr<ModelAPI_Document> theDoc);
118
120 MODELAPI_EXPORT virtual void erase();
121
122 friend class Model_Objects;
123 friend class ModelAPI_Feature;
124 friend class Model_Document;
125
126};
127
128typedef std::shared_ptr<ModelAPI_Object> ObjectPtr;
129
130#endif
General object of the application that allows to get/set attributes from the document and compute res...
Definition: ModelAPI_Data.h:73
Document for internal data structure of any object storage.
Definition: ModelAPI_Document.h:53
Represents a common parent class for Objects and documents.
Definition: ModelAPI_Entity.h:32
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:41
Represents any object in the data model and in the object browser.
Definition: ModelAPI_Object.h:45
virtual bool isDisplayed()
Returns true if object must be displayed in the viewer: flag is stored in the data model,...
Definition: ModelAPI_Object.cpp:89
virtual void setDisplayed(const bool theDisplay)
Sets the displayed/hidden state of the object.
Definition: ModelAPI_Object.cpp:94
virtual std::shared_ptr< ModelAPI_Data > data() const
Returns the data manager of this object: attributes.
Definition: ModelAPI_Object.cpp:45
virtual void erase()
removes all fields from this feature
Definition: ModelAPI_Object.cpp:82
virtual bool isSame(const std::shared_ptr< ModelAPI_Object > &theObject)
Returns true if object refers to the same data model instance.
Definition: ModelAPI_Object.cpp:50
virtual bool isInHistory()
By default object is displayed in the object browser.
Definition: ModelAPI_Object.cpp:26
virtual void setInHistory(const std::shared_ptr< ModelAPI_Object > theObject, const bool theFlag)
Makes object presented or not in the history of the created objects.
Definition: ModelAPI_Object.cpp:34
virtual void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: ModelAPI_Object.cpp:60
virtual void init()=0
This method is called just after creation of the object: it must initialize all fields,...
virtual bool isDisabled()=0
Returns the feature is disabled or not.
virtual void setDoc(std::shared_ptr< ModelAPI_Document > theDoc)
Sets the data manager of an object (document does)
Definition: ModelAPI_Object.cpp:77
virtual void initAttributes()=0
Request for initialization of data model of the object: adding all attributes.
virtual std::string groupName()=0
Returns the group identifier of this object.
virtual ~ModelAPI_Object()
To use virtuality for destructors.
Definition: ModelAPI_Object.cpp:68
virtual std::shared_ptr< ModelAPI_Document > document() const
Returns document this feature belongs to.
Definition: ModelAPI_Object.cpp:55
ModelAPI_Object()
Initializes the default states of the object.
Definition: ModelAPI_Object.cpp:64
virtual void colorConfigInfo(std::string &, std::string &, std::string &)
Returns the parameters of color definition in the resources config manager.
Definition: ModelAPI_Object.h:80
virtual void setData(std::shared_ptr< ModelAPI_Data > theData)
Sets the data manager of an object (document does)
Definition: ModelAPI_Object.cpp:72
Document for internal data structure of any object storage.
Definition: Model_Document.h:45
Manager of objects of the document.
Definition: Model_Objects.h:46