Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/geom.git] / src / GEOM_I / GEOM_Gen_i.hh
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, 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.
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 #ifndef __GEOM_GEN_I_H__
23 #define __GEOM_GEN_I_H__
24
25 #include "GEOM_GEOM_I.hxx"
26
27 #include "GEOMImpl_Gen.hxx"
28
29 // IDL headers
30 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(GEOM_Gen)
32
33 #include CORBA_CLIENT_HEADER(SALOMEDS)
34 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
35
36
37 #include "SALOME_Component_i.hxx"
38 #include "SALOME_NamingService.hxx"
39
40 #include "GEOM_IBasicOperations_i.hh"
41 #include "GEOM_ITransformOperations_i.hh"
42 #include "GEOM_I3DPrimOperations_i.hh"
43 #include "GEOM_IShapesOperations_i.hh"
44 #include "GEOM_IBlocksOperations_i.hh"
45 #include "GEOM_IBooleanOperations_i.hh"
46 #include "GEOM_ICurvesOperations_i.hh"
47 #include "GEOM_ILocalOperations_i.hh"
48 #include "GEOM_IHealingOperations_i.hh"
49 #include "GEOM_IInsertOperations_i.hh"
50 #include "GEOM_IMeasureOperations_i.hh"
51 #include "GEOM_IGroupOperations_i.hh"
52
53 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
54
55
56 //=====================================================================
57 // GEOM_Gen_i : class definition
58 //=====================================================================
59 class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual public Engines_Component_i
60 {
61  public:
62
63   //-----------------------------------------------------------------------//
64   // Constructor / Destructor                                              //
65   //-----------------------------------------------------------------------//
66
67   // constructor to be called for servant creation.
68   GEOM_Gen_i();
69   GEOM_Gen_i(CORBA::ORB_ptr orb,
70              PortableServer::POA_ptr poa,
71              PortableServer::ObjectId * contId,
72              const char *instanceName,
73              const char *interfaceName);
74
75   // destructor, doing nothing (for now)
76   virtual ~GEOM_Gen_i();
77
78   // generic method to be put in a super class
79   void register_name(char * name);
80
81
82   //-----------------------------------------------------------------------//
83   // Inherited methods from SALOMEDS::Driver                               //
84   //-----------------------------------------------------------------------//
85
86   SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
87                           const char* theURL,
88                           bool isMultiFile);
89
90   SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
91                                const char* theURL,
92                                bool isMultiFile);
93
94   CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
95                       const SALOMEDS::TMPFile& theStream,
96                       const char* theURL,
97                       bool isMultiFile);
98
99   CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
100                            const SALOMEDS::TMPFile& theStream,
101                            const char* theURL,
102                            bool isMultiFile);
103
104   void Close(SALOMEDS::SComponent_ptr theComponent);
105   char* ComponentDataType();
106
107
108   char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
109                                const char* IORString,
110                                CORBA::Boolean isMultiFile,
111                                CORBA::Boolean isASCII);
112   char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
113                                const char* aLocalPersistentID,
114                                CORBA::Boolean isMultiFile,
115                                CORBA::Boolean isASCII);
116
117   bool CanPublishInStudy(CORBA::Object_ptr theIOR);
118   SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
119                                        SALOMEDS::SObject_ptr theSObject,
120                                        CORBA::Object_ptr theObject,
121                                        const char* theName) throw (SALOME::SALOME_Exception) ;
122
123   CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
124   SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
125   CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
126   SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
127                                   CORBA::Long theObjectID,
128                                   SALOMEDS::SObject_ptr theObject);
129
130   /*! \brief Adds theObject in the study with a name = theName, if
131    *         theFather is not null the object is placed under theFather
132    */
133   SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
134                                     GEOM::GEOM_Object_ptr theObject,
135                                     const char* theName,
136                                     GEOM::GEOM_Object_ptr theFather);
137
138   /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
139    *         To be used from python scripts out of geompy.addToStudy (non-default usage)
140    */
141   CORBA::Boolean RestoreSubShapesO (SALOMEDS::Study_ptr     theStudy,
142                                     GEOM::GEOM_Object_ptr   theObject,
143                                     const GEOM::ListOfGO&   theArgs,
144                                     GEOM::find_shape_method theFindMethod,
145                                     CORBA::Boolean          theInheritFirstArg);
146
147   /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
148    *         To be used from GUI and from geompy.addToStudy
149    */
150   CORBA::Boolean RestoreSubShapesSO (SALOMEDS::Study_ptr     theStudy,
151                                      SALOMEDS::SObject_ptr   theSObject,
152                                      const GEOM::ListOfGO&   theArgs,
153                                      GEOM::find_shape_method theFindMethod,
154                                      CORBA::Boolean          theInheritFirstArg);
155
156   //-----------------------------------------------------------------------//
157   // Transaction methods                                                   //
158   //-----------------------------------------------------------------------//
159
160   //Undos one transaction in the document associated with theStudyID
161   virtual void Undo(CORBA::Long theStudyID);
162
163   //Redos one transaction in the document associated with theStudyID
164   virtual void Redo(CORBA::Long theStudyID);
165
166   //-----------------------------------------------------------------------//
167   // Operations methods                                                    //
168   //-----------------------------------------------------------------------//
169
170   //Returns a pointer to BasicOperations interface
171   virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID)
172     throw (SALOME::SALOME_Exception);
173
174   //Returns a pointer to TransformOperations interface
175   virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID)
176     throw (SALOME::SALOME_Exception);
177
178   //Returns a pointer to 3DPrimOperations interface
179   virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID)
180     throw (SALOME::SALOME_Exception);
181
182   //Returns a pointer to ShapesOperations interface
183   virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID)
184     throw (SALOME::SALOME_Exception);
185
186   //Returns a pointer to BlocksOperations interface
187   virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID)
188     throw (SALOME::SALOME_Exception);
189
190   //Returns a pointer to BooleanOperations interface
191   virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID)
192     throw (SALOME::SALOME_Exception);
193
194   //Returns a pointer to CurvesOperations interface
195   virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID)
196     throw (SALOME::SALOME_Exception);
197
198   //Returns a pointer to LocalOperations interface
199   virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID)
200     throw (SALOME::SALOME_Exception);
201
202   //Returns a pointer to HealingOperations interface
203   virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID)
204     throw (SALOME::SALOME_Exception);
205
206   //Returns a pointer to InsertOperations interface
207   virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID)
208     throw (SALOME::SALOME_Exception);
209
210   //Returns a pointer to MeasureOperations interface
211   virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID)
212     throw (SALOME::SALOME_Exception);
213
214   //Returns a pointer to GroupOperations interface
215   virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
216     throw (SALOME::SALOME_Exception);
217
218   //Adds a new sub shape
219   virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
220                                              const GEOM::ListOfLong& theIndices);
221
222   virtual void RemoveObject(GEOM::GEOM_Object_ptr theObject);
223
224   virtual  char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
225
226   virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
227
228   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
229                                        CORBA::Boolean isPublished,
230                                        CORBA::Boolean& isValidScript);
231
232   char* GetDumpName (const char* theStudyEntry);
233
234   GEOM::string_array* GetAllDumpNames();
235   
236   // Object information
237   virtual bool hasObjectInfo();
238   virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
239   
240   //-----------------------------------------------------------------------//
241   // Internal methods                                                      //
242   //-----------------------------------------------------------------------//
243
244   virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
245
246  private:
247   GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr     theStudy,
248                                             SALOMEDS::SObject_ptr   theOldSO,
249                                             SALOMEDS::SObject_ptr   theNewSO,
250                                             GEOM::GEOM_Object_ptr   theNewO,
251                                             GEOM::find_shape_method theFindMethod);
252
253   CORBA::Boolean RestoreSubShapes (SALOMEDS::Study_ptr     theStudy,
254                                    GEOM::GEOM_Object_ptr   theObject,
255                                    SALOMEDS::SObject_ptr   theSObject,
256                                    const GEOM::ListOfGO&   theArgs,
257                                    GEOM::find_shape_method theFindMethod,
258                                    CORBA::Boolean          theInheritFirstArg);
259
260  private:
261
262    ::GEOMImpl_Gen* _impl;
263    SALOME_NamingService * name_service;
264    char * _name;
265 };
266
267 #endif