/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. #ifndef _GEOM_Engine_HXX_
  21. #define _GEOM_Engine_HXX_
  22. #include "SGEOM_Application.hxx"
  23. #include "SGEOM_Object.hxx"
  24. #include "SGEOM_DataMapOfAsciiStringTransient.hxx"
  25. #include <Interface_DataMapOfIntegerTransient.hxx>
  26. #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
  27. #include <TDocStd_Document.hxx>
  28. #include <TColStd_HArray1OfInteger.hxx>
  29. #include <TColStd_HArray1OfTransient.hxx>
  30. #include <TColStd_HSequenceOfAsciiString.hxx>
  31. //---------------------------------------------------------------------------
  32. #include <ExprIntrp_Analysis.hxx>
  33. #include <ExprIntrp_GenExp.hxx>
  34. #include <Expr_NamedConstant.hxx>
  35. //---------------------------------------------------------------------------
  36. #ifdef GetObject
  37. #undef GetObject
  38. #endif
  39. #include <map>
  40. #include <list>
  41. #include <vector>
  42. struct TVariable{
  43. TCollection_AsciiString myVariable;
  44. bool isVariable;
  45. TVariable(const TCollection_AsciiString& theVariable, bool theFlag = true):
  46. myVariable(theVariable),
  47. isVariable(theFlag){}
  48. };
  49. typedef std::vector<TVariable> TState;
  50. typedef std::vector<TState> TAllStates;
  51. class ObjectStates
  52. {
  53. public:
  54. Standard_EXPORT ObjectStates();
  55. ~ObjectStates();
  56. TAllStates GetAllStates() const { return _states; }
  57. TState GetCurrectState() const;
  58. Standard_EXPORT void AddState(const TState &theState);
  59. void IncrementState();
  60. private:
  61. TAllStates _states;
  62. int _dumpstate;
  63. };
  64. typedef std::map<TCollection_AsciiString, ObjectStates* > TVariablesList;
  65. #ifdef MEM_OPTIMISED_LABEL
  66. typedef std::map<int, std::list<TDF_Label> > TFreeLabelsList;
  67. #endif
  68. //!Manages documents and objects in a document
  69. class GEOM_Engine
  70. {
  71. public:
  72. Standard_EXPORT GEOM_Engine();
  73. Standard_EXPORT virtual ~GEOM_Engine();
  74. //!Retuns the engine
  75. Standard_EXPORT static GEOM_Engine* GetEngine();
  76. //!Checks if the document with document id theDocID exists in the framework
  77. Standard_EXPORT bool IsDocumentExistant(int theDocID);
  78. //!Returns the OCAF document by its ID, if document doesn't exists it will be created
  79. Standard_EXPORT Handle(TDocStd_Document) GetDocument(int theDocID);
  80. //!Returns the ID of the given OCAF document
  81. Standard_EXPORT int GetDocID(Handle(TDocStd_Document) theDocument);
  82. //!Returns the OCAF appliaction
  83. Standard_EXPORT Handle(TDocStd_Application) GetApplication() { return _OCAFApp; }
  84. //!Returns a pointer to GEOM_Object defined by a document and the entry
  85. Standard_EXPORT Handle(GEOM_Object) GetObject(int theDocID, const char* theEntry);
  86. //!Adds a new object of the type theType in the OCAF document
  87. Standard_EXPORT Handle(GEOM_Object) AddObject(int theDocID, int theType);
  88. //!Removes the object from the OCAF document
  89. Standard_EXPORT bool RemoveObject(Handle(GEOM_Object) theObject);
  90. //!Saves the OCAF document with ID = theDocID with file with name theFileName
  91. Standard_EXPORT bool Save(int theDocID, char* theFileName);
  92. //!Loads the OCAF document into the application and assigns to it an ID = theDocID
  93. Standard_EXPORT bool Load(int theDocID, char* theFileName);
  94. //!Closes the document with ID = theDocID
  95. Standard_EXPORT void Close(int theDocID);
  96. //!Sets the number of Undos (default value = 10)
  97. Standard_EXPORT void SetUndoLimit(int theLimit) { _UndoLimit = theLimit; }
  98. //!Applies an Undo to document with ID = theDocID
  99. Standard_EXPORT void Undo(int theDocID);
  100. //!Applies an Redo to document with ID = theDocID
  101. Standard_EXPORT void Redo(int theDocID);
  102. //!Adds a new sub shape object of the MainShape object
  103. Standard_EXPORT Handle(GEOM_Object) AddSubShape(Handle(GEOM_Object) theMainShape,
  104. Handle(TColStd_HArray1OfInteger) theIndices,
  105. bool isStandaloneOperation = false);
  106. //!Returns Python script of document
  107. Standard_EXPORT TCollection_AsciiString DumpPython(int theDocID,
  108. Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
  109. TVariablesList theVariables,
  110. bool isPublished,
  111. bool& aValidScript);
  112. //!Returns dump name
  113. Standard_EXPORT const char* GetDumpName (const char* theStudyEntry) const;
  114. //!Returns all dump names
  115. Standard_EXPORT Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const;
  116. //!Queries the engine for the value of a variable
  117. Standard_EXPORT bool GetInterpreterEquationValue(int theDocID, const TCollection_AsciiString& theEquation, double& theRefValue);
  118. //!Sets to the engine a new variable
  119. Standard_EXPORT void SetInterpreterConstant(int theDocID, const TCollection_AsciiString& theConstant, double theValue, const TCollection_AsciiString& theDescription, bool isUpdateDescription = true);
  120. //!Gets an array with all the variables in use in a document
  121. Standard_EXPORT void GetInterpreterConstantArray(int theDocID, Handle(TColStd_HArray1OfTransient)& theArray, Handle(TColStd_HArray1OfAsciiString)& theDescriptions);
  122. //!Sets an array with all the variables to be used in a document
  123. Standard_EXPORT void SetInterpreterConstantArray(int theDocID, Handle(TColStd_HArray1OfTransient) theArray, Handle(TColStd_HArray1OfAsciiString) theDescriptions, bool forgetPrevious);
  124. //!Returns a label which could be used to store user data on documents
  125. Standard_EXPORT TDF_Label GetUserDataLabel(int theDocID);
  126. protected:
  127. Standard_EXPORT static void SetEngine(GEOM_Engine* theEngine);
  128. private:
  129. Handle(GEOM_Application) _OCAFApp;
  130. Interface_DataMapOfIntegerTransient _mapIDDocument;
  131. int _UndoLimit;
  132. GEOM_DataMapOfAsciiStringTransient _objects;
  133. Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
  134. #ifdef MEM_OPTIMISED_LABEL
  135. TFreeLabelsList _freeLabels;
  136. #endif
  137. };
  138. #endif