Back to index

salome-geom  6.5.0
GEOM_Object.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef _GEOM_Object_HeaderFile
00024 #define _GEOM_Object_HeaderFile
00025 
00026 #ifndef _Standard_TypeMismatch_HeaderFile
00027 #include <Standard_TypeMismatch.hxx>
00028 #endif
00029 #ifndef _Standard_HeaderFile
00030 #include <Standard.hxx>
00031 #endif
00032 #ifndef _Standard_Macro_HeaderFile
00033 #include <Standard_Macro.hxx>
00034 #endif
00035 #ifndef _Standard_HeaderFile
00036 #include <Standard.hxx>
00037 #endif
00038 #ifndef _Handle_MMgt_TShared_HeaderFile
00039 #include <Handle_MMgt_TShared.hxx>
00040 #endif
00041 #ifndef _MMgt_TShared_HeaderFile
00042 #include <MMgt_TShared.hxx>
00043 #endif
00044 #ifndef _Standard_GUID_HeaderFile
00045 #include <Standard_GUID.hxx>
00046 #endif
00047 #ifndef _TopoDS_Shape_HeaderFile
00048 #include <TopoDS_Shape.hxx>
00049 #endif
00050 #ifndef _TDF_Label_HeaderFile
00051 #include <TDF_Label.hxx>
00052 #endif
00053 #ifndef _TColStd_HSequenceOfTransient_HeaderFile
00054 #include <TColStd_HSequenceOfTransient.hxx>
00055 #endif
00056 #ifndef _TCollection_AsciiString_HeaderFile
00057 #include <TCollection_AsciiString.hxx>
00058 #endif
00059 #ifndef _Aspect_TypeOfMarker_HeaderFile
00060 #include <Aspect_TypeOfMarker.hxx>
00061 #endif
00062 
00063 
00064 class Handle_TColStd_HSequenceOfTransient;
00065 class Standard_Transient;
00066 class Handle_Standard_Type;
00067 class Handle(MMgt_TShared);
00068 class GEOM_Object;
00069 
00070 
00071 Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_Object);
00072 
00073 class Handle(GEOM_Object) : public Handle(MMgt_TShared) {
00074   public:
00075     inline void* operator new(size_t,void* anAddress)
00076       {
00077         return anAddress;
00078       }
00079     inline void* operator new(size_t size)
00080       {
00081         return Standard::Allocate(size);
00082       }
00083     inline void  operator delete(void *anAddress)
00084       {
00085         if (anAddress) Standard::Free((Standard_Address&)anAddress);
00086       }
00087 
00088     Handle(GEOM_Object)():Handle(MMgt_TShared)() {}
00089     Handle(GEOM_Object)(const Handle(GEOM_Object)& aHandle) : Handle(MMgt_TShared)(aHandle)
00090      {
00091      }
00092 
00093     Handle(GEOM_Object)(const GEOM_Object* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem)
00094      {
00095      }
00096 
00097     Handle(GEOM_Object)& operator=(const Handle(GEOM_Object)& aHandle)
00098      {
00099       Assign(aHandle.Access());
00100       return *this;
00101      }
00102 
00103     Handle(GEOM_Object)& operator=(const GEOM_Object* anItem)
00104      {
00105       Assign((Standard_Transient *)anItem);
00106       return *this;
00107      }
00108 
00109     GEOM_Object* operator->()
00110      {
00111       return (GEOM_Object *)ControlAccess();
00112      }
00113 
00114     GEOM_Object* operator->() const
00115      {
00116       return (GEOM_Object *)ControlAccess();
00117      }
00118 
00119    Standard_EXPORT ~Handle(GEOM_Object)() {};
00120 
00121    Standard_EXPORT static const Handle(GEOM_Object) DownCast(const Handle(Standard_Transient)& AnObject);
00122 };
00123 
00124 
00125 #include <Standard_GUID.hxx>
00126 #include <TDataStd_TreeNode.hxx>
00127 #include "GEOM_Function.hxx"
00128 #include "GEOM_Engine.hxx"
00129 
00130 class GEOM_Object : public MMgt_TShared
00131 {
00132  friend class GEOM_Engine;
00133  
00134  public:
00135   struct Color {
00137     double R;
00139     double G;
00141     double B;
00142   };
00143 
00144  public:
00145   inline void* operator new(size_t,void* anAddress)
00146     {
00147       return anAddress;
00148     }
00149   inline void* operator new(size_t size)
00150     {
00151       return Standard::Allocate(size);
00152     }
00153   inline void  operator delete(void *anAddress)
00154     {
00155       if (anAddress) Standard::Free((Standard_Address&)anAddress);
00156     }
00157 
00158   // Type management
00159   //
00160   Standard_EXPORT friend Handle_Standard_Type& GEOM_Object_Type_();
00161   Standard_EXPORT const Handle(Standard_Type)& DynamicType() const  { return STANDARD_TYPE(GEOM_Object) ; }
00162   Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const
00163            { return (STANDARD_TYPE(GEOM_Object) == AType || MMgt_TShared::IsKind(AType)); }
00164 
00165  private:
00166   GEOM_Object(TDF_Label& theLabel);
00167 
00168  public:
00169   Standard_EXPORT GEOM_Object(TDF_Label& theEntry, int theType);
00170   Standard_EXPORT ~GEOM_Object();
00171 
00172   //Finds a GEOM_Object on the label theLabel
00173   Standard_EXPORT static Handle(GEOM_Object) GetObject(TDF_Label& theLabel);
00174 
00175   //Finds a GEOM_Object by a reference, stored on the label theLabel
00176   Standard_EXPORT static Handle(GEOM_Object) GetReferencedObject(TDF_Label& theLabel);
00177 
00178   //Returns a GEOM_Object common GUID
00179   Standard_EXPORT static const Standard_GUID& GetObjectID();
00180 
00181   //Returns a GUID associated with a sub-shape object
00182   Standard_EXPORT static const Standard_GUID& GetSubShapeID();
00183 
00184   //###########################################################
00185   //Access to properties
00186   //###########################################################
00187 
00188   //Returns a TreeNode that presents a root of a function tree for this GEOM_Object
00189   Standard_EXPORT Handle(TDataStd_TreeNode) GetRootNode() { return _root; }
00190 
00191   //Returns a label of this GEOM_Object
00192   Standard_EXPORT TDF_Label GetEntry() { return _label; }
00193 
00194   //Returns a type of this GEOM_Object (GEOM_POINT, GEOM_VECTOR...)
00195   Standard_EXPORT int GetType();
00196 
00197   //Sets the type of this GEOM_Object
00198   Standard_EXPORT void SetType(int theType);
00199 
00200   //Modifications counter management
00201   Standard_EXPORT int  GetTic();
00202   Standard_EXPORT void SetTic(int theTic);
00203   Standard_EXPORT void IncrementTic();
00204 
00205   //Returns an ID of the OCAF document where this GEOM_Object is stored
00206   Standard_EXPORT int GetDocID();
00207 
00208   //Returns a value (as TopoDS_Shape) of this GEOM_Object
00209   Standard_EXPORT TopoDS_Shape GetValue();
00210 
00211   //Sets a name of this GEOM_Object
00212   Standard_EXPORT void SetName(const char* theName);
00213 
00214   //Returns a name of this GEOM_Object
00215   Standard_EXPORT char* GetName();
00216 
00217   //Sets a color of this GEOM_Object
00218   Standard_EXPORT void SetColor(const Color& theColor);
00219 
00220   //Returns a color of this GEOM_Object
00221   Standard_EXPORT Color GetColor();
00222 
00223   //Toggles an auto color mode on this GEOM_Object
00224   Standard_EXPORT void SetAutoColor(bool theAutoColor);
00225 
00226   //Returns a flag of auto color mode of this GEOM_Object
00227   Standard_EXPORT bool GetAutoColor();
00228 
00229   //Sets predefined point marker texture
00230   Standard_EXPORT void SetMarkerStd(const Aspect_TypeOfMarker theType, double theSize);
00231   
00232   //Sets custom point marker texture
00233   Standard_EXPORT void SetMarkerTexture(int theTextureId);
00234 
00235   //Gets point marker type
00236   Standard_EXPORT Aspect_TypeOfMarker GetMarkerType();
00237 
00238   //Gets point marker scale factor / size
00239   Standard_EXPORT double GetMarkerSize();
00240 
00241   //Gets custom marker texture ID
00242   Standard_EXPORT int GetMarkerTexture();
00243 
00244   //Unsets point marker
00245   Standard_EXPORT void UnsetMarker();
00246 
00247   //Sets an auxiliary data
00248   Standard_EXPORT void SetAuxData(const char* theData);
00249 
00250   //Returns an auxiliary data
00251   Standard_EXPORT TCollection_AsciiString GetAuxData();
00252 
00253   //Set a notebook variables used for object creation
00254   Standard_EXPORT void SetParameters(const TCollection_AsciiString& theParameters);
00255 
00256   //Get a notebook variables used for object creation
00257   Standard_EXPORT TCollection_AsciiString GetParameters() const;
00258 
00259   //###########################################################
00260   // Sub-shape methods
00261   //###########################################################
00262 
00263   //Returns false if the object is a sub-shape of another object
00264   Standard_EXPORT bool IsMainShape();
00265 
00266   //###########################################################
00267   // CORBA related methods
00268   //###########################################################
00269 
00270   //Sets an IOR of CORBA GEOM_Object_i which refers to this object
00271   Standard_EXPORT void SetIOR(TCollection_AsciiString& theIOR) { _ior = theIOR; }
00272 
00273   //Returns an IOR of CORBA GEOM_Object_i which refers to this object
00274   Standard_EXPORT TCollection_AsciiString GetIOR() { return _ior; }
00275 
00276   //###########################################################
00277   //Functions methods
00278   //###########################################################
00279 
00280   //Adds a function with a driver GUID = theGUID and a type theFunctionType
00281   //to the function tree of this GEOM_Object
00282   Standard_EXPORT Handle(GEOM_Function) AddFunction(const Standard_GUID& theGUID, int theFunctionType);
00283 
00284   //Returns a number of functions of this GEOM_Object
00285   Standard_EXPORT int GetNbFunctions();
00286 
00287   //Returns a function with given number theFunctionNumber
00288   Standard_EXPORT Handle(GEOM_Function) GetFunction(int theFunctionNumber);
00289 
00290   //Return the last function of this GEOM_Object
00291   Standard_EXPORT Handle(GEOM_Function) GetLastFunction();
00292 
00293   //Returns all dependencies of the object
00294   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetAllDependency();
00295 
00296   //Returns the dependencies of the last function
00297   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
00298 
00299   //###########################################################
00300   // Internal methods
00301   //###########################################################
00302 
00303   //Returns a label which could be used to store some additional data
00304   Standard_EXPORT TDF_Label GetFreeLabel();
00305 
00306  private:
00307   Handle(TDataStd_TreeNode) _root;
00308   TDF_Label                 _label;
00309   TCollection_AsciiString   _ior;
00310   TCollection_AsciiString   _parameters;
00311   int                       _docID;
00312 
00313 
00314 };
00315 
00316 #endif