1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 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 // 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"
50 #include <qfileinfo.h>
51 #include <qapplication.h>
53 // standard C++ headers
65 class SUIT_ResourceMgr;
66 class SalomeApp_Study;
72 VISU_I_EXPORT SUIT_Session *GetSession();
73 VISU_I_EXPORT SUIT_ResourceMgr *GetResourceMgr();
75 //===========================================================================
79 class VISU_I_EXPORT Base_i : public virtual POA_VISU::Base,
80 public virtual PortableServer::RefCountServantBase
83 typedef VISU::Base TInterface;
87 virtual char* GetID();
88 virtual VISU::VISUType GetType() = 0;
94 static QMutex* myMutex;
95 static CORBA::ORB_var myOrb;
96 static PortableServer::POA_var myPoa;
97 static SALOME_NamingService* myNamingService;
98 static VISU_Gen_i* myVisuGenImpl;
99 static SALOME_LifeCycleCORBA* myEnginesLifeCycle;
102 static CORBA::ORB_var GetORB() { return myOrb;}
103 static PortableServer::POA_var GetPOA() { return myPoa;}
104 static SALOME_NamingService* GetNS() { return myNamingService;}
105 static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;}
106 static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;}
110 //===========================================================================
111 class VISU_I_EXPORT Mutex
116 Mutex(QMutex* theMutex);
121 //===========================================================================
122 class VISU_I_EXPORT Storable : public virtual Base_i
130 GetComment() const = 0;
133 //---------------------------------------------------------------
134 typedef std::map<std::string, QString> TRestoringMap;
136 typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
137 const TRestoringMap& theMap,
138 const std::string& thePrefix,
139 CORBA::Boolean theIsMultiFile);
141 typedef std::map<std::string, TStorableEngine> TStorableEngineMap;
145 RegistryStorableEngine(const std::string& theComment,
146 TStorableEngine theEngine);
150 Create(SALOMEDS::SObject_ptr theSObject,
151 const std::string& theLocalPersistentID,
152 const std::string& thePrefix,
153 CORBA::Boolean theIsMultiFile);
156 //---------------------------------------------------------------
159 Comment2Type(const std::string& theComment);
163 RestoringMap2Type(const TRestoringMap& theRestoringMap);
167 Stream2Type(const std::string& thePersistentString);
171 SObject2Type(const _PTR(SObject)& theSObject);
175 CorrectPersistentString(const std::string& thePersistentString);
179 FindEntry(SALOMEDS::Study_ptr theStudyDocument,
180 const std::string& theStartEntry,
181 const TRestoringMap& theRestoringMap,
182 int IsAllLevels = true);
186 FindValue(const TRestoringMap& theMap,
187 const std::string& theArg,
188 bool* theIsFind = NULL);
192 FindValue(const TRestoringMap& theMap,
193 const std::string& theArg,
194 const QString& theDefaultValue);
198 StringToMap(const QString& theString,
199 TRestoringMap& theMap);
203 GetStorableMap(_PTR(SObject) theSObject);
206 SALOMEDS::SObject_ptr
207 GetResultSO(SALOMEDS::SObject_ptr theSObject);
211 DataToStream(std::ostringstream& theStr,
212 const QString& theName,
213 const QString& theVal);
217 DataToStream(std::ostringstream& theStr,
218 const QString& theName,
223 DataToStream(std::ostringstream& theStr,
224 const QString& theName,
229 DataToStream(std::ostringstream& theStr,
230 const QString& theName,
233 //---------------------------------------------------------------
236 CanCopy(SALOMEDS::SObject_ptr theObject);
238 typedef std::string TFileName;
239 typedef std::vector<TFileName> TFileNames;
243 CopyFrom(SALOMEDS::SObject_ptr theObject,
244 CORBA::Long& theObjectID,
245 const std::string& theTmpDir,
246 TFileNames& theFileNames);
249 //---------------------------------------------------------------
253 ToStream(std::ostringstream& theStr) = 0;
256 static TStorableEngineMap myStorableEngineMap;
259 //===========================================================================
262 GenerateName(const std::string& theFmt, int theId);
265 PortableServer::ServantBase_var
266 GetServant(CORBA::Object_ptr theObject);
270 ClientSObjectToObject(_PTR(SObject) theSObject);
274 SObjectToObject(SALOMEDS::SObject_ptr);
278 ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
281 SALOMEDS::SComponent_var
282 FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
284 const char* const NO_ICON = "";
285 const char* const NO_IOR = "";
286 const char* const NO_NAME = "";
287 const char* const NO_PERFSITENT_REF = "";
288 const char* const NO_COMMENT = "";
292 CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
293 const std::string& theFatherEntry,
294 const std::string& theIconName,
295 const std::string& theIOR,
296 const std::string& theName,
297 const std::string& thePersistentRef,
298 const std::string& theComment,
299 CORBA::Boolean theCreateNew = true);
303 CreateAttributes(_PTR(Study) theStudyDocument,
304 const std::string& theFatherEntry,
305 const std::string& theIconName,
306 const std::string& theIOR,
307 const std::string& theName,
308 const std::string& thePersistentRef,
309 const std::string& theComment,
310 CORBA::Boolean theCreateNew = true);
313 SALOMEDS::SObject_var
314 GetSObject(_PTR(SObject));
318 GetClientSObject(SALOMEDS::SObject_ptr theSObject,
319 _PTR(Study) theStudy);
323 GetDSStudy(_PTR(Study) theStudy);
327 GetGUIStudy(SALOMEDS::Study_ptr theStudy);
331 GetStudy(SALOMEDS::Study_ptr theStudy);
335 RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
336 bool theIsAttrOnly = true,
337 bool theDestroySubObjects = false);
340 RemoveFromStudy(_PTR(SObject) theSObject,
341 bool theIsAttrOnly = true,
342 bool theDestroySubObjects = false);