1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "VISU_Engine_i.hh"
23 #include "utilities.h"
25 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
27 #include "SALOME_NamingService.hxx"
28 #include "Utils_ExceptHandlers.hxx"
33 static int MYDEBUG = 1;
35 static int MYDEBUG = 0;
39 #if defined VISU_ENGINE_EXPORTS || defined VISUEngine_EXPORTS
40 #define VISU_ENGINE_EXPORT __declspec(dllexport)
42 #define VISU_ENGINE_EXPORT __declspec(dllimport)
45 #define VISU_ENGINE_EXPORT
48 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
52 PortableServer::ObjectId *
53 VISUEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId,
54 const char *instanceName, const char *interfaceName)
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))
64 VISU::VISU_Gen_i * pVISU_Gen = new VISU::VISU_Gen_i(aSession, orb, poa, contId, instanceName, interfaceName);
65 return pVISU_Gen->getId() ;
70 //===========================================================================
71 VISU_Gen_i::VISU_Gen_i(SALOME::Session_ptr session,
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)
80 _id = _poa->activate_object(_thisObj);
82 Engines::Component_var aComponent = session->GetComponent("libVISUEngineImpl.so");
84 Engines::Component_var aComponent = session->GetComponent("VISUEngineImpl.dll");
86 myVisuGen = VISU::VISU_Gen::_narrow(aComponent);
89 VISU_Gen_i::~VISU_Gen_i(){
90 if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
93 VISU::VISUType VISU_Gen_i::GetType() {
94 return myVisuGen->GetType();
97 //===========================================================================
98 bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
99 const SALOMEDS::TMPFile & theStream,
103 return myVisuGen->Load(theComponent,theStream,theURL,isMultiFile);
106 bool VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
107 const SALOMEDS::TMPFile & theStream,
111 return Load(theComponent, theStream, theURL, isMultiFile);
114 char* VISU_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
115 const char* aLocalPersistentID,
116 CORBA::Boolean isMultiFile,
117 CORBA::Boolean isASCII)
119 return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
123 //===========================================================================
124 SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
128 return myVisuGen->Save(theComponent,theURL,isMultiFile);
131 SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
135 return myVisuGen->Save(theComponent,theURL,isMultiFile);
139 char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
140 const char* IORString,
141 CORBA::Boolean isMultiFile,
142 CORBA::Boolean isASCII)
144 return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
148 char* VISU_Gen_i::GetID(){
149 return myVisuGen->GetID();
153 void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
154 myVisuGen->SetCurrentStudy(theStudy);
158 SALOMEDS::Study_ptr VISU_Gen_i::GetCurrentStudy(){
159 return myVisuGen->GetCurrentStudy();
163 ViewManager_ptr VISU_Gen_i::GetViewManager(){
164 return myVisuGen->GetViewManager();
168 SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){
169 return myVisuGen->ImportTables(theFileName);
173 CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
174 const char* theFileName)
176 return myVisuGen->ExportTableToFile(theTable, theFileName);
180 Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
181 return myVisuGen->ImportFile(theFileName);
185 Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
186 return myVisuGen->CreateResult(theFileName);
190 Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
191 return myVisuGen->CopyAndImportFile(theFileName);
195 Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
196 return myVisuGen->ImportMed(theMedSObject);
200 Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){
201 return myVisuGen->ImportMedField(theField);
205 Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
206 const char* theMeshName,
207 VISU::Entity theEntity)
209 return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
212 Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult,
213 const char* theMeshName,
214 VISU::Entity theEntity,
215 const char* theFamilyName)
217 return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName);
220 Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult,
221 const char* theMeshName,
222 const char* theGroupName)
224 return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName);
228 void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult, const char* theMeshName,
229 VISU::Entity theEntity, const char* theNewName)
231 myVisuGen->RenameEntityInStudy(theResult,theMeshName,theEntity,theNewName);
234 void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName,
235 VISU::Entity theEntity, const char* theFamilyName,
236 const char* theNewName)
238 myVisuGen->RenameFamilyInStudy(theResult,theMeshName,theEntity,theFamilyName,theNewName);
241 void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult, const char* theMeshName,
242 const char* theGroupName, const char* theNewName)
244 myVisuGen->RenameGroupInStudy(theResult,theMeshName,theGroupName,theNewName);
250 ::ScalarMapOnField(Result_ptr theResult,
251 const char* theMeshName,
252 VISU::Entity theEntity,
253 const char* theFieldName,
254 CORBA::Long theIteration)
256 return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
262 ::GaussPointsOnField(Result_ptr theResult,
263 const char* theMeshName,
264 VISU::Entity theEntity,
265 const char* theFieldName,
266 CORBA::Long theIteration)
268 return myVisuGen->GaussPointsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
274 ::DeformedShapeOnField(Result_ptr theResult,
275 const char* theMeshName,
276 VISU::Entity theEntity,
277 const char* theFieldName,
278 CORBA::Long theIteration)
280 return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
283 DeformedShapeAndScalarMap_ptr
285 ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
286 const char* theMeshName,
287 VISU::Entity theEntity,
288 const char* theFieldName,
289 CORBA::Long theIteration)
291 return DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
294 DeformedShapeAndScalarMap_ptr
296 ::DeformedShapeAndScalarMapOnField(Result_ptr theResult,
297 const char* theMeshName,
298 VISU::Entity theEntity,
299 const char* theFieldName,
300 CORBA::Long theIteration)
302 return myVisuGen->DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
307 ::VectorsOnField(Result_ptr theResult,
308 const char* theMeshName,
309 VISU::Entity theEntity,
310 const char* theFieldName,
311 CORBA::Long theIteration)
313 return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
318 ::IsoSurfacesOnField(Result_ptr theResult,
319 const char* theMeshName,
320 VISU::Entity theEntity,
321 const char* theFieldName,
322 CORBA::Long theIteration)
324 return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
330 ::StreamLinesOnField(Result_ptr theResult,
331 const char* theMeshName,
332 VISU::Entity theEntity,
333 const char* theFieldName,
334 CORBA::Long theIteration)
336 return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
342 ::CutPlanesOnField(Result_ptr theResult,
343 const char* theMeshName,
344 VISU::Entity theEntity,
345 const char* theFieldName,
346 CORBA::Long theIteration)
348 return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
354 ::CutLinesOnField(Result_ptr theResult,
355 const char* theMeshName,
356 VISU::Entity theEntity,
357 const char* theFieldName,
358 CORBA::Long theIteration)
360 return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
366 ::Plot3DOnField(Result_ptr theResult,
367 const char* theMeshName,
368 VISU::Entity theEntity,
369 const char* theFieldName,
370 CORBA::Long theIteration)
372 return myVisuGen->Plot3DOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
375 Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
376 return myVisuGen->CreateTable(theTableEntry);
380 Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable,
384 return myVisuGen->CreateCurve(theTable,theHRow,theVRow);
387 Curve_ptr VISU_Gen_i::CreateCurveWithZ(Table_ptr theTable,
392 return myVisuGen->CreateCurveWithZ(theTable,theHRow,theVRow,theZRow);
396 Container_ptr VISU_Gen_i::CreateContainer(){
397 return myVisuGen->CreateContainer();
401 Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){
402 return myVisuGen->CreateAnimation(theView3D);
406 void VISU_Gen_i::DeleteResult(Result_ptr theResult){
407 myVisuGen->DeleteResult(theResult);
411 void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d){
412 myVisuGen->DeletePrs3d(thePrs3d);
416 void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
417 myVisuGen->Close(theComponent);
421 char* VISU_Gen_i::ComponentDataType(){
422 return CORBA::string_dup("VISU");
426 CORBA::Boolean VISU_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) {
427 return myVisuGen->CanPublishInStudy(theIOR);
431 SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
432 SALOMEDS::SObject_ptr theSObject,
433 CORBA::Object_ptr theObject,
435 throw (SALOME::SALOME_Exception)
437 return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName);
441 CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
442 return myVisuGen->CanCopy(theObject);
446 SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
447 return myVisuGen->CopyFrom(theObject, theObjectID);
451 CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
452 return myVisuGen->CanPaste(theComponentName, theObjectID);
456 SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
457 CORBA::Long theObjectID,
458 SALOMEDS::SObject_ptr theObject)
460 return myVisuGen->PasteInto(theStream,theObjectID,theObject);
462 Engines::TMPFile* VISU_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
463 CORBA::Boolean theIsPublished,
464 CORBA::Boolean& theIsValidScript)
466 return myVisuGen->DumpPython(theStudy, theIsPublished, theIsValidScript);
469 VISU::ColoredPrs3dCache_ptr
471 GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
473 return myVisuGen->GetColoredPrs3dCache(theStudy);
478 CORBA::Long VISU_Gen_i::CreateClippingPlane(CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
479 CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
480 CORBA::Boolean isAuto, const char* name)
482 return myVisuGen->CreateClippingPlane(X, Y, Z, dX, dY, dZ, isAuto, name);
486 void VISU_Gen_i::EditClippingPlane(CORBA::Long id, CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
487 CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
488 CORBA::Boolean isAuto, const char* name)
490 myVisuGen->EditClippingPlane(id, X, Y, Z, dX, dY, dZ, isAuto, name);
493 /* Returns clipping plane by its Id */
494 VISU::ClippingPlane* VISU_Gen_i::GetClippingPlane(CORBA::Long id)
496 return myVisuGen->GetClippingPlane(id);
499 /* Deletes clipping plane by its Id */
500 CORBA::Boolean VISU_Gen_i::DeleteClippingPlane(CORBA::Long id)
502 return myVisuGen->DeleteClippingPlane(id);
505 /* Applyes a clipping plane with Id to presentation thePrs */
506 CORBA::Boolean VISU_Gen_i::ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
508 return myVisuGen->ApplyClippingPlane(thePrs, id);
511 CORBA::Boolean VISU_Gen_i::DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
513 return myVisuGen->DetachClippingPlane(thePrs, id);
516 /* Get number of clipping planes */
517 CORBA::Long VISU_Gen_i::GetClippingPlanesNb()
519 return myVisuGen->GetClippingPlanesNb();
522 CORBA::Boolean VISU_Gen_i::VTK2MED( const VISU::string_array& theVTKFiles,
523 const char* theMEDFile,
524 const char* theMeshName,
525 const VISU::double_array& theTStamps )
527 return myVisuGen->VTK2MED(theVTKFiles, theMEDFile, theMeshName, theTStamps);