Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / ENGINE / VISU_Engine_i.cc
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
19
20 #include "VISU_Engine_i.hh"
21 #include "utilities.h"
22
23 #include CORBA_SERVER_HEADER(SALOME_Session)
24 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
25
26 #include "SALOME_NamingService.hxx"
27 #include "Utils_ExceptHandlers.hxx"
28
29 using namespace std;
30
31 #ifdef _DEBUG_
32 static int MYDEBUG = 1;
33 #else
34 static int MYDEBUG = 0;
35 #endif
36
37 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
38
39 extern "C" {
40   PortableServer::ObjectId * 
41   VISUEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId,
42                      const char *instanceName, const char *interfaceName) 
43   {
44     if(MYDEBUG) MESSAGE("VisuEngine_factory : "<<interfaceName);
45     VISU::VISU_Gen_i * pVISU_Gen = new VISU::VISU_Gen_i(orb, poa, contId, instanceName, interfaceName);
46     return pVISU_Gen->getId() ;
47   }
48 }
49
50 namespace VISU{
51   //===========================================================================
52   VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr orb,
53                          PortableServer::POA_ptr poa,
54                          PortableServer::ObjectId * contId, 
55                          const char *instanceName, 
56                          const char *interfaceName) :
57     Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
58   {
59     _thisObj = this ;
60     _id = _poa->activate_object(_thisObj);
61     SALOME_NamingService aNamingService(orb);
62     CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session");
63     SALOME::Session_var aSession = SALOME::Session::_narrow(anObject);
64     //aSession->GetInterface(); 
65     Engines::Component_var aComponent = aSession->GetComponent("libVISUEngineImpl.so");
66     myVisuGen = VISU::VISU_Gen::_narrow(aComponent);
67   } 
68
69   VISU_Gen_i::~VISU_Gen_i(){
70     if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
71   }
72
73   VISU::VISUType VISU_Gen_i::GetType() {
74         return myVisuGen->GetType();
75   };
76
77   //===========================================================================
78   bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
79                         const SALOMEDS::TMPFile & theStream,
80                         const char* theURL,
81                         bool isMultiFile)
82   {
83     return myVisuGen->Load(theComponent,theStream,theURL,isMultiFile);
84   }
85
86   bool VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
87                              const SALOMEDS::TMPFile & theStream,
88                              const char* theURL,
89                              bool isMultiFile) 
90   {
91     return Load(theComponent, theStream, theURL, isMultiFile);
92   }
93
94   char* VISU_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
95                                            const char* aLocalPersistentID,
96                                            CORBA::Boolean isMultiFile,
97                                            CORBA::Boolean isASCII) 
98   {
99     return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
100   }
101
102
103   //===========================================================================
104   SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
105                                       const char* theURL,
106                                       bool isMultiFile)
107   {
108     return myVisuGen->Save(theComponent,theURL,isMultiFile);
109   }
110
111   SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
112                                            const char* theURL,
113                                            bool isMultiFile) 
114   {
115     return myVisuGen->Save(theComponent,theURL,isMultiFile);
116   }
117
118
119   char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
120                                            const char* IORString,
121                                            CORBA::Boolean isMultiFile,
122                                            CORBA::Boolean isASCII) 
123   {
124     return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
125   }
126
127
128   char* VISU_Gen_i::GetID(){
129     return myVisuGen->GetID();
130   }
131
132
133   void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
134     myVisuGen->SetCurrentStudy(theStudy);
135   }
136
137
138   SALOMEDS::Study_ptr VISU_Gen_i::GetCurrentStudy(){
139     return myVisuGen->GetCurrentStudy();
140   }
141
142
143   ViewManager_ptr VISU_Gen_i::GetViewManager(){
144     return myVisuGen->GetViewManager();
145   }
146
147
148   SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){
149     return myVisuGen->ImportTables(theFileName);
150   }
151
152
153   CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
154                                                const char* theFileName)
155   {
156     return myVisuGen->ExportTableToFile(theTable, theFileName);
157   }
158
159
160   Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
161     return myVisuGen->ImportFile(theFileName);
162   }
163
164
165   Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
166     return myVisuGen->CreateResult(theFileName);
167   }
168
169
170   Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
171     return myVisuGen->CopyAndImportFile(theFileName);
172   }
173
174
175   Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
176     return myVisuGen->ImportMed(theMedSObject);
177   }
178
179
180   Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){
181     return myVisuGen->ImportMedField(theField);
182   }
183
184
185   Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, 
186                                     const char* theMeshName, 
187                                     VISU::Entity theEntity)
188   {
189     return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
190   }
191
192   
193   Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, 
194                                           const char* theMeshName, 
195                                           VISU::Entity theEntity, 
196                                           const char* theFamilyName)
197   {
198     return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName);
199   }
200
201
202   Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, 
203                                  const char* theMeshName, 
204                                  const char* theGroupName)
205   {
206     return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName);
207   }
208
209
210   ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult, 
211                                              const char* theMeshName, 
212                                              VISU::Entity theEntity, 
213                                              const char* theFieldName, 
214                                              CORBA::Double theIteration)
215   {
216     return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
217   }
218
219
220   GaussPoints_ptr VISU_Gen_i::GaussPointsOnField(Result_ptr theResult, 
221                                                  const char* theMeshName, 
222                                                  VISU::Entity theEntity, 
223                                                  const char* theFieldName, 
224                                                  CORBA::Double theIteration)
225   {
226     return myVisuGen->GaussPointsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
227   }
228
229
230   DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult, 
231                                                      const char* theMeshName, 
232                                                      VISU::Entity theEntity, 
233                                                      const char* theFieldName, 
234                                                      CORBA::Double theIteration)
235   {
236     return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
237   }
238
239   ScalarMapOnDeformedShape_ptr VISU_Gen_i::ScalarMapOnDeformedShapeOnField(Result_ptr theResult, 
240                                                                            const char* theMeshName, 
241                                                                            VISU::Entity theEntity, 
242                                                                            const char* theFieldName, 
243                                                                            CORBA::Double theIteration)
244   {
245     return myVisuGen->ScalarMapOnDeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
246   }
247
248   Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult, 
249                                          const char* theMeshName, 
250                                          VISU::Entity theEntity, 
251                                          const char* theFieldName, 
252                                          CORBA::Double theIteration)
253   {
254     return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
255   }
256
257   IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult, 
258                                                  const char* theMeshName, 
259                                                  VISU::Entity theEntity, 
260                                                  const char* theFieldName, 
261                                                  CORBA::Double theIteration)
262   {
263     return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
264   }
265
266
267   StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult, 
268                                                  const char* theMeshName, 
269                                                  VISU::Entity theEntity, 
270                                                  const char* theFieldName, 
271                                                  CORBA::Double theIteration)
272   {
273     return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
274   }
275
276
277   CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult, 
278                                              const char* theMeshName, 
279                                              VISU::Entity theEntity, 
280                                              const char* theFieldName, 
281                                              CORBA::Double theIteration)
282   {
283     return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
284   }
285
286
287   CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult, 
288                                            const char* theMeshName, 
289                                            VISU::Entity theEntity, 
290                                            const char* theFieldName, 
291                                            CORBA::Double theIteration)
292   {
293     return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
294   }
295
296
297   Plot3D_ptr VISU_Gen_i::Plot3DOnField(Result_ptr theResult, 
298                                        const char* theMeshName, 
299                                        VISU::Entity theEntity, 
300                                        const char* theFieldName, 
301                                        CORBA::Double theIteration)
302   {
303     return myVisuGen->Plot3DOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
304   }
305
306
307   Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
308     return myVisuGen->CreateTable(theTableEntry);
309   }
310
311
312   Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable, 
313                                     CORBA::Long theHRow, 
314                                     CORBA::Long theVRow)
315   {
316     return myVisuGen->CreateCurve(theTable,theHRow,theVRow);
317   }
318
319
320   Container_ptr VISU_Gen_i::CreateContainer(){
321     return myVisuGen->CreateContainer();
322   }
323
324
325   Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){
326     return myVisuGen->CreateAnimation(theView3D);
327   }
328
329
330   void VISU_Gen_i::DeleteResult(Result_ptr theResult){
331     myVisuGen->DeleteResult(theResult);
332   }
333
334
335   void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d){
336     myVisuGen->DeletePrs3d(thePrs3d);
337   }
338
339
340   void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
341     myVisuGen->Close(theComponent);
342   }
343
344
345   char* VISU_Gen_i::ComponentDataType(){
346     return CORBA::string_dup("VISU");
347   }
348
349
350   CORBA::Boolean VISU_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) {
351     return myVisuGen->CanPublishInStudy(theIOR);
352   }
353
354
355   SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
356                                                    SALOMEDS::SObject_ptr theSObject,
357                                                    CORBA::Object_ptr theObject,
358                                                    const char* theName) 
359     throw (SALOME::SALOME_Exception) 
360   {
361     return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName);
362   }
363     
364
365   CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
366     return myVisuGen->CanCopy(theObject);
367   }
368   
369
370   SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
371     return myVisuGen->CopyFrom(theObject, theObjectID);
372   }
373   
374
375   CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
376     return myVisuGen->CanPaste(theComponentName, theObjectID);
377   }
378   
379
380   SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
381                                               CORBA::Long theObjectID,
382                                               SALOMEDS::SObject_ptr theObject) 
383   {
384     return myVisuGen->PasteInto(theStream,theObjectID,theObject);
385   }
386   Engines::TMPFile* VISU_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
387                                            CORBA::Boolean theIsPublished,
388                                            CORBA::Boolean& theIsValidScript)
389   {
390     return myVisuGen->DumpPython(theStudy, theIsPublished, theIsValidScript);
391   }     
392
393 };