1 // Copyright (C) 2007-2010 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::EngineComponent_var aComponent = session->GetComponent("libVISUEngineImpl.so");
84 Engines::EngineComponent_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 bool theFirstStrAsTitle)
171 return myVisuGen->ImportTables(theFileName,theFirstStrAsTitle);
175 CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
176 const char* theFileName)
178 return myVisuGen->ExportTableToFile(theTable, theFileName);
182 Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
183 return myVisuGen->ImportFile(theFileName);
187 Result_ptr VISU_Gen_i::CreateResult(const char* theFileName){
188 return myVisuGen->CreateResult(theFileName);
192 Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
193 return myVisuGen->CopyAndImportFile(theFileName);
197 Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
198 return myVisuGen->ImportMed(theMedSObject);
202 Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){
203 return myVisuGen->ImportMedField(theField);
207 Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
208 const char* theMeshName,
209 VISU::Entity theEntity)
211 return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity);
214 Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult,
215 const char* theMeshName,
216 VISU::Entity theEntity,
217 const char* theFamilyName)
219 return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName);
222 Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult,
223 const char* theMeshName,
224 const char* theGroupName)
226 return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName);
230 void VISU_Gen_i::RenameEntityInStudy(Result_ptr theResult, const char* theMeshName,
231 VISU::Entity theEntity, const char* theNewName)
233 myVisuGen->RenameEntityInStudy(theResult,theMeshName,theEntity,theNewName);
236 void VISU_Gen_i::RenameFamilyInStudy(Result_ptr theResult, const char* theMeshName,
237 VISU::Entity theEntity, const char* theFamilyName,
238 const char* theNewName)
240 myVisuGen->RenameFamilyInStudy(theResult,theMeshName,theEntity,theFamilyName,theNewName);
243 void VISU_Gen_i::RenameGroupInStudy(Result_ptr theResult, const char* theMeshName,
244 const char* theGroupName, const char* theNewName)
246 myVisuGen->RenameGroupInStudy(theResult,theMeshName,theGroupName,theNewName);
252 ::ScalarMapOnField(Result_ptr theResult,
253 const char* theMeshName,
254 VISU::Entity theEntity,
255 const char* theFieldName,
256 CORBA::Long theIteration)
258 return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
264 ::GaussPointsOnField(Result_ptr theResult,
265 const char* theMeshName,
266 VISU::Entity theEntity,
267 const char* theFieldName,
268 CORBA::Long theIteration)
270 return myVisuGen->GaussPointsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
276 ::DeformedShapeOnField(Result_ptr theResult,
277 const char* theMeshName,
278 VISU::Entity theEntity,
279 const char* theFieldName,
280 CORBA::Long theIteration)
282 return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
285 DeformedShapeAndScalarMap_ptr
287 ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
288 const char* theMeshName,
289 VISU::Entity theEntity,
290 const char* theFieldName,
291 CORBA::Long theIteration)
293 return DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
296 DeformedShapeAndScalarMap_ptr
298 ::DeformedShapeAndScalarMapOnField(Result_ptr theResult,
299 const char* theMeshName,
300 VISU::Entity theEntity,
301 const char* theFieldName,
302 CORBA::Long theIteration)
304 return myVisuGen->DeformedShapeAndScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
309 ::VectorsOnField(Result_ptr theResult,
310 const char* theMeshName,
311 VISU::Entity theEntity,
312 const char* theFieldName,
313 CORBA::Long theIteration)
315 return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
320 ::IsoSurfacesOnField(Result_ptr theResult,
321 const char* theMeshName,
322 VISU::Entity theEntity,
323 const char* theFieldName,
324 CORBA::Long theIteration)
326 return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
332 ::StreamLinesOnField(Result_ptr theResult,
333 const char* theMeshName,
334 VISU::Entity theEntity,
335 const char* theFieldName,
336 CORBA::Long theIteration)
338 return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
344 ::CutPlanesOnField(Result_ptr theResult,
345 const char* theMeshName,
346 VISU::Entity theEntity,
347 const char* theFieldName,
348 CORBA::Long theIteration)
350 return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
356 ::CutLinesOnField(Result_ptr theResult,
357 const char* theMeshName,
358 VISU::Entity theEntity,
359 const char* theFieldName,
360 CORBA::Long theIteration)
362 return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
368 ::CutSegmentOnField(Result_ptr theResult,
369 const char* theMeshName,
370 VISU::Entity theEntity,
371 const char* theFieldName,
372 CORBA::Long theIteration)
374 return myVisuGen->CutSegmentOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
380 ::Plot3DOnField(Result_ptr theResult,
381 const char* theMeshName,
382 VISU::Entity theEntity,
383 const char* theFieldName,
384 CORBA::Long theIteration)
386 return myVisuGen->Plot3DOnField(theResult,theMeshName,theEntity,theFieldName,theIteration);
389 Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
390 return myVisuGen->CreateTable(theTableEntry);
394 Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable,
398 return myVisuGen->CreateCurve(theTable,theHRow,theVRow);
401 Curve_ptr VISU_Gen_i::CreateCurveWithZ(Table_ptr theTable,
406 return myVisuGen->CreateCurveWithZ(theTable,theHRow,theVRow,theZRow);
409 Curve_ptr VISU_Gen_i::CreateCurveWithZExt(Table_ptr theTable,
413 CORBA::Boolean theIsV2)
415 return myVisuGen->CreateCurveWithZExt(theTable,theHRow,theVRow,theZRow,theIsV2);
418 Container_ptr VISU_Gen_i::CreateContainer(){
419 return myVisuGen->CreateContainer();
423 Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){
424 return myVisuGen->CreateAnimation(theView3D);
428 Evolution_ptr VISU_Gen_i::CreateEvolution(XYPlot_ptr theXYPlot){
429 return myVisuGen->CreateEvolution(theXYPlot);
433 void VISU_Gen_i::DeleteResult(Result_ptr theResult){
434 myVisuGen->DeleteResult(theResult);
438 void VISU_Gen_i::DeletePrs3d(Prs3d_ptr thePrs3d){
439 myVisuGen->DeletePrs3d(thePrs3d);
443 void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
444 myVisuGen->Close(theComponent);
448 char* VISU_Gen_i::ComponentDataType(){
449 return CORBA::string_dup("VISU");
453 CORBA::Boolean VISU_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) {
454 return myVisuGen->CanPublishInStudy(theIOR);
458 SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
459 SALOMEDS::SObject_ptr theSObject,
460 CORBA::Object_ptr theObject,
462 throw (SALOME::SALOME_Exception)
464 return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName);
468 CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
469 return myVisuGen->CanCopy(theObject);
473 SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
474 return myVisuGen->CopyFrom(theObject, theObjectID);
478 CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
479 return myVisuGen->CanPaste(theComponentName, theObjectID);
483 SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
484 CORBA::Long theObjectID,
485 SALOMEDS::SObject_ptr theObject)
487 return myVisuGen->PasteInto(theStream,theObjectID,theObject);
489 Engines::TMPFile* VISU_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
490 CORBA::Boolean theIsPublished,
491 CORBA::Boolean& theIsValidScript)
493 return myVisuGen->DumpPython(theStudy, theIsPublished, theIsValidScript);
496 VISU::ColoredPrs3dCache_ptr
498 GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
500 return myVisuGen->GetColoredPrs3dCache(theStudy);
505 CORBA::Long VISU_Gen_i::CreateClippingPlane(CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
506 CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
507 CORBA::Boolean isAuto, const char* name)
509 return myVisuGen->CreateClippingPlane(X, Y, Z, dX, dY, dZ, isAuto, name);
513 void VISU_Gen_i::EditClippingPlane(CORBA::Long id, CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
514 CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
515 CORBA::Boolean isAuto, const char* name)
517 myVisuGen->EditClippingPlane(id, X, Y, Z, dX, dY, dZ, isAuto, name);
520 /* Returns clipping plane by its Id */
521 VISU::ClippingPlane* VISU_Gen_i::GetClippingPlane(CORBA::Long id)
523 return myVisuGen->GetClippingPlane(id);
526 /* Deletes clipping plane by its Id */
527 CORBA::Boolean VISU_Gen_i::DeleteClippingPlane(CORBA::Long id)
529 return myVisuGen->DeleteClippingPlane(id);
532 /* Applyes a clipping plane with Id to presentation thePrs */
533 CORBA::Boolean VISU_Gen_i::ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
535 return myVisuGen->ApplyClippingPlane(thePrs, id);
538 CORBA::Boolean VISU_Gen_i::DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
540 return myVisuGen->DetachClippingPlane(thePrs, id);
543 /* Get number of clipping planes */
544 CORBA::Long VISU_Gen_i::GetClippingPlanesNb()
546 return myVisuGen->GetClippingPlanesNb();
549 CORBA::Boolean VISU_Gen_i::VTK2MED( const VISU::string_array& theVTKFiles,
550 const char* theMEDFile,
551 const char* theMeshName,
552 const VISU::double_array& theTStamps )
554 return myVisuGen->VTK2MED(theVTKFiles, theMEDFile, theMeshName, theTStamps);
557 /* Load texture from file */
558 CORBA::Long VISU_Gen_i::LoadTexture(const char* theTextureFile)
560 return myVisuGen->LoadTexture(theTextureFile);