PageRenderTime 18ms CodeModel.GetById 7ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/src/contrib/geom-5.1.2.7/inc_pythonocc/SGEOM_Engine.hxx

http://pythonocc.googlecode.com/
C++ Header | 186 lines | 93 code | 48 blank | 45 comment | 0 complexity | 29ce5b3c24b41776d3be2d606e7722e2 MD5 | raw file
  1// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
  2// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
  3// 
  4// This library is free software; you can redistribute it and/or
  5// modify it under the terms of the GNU Lesser General Public
  6// License as published by the Free Software Foundation; either 
  7// version 2.1 of the License.
  8// 
  9// This library is distributed in the hope that it will be useful 
 10// but WITHOUT ANY WARRANTY; without even the implied warranty of 
 11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
 12// Lesser General Public License for more details.
 13//
 14// You should have received a copy of the GNU Lesser General Public  
 15// License along with this library; if not, write to the Free Software 
 16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 17//
 18// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 19//
 20
 21#ifndef _GEOM_Engine_HXX_
 22#define _GEOM_Engine_HXX_
 23
 24#include "SGEOM_Application.hxx"
 25#include "SGEOM_Object.hxx"
 26#include "SGEOM_DataMapOfAsciiStringTransient.hxx"
 27
 28#include <Interface_DataMapOfIntegerTransient.hxx> 
 29#include <Resource_DataMapOfAsciiStringAsciiString.hxx>
 30#include <TDocStd_Document.hxx>
 31#include <TColStd_HArray1OfInteger.hxx>
 32#include <TColStd_HArray1OfTransient.hxx>
 33#include <TColStd_HSequenceOfAsciiString.hxx>
 34
 35//---------------------------------------------------------------------------
 36#include <ExprIntrp_Analysis.hxx>
 37#include <ExprIntrp_GenExp.hxx>
 38#include <Expr_NamedConstant.hxx>
 39//---------------------------------------------------------------------------
 40
 41#ifdef GetObject
 42#undef GetObject
 43#endif
 44
 45#include <map>
 46#include <list>
 47#include <vector>
 48
 49struct TVariable{
 50  TCollection_AsciiString myVariable;
 51  bool isVariable;
 52
 53  TVariable(const TCollection_AsciiString& theVariable, bool theFlag = true):
 54    myVariable(theVariable),
 55    isVariable(theFlag){}
 56};
 57
 58typedef std::vector<TVariable> TState;
 59typedef std::vector<TState>    TAllStates;
 60
 61class ObjectStates
 62{
 63public:
 64  Standard_EXPORT ObjectStates();
 65  ~ObjectStates();
 66
 67  TAllStates GetAllStates() const { return _states; }
 68
 69  TState GetCurrectState() const;
 70  Standard_EXPORT void AddState(const TState &theState);
 71  void IncrementState();
 72
 73private:
 74  TAllStates              _states;
 75  int                     _dumpstate;
 76};
 77
 78typedef std::map<TCollection_AsciiString, ObjectStates* > TVariablesList;
 79
 80#ifdef MEM_OPTIMISED_LABEL
 81typedef std::map<int, std::list<TDF_Label> > TFreeLabelsList;
 82#endif
 83
 84//!Manages documents and objects in a document
 85class GEOM_Engine
 86{
 87 public:
 88  Standard_EXPORT GEOM_Engine();
 89  Standard_EXPORT virtual ~GEOM_Engine();
 90
 91  //!Retuns the engine
 92  Standard_EXPORT static GEOM_Engine* GetEngine();
 93
 94  //!Checks if the document with document id theDocID exists in the framework
 95  Standard_EXPORT bool IsDocumentExistant(int theDocID);
 96
 97  //!Returns the OCAF document by its ID, if document doesn't exists it will be created
 98  Standard_EXPORT Handle(TDocStd_Document) GetDocument(int theDocID);
 99
100  //!Returns the ID of the given OCAF document
101  Standard_EXPORT int GetDocID(Handle(TDocStd_Document) theDocument);
102  
103  //!Returns the OCAF appliaction
104  Standard_EXPORT Handle(TDocStd_Application) GetApplication() { return _OCAFApp; }
105
106  //!Returns a pointer to GEOM_Object defined by a document and the entry
107  Standard_EXPORT Handle(GEOM_Object) GetObject(int theDocID, const char* theEntry);
108  
109  //!Adds a new object of the type theType in the OCAF document
110  Standard_EXPORT Handle(GEOM_Object) AddObject(int theDocID, int theType);
111
112  //!Removes the object from the OCAF document
113  Standard_EXPORT bool RemoveObject(Handle(GEOM_Object) theObject);  
114
115  //!Saves the OCAF document with ID = theDocID with file with name theFileName
116  Standard_EXPORT bool Save(int theDocID, char* theFileName);
117  
118  //!Loads the OCAF document into the application and assigns to it an ID = theDocID
119  Standard_EXPORT bool Load(int theDocID, char* theFileName);
120
121  //!Closes the document with ID =  theDocID
122  Standard_EXPORT void Close(int theDocID);
123
124  //!Sets the number of Undos (default value = 10)
125  Standard_EXPORT void SetUndoLimit(int theLimit) { _UndoLimit = theLimit; }
126
127  //!Applies an Undo to document with ID = theDocID
128  Standard_EXPORT void Undo(int theDocID);
129
130  //!Applies an Redo to document with ID = theDocID
131  Standard_EXPORT void Redo(int theDocID);
132
133  //!Adds a new sub shape object of the MainShape object
134  Standard_EXPORT Handle(GEOM_Object) AddSubShape(Handle(GEOM_Object) theMainShape, 
135                    Handle(TColStd_HArray1OfInteger) theIndices,
136                    bool isStandaloneOperation = false);
137
138  //!Returns Python script of document
139  Standard_EXPORT TCollection_AsciiString DumpPython(int theDocID,
140                        Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
141                        TVariablesList theVariables,
142                        bool isPublished,
143                        bool& aValidScript);
144
145  //!Returns dump name
146  Standard_EXPORT const char* GetDumpName (const char* theStudyEntry) const;
147
148  //!Returns all dump names
149  Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const;
150
151  //!Queries the engine for the value of a variable
152  Standard_EXPORT bool GetInterpreterEquationValue(int theDocID, const TCollection_AsciiString& theEquation, double& theRefValue);
153
154  //!Sets to the engine a new variable
155  Standard_EXPORT void SetInterpreterConstant(int theDocID, const TCollection_AsciiString& theConstant, double theValue, const TCollection_AsciiString& theDescription, bool isUpdateDescription = true);
156
157  //!Gets an array with all the variables in use in a document
158  Standard_EXPORT void GetInterpreterConstantArray(int theDocID, Handle(TColStd_HArray1OfTransient)& theArray, Handle(TColStd_HArray1OfAsciiString)& theDescriptions);
159
160  //!Sets an array with all the variables to be used in a document
161  Standard_EXPORT void SetInterpreterConstantArray(int theDocID, Handle(TColStd_HArray1OfTransient) theArray, Handle(TColStd_HArray1OfAsciiString) theDescriptions, bool forgetPrevious);
162
163  //!Returns a label which could be used to store user data on documents
164  Standard_EXPORT TDF_Label GetUserDataLabel(int theDocID);
165
166 protected:
167  Standard_EXPORT static void SetEngine(GEOM_Engine* theEngine);
168
169 private:
170
171  Handle(GEOM_Application)  _OCAFApp;
172
173  Interface_DataMapOfIntegerTransient _mapIDDocument;
174
175  int _UndoLimit;
176  GEOM_DataMapOfAsciiStringTransient _objects;
177
178  Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
179
180  #ifdef MEM_OPTIMISED_LABEL
181  TFreeLabelsList _freeLabels;
182  #endif
183
184};
185
186#endif