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