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__
31 #include "SALOMEconfig.h"
32 #include CORBA_SERVER_HEADER(VISU_Gen)
33 #include CORBA_SERVER_HEADER(MED)
34 #include CORBA_SERVER_HEADER(SALOMEDS)
35 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
37 #include "SALOME_NamingService.hxx"
38 #include "SALOME_LifeCycleCORBA.hxx"
39 #include "Utils_CorbaException.hxx"
40 #include "utilities.h"
42 #include "SALOMEDSClient_SObject.hxx"
43 #include "SALOMEDSClient_Study.hxx"
48 #include <qfileinfo.h>
49 #include <qapplication.h>
51 // standard C++ headers
62 class SUIT_ResourceMgr;
67 SUIT_Session *GetSession();
68 SUIT_ResourceMgr *GetResourceMgr();
70 //===========================================================================
74 class Base_i : public virtual POA_VISU::Base,
75 public virtual PortableServer::RefCountServantBase
80 virtual char* GetID();
81 virtual VISU::VISUType GetType() = 0;
87 static QMutex* myMutex;
88 static CORBA::ORB_var myOrb;
89 static PortableServer::POA_var myPoa;
90 static SALOME_NamingService* myNamingService;
91 static VISU_Gen_i* myVisuGenImpl;
92 static SALOME_LifeCycleCORBA* myEnginesLifeCycle;
95 static CORBA::ORB_var GetORB() { return myOrb;}
96 static PortableServer::POA_var GetPOA() { return myPoa;}
97 static SALOME_NamingService* GetNS() { return myNamingService;}
98 static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;}
99 static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;}
103 //===========================================================================
108 Mutex(QMutex* theMutex);
113 //===========================================================================
114 class Storable : public virtual Base_i {
116 virtual void ToStream(std::ostringstream& theStr) = 0;
118 std::string ToString();
119 virtual const char* GetComment() const = 0;
120 typedef std::map<std::string,QString> TRestoringMap;
121 typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
122 const std::string& thePrefix, const TRestoringMap& theMap);
123 typedef std::map<std::string,TStorableEngine> TCallbackMap;
124 static void Registry(const char* theComment, TStorableEngine theEngine);
125 static Storable* Create(SALOMEDS::SObject_ptr, const std::string& thePrefix, const std::string& theString);
126 static QString FindValue(const TRestoringMap& theMap, const std::string& theArg, bool* isFind = NULL);
127 static void StrToMap(const QString& theStr, VISU::Storable::TRestoringMap& theMap);
128 static SALOMEDS::SObject_ptr GetResultSO(SALOMEDS::SObject_ptr theSObject);
129 static void DataToStream(std::ostringstream& theStr, const QString& theName, const QString& theVal);
130 static void DataToStream(std::ostringstream& theStr, const QString& theName, const int theVal);
131 static void DataToStream(std::ostringstream& theStr, const QString& theName, const double theVal);
134 //===========================================================================
135 class RemovableObject_i : public virtual POA_VISU::RemovableObject,
136 public virtual Storable
139 virtual void RemoveFromStudy() = 0;
142 //===========================================================================
143 const CORBA::Boolean IsMultifile();
144 QString GenerateName(const std::string& theFmt, int theId);
146 PortableServer::ServantBase_var GetServant(CORBA::Object_ptr theObject);
147 CORBA::Object_var ClientSObjectToObject(_PTR(SObject) theSObject);
148 CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr);
150 _PTR(SComponent) ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
151 SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
153 std::string CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
154 const char* theFatherEntry, const char* theRefFatherEntry,
155 const char* theIOR, const char* theName,
156 const char* thePersistentRef, const char* theComment,
157 CORBA::Boolean theCreateNew = true);
159 std::string CreateAttributes(_PTR(Study) theStudyDocument,
160 const char* theFatherEntry, const char* theRefFatherEntry,
161 const char* theIOR, const char* theName,
162 const char* thePersistentRef, const char* theComment,
163 CORBA::Boolean theCreateNew = true);
165 std::string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
166 const char* theComment, int IsAllLevels = true);
168 SALOMEDS::SObject_var GetSObject(_PTR(SObject));
169 _PTR(SObject) GetClientSObject(SALOMEDS::SObject_var, _PTR(Study));
171 SALOMEDS::Study_var GetDSStudy(_PTR(Study));
173 void RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
174 bool theIsAttrOnly = true,
175 bool theDestroySubObjects = false);
176 void RemoveFromStudy(_PTR(SObject) theSObject,
177 bool theIsAttrOnly = true,
178 bool theDestroySubObjects = false);