Salome HOME
Merge from V7_siman 11/10/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 #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_IFieldOperations_i.hh"
53
54 #include <TopTools_IndexedMapOfShape.hxx>
55
56 #include <map>
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 // Generic operations creator (for plugins mechanism)
65 //=====================================================================
66 class GEOM_I_EXPORT GEOM_GenericOperationsCreator
67 {
68 public:
69   // Create operations
70   virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA,
71                                       int                     theStudyId,
72                                       GEOM::GEOM_Gen_ptr      theEngine,
73                                       ::GEOMImpl_Gen*         theGenImpl) = 0;
74   // return the name of IDL module
75   //virtual std::string GetModuleName() = 0;
76 };
77
78 //=====================================================================
79 // GEOM_Gen_i : class definition
80 //=====================================================================
81 class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual public Engines_Component_i
82 {
83  public:
84
85   //-----------------------------------------------------------------------//
86   // Constructor / Destructor                                              //
87   //-----------------------------------------------------------------------//
88
89   // constructor to be called for servant creation.
90   GEOM_Gen_i();
91   GEOM_Gen_i(CORBA::ORB_ptr orb,
92              PortableServer::POA_ptr poa,
93              PortableServer::ObjectId * contId,
94              const char *instanceName,
95              const char *interfaceName);
96
97   // destructor, doing nothing (for now)
98   virtual ~GEOM_Gen_i();
99
100   // generic method to be put in a super class
101   void register_name(char * name);
102
103   // Get ORB object
104   CORBA::ORB_ptr GetORB() { return CORBA::ORB::_duplicate(_orb); }
105
106   // Get Naming Service object
107   SALOME_NamingService* GetNS() { return name_service; }
108
109   //-----------------------------------------------------------------------//
110   // Inherited methods from SALOMEDS::Driver                               //
111   //-----------------------------------------------------------------------//
112
113   SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
114                           const char* theURL,
115                           bool isMultiFile);
116
117   SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
118                                const char* theURL,
119                                bool isMultiFile);
120
121   CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
122                       const SALOMEDS::TMPFile& theStream,
123                       const char* theURL,
124                       bool isMultiFile);
125
126   CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
127                            const SALOMEDS::TMPFile& theStream,
128                            const char* theURL,
129                            bool isMultiFile);
130
131   void Close(SALOMEDS::SComponent_ptr theComponent);
132   char* ComponentDataType();
133
134
135   char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
136                                const char* IORString,
137                                CORBA::Boolean isMultiFile,
138                                CORBA::Boolean isASCII);
139   char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
140                                const char* aLocalPersistentID,
141                                CORBA::Boolean isMultiFile,
142                                CORBA::Boolean isASCII);
143
144   bool CanPublishInStudy(CORBA::Object_ptr theIOR);
145   SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
146                                        SALOMEDS::SObject_ptr theSObject,
147                                        CORBA::Object_ptr theObject,
148                                        const char* theName) throw (SALOME::SALOME_Exception) ;
149
150   GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
151                                             CORBA::Object_ptr theObject);
152
153   CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
154   SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
155   CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
156   SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
157                                   CORBA::Long theObjectID,
158                                   SALOMEDS::SObject_ptr theObject);
159
160   /*! \brief Adds theObject in the study with a name = theName, if
161    *         theFather is not null the object is placed under theFather
162    */
163   SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr       theStudy,
164                                     GEOM::GEOM_BaseObject_ptr theObject,
165                                     const char*               theName,
166                                     GEOM::GEOM_BaseObject_ptr theFather);
167
168   /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
169    *         To be used from python scripts out of geompy.addToStudy (non-default usage)
170    */
171   GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr     theStudy,
172                                      GEOM::GEOM_Object_ptr   theObject,
173                                      const GEOM::ListOfGO&   theArgs,
174                                      GEOM::find_shape_method theFindMethod,
175                                      CORBA::Boolean          theInheritFirstArg,
176                                      CORBA::Boolean          theAddPrefix);
177
178   /*! \brief Publish sub-shapes, standing for given in \a theArgs arguments and sub-shapes.
179    *         To be used from python scripts, generated by Dump Python.
180    */
181   GEOM::ListOfGO* RestoreGivenSubShapesO (SALOMEDS::Study_ptr     theStudy,
182                                           GEOM::GEOM_Object_ptr   theObject,
183                                           const GEOM::ListOfGO&   theArgs,
184                                           GEOM::find_shape_method theFindMethod,
185                                           CORBA::Boolean          theInheritFirstArg,
186                                           CORBA::Boolean          theAddPrefix);
187
188   /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
189    *         To be used from GUI and from geompy.addToStudy
190    */
191   GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr     theStudy,
192                                       SALOMEDS::SObject_ptr   theSObject,
193                                       const GEOM::ListOfGO&   theArgs,
194                                       GEOM::find_shape_method theFindMethod,
195                                       CORBA::Boolean          theInheritFirstArg,
196                                       CORBA::Boolean          theAddPrefix);
197
198   //-----------------------------------------------------------------------//
199   // Transaction methods                                                   //
200   //-----------------------------------------------------------------------//
201
202   //Undos one transaction in the document associated with theStudyID
203   virtual void Undo(CORBA::Long theStudyID);
204
205   //Redos one transaction in the document associated with theStudyID
206   virtual void Redo(CORBA::Long theStudyID);
207
208   //-----------------------------------------------------------------------//
209   // Operations methods                                                    //
210   //-----------------------------------------------------------------------//
211
212   //Returns a pointer to BasicOperations interface
213   virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID)
214     throw (SALOME::SALOME_Exception);
215
216   //Returns a pointer to TransformOperations interface
217   virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID)
218     throw (SALOME::SALOME_Exception);
219
220   //Returns a pointer to 3DPrimOperations interface
221   virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID)
222     throw (SALOME::SALOME_Exception);
223
224   //Returns a pointer to ShapesOperations interface
225   virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID)
226     throw (SALOME::SALOME_Exception);
227
228   //Returns a pointer to BlocksOperations interface
229   virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID)
230     throw (SALOME::SALOME_Exception);
231
232   //Returns a pointer to BooleanOperations interface
233   virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID)
234     throw (SALOME::SALOME_Exception);
235
236   //Returns a pointer to CurvesOperations interface
237   virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID)
238     throw (SALOME::SALOME_Exception);
239
240   //Returns a pointer to LocalOperations interface
241   virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID)
242     throw (SALOME::SALOME_Exception);
243
244   //Returns a pointer to HealingOperations interface
245   virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID)
246     throw (SALOME::SALOME_Exception);
247
248   //Returns a pointer to InsertOperations interface
249   virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID)
250     throw (SALOME::SALOME_Exception);
251
252   //Returns a pointer to MeasureOperations interface
253   virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID)
254     throw (SALOME::SALOME_Exception);
255
256   //Returns a pointer to GroupOperations interface
257   virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
258     throw (SALOME::SALOME_Exception);
259
260   //Returns a pointer to FiedlOperations interface
261   virtual GEOM::GEOM_IFieldOperations_ptr GetIFieldOperations (CORBA::Long theStudyID)
262     throw (SALOME::SALOME_Exception);
263
264   //Returns a pointer to corresponding plugin operations interface
265   virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (CORBA::Long theStudyID,
266                                                           const char* theLibName)
267     throw (SALOME::SALOME_Exception);
268
269   //Adds a new sub-shape
270   virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
271                                              const GEOM::ListOfLong& theIndices);
272
273   virtual void RemoveObject(GEOM::GEOM_BaseObject_ptr theObject);
274
275   virtual  char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
276
277   virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
278
279   virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
280                                        CORBA::Boolean isPublished,
281                                        CORBA::Boolean isMultiFile,
282                                        CORBA::Boolean& isValidScript);
283
284   char* GetDumpName (const char* theStudyEntry);
285
286   GEOM::string_array* GetAllDumpNames();
287
288   // Object information
289   virtual bool hasObjectInfo();
290   virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
291
292   // Version information
293   virtual char* getVersion();
294
295   // Create a new folder object
296   SALOMEDS::SObject_ptr CreateFolder(const char* theName, 
297                                      SALOMEDS::SObject_ptr theFather);
298
299   // Move GEOM object to the specified folder
300   void MoveToFolder(GEOM::GEOM_Object_ptr theObject, 
301                     SALOMEDS::SObject_ptr theFolder);
302
303   // Move list of GEOM objects to the specified folder
304   void MoveListToFolder (const GEOM::ListOfGO& theListOfGO, 
305                          SALOMEDS::SObject_ptr theFolder);
306
307   // Move objects to the specified position
308   void Move( const GEOM::object_list& what,
309              SALOMEDS::SObject_ptr where,
310              CORBA::Long row );
311
312   // SIMAN-related functions (check out/check in) : import data to study
313   virtual Engines::ListOfIdentifiers* importData(CORBA::Long studyId,
314                                                  Engines::DataContainer_ptr data,
315                                                  const Engines::ListOfOptions& options);
316   // SIMAN-related functions (check out/check in) : get modified data
317   virtual Engines::ListOfData* getModifiedData(CORBA::Long studyId);
318
319   //-----------------------------------------------------------------------//
320   // Internal methods                                                      //
321   //-----------------------------------------------------------------------//
322
323   virtual GEOM::GEOM_BaseObject_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
324
325  private:
326   GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr     theStudy,
327                                     GEOM::GEOM_Object_ptr   theObject,
328                                     SALOMEDS::SObject_ptr   theSObject,
329                                     const GEOM::ListOfGO&   theArgs,
330                                     GEOM::find_shape_method theFindMethod,
331                                     CORBA::Boolean          theInheritFirstArg,
332                                     CORBA::Boolean          theAddPrefix);
333
334   GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr     theStudy,
335                                             SALOMEDS::SObject_ptr   theOldSO,
336                                             SALOMEDS::SObject_ptr   theNewSO,
337                                             GEOM::GEOM_Object_ptr   theNewO,
338                                             GEOM::ListOfGO&         theOutArgs,
339                                             GEOM::find_shape_method theFindMethod,
340                                             CORBA::Boolean          theAddPrefix);
341
342   GEOM::ListOfGO* RestoreGivenSubShapes (SALOMEDS::Study_ptr     theStudy,
343                                          GEOM::GEOM_Object_ptr   theObject,
344                                          SALOMEDS::SObject_ptr   theSObject,
345                                          const GEOM::ListOfGO&   theArgs,
346                                          GEOM::find_shape_method theFindMethod,
347                                          CORBA::Boolean          theInheritFirstArg,
348                                          CORBA::Boolean          theAddPrefix);
349
350   GEOM::ListOfGO* RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr     theStudy,
351                                                  SALOMEDS::SObject_ptr   theOldSO,
352                                                  SALOMEDS::SObject_ptr   theNewSO,
353                                                  GEOM::GEOM_Object_ptr   theNewO,
354                                                  std::set<std::string>   theArgs,
355                                                  GEOM::find_shape_method theFindMethod,
356                                                  CORBA::Boolean          theAddPrefix);
357
358   // auxilary for PublishNamedShapesInStudy
359   void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
360                              GEOM::GEOM_Object_var theMainShape,
361                              const TopTools_IndexedMapOfShape& anIndices,
362                              const TopTools_SequenceOfShape& SeqS,
363                              const TColStd_SequenceOfAsciiString& SeqN,
364                              const Standard_CString& GrName,
365                              GEOM::ListOfGO_var aResList);
366
367  private:
368
369    ::GEOMImpl_Gen* _impl;
370    SALOME_NamingService * name_service;
371    char * _name;
372
373    // plugin operations managing
374    std::map<std::string, GEOM_GenericOperationsCreator*> myOpCreatorMap;
375 };
376
377 #endif