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