1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef _GEOM_Engine_HXX_
24 #define _GEOM_Engine_HXX_
26 #include "GEOM_Application.hxx"
27 #include "GEOM_Object.hxx"
28 #include "GEOM_DataMapOfAsciiStringTransient.hxx"
30 #include <Basics_OCCTVersion.hxx>
32 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
33 #include <TColStd_DataMapOfIntegerTransient.hxx>
35 #include <Interface_DataMapOfIntegerTransient.hxx>
38 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
39 #include <TDocStd_Document.hxx>
40 #include <TColStd_HArray1OfInteger.hxx>
41 #include <TColStd_HSequenceOfAsciiString.hxx>
42 #include <TColStd_MapOfInteger.hxx>
43 #include <TDF_Label.hxx>
51 * \brief Data of GEOM_Object
55 TCollection_AsciiString _entry;
56 TCollection_AsciiString _studyEntry;
57 TCollection_AsciiString _name;
58 TCollection_AsciiString _pyName;
62 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
63 class Handle_TColStd_HArray1OfByte;
65 class Handle_TDataStd_HArray1OfByte;
69 TCollection_AsciiString myVariable;
72 TVariable(const TCollection_AsciiString& theVariable, bool theFlag = true):
73 myVariable(theVariable),
77 typedef std::vector<TVariable> TState;
78 typedef std::vector<TState> TAllStates;
83 Standard_EXPORT ObjectStates();
86 TAllStates GetAllStates() const { return _states; }
88 TState GetCurrectState() const;
89 Standard_EXPORT void AddState(const TState &theState);
90 void IncrementState();
97 typedef std::map<TCollection_AsciiString, ObjectStates* > TVariablesList;
99 typedef std::map<int, std::list<TDF_Label> > TFreeLabelsList;
104 Standard_EXPORT GEOM_Engine();
105 Standard_EXPORT virtual ~GEOM_Engine();
108 Standard_EXPORT static GEOM_Engine* GetEngine();
110 //Returns the OCAF document by its ID, if document doesn't exists it will be created
111 Standard_EXPORT Handle(TDocStd_Document) GetDocument(int theDocID, bool force=true);
113 //Returns the ID of the given OCAF document
114 Standard_EXPORT int GetDocID(Handle(TDocStd_Document) theDocument);
116 //Returns the OCAF appliaction
117 Standard_EXPORT Handle(TDocStd_Application) GetApplication() { return _OCAFApp; }
119 //Returns a pointer to GEOM_BaseObject defined by a document and the entry
120 Standard_EXPORT Handle(GEOM_BaseObject) GetObject(int theDocID,
121 const char* theEntry,
124 //Adds a new object of the type theType in the OCAF document
125 Standard_EXPORT Handle(GEOM_BaseObject) AddBaseObject(int theDocID, int theType);
127 //Adds a new object of the type theType in the OCAF document
128 Standard_EXPORT Handle(GEOM_Object) AddObject(int theDocID, int theType);
130 //Removes the object from the OCAF document
131 Standard_EXPORT bool RemoveObject(Handle(GEOM_BaseObject)& theObject);
133 //Saves the OCAF document with ID = theDocID with file with name theFileName
134 Standard_EXPORT bool Save(int theDocID, const char* theFileName);
136 //Loads the OCAF document into the application and assigns to it an ID = theDocID
137 Standard_EXPORT bool Load(int theDocID, const char* theFileName);
139 //Closes the document with ID = theDocID
140 Standard_EXPORT void Close(int theDocID);
142 //Sets the number of Undos (default value = 10)
143 Standard_EXPORT void SetUndoLimit(int theLimit) { _UndoLimit = theLimit; }
145 //Applies an Undo to document with ID = theDocID
146 Standard_EXPORT void Undo(int theDocID);
148 //Applies an Redo to document with ID = theDocID
149 Standard_EXPORT void Redo(int theDocID);
151 //Adds a new sub-shape object of the MainShape object
152 Standard_EXPORT Handle(GEOM_Object) AddSubShape(Handle(GEOM_Object) theMainShape,
153 Handle(TColStd_HArray1OfInteger) theIndices,
154 bool isStandaloneOperation = false);
156 Standard_EXPORT TCollection_AsciiString DumpPython(int theDocID,
157 std::vector<TObjectData>& theObjectData,
158 TVariablesList theVariables,
163 Standard_EXPORT const char* GetDumpName (const char* theStudyEntry) const;
165 Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const;
167 Standard_EXPORT int addTexture(int theDocID, int theWidth, int theHeight,
168 const Handle(TColStd_HArray1OfByte)& theTexture,
169 const TCollection_AsciiString& theFileName = "");
171 Standard_EXPORT Handle(TColStd_HArray1OfByte) getTexture(int theDocID, int theTextureID,
172 int& theWidth, int& theHeight,
173 TCollection_AsciiString& theFileName);
175 Standard_EXPORT std::list<int> getAllTextures(int theDocID);
177 static const Standard_GUID& GetTextureGUID();
179 Standard_EXPORT void healPyName( TCollection_AsciiString& pyName,
180 const TCollection_AsciiString& anEntry,
181 Resource_DataMapOfAsciiStringAsciiString& aNameToEntry);
183 Standard_EXPORT void DocumentModified(const int theDocId, const bool isModified);
185 Standard_EXPORT bool DocumentModified(const int theDocId);
188 Standard_EXPORT static void SetEngine(GEOM_Engine* theEngine);
192 Handle(GEOM_Application) _OCAFApp;
193 TColStd_DataMapOfIntegerTransient _mapIDDocument;
194 TColStd_MapOfInteger _mapModifiedDocs; // keeps the identifiers of the modified document ids
197 GEOM_DataMapOfAsciiStringTransient _objects;
199 Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
201 TFreeLabelsList _freeLabels;