Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GEOM_Gen_i.hh
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 #ifndef __GEOM_GEN_I_H__
24 #define __GEOM_GEN_I_H__
25 
26 #include "GEOM_GEOM_I.hxx"
27 
28 #include "GEOMImpl_Gen.hxx"
29 
30 // IDL headers
31 #include <SALOMEconfig.h>
32 #include CORBA_SERVER_HEADER(GEOM_Gen)
33 
34 #include CORBA_CLIENT_HEADER(SALOMEDS)
35 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
36 
37 
38 #include "SALOME_Component_i.hxx"
39 #include "SALOME_NamingService.hxx"
40 
54 #include "GEOMUtils.hxx"
55 
56 #include <TopTools_IndexedMapOfShape.hxx>
57 #include <TopTools_SequenceOfShape.hxx>
58 
59 #include <map>
60 #include <set>
61 #include <list>
62 #include <string>
63 
64 //#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
65 
66 //=====================================================================
67 // Generic operations creator (for plugins mechanism)
68 //=====================================================================
70 {
71 public:
72  // Create operations
73  virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA,
74  int theStudyId,
75  GEOM::GEOM_Gen_ptr theEngine,
76  ::GEOMImpl_Gen* theGenImpl) = 0;
77  // return the name of IDL module
78  //virtual std::string GetModuleName() = 0;
79 };
80 
81 //=====================================================================
82 // GEOM_Gen_i : class definition
83 //=====================================================================
84 class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual public Engines_Component_i
85 {
86  public:
87 
88  //-----------------------------------------------------------------------//
89  // Constructor / Destructor //
90  //-----------------------------------------------------------------------//
91 
92  // constructor to be called for servant creation.
93  GEOM_Gen_i();
94  GEOM_Gen_i(CORBA::ORB_ptr orb,
95  PortableServer::POA_ptr poa,
96  PortableServer::ObjectId * contId,
97  const char *instanceName,
98  const char *interfaceName);
99 
100  // destructor, doing nothing (for now)
101  virtual ~GEOM_Gen_i();
102 
103  // generic method to be put in a super class
104  void register_name(char * name);
105 
106  // Get ORB object
107  CORBA::ORB_ptr GetORB() { return CORBA::ORB::_duplicate(_orb); }
108 
109  // Get Naming Service object
110  SALOME_NamingService* GetNS() { return name_service; }
111 
112  //-----------------------------------------------------------------------//
113  // Inherited methods from SALOMEDS::Driver //
114  //-----------------------------------------------------------------------//
115 
116  SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
117  const char* theURL,
118  bool isMultiFile);
119 
120  SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
121  const char* theURL,
122  bool isMultiFile);
123 
124  CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
125  const SALOMEDS::TMPFile& theStream,
126  const char* theURL,
127  bool isMultiFile);
128 
129  CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
130  const SALOMEDS::TMPFile& theStream,
131  const char* theURL,
132  bool isMultiFile);
133 
134  void Close(SALOMEDS::SComponent_ptr theComponent);
135  char* ComponentDataType();
136 
137 
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);
146 
147  bool CanPublishInStudy(CORBA::Object_ptr theIOR);
148  SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
149  SALOMEDS::SObject_ptr theSObject,
150  CORBA::Object_ptr theObject,
151  const char* theName) throw (SALOME::SALOME_Exception) ;
152 
153  GEOM::ListOfGO* PublishNamedShapesInStudy(SALOMEDS::Study_ptr theStudy,
154  CORBA::Object_ptr theObject);
155 
156  CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
157  SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
158  CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
159  SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
160  CORBA::Long theObjectID,
161  SALOMEDS::SObject_ptr theObject);
162 
166  SALOMEDS::SObject_ptr AddInStudy (SALOMEDS::Study_ptr theStudy,
167  GEOM::GEOM_BaseObject_ptr theObject,
168  const char* theName,
169  GEOM::GEOM_BaseObject_ptr theFather);
170 
174  GEOM::ListOfGO* RestoreSubShapesO (SALOMEDS::Study_ptr theStudy,
175  GEOM::GEOM_Object_ptr theObject,
176  const GEOM::ListOfGO& theArgs,
177  GEOM::find_shape_method theFindMethod,
178  CORBA::Boolean theInheritFirstArg,
179  CORBA::Boolean theAddPrefix);
180 
184  GEOM::ListOfGO* RestoreGivenSubShapesO (SALOMEDS::Study_ptr theStudy,
185  GEOM::GEOM_Object_ptr theObject,
186  const GEOM::ListOfGO& theArgs,
187  GEOM::find_shape_method theFindMethod,
188  CORBA::Boolean theInheritFirstArg,
189  CORBA::Boolean theAddPrefix);
190 
194  GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::Study_ptr theStudy,
195  SALOMEDS::SObject_ptr theSObject,
196  const GEOM::ListOfGO& theArgs,
197  GEOM::find_shape_method theFindMethod,
198  CORBA::Boolean theInheritFirstArg,
199  CORBA::Boolean theAddPrefix);
200 
201  //Collects dependencies of the given objects from other ones
202  SALOMEDS::TMPFile* GetDependencyTree(SALOMEDS::Study_ptr theStudy,
203  const GEOM::string_array& theObjectEntries);
204 
205  //-----------------------------------------------------------------------//
206  // Transaction methods //
207  //-----------------------------------------------------------------------//
208 
209  //Undos one transaction in the document associated with theStudyID
210  virtual void Undo(CORBA::Long theStudyID);
211 
212  //Redos one transaction in the document associated with theStudyID
213  virtual void Redo(CORBA::Long theStudyID);
214 
215  //-----------------------------------------------------------------------//
216  // Operations methods //
217  //-----------------------------------------------------------------------//
218 
219  //Returns a pointer to BasicOperations interface
220  virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations (CORBA::Long theStudyID)
221  throw (SALOME::SALOME_Exception);
222 
223  //Returns a pointer to TransformOperations interface
224  virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations (CORBA::Long theStudyID)
225  throw (SALOME::SALOME_Exception);
226 
227  //Returns a pointer to 3DPrimOperations interface
228  virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations (CORBA::Long theStudyID)
229  throw (SALOME::SALOME_Exception);
230 
231  //Returns a pointer to ShapesOperations interface
232  virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations (CORBA::Long theStudyID)
233  throw (SALOME::SALOME_Exception);
234 
235  //Returns a pointer to BlocksOperations interface
236  virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations (CORBA::Long theStudyID)
237  throw (SALOME::SALOME_Exception);
238 
239  //Returns a pointer to BooleanOperations interface
240  virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations (CORBA::Long theStudyID)
241  throw (SALOME::SALOME_Exception);
242 
243  //Returns a pointer to CurvesOperations interface
244  virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations (CORBA::Long theStudyID)
245  throw (SALOME::SALOME_Exception);
246 
247  //Returns a pointer to LocalOperations interface
248  virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations (CORBA::Long theStudyID)
249  throw (SALOME::SALOME_Exception);
250 
251  //Returns a pointer to HealingOperations interface
252  virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations (CORBA::Long theStudyID)
253  throw (SALOME::SALOME_Exception);
254 
255  //Returns a pointer to InsertOperations interface
256  virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations (CORBA::Long theStudyID)
257  throw (SALOME::SALOME_Exception);
258 
259  //Returns a pointer to MeasureOperations interface
260  virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations (CORBA::Long theStudyID)
261  throw (SALOME::SALOME_Exception);
262 
263  //Returns a pointer to GroupOperations interface
264  virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations (CORBA::Long theStudyID)
265  throw (SALOME::SALOME_Exception);
266 
267  //Returns a pointer to FiedlOperations interface
268  virtual GEOM::GEOM_IFieldOperations_ptr GetIFieldOperations (CORBA::Long theStudyID)
269  throw (SALOME::SALOME_Exception);
270 
271  //Returns a pointer to corresponding plugin operations interface
272  virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (CORBA::Long theStudyID,
273  const char* theLibName)
274  throw (SALOME::SALOME_Exception);
275 
276  //Adds a new sub-shape
277  virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
278  const GEOM::ListOfLong& theIndices);
279 
280  virtual void RemoveObject(GEOM::GEOM_BaseObject_ptr theObject);
281 
282  virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
283 
284  virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
285 
286  virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
287  CORBA::Boolean isPublished,
288  CORBA::Boolean isMultiFile,
289  CORBA::Boolean& isValidScript);
290 
291  char* GetDumpName (const char* theStudyEntry);
292 
293  GEOM::string_array* GetAllDumpNames();
294 
295  // Object information
296  virtual bool hasObjectInfo();
297  virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
298 
299  // Version information
300  virtual char* getVersion();
301 
302  // Create a new folder object
303  SALOMEDS::SObject_ptr CreateFolder(const char* theName,
304  SALOMEDS::SObject_ptr theFather);
305 
306  // Move GEOM object to the specified folder
307  void MoveToFolder(GEOM::GEOM_Object_ptr theObject,
308  SALOMEDS::SObject_ptr theFolder);
309 
310  // Move list of GEOM objects to the specified folder
311  void MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
312  SALOMEDS::SObject_ptr theFolder);
313 
314  // Move objects to the specified position
315  void Move( const GEOM::object_list& what,
316  SALOMEDS::SObject_ptr where,
317  CORBA::Long row );
318 
322  void GetEntriesToReduceStudy(SALOMEDS::Study_ptr theStudy,
323  GEOM::string_array& theSelectedEntries,
324  GEOM::string_array& theParentEntries,
325  GEOM::string_array& theSubEntries,
326  GEOM::string_array& theOtherEntries);
327 
328  //-----------------------------------------------------------------------//
329  // Internal methods //
330  //-----------------------------------------------------------------------//
331 
332  virtual GEOM::GEOM_BaseObject_ptr GetObject(CORBA::Long theStudyID, const char* theEntry);
333 
334  private:
335  GEOM::ListOfGO* RestoreSubShapes (SALOMEDS::Study_ptr theStudy,
336  GEOM::GEOM_Object_ptr theObject,
337  SALOMEDS::SObject_ptr theSObject,
338  const GEOM::ListOfGO& theArgs,
339  GEOM::find_shape_method theFindMethod,
340  CORBA::Boolean theInheritFirstArg,
341  CORBA::Boolean theAddPrefix);
342 
343  GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
344  SALOMEDS::SObject_ptr theOldSO,
345  SALOMEDS::SObject_ptr theNewSO,
346  GEOM::GEOM_Object_ptr theNewO,
347  GEOM::ListOfGO& theOutArgs,
348  GEOM::find_shape_method theFindMethod,
349  CORBA::Boolean theAddPrefix);
350 
351  GEOM::ListOfGO* RestoreGivenSubShapes (SALOMEDS::Study_ptr theStudy,
352  GEOM::GEOM_Object_ptr theObject,
353  SALOMEDS::SObject_ptr theSObject,
354  const GEOM::ListOfGO& theArgs,
355  GEOM::find_shape_method theFindMethod,
356  CORBA::Boolean theInheritFirstArg,
357  CORBA::Boolean theAddPrefix);
358 
359  GEOM::ListOfGO* RestoreGivenSubShapesOneLevel (SALOMEDS::Study_ptr theStudy,
360  SALOMEDS::SObject_ptr theOldSO,
361  SALOMEDS::SObject_ptr theNewSO,
362  GEOM::GEOM_Object_ptr theNewO,
363  std::set<std::string> theArgs,
364  GEOM::find_shape_method theFindMethod,
365  CORBA::Boolean theAddPrefix);
366 
367  // auxilary for PublishNamedShapesInStudy
368  void CreateAndPublishGroup(SALOMEDS::Study_ptr theStudy,
369  GEOM::GEOM_Object_var theMainShape,
370  const TopTools_IndexedMapOfShape& anIndices,
371  const TopTools_SequenceOfShape& SeqS,
372  const TColStd_SequenceOfAsciiString& SeqN,
373  const Standard_CString& GrName,
374  GEOM::ListOfGO_var aResList);
375 
376  void getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
377  GEOMUtils::LevelsList &upLevelList,
378  std::map< std::string, std::set<std::string> > &passedEntries,
379  int level = 0 );
380 
381  void getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
382  GEOMUtils::LevelsList &downLevelList,
383  std::map< std::string, std::set<std::string> > &passedEntries,
384  int level = 0 );
385 
386  void includeParentDependencies(GEOM::GEOM_BaseObject_ptr gbo,
387  std::set<std::string>& aSelected,
388  std::set<std::string>& aParents,
389  std::set<std::string>& aChildren,
390  std::set<std::string>& anOthers);
391 
392  void includeSubObjects(SALOMEDS::Study_ptr theStudy,
393  const std::string& aSelectedEntry,
394  std::set<std::string>& aSelected,
395  std::set<std::string>& aParents,
396  std::set<std::string>& aChildren,
397  std::set<std::string>& anOthers);
398 
399  void LoadPlugin(const std::string& theLibName);
400 
401  private:
402 
404  SALOME_NamingService * name_service;
405  char * _name;
406 
407  // plugin operations managing
408  std::map<std::string, GEOM_GenericOperationsCreator*> myOpCreatorMap;
409 };
410 
411 #endif