1 // Copyright (C) 2007-2010 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
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISUConfig.hh
25 // Author : Alexey PETROV
28 #ifndef __VISU_CONFIG_H__
29 #define __VISU_CONFIG_H__
34 #include "SALOMEconfig.h"
35 #include CORBA_SERVER_HEADER(VISU_Gen)
36 #include CORBA_SERVER_HEADER(MED)
37 #include CORBA_SERVER_HEADER(SALOMEDS)
38 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
39 #include CORBA_SERVER_HEADER(SALOME_Types)
41 #include "SALOME_NamingService.hxx"
42 #include "SALOME_LifeCycleCORBA.hxx"
43 #include "Utils_CorbaException.hxx"
44 #include "utilities.h"
46 #include "SALOMEDSClient_SObject.hxx"
47 #include "SALOMEDSClient_Study.hxx"
53 #include <QApplication>
56 // standard C++ headers
68 class SUIT_ResourceMgr;
69 class SalomeApp_Study;
75 VISU_I_EXPORT SUIT_Session *GetSession();
76 VISU_I_EXPORT SUIT_ResourceMgr *GetResourceMgr();
78 //===========================================================================
82 class VISU_I_EXPORT Base_i : public virtual POA_VISU::Base,
83 public virtual PortableServer::RefCountServantBase
86 typedef VISU::Base TInterface;
90 virtual char* GetID();
91 virtual VISU::VISUType GetType() = 0;
97 static QMutex* myMutex;
98 static CORBA::ORB_var myOrb;
99 static PortableServer::POA_var myPoa;
100 static SALOME_NamingService* myNamingService;
101 static VISU_Gen_i* myVisuGenImpl;
102 static SALOME_LifeCycleCORBA* myEnginesLifeCycle;
105 static CORBA::ORB_var GetORB() { return myOrb;}
106 static PortableServer::POA_var GetPOA() { return myPoa;}
107 static SALOME_NamingService* GetNS() { return myNamingService;}
108 static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;}
109 static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;}
113 //===========================================================================
114 class VISU_I_EXPORT Mutex
119 Mutex(QMutex* theMutex);
124 //===========================================================================
125 class VISU_I_EXPORT Storable : public virtual Base_i
133 GetComment() const = 0;
136 //---------------------------------------------------------------
137 typedef std::map<std::string, QString> TRestoringMap;
139 typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
140 const TRestoringMap& theMap,
141 const std::string& thePrefix,
142 CORBA::Boolean theIsMultiFile);
144 typedef std::map<std::string, TStorableEngine> TStorableEngineMap;
148 RegistryStorableEngine(const std::string& theComment,
149 TStorableEngine theEngine);
153 Create(SALOMEDS::SObject_ptr theSObject,
154 const std::string& theLocalPersistentID,
155 const std::string& thePrefix,
156 CORBA::Boolean theIsMultiFile);
159 //---------------------------------------------------------------
162 Comment2Type(const std::string& theComment);
166 RestoringMap2Type(const TRestoringMap& theRestoringMap);
170 Stream2Type(const std::string& thePersistentString);
174 SObject2Type(const _PTR(SObject)& theSObject);
178 CorrectPersistentString(const std::string& thePersistentString);
182 FindEntry(SALOMEDS::Study_ptr theStudyDocument,
183 const std::string& theStartEntry,
184 const TRestoringMap& theRestoringMap,
185 int IsAllLevels = true);
189 FindValue(const TRestoringMap& theMap,
190 const std::string& theArg,
191 bool* theIsFind = NULL);
195 FindValue(const TRestoringMap& theMap,
196 const std::string& theArg,
197 const QString& theDefaultValue);
201 StringToMap(const QString& theString,
202 TRestoringMap& theMap);
206 GetStorableMap(_PTR(SObject) theSObject);
209 SALOMEDS::SObject_ptr
210 GetResultSO(SALOMEDS::SObject_ptr theSObject);
214 DataToStream(std::ostringstream& theStr,
215 const QString& theName,
216 const QString& theVal);
220 DataToStream(std::ostringstream& theStr,
221 const QString& theName,
226 DataToStream(std::ostringstream& theStr,
227 const QString& theName,
232 DataToStream(std::ostringstream& theStr,
233 const QString& theName,
236 //---------------------------------------------------------------
239 CanCopy(SALOMEDS::SObject_ptr theObject);
241 typedef std::string TFileName;
242 typedef std::vector<TFileName> TFileNames;
246 CopyFrom(SALOMEDS::SObject_ptr theObject,
247 CORBA::Long& theObjectID,
248 const std::string& theTmpDir,
249 TFileNames& theFileNames);
252 //---------------------------------------------------------------
256 ToStream(std::ostringstream& theStr) = 0;
259 static TStorableEngineMap myStorableEngineMap;
262 //===========================================================================
265 GenerateName(const std::string& theFmt, int theId);
268 PortableServer::ServantBase_var
269 GetServant(CORBA::Object_ptr theObject);
273 ClientSObjectToObject(_PTR(SObject) theSObject);
277 SObjectToObject(SALOMEDS::SObject_ptr);
281 ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
284 SALOMEDS::SComponent_var
285 FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
287 const char* const NO_ICON = "";
288 const char* const NO_IOR = "";
289 const char* const NO_NAME = "";
290 const char* const NO_PERFSITENT_REF = "";
291 const char* const NO_COMMENT = "";
295 CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
296 const std::string& theFatherEntry,
297 const std::string& theIconName,
298 const std::string& theIOR,
299 const std::string& theName,
300 const std::string& thePersistentRef,
301 const std::string& theComment,
302 CORBA::Boolean theCreateNew = true);
306 CreateAttributes(_PTR(Study) theStudyDocument,
307 const std::string& theFatherEntry,
308 const std::string& theIconName,
309 const std::string& theIOR,
310 const std::string& theName,
311 const std::string& thePersistentRef,
312 const std::string& theComment,
313 CORBA::Boolean theCreateNew = true);
316 SALOMEDS::SObject_var
317 GetSObject(_PTR(SObject));
321 GetClientSObject(SALOMEDS::SObject_ptr theSObject,
322 _PTR(Study) theStudy);
326 GetDSStudy(_PTR(Study) theStudy);
330 GetGUIStudy(SALOMEDS::Study_ptr theStudy);
334 GetStudy(SALOMEDS::Study_ptr theStudy);
338 RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
339 bool theIsAttrOnly = true,
340 bool theDestroySubObjects = false);
343 RemoveFromStudy(_PTR(SObject) theSObject,
344 bool theIsAttrOnly = true,
345 bool theDestroySubObjects = false);