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