1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _GEOM_Object_HeaderFile
21 #define _GEOM_Object_HeaderFile
23 #ifndef _Standard_TypeMismatch_HeaderFile
24 #include <Standard_TypeMismatch.hxx>
26 #ifndef _Standard_HeaderFile
27 #include <Standard.hxx>
29 #ifndef _Standard_Macro_HeaderFile
30 #include <Standard_Macro.hxx>
32 #ifndef _Standard_HeaderFile
33 #include <Standard.hxx>
35 #ifndef _Handle_MMgt_TShared_HeaderFile
36 #include <Handle_MMgt_TShared.hxx>
38 #ifndef _MMgt_TShared_HeaderFile
39 #include <MMgt_TShared.hxx>
41 #ifndef _Standard_GUID_HeaderFile
42 #include <Standard_GUID.hxx>
44 #ifndef _TopoDS_Shape_HeaderFile
45 #include <TopoDS_Shape.hxx>
47 #ifndef _TDF_Label_HeaderFile
48 #include <TDF_Label.hxx>
50 #ifndef _TColStd_HSequenceOfTransient_HeaderFile
51 #include <TColStd_HSequenceOfTransient.hxx>
53 #ifndef _TCollection_AsciiString_HeaderFile
54 #include <TCollection_AsciiString.hxx>
57 #include "SALOMEconfig.h"
58 #include CORBA_SERVER_HEADER(SALOMEDS)
59 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
61 class Handle_TColStd_HSequenceOfTransient;
62 class Standard_Transient;
63 class Handle_Standard_Type;
64 class Handle(MMgt_TShared);
68 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Object);
70 class Handle(GEOM_Object) : public Handle(MMgt_TShared) {
72 inline void* operator new(size_t,void* anAddress)
76 inline void* operator new(size_t size)
78 return Standard::Allocate(size);
80 inline void operator delete(void *anAddress)
82 if (anAddress) Standard::Free((Standard_Address&)anAddress);
85 Handle(GEOM_Object)():Handle(MMgt_TShared)() {}
86 Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle)
90 Handle(GEOM_Object)(const GEOM_Object* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem)
94 Handle(GEOM_Object)& operator=(const Handle(GEOM_Object)& aHandle)
96 Assign(aHandle.Access());
100 Handle(GEOM_Object)& operator=(const GEOM_Object* anItem)
102 Assign((Standard_Transient *)anItem);
106 GEOM_Object* operator->()
108 return (GEOM_Object *)ControlAccess();
111 GEOM_Object* operator->() const
113 return (GEOM_Object *)ControlAccess();
116 Standard_EXPORT ~Handle(GEOM_Object)() {};
118 Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject);
122 #include <Standard_GUID.hxx>
123 #include <TDataStd_TreeNode.hxx>
124 #include "GEOM_Function.hxx"
125 #include "GEOM_Engine.hxx"
127 class GEOM_Object : public MMgt_TShared
129 friend class GEOM_Engine;
132 inline void* operator new(size_t,void* anAddress)
136 inline void* operator new(size_t size)
138 return Standard::Allocate(size);
140 inline void operator delete(void *anAddress)
142 if (anAddress) Standard::Free((Standard_Address&)anAddress);
147 Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_();
148 Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOM_Object) ; }
149 Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
150 { return (STANDARD_TYPE(GEOM_Object) == AType || MMgt_TShared::IsKind(AType)); }
153 GEOM_Object(TDF_Label& theLabel);
156 Standard_EXPORT GEOM_Object(TDF_Label& theEntry, int theType);
157 Standard_EXPORT ~GEOM_Object() {;}
159 //Finds a GEOM_Object on the label theLabel
160 Standard_EXPORT static Handle(GEOM_Object) GetObject(TDF_Label& theLabel);
162 //Finds a GEOM_Object by a reference, stored on the label theLabel
163 Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(TDF_Label& theLabel);
165 //Returns a GEOM_Object common GUID
166 Standard_EXPORT static const Standard_GUID& GetObjectID();
168 //Returns a GUID associated with a sub shape object
169 Standard_EXPORT static const Standard_GUID& GetSubShapeID();
171 //###########################################################
172 //Access to properties
173 //###########################################################
175 //Returns a TreeNode that presents a root of a function tree for this GEOM_Object
176 Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; }
178 //Returns a label of this GEOM_Object
179 Standard_EXPORT TDF_Label GetEntry() { return _label; }
181 //Returns a type of this GEOM_Object (GEOM_POINT, GEOM_VECTOR...)
182 Standard_EXPORT int GetType();
184 //Sets the type of this GEOM_Object
185 Standard_EXPORT void SetType(int theType);
187 //Modifications counter management
188 Standard_EXPORT int GetTic();
189 Standard_EXPORT void SetTic(int theTic);
190 Standard_EXPORT void IncrementTic();
192 //Returns an ID of the OCAF document where this GEOM_Object is stored
193 Standard_EXPORT int GetDocID();
195 //Returns a value (as TopoDS_Shape) of this GEOM_Object
196 Standard_EXPORT TopoDS_Shape GetValue();
198 //Sets a name of this GEOM_Object
199 Standard_EXPORT void SetName(const char* theName);
201 //Returns a name of this GEOM_Object
202 Standard_EXPORT char* GetName();
204 //Sets a color of this GEOM_Object
205 Standard_EXPORT void SetColor(const SALOMEDS::Color& theColor);
207 //Returns a color of this GEOM_Object
208 Standard_EXPORT SALOMEDS::Color GetColor();
210 //Toggles an auto color mode on this GEOM_Object
211 Standard_EXPORT void SetAutoColor(CORBA::Boolean theAutoColor);
213 //Returns a flag of auto color mode of this GEOM_Object
214 Standard_EXPORT CORBA::Boolean GetAutoColor();
216 //Sets an auxiliary data
217 Standard_EXPORT void SetAuxData(const char* theData);
219 //Returns an auxiliary data
220 Standard_EXPORT TCollection_AsciiString GetAuxData();
222 //###########################################################
224 //###########################################################
226 //Returns false if the object is a sub shape of another object
227 Standard_EXPORT bool IsMainShape();
229 //###########################################################
230 // CORBA related methods
231 //###########################################################
233 //Sets an IOR of CORBA GEOM_Object_i which refers to this object
234 Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; }
236 //Returns an IOR of CORBA GEOM_Object_i which refers to this object
237 Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; }
239 //###########################################################
241 //###########################################################
243 //Adds a function with a driver GUID = theGUID and a type theFunctionType
244 //to the function tree of this GEOM_Object
245 Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID, int theFunctionType);
247 //Returns a number of functions of this GEOM_Object
248 Standard_EXPORT int GetNbFunctions();
250 //Returns a function with given number theFunctionNumber
251 Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
253 //Return the last function of this GEOM_Object
254 Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
256 //Returns all dependencies of the object
257 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetAllDependency();
259 //Returns the dependencies of the last function
260 Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
262 //###########################################################
264 //###########################################################
266 //Returns a label which could be used to store some additional data
267 Standard_EXPORT TDF_Label GetFreeLabel();
270 Handle(TDataStd_TreeNode) _root;
272 TCollection_AsciiString _ior;