Salome HOME
Merge from V5_1_3_BR branch (07/12/09)
[modules/geom.git] / src / GEOM / GEOM_Object.hxx
1 //  Copyright (C) 2007-2008  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.
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 #ifndef _GEOM_Object_HeaderFile
23 #define _GEOM_Object_HeaderFile
24
25 #ifndef _Standard_TypeMismatch_HeaderFile
26 #include <Standard_TypeMismatch.hxx>
27 #endif
28 #ifndef _Standard_HeaderFile
29 #include <Standard.hxx>
30 #endif
31 #ifndef _Standard_Macro_HeaderFile
32 #include <Standard_Macro.hxx>
33 #endif
34 #ifndef _Standard_HeaderFile
35 #include <Standard.hxx>
36 #endif
37 #ifndef _Handle_MMgt_TShared_HeaderFile
38 #include <Handle_MMgt_TShared.hxx>
39 #endif
40 #ifndef _MMgt_TShared_HeaderFile
41 #include <MMgt_TShared.hxx>
42 #endif
43 #ifndef _Standard_GUID_HeaderFile
44 #include <Standard_GUID.hxx>
45 #endif
46 #ifndef _TopoDS_Shape_HeaderFile
47 #include <TopoDS_Shape.hxx>
48 #endif
49 #ifndef _TDF_Label_HeaderFile
50 #include <TDF_Label.hxx>
51 #endif
52 #ifndef _TColStd_HSequenceOfTransient_HeaderFile
53 #include <TColStd_HSequenceOfTransient.hxx>
54 #endif
55 #ifndef _TCollection_AsciiString_HeaderFile
56 #include <TCollection_AsciiString.hxx>
57 #endif
58 #ifndef _Aspect_TypeOfMarker_HeaderFile
59 #include <Aspect_TypeOfMarker.hxx>
60 #endif
61
62 #include "SALOMEconfig.h"
63 #include CORBA_SERVER_HEADER(SALOMEDS)
64 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
65
66 class Handle_TColStd_HSequenceOfTransient;
67 class Standard_Transient;
68 class Handle_Standard_Type;
69 class Handle(MMgt_TShared);
70 class GEOM_Object;
71
72
73 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Object);
74
75 class Handle(GEOM_Object) : public Handle(MMgt_TShared) {
76   public:
77     inline void* operator new(size_t,void* anAddress)
78       {
79         return anAddress;
80       }
81     inline void* operator new(size_t size)
82       {
83         return Standard::Allocate(size);
84       }
85     inline void  operator delete(void *anAddress)
86       {
87         if (anAddress) Standard::Free((Standard_Address&)anAddress);
88       }
89
90     Handle(GEOM_Object)():Handle(MMgt_TShared)() {}
91     Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle)
92      {
93      }
94
95     Handle(GEOM_Object)(const GEOM_Object* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem)
96      {
97      }
98
99     Handle(GEOM_Object)& operator=(const Handle(GEOM_Object)& aHandle)
100      {
101       Assign(aHandle.Access());
102       return *this;
103      }
104
105     Handle(GEOM_Object)& operator=(const GEOM_Object* anItem)
106      {
107       Assign((Standard_Transient *)anItem);
108       return *this;
109      }
110
111     GEOM_Object* operator->()
112      {
113       return (GEOM_Object *)ControlAccess();
114      }
115
116     GEOM_Object* operator->() const
117      {
118       return (GEOM_Object *)ControlAccess();
119      }
120
121    Standard_EXPORT ~Handle(GEOM_Object)() {};
122
123    Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject);
124 };
125
126
127 #include <Standard_GUID.hxx>
128 #include <TDataStd_TreeNode.hxx>
129 #include "GEOM_Function.hxx"
130 #include "GEOM_Engine.hxx"
131
132 class GEOM_Object : public MMgt_TShared
133 {
134  friend class GEOM_Engine;
135
136  public:
137   inline void* operator new(size_t,void* anAddress)
138     {
139       return anAddress;
140     }
141   inline void* operator new(size_t size)
142     {
143       return Standard::Allocate(size);
144     }
145   inline void  operator delete(void *anAddress)
146     {
147       if (anAddress) Standard::Free((Standard_Address&)anAddress);
148     }
149
150   // Type management
151   //
152   Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_();
153   Standard_EXPORT const Handle(Standard_Type)& DynamicType() const  { return STANDARD_TYPE(GEOM_Object) ; }
154   Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
155            { return (STANDARD_TYPE(GEOM_Object) == AType || MMgt_TShared::IsKind(AType)); }
156
157  private:
158   GEOM_Object(TDF_Label& theLabel);
159
160  public:
161   Standard_EXPORT GEOM_Object(TDF_Label& theEntry, int theType);
162   Standard_EXPORT ~GEOM_Object();
163
164   //Finds a GEOM_Object on the label theLabel
165   Standard_EXPORT static Handle(GEOM_Object) GetObject(TDF_Label& theLabel);
166
167   //Finds a GEOM_Object by a reference, stored on the label theLabel
168   Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(TDF_Label& theLabel);
169
170   //Returns a GEOM_Object common GUID
171   Standard_EXPORT static const Standard_GUID& GetObjectID();
172
173   //Returns a GUID associated with a sub shape object
174   Standard_EXPORT static const Standard_GUID& GetSubShapeID();
175
176   //###########################################################
177   //Access to properties
178   //###########################################################
179
180   //Returns a TreeNode that presents a root of a function tree for this GEOM_Object
181   Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; }
182
183   //Returns a label of this GEOM_Object
184   Standard_EXPORT TDF_Label GetEntry() { return _label; }
185
186   //Returns a type of this GEOM_Object (GEOM_POINT, GEOM_VECTOR...)
187   Standard_EXPORT int GetType();
188
189   //Sets the type of this GEOM_Object
190   Standard_EXPORT void SetType(int theType);
191
192   //Modifications counter management
193   Standard_EXPORT int  GetTic();
194   Standard_EXPORT void SetTic(int theTic);
195   Standard_EXPORT void IncrementTic();
196
197   //Returns an ID of the OCAF document where this GEOM_Object is stored
198   Standard_EXPORT int GetDocID();
199
200   //Returns a value (as TopoDS_Shape) of this GEOM_Object
201   Standard_EXPORT TopoDS_Shape GetValue();
202
203   //Sets a name of this GEOM_Object
204   Standard_EXPORT void SetName(const char* theName);
205
206   //Returns a name of this GEOM_Object
207   Standard_EXPORT char* GetName();
208
209   //Sets a color of this GEOM_Object
210   Standard_EXPORT void SetColor(const SALOMEDS::Color& theColor);
211
212   //Returns a color of this GEOM_Object
213   Standard_EXPORT SALOMEDS::Color GetColor();
214
215   //Toggles an auto color mode on this GEOM_Object
216   Standard_EXPORT void SetAutoColor(CORBA::Boolean theAutoColor);
217
218   //Returns a flag of auto color mode of this GEOM_Object
219   Standard_EXPORT CORBA::Boolean GetAutoColor();
220
221   //Sets predefined point marker texture
222   Standard_EXPORT void SetMarkerStd(const Aspect_TypeOfMarker theType, double theSize);
223   
224   //Sets custom point marker texture
225   Standard_EXPORT void SetMarkerTexture(int theTextureId);
226
227   //Gets point marker type
228   Standard_EXPORT Aspect_TypeOfMarker GetMarkerType();
229
230   //Gets point marker scale factor / size
231   Standard_EXPORT double GetMarkerSize();
232
233   //Gets custom marker texture ID
234   Standard_EXPORT int GetMarkerTexture();
235
236   //Unsets point marker
237   Standard_EXPORT void UnsetMarker();
238
239   //Sets an auxiliary data
240   Standard_EXPORT void SetAuxData(const char* theData);
241
242   //Returns an auxiliary data
243   Standard_EXPORT TCollection_AsciiString GetAuxData();
244
245   //Set a notebook variables used for object creation
246   Standard_EXPORT void SetParameters(const TCollection_AsciiString& theParameters);
247
248   //Get a notebook variables used for object creation
249   Standard_EXPORT TCollection_AsciiString GetParameters() const;
250
251   //###########################################################
252   // Sub shape methods
253   //###########################################################
254
255   //Returns false if the object is a sub shape of another object
256   Standard_EXPORT bool IsMainShape();
257
258   //###########################################################
259   // CORBA related methods
260   //###########################################################
261
262   //Sets an IOR of CORBA GEOM_Object_i which refers to this object
263   Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; }
264
265   //Returns an IOR of CORBA GEOM_Object_i which refers to this object
266   Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; }
267
268   //###########################################################
269   //Functions methods
270   //###########################################################
271
272   //Adds a function with a driver GUID = theGUID and a type theFunctionType
273   //to the function tree of this GEOM_Object
274   Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID, int theFunctionType);
275
276   //Returns a number of functions of this GEOM_Object
277   Standard_EXPORT int GetNbFunctions();
278
279   //Returns a function with given number theFunctionNumber
280   Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
281
282   //Return the last function of this GEOM_Object
283   Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
284
285   //Returns all dependencies of the object
286   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetAllDependency();
287
288   //Returns the dependencies of the last function
289   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
290
291   //###########################################################
292   // Internal methods
293   //###########################################################
294
295   //Returns a label which could be used to store some additional data
296   Standard_EXPORT TDF_Label GetFreeLabel();
297
298  private:
299   Handle(TDataStd_TreeNode) _root;
300   TDF_Label                 _label;
301   TCollection_AsciiString   _ior;
302   TCollection_AsciiString   _parameters;
303   int                       _docID;
304 };
305
306 #endif