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