Version: 6.3.1

src/GEOM/GEOM_Engine.hxx

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