Salome HOME
Merge from BR_PARAVIS_DEV 29Dec09
[modules/paravis.git] / src / PVGUI / PARAVIS_Gen_i.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 //  File   : PARAVIS_Gen_i.hh
23 //  Author : Vitaly Smetannikov
24 //  Module : PARAVIS
25 //
26 #ifndef __PARAVIS_GEN_I_H__
27 #define __PARAVIS_GEN_I_H__
28
29 #include "PV_I.h"
30 #include "vtkSmartPointer.h"
31
32 #include "SALOMEconfig.h"
33 #include CORBA_SERVER_HEADER(PARAVIS_Gen)
34 #include CORBA_SERVER_HEADER(SALOMEDS)
35 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
36
37 #include "SALOME_NamingService.hxx"
38 #include "SALOME_LifeCycleCORBA.hxx"
39
40 #include "SALOME_Component_i.hxx"
41 #include "SALOME_NamingService.hxx"
42
43 #include "vtkSmartPointer.h"
44
45 // QT Includes
46 #include <QMutex>
47
48 class SalomeApp_Application;
49 class PVGUI_Module;
50 class vtkObjectBase;
51
52 namespace PARAVIS
53 {
54
55   /*!
56    * Base implementation for all container objects for Paravis serevrmanager API classes
57    */
58   class PARAVIS_Base_i : public virtual POA_PARAVIS::PARAVIS_Base
59   {
60   public:
61     //! Constructor
62     PARAVIS_Base_i() {};
63
64     //! Destructor
65     virtual ~PARAVIS_Base_i();
66
67     //! Initialises internal pointer on existing Paraview class instance
68     virtual void Init(::vtkObjectBase* base);
69
70     //! Returns pointer on internal Paraview class instance
71     virtual ::vtkObjectBase* getVTKObject() { return mySmartPointer.GetPointer(); }
72
73     //! The same as previous in static context
74     static ::vtkObjectBase* getVTKObject(PARAVIS_Base_ptr theBase);
75
76     //! Compares two container objects comparing of their internal pointers
77     virtual CORBA::Boolean IsSame(PARAVIS_Base_ptr theOther);
78
79   protected:
80
81     //! Pointer on wrapped class
82     vtkSmartPointer< ::vtkObjectBase> mySmartPointer;
83   };
84
85   //----------------------------------------------------------------------------
86   class PARAVIS_Gen_i : public virtual POA_PARAVIS::PARAVIS_Gen,
87                      public virtual ::Engines_Component_i
88   {
89     //! Copy constructor
90     PARAVIS_Gen_i(const PARAVIS::PARAVIS_Gen_i &);
91   public:
92     
93     //! Constructor
94     PARAVIS_Gen_i(CORBA::ORB_ptr theORB,
95                   PortableServer::POA_ptr thePOA,
96                   SALOME_NamingService* theNamingService, 
97                   QMutex* theMutex);
98     
99     //! Destructor
100     virtual ~PARAVIS_Gen_i();
101     
102     //! Returns CORBA ID for the current instance
103     virtual char* GetIOR();
104
105     //! Import file to PARAVIS module by its name. 
106     virtual void ImportFile(const char* theFileName);
107     
108     //! Returns Trace string. If Trace is not activated then empty string is returned
109     virtual char* GetTrace();
110
111     //! Save trace sting to a disk file.
112     virtual void SaveTrace(const char* theFileName);
113
114     //! inherited methods from Engines::Component
115     virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
116                                          CORBA::Boolean theIsPublished,
117                                          CORBA::Boolean& theIsValidScript);
118
119     //! inherited methods from SALOMEDS::Driver
120     virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, 
121                                     const char* theURL, bool isMultiFile);
122     
123     //! inherited methods from SALOMEDS::Driver
124     virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
125                                          const char* theURL, bool isMultiFile);
126     
127     //! inherited methods from SALOMEDS::Driver
128     virtual bool Load(SALOMEDS::SComponent_ptr,  const SALOMEDS::TMPFile &,
129                       const char* theURL, bool isMultiFile);
130
131     //! inherited methods from SALOMEDS::Driver
132     virtual bool LoadASCII(SALOMEDS::SComponent_ptr, const SALOMEDS::TMPFile &,
133                            const char* theURL, bool isMultiFile);
134     
135     //! inherited methods from SALOMEDS::Driver
136     virtual void Close(SALOMEDS::SComponent_ptr IORSComponent);
137
138     //! inherited methods from SALOMEDS::Driver
139     virtual char* ComponentDataType();
140
141     //! inherited methods from SALOMEDS::Driver
142     virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString,
143                                          CORBA::Boolean isMultiFile, CORBA::Boolean isASCII);
144
145     //! inherited methods from SALOMEDS::Driver
146     virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID,
147                                          CORBA::Boolean isMultiFile, CORBA::Boolean isASCII);
148
149     //! inherited methods from SALOMEDS::Driver. Alwais returns false for this module
150     virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR);
151
152     //! inherited methods from SALOMEDS::Driver. Does nothing
153     virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
154                                                  SALOMEDS::SObject_ptr theSObject, 
155                                                  CORBA::Object_ptr theObject,
156                                                  const char* theName) throw (SALOME::SALOME_Exception);
157
158     //! inherited methods from SALOMEDS::Driver. Alwais returns false for this module
159     virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
160
161     //! inherited methods from SALOMEDS::Driver. Does nothing
162     virtual SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
163
164     //! inherited methods from SALOMEDS::Driver. Does nothing
165     virtual CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
166
167     //! inherited methods from SALOMEDS::Driver. Does nothing
168     virtual SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
169                                             CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject);
170
171     //! Implementation of PARAVIS_Gen interface
172     virtual PARAVIS::string_array* GetClassesList();
173
174     //! Implementation of PARAVIS_Gen interface
175     virtual PARAVIS_Base_ptr CreateClass(const char* theClassName);
176
177     //! Implementation of PARAVIS_Gen interface
178     virtual void GetConnectionParameters(CORBA::Long& theId, 
179                                          CORBA::String_out theDHost, CORBA::Long& theDPort,
180                                          CORBA::String_out theRHost, CORBA::Long& theRPort,
181                                          CORBA::Long& theReversed);
182
183
184     //! Implementation of PARAVIS_Gen interface
185     virtual void ActivateModule();
186
187     //! Returns current ORB
188     static CORBA::ORB_var GetORB() { return myOrb;}
189
190     //! Returns current POA
191     static PortableServer::POA_var GetPOA() { return myPoa;}
192
193     //! Returns current implementation instance
194     static PARAVIS_Gen_i* GetParavisGenImpl() { return myParavisGenImpl;}
195
196   private:
197     static CORBA::ORB_var          myOrb;
198     static PortableServer::POA_var myPoa;
199     static PARAVIS_Gen_i*          myParavisGenImpl;
200     static SALOME_LifeCycleCORBA*  myEnginesLifeCycle;
201     static SALOME_NamingService*   myNamingService;
202     static QMutex*                 myMutex;
203
204     std::string         myIOR;
205     SALOMEDS::Study_var myStudyDocument;
206     static SalomeApp_Application* mySalomeApp;
207
208   };
209
210 };
211 #endif