]> SALOME platform Git repositories - modules/visu.git/blob - src/ENGINE/VISU_Engine_i.cc
Salome HOME
2d0f66ad2a4cdd5fe770b9e29db33fcb1af18c47
[modules/visu.git] / src / ENGINE / VISU_Engine_i.cc
1 //  Copyright (C) 2007-2008  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::Component_var aComponent = session->GetComponent("libVISUEngineImpl.so");
83 #else
84     Engines::Component_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     return myVisuGen->ImportTables(theFileName);
170   }
171
172
173   CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
174                                                const char* theFileName)
175   {
176     return myVisuGen->ExportTableToFile(theTable, theFileName);
177   }
178
179
180   Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
181     return myVisuGen->ImportFile(theFileName);
182   }
183
184
185   Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
186     return myVisuGen->CreateResult(theFileName);
187   }
188
189
190   Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
191     return myVisuGen->CopyAndImportFile(theFileName);
192   }
193
194
195   Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
196     return myVisuGen->ImportMed(theMedSObject);
197   }
198
199
200   Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){
201     return myVisuGen->ImportMedField(theField);
202   }
203
204
205   Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, 
206                                     const char* theMeshName, 
207                                     VISU::Entity theEntity)
208   {
209     return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
210   }
211
212   Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, 
213                                           const char* theMeshName, 
214                                           VISU::Entity theEntity, 
215                                           const char* theFamilyName)
216   {
217     return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName);
218   }
219
220   Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, 
221                                  const char* theMeshName, 
222                                  const char* theGroupName)
223   {
224     return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName);
225   }
226
227
228   void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult, const char* theMeshName, 
229                                        VISU::Entity theEntity, const char* theNewName)
230   {
231     myVisuGen->RenameEntityInStudy(theResult,theMeshName,theEntity,theNewName);
232   }
233
234   void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName, 
235                                        VISU::Entity theEntity, const char* theFamilyName,
236                                        const char* theNewName)
237   {
238     myVisuGen->RenameFamilyInStudy(theResult,theMeshName,theEntity,theFamilyName,theNewName);
239   }
240
241   void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult, const char* theMeshName, 
242                                       const char* theGroupName, const char* theNewName)
243   {
244     myVisuGen->RenameGroupInStudy(theResult,theMeshName,theGroupName,theNewName);
245   }
246
247
248   ScalarMap_ptr
249   VISU_Gen_i
250   ::ScalarMapOnField(Result_ptr theResult, 
251                      const char* theMeshName, 
252                      VISU::Entity theEntity,
253                      const char* theFieldName, 
254                      CORBA::Long theIteration)
255   {
256     return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
257   }
258
259
260   GaussPoints_ptr 
261   VISU_Gen_i
262   ::GaussPointsOnField(Result_ptr theResult, 
263                        const char* theMeshName, 
264                        VISU::Entity theEntity,
265                        const char* theFieldName, 
266                        CORBA::Long theIteration)
267   {
268     return myVisuGen->GaussPointsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
269   }
270
271
272   DeformedShape_ptr 
273   VISU_Gen_i
274   ::DeformedShapeOnField(Result_ptr theResult, 
275                          const char* theMeshName, 
276                          VISU::Entity theEntity,
277                          const char* theFieldName, 
278                          CORBA::Long theIteration)
279   {
280     return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
281   }
282
283   DeformedShapeAndScalarMap_ptr 
284   VISU_Gen_i
285   ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult, 
286                                     const char* theMeshName, 
287                                     VISU::Entity theEntity,
288                                     const char* theFieldName, 
289                                     CORBA::Long theIteration)
290   {
291     return DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
292   }
293
294   DeformedShapeAndScalarMap_ptr 
295   VISU_Gen_i
296   ::DeformedShapeAndScalarMapOnField(Result_ptr theResult, 
297                                      const char* theMeshName, 
298                                      VISU::Entity theEntity,
299                                      const char* theFieldName, 
300                                      CORBA::Long theIteration)
301   {
302     return myVisuGen->DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
303   }
304
305   Vectors_ptr 
306   VISU_Gen_i
307   ::VectorsOnField(Result_ptr theResult, 
308                    const char* theMeshName, 
309                    VISU::Entity theEntity,
310                    const char* theFieldName, 
311                    CORBA::Long theIteration)
312   {
313     return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
314   }
315
316   IsoSurfaces_ptr 
317   VISU_Gen_i
318   ::IsoSurfacesOnField(Result_ptr theResult, 
319                        const char* theMeshName, 
320                        VISU::Entity theEntity,
321                        const char* theFieldName, 
322                        CORBA::Long theIteration)
323   {
324     return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
325   }
326
327
328   StreamLines_ptr 
329   VISU_Gen_i
330   ::StreamLinesOnField(Result_ptr theResult, 
331                        const char* theMeshName, 
332                        VISU::Entity theEntity,
333                        const char* theFieldName, 
334                        CORBA::Long theIteration)
335   {
336     return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
337   }
338
339
340   CutPlanes_ptr 
341   VISU_Gen_i
342   ::CutPlanesOnField(Result_ptr theResult, 
343                      const char* theMeshName, 
344                      VISU::Entity theEntity,
345                      const char* theFieldName, 
346                      CORBA::Long theIteration)
347   {
348     return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
349   }
350
351
352   CutLines_ptr 
353   VISU_Gen_i
354   ::CutLinesOnField(Result_ptr theResult, 
355                     const char* theMeshName, 
356                     VISU::Entity theEntity,
357                     const char* theFieldName, 
358                     CORBA::Long theIteration)
359   {
360     return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
361   }
362
363
364   CutSegment_ptr 
365   VISU_Gen_i
366   ::CutSegmentOnField(Result_ptr theResult, 
367                       const char* theMeshName, 
368                       VISU::Entity theEntity,
369                       const char* theFieldName, 
370                       CORBA::Long theIteration)
371   {
372     return myVisuGen->CutSegmentOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
373   }
374
375
376   Plot3D_ptr 
377   VISU_Gen_i
378   ::Plot3DOnField(Result_ptr theResult, 
379                   const char* theMeshName, 
380                   VISU::Entity theEntity,
381                   const char* theFieldName, 
382                   CORBA::Long theIteration)
383   {
384     return myVisuGen->Plot3DOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
385   }
386
387   Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
388     return myVisuGen->CreateTable(theTableEntry);
389   }
390
391
392   Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable, 
393                                     CORBA::Long theHRow, 
394                                     CORBA::Long theVRow)
395   {
396     return myVisuGen->CreateCurve(theTable,theHRow,theVRow);
397   }
398
399   Curve_ptr VISU_Gen_i::CreateCurveWithZ(Table_ptr theTable, 
400                                     CORBA::Long theHRow,
401                                     CORBA::Long theVRow,
402                                     CORBA::Long theZRow)
403   {
404     return myVisuGen->CreateCurveWithZ(theTable,theHRow,theVRow,theZRow);
405   }
406
407
408   Container_ptr VISU_Gen_i::CreateContainer(){
409     return myVisuGen->CreateContainer();
410   }
411
412
413   Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){
414     return myVisuGen->CreateAnimation(theView3D);
415   }
416
417
418   Evolution_ptr VISU_Gen_i::CreateEvolution(XYPlot_ptr theXYPlot){
419     return myVisuGen->CreateEvolution(theXYPlot);
420   }
421
422
423   void VISU_Gen_i::DeleteResult(Result_ptr theResult){
424     myVisuGen->DeleteResult(theResult);
425   }
426
427
428   void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d){
429     myVisuGen->DeletePrs3d(thePrs3d);
430   }
431
432
433   void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
434     myVisuGen->Close(theComponent);
435   }
436
437
438   char* VISU_Gen_i::ComponentDataType(){
439     return CORBA::string_dup("VISU");
440   }
441
442
443   CORBA::Boolean VISU_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) {
444     return myVisuGen->CanPublishInStudy(theIOR);
445   }
446
447
448   SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
449                                                    SALOMEDS::SObject_ptr theSObject,
450                                                    CORBA::Object_ptr theObject,
451                                                    const char* theName) 
452     throw (SALOME::SALOME_Exception) 
453   {
454     return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName);
455   }
456     
457
458   CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
459     return myVisuGen->CanCopy(theObject);
460   }
461   
462
463   SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
464     return myVisuGen->CopyFrom(theObject, theObjectID);
465   }
466   
467
468   CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
469     return myVisuGen->CanPaste(theComponentName, theObjectID);
470   }
471   
472
473   SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
474                                               CORBA::Long theObjectID,
475                                               SALOMEDS::SObject_ptr theObject) 
476   {
477     return myVisuGen->PasteInto(theStream,theObjectID,theObject);
478   }
479   Engines::TMPFile* VISU_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
480                                            CORBA::Boolean theIsPublished,
481                                            CORBA::Boolean& theIsValidScript)
482   {
483     return myVisuGen->DumpPython(theStudy, theIsPublished, theIsValidScript);
484   }     
485
486   VISU::ColoredPrs3dCache_ptr
487   VISU_Gen_i::
488   GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
489   {
490     return myVisuGen->GetColoredPrs3dCache(theStudy);
491   }
492
493
494
495   CORBA::Long VISU_Gen_i::CreateClippingPlane(CORBA::Double X,CORBA::Double  Y, CORBA::Double Z, 
496                                               CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ, 
497                                               CORBA::Boolean isAuto, const char* name)
498   {
499     return myVisuGen->CreateClippingPlane(X, Y, Z, dX, dY, dZ, isAuto, name);
500   }
501   
502
503   void VISU_Gen_i::EditClippingPlane(CORBA::Long id, CORBA::Double X,CORBA::Double  Y, CORBA::Double Z, 
504                                               CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ, 
505                                               CORBA::Boolean isAuto, const char* name)
506   {
507     myVisuGen->EditClippingPlane(id, X, Y, Z, dX, dY, dZ, isAuto, name);
508   }
509   
510   /* Returns clipping plane by its Id */
511   VISU::ClippingPlane* VISU_Gen_i::GetClippingPlane(CORBA::Long id)
512   {
513     return myVisuGen->GetClippingPlane(id);
514   }
515   
516   /* Deletes clipping plane by its Id */
517   CORBA::Boolean VISU_Gen_i::DeleteClippingPlane(CORBA::Long id)
518   {
519     return myVisuGen->DeleteClippingPlane(id);
520   }
521   
522   /* Applyes a clipping plane with Id to presentation thePrs */
523   CORBA::Boolean VISU_Gen_i::ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
524   {
525     return myVisuGen->ApplyClippingPlane(thePrs, id);
526   }
527   
528   CORBA::Boolean VISU_Gen_i::DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
529   {
530     return myVisuGen->DetachClippingPlane(thePrs, id);
531   }
532   
533   /* Get number of clipping planes */
534   CORBA::Long VISU_Gen_i::GetClippingPlanesNb()
535   {
536     return myVisuGen->GetClippingPlanesNb();
537   }
538
539   CORBA::Boolean VISU_Gen_i::VTK2MED( const VISU::string_array& theVTKFiles,
540                                       const char* theMEDFile,
541                                       const char* theMeshName,
542                                       const VISU::double_array& theTStamps )
543   {
544     return myVisuGen->VTK2MED(theVTKFiles, theMEDFile, theMeshName, theTStamps);
545   }   
546
547 };