Version: 9.16.0
GEOM_Engine.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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, or (at your option) any later version.
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_Engine_HXX_
24#define _GEOM_Engine_HXX_
25
26#include "GEOM_Application.hxx"
27#include "GEOM_Object.hxx"
29
30#include <TColStd_DataMapOfIntegerTransient.hxx>
31
32#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
33#include <TDocStd_Document.hxx>
34#include <TColStd_HArray1OfInteger.hxx>
35#include <TColStd_HArray1OfByte.hxx>
36#include <TColStd_HSequenceOfAsciiString.hxx>
37#include <TColStd_MapOfInteger.hxx>
38#include <TDF_Label.hxx>
39
40#include <map>
41#include <list>
42#include <vector>
43#include <string>
44
49{
50 TCollection_AsciiString _entry;
51 TCollection_AsciiString _studyEntry;
52 TCollection_AsciiString _name;
53 TCollection_AsciiString _pyName;
55};
56
57struct TVariable{
58 TCollection_AsciiString myVariable;
60
61 TVariable(const TCollection_AsciiString& theVariable, bool theFlag = true):
62 myVariable(theVariable),
63 isVariable(theFlag){}
64};
65
66typedef std::vector<TVariable> TState;
67typedef std::vector<TState> TAllStates;
68
70{
71public:
72 Standard_EXPORT ObjectStates();
74
75 TAllStates GetAllStates() const { return _states; }
76
77 TState GetCurrectState() const;
78 Standard_EXPORT void AddState(const TState &theState);
79 void IncrementState();
80
81private:
84};
85
86typedef std::map<TCollection_AsciiString, ObjectStates* > TVariablesList;
87
88typedef std::map<int, std::list<TDF_Label> > TFreeLabelsList;
89
91{
92public:
93 Standard_EXPORT GEOM_Engine();
94 Standard_EXPORT virtual ~GEOM_Engine();
95
96 //Returns the engine
97 Standard_EXPORT static GEOM_Engine* GetEngine();
98
99 //Returns the OCAF document by its ID, if document doesn't exists it will be created
100 Standard_EXPORT Handle(TDocStd_Document) GetDocument(bool force=true);
101
102 //Returns the OCAF application
103 Standard_EXPORT Handle(TDocStd_Application) GetApplication() { return _OCAFApp; }
104
105 //Returns a pointer to GEOM_BaseObject defined by a document and the entry
106 Standard_EXPORT Handle(GEOM_BaseObject) GetObject(const char* theEntry,
107 bool force=true);
108
109 //Adds a new object of the type theType in the OCAF document
110 Standard_EXPORT Handle(GEOM_BaseObject) AddBaseObject(int theType);
111
112 //Adds a new object of the type theType in the OCAF document
113 Standard_EXPORT Handle(GEOM_Object) AddObject(int theType);
114
115 //Removes the object from the OCAF document
116 Standard_EXPORT bool RemoveObject(Handle(GEOM_BaseObject)& theObject);
117
118 //Saves the OCAF document with file with name theFileName
119 Standard_EXPORT bool Save(const char* theFileName);
120
121 //Loads the OCAF document into the application
122 Standard_EXPORT bool Load(const char* theFileName);
123
124 //Closes the document
125 Standard_EXPORT void Close();
126
127 //Sets the number of Undos (default value = 10)
128 Standard_EXPORT void SetUndoLimit(int theLimit) { _UndoLimit = theLimit; }
129
130 //Applies an Undo to document
131 Standard_EXPORT void Undo();
132
133 //Applies an Redo to document
134 Standard_EXPORT void Redo();
135
136 //Adds a new sub-shape object of the MainShape object
137 Standard_EXPORT Handle(GEOM_Object) AddSubShape(Handle(GEOM_Object) theMainShape,
138 Handle(TColStd_HArray1OfInteger) theIndices,
140
141 Standard_EXPORT TCollection_AsciiString DumpPython(std::vector<TObjectData>& theObjectData,
142 TVariablesList theVariables,
143 bool isPublished,
144 bool isMultiFile,
145 bool& aValidScript);
146
147 Standard_EXPORT const char* GetDumpName (const char* theStudyEntry) const;
148
149 Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const;
150
151 Standard_EXPORT int addTexture(int theWidth, int theHeight,
152 const Handle(TColStd_HArray1OfByte)& theTexture,
153 const TCollection_AsciiString& theFileName = "");
154
155 Standard_EXPORT Handle(TColStd_HArray1OfByte) getTexture(int theTextureID,
156 int& theWidth, int& theHeight,
157 TCollection_AsciiString& theFileName);
158
159 Standard_EXPORT std::list<int> getAllTextures();
160
161 static const Standard_GUID& GetTextureGUID();
162
163 Standard_EXPORT void healPyName( TCollection_AsciiString& pyName,
164 const TCollection_AsciiString& anEntry,
165 Resource_DataMapOfAsciiStringAsciiString& aNameToEntry);
166
167protected:
168 Standard_EXPORT static void SetEngine(GEOM_Engine* theEngine);
169
170private:
171
173 Handle(TDocStd_Document) _document;
174
177
178 Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
179
180 std::list<TDF_Label> _freeLabels;
181};
182
183#endif
static const TopTools_IndexedMapOfShape & theIndices
Definition: GEOMImpl_ShapeDriver.cxx:127
NCollection_DataMap< TCollection_AsciiString, Handle(Standard_Transient)> GEOM_DataMapOfAsciiStringTransient
Definition: GEOM_DataMapOfAsciiStringTransient.hxx:30
std::map< TCollection_AsciiString, ObjectStates * > TVariablesList
Definition: GEOM_Engine.hxx:86
std::vector< TVariable > TState
Definition: GEOM_Engine.hxx:66
std::map< int, std::list< TDF_Label > > TFreeLabelsList
Definition: GEOM_Engine.hxx:88
std::vector< TState > TAllStates
Definition: GEOM_Engine.hxx:67
Definition: GEOM_Application.hxx:32
Definition: GEOM_Engine.hxx:91
Standard_EXPORT int addTexture(int theWidth, int theHeight, const Handle(TColStd_HArray1OfByte)&theTexture, const TCollection_AsciiString &theFileName="")
Standard_EXPORT Handle(GEOM_BaseObject) AddBaseObject(int theType)
Standard_EXPORT int int & theHeight
Definition: GEOM_Engine.hxx:156
Standard_EXPORT bool isStandaloneOperation
Definition: GEOM_Engine.hxx:139
Standard_EXPORT Handle(TDocStd_Document) GetDocument(bool force
Standard_EXPORT Handle(GEOM_BaseObject) GetObject(const char *theEntry
Standard_EXPORT TCollection_AsciiString DumpPython(std::vector< TObjectData > &theObjectData, TVariablesList theVariables, bool isPublished, bool isMultiFile, bool &aValidScript)
Definition: GEOM_Engine.cxx:696
std::list< TDF_Label > _freeLabels
Definition: GEOM_Engine.hxx:180
Handle(TDocStd_Document) _document
Standard_EXPORT Handle(TDocStd_Application) GetApplication()
Definition: GEOM_Engine.hxx:103
Standard_EXPORT const char * GetDumpName(const char *theStudyEntry) const
Definition: GEOM_Engine.cxx:948
Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const
Standard_EXPORT int int TCollection_AsciiString & theFileName
Definition: GEOM_Engine.hxx:157
Standard_EXPORT Handle(TColStd_HArray1OfInteger) theIndices
Standard_EXPORT bool RemoveObject(Handle(GEOM_BaseObject)&theObject)
Definition: GEOM_Engine.cxx:542
Standard_EXPORT std::list< int > getAllTextures()
Definition: GEOM_Engine.cxx:1063
static Standard_EXPORT void SetEngine(GEOM_Engine *theEngine)
Definition: GEOM_Engine.cxx:324
Standard_EXPORT GEOM_Engine()
Definition: GEOM_Engine.cxx:331
Standard_EXPORT void SetUndoLimit(int theLimit)
Definition: GEOM_Engine.hxx:128
Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap
Definition: GEOM_Engine.hxx:178
Handle(GEOM_Application) _OCAFApp
static Standard_EXPORT GEOM_Engine * GetEngine()
Definition: GEOM_Engine.cxx:317
GEOM_DataMapOfAsciiStringTransient _objects
Definition: GEOM_Engine.hxx:176
Standard_EXPORT int & theWidth
Definition: GEOM_Engine.hxx:156
Standard_EXPORT Handle(GEOM_Object) AddSubShape(Handle(GEOM_Object) theMainShape
Standard_EXPORT void Undo()
Definition: GEOM_Engine.cxx:603
Standard_EXPORT bool Save(const char *theFileName)
Definition: GEOM_Engine.cxx:623
virtual Standard_EXPORT ~GEOM_Engine()
Definition: GEOM_Engine.cxx:345
Standard_EXPORT void healPyName(TCollection_AsciiString &pyName, const TCollection_AsciiString &anEntry, Resource_DataMapOfAsciiStringAsciiString &aNameToEntry)
Fix up the name of python variable.
Definition: GEOM_Engine.cxx:276
Standard_EXPORT void Redo()
Definition: GEOM_Engine.cxx:613
Standard_EXPORT void Close()
Definition: GEOM_Engine.cxx:670
int _UndoLimit
Definition: GEOM_Engine.hxx:175
Standard_EXPORT bool Load(const char *theFileName)
Definition: GEOM_Engine.cxx:641
Standard_EXPORT Handle(TColStd_HArray1OfByte) getTexture(int theTextureID
Standard_EXPORT bool force
Definition: GEOM_Engine.hxx:107
static const Standard_GUID & GetTextureGUID()
Definition: GEOM_Engine.cxx:306
Standard_EXPORT Handle(GEOM_Object) AddObject(int theType)
Definition: GEOM_Engine.hxx:70
int _dumpstate
Definition: GEOM_Engine.hxx:83
TAllStates GetAllStates() const
Definition: GEOM_Engine.hxx:75
TState GetCurrectState() const
Return current object state.
Definition: GEOM_Engine.cxx:2034
TAllStates _states
Definition: GEOM_Engine.hxx:82
~ObjectStates()
Destructor.
Definition: GEOM_Engine.cxx:2024
Standard_EXPORT ObjectStates()
Constructor.
Definition: GEOM_Engine.cxx:2014
Standard_EXPORT void AddState(const TState &theState)
Add new object state.
Definition: GEOM_Engine.cxx:2047
void IncrementState()
Increment object state.
Definition: GEOM_Engine.cxx:2057
Data of GEOM_Object.
Definition: GEOM_Engine.hxx:49
TCollection_AsciiString _studyEntry
Definition: GEOM_Engine.hxx:51
bool _unpublished
Definition: GEOM_Engine.hxx:54
TCollection_AsciiString _pyName
Definition: GEOM_Engine.hxx:53
TCollection_AsciiString _name
Definition: GEOM_Engine.hxx:52
TCollection_AsciiString _entry
Definition: GEOM_Engine.hxx:50
Definition: GEOM_Engine.hxx:57
TCollection_AsciiString myVariable
Definition: GEOM_Engine.hxx:58
bool isVariable
Definition: GEOM_Engine.hxx:59
TVariable(const TCollection_AsciiString &theVariable, bool theFlag=true)
Definition: GEOM_Engine.hxx:61