1 // Copyright (C) 2007-2012 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
23 #include "VISU_Engine_i.hh"
24 #include "utilities.h"
26 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
28 #include "SALOME_NamingService.hxx"
29 #include "Utils_ExceptHandlers.hxx"
34 static int MYDEBUG = 1;
36 static int MYDEBUG = 0;
40 #if defined VISU_ENGINE_EXPORTS || defined VISUEngine_EXPORTS
41 #define VISU_ENGINE_EXPORT __declspec(dllexport)
43 #define VISU_ENGINE_EXPORT __declspec(dllimport)
46 #define VISU_ENGINE_EXPORT
49 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
53 PortableServer::ObjectId *
54 VISUEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId,
55 const char *instanceName, const char *interfaceName)
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))
65 VISU::VISU_Gen_i * pVISU_Gen = new VISU::VISU_Gen_i(aSession, orb, poa, contId, instanceName, interfaceName);
66 return pVISU_Gen->getId() ;
71 //===========================================================================
72 VISU_Gen_i::VISU_Gen_i(SALOME::Session_ptr session,
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)
81 _id = _poa->activate_object(_thisObj);
83 Engines::EngineComponent_var aComponent = session->GetComponent("libVISUEngineImpl.so");
85 Engines::EngineComponent_var aComponent = session->GetComponent("VISUEngineImpl.dll");
87 myVisuGen = VISU::VISU_Gen::_narrow(aComponent);
90 VISU_Gen_i::~VISU_Gen_i(){
91 if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
94 VISU::VISUType VISU_Gen_i::GetType() {
95 return myVisuGen->GetType();
98 //===========================================================================
99 bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
100 const SALOMEDS::TMPFile & theStream,
104 return myVisuGen->Load(theComponent,theStream,theURL,isMultiFile);
107 bool VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
108 const SALOMEDS::TMPFile & theStream,
112 return Load(theComponent, theStream, theURL, isMultiFile);
115 char* VISU_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
116 const char* aLocalPersistentID,
117 CORBA::Boolean isMultiFile,
118 CORBA::Boolean isASCII)
120 return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII);
124 //===========================================================================
125 SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
129 return myVisuGen->Save(theComponent,theURL,isMultiFile);
132 SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
136 return myVisuGen->Save(theComponent,theURL,isMultiFile);
140 char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
141 const char* IORString,
142 CORBA::Boolean isMultiFile,
143 CORBA::Boolean isASCII)
145 return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII);
149 char* VISU_Gen_i::GetID(){
150 return myVisuGen->GetID();
154 void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){
155 myVisuGen->SetCurrentStudy(theStudy);
159 SALOMEDS::Study_ptr VISU_Gen_i::GetCurrentStudy(){
160 return myVisuGen->GetCurrentStudy();
164 ViewManager_ptr VISU_Gen_i::GetViewManager(){
165 return myVisuGen->GetViewManager();
169 SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName,
170 bool theFirstStrAsTitle)
172 return myVisuGen->ImportTables(theFileName,theFirstStrAsTitle);
176 CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
177 const char* theFileName)
179 return myVisuGen->ExportTableToFile(theTable, theFileName);
183 Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
184 return myVisuGen->ImportFile(theFileName);
188 Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
189 return myVisuGen->CreateResult(theFileName);
193 Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
194 return myVisuGen->CopyAndImportFile(theFileName);
198 Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
199 return myVisuGen->ImportMed(theMedSObject);
203 Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){
204 return myVisuGen->ImportMedField(theField);
208 Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
209 const char* theMeshName,
210 VISU::Entity theEntity)
212 return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
215 Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult,
216 const char* theMeshName,
217 VISU::Entity theEntity,
218 const char* theFamilyName)
220 return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName);
223 Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult,
224 const char* theMeshName,
225 const char* theGroupName)
227 return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName);
231 void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult, const char* theMeshName,
232 VISU::Entity theEntity, const char* theNewName)
234 myVisuGen->RenameEntityInStudy(theResult,theMeshName,theEntity,theNewName);
237 void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName,
238 VISU::Entity theEntity, const char* theFamilyName,
239 const char* theNewName)
241 myVisuGen->RenameFamilyInStudy(theResult,theMeshName,theEntity,theFamilyName,theNewName);
244 void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult, const char* theMeshName,
245 const char* theGroupName, const char* theNewName)
247 myVisuGen->RenameGroupInStudy(theResult,theMeshName,theGroupName,theNewName);
253 ::ScalarMapOnField(Result_ptr theResult,
254 const char* theMeshName,
255 VISU::Entity theEntity,
256 const char* theFieldName,
257 CORBA::Long theIteration)
259 return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
265 ::GaussPointsOnField(Result_ptr theResult,
266 const char* theMeshName,
267 VISU::Entity theEntity,
268 const char* theFieldName,
269 CORBA::Long theIteration)
271 return myVisuGen->GaussPointsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
277 ::DeformedShapeOnField(Result_ptr theResult,
278 const char* theMeshName,
279 VISU::Entity theEntity,
280 const char* theFieldName,
281 CORBA::Long theIteration)
283 return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
286 DeformedShapeAndScalarMap_ptr
288 ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
289 const char* theMeshName,
290 VISU::Entity theEntity,
291 const char* theFieldName,
292 CORBA::Long theIteration)
294 return DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
297 DeformedShapeAndScalarMap_ptr
299 ::DeformedShapeAndScalarMapOnField(Result_ptr theResult,
300 const char* theMeshName,
301 VISU::Entity theEntity,
302 const char* theFieldName,
303 CORBA::Long theIteration)
305 return myVisuGen->DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
310 ::VectorsOnField(Result_ptr theResult,
311 const char* theMeshName,
312 VISU::Entity theEntity,
313 const char* theFieldName,
314 CORBA::Long theIteration)
316 return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
321 ::IsoSurfacesOnField(Result_ptr theResult,
322 const char* theMeshName,
323 VISU::Entity theEntity,
324 const char* theFieldName,
325 CORBA::Long theIteration)
327 return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
333 ::StreamLinesOnField(Result_ptr theResult,
334 const char* theMeshName,
335 VISU::Entity theEntity,
336 const char* theFieldName,
337 CORBA::Long theIteration)
339 return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
345 ::CutPlanesOnField(Result_ptr theResult,
346 const char* theMeshName,
347 VISU::Entity theEntity,
348 const char* theFieldName,
349 CORBA::Long theIteration)
351 return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
357 ::CutLinesOnField(Result_ptr theResult,
358 const char* theMeshName,
359 VISU::Entity theEntity,
360 const char* theFieldName,
361 CORBA::Long theIteration)
363 return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
369 ::CutSegmentOnField(Result_ptr theResult,
370 const char* theMeshName,
371 VISU::Entity theEntity,
372 const char* theFieldName,
373 CORBA::Long theIteration)
375 return myVisuGen->CutSegmentOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
381 ::Plot3DOnField(Result_ptr theResult,
382 const char* theMeshName,
383 VISU::Entity theEntity,
384 const char* theFieldName,
385 CORBA::Long theIteration)
387 return myVisuGen->Plot3DOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
390 Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
391 return myVisuGen->CreateTable(theTableEntry);
395 Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable,
399 return myVisuGen->CreateCurve(theTable,theHRow,theVRow);
402 Curve_ptr VISU_Gen_i::CreateCurveWithZ(Table_ptr theTable,
407 return myVisuGen->CreateCurveWithZ(theTable,theHRow,theVRow,theZRow);
410 Curve_ptr VISU_Gen_i::CreateCurveWithZExt(Table_ptr theTable,
414 CORBA::Boolean theIsV2)
416 return myVisuGen->CreateCurveWithZExt(theTable,theHRow,theVRow,theZRow,theIsV2);
419 Container_ptr VISU_Gen_i::CreateContainer(){
420 return myVisuGen->CreateContainer();
424 Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){
425 return myVisuGen->CreateAnimation(theView3D);
429 Evolution_ptr VISU_Gen_i::CreateEvolution(XYPlot_ptr theXYPlot){
430 return myVisuGen->CreateEvolution(theXYPlot);
434 void VISU_Gen_i::DeleteResult(Result_ptr theResult){
435 myVisuGen->DeleteResult(theResult);
439 void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d){
440 myVisuGen->DeletePrs3d(thePrs3d);
444 void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
445 myVisuGen->Close(theComponent);
449 char* VISU_Gen_i::ComponentDataType(){
450 return CORBA::string_dup("VISU");
454 CORBA::Boolean VISU_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) {
455 return myVisuGen->CanPublishInStudy(theIOR);
459 SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
460 SALOMEDS::SObject_ptr theSObject,
461 CORBA::Object_ptr theObject,
463 throw (SALOME::SALOME_Exception)
465 return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName);
469 CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
470 return myVisuGen->CanCopy(theObject);
474 SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
475 return myVisuGen->CopyFrom(theObject, theObjectID);
479 CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
480 return myVisuGen->CanPaste(theComponentName, theObjectID);
484 SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
485 CORBA::Long theObjectID,
486 SALOMEDS::SObject_ptr theObject)
488 return myVisuGen->PasteInto(theStream,theObjectID,theObject);
490 Engines::TMPFile* VISU_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
491 CORBA::Boolean theIsPublished,
492 CORBA::Boolean theIsMultiFile,
493 CORBA::Boolean& theIsValidScript)
495 return myVisuGen->DumpPython(theStudy, theIsPublished, theIsMultiFile, theIsValidScript);
498 VISU::ColoredPrs3dCache_ptr
500 GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
502 return myVisuGen->GetColoredPrs3dCache(theStudy);
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)
511 return myVisuGen->CreateClippingPlane(X, Y, Z, dX, dY, dZ, isAuto, name);
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)
519 myVisuGen->EditClippingPlane(id, X, Y, Z, dX, dY, dZ, isAuto, name);
522 /* Returns clipping plane by its Id */
523 VISU::ClippingPlane* VISU_Gen_i::GetClippingPlane(CORBA::Long id)
525 return myVisuGen->GetClippingPlane(id);
528 /* Deletes clipping plane by its Id */
529 CORBA::Boolean VISU_Gen_i::DeleteClippingPlane(CORBA::Long id)
531 return myVisuGen->DeleteClippingPlane(id);
534 /* Applyes a clipping plane with Id to presentation thePrs */
535 CORBA::Boolean VISU_Gen_i::ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
537 return myVisuGen->ApplyClippingPlane(thePrs, id);
540 CORBA::Boolean VISU_Gen_i::DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
542 return myVisuGen->DetachClippingPlane(thePrs, id);
545 /* Get number of clipping planes */
546 CORBA::Long VISU_Gen_i::GetClippingPlanesNb()
548 return myVisuGen->GetClippingPlanesNb();
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 )
556 return myVisuGen->VTK2MED(theVTKFiles, theMEDFile, theMeshName, theTStamps);
559 /* Load texture from file */
560 CORBA::Long VISU_Gen_i::LoadTexture(const char* theTextureFile)
562 return myVisuGen->LoadTexture(theTextureFile);
565 /* Version information */
566 char* VISU_Gen_i::getVersion()
568 return myVisuGen->getVersion();