Salome HOME
Merge remote branch 'origin/abn/guifix' into V7_5_BR
[modules/paravis.git] / src / PVGUI / PARAVIS_Gen_i.hh
1 // Copyright (C) 2010-2014  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 //  File   : PARAVIS_Gen_i.hh
20 //  Author : Vitaly Smetannikov
21 //  Module : PARAVIS
22 //
23 #ifndef __PARAVIS_GEN_I_H__
24 #define __PARAVIS_GEN_I_H__
25
26 #include "PV_I.h"
27 #include "vtkSmartPointer.h"
28
29 #include "SALOMEconfig.h"
30 #include CORBA_SERVER_HEADER(PARAVIS_Gen)
31 #include CORBA_SERVER_HEADER(SALOMEDS)
32 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
33
34 #include "SALOME_NamingService.hxx"
35 #include "SALOME_LifeCycleCORBA.hxx"
36
37 #include "SALOME_Component_i.hxx"
38 #include "SALOME_NamingService.hxx"
39
40 #include "vtkSmartPointer.h"
41
42 // QT Includes
43 #include <QMutex>
44
45 class SalomeApp_Application;
46 class PVGUI_Module;
47 class vtkObjectBase;
48
49 //#define PVSTATEID 15555  // now in PVGUI_Tools.h
50
51 namespace PARAVIS
52 {
53
54   const char* checkNullStr(const char* theStr);
55
56   /*!
57    * Base implementation for all container objects for Paravis serevrmanager API classes
58    */
59   class PARAVIS_Base_i : public virtual POA_PARAVIS::PARAVIS_Base
60   {
61   public:
62     //! Constructor
63     PARAVIS_Base_i() {};
64
65     //! Destructor
66     virtual ~PARAVIS_Base_i();
67
68     //! Initialises internal pointer on existing Paraview class instance
69     virtual void Init(::vtkObjectBase* base);
70
71     virtual ::vtkObjectBase* GetNew() { return NULL; }
72
73     //! Returns pointer on internal Paraview class instance
74     virtual ::vtkObjectBase* getVTKObject() 
75     { if (mySmartPointer == NULL)
76         mySmartPointer = GetNew();
77       return mySmartPointer.GetPointer(); 
78     }
79
80     //! The same as previous in static context
81     static ::vtkObjectBase* getVTKObject(PARAVIS_Base_ptr theBase);
82
83     //! Compares two container objects comparing of their internal pointers
84     virtual CORBA::Boolean IsSame(PARAVIS_Base_ptr theOther);
85
86   protected:
87
88     //! Pointer on wrapped class
89     vtkSmartPointer< ::vtkObjectBase> mySmartPointer;
90   };
91
92   //----------------------------------------------------------------------------
93   class PARAVIS_Gen_i : public virtual POA_PARAVIS::PARAVIS_Gen,
94                      public virtual ::Engines_Component_i
95   {
96     //! Copy constructor
97     PARAVIS_Gen_i(const PARAVIS::PARAVIS_Gen_i &);
98   public:
99     
100     //! Constructor
101     PARAVIS_Gen_i(CORBA::ORB_ptr theORB,
102                   PortableServer::POA_ptr thePOA,
103                   SALOME_NamingService* theNamingService, 
104                   QMutex* theMutex);
105     
106     //! Destructor
107     virtual ~PARAVIS_Gen_i();
108     
109     //! Returns CORBA ID for the current instance
110     virtual char* GetIOR();
111
112     //! Import file to PARAVIS module by its name. 
113     virtual void ImportFile(const char* theFileName);
114
115     //! Execute a PARAVIS script on Session
116     virtual void ExecuteScript(const char* script);
117     
118     //! Returns Trace string. If Trace is not activated then empty string is returned
119     virtual char* GetTrace();
120
121     //! Save trace sting to a disk file.
122     virtual void SaveTrace(const char* theFileName);
123
124     //! inherited methods from Engines::Component
125     virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
126                                          CORBA::Boolean theIsPublished,
127                                          CORBA::Boolean theIsMultiFile,
128                                          CORBA::Boolean& theIsValidScript);
129
130     //! inherited methods from SALOMEDS::Driver
131     virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, 
132                                     const char* theURL, bool isMultiFile);
133     
134     //! inherited methods from SALOMEDS::Driver
135     virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
136                                          const char* theURL, bool isMultiFile);
137     
138     //! inherited methods from SALOMEDS::Driver
139     virtual bool Load(SALOMEDS::SComponent_ptr,  const SALOMEDS::TMPFile &,
140                       const char* theURL, bool isMultiFile);
141
142     //! inherited methods from SALOMEDS::Driver
143     virtual bool LoadASCII(SALOMEDS::SComponent_ptr, const SALOMEDS::TMPFile &,
144                            const char* theURL, bool isMultiFile);
145     
146     //! inherited methods from SALOMEDS::Driver
147     virtual void Close(SALOMEDS::SComponent_ptr IORSComponent);
148
149     //! inherited methods from SALOMEDS::Driver
150     virtual char* ComponentDataType();
151
152     //! inherited methods from SALOMEDS::Driver
153     virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString,
154                                          CORBA::Boolean isMultiFile, CORBA::Boolean isASCII);
155
156     //! inherited methods from SALOMEDS::Driver
157     virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID,
158                                          CORBA::Boolean isMultiFile, CORBA::Boolean isASCII);
159
160     //! inherited methods from SALOMEDS::Driver. Alwais returns false for this module
161     virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR);
162
163     //! inherited methods from SALOMEDS::Driver. Does nothing
164     virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
165                                                  SALOMEDS::SObject_ptr theSObject, 
166                                                  CORBA::Object_ptr theObject,
167                                                  const char* theName) throw (SALOME::SALOME_Exception);
168
169     //! inherited methods from SALOMEDS::Driver. Alwais returns false for this module
170     virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
171
172     //! inherited methods from SALOMEDS::Driver. Does nothing
173     virtual SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
174
175     //! inherited methods from SALOMEDS::Driver. Does nothing
176     virtual CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
177
178     //! inherited methods from SALOMEDS::Driver. Does nothing
179     virtual SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
180                                             CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject);
181
182     //! inherited methods from Engines::EngineComponent. Returns module version.
183     virtual char* getVersion();
184
185 #ifdef PARAVIS_WITH_FULL_CORBA
186     //! Implementation of PARAVIS_Gen interface
187     virtual PARAVIS::string_array* GetClassesList();
188
189     //! Implementation of PARAVIS_Gen interface
190     virtual PARAVIS_Base_ptr CreateClass(const char* theClassName);
191 #endif
192
193     //! Implementation of PARAVIS_Gen interface
194     virtual void GetConnectionParameters(CORBA::Long& theId, 
195                                          CORBA::String_out theDHost, CORBA::Long& theDPort,
196                                          CORBA::String_out theRHost, CORBA::Long& theRPort,
197                                          CORBA::Long& theReversed);
198
199
200     //! Implementation of PARAVIS_Gen interface
201     virtual void ActivateModule();
202
203     virtual void SetCurrentStudy(SALOMEDS::Study_ptr theStudy);
204
205     virtual SALOMEDS::Study_ptr GetCurrentStudy();
206
207     //! Returns current ORB
208     static CORBA::ORB_var GetORB() { return myOrb;}
209
210     //! Returns current POA
211     static PortableServer::POA_var GetPOA() { return myPoa;}
212
213     //! Returns current implementation instance
214     static PARAVIS_Gen_i* GetParavisGenImpl() { return myParavisGenImpl;}
215
216   private:
217     static CORBA::ORB_var          myOrb;
218     static PortableServer::POA_var myPoa;
219     static PARAVIS_Gen_i*          myParavisGenImpl;
220     static SALOME_LifeCycleCORBA*  myEnginesLifeCycle;
221     static SALOME_NamingService*   myNamingService;
222     static QMutex*                 myMutex;
223
224     std::string         myIOR;
225     SALOMEDS::Study_var myStudyDocument;
226     static SalomeApp_Application* mySalomeApp;
227
228   };
229
230 };
231 #endif