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
63 class TopTools_SequenceOfShape;
65 //=====================================================================
66 // Generic operations creator (for plugins mechanism)
67 //=====================================================================
68 class GEOM_I_EXPORT GEOM_GenericOperationsCreator
72 virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA,
74 GEOM::GEOM_Gen_ptr theEngine,
75 ::GEOMImpl_Gen* theGenImpl) = 0;
76 // return the name of IDL module
77 //virtual std::string GetModuleName() = 0;
80 //=====================================================================
81 // GEOM_Gen_i : class definition
82 //=====================================================================
83 class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual public Engines_Component_i
87 //-----------------------------------------------------------------------//
88 // Constructor / Destructor //
89 //-----------------------------------------------------------------------//
91 // constructor to be called for servant creation.
93 GEOM_Gen_i(CORBA::ORB_ptr orb,
94 PortableServer::POA_ptr poa,
95 PortableServer::ObjectId * contId,
96 const char *instanceName,
97 const char *interfaceName);
99 // destructor, doing nothing (for now)
100 virtual ~GEOM_Gen_i();
102 // generic method to be put in a super class
103 void register_name(char * name);
106 CORBA::ORB_ptr GetORB() { return CORBA::ORB::_duplicate(_orb); }
108 // Get Naming Service object
109 SALOME_NamingService* GetNS() { return name_service; }
111 //-----------------------------------------------------------------------//
112 // Inherited methods from SALOMEDS::Driver //
113 //-----------------------------------------------------------------------//
115 SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
119 SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
123 CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
124 const SALOMEDS::TMPFile& theStream,
128 CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
129 const SALOMEDS::TMPFile& theStream,
133 void Close(SALOMEDS::SComponent_ptr theComponent);
134 char* ComponentDataType();
137 char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
138 const char* IORString,
139 CORBA::Boolean isMultiFile,
140 CORBA::Boolean isASCII);
141 char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
142 const char* aLocalPersistentID,
143 CORBA::Boolean isMultiFile,
144 CORBA::Boolean isASCII);
146 bool CanPublishInStudy(CORBA::Object_ptr theIOR);
147 SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
148 SALOMEDS::SObject_ptr theSObject,
149 CORBA::Object_ptr theObject,
150 const char* theName) throw (SALOME::SALOME_Exception) ;
152 GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
153 CORBA::Object_ptr theObject);
155 CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
156 SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
157 CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
158 SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
159 CORBA::Long theObjectID,
160 SALOMEDS::SObject_ptr theObject);
162 /*! \brief Adds theObject in the study with a name = theName, if
163 * theFather is not null the object is placed under theFather
165 SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
166 GEOM::GEOM_BaseObject_ptr theObject,
168 GEOM::GEOM_BaseObject_ptr theFather);
170 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
171 * To be used from python scripts out of geompy.addToStudy (non-default usage)
173 GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
174 GEOM::GEOM_Object_ptr theObject,
175 const GEOM::ListOfGO& theArgs,
176 GEOM::find_shape_method theFindMethod,
177 CORBA::Boolean theInheritFirstArg,
178 CORBA::Boolean theAddPrefix);
180 /*! \brief Publish sub-shapes, standing for given in \a theArgs arguments and sub-shapes.
181 * To be used from python scripts, generated by Dump Python.
183 GEOM::ListOfGO* RestoreGivenSubShapesO (SALOMEDS::Study_ptr theStudy,
184 GEOM::GEOM_Object_ptr theObject,
185 const GEOM::ListOfGO& theArgs,
186 GEOM::find_shape_method theFindMethod,
187 CORBA::Boolean theInheritFirstArg,
188 CORBA::Boolean theAddPrefix);
190 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
191 * To be used from GUI and from geompy.addToStudy
193 GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
194 SALOMEDS::SObject_ptr theSObject,
195 const GEOM::ListOfGO& theArgs,
196 GEOM::find_shape_method theFindMethod,
197 CORBA::Boolean theInheritFirstArg,
198 CORBA::Boolean theAddPrefix);
200 //-----------------------------------------------------------------------//
201 // Transaction methods //
202 //-----------------------------------------------------------------------//
204 //Undos one transaction in the document associated with theStudyID
205 virtual void Undo(CORBA::Long theStudyID);
207 //Redos one transaction in the document associated with theStudyID
208 virtual void Redo(CORBA::Long theStudyID);
210 //-----------------------------------------------------------------------//
211 // Operations methods //
212 //-----------------------------------------------------------------------//
214 //Returns a pointer to BasicOperations interface
215 virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID)
216 throw (SALOME::SALOME_Exception);
218 //Returns a pointer to TransformOperations interface
219 virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID)
220 throw (SALOME::SALOME_Exception);
222 //Returns a pointer to 3DPrimOperations interface
223 virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID)
224 throw (SALOME::SALOME_Exception);
226 //Returns a pointer to ShapesOperations interface
227 virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID)
228 throw (SALOME::SALOME_Exception);
230 //Returns a pointer to BlocksOperations interface
231 virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID)
232 throw (SALOME::SALOME_Exception);
234 //Returns a pointer to BooleanOperations interface
235 virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID)
236 throw (SALOME::SALOME_Exception);
238 //Returns a pointer to CurvesOperations interface
239 virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID)
240 throw (SALOME::SALOME_Exception);
242 //Returns a pointer to LocalOperations interface
243 virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID)
244 throw (SALOME::SALOME_Exception);
246 //Returns a pointer to HealingOperations interface
247 virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID)
248 throw (SALOME::SALOME_Exception);
250 //Returns a pointer to InsertOperations interface
251 virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID)
252 throw (SALOME::SALOME_Exception);
254 //Returns a pointer to MeasureOperations interface
255 virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID)
256 throw (SALOME::SALOME_Exception);
258 //Returns a pointer to GroupOperations interface
259 virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
260 throw (SALOME::SALOME_Exception);
262 //Returns a pointer to FiedlOperations interface
263 virtual GEOM::GEOM_IFieldOperations_ptr GetIFieldOperations (CORBA::Long theStudyID)
264 throw (SALOME::SALOME_Exception);
266 //Returns a pointer to corresponding plugin operations interface
267 virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (CORBA::Long theStudyID,
268 const char* theLibName)
269 throw (SALOME::SALOME_Exception);
271 //Adds a new sub-shape
272 virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
273 const GEOM::ListOfLong& theIndices);
275 virtual void RemoveObject(GEOM::GEOM_BaseObject_ptr theObject);
277 virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
279 virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
281 virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
282 CORBA::Boolean isPublished,
283 CORBA::Boolean isMultiFile,
284 CORBA::Boolean& isValidScript);
286 char* GetDumpName (const char* theStudyEntry);
288 GEOM::string_array* GetAllDumpNames();
290 // Object information
291 virtual bool hasObjectInfo();
292 virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
294 // Version information
295 virtual char* getVersion();
297 // Create a new folder object
298 SALOMEDS::SObject_ptr CreateFolder(const char* theName,
299 SALOMEDS::SObject_ptr theFather);
301 // Move GEOM object to the specified folder
302 void MoveToFolder(GEOM::GEOM_Object_ptr theObject,
303 SALOMEDS::SObject_ptr theFolder);
305 // Move list of GEOM objects to the specified folder
306 void MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
307 SALOMEDS::SObject_ptr theFolder);
309 // Move objects to the specified position
310 void Move( const GEOM::object_list& what,
311 SALOMEDS::SObject_ptr where,
314 // SIMAN-related functions (check out/check in) : import data to study
315 virtual Engines::ListOfIdentifiers* importData(CORBA::Long studyId,
316 Engines::DataContainer_ptr data,
317 const Engines::ListOfOptions& options);
318 // SIMAN-related functions (check out/check in) : get modified data
319 virtual Engines::ListOfData* getModifiedData(CORBA::Long studyId);
321 //-----------------------------------------------------------------------//
322 // Internal methods //
323 //-----------------------------------------------------------------------//
325 virtual GEOM::GEOM_BaseObject_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
328 GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr theStudy,
329 GEOM::GEOM_Object_ptr theObject,
330 SALOMEDS::SObject_ptr theSObject,
331 const GEOM::ListOfGO& theArgs,
332 GEOM::find_shape_method theFindMethod,
333 CORBA::Boolean theInheritFirstArg,
334 CORBA::Boolean theAddPrefix);
336 GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
337 SALOMEDS::SObject_ptr theOldSO,
338 SALOMEDS::SObject_ptr theNewSO,
339 GEOM::GEOM_Object_ptr theNewO,
340 GEOM::ListOfGO& theOutArgs,
341 GEOM::find_shape_method theFindMethod,
342 CORBA::Boolean theAddPrefix);
344 GEOM::ListOfGO* RestoreGivenSubShapes (SALOMEDS::Study_ptr theStudy,
345 GEOM::GEOM_Object_ptr theObject,
346 SALOMEDS::SObject_ptr theSObject,
347 const GEOM::ListOfGO& theArgs,
348 GEOM::find_shape_method theFindMethod,
349 CORBA::Boolean theInheritFirstArg,
350 CORBA::Boolean theAddPrefix);
352 GEOM::ListOfGO* RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
353 SALOMEDS::SObject_ptr theOldSO,
354 SALOMEDS::SObject_ptr theNewSO,
355 GEOM::GEOM_Object_ptr theNewO,
356 std::set<std::string> theArgs,
357 GEOM::find_shape_method theFindMethod,
358 CORBA::Boolean theAddPrefix);
360 // auxilary for PublishNamedShapesInStudy
361 void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
362 GEOM::GEOM_Object_var theMainShape,
363 const TopTools_IndexedMapOfShape& anIndices,
364 const TopTools_SequenceOfShape& SeqS,
365 const TColStd_SequenceOfAsciiString& SeqN,
366 const Standard_CString& GrName,
367 GEOM::ListOfGO_var aResList);
371 ::GEOMImpl_Gen* _impl;
372 SALOME_NamingService * name_service;
375 // plugin operations managing
376 std::map<std::string, GEOM_GenericOperationsCreator*> myOpCreatorMap;