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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : VISUConfig.hh
24 // Author : Alexey PETROV
27 #ifndef __VISU_CONFIG_H__
28 #define __VISU_CONFIG_H__
30 // standard C++ headers
39 #include <qfileinfo.h>
40 #include <qapplication.h>
43 #include "SALOMEconfig.h"
44 #include CORBA_SERVER_HEADER(VISU_Gen)
45 #include CORBA_SERVER_HEADER(MED)
46 #include CORBA_SERVER_HEADER(SALOMEDS)
47 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
48 #include "SALOME_NamingService.hxx"
49 #include "SALOME_LifeCycleCORBA.hxx"
50 #include "Utils_CorbaException.hxx"
51 #include "utilities.h"
53 #include <SALOMEDSClient_SObject.hxx>
54 #include <SALOMEDSClient_Study.hxx>
60 class SUIT_ResourceMgr;
65 SUIT_Session *GetSession();
66 SUIT_ResourceMgr *GetResourceMgr();
68 //===========================================================================
72 class Base_i : public virtual POA_VISU::Base,
73 public virtual PortableServer::RefCountServantBase
78 virtual char* GetID();
79 virtual VISU::VISUType GetType() = 0;
85 static QMutex* myMutex;
86 static CORBA::ORB_var myOrb;
87 static PortableServer::POA_var myPoa;
88 static SALOME_NamingService* myNamingService;
89 static VISU_Gen_i* myVisuGenImpl;
90 static SALOME_LifeCycleCORBA* myEnginesLifeCycle;
93 static CORBA::ORB_var GetORB() { return myOrb;}
94 static PortableServer::POA_var GetPOA() { return myPoa;}
95 static SALOME_NamingService* GetNS() { return myNamingService;}
96 static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;}
97 static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;}
101 //===========================================================================
106 Mutex(QMutex* theMutex);
111 //===========================================================================
112 class Storable : public virtual Base_i {
114 virtual void ToStream(std::ostringstream& theStr) = 0;
116 std::string ToString();
117 virtual const char* GetComment() const = 0;
118 typedef std::map<std::string,QString> TRestoringMap;
119 typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
120 const std::string& thePrefix, const TRestoringMap& theMap);
121 typedef std::map<std::string,TStorableEngine> TCallbackMap;
122 static void Registry(const char* theComment, TStorableEngine theEngine);
123 static Storable* Create(SALOMEDS::SObject_ptr, const std::string& thePrefix, const std::string& theString);
124 static QString FindValue(const TRestoringMap& theMap, const std::string& theArg, bool* isFind = NULL);
125 static void StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap);
126 static SALOMEDS::SObject_ptr GetResultSO(SALOMEDS::SObject_ptr theSObject);
127 static void DataToStream(std::ostringstream& theStr, const QString& theName, const QString& theVal);
128 static void DataToStream(std::ostringstream& theStr, const QString& theName, const int theVal);
129 static void DataToStream(std::ostringstream& theStr, const QString& theName, const double theVal);
132 //===========================================================================
133 class RemovableObject_i : public virtual POA_VISU::RemovableObject,
134 public virtual Storable
137 virtual void RemoveFromStudy() = 0;
140 //===========================================================================
141 const CORBA::Boolean IsMultifile();
142 QString GenerateName(const std::string& theFmt, int theId);
144 PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
145 CORBA::Object_var ClientSObjectToObject(_PTR(SObject) theSObject);
146 CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr);
148 _PTR(SComponent) ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
149 SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
151 std::string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
152 const char* theFatherEntry, const char* theRefFatherEntry,
153 const char* theIOR, const char* theName,
154 const char* thePersistentRef, const char* theComment,
155 CORBA::Boolean theCreateNew = true);
157 std::string CreateAttributes(_PTR(Study) theStudyDocument,
158 const char* theFatherEntry, const char* theRefFatherEntry,
159 const char* theIOR, const char* theName,
160 const char* thePersistentRef, const char* theComment,
161 CORBA::Boolean theCreateNew = true);
163 std::string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
164 const char* theComment, int IsAllLevels = true);
166 SALOMEDS::SObject_var GetSObject( _PTR(SObject) );
167 _PTR(SObject) GetClientSObject( SALOMEDS::SObject_var, _PTR(Study) );
168 SALOMEDS::Study_var GetDSStudy( _PTR(Study) );