Salome HOME
c0ccce709ac9025af15ffc0b2daffa6ab7080122
[modules/visu.git] / src / ENGINE / VISU_Engine_i.cc
1 //  Copyright (C) 2007-2010  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 #include "VISU_Engine_i.hh"
23 #include "utilities.h"
24
25 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
26
27 #include "SALOME_NamingService.hxx"
28 #include "Utils_ExceptHandlers.hxx"
29
30 using namespace std;
31
32 #ifdef _DEBUG_
33 static int MYDEBUG = 1;
34 #else
35 static int MYDEBUG = 0;
36 #endif
37
38 #ifdef WNT
39 #if defined VISU_ENGINE_EXPORTS || defined VISUEngine_EXPORTS
40 #define VISU_ENGINE_EXPORT __declspec(dllexport)
41 #else
42 #define VISU_ENGINE_EXPORT __declspec(dllimport)
43 #endif
44 #else
45 #define VISU_ENGINE_EXPORT
46 #endif
47
48 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
49
50 extern "C" {
51 VISU_ENGINE_EXPORT
52   PortableServer::ObjectId *
53   VISUEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId,
54                      const char *instanceName, const char *interfaceName)
55   {
56     MESSAGE("VisuEngine_factory : "<<interfaceName);
57     // Check session: MZN: 24.11.2006 PAL 13948
58     SALOME_NamingService aNamingService(orb);
59     CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session");
60     SALOME::Session_var aSession = SALOME::Session::_narrow(anObject);
61     if (CORBA::is_nil(aSession))
62       return NULL;
63
64     VISU::VISU_Gen_i * pVISU_Gen = new VISU::VISU_Gen_i(aSession, orb, poa, contId, instanceName, interfaceName);
65     return pVISU_Gen->getId() ;
66   }
67 }
68
69 namespace VISU{
70   //===========================================================================
71   VISU_Gen_i::VISU_Gen_i(SALOME::Session_ptr session,
72                          CORBA::ORB_ptr orb,
73                          PortableServer::POA_ptr poa,
74                          PortableServer::ObjectId * contId,
75                          const char *instanceName,
76                          const char *interfaceName) :
77     Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
78   {
79     _thisObj = this ;
80     _id = _poa->activate_object(_thisObj);
81 #ifndef WIN32
82     Engines::EngineComponent_var aComponent = session->GetComponent("libVISUEngineImpl.so");
83 #else
84     Engines::EngineComponent_var aComponent = session->GetComponent("VISUEngineImpl.dll");
85 #endif
86     myVisuGen = VISU::VISU_Gen::_narrow(aComponent);
87   }
88
89   VISU_Gen_i::~VISU_Gen_i(){
90     if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
91   }
92
93   VISU::VISUType VISU_Gen_i::GetType() {
94         return myVisuGen->GetType();
95   };
96
97   //===========================================================================
98   bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
99                         const SALOMEDS::TMPFile & theStream,
100                         const char* theURL,
101                         bool isMultiFile)
102   {
103     return myVisuGen->Load(theComponent,theStream,theURL,isMultiFile);
104   }
105
106   bool VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
107                              const SALOMEDS::TMPFile & theStream,
108                              const char* theURL,
109                              bool isMultiFile)
110   {
111     return Load(theComponent, theStream, theURL, isMultiFile);
112   }
113
114   char* VISU_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
115                                            const char* aLocalPersistentID,
116                                            CORBA::Boolean isMultiFile,
117                                            CORBA::Boolean isASCII)
118   {
119     return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
120   }
121
122
123   //===========================================================================
124   SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
125                                       const char* theURL,
126                                       bool isMultiFile)
127   {
128     return myVisuGen->Save(theComponent,theURL,isMultiFile);
129   }
130
131   SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
132                                            const char* theURL,
133                                            bool isMultiFile)
134   {
135     return myVisuGen->Save(theComponent,theURL,isMultiFile);
136   }
137
138
139   char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
140                                            const char* IORString,
141                                            CORBA::Boolean isMultiFile,
142                                            CORBA::Boolean isASCII)
143   {
144     return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
145   }
146
147
148   char* VISU_Gen_i::GetID(){
149     return myVisuGen->GetID();
150   }
151
152
153   void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
154     myVisuGen->SetCurrentStudy(theStudy);
155   }
156
157
158   SALOMEDS::Study_ptr VISU_Gen_i::GetCurrentStudy(){
159     return myVisuGen->GetCurrentStudy();
160   }
161
162
163   ViewManager_ptr VISU_Gen_i::GetViewManager(){
164     return myVisuGen->GetViewManager();
165   }
166
167
168   SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName,
169                                                  bool theFirstStrAsTitle)
170   {
171     return myVisuGen->ImportTables(theFileName,theFirstStrAsTitle);
172   }
173
174
175   CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
176                                                const char* theFileName)
177   {
178     return myVisuGen->ExportTableToFile(theTable, theFileName);
179   }
180
181
182   Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
183     return myVisuGen->ImportFile(theFileName);
184   }
185
186
187   Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
188     return myVisuGen->CreateResult(theFileName);
189   }
190
191
192   Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
193     return myVisuGen->CopyAndImportFile(theFileName);
194   }
195
196
197   Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
198     return myVisuGen->ImportMed(theMedSObject);
199   }
200
201
202   Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){
203     return myVisuGen->ImportMedField(theField);
204   }
205
206
207   Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
208                                     const char* theMeshName,
209                                     VISU::Entity theEntity)
210   {
211     return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
212   }
213
214   Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult,
215                                           const char* theMeshName,
216                                           VISU::Entity theEntity,
217                                           const char* theFamilyName)
218   {
219     return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName);
220   }
221
222   Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult,
223                                  const char* theMeshName,
224                                  const char* theGroupName)
225   {
226     return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName);
227   }
228
229
230   void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult, const char* theMeshName,
231                                        VISU::Entity theEntity, const char* theNewName)
232   {
233     myVisuGen->RenameEntityInStudy(theResult,theMeshName,theEntity,theNewName);
234   }
235
236   void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName,
237                                        VISU::Entity theEntity, const char* theFamilyName,
238                                        const char* theNewName)
239   {
240     myVisuGen->RenameFamilyInStudy(theResult,theMeshName,theEntity,theFamilyName,theNewName);
241   }
242
243   void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult, const char* theMeshName,
244                                       const char* theGroupName, const char* theNewName)
245   {
246     myVisuGen->RenameGroupInStudy(theResult,theMeshName,theGroupName,theNewName);
247   }
248
249
250   ScalarMap_ptr
251   VISU_Gen_i
252   ::ScalarMapOnField(Result_ptr theResult,
253                      const char* theMeshName,
254                      VISU::Entity theEntity,
255                      const char* theFieldName,
256                      CORBA::Long theIteration)
257   {
258     return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
259   }
260
261
262   GaussPoints_ptr
263   VISU_Gen_i
264   ::GaussPointsOnField(Result_ptr theResult,
265                        const char* theMeshName,
266                        VISU::Entity theEntity,
267                        const char* theFieldName,
268                        CORBA::Long theIteration)
269   {
270     return myVisuGen->GaussPointsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
271   }
272
273
274   DeformedShape_ptr
275   VISU_Gen_i
276   ::DeformedShapeOnField(Result_ptr theResult,
277                          const char* theMeshName,
278                          VISU::Entity theEntity,
279                          const char* theFieldName,
280                          CORBA::Long theIteration)
281   {
282     return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
283   }
284
285   DeformedShapeAndScalarMap_ptr
286   VISU_Gen_i
287   ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
288                                     const char* theMeshName,
289                                     VISU::Entity theEntity,
290                                     const char* theFieldName,
291                                     CORBA::Long theIteration)
292   {
293     return DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
294   }
295
296   DeformedShapeAndScalarMap_ptr
297   VISU_Gen_i
298   ::DeformedShapeAndScalarMapOnField(Result_ptr theResult,
299                                      const char* theMeshName,
300                                      VISU::Entity theEntity,
301                                      const char* theFieldName,
302                                      CORBA::Long theIteration)
303   {
304     return myVisuGen->DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
305   }
306
307   Vectors_ptr
308   VISU_Gen_i
309   ::VectorsOnField(Result_ptr theResult,
310                    const char* theMeshName,
311                    VISU::Entity theEntity,
312                    const char* theFieldName,
313                    CORBA::Long theIteration)
314   {
315     return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
316   }
317
318   IsoSurfaces_ptr
319   VISU_Gen_i
320   ::IsoSurfacesOnField(Result_ptr theResult,
321                        const char* theMeshName,
322                        VISU::Entity theEntity,
323                        const char* theFieldName,
324                        CORBA::Long theIteration)
325   {
326     return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
327   }
328
329
330   StreamLines_ptr
331   VISU_Gen_i
332   ::StreamLinesOnField(Result_ptr theResult,
333                        const char* theMeshName,
334                        VISU::Entity theEntity,
335                        const char* theFieldName,
336                        CORBA::Long theIteration)
337   {
338     return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
339   }
340
341
342   CutPlanes_ptr
343   VISU_Gen_i
344   ::CutPlanesOnField(Result_ptr theResult,
345                      const char* theMeshName,
346                      VISU::Entity theEntity,
347                      const char* theFieldName,
348                      CORBA::Long theIteration)
349   {
350     return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
351   }
352
353
354   CutLines_ptr
355   VISU_Gen_i
356   ::CutLinesOnField(Result_ptr theResult,
357                     const char* theMeshName,
358                     VISU::Entity theEntity,
359                     const char* theFieldName,
360                     CORBA::Long theIteration)
361   {
362     return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
363   }
364
365
366   CutSegment_ptr
367   VISU_Gen_i
368   ::CutSegmentOnField(Result_ptr theResult,
369                       const char* theMeshName,
370                       VISU::Entity theEntity,
371                       const char* theFieldName,
372                       CORBA::Long theIteration)
373   {
374     return myVisuGen->CutSegmentOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
375   }
376
377
378   Plot3D_ptr
379   VISU_Gen_i
380   ::Plot3DOnField(Result_ptr theResult,
381                   const char* theMeshName,
382                   VISU::Entity theEntity,
383                   const char* theFieldName,
384                   CORBA::Long theIteration)
385   {
386     return myVisuGen->Plot3DOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
387   }
388
389   Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
390     return myVisuGen->CreateTable(theTableEntry);
391   }
392
393
394   Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable,
395                                     CORBA::Long theHRow,
396                                     CORBA::Long theVRow)
397   {
398     return myVisuGen->CreateCurve(theTable,theHRow,theVRow);
399   }
400
401   Curve_ptr VISU_Gen_i::CreateCurveWithZ(Table_ptr theTable,
402                                     CORBA::Long theHRow,
403                                     CORBA::Long theVRow,
404                                     CORBA::Long theZRow)
405   {
406     return myVisuGen->CreateCurveWithZ(theTable,theHRow,theVRow,theZRow);
407   }
408
409   Curve_ptr  VISU_Gen_i::CreateCurveWithZExt(Table_ptr theTable,
410                                              CORBA::Long theHRow,
411                                              CORBA::Long theVRow,
412                                              CORBA::Long theZRow,
413                                              CORBA::Boolean theIsV2)
414   {
415     return myVisuGen->CreateCurveWithZExt(theTable,theHRow,theVRow,theZRow,theIsV2);
416   }
417
418   Container_ptr VISU_Gen_i::CreateContainer(){
419     return myVisuGen->CreateContainer();
420   }
421
422
423   Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){
424     return myVisuGen->CreateAnimation(theView3D);
425   }
426
427
428   Evolution_ptr VISU_Gen_i::CreateEvolution(XYPlot_ptr theXYPlot){
429     return myVisuGen->CreateEvolution(theXYPlot);
430   }
431
432
433   void VISU_Gen_i::DeleteResult(Result_ptr theResult){
434     myVisuGen->DeleteResult(theResult);
435   }
436
437
438   void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d){
439     myVisuGen->DeletePrs3d(thePrs3d);
440   }
441
442
443   void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
444     myVisuGen->Close(theComponent);
445   }
446
447
448   char* VISU_Gen_i::ComponentDataType(){
449     return CORBA::string_dup("VISU");
450   }
451
452
453   CORBA::Boolean VISU_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) {
454     return myVisuGen->CanPublishInStudy(theIOR);
455   }
456
457
458   SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
459                                                    SALOMEDS::SObject_ptr theSObject,
460                                                    CORBA::Object_ptr theObject,
461                                                    const char* theName)
462     throw (SALOME::SALOME_Exception)
463   {
464     return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName);
465   }
466
467
468   CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
469     return myVisuGen->CanCopy(theObject);
470   }
471
472
473   SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
474     return myVisuGen->CopyFrom(theObject, theObjectID);
475   }
476
477
478   CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
479     return myVisuGen->CanPaste(theComponentName, theObjectID);
480   }
481
482
483   SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
484                                               CORBA::Long theObjectID,
485                                               SALOMEDS::SObject_ptr theObject)
486   {
487     return myVisuGen->PasteInto(theStream,theObjectID,theObject);
488   }
489   Engines::TMPFile* VISU_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
490                                            CORBA::Boolean theIsPublished,
491                                            CORBA::Boolean theIsMultiFile,
492                                            CORBA::Boolean& theIsValidScript)
493   {
494     return myVisuGen->DumpPython(theStudy, theIsPublished, theIsMultiFile, theIsValidScript);
495   }
496
497   VISU::ColoredPrs3dCache_ptr
498   VISU_Gen_i::
499   GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
500   {
501     return myVisuGen->GetColoredPrs3dCache(theStudy);
502   }
503
504
505
506   CORBA::Long VISU_Gen_i::CreateClippingPlane(CORBA::Double X,CORBA::Double  Y, CORBA::Double Z,
507                                               CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
508                                               CORBA::Boolean isAuto, const char* name)
509   {
510     return myVisuGen->CreateClippingPlane(X, Y, Z, dX, dY, dZ, isAuto, name);
511   }
512
513
514   void VISU_Gen_i::EditClippingPlane(CORBA::Long id, CORBA::Double X,CORBA::Double  Y, CORBA::Double Z,
515                                      CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
516                                      CORBA::Boolean isAuto, const char* name)
517   {
518     myVisuGen->EditClippingPlane(id, X, Y, Z, dX, dY, dZ, isAuto, name);
519   }
520
521   /* Returns clipping plane by its Id */
522   VISU::ClippingPlane* VISU_Gen_i::GetClippingPlane(CORBA::Long id)
523   {
524     return myVisuGen->GetClippingPlane(id);
525   }
526
527   /* Deletes clipping plane by its Id */
528   CORBA::Boolean VISU_Gen_i::DeleteClippingPlane(CORBA::Long id)
529   {
530     return myVisuGen->DeleteClippingPlane(id);
531   }
532
533   /* Applyes a clipping plane with Id to presentation thePrs */
534   CORBA::Boolean VISU_Gen_i::ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
535   {
536     return myVisuGen->ApplyClippingPlane(thePrs, id);
537   }
538
539   CORBA::Boolean VISU_Gen_i::DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
540   {
541     return myVisuGen->DetachClippingPlane(thePrs, id);
542   }
543
544   /* Get number of clipping planes */
545   CORBA::Long VISU_Gen_i::GetClippingPlanesNb()
546   {
547     return myVisuGen->GetClippingPlanesNb();
548   }
549
550   CORBA::Boolean VISU_Gen_i::VTK2MED( const VISU::string_array& theVTKFiles,
551                                       const char* theMEDFile,
552                                       const char* theMeshName,
553                                       const VISU::double_array& theTStamps )
554   {
555     return myVisuGen->VTK2MED(theVTKFiles, theMEDFile, theMeshName, theTStamps);
556   }
557
558   /* Load texture from file */
559   CORBA::Long VISU_Gen_i::LoadTexture(const char* theTextureFile)
560   {
561     return myVisuGen->LoadTexture(theTextureFile);
562   }
563 };