Back to index

salome-geom  6.5.0
GEOM_Engine.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_Engine_HXX_
00024 #define _GEOM_Engine_HXX_
00025 
00026 #include "GEOM_Application.hxx"
00027 #include "GEOM_Object.hxx"
00028 #include "GEOM_DataMapOfAsciiStringTransient.hxx"
00029 
00030 #include <Basics_OCCTVersion.hxx>
00031 
00032 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
00033 #include <TColStd_DataMapOfIntegerTransient.hxx>
00034 #else
00035 #include <Interface_DataMapOfIntegerTransient.hxx>
00036 #endif
00037 
00038 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
00039 #include <TDocStd_Document.hxx>
00040 #include <TColStd_HArray1OfInteger.hxx>
00041 #include <TColStd_HSequenceOfAsciiString.hxx>
00042 #include <TDF_Label.hxx>
00043 
00044 #include <map>
00045 #include <list>
00046 #include <vector>
00047 #include <string>
00048 
00052 struct TObjectData
00053 {
00054   TCollection_AsciiString _entry;
00055   TCollection_AsciiString _studyEntry;
00056   TCollection_AsciiString _name;
00057   TCollection_AsciiString _pyName;
00058   bool                    _unpublished;
00059 };
00060   
00061 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
00062 class Handle_TColStd_HArray1OfByte;
00063 #else
00064 class Handle_TDataStd_HArray1OfByte;
00065 #endif
00066 
00067 struct TVariable{
00068   TCollection_AsciiString myVariable;
00069   bool isVariable;
00070 
00071   TVariable(const TCollection_AsciiString& theVariable, bool theFlag = true):
00072     myVariable(theVariable),
00073     isVariable(theFlag){}
00074 };
00075 
00076 typedef std::vector<TVariable> TState;
00077 typedef std::vector<TState>    TAllStates;
00078 
00079 class ObjectStates
00080 {
00081 public:
00082   Standard_EXPORT ObjectStates();
00083   ~ObjectStates();
00084 
00085   TAllStates GetAllStates() const { return _states; }
00086 
00087   TState GetCurrectState() const;
00088   Standard_EXPORT void AddState(const TState &theState);
00089   void IncrementState();
00090 
00091 private:
00092   TAllStates              _states;
00093   int                     _dumpstate;
00094 };
00095 
00096 typedef std::map<TCollection_AsciiString, ObjectStates* > TVariablesList;
00097 
00098 typedef std::map<int, std::list<TDF_Label> > TFreeLabelsList;
00099 
00100 class GEOM_Engine
00101 {
00102  public:
00103   Standard_EXPORT GEOM_Engine();
00104   Standard_EXPORT virtual ~GEOM_Engine();
00105 
00106   //Retuns the engine    
00107   Standard_EXPORT static GEOM_Engine* GetEngine();   
00108 
00109   //Returns the OCAF document by its ID, if document doesn't exists it will be created
00110   Standard_EXPORT Handle(TDocStd_Document) GetDocument(int theDocID, bool force=true);
00111 
00112   //Returns the ID of the given OCAF document
00113   Standard_EXPORT int GetDocID(Handle(TDocStd_Document) theDocument);
00114   
00115   //Returns the OCAF appliaction
00116   Standard_EXPORT Handle(TDocStd_Application) GetApplication() { return _OCAFApp; }
00117 
00118   //Returns a pointer to GEOM_Object defined by a document and the entry
00119   Standard_EXPORT Handle(GEOM_Object) GetObject(int theDocID, char* theEntry, bool force=true);
00120   
00121   //Adds a new object of the type theType in the OCAF document
00122   Standard_EXPORT Handle(GEOM_Object) AddObject(int theDocID, int theType);
00123 
00124   //Removes the object from the OCAF document
00125   Standard_EXPORT bool RemoveObject(Handle(GEOM_Object) theObject);  
00126 
00127   //Saves the OCAF document with ID = theDocID with file with name theFileName
00128   Standard_EXPORT bool Save(int theDocID, char* theFileName);
00129   
00130   //Loads the OCAF document into the application and assigns to it an ID = theDocID
00131   Standard_EXPORT bool Load(int theDocID, char* theFileName);
00132 
00133   //Closes the document with ID =  theDocID
00134   Standard_EXPORT void Close(int theDocID);
00135 
00136   //Sets the number of Undos (default value = 10)
00137   Standard_EXPORT void SetUndoLimit(int theLimit) { _UndoLimit = theLimit; }
00138 
00139   //Applies an Undo to document with ID = theDocID
00140   Standard_EXPORT void Undo(int theDocID);
00141 
00142   //Applies an Redo to document with ID = theDocID
00143   Standard_EXPORT void Redo(int theDocID);
00144 
00145   //Adds a new sub-shape object of the MainShape object
00146   Standard_EXPORT Handle(GEOM_Object) AddSubShape(Handle(GEOM_Object) theMainShape, 
00147                                   Handle(TColStd_HArray1OfInteger) theIndices,
00148                                   bool isStandaloneOperation = false);
00149 
00150   Standard_EXPORT TCollection_AsciiString DumpPython(int theDocID, 
00151                                                      std::vector<TObjectData>& theObjectData,
00152                                                      TVariablesList theVariables,
00153                                                      bool isPublished, 
00154                                                      bool isMultiFile, 
00155                                                      bool& aValidScript);
00156 
00157   Standard_EXPORT const char* GetDumpName (const char* theStudyEntry) const;
00158 
00159   Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const;
00160 
00161   Standard_EXPORT int addTexture(int theDocID, int theWidth, int theHeight,
00162 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
00163                                  const Handle(TColStd_HArray1OfByte)& theTexture,
00164 #else
00165                                  const Handle(TDataStd_HArray1OfByte)& theTexture,
00166 #endif
00167                                  const TCollection_AsciiString& theFileName = "");
00168 
00169 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
00170   Standard_EXPORT Handle(TColStd_HArray1OfByte) getTexture(int theDocID, int theTextureID,
00171 #else
00172   Standard_EXPORT Handle(TDataStd_HArray1OfByte) getTexture(int theDocID, int theTextureID,
00173 #endif
00174                                                            int& theWidth, int& theHeight,
00175                                                            TCollection_AsciiString& theFileName);
00176 
00177   Standard_EXPORT std::list<int> getAllTextures(int theDocID);
00178 
00179   static const Standard_GUID& GetTextureGUID();
00180 
00181  protected:
00182   Standard_EXPORT static void SetEngine(GEOM_Engine* theEngine);       
00183   
00184  private:
00185 
00186   Handle(GEOM_Application)  _OCAFApp;
00187 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
00188   TColStd_DataMapOfIntegerTransient _mapIDDocument;
00189 #else
00190   Interface_DataMapOfIntegerTransient _mapIDDocument;
00191 #endif
00192   int _UndoLimit;
00193   GEOM_DataMapOfAsciiStringTransient _objects;
00194 
00195   Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
00196 
00197   TFreeLabelsList _freeLabels;
00198 };
00199 
00200 #endif