1 // Copyright (C) 2007-2013 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>
59 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
62 //=====================================================================
63 // Generic operations creator (for plugins mechanism)
64 //=====================================================================
65 class GEOM_I_EXPORT GEOM_GenericOperationsCreator
69 virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA,
71 GEOM::GEOM_Gen_ptr theEngine,
72 ::GEOMImpl_Gen* theGenImpl) = 0;
73 // return the name of IDL module
74 //virtual std::string GetModuleName() = 0;
77 //=====================================================================
78 // GEOM_Gen_i : class definition
79 //=====================================================================
80 class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual public Engines_Component_i
84 //-----------------------------------------------------------------------//
85 // Constructor / Destructor //
86 //-----------------------------------------------------------------------//
88 // constructor to be called for servant creation.
90 GEOM_Gen_i(CORBA::ORB_ptr orb,
91 PortableServer::POA_ptr poa,
92 PortableServer::ObjectId * contId,
93 const char *instanceName,
94 const char *interfaceName);
96 // destructor, doing nothing (for now)
97 virtual ~GEOM_Gen_i();
99 // generic method to be put in a super class
100 void register_name(char * name);
103 CORBA::ORB_ptr GetORB() { return CORBA::ORB::_duplicate(_orb); }
105 // Get Naming Service object
106 SALOME_NamingService* GetNS() { return name_service; }
108 //-----------------------------------------------------------------------//
109 // Inherited methods from SALOMEDS::Driver //
110 //-----------------------------------------------------------------------//
112 SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
116 SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
120 CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
121 const SALOMEDS::TMPFile& theStream,
125 CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
126 const SALOMEDS::TMPFile& theStream,
130 void Close(SALOMEDS::SComponent_ptr theComponent);
131 char* ComponentDataType();
134 char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
135 const char* IORString,
136 CORBA::Boolean isMultiFile,
137 CORBA::Boolean isASCII);
138 char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
139 const char* aLocalPersistentID,
140 CORBA::Boolean isMultiFile,
141 CORBA::Boolean isASCII);
143 bool CanPublishInStudy(CORBA::Object_ptr theIOR);
144 SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
145 SALOMEDS::SObject_ptr theSObject,
146 CORBA::Object_ptr theObject,
147 const char* theName) throw (SALOME::SALOME_Exception) ;
149 GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
150 CORBA::Object_ptr theObject);
152 CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
153 SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
154 CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
155 SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
156 CORBA::Long theObjectID,
157 SALOMEDS::SObject_ptr theObject);
159 /*! \brief Adds theObject in the study with a name = theName, if
160 * theFather is not null the object is placed under theFather
162 SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
163 GEOM::GEOM_Object_ptr theObject,
165 GEOM::GEOM_Object_ptr theFather);
167 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
168 * To be used from python scripts out of geompy.addToStudy (non-default usage)
170 GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
171 GEOM::GEOM_Object_ptr theObject,
172 const GEOM::ListOfGO& theArgs,
173 GEOM::find_shape_method theFindMethod,
174 CORBA::Boolean theInheritFirstArg,
175 CORBA::Boolean theAddPrefix);
177 /*! \brief Publish sub-shapes, standing for given in \a theArgs arguments and sub-shapes.
178 * To be used from python scripts, generated by Dump Python.
180 GEOM::ListOfGO* RestoreGivenSubShapesO (SALOMEDS::Study_ptr theStudy,
181 GEOM::GEOM_Object_ptr theObject,
182 const GEOM::ListOfGO& theArgs,
183 GEOM::find_shape_method theFindMethod,
184 CORBA::Boolean theInheritFirstArg,
185 CORBA::Boolean theAddPrefix);
187 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
188 * To be used from GUI and from geompy.addToStudy
190 GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
191 SALOMEDS::SObject_ptr theSObject,
192 const GEOM::ListOfGO& theArgs,
193 GEOM::find_shape_method theFindMethod,
194 CORBA::Boolean theInheritFirstArg,
195 CORBA::Boolean theAddPrefix);
197 //-----------------------------------------------------------------------//
198 // Transaction methods //
199 //-----------------------------------------------------------------------//
201 //Undos one transaction in the document associated with theStudyID
202 virtual void Undo(CORBA::Long theStudyID);
204 //Redos one transaction in the document associated with theStudyID
205 virtual void Redo(CORBA::Long theStudyID);
207 //-----------------------------------------------------------------------//
208 // Operations methods //
209 //-----------------------------------------------------------------------//
211 //Returns a pointer to BasicOperations interface
212 virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID)
213 throw (SALOME::SALOME_Exception);
215 //Returns a pointer to TransformOperations interface
216 virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID)
217 throw (SALOME::SALOME_Exception);
219 //Returns a pointer to 3DPrimOperations interface
220 virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID)
221 throw (SALOME::SALOME_Exception);
223 //Returns a pointer to ShapesOperations interface
224 virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID)
225 throw (SALOME::SALOME_Exception);
227 //Returns a pointer to BlocksOperations interface
228 virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID)
229 throw (SALOME::SALOME_Exception);
231 //Returns a pointer to BooleanOperations interface
232 virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID)
233 throw (SALOME::SALOME_Exception);
235 //Returns a pointer to CurvesOperations interface
236 virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID)
237 throw (SALOME::SALOME_Exception);
239 //Returns a pointer to LocalOperations interface
240 virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID)
241 throw (SALOME::SALOME_Exception);
243 //Returns a pointer to HealingOperations interface
244 virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID)
245 throw (SALOME::SALOME_Exception);
247 //Returns a pointer to InsertOperations interface
248 virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID)
249 throw (SALOME::SALOME_Exception);
251 //Returns a pointer to MeasureOperations interface
252 virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID)
253 throw (SALOME::SALOME_Exception);
255 //Returns a pointer to GroupOperations interface
256 virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
257 throw (SALOME::SALOME_Exception);
259 //Returns a pointer to corresponding plugin operations interface
260 virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (CORBA::Long theStudyID,
261 const char* theLibName)
262 throw (SALOME::SALOME_Exception);
264 //Adds a new sub-shape
265 virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
266 const GEOM::ListOfLong& theIndices);
268 virtual void RemoveObject(GEOM::GEOM_Object_ptr theObject);
270 virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
272 virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
274 virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
275 CORBA::Boolean isPublished,
276 CORBA::Boolean isMultiFile,
277 CORBA::Boolean& isValidScript);
279 char* GetDumpName (const char* theStudyEntry);
281 GEOM::string_array* GetAllDumpNames();
283 // Object information
284 virtual bool hasObjectInfo();
285 virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
287 // Version information
288 virtual char* getVersion();
290 // Create a new folder object
291 SALOMEDS::SObject_ptr CreateFolder(const char* theName,
292 SALOMEDS::SObject_ptr theFather);
294 // Move GEOM object to the specified folder
295 void MoveToFolder(GEOM::GEOM_Object_ptr theObject,
296 SALOMEDS::SObject_ptr theFolder);
298 // Move list of GEOM objects to the specified folder
299 void MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
300 SALOMEDS::SObject_ptr theFolder);
302 // Move objects to the specified position
303 void Move( const GEOM::object_list& what,
304 SALOMEDS::SObject_ptr where,
307 //-----------------------------------------------------------------------//
308 // Internal methods //
309 //-----------------------------------------------------------------------//
311 virtual GEOM::GEOM_Object_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
314 GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr theStudy,
315 GEOM::GEOM_Object_ptr theObject,
316 SALOMEDS::SObject_ptr theSObject,
317 const GEOM::ListOfGO& theArgs,
318 GEOM::find_shape_method theFindMethod,
319 CORBA::Boolean theInheritFirstArg,
320 CORBA::Boolean theAddPrefix);
322 GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
323 SALOMEDS::SObject_ptr theOldSO,
324 SALOMEDS::SObject_ptr theNewSO,
325 GEOM::GEOM_Object_ptr theNewO,
326 GEOM::ListOfGO& theOutArgs,
327 GEOM::find_shape_method theFindMethod,
328 CORBA::Boolean theAddPrefix);
330 GEOM::ListOfGO* RestoreGivenSubShapes (SALOMEDS::Study_ptr theStudy,
331 GEOM::GEOM_Object_ptr theObject,
332 SALOMEDS::SObject_ptr theSObject,
333 const GEOM::ListOfGO& theArgs,
334 GEOM::find_shape_method theFindMethod,
335 CORBA::Boolean theInheritFirstArg,
336 CORBA::Boolean theAddPrefix);
338 GEOM::ListOfGO* RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
339 SALOMEDS::SObject_ptr theOldSO,
340 SALOMEDS::SObject_ptr theNewSO,
341 GEOM::GEOM_Object_ptr theNewO,
342 std::set<std::string> theArgs,
343 GEOM::find_shape_method theFindMethod,
344 CORBA::Boolean theAddPrefix);
346 // auxilary for PublishNamedShapesInStudy
347 void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
348 GEOM::GEOM_Object_var theMainShape,
349 const TopTools_IndexedMapOfShape& anIndices,
350 const TopTools_SequenceOfShape& SeqS,
351 const TColStd_SequenceOfAsciiString& SeqN,
352 const Standard_CString& GrName,
353 GEOM::ListOfGO_var aResList);
357 ::GEOMImpl_Gen* _impl;
358 SALOME_NamingService * name_service;
361 // plugin operations managing
362 std::map<std::string, GEOM_GenericOperationsCreator*> myOpCreatorMap;