1 // Copyright (C) 2010-2014 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File : PARAVIS_Gen_i.hh
20 // Author : Vitaly Smetannikov
23 #ifndef __PARAVIS_GEN_I_H__
24 #define __PARAVIS_GEN_I_H__
27 #include "vtkSmartPointer.h"
29 #include "SALOMEconfig.h"
30 #include CORBA_SERVER_HEADER(PARAVIS_Gen)
31 #include CORBA_SERVER_HEADER(SALOMEDS)
32 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
34 #include "SALOME_NamingService.hxx"
35 #include "SALOME_LifeCycleCORBA.hxx"
37 #include "SALOME_Component_i.hxx"
38 #include "SALOME_NamingService.hxx"
40 #include "vtkSmartPointer.h"
45 class SalomeApp_Application;
49 #define PVSTATEID 15555
54 const char* checkNullStr(const char* theStr);
57 * Base implementation for all container objects for Paravis serevrmanager API classes
59 class PARAVIS_Base_i : public virtual POA_PARAVIS::PARAVIS_Base
66 virtual ~PARAVIS_Base_i();
68 //! Initialises internal pointer on existing Paraview class instance
69 virtual void Init(::vtkObjectBase* base);
71 virtual ::vtkObjectBase* GetNew() { return NULL; }
73 //! Returns pointer on internal Paraview class instance
74 virtual ::vtkObjectBase* getVTKObject()
75 { if (mySmartPointer == NULL)
76 mySmartPointer = GetNew();
77 return mySmartPointer.GetPointer();
80 //! The same as previous in static context
81 static ::vtkObjectBase* getVTKObject(PARAVIS_Base_ptr theBase);
83 //! Compares two container objects comparing of their internal pointers
84 virtual CORBA::Boolean IsSame(PARAVIS_Base_ptr theOther);
88 //! Pointer on wrapped class
89 vtkSmartPointer< ::vtkObjectBase> mySmartPointer;
92 //----------------------------------------------------------------------------
93 class PARAVIS_Gen_i : public virtual POA_PARAVIS::PARAVIS_Gen,
94 public virtual ::Engines_Component_i
97 PARAVIS_Gen_i(const PARAVIS::PARAVIS_Gen_i &);
101 PARAVIS_Gen_i(CORBA::ORB_ptr theORB,
102 PortableServer::POA_ptr thePOA,
103 SALOME_NamingService* theNamingService,
107 virtual ~PARAVIS_Gen_i();
109 //! Returns CORBA ID for the current instance
110 virtual char* GetIOR();
112 //! Import file to PARAVIS module by its name.
113 virtual void ImportFile(const char* theFileName);
115 //! Execute a PARAVIS script on Session
116 virtual void ExecuteScript(const char* script);
118 //! Returns Trace string. If Trace is not activated then empty string is returned
119 virtual char* GetTrace();
121 //! Save trace sting to a disk file.
122 virtual void SaveTrace(const char* theFileName);
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);
130 //! inherited methods from SALOMEDS::Driver
131 virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
132 const char* theURL, bool isMultiFile);
134 //! inherited methods from SALOMEDS::Driver
135 virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
136 const char* theURL, bool isMultiFile);
138 //! inherited methods from SALOMEDS::Driver
139 virtual bool Load(SALOMEDS::SComponent_ptr, const SALOMEDS::TMPFile &,
140 const char* theURL, bool isMultiFile);
142 //! inherited methods from SALOMEDS::Driver
143 virtual bool LoadASCII(SALOMEDS::SComponent_ptr, const SALOMEDS::TMPFile &,
144 const char* theURL, bool isMultiFile);
146 //! inherited methods from SALOMEDS::Driver
147 virtual void Close(SALOMEDS::SComponent_ptr IORSComponent);
149 //! inherited methods from SALOMEDS::Driver
150 virtual char* ComponentDataType();
152 //! inherited methods from SALOMEDS::Driver
153 virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString,
154 CORBA::Boolean isMultiFile, CORBA::Boolean isASCII);
156 //! inherited methods from SALOMEDS::Driver
157 virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID,
158 CORBA::Boolean isMultiFile, CORBA::Boolean isASCII);
160 //! inherited methods from SALOMEDS::Driver. Alwais returns false for this module
161 virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR);
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);
169 //! inherited methods from SALOMEDS::Driver. Alwais returns false for this module
170 virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
172 //! inherited methods from SALOMEDS::Driver. Does nothing
173 virtual SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
175 //! inherited methods from SALOMEDS::Driver. Does nothing
176 virtual CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
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);
182 //! inherited methods from Engines::EngineComponent. Returns module version.
183 virtual char* getVersion();
185 #ifdef PARAVIS_WITH_FULL_CORBA
186 //! Implementation of PARAVIS_Gen interface
187 virtual PARAVIS::string_array* GetClassesList();
189 //! Implementation of PARAVIS_Gen interface
190 virtual PARAVIS_Base_ptr CreateClass(const char* theClassName);
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);
200 //! Implementation of PARAVIS_Gen interface
201 virtual void ActivateModule();
203 virtual void SetCurrentStudy(SALOMEDS::Study_ptr theStudy);
205 virtual SALOMEDS::Study_ptr GetCurrentStudy();
207 //! Returns current ORB
208 static CORBA::ORB_var GetORB() { return myOrb;}
210 //! Returns current POA
211 static PortableServer::POA_var GetPOA() { return myPoa;}
213 //! Returns current implementation instance
214 static PARAVIS_Gen_i* GetParavisGenImpl() { return myParavisGenImpl;}
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;
225 SALOMEDS::Study_var myStudyDocument;
226 static SalomeApp_Application* mySalomeApp;