1 // Copyright (C) 2007-2024 CEA, EDF, 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"
54 #include "GEOM_ITestOperations_i.hh"
55 #include "GEOM_ICanonicalRecognition_i.hh"
56 #include "GEOMUtils.hxx"
58 #include <TopTools_IndexedMapOfShape.hxx>
59 #include <TopTools_SequenceOfShape.hxx>
66 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
68 //=====================================================================
69 // Generic operations creator (for plugins mechanism)
70 //=====================================================================
71 class GEOM_I_EXPORT GEOM_GenericOperationsCreator
75 virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA,
76 GEOM::GEOM_Gen_ptr theEngine,
77 ::GEOMImpl_Gen* theGenImpl) = 0;
78 // return the name of IDL module
79 //virtual std::string GetModuleName() = 0;
80 virtual ~GEOM_GenericOperationsCreator() {}
83 //=====================================================================
84 // GEOM_Gen_i : class definition
85 //=====================================================================
86 class GEOM_I_EXPORT GEOM_Gen_i : public POA_GEOM::GEOM_Gen, public Engines_Component_i
90 //-----------------------------------------------------------------------//
91 // Constructor / Destructor //
92 //-----------------------------------------------------------------------//
94 // constructor to be called for servant creation.
96 GEOM_Gen_i(CORBA::ORB_ptr orb,
97 PortableServer::POA_ptr poa,
98 PortableServer::ObjectId * contId,
99 const char *instanceName,
100 const char *interfaceName,
101 bool withRegistry = true);
103 // destructor, doing nothing (for now)
104 virtual ~GEOM_Gen_i();
107 CORBA::ORB_ptr GetORB() { return CORBA::ORB::_duplicate(_orb); }
110 virtual SALOMEDS::Study_var getStudyServant() = 0;
112 //-----------------------------------------------------------------------//
113 // Inherited methods from SALOMEDS::Driver //
114 //-----------------------------------------------------------------------//
116 SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
120 SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
124 CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
125 const SALOMEDS::TMPFile& theStream,
129 CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
130 const SALOMEDS::TMPFile& theStream,
134 void Close(SALOMEDS::SComponent_ptr theComponent);
135 char* ComponentDataType();
138 char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
139 const char* IORString,
140 CORBA::Boolean isMultiFile,
141 CORBA::Boolean isASCII);
142 char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
143 const char* aLocalPersistentID,
144 CORBA::Boolean isMultiFile,
145 CORBA::Boolean isASCII);
147 bool CanPublishInStudy(CORBA::Object_ptr theIOR);
148 SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::SObject_ptr theSObject,
149 CORBA::Object_ptr theObject,
150 const char* theName) ;
152 GEOM::ListOfGO* PublishNamedShapesInStudy(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 (GEOM::GEOM_BaseObject_ptr theObject,
166 GEOM::GEOM_BaseObject_ptr theFather);
168 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
169 * To be used from python scripts out of geompy.addToStudy (non-default usage)
171 GEOM::ListOfGO* RestoreSubShapesO (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 (GEOM::GEOM_Object_ptr theObject,
181 const GEOM::ListOfGO& theArgs,
182 GEOM::find_shape_method theFindMethod,
183 CORBA::Boolean theInheritFirstArg,
184 CORBA::Boolean theAddPrefix);
186 /*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
187 * To be used from GUI and from geompy.addToStudy
189 GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::SObject_ptr theSObject,
190 const GEOM::ListOfGO& theArgs,
191 GEOM::find_shape_method theFindMethod,
192 CORBA::Boolean theInheritFirstArg,
193 CORBA::Boolean theAddPrefix);
195 //Collects dependencies of the given objects from other ones
196 SALOMEDS::TMPFile* GetDependencyTree(const GEOM::string_array& theObjectEntries);
198 //-----------------------------------------------------------------------//
199 // Transaction methods //
200 //-----------------------------------------------------------------------//
202 //Undos one transaction in the document
205 //Redos one transaction in the document
208 //-----------------------------------------------------------------------//
209 // Operations methods //
210 //-----------------------------------------------------------------------//
212 //Returns a pointer to BasicOperations interface
213 virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations();
215 //Returns a pointer to TransformOperations interface
216 virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations();
218 //Returns a pointer to 3DPrimOperations interface
219 virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations();
221 //Returns a pointer to ShapesOperations interface
222 virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations();
224 //Returns a pointer to BlocksOperations interface
225 virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations();
227 //Returns a pointer to BooleanOperations interface
228 virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations()
231 //Returns a pointer to CurvesOperations interface
232 virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations()
235 //Returns a pointer to LocalOperations interface
236 virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations()
239 //Returns a pointer to HealingOperations interface
240 virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations()
243 //Returns a pointer to InsertOperations interface
244 virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations()
247 //Returns a pointer to MeasureOperations interface
248 virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations()
251 //Returns a pointer to GroupOperations interface
252 virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations()
255 //Returns a pointer to FiedlOperations interface
256 virtual GEOM::GEOM_IFieldOperations_ptr GetIFieldOperations()
259 //Returns a pointer to TestOperations interface
260 virtual GEOM::GEOM_ITestOperations_ptr GetITestOperations()
263 virtual GEOM::GEOM_ICanonicalRecognition_ptr GetICanonicalRecognition();
265 //Returns a pointer to corresponding plugin operations interface
266 virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (const char* theLibName)
269 //Adds a new sub-shape
270 virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
271 const GEOM::ListOfLong& theIndices);
273 virtual void RemoveObject(GEOM::GEOM_BaseObject_ptr theObject);
275 virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
277 virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
279 virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
280 CORBA::Boolean isMultiFile,
281 CORBA::Boolean& isValidScript);
283 char* GetDumpName (const char* theStudyEntry);
285 GEOM::string_array* GetAllDumpNames();
287 // Object information
288 virtual bool hasObjectInfo();
289 virtual char* getObjectInfo(const char* entry);
291 // Version information
292 virtual char* getVersion();
294 // Create a new folder object
295 SALOMEDS::SObject_ptr CreateFolder(const char* theName,
296 SALOMEDS::SObject_ptr theFather);
298 // Move GEOM object to the specified folder
299 void MoveToFolder(GEOM::GEOM_Object_ptr theObject,
300 SALOMEDS::SObject_ptr theFolder);
302 // Move list of GEOM objects to the specified folder
303 void MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
304 SALOMEDS::SObject_ptr theFolder);
306 // Move objects to the specified position
307 void Move( const GEOM::object_list& what,
308 SALOMEDS::SObject_ptr where,
311 /*! \brief Fills 3 lists that is used to clean study of redundant objects.
312 * To be used from GUI.
314 void GetEntriesToReduceStudy(GEOM::string_array& theSelectedEntries,
315 GEOM::string_array& theParentEntries,
316 GEOM::string_array& theSubEntries,
317 GEOM::string_array& theOtherEntries);
319 //-----------------------------------------------------------------------//
320 // Internal methods //
321 //-----------------------------------------------------------------------//
323 virtual GEOM::GEOM_BaseObject_ptr GetObject(const char* theEntry);
326 SALOMEDS::SComponent_var findOrCreateComponent();
328 GEOM::ListOfGO* RestoreSubShapes (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::SObject_ptr theOldSO,
336 SALOMEDS::SObject_ptr theNewSO,
337 GEOM::GEOM_Object_ptr theNewO,
338 GEOM::ListOfGO& theOutArgs,
339 GEOM::find_shape_method theFindMethod,
340 CORBA::Boolean theAddPrefix);
342 GEOM::ListOfGO* RestoreGivenSubShapes (GEOM::GEOM_Object_ptr theObject,
343 SALOMEDS::SObject_ptr theSObject,
344 const GEOM::ListOfGO& theArgs,
345 GEOM::find_shape_method theFindMethod,
346 CORBA::Boolean theInheritFirstArg,
347 CORBA::Boolean theAddPrefix);
349 GEOM::ListOfGO* RestoreGivenSubShapesOneLevel (SALOMEDS::SObject_ptr theOldSO,
350 SALOMEDS::SObject_ptr theNewSO,
351 GEOM::GEOM_Object_ptr theNewO,
352 std::set<std::string> theArgs,
353 GEOM::find_shape_method theFindMethod,
354 CORBA::Boolean theAddPrefix);
356 // auxilary for PublishNamedShapesInStudy
357 void CreateAndPublishGroup(GEOM::GEOM_Object_var theMainShape,
358 const TopTools_IndexedMapOfShape& anIndices,
359 const TopTools_SequenceOfShape& SeqS,
360 const TColStd_SequenceOfAsciiString& SeqN,
361 const Standard_CString& GrName,
362 GEOM::ListOfGO_var aResList);
364 void getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
365 GEOMUtils::LevelsList &upLevelList,
366 std::map< std::string, std::set<std::string> > &passedEntries,
369 void getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
370 GEOMUtils::LevelsList &downLevelList,
371 std::map< std::string, std::set<std::string> > &passedEntries,
374 void includeParentDependencies(GEOM::GEOM_BaseObject_ptr gbo,
375 std::set<std::string>& aSelected,
376 std::set<std::string>& aParents,
377 std::set<std::string>& aChildren,
378 std::set<std::string>& anOthers);
380 void includeSubObjects(const std::string& aSelectedEntry,
381 std::set<std::string>& aSelected,
382 std::set<std::string>& aParents,
383 std::set<std::string>& aChildren,
384 std::set<std::string>& anOthers);
386 void LoadPlugin(const std::string& theLibName);
389 virtual void BreakLink(const char*) {}
393 ::GEOMImpl_Gen* _impl;
396 // plugin operations managing
397 std::map<std::string, GEOM_GenericOperationsCreator*> myOpCreatorMap;