]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISUConfig.hh
Salome HOME
IPAL21489 Filter by Scalars... does not show visible elements for some presentations.
[modules/visu.git] / src / VISU_I / VISUConfig.hh
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  VISU OBJECT : interactive object for VISU entities implementation
23 //  File   : VISUConfig.hh
24 //  Author : Alexey PETROV
25 //  Module : VISU
26 //
27 #ifndef __VISU_CONFIG_H__
28 #define __VISU_CONFIG_H__
29
30 #include "VISU_I.hxx"
31
32 // IDL headers
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)
38
39 #include "SALOME_NamingService.hxx"
40 #include "SALOME_LifeCycleCORBA.hxx"
41 #include "Utils_CorbaException.hxx"
42 #include "utilities.h"
43
44 #include "SALOMEDSClient_SObject.hxx"
45 #include "SALOMEDSClient_Study.hxx"
46
47 // QT headers
48 #include <QString>
49 #include <QThread>
50 #include <QFileInfo>
51 #include <QApplication>
52 #include <QMutex>
53
54 // standard C++ headers
55 #include <stdio.h>
56
57 // STL headers
58 #include <map>
59 #include <deque>
60 #include <string>
61 #include <sstream>
62 #include <iostream>
63 #include <stdexcept>
64
65 class SUIT_Session;
66 class SUIT_ResourceMgr;
67 class SalomeApp_Study;
68
69
70 namespace VISU
71 {
72
73   VISU_I_EXPORT SUIT_Session *GetSession();
74   VISU_I_EXPORT SUIT_ResourceMgr *GetResourceMgr();
75
76   //===========================================================================
77
78   class VISU_Gen_i;
79
80   class VISU_I_EXPORT Base_i : public virtual POA_VISU::Base,
81                                public virtual PortableServer::RefCountServantBase
82   {
83   public:
84     typedef VISU::Base TInterface;
85
86     Base_i();
87     virtual ~Base_i();
88     virtual char* GetID();
89     virtual VISU::VISUType GetType() = 0;
90
91   protected:
92     std::string myID;
93
94   protected:
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;
101
102   public:
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;}
108   };
109
110
111   //===========================================================================
112   class VISU_I_EXPORT Mutex
113   {
114     QMutex* myMutex;
115     int isQAppLocked;
116   public:
117     Mutex(QMutex* theMutex);
118     ~Mutex();
119   };
120
121
122   //===========================================================================
123   class VISU_I_EXPORT Storable : public virtual Base_i 
124   {
125   public:
126     std::string
127     ToString();
128
129     virtual
130     const char* 
131     GetComment() const = 0;
132
133
134     //---------------------------------------------------------------
135     typedef std::map<std::string, QString> TRestoringMap;
136
137     typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
138                                          const TRestoringMap& theMap,
139                                          const std::string& thePrefix,
140                                          CORBA::Boolean theIsMultiFile);
141
142     typedef std::map<std::string, TStorableEngine> TStorableEngineMap;
143
144     static 
145     void
146     RegistryStorableEngine(const std::string& theComment, 
147                            TStorableEngine theEngine);
148
149     static
150     Storable* 
151     Create(SALOMEDS::SObject_ptr theSObject,
152            const std::string& theLocalPersistentID, 
153            const std::string& thePrefix,
154            CORBA::Boolean theIsMultiFile);
155
156
157     //---------------------------------------------------------------
158     static 
159     VISU::VISUType
160     Comment2Type(const std::string& theComment);
161
162     static 
163     VISU::VISUType
164     RestoringMap2Type(const TRestoringMap& theRestoringMap);
165
166     static 
167     VISU::VISUType
168     Stream2Type(const std::string& thePersistentString);
169
170     static 
171     VISU::VISUType
172     SObject2Type(const _PTR(SObject)& theSObject);
173
174     static 
175     std::string
176     CorrectPersistentString(const std::string& thePersistentString);
177
178     static 
179     std::string 
180     FindEntry(SALOMEDS::Study_ptr theStudyDocument, 
181               const std::string& theStartEntry,
182               const TRestoringMap& theRestoringMap, 
183               int IsAllLevels = true);
184   
185     static 
186     QString 
187     FindValue(const TRestoringMap& theMap, 
188               const std::string& theArg, 
189               bool* theIsFind = NULL);
190
191     static 
192     QString
193     FindValue(const TRestoringMap& theMap, 
194               const std::string& theArg, 
195               const QString& theDefaultValue);
196
197     static
198     void
199     StringToMap(const QString& theString, 
200                 TRestoringMap& theMap);
201
202     static
203     TRestoringMap
204     GetStorableMap(_PTR(SObject) theSObject);
205
206     static
207     SALOMEDS::SObject_ptr 
208     GetResultSO(SALOMEDS::SObject_ptr theSObject);
209
210     static
211     void
212     DataToStream(std::ostringstream& theStr, 
213                  const QString& theName, 
214                  const QString& theVal);
215
216     static 
217     void
218     DataToStream(std::ostringstream& theStr, 
219                  const QString& theName, 
220                  int theVal);
221
222     static 
223     void
224     DataToStream(std::ostringstream& theStr, 
225                  const QString& theName, 
226                  long theVal);
227
228     static
229     void
230     DataToStream(std::ostringstream& theStr, 
231                  const QString& theName, 
232                  double theVal);
233
234     //---------------------------------------------------------------
235     virtual 
236     CORBA::Boolean 
237     CanCopy(SALOMEDS::SObject_ptr theObject);
238
239     typedef std::string TFileName;
240     typedef std::vector<TFileName> TFileNames;
241
242     virtual 
243     bool 
244     CopyFrom(SALOMEDS::SObject_ptr theObject, 
245              CORBA::Long& theObjectID,
246              const std::string& theTmpDir,
247              TFileNames& theFileNames);
248
249
250     //---------------------------------------------------------------
251   protected:
252     virtual 
253     void 
254     ToStream(std::ostringstream& theStr) = 0;
255
256   private:
257     static TStorableEngineMap myStorableEngineMap;
258   };
259
260   //===========================================================================
261   VISU_I_EXPORT
262   QString
263   GenerateName(const std::string& theFmt, int theId);
264
265   VISU_I_EXPORT 
266   PortableServer::ServantBase_var 
267   GetServant(CORBA::Object_ptr theObject);
268
269   VISU_I_EXPORT
270   CORBA::Object_var
271   ClientSObjectToObject(_PTR(SObject) theSObject);
272
273   VISU_I_EXPORT
274   CORBA::Object_var
275   SObjectToObject(SALOMEDS::SObject_ptr);
276
277   VISU_I_EXPORT
278   _PTR(SComponent) 
279   ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
280
281   VISU_I_EXPORT 
282   SALOMEDS::SComponent_var 
283   FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
284
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 = "";
290
291   VISU_I_EXPORT
292   std::string 
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);
301
302   VISU_I_EXPORT
303   std::string 
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);
312
313   VISU_I_EXPORT
314   SALOMEDS::SObject_var
315   GetSObject(_PTR(SObject));
316
317   VISU_I_EXPORT
318   _PTR(SObject) 
319   GetClientSObject(SALOMEDS::SObject_ptr theSObject, 
320                    _PTR(Study) theStudy);
321
322   VISU_I_EXPORT
323   SALOMEDS::Study_var 
324   GetDSStudy(_PTR(Study) theStudy);
325
326   VISU_I_EXPORT
327   SalomeApp_Study* 
328   GetGUIStudy(SALOMEDS::Study_ptr theStudy);
329
330   VISU_I_EXPORT
331   _PTR(Study) 
332   GetStudy(SALOMEDS::Study_ptr theStudy);
333
334   VISU_I_EXPORT
335   void
336   RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
337                   bool theIsAttrOnly = true,
338                   bool theDestroySubObjects = false);
339   VISU_I_EXPORT
340   void 
341   RemoveFromStudy(_PTR(SObject) theSObject,
342                   bool theIsAttrOnly = true,
343                   bool theDestroySubObjects = false);
344 }
345
346 #endif