Salome HOME
Implementation of the following issues:
[modules/geom.git] / src / GEOM / GEOM_BaseObject.hxx
1 // Copyright (C) 2007-2013  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_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
34 class GEOM_BaseObject;
35 class Handle(TFunction_Driver);
36 class GEOM_Engine;
37
38 DEFINE_STANDARD_HANDLE( GEOM_BaseObject, Standard_Transient );
39
40 class GEOM_BaseObject : public Standard_Transient
41 {
42   friend class GEOM_Engine;
43
44 protected:
45   Standard_EXPORT GEOM_BaseObject(const TDF_Label& theLabel);
46
47 public:
48
49   Standard_EXPORT GEOM_BaseObject(const TDF_Label& theEntry, int theType);
50   Standard_EXPORT ~GEOM_BaseObject();
51
52   //Finds a GEOM_BaseObject on the label theLabel
53   Standard_EXPORT static Handle(GEOM_BaseObject) GetObject(const TDF_Label& theLabel);
54
55   //Finds a GEOM_BaseObject by a reference, stored on the label theLabel
56   Standard_EXPORT static Handle(GEOM_BaseObject) GetReferencedObject(const TDF_Label& theLabel);
57
58   // Returns type of a object (GEOM_POINT, GEOM_VECTOR...) on theLabel, -1 if no object is there
59   Standard_EXPORT static int GetType(const TDF_Label& theLabel);
60
61   //Returns a GEOM_BaseObject common GUID.
62   // This GUID marks the label of any object in GEOM module
63   Standard_EXPORT static const Standard_GUID& GetObjectID();
64
65   //Returns a GUID associated with a sub-shape object
66   // This GUID corresponds to GEOM_SubShapeDriver
67   Standard_EXPORT static const Standard_GUID& GetSubShapeID();
68
69   //###########################################################
70   //Access to properties
71   //###########################################################
72
73   //Returns a TreeNode that presents a root of a function tree for this GEOM_BaseObject
74   Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; }
75
76   //Returns a label of this GEOM_BaseObject
77   Standard_EXPORT TDF_Label GetEntry() const { return _label; }
78
79   //Returns an entry of this GEOM_BaseObject
80   Standard_EXPORT TCollection_AsciiString GetEntryString();
81
82   //Returns a type of this GEOM_BaseObject (GEOM_POINT, GEOM_VECTOR...)
83   Standard_EXPORT int GetType();
84
85   //Sets the type of this GEOM_BaseObject
86   Standard_EXPORT void SetType(int theType);
87
88   //Modifications counter management
89   Standard_EXPORT int  GetTic();
90   Standard_EXPORT void SetTic(int theTic);
91   Standard_EXPORT void IncrementTic();
92
93   //Returns an ID of the OCAF document where this GEOM_BaseObject is stored
94   Standard_EXPORT int GetDocID();
95
96   //Sets a name of this GEOM_BaseObject
97   Standard_EXPORT void SetName(const char* theName);
98
99   //Returns a name of this GEOM_BaseObject
100   Standard_EXPORT TCollection_AsciiString GetName();
101
102   //Sets an auxiliary data
103   Standard_EXPORT void SetAuxData(const char* theData);
104
105   //Returns an auxiliary data
106   Standard_EXPORT TCollection_AsciiString GetAuxData();
107
108   //Set a notebook variables used for object creation
109   Standard_EXPORT void SetParameters(const TCollection_AsciiString& theParameters);
110
111   //Get a notebook variables used for object creation
112   Standard_EXPORT TCollection_AsciiString GetParameters() const;
113
114   //###########################################################
115   // CORBA related methods
116   //###########################################################
117
118   //Sets an IOR of CORBA GEOM_BaseObject_i which refers to this object
119   Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; }
120
121   //Returns an IOR of CORBA GEOM_BaseObject_i which refers to this object
122   Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; }
123
124   //###########################################################
125   //Functions methods
126   //###########################################################
127
128   //Adds a function with a driver GUID = theGUID and a type theFunctionType
129   //to the function tree of this GEOM_BaseObject
130   Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID,
131                                                     int                  theFunctionType,
132                                                     bool                 allowSubShape=false);
133
134   //Returns a number of functions of this GEOM_BaseObject
135   Standard_EXPORT int GetNbFunctions();
136
137   //Returns a function with given number theFunctionNumber
138   Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
139
140   //Return the last function of this GEOM_BaseObject
141   Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
142
143   //Returns all dependencies of the object
144   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetAllDependency();
145
146   //Returns the dependencies of the last function
147   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
148
149   //Returns a driver creator of this object
150   Standard_EXPORT Handle(TFunction_Driver) GetCreationDriver();
151
152   //###########################################################
153   // Internal methods
154   //###########################################################
155
156   //Returns a label which could be used to store some additional data
157   Standard_EXPORT TDF_Label GetFreeLabel();
158
159  protected:
160   Handle(TDataStd_TreeNode) _root;
161   TDF_Label                 _label;
162   TCollection_AsciiString   _ior;
163   TCollection_AsciiString   _parameters;
164   int                       _docID;
165
166 public:
167   DEFINE_STANDARD_RTTI( GEOM_BaseObject );
168 };
169
170 #endif