]> SALOME platform Git repositories - modules/visu.git/blob - src/ENGINE/VISU_Engine_i.cc
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
20 #include "VISU_Engine_i.hh"
21 #include "utilities.h"
22
23 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
24
25 #include "SALOME_NamingService.hxx"
26 #include "Utils_ExceptHandlers.hxx"
27
28 using namespace std;
29
30 #ifdef _DEBUG_
31 static int MYDEBUG = 1;
32 #else
33 static int MYDEBUG = 0;
34 #endif
35
36 #ifdef WNT
37 #ifdef VISU_ENGINE_EXPORTS
38 #define VISU_ENGINE_EXPORT __declspec(dllexport)
39 #else
40 #define VISU_ENGINE_EXPORT __declspec(dllimport)
41 #endif
42 #else
43 #define VISU_ENGINE_EXPORT
44 #endif
45
46 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
47
48 extern "C" {
49 VISU_ENGINE_EXPORT
50   PortableServer::ObjectId * 
51   VISUEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId,
52                      const char *instanceName, const char *interfaceName) 
53   {
54     MESSAGE("VisuEngine_factory : "<<interfaceName);
55     // Check session: MZN: 24.11.2006 PAL 13948
56     SALOME_NamingService aNamingService(orb);
57     CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session");
58     SALOME::Session_var aSession = SALOME::Session::_narrow(anObject);
59     if (CORBA::is_nil(aSession))
60       return NULL;
61     
62     VISU::VISU_Gen_i * pVISU_Gen = new VISU::VISU_Gen_i(aSession, orb, poa, contId, instanceName, interfaceName);
63     return pVISU_Gen->getId() ;
64   }
65 }
66
67 namespace VISU{
68   //===========================================================================
69   VISU_Gen_i::VISU_Gen_i(SALOME::Session_ptr session,
70                          CORBA::ORB_ptr orb,
71                          PortableServer::POA_ptr poa,
72                          PortableServer::ObjectId * contId, 
73                          const char *instanceName, 
74                          const char *interfaceName) :
75     Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
76   {
77     _thisObj = this ;
78     _id = _poa->activate_object(_thisObj);
79 #ifndef WIN32
80     Engines::Component_var aComponent = session->GetComponent("libVISUEngineImpl.so");
81 #else
82     Engines::Component_var aComponent = session->GetComponent("VISUEngineImpl.dll");
83 #endif
84     myVisuGen = VISU::VISU_Gen::_narrow(aComponent);
85   } 
86
87   VISU_Gen_i::~VISU_Gen_i(){
88     if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
89   }
90
91   VISU::VISUType VISU_Gen_i::GetType() {
92         return myVisuGen->GetType();
93   };
94
95   //===========================================================================
96   bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
97                         const SALOMEDS::TMPFile & theStream,
98                         const char* theURL,
99                         bool isMultiFile)
100   {
101     return myVisuGen->Load(theComponent,theStream,theURL,isMultiFile);
102   }
103
104   bool VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
105                              const SALOMEDS::TMPFile & theStream,
106                              const char* theURL,
107                              bool isMultiFile) 
108   {
109     return Load(theComponent, theStream, theURL, isMultiFile);
110   }
111
112   char* VISU_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
113                                            const char* aLocalPersistentID,
114                                            CORBA::Boolean isMultiFile,
115                                            CORBA::Boolean isASCII) 
116   {
117     return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
118   }
119
120
121   //===========================================================================
122   SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
123                                       const char* theURL,
124                                       bool isMultiFile)
125   {
126     return myVisuGen->Save(theComponent,theURL,isMultiFile);
127   }
128
129   SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
130                                            const char* theURL,
131                                            bool isMultiFile) 
132   {
133     return myVisuGen->Save(theComponent,theURL,isMultiFile);
134   }
135
136
137   char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
138                                            const char* IORString,
139                                            CORBA::Boolean isMultiFile,
140                                            CORBA::Boolean isASCII) 
141   {
142     return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
143   }
144
145
146   char* VISU_Gen_i::GetID(){
147     return myVisuGen->GetID();
148   }
149
150
151   void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
152     myVisuGen->SetCurrentStudy(theStudy);
153   }
154
155
156   SALOMEDS::Study_ptr VISU_Gen_i::GetCurrentStudy(){
157     return myVisuGen->GetCurrentStudy();
158   }
159
160
161   ViewManager_ptr VISU_Gen_i::GetViewManager(){
162     return myVisuGen->GetViewManager();
163   }
164
165
166   SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){
167     return myVisuGen->ImportTables(theFileName);
168   }
169
170
171   CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
172                                                const char* theFileName)
173   {
174     return myVisuGen->ExportTableToFile(theTable, theFileName);
175   }
176
177
178   Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
179     return myVisuGen->ImportFile(theFileName);
180   }
181
182
183   Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
184     return myVisuGen->CreateResult(theFileName);
185   }
186
187
188   Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
189     return myVisuGen->CopyAndImportFile(theFileName);
190   }
191
192
193   Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
194     return myVisuGen->ImportMed(theMedSObject);
195   }
196
197
198   Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){
199     return myVisuGen->ImportMedField(theField);
200   }
201
202
203   Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, 
204                                     const char* theMeshName, 
205                                     VISU::Entity theEntity)
206   {
207     return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
208   }
209
210   Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, 
211                                           const char* theMeshName, 
212                                           VISU::Entity theEntity, 
213                                           const char* theFamilyName)
214   {
215     return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName);
216   }
217
218   Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, 
219                                  const char* theMeshName, 
220                                  const char* theGroupName)
221   {
222     return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName);
223   }
224
225
226   void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult, const char* theMeshName, 
227                                        VISU::Entity theEntity, const char* theNewName)
228   {
229     myVisuGen->RenameEntityInStudy(theResult,theMeshName,theEntity,theNewName);
230   }
231
232   void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName, 
233                                        VISU::Entity theEntity, const char* theFamilyName,
234                                        const char* theNewName)
235   {
236     myVisuGen->RenameFamilyInStudy(theResult,theMeshName,theEntity,theFamilyName,theNewName);
237   }
238
239   void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult, const char* theMeshName, 
240                                       const char* theGroupName, const char* theNewName)
241   {
242     myVisuGen->RenameGroupInStudy(theResult,theMeshName,theGroupName,theNewName);
243   }
244
245
246   ScalarMap_ptr
247   VISU_Gen_i
248   ::ScalarMapOnField(Result_ptr theResult, 
249                      const char* theMeshName, 
250                      VISU::Entity theEntity,
251                      const char* theFieldName, 
252                      CORBA::Long theIteration)
253   {
254     return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
255   }
256
257
258   GaussPoints_ptr 
259   VISU_Gen_i
260   ::GaussPointsOnField(Result_ptr theResult, 
261                        const char* theMeshName, 
262                        VISU::Entity theEntity,
263                        const char* theFieldName, 
264                        CORBA::Long theIteration)
265   {
266     return myVisuGen->GaussPointsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
267   }
268
269
270   DeformedShape_ptr 
271   VISU_Gen_i
272   ::DeformedShapeOnField(Result_ptr theResult, 
273                          const char* theMeshName, 
274                          VISU::Entity theEntity,
275                          const char* theFieldName, 
276                          CORBA::Long theIteration)
277   {
278     return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
279   }
280
281   ScalarMapOnDeformedShape_ptr 
282   VISU_Gen_i
283   ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult, 
284                                     const char* theMeshName, 
285                                     VISU::Entity theEntity,
286                                     const char* theFieldName, 
287                                     CORBA::Long theIteration)
288   {
289     return myVisuGen->ScalarMapOnDeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
290   }
291
292   Vectors_ptr 
293   VISU_Gen_i
294   ::VectorsOnField(Result_ptr theResult, 
295                    const char* theMeshName, 
296                    VISU::Entity theEntity,
297                    const char* theFieldName, 
298                    CORBA::Long theIteration)
299   {
300     return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
301   }
302
303   IsoSurfaces_ptr 
304   VISU_Gen_i
305   ::IsoSurfacesOnField(Result_ptr theResult, 
306                        const char* theMeshName, 
307                        VISU::Entity theEntity,
308                        const char* theFieldName, 
309                        CORBA::Long theIteration)
310   {
311     return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
312   }
313
314
315   StreamLines_ptr 
316   VISU_Gen_i
317   ::StreamLinesOnField(Result_ptr theResult, 
318                        const char* theMeshName, 
319                        VISU::Entity theEntity,
320                        const char* theFieldName, 
321                        CORBA::Long theIteration)
322   {
323     return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
324   }
325
326
327   CutPlanes_ptr 
328   VISU_Gen_i
329   ::CutPlanesOnField(Result_ptr theResult, 
330                      const char* theMeshName, 
331                      VISU::Entity theEntity,
332                      const char* theFieldName, 
333                      CORBA::Long theIteration)
334   {
335     return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
336   }
337
338
339   CutLines_ptr 
340   VISU_Gen_i
341   ::CutLinesOnField(Result_ptr theResult, 
342                     const char* theMeshName, 
343                     VISU::Entity theEntity,
344                     const char* theFieldName, 
345                     CORBA::Long theIteration)
346   {
347     return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
348   }
349
350
351   Plot3D_ptr 
352   VISU_Gen_i
353   ::Plot3DOnField(Result_ptr theResult, 
354                   const char* theMeshName, 
355                   VISU::Entity theEntity,
356                   const char* theFieldName, 
357                   CORBA::Long theIteration)
358   {
359     return myVisuGen->Plot3DOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
360   }
361
362   Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
363     return myVisuGen->CreateTable(theTableEntry);
364   }
365
366
367   Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable, 
368                                     CORBA::Long theHRow, 
369                                     CORBA::Long theVRow)
370   {
371     return myVisuGen->CreateCurve(theTable,theHRow,theVRow);
372   }
373
374   Curve_ptr VISU_Gen_i::CreateCurveWithZ(Table_ptr theTable, 
375                                     CORBA::Long theHRow,
376                                     CORBA::Long theVRow,
377                                     CORBA::Long theZRow)
378   {
379     return myVisuGen->CreateCurveWithZ(theTable,theHRow,theVRow,theZRow);
380   }
381
382
383   Container_ptr VISU_Gen_i::CreateContainer(){
384     return myVisuGen->CreateContainer();
385   }
386
387
388   Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){
389     return myVisuGen->CreateAnimation(theView3D);
390   }
391
392
393   void VISU_Gen_i::DeleteResult(Result_ptr theResult){
394     myVisuGen->DeleteResult(theResult);
395   }
396
397
398   void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d){
399     myVisuGen->DeletePrs3d(thePrs3d);
400   }
401
402
403   void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
404     myVisuGen->Close(theComponent);
405   }
406
407
408   char* VISU_Gen_i::ComponentDataType(){
409     return CORBA::string_dup("VISU");
410   }
411
412
413   CORBA::Boolean VISU_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) {
414     return myVisuGen->CanPublishInStudy(theIOR);
415   }
416
417
418   SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
419                                                    SALOMEDS::SObject_ptr theSObject,
420                                                    CORBA::Object_ptr theObject,
421                                                    const char* theName) 
422     throw (SALOME::SALOME_Exception) 
423   {
424     return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName);
425   }
426     
427
428   CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
429     return myVisuGen->CanCopy(theObject);
430   }
431   
432
433   SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
434     return myVisuGen->CopyFrom(theObject, theObjectID);
435   }
436   
437
438   CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
439     return myVisuGen->CanPaste(theComponentName, theObjectID);
440   }
441   
442
443   SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
444                                               CORBA::Long theObjectID,
445                                               SALOMEDS::SObject_ptr theObject) 
446   {
447     return myVisuGen->PasteInto(theStream,theObjectID,theObject);
448   }
449   Engines::TMPFile* VISU_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
450                                            CORBA::Boolean theIsPublished,
451                                            CORBA::Boolean& theIsValidScript)
452   {
453     return myVisuGen->DumpPython(theStudy, theIsPublished, theIsValidScript);
454   }     
455
456   VISU::ColoredPrs3dCache_ptr
457   VISU_Gen_i::
458   GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
459   {
460     return myVisuGen->GetColoredPrs3dCache(theStudy);
461   }
462 };