1 // Copyright (C) 2007-2008 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
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISUConfig.hh
24 // Author : Alexey PETROV
27 #ifndef __VISU_CONFIG_H__
28 #define __VISU_CONFIG_H__
33 #include "SALOMEconfig.h"
34 #include CORBA_SERVER_HEADER(VISU_Gen)
35 #include CORBA_SERVER_HEADER(MED)
36 #include CORBA_SERVER_HEADER(SALOMEDS)
37 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
39 #include "SALOME_NamingService.hxx"
40 #include "SALOME_LifeCycleCORBA.hxx"
41 #include "Utils_CorbaException.hxx"
42 #include "utilities.h"
44 #include "SALOMEDSClient_SObject.hxx"
45 #include "SALOMEDSClient_Study.hxx"
51 #include <QApplication>
54 // standard C++ headers
66 class SUIT_ResourceMgr;
67 class SalomeApp_Study;
73 VISU_I_EXPORT SUIT_Session *GetSession();
74 VISU_I_EXPORT SUIT_ResourceMgr *GetResourceMgr();
76 //===========================================================================
80 class VISU_I_EXPORT Base_i : public virtual POA_VISU::Base,
81 public virtual PortableServer::RefCountServantBase
84 typedef VISU::Base TInterface;
88 virtual char* GetID();
89 virtual VISU::VISUType GetType() = 0;
95 static QMutex* myMutex;
96 static CORBA::ORB_var myOrb;
97 static PortableServer::POA_var myPoa;
98 static SALOME_NamingService* myNamingService;
99 static VISU_Gen_i* myVisuGenImpl;
100 static SALOME_LifeCycleCORBA* myEnginesLifeCycle;
103 static CORBA::ORB_var GetORB() { return myOrb;}
104 static PortableServer::POA_var GetPOA() { return myPoa;}
105 static SALOME_NamingService* GetNS() { return myNamingService;}
106 static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;}
107 static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;}
111 //===========================================================================
112 class VISU_I_EXPORT Mutex
117 Mutex(QMutex* theMutex);
122 //===========================================================================
123 class VISU_I_EXPORT Storable : public virtual Base_i
131 GetComment() const = 0;
134 //---------------------------------------------------------------
135 typedef std::map<std::string, QString> TRestoringMap;
137 typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
138 const TRestoringMap& theMap,
139 const std::string& thePrefix,
140 CORBA::Boolean theIsMultiFile);
142 typedef std::map<std::string, TStorableEngine> TStorableEngineMap;
146 RegistryStorableEngine(const std::string& theComment,
147 TStorableEngine theEngine);
151 Create(SALOMEDS::SObject_ptr theSObject,
152 const std::string& theLocalPersistentID,
153 const std::string& thePrefix,
154 CORBA::Boolean theIsMultiFile);
157 //---------------------------------------------------------------
160 Comment2Type(const std::string& theComment);
164 RestoringMap2Type(const TRestoringMap& theRestoringMap);
168 Stream2Type(const std::string& thePersistentString);
172 SObject2Type(const _PTR(SObject)& theSObject);
176 CorrectPersistentString(const std::string& thePersistentString);
180 FindEntry(SALOMEDS::Study_ptr theStudyDocument,
181 const std::string& theStartEntry,
182 const TRestoringMap& theRestoringMap,
183 int IsAllLevels = true);
187 FindValue(const TRestoringMap& theMap,
188 const std::string& theArg,
189 bool* theIsFind = NULL);
193 FindValue(const TRestoringMap& theMap,
194 const std::string& theArg,
195 const QString& theDefaultValue);
199 StringToMap(const QString& theString,
200 TRestoringMap& theMap);
204 GetStorableMap(_PTR(SObject) theSObject);
207 SALOMEDS::SObject_ptr
208 GetResultSO(SALOMEDS::SObject_ptr theSObject);
212 DataToStream(std::ostringstream& theStr,
213 const QString& theName,
214 const QString& theVal);
218 DataToStream(std::ostringstream& theStr,
219 const QString& theName,
224 DataToStream(std::ostringstream& theStr,
225 const QString& theName,
230 DataToStream(std::ostringstream& theStr,
231 const QString& theName,
234 //---------------------------------------------------------------
237 CanCopy(SALOMEDS::SObject_ptr theObject);
239 typedef std::string TFileName;
240 typedef std::vector<TFileName> TFileNames;
244 CopyFrom(SALOMEDS::SObject_ptr theObject,
245 CORBA::Long& theObjectID,
246 const std::string& theTmpDir,
247 TFileNames& theFileNames);
250 //---------------------------------------------------------------
254 ToStream(std::ostringstream& theStr) = 0;
257 static TStorableEngineMap myStorableEngineMap;
260 //===========================================================================
263 GenerateName(const std::string& theFmt, int theId);
266 PortableServer::ServantBase_var
267 GetServant(CORBA::Object_ptr theObject);
271 ClientSObjectToObject(_PTR(SObject) theSObject);
275 SObjectToObject(SALOMEDS::SObject_ptr);
279 ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
282 SALOMEDS::SComponent_var
283 FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
285 const char* const NO_ICON = "";
286 const char* const NO_IOR = "";
287 const char* const NO_NAME = "";
288 const char* const NO_PERFSITENT_REF = "";
289 const char* const NO_COMMENT = "";
293 CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
294 const std::string& theFatherEntry,
295 const std::string& theIconName,
296 const std::string& theIOR,
297 const std::string& theName,
298 const std::string& thePersistentRef,
299 const std::string& theComment,
300 CORBA::Boolean theCreateNew = true);
304 CreateAttributes(_PTR(Study) theStudyDocument,
305 const std::string& theFatherEntry,
306 const std::string& theIconName,
307 const std::string& theIOR,
308 const std::string& theName,
309 const std::string& thePersistentRef,
310 const std::string& theComment,
311 CORBA::Boolean theCreateNew = true);
314 SALOMEDS::SObject_var
315 GetSObject(_PTR(SObject));
319 GetClientSObject(SALOMEDS::SObject_ptr theSObject,
320 _PTR(Study) theStudy);
324 GetDSStudy(_PTR(Study) theStudy);
328 GetGUIStudy(SALOMEDS::Study_ptr theStudy);
332 GetStudy(SALOMEDS::Study_ptr theStudy);
336 RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
337 bool theIsAttrOnly = true,
338 bool theDestroySubObjects = false);
341 RemoveFromStudy(_PTR(SObject) theSObject,
342 bool theIsAttrOnly = true,
343 bool theDestroySubObjects = false);