1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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_IFieldOperations_i.hh"
55 #include <TopTools_IndexedMapOfShape.hxx>
61 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
64 //=====================================================================
65 // Generic operations creator (for plugins mechanism)
66 //=====================================================================
67 class GEOM_I_EXPORT GEOM_GenericOperationsCreator
71 virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA,
73 GEOM::GEOM_Gen_ptr theEngine,
74 ::GEOMImpl_Gen* theGenImpl) = 0;
75 // return the name of IDL module
76 //virtual std::string GetModuleName() = 0;
79 //=====================================================================
80 // GEOM_Gen_i : class definition
81 //=====================================================================
82 class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual public Engines_Component_i
86 //-----------------------------------------------------------------------//
87 // Constructor / Destructor //
88 //-----------------------------------------------------------------------//
90 // constructor to be called for servant creation.
92 GEOM_Gen_i(CORBA::ORB_ptr orb,
93 PortableServer::POA_ptr poa,
94 PortableServer::ObjectId * contId,
95 const char *instanceName,
96 const char *interfaceName);
98 // destructor, doing nothing (for now)
99 virtual ~GEOM_Gen_i();
101 // generic method to be put in a super class
102 void register_name(char * name);
105 CORBA::ORB_ptr GetORB() { return CORBA::ORB::_duplicate(_orb); }
107 // Get Naming Service object
108 SALOME_NamingService* GetNS() { return name_service; }
110 //-----------------------------------------------------------------------//
111 // Inherited methods from SALOMEDS::Driver //
112 //-----------------------------------------------------------------------//
114 SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
118 SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
122 CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
123 const SALOMEDS::TMPFile& theStream,
127 CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
128 const SALOMEDS::TMPFile& theStream,
132 void Close(SALOMEDS::SComponent_ptr theComponent);
133 char* ComponentDataType();
136 char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
137 const char* IORString,
138 CORBA::Boolean isMultiFile,
139 CORBA::Boolean isASCII);
140 char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
141 const char* aLocalPersistentID,
142 CORBA::Boolean isMultiFile,
143 CORBA::Boolean isASCII);
145 bool CanPublishInStudy(CORBA::Object_ptr theIOR);
146 SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
147 SALOMEDS::SObject_ptr theSObject,
148 CORBA::Object_ptr theObject,
149 const char* theName) throw (SALOME::SALOME_Exception) ;
151 GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
152 CORBA::Object_ptr theObject);
154 CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
155 SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
156 CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
157 SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
158 CORBA::Long theObjectID,
159 SALOMEDS::SObject_ptr theObject);
161 /*! \brief Adds theObject in the study with a name = theName, if
162 * theFather is not null the object is placed under theFather
164 SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
165 GEOM::GEOM_BaseObject_ptr theObject,
167 GEOM::GEOM_BaseObject_ptr theFather);
169 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
170 * To be used from python scripts out of geompy.addToStudy (non-default usage)
172 GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
173 GEOM::GEOM_Object_ptr theObject,
174 const GEOM::ListOfGO& theArgs,
175 GEOM::find_shape_method theFindMethod,
176 CORBA::Boolean theInheritFirstArg,
177 CORBA::Boolean theAddPrefix);
179 /*! \brief Publish sub-shapes, standing for given in \a theArgs arguments and sub-shapes.
180 * To be used from python scripts, generated by Dump Python.
182 GEOM::ListOfGO* RestoreGivenSubShapesO (SALOMEDS::Study_ptr theStudy,
183 GEOM::GEOM_Object_ptr theObject,
184 const GEOM::ListOfGO& theArgs,
185 GEOM::find_shape_method theFindMethod,
186 CORBA::Boolean theInheritFirstArg,
187 CORBA::Boolean theAddPrefix);
189 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
190 * To be used from GUI and from geompy.addToStudy
192 GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
193 SALOMEDS::SObject_ptr theSObject,
194 const GEOM::ListOfGO& theArgs,
195 GEOM::find_shape_method theFindMethod,
196 CORBA::Boolean theInheritFirstArg,
197 CORBA::Boolean theAddPrefix);
199 //-----------------------------------------------------------------------//
200 // Transaction methods //
201 //-----------------------------------------------------------------------//
203 //Undos one transaction in the document associated with theStudyID
204 virtual void Undo(CORBA::Long theStudyID);
206 //Redos one transaction in the document associated with theStudyID
207 virtual void Redo(CORBA::Long theStudyID);
209 //-----------------------------------------------------------------------//
210 // Operations methods //
211 //-----------------------------------------------------------------------//
213 //Returns a pointer to BasicOperations interface
214 virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID)
215 throw (SALOME::SALOME_Exception);
217 //Returns a pointer to TransformOperations interface
218 virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID)
219 throw (SALOME::SALOME_Exception);
221 //Returns a pointer to 3DPrimOperations interface
222 virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID)
223 throw (SALOME::SALOME_Exception);
225 //Returns a pointer to ShapesOperations interface
226 virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID)
227 throw (SALOME::SALOME_Exception);
229 //Returns a pointer to BlocksOperations interface
230 virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID)
231 throw (SALOME::SALOME_Exception);
233 //Returns a pointer to BooleanOperations interface
234 virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID)
235 throw (SALOME::SALOME_Exception);
237 //Returns a pointer to CurvesOperations interface
238 virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID)
239 throw (SALOME::SALOME_Exception);
241 //Returns a pointer to LocalOperations interface
242 virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID)
243 throw (SALOME::SALOME_Exception);
245 //Returns a pointer to HealingOperations interface
246 virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID)
247 throw (SALOME::SALOME_Exception);
249 //Returns a pointer to InsertOperations interface
250 virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID)
251 throw (SALOME::SALOME_Exception);
253 //Returns a pointer to MeasureOperations interface
254 virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID)
255 throw (SALOME::SALOME_Exception);
257 //Returns a pointer to GroupOperations interface
258 virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
259 throw (SALOME::SALOME_Exception);
261 //Returns a pointer to FiedlOperations interface
262 virtual GEOM::GEOM_IFieldOperations_ptr GetIFieldOperations (CORBA::Long theStudyID)
263 throw (SALOME::SALOME_Exception);
265 //Returns a pointer to corresponding plugin operations interface
266 virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (CORBA::Long theStudyID,
267 const char* theLibName)
268 throw (SALOME::SALOME_Exception);
270 //Adds a new sub-shape
271 virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
272 const GEOM::ListOfLong& theIndices);
274 virtual void RemoveObject(GEOM::GEOM_BaseObject_ptr theObject);
276 virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
278 virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
280 virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
281 CORBA::Boolean isPublished,
282 CORBA::Boolean isMultiFile,
283 CORBA::Boolean& isValidScript);
285 char* GetDumpName (const char* theStudyEntry);
287 GEOM::string_array* GetAllDumpNames();
289 // Object information
290 virtual bool hasObjectInfo();
291 virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
293 // Version information
294 virtual char* getVersion();
296 // Create a new folder object
297 SALOMEDS::SObject_ptr CreateFolder(const char* theName,
298 SALOMEDS::SObject_ptr theFather);
300 // Move GEOM object to the specified folder
301 void MoveToFolder(GEOM::GEOM_Object_ptr theObject,
302 SALOMEDS::SObject_ptr theFolder);
304 // Move list of GEOM objects to the specified folder
305 void MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
306 SALOMEDS::SObject_ptr theFolder);
308 // Move objects to the specified position
309 void Move( const GEOM::object_list& what,
310 SALOMEDS::SObject_ptr where,
313 // SIMAN-related functions (check out/check in) : import data to study
314 virtual Engines::ListOfIdentifiers* importData(CORBA::Long studyId,
315 Engines::DataContainer_ptr data,
316 const Engines::ListOfOptions& options);
317 // SIMAN-related functions (check out/check in) : get modified data
318 virtual Engines::ListOfData* getModifiedData(CORBA::Long studyId);
320 //-----------------------------------------------------------------------//
321 // Internal methods //
322 //-----------------------------------------------------------------------//
324 virtual GEOM::GEOM_BaseObject_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
327 GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr theStudy,
328 GEOM::GEOM_Object_ptr theObject,
329 SALOMEDS::SObject_ptr theSObject,
330 const GEOM::ListOfGO& theArgs,
331 GEOM::find_shape_method theFindMethod,
332 CORBA::Boolean theInheritFirstArg,
333 CORBA::Boolean theAddPrefix);
335 GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
336 SALOMEDS::SObject_ptr theOldSO,
337 SALOMEDS::SObject_ptr theNewSO,
338 GEOM::GEOM_Object_ptr theNewO,
339 GEOM::ListOfGO& theOutArgs,
340 GEOM::find_shape_method theFindMethod,
341 CORBA::Boolean theAddPrefix);
343 GEOM::ListOfGO* RestoreGivenSubShapes (SALOMEDS::Study_ptr theStudy,
344 GEOM::GEOM_Object_ptr theObject,
345 SALOMEDS::SObject_ptr theSObject,
346 const GEOM::ListOfGO& theArgs,
347 GEOM::find_shape_method theFindMethod,
348 CORBA::Boolean theInheritFirstArg,
349 CORBA::Boolean theAddPrefix);
351 GEOM::ListOfGO* RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
352 SALOMEDS::SObject_ptr theOldSO,
353 SALOMEDS::SObject_ptr theNewSO,
354 GEOM::GEOM_Object_ptr theNewO,
355 std::set<std::string> theArgs,
356 GEOM::find_shape_method theFindMethod,
357 CORBA::Boolean theAddPrefix);
359 // auxilary for PublishNamedShapesInStudy
360 void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
361 GEOM::GEOM_Object_var theMainShape,
362 const TopTools_IndexedMapOfShape& anIndices,
363 const TopTools_SequenceOfShape& SeqS,
364 const TColStd_SequenceOfAsciiString& SeqN,
365 const Standard_CString& GrName,
366 GEOM::ListOfGO_var aResList);
370 ::GEOMImpl_Gen* _impl;
371 SALOME_NamingService * name_service;
374 // plugin operations managing
375 std::map<std::string, GEOM_GenericOperationsCreator*> myOpCreatorMap;