Salome HOME
Debug visu.py; add visu_split_views.py as example of view parameters management
[modules/visu.git] / src / VISU_I / VISUConfig.hh
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //  File   : VISUConfig.hh
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #ifndef __VISU_CONFIG_H__
28 #define __VISU_CONFIG_H__
29
30 // standard C++ headers
31 #include <stdio.h>
32 #include <iostream>
33
34 #include <map>
35 #include <string>
36
37 #include <qstring.h>
38 #include <qthread.h>
39 #include <qfileinfo.h>
40 #include <qapplication.h>
41
42 // IDL headers
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"
52
53 #include <SALOMEDSClient_SObject.hxx>
54 #include <SALOMEDSClient_Study.hxx>
55
56 #include <stdexcept>
57 #include <sstream>
58
59 class SUIT_Session;
60 class SUIT_ResourceMgr;
61
62
63 namespace VISU{
64
65   SUIT_Session *GetSession();
66   SUIT_ResourceMgr *GetResourceMgr();
67
68   //===========================================================================
69
70   class VISU_Gen_i;
71
72   class Base_i : public virtual POA_VISU::Base,
73                  public virtual PortableServer::RefCountServantBase
74   {
75   public:
76     Base_i();
77     virtual ~Base_i();
78     virtual char* GetID();
79     virtual VISU::VISUType GetType() = 0;
80
81   protected:
82     std::string myID;
83
84   protected:
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;
91
92   public:
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;}
98   };
99
100
101   //===========================================================================
102   class Mutex{
103     QMutex* myMutex;
104     int isQAppLocked;
105   public:
106     Mutex(QMutex* theMutex);
107     ~Mutex();
108   };
109
110
111   //===========================================================================
112   class Storable : public virtual Base_i {
113   protected:
114     virtual void ToStream(std::ostringstream& theStr) = 0;
115   public:
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);
130   };
131
132   //===========================================================================
133   class RemovableObject_i : public virtual POA_VISU::RemovableObject,
134                             public virtual Storable
135   {
136   public:
137     virtual void RemoveFromStudy() = 0;
138   };
139
140   //===========================================================================
141   const CORBA::Boolean IsMultifile();
142   QString GenerateName(const std::string& theFmt, int theId);
143
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);
147
148   _PTR(SComponent) ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
149   SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
150
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);
156
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);
162
163   std::string FindEntryWithComment(SALOMEDS::Study_ptr theStudyDocument, const char* theStartEntry,
164                                    const char* theComment, int IsAllLevels = true);
165
166   SALOMEDS::SObject_var GetSObject( _PTR(SObject) );
167   _PTR(SObject) GetClientSObject( SALOMEDS::SObject_var, _PTR(Study) );
168   SALOMEDS::Study_var GetDSStudy( _PTR(Study) );
169 }
170
171 #endif