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"
53 #include <TopTools_IndexedMapOfShape.hxx>
55 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
58 //=====================================================================
59 // GEOM_Gen_i : class definition
60 //=====================================================================
61 class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual public Engines_Component_i
65 //-----------------------------------------------------------------------//
66 // Constructor / Destructor //
67 //-----------------------------------------------------------------------//
69 // constructor to be called for servant creation.
71 GEOM_Gen_i(CORBA::ORB_ptr orb,
72 PortableServer::POA_ptr poa,
73 PortableServer::ObjectId * contId,
74 const char *instanceName,
75 const char *interfaceName);
77 // destructor, doing nothing (for now)
78 virtual ~GEOM_Gen_i();
80 // generic method to be put in a super class
81 void register_name(char * name);
84 //-----------------------------------------------------------------------//
85 // Inherited methods from SALOMEDS::Driver //
86 //-----------------------------------------------------------------------//
88 SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
92 SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
96 CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
97 const SALOMEDS::TMPFile& theStream,
101 CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
102 const SALOMEDS::TMPFile& theStream,
106 void Close(SALOMEDS::SComponent_ptr theComponent);
107 char* ComponentDataType();
110 char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
111 const char* IORString,
112 CORBA::Boolean isMultiFile,
113 CORBA::Boolean isASCII);
114 char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
115 const char* aLocalPersistentID,
116 CORBA::Boolean isMultiFile,
117 CORBA::Boolean isASCII);
119 bool CanPublishInStudy(CORBA::Object_ptr theIOR);
120 SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
121 SALOMEDS::SObject_ptr theSObject,
122 CORBA::Object_ptr theObject,
123 const char* theName) throw (SALOME::SALOME_Exception) ;
125 GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
126 CORBA::Object_ptr theObject);
128 CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
129 SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
130 CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
131 SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
132 CORBA::Long theObjectID,
133 SALOMEDS::SObject_ptr theObject);
135 /*! \brief Adds theObject in the study with a name = theName, if
136 * theFather is not null the object is placed under theFather
138 SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
139 GEOM::GEOM_Object_ptr theObject,
141 GEOM::GEOM_Object_ptr theFather);
143 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
144 * To be used from python scripts out of geompy.addToStudy (non-default usage)
146 GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
147 GEOM::GEOM_Object_ptr theObject,
148 const GEOM::ListOfGO& theArgs,
149 GEOM::find_shape_method theFindMethod,
150 CORBA::Boolean theInheritFirstArg);
152 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
153 * To be used from GUI and from geompy.addToStudy
155 GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
156 SALOMEDS::SObject_ptr theSObject,
157 const GEOM::ListOfGO& theArgs,
158 GEOM::find_shape_method theFindMethod,
159 CORBA::Boolean theInheritFirstArg);
161 //-----------------------------------------------------------------------//
162 // Transaction methods //
163 //-----------------------------------------------------------------------//
165 //Undos one transaction in the document associated with theStudyID
166 virtual void Undo(CORBA::Long theStudyID);
168 //Redos one transaction in the document associated with theStudyID
169 virtual void Redo(CORBA::Long theStudyID);
171 //-----------------------------------------------------------------------//
172 // Operations methods //
173 //-----------------------------------------------------------------------//
175 //Returns a pointer to BasicOperations interface
176 virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID)
177 throw (SALOME::SALOME_Exception);
179 //Returns a pointer to TransformOperations interface
180 virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID)
181 throw (SALOME::SALOME_Exception);
183 //Returns a pointer to 3DPrimOperations interface
184 virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID)
185 throw (SALOME::SALOME_Exception);
187 //Returns a pointer to ShapesOperations interface
188 virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID)
189 throw (SALOME::SALOME_Exception);
191 //Returns a pointer to BlocksOperations interface
192 virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID)
193 throw (SALOME::SALOME_Exception);
195 //Returns a pointer to BooleanOperations interface
196 virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID)
197 throw (SALOME::SALOME_Exception);
199 //Returns a pointer to CurvesOperations interface
200 virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID)
201 throw (SALOME::SALOME_Exception);
203 //Returns a pointer to LocalOperations interface
204 virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID)
205 throw (SALOME::SALOME_Exception);
207 //Returns a pointer to HealingOperations interface
208 virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID)
209 throw (SALOME::SALOME_Exception);
211 //Returns a pointer to InsertOperations interface
212 virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID)
213 throw (SALOME::SALOME_Exception);
215 //Returns a pointer to MeasureOperations interface
216 virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID)
217 throw (SALOME::SALOME_Exception);
219 //Returns a pointer to GroupOperations interface
220 virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
221 throw (SALOME::SALOME_Exception);
223 //Adds a new sub shape
224 virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
225 const GEOM::ListOfLong& theIndices);
227 virtual void RemoveObject(GEOM::GEOM_Object_ptr theObject);
229 virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
231 virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
233 virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
234 CORBA::Boolean isPublished,
235 CORBA::Boolean& isValidScript);
237 char* GetDumpName (const char* theStudyEntry);
239 GEOM::string_array* GetAllDumpNames();
241 // Object information
242 virtual bool hasObjectInfo();
243 virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
245 //-----------------------------------------------------------------------//
246 // Internal methods //
247 //-----------------------------------------------------------------------//
249 virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
251 virtual SALOME::GenericObj_ptr FindObjectByInternalEntry( CORBA::Long theStudyID, const char* theEntry );
254 GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
255 SALOMEDS::SObject_ptr theOldSO,
256 SALOMEDS::SObject_ptr theNewSO,
257 GEOM::GEOM_Object_ptr theNewO,
258 GEOM::find_shape_method theFindMethod);
260 GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr theStudy,
261 GEOM::GEOM_Object_ptr theObject,
262 SALOMEDS::SObject_ptr theSObject,
263 const GEOM::ListOfGO& theArgs,
264 GEOM::find_shape_method theFindMethod,
265 CORBA::Boolean theInheritFirstArg);
267 // auxilary for PublishNamedShapesInStudy
268 void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
269 GEOM::GEOM_Object_var theMainShape,
270 const TopTools_IndexedMapOfShape& anIndices,
271 const TopTools_SequenceOfShape& SeqS,
272 const TColStd_SequenceOfAsciiString& SeqN,
273 const Standard_CString& GrName,
274 GEOM::ListOfGO_var aResList);
278 ::GEOMImpl_Gen* _impl;
279 SALOME_NamingService * name_service;