From: smh Date: Thu, 22 Apr 2004 12:22:55 +0000 (+0000) Subject: Improve loading mechanism of VISU module X-Git-Tag: Merge_300404~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=834379893ceb31d34e3b6543a50347458180d946;p=modules%2Fvisu.git Improve loading mechanism of VISU module --- diff --git a/src/ENGINE/Makefile.in b/src/ENGINE/Makefile.in new file mode 100644 index 00000000..320f6a4b --- /dev/null +++ b/src/ENGINE/Makefile.in @@ -0,0 +1,50 @@ +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : Makefile.in +# Author : Alexey Petrov +# Module : VISU +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets +LIB = libVISUEngine.la +LIB_SRC = VISU_Engine_i.cc + +LIB_MOC = + +LIB_SERVER_IDL = VISU_Gen.idl SALOME_Component.idl \ + SALOME_Exception.idl SALOME_GenericObj.idl \ + SALOME_Session.idl MED.idl +LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl + +# Executables targets +BIN = +BIN_SRC = + +BIN_CLIENT_IDL = +BIN_SERVER_IDL = + +EXPORT_HEADERS = + +# additionnal information to compil and link file +CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS += -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer + +LIBS+= + +# additional file to be cleaned +MOSTLYCLEAN = +CLEAN = +DISTCLEAN = + +@CONCLUDE@ \ No newline at end of file diff --git a/src/ENGINE/VISU_Engine_i.cc b/src/ENGINE/VISU_Engine_i.cc new file mode 100644 index 00000000..fd0c065e --- /dev/null +++ b/src/ENGINE/VISU_Engine_i.cc @@ -0,0 +1,358 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "VISU_Engine_i.hh" +#include "utilities.h" + +#include CORBA_SERVER_HEADER(SALOME_Session) +#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) + +#include "SALOME_NamingService.hxx" +#include "Utils_ExceptHandlers.hxx" + +using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + +UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception); + +extern "C" { + PortableServer::ObjectId * + VISUEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, + const char *instanceName, const char *interfaceName) + { + if(MYDEBUG) MESSAGE("VisuEngine_factory : "<getId() ; + } +} + +namespace VISU{ + //=========================================================================== + VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName) + { + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + SALOME_NamingService aNamingService(orb); + CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session"); + SALOME::Session_var aSession = SALOME::Session::_narrow(anObject); + //aSession->GetInterface(); + Engines::Component_var aComponent = aSession->GetVisuComponent(); + myVisuGen = VISU::VISU_Gen::_narrow(aComponent); + } + + VISU_Gen_i::~VISU_Gen_i(){ + if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i"); + } + + VISU::VISUType VISU_Gen_i::GetType() { + return myVisuGen->GetType(); + }; + + //=========================================================================== + bool VISU_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile & theStream, + const char* theURL, + bool isMultiFile) + { + return myVisuGen->Load(theComponent,theStream,theURL,isMultiFile); + } + + bool VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent, + const SALOMEDS::TMPFile & theStream, + const char* theURL, + bool isMultiFile) + { + return Load(theComponent, theStream, theURL, isMultiFile); + } + + char* VISU_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) + { + return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII); + } + + + //=========================================================================== + SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) + { + return myVisuGen->Save(theComponent,theURL,isMultiFile); + } + + SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile) + { + return myVisuGen->Save(theComponent,theURL,isMultiFile); + } + + + char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII) + { + return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII); + } + + + char* VISU_Gen_i::GetID(){ + return myVisuGen->GetID(); + } + + + void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){ + myVisuGen->SetCurrentStudy(theStudy); + } + + + SALOMEDS::Study_ptr VISU_Gen_i::GetCurrentStudy(){ + return myVisuGen->GetCurrentStudy(); + } + + + ViewManager_ptr VISU_Gen_i::GetViewManager(){ + return myVisuGen->GetViewManager(); + } + + + SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){ + return myVisuGen->ImportTables(theFileName); + } + + + CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable, + const char* theFileName) + { + return myVisuGen->ExportTableToFile(theTable, theFileName); + } + + + Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){ + return myVisuGen->ImportFile(theFileName); + } + + + Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){ + return myVisuGen->CopyAndImportFile(theFileName); + } + + + Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){ + return myVisuGen->ImportMed(theMedSObject); + } + + + Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){ + return myVisuGen->ImportMedField(theField); + } + + + Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity) + { + return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity); + } + + + Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFamilyName) + { + return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName); + } + + + Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, + const char* theMeshName, + const char* theGroupName) + { + return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName); + } + + + ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) + { + return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + + + DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) + { + return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + + + Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) + { + return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + + IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) + { + return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + + + StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) + { + return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + + + CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) + { + return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + + + CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) + { + return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + } + + + Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){ + return myVisuGen->CreateTable(theTableEntry); + } + + + Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable, + CORBA::Long theHRow, + CORBA::Long theVRow) + { + return myVisuGen->CreateCurve(theTable,theHRow,theVRow); + } + + + Container_ptr VISU_Gen_i::CreateContainer(){ + return myVisuGen->CreateContainer(); + } + + + Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){ + return myVisuGen->CreateAnimation(theView3D); + } + + + void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){ + myVisuGen->Close(theComponent); + } + + + char* VISU_Gen_i::ComponentDataType(){ + return CORBA::string_dup("VISU"); + } + + + CORBA::Boolean VISU_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) { + return myVisuGen->CanPublishInStudy(theIOR); + } + + + SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) + throw (SALOME::SALOME_Exception) + { + return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName); + } + + + CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) { + return myVisuGen->CanCopy(theObject); + } + + + SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) { + return myVisuGen->CopyFrom(theObject, theObjectID); + } + + + CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) { + return myVisuGen->CanPaste(theComponentName, theObjectID); + } + + + SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject) + { + return myVisuGen->PasteInto(theStream,theObjectID,theObject); + } + + + /*! SAN & VSR : Test QT_EVENT + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + */ + void VISU_Gen_i::CreateTestView() { + myVisuGen->CreateTestView(); + } + void VISU_Gen_i::ShowTestObject() { + myVisuGen->ShowTestObject(); + } + /*! SAN & VSR : Test QT_EVENT + <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + */ + +}; diff --git a/src/ENGINE/VISU_Engine_i.hh b/src/ENGINE/VISU_Engine_i.hh new file mode 100644 index 00000000..10f96e14 --- /dev/null +++ b/src/ENGINE/VISU_Engine_i.hh @@ -0,0 +1,143 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef __VISU_ENGINE_I_H__ +#define __VISU_ENGINE_I_H__ + +// IDL headers +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(VISU_Gen) +#include CORBA_SERVER_HEADER(MED) +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +#include "SALOME_Component_i.hxx" + +namespace VISU{ + class VISU_Gen_i : public virtual POA_VISU::VISU_Gen, + public virtual ::Engines_Component_i + { + VISU_Gen_var myVisuGen; + VISU_Gen_i(); + VISU_Gen_i(const VISU::VISU_Gen_i &); + public: + VISU_Gen_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + virtual ~VISU_Gen_i(); + + virtual char* GetID(); + virtual VISU::VISUType GetType(); + + virtual void SetCurrentStudy(SALOMEDS::Study_ptr theStudy); + virtual SALOMEDS::Study_ptr GetCurrentStudy(); + + virtual ViewManager_ptr GetViewManager(); + + virtual SALOMEDS::SObject_ptr ImportTables(const char* theFileName); + virtual CORBA::Boolean ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName ); + + //Create Result + virtual Result_ptr ImportFile(const char* theFileName); + virtual Result_ptr CopyAndImportFile(const char* theFileName); + virtual Result_ptr ImportMed(SALOMEDS::SObject_ptr theMedSObject); + virtual Result_ptr ImportMedField(SALOME_MED::FIELD_ptr theField); + + //Create Presentation Of Submeshes + virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity); + virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName, + VISU::Entity theEntity, const char* theFamilyName); + virtual Mesh_ptr GroupMesh(Result_ptr theResult, const char* theMeshName, const char* theGroupName); + + virtual ScalarMap_ptr ScalarMapOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual DeformedShape_ptr DeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual Vectors_ptr VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual IsoSurfaces_ptr IsoSurfacesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual CutPlanes_ptr CutPlanesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual CutLines_ptr CutLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + virtual StreamLines_ptr StreamLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, CORBA::Double theIteration); + //Create Digital Presentation + virtual Table_ptr CreateTable(const char* theTableEntry); + virtual Curve_ptr CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow); + virtual Container_ptr CreateContainer(); + virtual Animation_ptr CreateAnimation(View3D_ptr theView3d); + + // inherited methods from SALOMEDS::Driver + virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); + virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, + const char* theURL, + bool isMultiFile); + virtual bool Load(SALOMEDS::SComponent_ptr, + const SALOMEDS::TMPFile &, + const char* theURL, + bool isMultiFile); + virtual bool LoadASCII(SALOMEDS::SComponent_ptr, + const SALOMEDS::TMPFile &, + const char* theURL, + bool isMultiFile); + + virtual void Close(SALOMEDS::SComponent_ptr IORSComponent); + + virtual char* ComponentDataType(); + + virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, + const char* IORString, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); + virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, + const char* aLocalPersistentID, + CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII); + + virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR); + virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theObject, + const char* theName) throw (SALOME::SALOME_Exception); + + CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); + SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID); + CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); + SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, + CORBA::Long theObjectID, + SALOMEDS::SObject_ptr theObject); + /*! SAN & VSR : Test QT_EVENT + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + */ + virtual void CreateTestView(); + virtual void ShowTestObject(); + /*! SAN & VSR : Test QT_EVENT + <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + */ + }; +}; + + +#endif diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index 3744c066..10727700 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -96,7 +96,7 @@ CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) \ -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS += $(MED2_LIBS) $(HDF5_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeGUI -lSalomeNS \ - -lVisuObject -lVISUEngine -lmed -lVTKViewer -L${KERNEL_ROOT_DIR}/lib/salome + -lVisuObject -lVISUEngineImpl -lmed -lVTKViewer -L${KERNEL_ROOT_DIR}/lib/salome @CONCLUDE@ diff --git a/src/VISU_I/Makefile.in b/src/VISU_I/Makefile.in index abc4a5cb..29cbeaee 100644 --- a/src/VISU_I/Makefile.in +++ b/src/VISU_I/Makefile.in @@ -16,7 +16,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl @COMMENCE@ # Libraries targets -LIB = libVISUEngine.la +LIB = libVISUEngineImpl.la LIB_SRC = VISUConfig.cc VISU_Gen_i.cc VISU_Result_i.cc \ VISU_ViewManager_i.cc VISU_PrsObject_i.cc VISU_Table_i.cc \ VISU_Prs3d_i.cc VISU_Mesh_i.cc VISU_ScalarMap_i.cc \ @@ -28,8 +28,8 @@ LIB_SRC = VISUConfig.cc VISU_Gen_i.cc VISU_Result_i.cc \ LIB_MOC = VISU_TimeAnimation.h LIB_SERVER_IDL = VISU_Gen.idl SALOME_Component.idl \ - SALOME_Exception.idl SALOME_GenericObj.idl \ - SALOME_Session.idl MED.idl + SALOME_Exception.idl SALOME_GenericObj.idl MED.idl + LIB_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl # Executables targets diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index dc533de5..665fb4d5 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -58,57 +58,27 @@ #include #include "Utils_ExceptHandlers.hxx" -/*! SAN & VSR : Test QT_EVENT - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -*/ -#include "SALOME_Event.hxx" - -#include "QAD_Config.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_RightFrame.h" - -#include "VTKViewer_ViewFrame.h" - -#include -#include -#include -#include - -/*! SAN & VSR : Test QT_EVENT - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -*/ - using namespace std; static QFileInfo aFileInfo; #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; #else static int MYDEBUG = 0; #endif UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception); -extern "C" { - PortableServer::ObjectId * - VISUEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, - const char *instanceName, const char *interfaceName) - { - if(MYDEBUG) MESSAGE("VisuEngine_factory : "<getId() ; - } - VISU::VISU_Gen_ptr - GetVisuGen(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, - SALOME_NamingService* theNamingService, QMutex* theMutex) - { - if(MYDEBUG) MESSAGE("extern \"C\" GetVisuGen"); - VISU::VISU_Gen_i *aVISU_Gen = new VISU::VISU_Gen_i(theORB,thePOA,theNamingService,theMutex); - return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()); - //return aVISU_Gen->_this(); - } +extern "C" VISU::VISU_Gen_ptr GetImpl(CORBA::ORB_ptr theORB, + PortableServer::POA_ptr thePOA, + SALOME_NamingService* theNamingService, + QMutex* theMutex) +{ + if(MYDEBUG) MESSAGE("extern \"C\" GetImpl"); + VISU::VISU_Gen_i *aVISU_Gen = new VISU::VISU_Gen_i(theORB,thePOA,theNamingService,theMutex); + //return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this()); + return aVISU_Gen->_this(); } namespace VISU{ @@ -168,30 +138,11 @@ namespace VISU{ //=========================================================================== - VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, - const char *interfaceName) : - Engines_Component_i(orb, poa, contId, instanceName, interfaceName) - { - if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<activate_object(_thisObj); - SALOME_NamingService aNamingService(orb); - CORBA::Object_ptr anObject = aNamingService.Resolve("/Kernel/Session"); - SALOME::Session_var aSession = SALOME::Session::_narrow(anObject); - //aSession->GetInterface(); - Engines::Component_var aComponent = aSession->GetVisuComponent(); - myVisuGen = VISU::VISU_Gen::_narrow(aComponent); - } - VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, SALOME_NamingService* theNamingService, QMutex* theMutex) : Engines_Component_i() { if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<GetID(); - } - return aString._retn(); + CORBA::String_var aString(""); + if(strcmp(aLocalPersistentID,"") != 0) { + Mutex mt(myMutex); + Storable* aStorable = + Storable::Create(theSObject,VisuTmpDir.c_str(),aLocalPersistentID); + if(aStorable != NULL) aString = aStorable->GetID(); } - return myVisuGen->LocalPersistentIDToIOR(theSObject, aLocalPersistentID, isMultiFile, isASCII); + return aString._retn(); } //=========================================================================== SALOMEDS::TMPFile* VISU_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile) { - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - myMutex = "<GetStudy(); - SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent); - for (; itBig->More(); itBig->Next()) { - SALOMEDS::SObject_var gotBranch = itBig->Value(); - CORBA::Object_var anObj = SObjectToObject(gotBranch); - if(CORBA::is_nil(anObj)) continue; - Result_i* pResult = dynamic_cast(GetServant(anObj).in()); - if(pResult){ - const Result_i::TSourceId& aSourceId = pResult->GetSourceId(); - if(aSourceId == Result_i::eFile || aSourceId == Result_i::eRestoredFile){ - const QFileInfo& aFileInfo = pResult->GetFileInfo(); - QString aPrefix(""); - if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); - QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str(); - static QString aCommand; - aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1()); - if(system(aCommand) == -1){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"<GetStudy(); + SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent); + for (; itBig->More(); itBig->Next()) { + SALOMEDS::SObject_var gotBranch = itBig->Value(); + CORBA::Object_var anObj = SObjectToObject(gotBranch); + if(CORBA::is_nil(anObj)) continue; + if(Result_i* pResult = dynamic_cast(GetServant(anObj).in())){ + const Result_i::TSourceId& aSourceId = pResult->GetSourceId(); + if(aSourceId == Result_i::eFile || aSourceId == Result_i::eRestoredFile){ + const QFileInfo& aFileInfo = pResult->GetFileInfo(); + QString aPrefix(""); + if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); + QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str(); + static QString aCommand; + aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1()); + if(system(aCommand) == -1){ + if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"< 0){ - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(aFileNames.Length()); - for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--) - aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString()); - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile); - if(!isMultiFile) - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); - } - return aStreamFile._retn(); } - return myVisuGen->Save(theComponent,theURL,isMultiFile); + SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0); + if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.Length() - "< 0){ + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(aFileNames.Length()); + for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--) + aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString()); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile); + if(!isMultiFile) + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); + } + return aStreamFile._retn(); } SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - bool isMultiFile) { - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - myMutex = "<GetStudy(); - SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent); - for (; itBig->More(); itBig->Next()) { - SALOMEDS::SObject_var gotBranch = itBig->Value(); - CORBA::Object_var anObj = SObjectToObject(gotBranch); - if(CORBA::is_nil(anObj)) continue; - Result_i* pResult = dynamic_cast(GetServant(anObj).in()); - if(pResult){ - const Result_i::TSourceId& aSourceId = pResult->GetSourceId(); - if(aSourceId == Result_i::eFile || aSourceId == Result_i::eRestoredFile){ - const QFileInfo& aFileInfo = pResult->GetFileInfo(); - QString aPrefix(""); - if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); - QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str(); - static QString aCommand; - aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1()); - - if(system(aCommand) == -1){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"<GetStudy(); + SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent); + for (; itBig->More(); itBig->Next()) { + SALOMEDS::SObject_var gotBranch = itBig->Value(); + CORBA::Object_var anObj = SObjectToObject(gotBranch); + if(CORBA::is_nil(anObj)) continue; + if(Result_i* pResult = dynamic_cast(GetServant(anObj).in())){ + const Result_i::TSourceId& aSourceId = pResult->GetSourceId(); + if(aSourceId == Result_i::eFile || aSourceId == Result_i::eRestoredFile){ + const QFileInfo& aFileInfo = pResult->GetFileInfo(); + QString aPrefix(""); + if (isMultiFile) aPrefix = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); + QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str(); + static QString aCommand; + aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1()); + + if(system(aCommand) == -1){ + if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"< 0){ - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(aFileNames.Length()); - for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--) - aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString()); - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile); - if(!isMultiFile) - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); - } - return aStreamFile._retn(); } - return myVisuGen->Save(theComponent,theURL,isMultiFile); + SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0); + if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.Length() - "< 0){ + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + aSeq->length(aFileNames.Length()); + for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--) + aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString()); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile); + if(!isMultiFile) + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true); + } + return aStreamFile._retn(); } char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString, CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII) { - if(MYDEBUG) MESSAGE("VISU_Gen_i::IORToLocalPersistentID - myMutex = "<string_to_object(aString); - if(!CORBA::is_nil(anObj)){ - Storable* pStorable = dynamic_cast(GetServant(anObj).in()); - if(pStorable != NULL){ - Mutex mt(myMutex); - aString = pStorable->ToString().c_str(); - return aString._retn(); - } + CORBA::Boolean isASCII) + { + CORBA::String_var aString(IORString); + if(strcmp(IORString,"") != 0){ + CORBA::ORB_ptr anORB = GetORB(); + CORBA::Object_var anObj = anORB->string_to_object(aString); + if(!CORBA::is_nil(anObj)){ + if(Storable* pStorable = dynamic_cast(GetServant(anObj).in())){ + Mutex mt(myMutex); + aString = pStorable->ToString().c_str(); + return aString._retn(); } } - return aString._retn(); } - return myVisuGen->IORToLocalPersistentID(theSObject, IORString, isMultiFile, isASCII); + return aString._retn(); } char* VISU_Gen_i::GetID(){ - if(myMutex) - return Base_i::GetID(); - return myVisuGen->GetID(); + return Base_i::GetID(); } void VISU_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy){ - if(myMutex){ - if(CORBA::is_nil(theStudy)) - INFOS("VISU_Gen_i::SetCurrentStudy : CORBA::is_nil(theStudy)"); - if(!CORBA::is_nil(theStudy)){ - CORBA::String_var aName = theStudy->Name(); - INFOS("VISU_Gen_i::SetCurrentStudy - StudyId = "<StudyId()<<"; Name = '"<SetCurrentStudy(theStudy); + if(!CORBA::is_nil(theStudy)){ + CORBA::String_var aName = theStudy->Name(); + MESSAGE("VISU_Gen_i::SetCurrentStudy - StudyId = "<StudyId()<<"; Name = '"<GetCurrentStudy(); + return SALOMEDS::Study::_duplicate(myStudyDocument); } + ViewManager_ptr VISU_Gen_i::GetViewManager(){ - //omni_mutex aMutex; - //omni_mutex_lock aMutexLock(aMutex); - if(MYDEBUG) MESSAGE("VISU_Gen_i::GetViewManager : "<_this()); - } - return myVisuGen->GetViewManager(); + Mutex mt(myMutex); + ViewManager_i * aViewManager = new ViewManager_i(myStudyDocument); + return ViewManager::_duplicate(aViewManager->_this()); } SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){ - if(myMutex){ - if(myStudyDocument->GetProperties()->IsLocked()) return SALOMEDS::SObject::_nil(); - Mutex mt(myMutex); - SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument); - return aRes._retn(); - } - return myVisuGen->ImportTables(theFileName); + if(myStudyDocument->GetProperties()->IsLocked()) + return SALOMEDS::SObject::_nil(); + Mutex mt(myMutex); + SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument); + return aRes._retn(); } CORBA::Boolean VISU_Gen_i::ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName) - { - return VISU::ExportTableToFile(theTable, theFileName); - } + { + return VISU::ExportTableToFile(theTable, theFileName); + } Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){ - if(myMutex){ - if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex); - aFileInfo.setFile(theFileName); - Result_i* pResult = new Result_i(myStudyDocument); - if(pResult->Create(theFileName) != NULL) - return pResult->_this(); - else{ - pResult->_remove_ref(); - return VISU::Result::_nil(); - } - } - return myVisuGen->ImportFile(theFileName); + if(myStudyDocument->GetProperties()->IsLocked()) + return Result::_nil(); + Mutex mt(myMutex); + aFileInfo.setFile(theFileName); + Result_i* pResult = new Result_i(myStudyDocument); + if(pResult->Create(theFileName) != NULL) + return pResult->_this(); + else{ + pResult->_remove_ref(); + return VISU::Result::_nil(); + } } Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){ - if(myMutex){ - if(myStudyDocument->GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex); - VISU::Result_var aResult; - aFileInfo.setFile(theFileName); - Result_i* pResult = new Result_i(myStudyDocument,Result_i::eRestoredFile); - if(pResult->Create(theFileName) != NULL) - aResult = pResult->_this(); - return aResult._retn(); - } - return myVisuGen->CopyAndImportFile(theFileName); + if(myStudyDocument->GetProperties()->IsLocked()) + return Result::_nil(); + Mutex mt(myMutex); + VISU::Result_var aResult; + aFileInfo.setFile(theFileName); + Result_i* pResult = new Result_i(myStudyDocument,Result_i::eRestoredFile); + if(pResult->Create(theFileName) != NULL) + aResult = pResult->_this(); + return aResult._retn(); } Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMed : "<GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex); - Result_i* pResult = new Result_i(myStudyDocument); - if(pResult->Create(theMedSObject) != NULL) - return pResult->_this(); - else{ - pResult->_remove_ref(); - return VISU::Result::_nil(); - } + if(myStudyDocument->GetProperties()->IsLocked()) + return Result::_nil(); + Mutex mt(myMutex); + Result_i* pResult = new Result_i(myStudyDocument); + if(pResult->Create(theMedSObject) != NULL) + return pResult->_this(); + else{ + pResult->_remove_ref(); + return VISU::Result::_nil(); } - return myVisuGen->ImportMed(theMedSObject); } Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::ImportMedField : "<GetProperties()->IsLocked()) return Result::_nil(); - Mutex mt(myMutex); - Result_i* pResult = new Result_i(myStudyDocument); - if(pResult->Create(theField) != NULL) - return pResult->_this(); - else{ - pResult->_remove_ref(); - return VISU::Result::_nil(); - } + if(myStudyDocument->GetProperties()->IsLocked()) + return Result::_nil(); + Mutex mt(myMutex); + Result_i* pResult = new Result_i(myStudyDocument); + if(pResult->Create(theField) != NULL) + return pResult->_this(); + else{ + pResult->_remove_ref(); + return VISU::Result::_nil(); } - return myVisuGen->ImportMedField(theField); } - Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::MeshOnEntity : "<GetProperties()->IsLocked()) return Mesh::_nil(); - Mutex mt(myMutex); - if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ - Mesh_i* aPresent = new Mesh_i(pResult); - if(aPresent->Create(theMeshName,theEntity) != NULL) - return aPresent->_this(); - else{ - aPresent->_remove_ref(); - return VISU::Mesh::_nil(); - } + Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity) + { + if(myStudyDocument->GetProperties()->IsLocked()) + return Mesh::_nil(); + Mutex mt(myMutex); + if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ + Mesh_i* aPresent = new Mesh_i(pResult); + if(aPresent->Create(theMeshName,theEntity) != NULL) + return aPresent->_this(); + else{ + aPresent->_remove_ref(); + return VISU::Mesh::_nil(); } } - return myVisuGen->MeshOnEntity(theResult,theMeshName,theEntity); } - Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName, + Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult, + const char* theMeshName, VISU::Entity theEntity, - const char* theFamilyName){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::FamilyMeshOnEntity : "<GetProperties()->IsLocked()) return Mesh::_nil(); - Mutex mt(myMutex); - if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ - Mesh_i* aPresent = new Mesh_i(pResult); - if(aPresent->Create(theMeshName,theEntity,theFamilyName) != NULL) - return aPresent->_this(); - else{ - aPresent->_remove_ref(); - return VISU::Mesh::_nil(); - } + const char* theFamilyName) + { + if(myStudyDocument->GetProperties()->IsLocked()) + return Mesh::_nil(); + Mutex mt(myMutex); + if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ + Mesh_i* aPresent = new Mesh_i(pResult); + if(aPresent->Create(theMeshName,theEntity,theFamilyName) != NULL) + return aPresent->_this(); + else{ + aPresent->_remove_ref(); + return VISU::Mesh::_nil(); } } - return myVisuGen->FamilyMeshOnEntity(theResult,theMeshName,theEntity,theFamilyName); } - Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, const char* theMeshName, - const char* theGroupName){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::GroupMesh : "<GetProperties()->IsLocked()) return Mesh::_nil(); - Mutex mt(myMutex); - if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ - Mesh_i* aPresent = new Mesh_i(pResult); - if(aPresent->Create(theMeshName,theGroupName) != NULL) - return aPresent->_this(); - else{ - aPresent->_remove_ref(); - return VISU::Mesh::_nil(); - } + Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult, + const char* theMeshName, + const char* theGroupName) + { + if(myStudyDocument->GetProperties()->IsLocked()) + return Mesh::_nil(); + Mutex mt(myMutex); + if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ + Mesh_i* aPresent = new Mesh_i(pResult); + if(aPresent->Create(theMeshName,theGroupName) != NULL) + return aPresent->_this(); + else{ + aPresent->_remove_ref(); + return VISU::Mesh::_nil(); } } - return myVisuGen->GroupMesh(theResult,theMeshName,theGroupName); } - ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration) + ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) { - if(myMutex) return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn(); - return myVisuGen->ScalarMapOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn(); } - DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration) + DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) { - if(myMutex) return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); - return myVisuGen->DeformedShapeOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); } - Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration) + Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) { - if(myMutex) return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); - return myVisuGen->VectorsOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); } - IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration) + IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) { - if(myMutex) return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); - return myVisuGen->IsoSurfacesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); } - StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration) + StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) { - if(myMutex) return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); - return myVisuGen->StreamLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); } - CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration) + CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) { - if(myMutex) return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); - return myVisuGen->CutPlanesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); } - CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, CORBA::Double theIteration) + CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult, + const char* theMeshName, + VISU::Entity theEntity, + const char* theFieldName, + CORBA::Double theIteration) { - if(myMutex) return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); - return myVisuGen->CutLinesOnField(theResult,theMeshName,theEntity,theFieldName,theIteration); + return Prs3dOnField(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn(); } Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateTable : "<GetProperties()->IsLocked()) return Table::_nil(); - Mutex mt(myMutex); - Table_i* pPresent = new Table_i(myStudyDocument,theTableEntry); - if(pPresent->Create() != NULL) - return pPresent->_this(); - else{ - pPresent->_remove_ref(); - return VISU::Table::_nil(); - } + if(myStudyDocument->GetProperties()->IsLocked()) + return Table::_nil(); + Mutex mt(myMutex); + Table_i* pPresent = new Table_i(myStudyDocument,theTableEntry); + if(pPresent->Create() != NULL) + return pPresent->_this(); + else{ + pPresent->_remove_ref(); + return VISU::Table::_nil(); } - return myVisuGen->CreateTable(theTableEntry); } - Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateCurve : "<GetProperties()->IsLocked()) return Curve::_nil(); - Mutex mt(myMutex); - PortableServer::POA_ptr aPOA = GetPOA(); - Table_i* pTable = dynamic_cast(aPOA->reference_to_servant(theTable)); - Curve_i* pPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow); - if(pPresent->Create() != NULL) - return pPresent->_this(); - else{ - pPresent->_remove_ref(); - return VISU::Curve::_nil(); - } + Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable, + CORBA::Long theHRow, + CORBA::Long theVRow) + { + if(myStudyDocument->GetProperties()->IsLocked()) + return Curve::_nil(); + Mutex mt(myMutex); + PortableServer::POA_ptr aPOA = GetPOA(); + Table_i* pTable = dynamic_cast(aPOA->reference_to_servant(theTable)); + Curve_i* pPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow); + if(pPresent->Create() != NULL) + return pPresent->_this(); + else{ + pPresent->_remove_ref(); + return VISU::Curve::_nil(); } - return myVisuGen->CreateCurve(theTable,theHRow,theVRow); } + Container_ptr VISU_Gen_i::CreateContainer(){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateContainer : "<GetProperties()->IsLocked()) return Container::_nil(); - Mutex mt(myMutex); - Container_i* pPresent = new Container_i(myStudyDocument); - if(pPresent->Create() != NULL) - return pPresent->_this(); - else{ - pPresent->_remove_ref(); - return VISU::Container::_nil(); - } + if(myStudyDocument->GetProperties()->IsLocked()) + return Container::_nil(); + Mutex mt(myMutex); + Container_i* pPresent = new Container_i(myStudyDocument); + if(pPresent->Create() != NULL) + return pPresent->_this(); + else{ + pPresent->_remove_ref(); + return VISU::Container::_nil(); } - return myVisuGen->CreateContainer(); } Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){ - if(myMutex){ - if(myStudyDocument->GetProperties()->IsLocked()) return Animation::_nil(); - Mutex mt(myMutex); - if(MYDEBUG) MESSAGE("VISU_Gen_i::CreateAnimation : "<_this(); - }else - return VISU::Animation::_nil(); - - } - return myVisuGen->CreateAnimation(theView3D); + if(myStudyDocument->GetProperties()->IsLocked()) + return Animation::_nil(); + Mutex mt(myMutex); + if(VISU_TimeAnimation_i* anAnim = new VISU_TimeAnimation_i(myStudyDocument,theView3D)){ + return anAnim->_this(); + }else + return VISU::Animation::_nil(); } void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){ - if(MYDEBUG) MESSAGE("VISU_Gen_i::Close : "<GetStudy(); - //if(!aStudy->_is_nil()){ - // SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(theComponent); - // aChildIter->InitEx(true); - // for (int i = 0; aChildIter->More(); aChildIter->Next(),i++) { - // SALOMEDS::SObject_var aSObject = aChildIter->Value(); - // if(MYDEBUG) MESSAGE("VISU_Gen_i::Close : aChildIter->Next() = "<(aServant.in())){ - // VISU::VISUType aType = pBase->GetType(); - // switch(aType){ - // case VISU::TRESULT: - // if(VISU::Result_i* pResult = dynamic_cast(pBase)){ - // //Try remove its file and directory - // if(pResult->GetSourceId() == Result_i::eRestoredFile){ - // const QFileInfo& aFileInfo = pResult->GetFileInfo(); - // static QString aCommand; - // aCommand.sprintf("rm %s",aFileInfo.filePath().latin1()); - // if(system(aCommand) != -1 && MYDEBUG) MESSAGE("VISU_Gen_i::Close - "<Close(theComponent); } char* VISU_Gen_i::ComponentDataType(){ @@ -734,265 +606,170 @@ namespace VISU{ SALOMEDS::SObject_ptr theSObject, CORBA::Object_ptr theObject, const char* theName) - throw (SALOME::SALOME_Exception) + throw (SALOME::SALOME_Exception) { Unexpect aCatch(SalomeException); if(MYDEBUG) MESSAGE("VISU_Gen_i::PublishInStudy : "<(GetServant(theObject).in()); - if (!aResultObj) return aResultSO._retn(); - const QFileInfo& aFileInfo = aResultObj->GetFileInfo(); - CORBA::String_var anEntry = aResultObj->Create(aFileInfo.filePath().latin1())->GetID(); - aResultSO = theStudy->FindObjectID(anEntry); - return aResultSO._retn(); - } - return myVisuGen->PublishInStudy(theStudy, theSObject, theObject, theName); + Mutex mt(myMutex); + SALOMEDS::SObject_var aResultSO; + Result_i* aResultObj = dynamic_cast(GetServant(theObject).in()); + if (!aResultObj) return aResultSO._retn(); + const QFileInfo& aFileInfo = aResultObj->GetFileInfo(); + CORBA::String_var anEntry = aResultObj->Create(aFileInfo.filePath().latin1())->GetID(); + aResultSO = theStudy->FindObjectID(anEntry); + return aResultSO._retn(); } CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) { - if(0 && MYDEBUG) MESSAGE("VISU_Gen_i::CanCopy : "<FindAttribute(anAttr, "AttributeIOR")) return false; - try { - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var aValue = anIOR->Value(); - if(strcmp(aValue,"") != 0){ - CORBA::Object_ptr anObj = GetORB()->string_to_object(aValue); - if (!CORBA::is_nil(anObj)){ - Result_var aResultObj = Result::_narrow(anObj); - if(!aResultObj->_is_nil()){ - if(Result_i* pResult = dynamic_cast(GetServant(aResultObj).in())){ - const Result_i::TSourceId& aSourceId = pResult->GetSourceId(); - if(aSourceId == Result_i::eComponent || aSourceId == Result_i::eRestoredComponent) - if((pResult->GetFileInfo()).filePath() == "MED") - return false; - return true; - } + Mutex mt(myMutex); + SALOMEDS::GenericAttribute_var anAttr; + if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false; + try { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var aValue = anIOR->Value(); + if(strcmp(aValue,"") != 0){ + CORBA::Object_ptr anObj = GetORB()->string_to_object(aValue); + if (!CORBA::is_nil(anObj)){ + Result_var aResultObj = Result::_narrow(anObj); + if(!aResultObj->_is_nil()){ + if(Result_i* pResult = dynamic_cast(GetServant(aResultObj).in())){ + const Result_i::TSourceId& aSourceId = pResult->GetSourceId(); + if(aSourceId == Result_i::eComponent || aSourceId == Result_i::eRestoredComponent) + if((pResult->GetFileInfo()).filePath() == "MED") + return false; + return true; } } } - }catch (...){ - INFOS("Unknown exception was accured!"); } - return false; + }catch (...){ + INFOS("Unknown exception was accured!"); } - return myVisuGen->CanCopy(theObject); + return false; } SALOMEDS::TMPFile* VISU_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) { - if(myMutex){ - Mutex mt(myMutex); - - theObjectID = 0; - SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile; - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - - PortableServer::POA_ptr aPOA = GetPOA(); - - SALOMEDS::GenericAttribute_var anAttr; - if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL; - SALOMEDS::AttributeIOR_var anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::Object_var aCorbaObj; - try { - aCorbaObj = GetORB()->string_to_object(anIORAttr->Value()); - } catch(...) { - aStreamFile->length(1); - aStreamFile[0] = strdup("E")[0]; - return aStreamFile._retn(); - } - if (CORBA::is_nil(aCorbaObj)) { - return NULL; - } + Mutex mt(myMutex); + theObjectID = 0; + SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile; + SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - Storable* pStorable = dynamic_cast(GetServant(aCorbaObj).in()); - if (!pStorable) { + PortableServer::POA_ptr aPOA = GetPOA(); + + SALOMEDS::GenericAttribute_var anAttr; + if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL; + SALOMEDS::AttributeIOR_var anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::Object_var aCorbaObj; + try { + aCorbaObj = GetORB()->string_to_object(anIORAttr->Value()); + } catch(...) { + aStreamFile->length(1); + aStreamFile[0] = strdup("E")[0]; + return aStreamFile._retn(); + } + if (CORBA::is_nil(aCorbaObj)) { + return NULL; + } + + Storable* pStorable = dynamic_cast(GetServant(aCorbaObj).in()); + if (!pStorable) { + return NULL; + } + CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir(); + + string aStr = pStorable->ToString().c_str(); + ofstream stmOut2((string(aTmpDir) + string("copy_persistent")).c_str(),ios::out); + stmOut2<(aPOA->reference_to_servant(aCorbaObj))) { + string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_"; + const QFileInfo& aFileInfo = aResultObj->GetFileInfo(); + aFileName += aFileInfo.fileName().latin1(); + static QString aCommand; + aCommand.sprintf("cp %s %s", + aFileInfo.filePath().latin1(), + (string(aTmpDir) + aFileName).c_str()); + if(system(aCommand) == -1) { + if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<ToString().c_str(); - ofstream stmOut2((string(aTmpDir) + string("copy_persistent")).c_str(),ios::out); - stmOut2<(aPOA->reference_to_servant(aCorbaObj)); - if (aResultObj) { - string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_"; - const QFileInfo& aFileInfo = aResultObj->GetFileInfo(); - aFileName += aFileInfo.fileName().latin1(); - static QString aCommand; - aCommand.sprintf("cp %s %s", - aFileInfo.filePath().latin1(), - (string(aTmpDir) + aFileName).c_str()); - if(system(aCommand) == -1) { - if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<length(2); - aSeq[0] = "copy_persistent"; - aSeq[1] = aFileName.c_str(); - } else { - aSeq->length(1); - aSeq[0] = "copy_persistent"; - } - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), false); - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true); - - // Assign an ID = 1 the the type VISU::Result - theObjectID = 1; - - - SALOMEDS::SComponent_var aSComponent = theObject->GetStudy()->FindComponent("VISU"); - return aStreamFile._retn(); + + aSeq->length(2); + aSeq[0] = "copy_persistent"; + aSeq[1] = aFileName.c_str(); + } else { + aSeq->length(1); + aSeq[0] = "copy_persistent"; } - return myVisuGen->CopyFrom(theObject, theObjectID); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), false); + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true); + + // Assign an ID = 1 the the type VISU::Result + theObjectID = 1; + + + SALOMEDS::SComponent_var aSComponent = theObject->GetStudy()->FindComponent("VISU"); + return aStreamFile._retn(); } CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) { // The VISU component can paste only objects copied by VISU component // and with the object type = 1 - if(0 && MYDEBUG) MESSAGE("VISU_Gen_i::CanPaste : "<length() > 1) aFileName += aSeq[1].in(); - - SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); - SALOMEDS::Study_var aStudy = theObject->GetStudy(); - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - CORBA::String_var aComponentID(aComponent->GetID()), aSObjID(theObject->GetID()); - - if (strcmp(aComponentID, aSObjID) == 0) //create the new result SObject - aResultSO = aStudyBuilder->NewObject(aComponent); - else - aResultSO = SALOMEDS::SObject::_duplicate(theObject); - - //Just for Result::Restore to find the Comment attribute :( - SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment"); - - Storable* aStorable = Storable::Create(aResultSO,aFileName,aString); - - SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames; - aSeqToRm->length(1); - aSeqToRm[0] = "copy_persistent"; - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeqToRm.in(), true); - - anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR"); - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var anIORValue(aStorable->GetID()); - anIOR->SetValue(anIORValue); + SALOMEDS::SObject_ptr theObject) + { + Mutex mt(myMutex); + SALOMEDS::SObject_var aResultSO; + if (theObjectID != 1) return aResultSO._retn(); - } - return myVisuGen->PasteInto(theStream,theObjectID,theObject); - } - - /*! SAN & VSR : Test QT_EVENT - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - */ - class TestViewEvent : public SALOME_Event { - public: - virtual void Execute(){ - QAD_Desktop* desktop = QAD_Application::getDesktop(); - QAD_Study* aStudy = desktop->getActiveStudy(); - if ( !aStudy ) { - QString defViewer = QAD_CONFIG->getSetting( "Viewer::DefaultViewer" ); - int dv = defViewer.toInt(); - QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( VIEW_VTK ) ); - desktop->createStudy(); - if ( !defViewer.isEmpty() ) { - QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( dv ) ); - } - } - else { - aStudy->newWindow3d( "", VIEW_VTK ); - } - } - }; - - class TestObjectEvent : public SALOME_Event { - public: - virtual void Execute(){ - float aRadius = 150.0 * random() / RAND_MAX + 10.; - float aX = 1000.0 * random() / RAND_MAX - 500.; - float aY = 1000.0 * random() / RAND_MAX - 500.; - float aZ = 1000.0 * random() / RAND_MAX - 500.; - float aR = (float)random() / RAND_MAX; - float aG = (float)random() / RAND_MAX; - float aB = (float)random() / RAND_MAX; - - vtkSphereSource* aSource = vtkSphereSource::New(); - aSource->SetRadius( aRadius ); - aSource->SetCenter( aX, aY, aZ ); - - vtkProperty* prop = vtkProperty::New(); - prop->SetColor( aR, aG, aB ); - - vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); - aMapper->SetInput( aSource->GetOutput() ); - - vtkActor* sphere = vtkActor::New(); - sphere->SetMapper( aMapper ); - sphere->SetProperty( prop ); - - QAD_Desktop* desktop = QAD_Application::getDesktop(); - QAD_Study* aStudy = desktop->getActiveStudy(); - if ( !aStudy ) - return ; - VTKViewer_ViewFrame* vf = (VTKViewer_ViewFrame*)(desktop->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()); - sphere->SetVisibility( true ); - vf->getRenderer()->AddActor(sphere); - vf->Repaint(); - } - }; - - void VISU_Gen_i::CreateTestView() { - if(myMutex){ - TestViewEvent* ve = new TestViewEvent(); - ve->process(); - ve->release(); - return; - } - myVisuGen->CreateTestView(); + + CORBA::String_var aTmpDir = (const char*)SALOMEDS_Tool::GetTmpDir(); + SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false); + + ifstream stmIn((string(aTmpDir) + string("copy_persistent")).c_str()); + stmIn.seekg(0, ios::end); + int aLength = stmIn.tellg(); + stmIn.seekg(0, ios::beg); + char* aString = new char[aLength+1]; + stmIn.read(aString, aLength); + aString[aLength] = 0; + myIsMultiFile = false; + + string aFileName(aTmpDir.in()); + if(aSeq->length() > 1) aFileName += aSeq[1].in(); + + SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); + SALOMEDS::Study_var aStudy = theObject->GetStudy(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + CORBA::String_var aComponentID(aComponent->GetID()), aSObjID(theObject->GetID()); + + if (strcmp(aComponentID, aSObjID) == 0) //create the new result SObject + aResultSO = aStudyBuilder->NewObject(aComponent); + else + aResultSO = SALOMEDS::SObject::_duplicate(theObject); + + //Just for Result::Restore to find the Comment attribute :( + SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment"); + + Storable* aStorable = Storable::Create(aResultSO,aFileName,aString); + + SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames; + aSeqToRm->length(1); + aSeqToRm[0] = "copy_persistent"; + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeqToRm.in(), true); + + anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR"); + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var anIORValue(aStorable->GetID()); + anIOR->SetValue(anIORValue); + return aResultSO._retn(); } - void VISU_Gen_i::ShowTestObject() { - if(myMutex){ - TestObjectEvent* ve = new TestObjectEvent(); - ve->process(); - ve->release(); - return; - } - myVisuGen->ShowTestObject(); - } - /*! SAN & VSR : Test QT_EVENT - <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - */ }; diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 9a1d4aa0..99572fae 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -21,31 +21,19 @@ namespace VISU{ public virtual ::Engines_Component_i, public virtual Base_i { - VISU_Gen_var myVisuGen; SALOMEDS::Study_var myStudyDocument; VISU_Gen_i(); VISU_Gen_i(const VISU::VISU_Gen_i &); public: - VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA, - SALOME_NamingService* theNamingService, QMutex* theMutex); - VISU_Gen_i(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, - const char *interfaceName); + VISU_Gen_i(CORBA::ORB_ptr theORB, + PortableServer::POA_ptr thePOA, + SALOME_NamingService* theNamingService, + QMutex* theMutex); virtual ~VISU_Gen_i(); virtual char* GetID(); virtual VISU::VISUType GetType() { return VISU::TVISUGEN;}; -/*! SAN & VSR : Test QT_EVENT ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -*/ - virtual void CreateTestView(); - virtual void ShowTestObject(); -/*! SAN & VSR : Test QT_EVENT -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -*/ virtual void SetCurrentStudy(SALOMEDS::Study_ptr theStudy); virtual SALOMEDS::Study_ptr GetCurrentStudy(); @@ -148,6 +136,14 @@ namespace VISU{ SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject); + /*! SAN & VSR : Test QT_EVENT + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + */ + virtual void CreateTestView(); + virtual void ShowTestObject(); + /*! SAN & VSR : Test QT_EVENT + <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + */ }; } #endif diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index 625be7a8..ee7724e0 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -978,10 +978,6 @@ namespace VISU{ ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]); ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]); } - //Storable* View3D_i::Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&) { - // Restore(myStudyFrame,theMap); - // return this; - //} string View3D_i::ToString(QAD_StudyFrame* theStudyFrame){ @@ -1312,4 +1308,89 @@ namespace VISU{ ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale)); } //=========================================================================== -} +}; + + +/*! SAN & VSR : Test QT_EVENT + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +*/ +#include "VISU_Gen_i.hh" +#include "QAD_Config.h" +#include +#include +#include + +namespace VISU{ + class TestViewEvent : public SALOME_Event { + public: + virtual void Execute(){ + QAD_Desktop* desktop = QAD_Application::getDesktop(); + QAD_Study* aStudy = desktop->getActiveStudy(); + if ( !aStudy ) { + QString defViewer = QAD_CONFIG->getSetting( "Viewer::DefaultViewer" ); + int dv = defViewer.toInt(); + QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( VIEW_VTK ) ); + desktop->createStudy(); + if ( !defViewer.isEmpty() ) { + QAD_CONFIG->addSetting( "Viewer::DefaultViewer", QString::number( dv ) ); + } + } + else { + aStudy->newWindow3d( "", VIEW_VTK ); + } + } + }; + + void VISU_Gen_i::CreateTestView() { + TestViewEvent* ve = new TestViewEvent(); + ve->process(); + ve->release(); + } + + + class TestObjectEvent : public SALOME_Event { + public: + virtual void Execute(){ + float aRadius = 150.0 * random() / RAND_MAX + 10.; + float aX = 1000.0 * random() / RAND_MAX - 500.; + float aY = 1000.0 * random() / RAND_MAX - 500.; + float aZ = 1000.0 * random() / RAND_MAX - 500.; + float aR = (float)random() / RAND_MAX; + float aG = (float)random() / RAND_MAX; + float aB = (float)random() / RAND_MAX; + + vtkSphereSource* aSource = vtkSphereSource::New(); + aSource->SetRadius( aRadius ); + aSource->SetCenter( aX, aY, aZ ); + + vtkProperty* prop = vtkProperty::New(); + prop->SetColor( aR, aG, aB ); + + vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New(); + aMapper->SetInput( aSource->GetOutput() ); + + vtkActor* sphere = vtkActor::New(); + sphere->SetMapper( aMapper ); + sphere->SetProperty( prop ); + + QAD_Desktop* desktop = QAD_Application::getDesktop(); + QAD_Study* aStudy = desktop->getActiveStudy(); + if ( !aStudy ) + return ; + VTKViewer_ViewFrame* vf = (VTKViewer_ViewFrame*)(desktop->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()); + sphere->SetVisibility( true ); + vf->getRenderer()->AddActor(sphere); + vf->Repaint(); + } + }; + + void VISU_Gen_i::ShowTestObject() { + TestObjectEvent* ve = new TestObjectEvent(); + ve->process(); + ve->release(); + return; + } + /*! SAN & VSR : Test QT_EVENT + <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + */ +}; diff --git a/src/VISU_I/VISU_ViewManager_i.hh b/src/VISU_I/VISU_ViewManager_i.hh index 4acb054e..b399434d 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -256,7 +256,6 @@ namespace VISU{ public: virtual Storable* Create(int theNew); - //virtual Storable* Restore(const Storable::TRestoringMap& theMap) throw(std::logic_error&); virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; static const string myComment;