Salome HOME
b5ea794e38c2459fe69f68e960dfff322e48335e
[modules/geom.git] / src / GEOM / GEOM_Engine.hxx
1
2 #ifndef _GEOM_Engine_HXX_
3 #define _GEOM_Engine_HXX_
4
5 #include "GEOM_Application.hxx"
6 #include "GEOM_Object.hxx"
7 #include "GEOM_DataMapOfAsciiStringTransient.hxx"
8
9 #include <Interface_DataMapOfIntegerTransient.hxx> 
10 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
11 #include <TDocStd_Document.hxx>
12 #include <TColStd_HArray1OfInteger.hxx>
13 #include <TColStd_HSequenceOfAsciiString.hxx>
14
15 class GEOM_Engine
16 {
17  public:
18   GEOM_Engine();
19   ~GEOM_Engine() { _mapIDDocument.Clear(); _objects.Clear(); }
20
21   //Retuns the engine    
22   static GEOM_Engine* GetEngine();   
23
24   //Returns the OCAF document by its ID, if document doesn't exists it will be created
25   Handle(TDocStd_Document) GetDocument(int theDocID);
26
27   //Returns the ID of the given OCAF document
28   int GetDocID(Handle(TDocStd_Document) theDocument);
29   
30   //Returns the OCAF appliaction
31   Handle(TDocStd_Application) GetApplication() { return _OCAFApp; }
32
33   //Returns a pointer to GEOM_Object defined by a document and the entry
34   Handle(GEOM_Object) GetObject(int theDocID, char* theEntry);
35   
36   //Adds a new object of the type theType in the OCAF document
37   Handle(GEOM_Object) AddObject(int theDocID, int theType);
38
39   //Removes the object from the OCAF document
40   bool RemoveObject(Handle(GEOM_Object) theObject);  
41
42   //Saves the OCAF document with ID = theDocID with file with name theFileName
43   bool Save(int theDocID, char* theFileName);
44   
45   //Loads the OCAF document into the application and assigns to it an ID = theDocID
46   bool Load(int theDocID, char* theFileName);
47
48   //Closes the document with ID =  theDocID
49   void Close(int theDocID);
50
51   //Sets the number of Undos (default value = 10)
52   void SetUndoLimit(int theLimit) { _UndoLimit = theLimit; }
53
54   //Applies an Undo to document with ID = theDocID
55   void Undo(int theDocID);
56
57   //Applies an Redo to document with ID = theDocID
58   void Redo(int theDocID);
59
60   //Adds a new sub shape object of the MainShape object
61   Handle(GEOM_Object) AddSubShape(Handle(GEOM_Object) theMainShape, 
62                                   Handle(TColStd_HArray1OfInteger) theIndices,
63                                   bool isStandaloneOperation = false);
64
65   TCollection_AsciiString DumpPython(int theDocID, 
66                                      Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
67                                      bool isPublished, 
68                                      bool& aValidScript);
69
70   const char* GetDumpName (const char* theStudyEntry) const;
71
72   Handle(TColStd_HSequenceOfAsciiString) GetAllDumpNames() const;
73
74  protected:
75   static void SetEngine(GEOM_Engine* theEngine);       
76
77  private:
78
79   Handle(GEOM_Application)  _OCAFApp;
80   Interface_DataMapOfIntegerTransient _mapIDDocument;
81   int _UndoLimit;
82   GEOM_DataMapOfAsciiStringTransient _objects;
83
84   Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
85 };
86
87 #endif