Salome HOME
cdf70800d593d00d00dfd2a70039452097d97f18
[modules/geom.git] / src / GEOM / GEOM_BaseObject.hxx
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef _GEOM_BaseObject_HeaderFile
24 #define _GEOM_BaseObject_HeaderFile
25
26 #include "GEOM_Function.hxx"
27
28 #include <Standard_GUID.hxx>
29 #include <TColStd_HSequenceOfTransient.hxx>
30 #include <TCollection_AsciiString.hxx>
31 #include <TDF_Label.hxx>
32 #include <TDataStd_TreeNode.hxx>
33 #include <TFunction_Driver.hxx>
34
35 #include <vector>
36
37 class GEOM_BaseObject;
38 class GEOM_Engine;
39
40 DEFINE_STANDARD_HANDLE( GEOM_BaseObject, Standard_Transient )
41
42 class GEOM_BaseObject : public Standard_Transient
43 {
44   friend class GEOM_Engine;
45
46 protected:
47   Standard_EXPORT GEOM_BaseObject(const TDF_Label& theLabel);
48
49 public:
50
51   Standard_EXPORT GEOM_BaseObject(const TDF_Label& theEntry, int theType);
52   Standard_EXPORT ~GEOM_BaseObject();
53
54   //Finds a GEOM_BaseObject on the label theLabel
55   Standard_EXPORT static Handle(GEOM_BaseObject) GetObject(const TDF_Label& theLabel);
56
57   //Finds a GEOM_BaseObject by a reference, stored on the label theLabel
58   Standard_EXPORT static Handle(GEOM_BaseObject) GetReferencedObject(const TDF_Label& theLabel);
59
60   // Returns type of a object (GEOM_POINT, GEOM_VECTOR...) on theLabel, -1 if no object is there
61   Standard_EXPORT static int GetType(const TDF_Label& theLabel);
62
63   //Returns a GEOM_BaseObject common GUID.
64   // This GUID marks the label of any object in GEOM module
65   Standard_EXPORT static const Standard_GUID& GetObjectID();
66
67   //Returns a GUID associated with a sub-shape object
68   // This GUID corresponds to GEOM_SubShapeDriver
69   Standard_EXPORT static const Standard_GUID& GetSubShapeID();
70
71   //###########################################################
72   //Access to properties
73   //###########################################################
74
75   //Returns a TreeNode that presents a root of a function tree for this GEOM_BaseObject
76   Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; }
77
78   //Returns a label of this GEOM_BaseObject
79   Standard_EXPORT TDF_Label GetEntry() const { return _label; }
80
81   //Returns an entry of this GEOM_BaseObject
82   Standard_EXPORT TCollection_AsciiString GetEntryString();
83
84   //Returns a type of this GEOM_BaseObject (GEOM_POINT, GEOM_VECTOR...)
85   Standard_EXPORT int GetType();
86
87   //Sets the type of this GEOM_BaseObject
88   Standard_EXPORT void SetType(int theType);
89
90   //Modifications counter management
91   Standard_EXPORT int  GetTic();
92   Standard_EXPORT void SetTic(int theTic);
93   Standard_EXPORT void IncrementTic();
94
95   //Sets a name of this GEOM_BaseObject
96   Standard_EXPORT void SetName(const char* theName);
97
98   //Returns a name of this GEOM_BaseObject
99   Standard_EXPORT TCollection_AsciiString GetName();
100
101   //Sets an auxiliary data
102   Standard_EXPORT void SetAuxData(const char* theData);
103
104   //Returns an auxiliary data
105   Standard_EXPORT TCollection_AsciiString GetAuxData();
106
107   //Set a notebook variables used for object creation
108   Standard_EXPORT void SetParameters(const TCollection_AsciiString& theParameters);
109
110   //Get a notebook variables used for object creation
111   Standard_EXPORT TCollection_AsciiString GetParameters() const;
112
113   //###########################################################
114   // CORBA related methods
115   //###########################################################
116
117   //Sets an IOR of CORBA GEOM_BaseObject_i which refers to this object
118   Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; }
119
120   //Returns an IOR of CORBA GEOM_BaseObject_i which refers to this object
121   Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; }
122
123   //###########################################################
124   //Functions methods
125   //###########################################################
126
127   //Adds a function with a driver GUID = theGUID and a type theFunctionType
128   //to the function tree of this GEOM_BaseObject
129   Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID,
130                                                     int                  theFunctionType,
131                                                     bool                 allowSubShape=false);
132
133   //Returns a number of functions of this GEOM_BaseObject
134   Standard_EXPORT int GetNbFunctions();
135
136   //Returns a function with given number theFunctionNumber
137   Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
138
139   //Return the last function of this GEOM_BaseObject
140   Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
141
142   //Returns all dependencies of the object
143   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetAllDependency();
144
145   //Returns the dependencies of the last function
146   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
147
148   //Returns drivers creators of this object
149   Standard_EXPORT Handle(TFunction_Driver) GetCreationDriver(int funNb);
150
151   //###########################################################
152   // Internal methods
153   //###########################################################
154
155   //Returns a label which could be used to store some additional data
156   Standard_EXPORT TDF_Label GetFreeLabel();
157
158  protected:
159   Handle(TDataStd_TreeNode) _root;
160   TDF_Label                 _label;
161   TCollection_AsciiString   _ior;
162   TCollection_AsciiString   _parameters;
163
164 public:
165   DEFINE_STANDARD_RTTIEXT(GEOM_BaseObject,Standard_Transient)
166 };
167
168 #endif