1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef __GEOM_GEN_I_H__
24 #define __GEOM_GEN_I_H__
26 #include "GEOM_GEOM_I.hxx"
28 #include "GEOMImpl_Gen.hxx"
31 #include <SALOMEconfig.h>
32 #include CORBA_SERVER_HEADER(GEOM_Gen)
34 #include CORBA_CLIENT_HEADER(SALOMEDS)
35 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
38 #include "SALOME_Component_i.hxx"
39 #include "SALOME_NamingService.hxx"
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"
55 #include <TopTools_IndexedMapOfShape.hxx>
60 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
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
70 //-----------------------------------------------------------------------//
71 // Constructor / Destructor //
72 //-----------------------------------------------------------------------//
74 // constructor to be called for servant creation.
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);
82 // destructor, doing nothing (for now)
83 virtual ~GEOM_Gen_i();
85 // generic method to be put in a super class
86 void register_name(char * name);
89 //-----------------------------------------------------------------------//
90 // Inherited methods from SALOMEDS::Driver //
91 //-----------------------------------------------------------------------//
93 SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
97 SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
101 CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
102 const SALOMEDS::TMPFile& theStream,
106 CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
107 const SALOMEDS::TMPFile& theStream,
111 void Close(SALOMEDS::SComponent_ptr theComponent);
112 char* ComponentDataType();
115 char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
116 const char* IORString,
117 CORBA::Boolean isMultiFile,
118 CORBA::Boolean isASCII);
119 char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
120 const char* aLocalPersistentID,
121 CORBA::Boolean isMultiFile,
122 CORBA::Boolean isASCII);
124 bool CanPublishInStudy(CORBA::Object_ptr theIOR);
125 SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
126 SALOMEDS::SObject_ptr theSObject,
127 CORBA::Object_ptr theObject,
128 const char* theName) throw (SALOME::SALOME_Exception) ;
130 GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
131 CORBA::Object_ptr theObject);
133 CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
134 SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
135 CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
136 SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
137 CORBA::Long theObjectID,
138 SALOMEDS::SObject_ptr theObject);
140 /*! \brief Adds theObject in the study with a name = theName, if
141 * theFather is not null the object is placed under theFather
143 SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
144 GEOM::GEOM_Object_ptr theObject,
146 GEOM::GEOM_Object_ptr theFather);
148 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
149 * To be used from python scripts out of geompy.addToStudy (non-default usage)
151 GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
152 GEOM::GEOM_Object_ptr theObject,
153 const GEOM::ListOfGO& theArgs,
154 GEOM::find_shape_method theFindMethod,
155 CORBA::Boolean theInheritFirstArg,
156 CORBA::Boolean theAddPrefix);
158 /*! \brief Publish sub-shapes, standing for given in \a theArgs arguments and sub-shapes.
159 * To be used from python scripts, generated by Dump Python.
161 GEOM::ListOfGO* RestoreGivenSubShapesO (SALOMEDS::Study_ptr theStudy,
162 GEOM::GEOM_Object_ptr theObject,
163 const GEOM::ListOfGO& theArgs,
164 GEOM::find_shape_method theFindMethod,
165 CORBA::Boolean theInheritFirstArg,
166 CORBA::Boolean theAddPrefix);
168 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
169 * To be used from GUI and from geompy.addToStudy
171 GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
172 SALOMEDS::SObject_ptr theSObject,
173 const GEOM::ListOfGO& theArgs,
174 GEOM::find_shape_method theFindMethod,
175 CORBA::Boolean theInheritFirstArg,
176 CORBA::Boolean theAddPrefix);
178 //-----------------------------------------------------------------------//
179 // Transaction methods //
180 //-----------------------------------------------------------------------//
182 //Undos one transaction in the document associated with theStudyID
183 virtual void Undo(CORBA::Long theStudyID);
185 //Redos one transaction in the document associated with theStudyID
186 virtual void Redo(CORBA::Long theStudyID);
188 //-----------------------------------------------------------------------//
189 // Operations methods //
190 //-----------------------------------------------------------------------//
192 //Returns a pointer to BasicOperations interface
193 virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID)
194 throw (SALOME::SALOME_Exception);
196 //Returns a pointer to TransformOperations interface
197 virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID)
198 throw (SALOME::SALOME_Exception);
200 //Returns a pointer to 3DPrimOperations interface
201 virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID)
202 throw (SALOME::SALOME_Exception);
204 //Returns a pointer to ShapesOperations interface
205 virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID)
206 throw (SALOME::SALOME_Exception);
208 //Returns a pointer to BlocksOperations interface
209 virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID)
210 throw (SALOME::SALOME_Exception);
212 //Returns a pointer to BooleanOperations interface
213 virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID)
214 throw (SALOME::SALOME_Exception);
216 //Returns a pointer to CurvesOperations interface
217 virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID)
218 throw (SALOME::SALOME_Exception);
220 //Returns a pointer to LocalOperations interface
221 virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID)
222 throw (SALOME::SALOME_Exception);
224 //Returns a pointer to HealingOperations interface
225 virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID)
226 throw (SALOME::SALOME_Exception);
228 //Returns a pointer to InsertOperations interface
229 virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID)
230 throw (SALOME::SALOME_Exception);
232 //Returns a pointer to MeasureOperations interface
233 virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID)
234 throw (SALOME::SALOME_Exception);
236 //Returns a pointer to GroupOperations interface
237 virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
238 throw (SALOME::SALOME_Exception);
240 //Returns a pointer to AdvancedOperations interface
241 virtual GEOM::GEOM_IAdvancedOperations_ptr GetIAdvancedOperations (CORBA::Long theStudyID)
242 throw (SALOME::SALOME_Exception);
244 //Adds a new sub-shape
245 virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
246 const GEOM::ListOfLong& theIndices);
248 virtual void RemoveObject(GEOM::GEOM_Object_ptr theObject);
250 virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
252 virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
254 virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
255 CORBA::Boolean isPublished,
256 CORBA::Boolean isMultiFile,
257 CORBA::Boolean& isValidScript);
259 char* GetDumpName (const char* theStudyEntry);
261 GEOM::string_array* GetAllDumpNames();
263 // Object information
264 virtual bool hasObjectInfo();
265 virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
267 // Version information
268 virtual char* getVersion();
270 //-----------------------------------------------------------------------//
271 // Internal methods //
272 //-----------------------------------------------------------------------//
274 virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
277 GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr theStudy,
278 GEOM::GEOM_Object_ptr theObject,
279 SALOMEDS::SObject_ptr theSObject,
280 const GEOM::ListOfGO& theArgs,
281 GEOM::find_shape_method theFindMethod,
282 CORBA::Boolean theInheritFirstArg,
283 CORBA::Boolean theAddPrefix);
285 GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
286 SALOMEDS::SObject_ptr theOldSO,
287 SALOMEDS::SObject_ptr theNewSO,
288 GEOM::GEOM_Object_ptr theNewO,
289 GEOM::ListOfGO& theOutArgs,
290 GEOM::find_shape_method theFindMethod,
291 CORBA::Boolean theAddPrefix);
293 GEOM::ListOfGO* RestoreGivenSubShapes (SALOMEDS::Study_ptr theStudy,
294 GEOM::GEOM_Object_ptr theObject,
295 SALOMEDS::SObject_ptr theSObject,
296 const GEOM::ListOfGO& theArgs,
297 GEOM::find_shape_method theFindMethod,
298 CORBA::Boolean theInheritFirstArg,
299 CORBA::Boolean theAddPrefix);
301 GEOM::ListOfGO* RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
302 SALOMEDS::SObject_ptr theOldSO,
303 SALOMEDS::SObject_ptr theNewSO,
304 GEOM::GEOM_Object_ptr theNewO,
305 std::set<std::string> theArgs,
306 GEOM::find_shape_method theFindMethod,
307 CORBA::Boolean theAddPrefix);
309 // auxilary for PublishNamedShapesInStudy
310 void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
311 GEOM::GEOM_Object_var theMainShape,
312 const TopTools_IndexedMapOfShape& anIndices,
313 const TopTools_SequenceOfShape& SeqS,
314 const TColStd_SequenceOfAsciiString& SeqN,
315 const Standard_CString& GrName,
316 GEOM::ListOfGO_var aResList);
320 ::GEOMImpl_Gen* _impl;
321 SALOME_NamingService * name_service;