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