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