Version: 6.3.1

src/VISU_I/VISUConfig.hh

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  VISU OBJECT : interactive object for VISU entities implementation
00024 //  File   : VISUConfig.hh
00025 //  Author : Alexey PETROV
00026 //  Module : VISU
00027 //
00028 #ifndef __VISU_CONFIG_H__
00029 #define __VISU_CONFIG_H__
00030 
00031 #include "VISU_I.hxx"
00032 
00033 // IDL headers
00034 #include "SALOMEconfig.h"
00035 #include CORBA_SERVER_HEADER(VISU_Gen)
00036 #include CORBA_SERVER_HEADER(MED)
00037 #include CORBA_SERVER_HEADER(SALOMEDS)
00038 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
00039 #include CORBA_SERVER_HEADER(SALOME_Types)
00040 
00041 #include "SALOME_NamingService.hxx"
00042 #include "SALOME_LifeCycleCORBA.hxx"
00043 #include "Utils_CorbaException.hxx"
00044 #include "utilities.h"
00045 
00046 #include "SALOMEDSClient_SObject.hxx"
00047 #include "SALOMEDSClient_Study.hxx"
00048 
00049 // QT headers
00050 #include <QString>
00051 #include <QThread>
00052 #include <QFileInfo>
00053 #include <QApplication>
00054 #include <QMutex>
00055 
00056 // standard C++ headers
00057 #include <stdio.h>
00058 
00059 // STL headers
00060 #include <map>
00061 #include <deque>
00062 #include <string>
00063 #include <sstream>
00064 #include <iostream>
00065 #include <stdexcept>
00066 
00067 class SUIT_Session;
00068 class SUIT_ResourceMgr;
00069 class SalomeApp_Study;
00070 
00071 
00072 namespace VISU
00073 {
00074 
00075   VISU_I_EXPORT SUIT_Session *GetSession();
00076   VISU_I_EXPORT SUIT_ResourceMgr *GetResourceMgr();
00077 
00078   //===========================================================================
00079 
00080   class VISU_Gen_i;
00081 
00082   class VISU_I_EXPORT Base_i : public virtual POA_VISU::Base,
00083                       public virtual PortableServer::RefCountServantBase
00084   {
00085   public:
00086     typedef VISU::Base TInterface;
00087 
00088     Base_i();
00089     virtual ~Base_i();
00090     virtual char* GetID();
00091     virtual VISU::VISUType GetType() = 0;
00092 
00093   protected:
00094     std::string myID;
00095 
00096   protected:
00097     static QMutex* myMutex;
00098     static CORBA::ORB_var myOrb;
00099     static PortableServer::POA_var myPoa;
00100     static SALOME_NamingService* myNamingService;
00101     static VISU_Gen_i* myVisuGenImpl;
00102     static SALOME_LifeCycleCORBA* myEnginesLifeCycle;
00103 
00104   public:
00105     static CORBA::ORB_var GetORB() { return myOrb;}
00106     static PortableServer::POA_var GetPOA() { return myPoa;}
00107     static SALOME_NamingService* GetNS() { return myNamingService;}
00108     static SALOME_LifeCycleCORBA* GetLCC() { return myEnginesLifeCycle;}
00109     static VISU_Gen_i* GetVisuGenImpl() { return myVisuGenImpl;}
00110   };
00111 
00112 
00113   //===========================================================================
00114   class VISU_I_EXPORT Mutex
00115   {
00116     QMutex* myMutex;
00117     int isQAppLocked;
00118   public:
00119     Mutex(QMutex* theMutex);
00120     ~Mutex();
00121   };
00122 
00123 
00124   //===========================================================================
00125   class VISU_I_EXPORT Storable : public virtual Base_i 
00126   {
00127   public:
00128     std::string
00129     ToString();
00130 
00131     virtual
00132     const char* 
00133     GetComment() const = 0;
00134 
00135 
00136     //---------------------------------------------------------------
00137     typedef std::map<std::string, QString> TRestoringMap;
00138 
00139     typedef Storable* (*TStorableEngine)(SALOMEDS::SObject_ptr theSObject,
00140                           const TRestoringMap& theMap,
00141                           const std::string& thePrefix,
00142                           CORBA::Boolean theIsMultiFile);
00143 
00144     typedef std::map<std::string, TStorableEngine> TStorableEngineMap;
00145 
00146     static 
00147     void
00148     RegistryStorableEngine(const std::string& theComment, 
00149                   TStorableEngine theEngine);
00150 
00151     static
00152     Storable* 
00153     Create(SALOMEDS::SObject_ptr theSObject,
00154         const std::string& theLocalPersistentID, 
00155         const std::string& thePrefix,
00156         CORBA::Boolean theIsMultiFile);
00157 
00158 
00159     //---------------------------------------------------------------
00160     static 
00161     VISU::VISUType
00162     Comment2Type(const std::string& theComment);
00163 
00164     static 
00165     VISU::VISUType
00166     RestoringMap2Type(const TRestoringMap& theRestoringMap);
00167 
00168     static 
00169     VISU::VISUType
00170     Stream2Type(const std::string& thePersistentString);
00171 
00172     static 
00173     VISU::VISUType
00174     SObject2Type(const _PTR(SObject)& theSObject);
00175 
00176     static 
00177     std::string
00178     CorrectPersistentString(const std::string& thePersistentString);
00179 
00180     static 
00181     std::string 
00182     FindEntry(SALOMEDS::Study_ptr theStudyDocument, 
00183            const std::string& theStartEntry,
00184            const TRestoringMap& theRestoringMap, 
00185            int IsAllLevels = true);
00186   
00187     static 
00188     QString 
00189     FindValue(const TRestoringMap& theMap, 
00190            const std::string& theArg, 
00191            bool* theIsFind = NULL);
00192 
00193     static 
00194     QString
00195     FindValue(const TRestoringMap& theMap, 
00196            const std::string& theArg, 
00197            const QString& theDefaultValue);
00198 
00199     static
00200     void
00201     StringToMap(const QString& theString, 
00202           TRestoringMap& theMap);
00203 
00204     static
00205     TRestoringMap
00206     GetStorableMap(_PTR(SObject) theSObject);
00207 
00208     static
00209     SALOMEDS::SObject_ptr 
00210     GetResultSO(SALOMEDS::SObject_ptr theSObject);
00211 
00212     static
00213     void
00214     DataToStream(std::ostringstream& theStr, 
00215            const QString& theName, 
00216            const QString& theVal);
00217 
00218     static 
00219     void
00220     DataToStream(std::ostringstream& theStr, 
00221            const QString& theName, 
00222            int theVal);
00223 
00224     static 
00225     void
00226     DataToStream(std::ostringstream& theStr, 
00227            const QString& theName, 
00228            long theVal);
00229 
00230     static
00231     void
00232     DataToStream(std::ostringstream& theStr, 
00233            const QString& theName, 
00234            double theVal);
00235 
00236     //---------------------------------------------------------------
00237     virtual 
00238     CORBA::Boolean 
00239     CanCopy(SALOMEDS::SObject_ptr theObject);
00240 
00241     typedef std::string TFileName;
00242     typedef std::vector<TFileName> TFileNames;
00243 
00244     virtual 
00245     bool 
00246     CopyFrom(SALOMEDS::SObject_ptr theObject, 
00247           CORBA::Long& theObjectID,
00248           const std::string& theTmpDir,
00249           TFileNames& theFileNames);
00250 
00251 
00252     //---------------------------------------------------------------
00253   protected:
00254     virtual 
00255     void 
00256     ToStream(std::ostringstream& theStr) = 0;
00257 
00258   private:
00259     static TStorableEngineMap myStorableEngineMap;
00260   };
00261 
00262   //===========================================================================
00263   VISU_I_EXPORT
00264   QString
00265   GenerateName(const std::string& theFmt, int theId);
00266 
00267   VISU_I_EXPORT 
00268   PortableServer::ServantBase_var 
00269   GetServant(CORBA::Object_ptr theObject);
00270 
00271   VISU_I_EXPORT
00272   CORBA::Object_var
00273   ClientSObjectToObject(_PTR(SObject) theSObject);
00274 
00275   VISU_I_EXPORT
00276   CORBA::Object_var
00277   SObjectToObject(SALOMEDS::SObject_ptr);
00278 
00279   VISU_I_EXPORT
00280   _PTR(SComponent) 
00281   ClientFindOrCreateVisuComponent(_PTR(Study) theStudyDocument);
00282 
00283   VISU_I_EXPORT 
00284   SALOMEDS::SComponent_var 
00285   FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument);
00286 
00287   const char* const NO_ICON = "";
00288   const char* const NO_IOR = "";
00289   const char* const NO_NAME = "";
00290   const char* const NO_PERFSITENT_REF = "";
00291   const char* const NO_COMMENT = "";
00292 
00293   VISU_I_EXPORT
00294   std::string 
00295   CreateAttributes(SALOMEDS::Study_ptr theStudyDocument,
00296              const std::string& theFatherEntry, 
00297              const std::string& theIconName,
00298              const std::string& theIOR, 
00299              const std::string& theName,
00300              const std::string& thePersistentRef, 
00301              const std::string& theComment,
00302              CORBA::Boolean theCreateNew = true);
00303 
00304   VISU_I_EXPORT
00305   std::string 
00306   CreateAttributes(_PTR(Study) theStudyDocument,
00307              const std::string& theFatherEntry, 
00308              const std::string& theIconName,
00309              const std::string& theIOR, 
00310              const std::string& theName,
00311              const std::string& thePersistentRef, 
00312              const std::string& theComment,
00313              CORBA::Boolean theCreateNew = true);
00314 
00315   VISU_I_EXPORT
00316   SALOMEDS::SObject_var
00317   GetSObject(_PTR(SObject));
00318 
00319   VISU_I_EXPORT
00320   _PTR(SObject) 
00321   GetClientSObject(SALOMEDS::SObject_ptr theSObject, 
00322              _PTR(Study) theStudy);
00323 
00324   VISU_I_EXPORT
00325   SALOMEDS::Study_var 
00326   GetDSStudy(_PTR(Study) theStudy);
00327 
00328   VISU_I_EXPORT
00329   SalomeApp_Study* 
00330   GetGUIStudy(SALOMEDS::Study_ptr theStudy);
00331 
00332   VISU_I_EXPORT
00333   _PTR(Study) 
00334   GetStudy(SALOMEDS::Study_ptr theStudy);
00335 
00336   VISU_I_EXPORT
00337   void
00338   RemoveFromStudy(SALOMEDS::SObject_ptr theSObject,
00339             bool theIsAttrOnly = true,
00340             bool theDestroySubObjects = false);
00341   VISU_I_EXPORT
00342   void 
00343   RemoveFromStudy(_PTR(SObject) theSObject,
00344             bool theIsAttrOnly = true,
00345             bool theDestroySubObjects = false);
00346 }
00347 
00348 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS