1 // Copyright (C) 2007-2008 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
22 #ifndef __GEOM_GEN_I_H__
23 #define __GEOM_GEN_I_H__
25 #include "GEOM_GEOM_I.hxx"
27 #include "GEOMImpl_Gen.hxx"
30 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(GEOM_Gen)
33 #include CORBA_CLIENT_HEADER(SALOMEDS)
34 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
37 #include "SALOME_Component_i.hxx"
38 #include "SALOME_NamingService.hxx"
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"
54 #include <TopTools_IndexedMapOfShape.hxx>
56 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
59 //=====================================================================
60 // GEOM_Gen_i : class definition
61 //=====================================================================
62 class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual public Engines_Component_i
66 //-----------------------------------------------------------------------//
67 // Constructor / Destructor //
68 //-----------------------------------------------------------------------//
70 // constructor to be called for servant creation.
72 GEOM_Gen_i(CORBA::ORB_ptr orb,
73 PortableServer::POA_ptr poa,
74 PortableServer::ObjectId * contId,
75 const char *instanceName,
76 const char *interfaceName);
78 // destructor, doing nothing (for now)
79 virtual ~GEOM_Gen_i();
81 // generic method to be put in a super class
82 void register_name(char * name);
85 //-----------------------------------------------------------------------//
86 // Inherited methods from SALOMEDS::Driver //
87 //-----------------------------------------------------------------------//
89 SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
93 SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
97 CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
98 const SALOMEDS::TMPFile& theStream,
102 CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
103 const SALOMEDS::TMPFile& theStream,
107 void Close(SALOMEDS::SComponent_ptr theComponent);
108 char* ComponentDataType();
111 char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
112 const char* IORString,
113 CORBA::Boolean isMultiFile,
114 CORBA::Boolean isASCII);
115 char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
116 const char* aLocalPersistentID,
117 CORBA::Boolean isMultiFile,
118 CORBA::Boolean isASCII);
120 bool CanPublishInStudy(CORBA::Object_ptr theIOR);
121 SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
122 SALOMEDS::SObject_ptr theSObject,
123 CORBA::Object_ptr theObject,
124 const char* theName) throw (SALOME::SALOME_Exception) ;
126 GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
127 CORBA::Object_ptr theObject);
129 CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
130 SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
131 CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
132 SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
133 CORBA::Long theObjectID,
134 SALOMEDS::SObject_ptr theObject);
136 /*! \brief Adds theObject in the study with a name = theName, if
137 * theFather is not null the object is placed under theFather
139 SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
140 GEOM::GEOM_Object_ptr theObject,
142 GEOM::GEOM_Object_ptr theFather);
144 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
145 * To be used from python scripts out of geompy.addToStudy (non-default usage)
147 GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
148 GEOM::GEOM_Object_ptr theObject,
149 const GEOM::ListOfGO& theArgs,
150 GEOM::find_shape_method theFindMethod,
151 CORBA::Boolean theInheritFirstArg,
152 CORBA::Boolean theAddPrefix);
154 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
155 * To be used from GUI and from geompy.addToStudy
157 GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
158 SALOMEDS::SObject_ptr theSObject,
159 const GEOM::ListOfGO& theArgs,
160 GEOM::find_shape_method theFindMethod,
161 CORBA::Boolean theInheritFirstArg,
162 CORBA::Boolean theAddPrefix);
164 //-----------------------------------------------------------------------//
165 // Transaction methods //
166 //-----------------------------------------------------------------------//
168 //Undos one transaction in the document associated with theStudyID
169 virtual void Undo(CORBA::Long theStudyID);
171 //Redos one transaction in the document associated with theStudyID
172 virtual void Redo(CORBA::Long theStudyID);
174 //-----------------------------------------------------------------------//
175 // Operations methods //
176 //-----------------------------------------------------------------------//
178 //Returns a pointer to BasicOperations interface
179 virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID)
180 throw (SALOME::SALOME_Exception);
182 //Returns a pointer to TransformOperations interface
183 virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID)
184 throw (SALOME::SALOME_Exception);
186 //Returns a pointer to 3DPrimOperations interface
187 virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID)
188 throw (SALOME::SALOME_Exception);
190 //Returns a pointer to ShapesOperations interface
191 virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID)
192 throw (SALOME::SALOME_Exception);
194 //Returns a pointer to BlocksOperations interface
195 virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID)
196 throw (SALOME::SALOME_Exception);
198 //Returns a pointer to BooleanOperations interface
199 virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID)
200 throw (SALOME::SALOME_Exception);
202 //Returns a pointer to CurvesOperations interface
203 virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID)
204 throw (SALOME::SALOME_Exception);
206 //Returns a pointer to LocalOperations interface
207 virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID)
208 throw (SALOME::SALOME_Exception);
210 //Returns a pointer to HealingOperations interface
211 virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID)
212 throw (SALOME::SALOME_Exception);
214 //Returns a pointer to InsertOperations interface
215 virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID)
216 throw (SALOME::SALOME_Exception);
218 //Returns a pointer to MeasureOperations interface
219 virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID)
220 throw (SALOME::SALOME_Exception);
222 //Returns a pointer to GroupOperations interface
223 virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
224 throw (SALOME::SALOME_Exception);
226 //Returns a pointer to AdvancedOperations interface
227 virtual GEOM::GEOM_IAdvancedOperations_ptr GetIAdvancedOperations (CORBA::Long theStudyID)
228 throw (SALOME::SALOME_Exception);
230 //Adds a new sub shape
231 virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
232 const GEOM::ListOfLong& theIndices);
234 virtual void RemoveObject(GEOM::GEOM_Object_ptr theObject);
236 virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
238 virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
240 virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
241 CORBA::Boolean isPublished,
242 CORBA::Boolean& isValidScript);
244 char* GetDumpName (const char* theStudyEntry);
246 GEOM::string_array* GetAllDumpNames();
248 // Object information
249 virtual bool hasObjectInfo();
250 virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
252 //-----------------------------------------------------------------------//
253 // Internal methods //
254 //-----------------------------------------------------------------------//
256 virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
259 GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
260 SALOMEDS::SObject_ptr theOldSO,
261 SALOMEDS::SObject_ptr theNewSO,
262 GEOM::GEOM_Object_ptr theNewO,
263 GEOM::find_shape_method theFindMethod,
264 CORBA::Boolean theAddPrefix);
266 GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr theStudy,
267 GEOM::GEOM_Object_ptr theObject,
268 SALOMEDS::SObject_ptr theSObject,
269 const GEOM::ListOfGO& theArgs,
270 GEOM::find_shape_method theFindMethod,
271 CORBA::Boolean theInheritFirstArg,
272 CORBA::Boolean theAddPrefix);
274 // auxilary for PublishNamedShapesInStudy
275 void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
276 GEOM::GEOM_Object_var theMainShape,
277 const TopTools_IndexedMapOfShape& anIndices,
278 const TopTools_SequenceOfShape& SeqS,
279 const TColStd_SequenceOfAsciiString& SeqN,
280 const Standard_CString& GrName,
281 GEOM::ListOfGO_var aResList);
285 ::GEOMImpl_Gen* _impl;
286 SALOME_NamingService * name_service;