From f83d413ffc4acd7f8f5f5f8b6dd21960387f29c7 Mon Sep 17 00:00:00 2001 From: nri Date: Fri, 30 Apr 2004 13:08:34 +0000 Subject: [PATCH] NRI : Merge from Event_Server. --- idl/VISU_Gen.idl | 12 +- src/ENGINE/Makefile.in | 50 + src/ENGINE/VISU_Engine_i.cc | 358 ++++++ src/ENGINE/VISU_Engine_i.hh | 143 +++ src/Makefile.in | 2 +- src/VISUGUI/Makefile.in | 2 +- src/VISUGUI/VisuGUI.cxx | 145 +-- src/VISUGUI/VisuGUI.h | 32 +- src/VISUGUI/VisuGUI_EditContainerDlg.cxx | 5 +- src/VISUGUI/VisuGUI_FileDlg.cxx | 1 - src/VISUGUI/VisuGUI_Selection.cxx | 1 + src/VISU_I/Makefile.in | 6 +- src/VISU_I/VISUConfig.cc | 30 +- src/VISU_I/VISUConfig.hh | 5 +- src/VISU_I/VISU_Gen_i.cc | 992 ++++++++--------- src/VISU_I/VISU_Gen_i.hh | 37 +- src/VISU_I/VISU_Prs3d_i.cc | 6 +- src/VISU_I/VISU_TimeAnimation.cxx | 183 +++- src/VISU_I/VISU_TimeAnimation.h | 66 +- src/VISU_I/VISU_ViewManager_i.cc | 1259 ++++++++++++---------- src/VISU_I/VISU_ViewManager_i.hh | 33 +- src/VISU_SWIG/Makefile.in | 2 +- src/VISU_SWIG/batch_test_events.py | 14 + src/VISU_SWIG/batchmode_visu_view.py | 57 + src/VISU_SWIG/batchmode_visu_view3d.py | 267 ++++- src/VISU_SWIG/test_events.py | 22 + src/VISU_SWIG/visu_view3d.py | 265 ++++- 27 files changed, 2597 insertions(+), 1398 deletions(-) create mode 100644 src/ENGINE/Makefile.in create mode 100644 src/ENGINE/VISU_Engine_i.cc create mode 100644 src/ENGINE/VISU_Engine_i.hh create mode 100644 src/VISU_SWIG/batch_test_events.py create mode 100644 src/VISU_SWIG/batchmode_visu_view.py create mode 100755 src/VISU_SWIG/test_events.py diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 77957a23..a01a2bb9 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -961,6 +961,14 @@ post-processing presentations from given %Result and %Table object reference, us provided by %ViewManager. */ interface VISU_Gen : Engines::Component, SALOMEDS::Driver, Base{ +/*! SAN & VSR : Test QT_EVENT +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +*/ + void CreateTestView(); + void ShowTestObject(); +/*! SAN & VSR : Test QT_EVENT +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +*/ /*! Sets a definite study to be current. */ void SetCurrentStudy(in SALOMEDS::Study theStudy); @@ -1416,10 +1424,6 @@ which the curve is constructed on the graphics. */ void Destroy(in View theView); -/*! Runs a cycle of events in GUI (desktop). -\note This method is one-way. -*/ - void ProcessEvents(); }; }; #endif 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/Makefile.in b/src/Makefile.in index 0751cdb2..fe1f880e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,6 +32,6 @@ VPATH=.:@srcdir@ @COMMENCE@ -SUBDIRS = CONVERTOR PIPELINE OBJECT VISU_I VISUGUI VISU_SWIG +SUBDIRS = CONVERTOR PIPELINE OBJECT ENGINE VISU_I VISUGUI VISU_SWIG @MODULE@ 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/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 6b8f6e45..c1d55941 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -165,7 +165,7 @@ private: QFont font; }; -static VisuGUI MYVISUGUI; +static VisuGUI MYVISUGUI(""); VisuGUI *visuGUI = &MYVISUGUI; VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){ @@ -357,7 +357,9 @@ void RepaintCurrentView(){ } -VisuGUI::VisuGUI(){ +VisuGUI::VisuGUI( const QString& theName, QObject* theParent ): + SALOMEGUI( theName, theParent ) +{ mySelectionDlg = 0; } @@ -401,7 +403,6 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ======================================================================================== */ /* Import Table from file */ /* ======================================================================================== */ - case 199: { if(checkLock(aStudy)) break; @@ -685,7 +686,6 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) return true; } - void VisuGUI::SelectionInfo() { if (mySelectionDlg) { mySelectionDlg->close(true); @@ -816,10 +816,10 @@ CREATEPRESENTATION(VisuGUI::CreateStreamLines); //===================================================================================== -// function : setSettings() +// function : SetSettings() // purpose : //===================================================================================== -bool VisuGUI::setSettings(QAD_Desktop* parent) +bool VisuGUI::SetSettings(QAD_Desktop* parent) { int anId = 53; QMenuData* pp; @@ -2229,57 +2229,31 @@ void VisuGUI::DeletePrs() { void VisuGUI::SaveViewParams() { if (checkLock(GetStudyDocument())) return; - SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); - if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame(); + if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK ) return; - VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager(); - if(!CORBA::is_nil(aVM.in())){ - VISU::View_var aView = aVM->GetCurrentView(); - if(!CORBA::is_nil(aView.in())){ - VISU::View3D_var aView3D = VISU::View3D::_narrow(aView); - if(CORBA::is_nil(aView3D.in())) return; - if ( Sel->IObjectCount() == 0 ) { - // Save view parameters by new name - aView3D->SaveViewParams( 0 ); - GetActiveStudy()->updateObjBrowser( true ); - }else{ - bool isExist; - VISU::Storable::TRestoringMap aMap; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); - VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); - if(isExist && aType == VISU::TVIEW3D){ - aView3D->SaveViewParams( anIO->getName() ); - GetActiveStudy()->updateObjBrowser( true ); - } - } - } + if ( aSel->IObjectCount() == 0 ) { + VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1()); + }else{ + const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject(); + VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName()); } + GetActiveStudy()->updateObjBrowser( true ); } void VisuGUI::RestoreViewParams() { - SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); - if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame(); + if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK ) return; - VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager(); - if(!CORBA::is_nil(aVM.in())){ - VISU::View_var aView = aVM->GetCurrentView(); - if(!CORBA::is_nil(aView.in())){ - VISU::View3D_var aView3D = VISU::View3D::_narrow(aView); - if(CORBA::is_nil(aView3D.in())) return; - bool isExist; - VISU::Storable::TRestoringMap aMap; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); - VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); - if(isExist && aType == VISU::TVIEW3D) - aView3D->RestoreViewParams( anIO->getName() ); - } - } + const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject(); + VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName()); } + //===================================================================================== // function : DeleteViewParams() // purpose : @@ -3144,72 +3118,27 @@ void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) END_OF("VisuGUI::BuildPresentation"); } -extern "C" -{ - - bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) - { - //if(MYDEBUG) MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID); - return VisuGUI::OnGUIEvent(theCommandID, parent); - } - - bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - { - if(MYDEBUG) MESSAGE("VisuGUI::OnKeyPress "); - return VisuGUI::OnKeyPress (pe, parent, studyFrame); - } - bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - { - //if(MYDEBUG) MESSAGE("VisuGUI::OnMousePress "); - return VisuGUI::OnMousePress (pe, parent, studyFrame); - } - - bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) - { - //if(MYDEBUG) MESSAGE("VisuGUI::OnMouseMove "); - return VisuGUI::OnMouseMove (pe, parent, studyFrame); - } - - bool SetSettings ( QAD_Desktop* parent ) - { - return VisuGUI::setSettings( parent ); - } - - bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, - const QString & theParent, const QString & theObject ) - { - return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject ); - } - - void definePopup ( QString & theContext, QString & theParent, QString & theObject ) - { - VisuGUI::DefinePopup( theContext, theParent, theObject ); - } - - bool activeStudyChanged ( QAD_Desktop* parent ) - { - ::UpdateViewFrame(); - } - - void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO ) - { - VisuGUI::BuildPresentation(theIO); - } - - void supportedViewType(int* buffer, int bufferSize) - { - if (!buffer || !bufferSize) return; - buffer[0] = (int)VIEW_VTK; - if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D; - } +//=========================================================================== +// SupportedViewType +//=========================================================================== +void VisuGUI::SupportedViewType(int* buffer, int bufferSize) +{ + if (!buffer || !bufferSize) return; + buffer[0] = (int)VIEW_VTK; + if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D; +} - void deactivate() - { - visuGUI->EmitSignalCloseAllDialogs(); +extern "C" +{ + Standard_EXPORT SALOMEGUI* GetComponentGUI() { + if ( !visuGUI ) + visuGUI = new VisuGUI( "" ); + return visuGUI; } } + ////////////////////////////////////////////////////////////////////////////////// //////////////// CHANGE ACTOR COLOR //////////////////////// ////////////////////////////////////////////////////////////////////////////////// diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index ec5677ec..9bed10f8 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -54,6 +54,8 @@ class vtkRenderer; #include #include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI.h" + namespace VISU{ class VISU_Gen_i; @@ -78,11 +80,11 @@ namespace VISU{ // ====================================================================== // -class VisuGUI : public QObject{ +class VisuGUI : public SALOMEGUI{ Q_OBJECT; public: - VisuGUI(); - ~VisuGUI(); + VisuGUI( const QString& name = "", QObject* parent = 0 ); + virtual ~VisuGUI(); static VISU::VISU_Gen_i* GetVisuGen(); @@ -177,27 +179,29 @@ class VisuGUI : public QObject{ // ---------------------------------------- // All method of standard EXPORT // ---------------------------------------- - Standard_EXPORT static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); - Standard_EXPORT static bool setSettings(QAD_Desktop* parent); - Standard_EXPORT static void DefinePopup(QString & theContext, + virtual bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + virtual bool SetSettings(QAD_Desktop* parent); + virtual void DefinePopup(QString & theContext, QString & theParent, QString & theObject ) ; - Standard_EXPORT static bool CustomPopup(QAD_Desktop* parent, + virtual bool CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, const QString & theParent, const QString & theObject); - Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&); - Standard_EXPORT static bool OnMousePress(QMouseEvent* pe , + virtual void BuildPresentation(const Handle(SALOME_InteractiveObject)&); + virtual bool OnMousePress(QMouseEvent* pe , QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - Standard_EXPORT static bool OnMouseMove(QMouseEvent* pe , + virtual bool OnMouseMove(QMouseEvent* pe , QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - Standard_EXPORT static bool OnKeyPress(QKeyEvent* pe, + virtual bool OnKeyPress(QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - public slots: + virtual void SupportedViewType (int* buffer, int bufferSize); + +public slots: void ImportTablesFromFile(); void ExportTableToFile(); @@ -267,10 +271,6 @@ private : QDialog* myActiveDialogBox; int myState ; VisuGUI_SelectionDlg* mySelectionDlg; - -signals: - void SignalDeactivateActiveDialog(); - void SignalCloseAllDialogs(); }; #endif diff --git a/src/VISUGUI/VisuGUI_EditContainerDlg.cxx b/src/VISUGUI/VisuGUI_EditContainerDlg.cxx index 58212511..50a1571b 100644 --- a/src/VISUGUI/VisuGUI_EditContainerDlg.cxx +++ b/src/VISUGUI/VisuGUI_EditContainerDlg.cxx @@ -1,5 +1,3 @@ -using namespace std; - // VISU VISUGUI : GUI of VISU component // // Copyright (C) 2003 CEA/DEN, EDF R&D @@ -21,13 +19,14 @@ using namespace std; #include #include #include - +#include #include CORBA_SERVER_HEADER(VISU_Gen) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) extern VisuGUI *visuGUI; +using namespace std; /* XPM */ diff --git a/src/VISUGUI/VisuGUI_FileDlg.cxx b/src/VISUGUI/VisuGUI_FileDlg.cxx index 87672a24..f6955d89 100644 --- a/src/VISUGUI/VisuGUI_FileDlg.cxx +++ b/src/VISUGUI/VisuGUI_FileDlg.cxx @@ -103,4 +103,3 @@ bool VisuGUI_FileDlg::IsChecked() { return myCBuildAll->isChecked(); } - diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index f75c3475..f90df49b 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include #include 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/VISUConfig.cc b/src/VISU_I/VISUConfig.cc index bef92c9d..1e760bbd 100644 --- a/src/VISU_I/VISUConfig.cc +++ b/src/VISU_I/VISUConfig.cc @@ -58,32 +58,16 @@ namespace VISU{ //=========================================================================== static int mySCnt = 0; - static int myQCnt = 0; - static int myIsBatchMode = 0; - Mutex::Mutex(QMutex* theMutex, QApplication* theQApp, int theDelay) : - myQApp(theQApp), isQAppLocked(theQApp->locked()), myDelay(theDelay), - myMutex(theMutex), isSessionLocked(theMutex->locked()) - { - if(MYDEBUG) MESSAGE("Mutex::Mutex : "<<(!isQAppLocked && !myQCnt)<<" "<<(!isSessionLocked && !mySCnt)); - if(!myIsBatchMode && isQAppLocked) myIsBatchMode++; - if(!isSessionLocked && !mySCnt) { myMutex->lock();}; mySCnt++; - if(!isQAppLocked && !myQCnt) { - myQApp->lock(); - myQApp->syncX(); - }; - myQCnt++; + Mutex::Mutex(QMutex* theMutex): myMutex(theMutex){ + if(MYDEBUG) MESSAGE("Mutex::Mutex : "<lock(); } Mutex::~Mutex(){ - myQCnt--; - if(!isQAppLocked && !myQCnt) { - myQApp->flushX(); - //if(myDelay > 0) - myQApp->processEvents(myDelay+3); - myQApp->unlock(); - } - mySCnt--; if(!isSessionLocked && !mySCnt) { myMutex->unlock();} - if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<<(!isQAppLocked && !myQCnt)<<" "<<(!isSessionLocked && !mySCnt)); + if(!(--mySCnt)) + myMutex->unlock(); + if(MYDEBUG) MESSAGE("Mutex::~Mutex : "<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{ @@ -147,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,qApp); - 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,qApp); - 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,qApp); - 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,qApp); - 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,qApp); - 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,qApp); - 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,qApp); - Result_i* pResult = dynamic_cast(GetServant(theResult).in()); + 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(); @@ -503,17 +434,17 @@ namespace VISU{ 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,qApp); - Result_i* pResult = dynamic_cast(GetServant(theResult).in()); + 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(); @@ -522,16 +453,16 @@ namespace VISU{ 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,qApp); - Result_i* pResult = dynamic_cast(GetServant(theResult).in()); + 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(); @@ -540,161 +471,126 @@ namespace VISU{ 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,qApp); - 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,qApp); - 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,qApp); - 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,qApp); - 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(){ @@ -710,184 +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,qApp); - - theObjectID = 0; - SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile; - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; + 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; - } - - 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); + + 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(); } }; diff --git a/src/VISU_I/VISU_Gen_i.hh b/src/VISU_I/VISU_Gen_i.hh index 2b4dfc34..99572fae 100644 --- a/src/VISU_I/VISU_Gen_i.hh +++ b/src/VISU_I/VISU_Gen_i.hh @@ -21,18 +21,14 @@ 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(); @@ -66,14 +62,15 @@ namespace VISU{ typedef typename TPrs3d_i::TInterface TPrs3d; typename TPrs3d::_var_type aPrs3d; if(myStudyDocument->GetProperties()->IsLocked()) return TPrs3d::_nil(); - Mutex mt(myMutex,qApp); - Result_i* pResult = dynamic_cast(GetServant(theResult).in()); - if(TPrs3d_i::IsPossible(pResult,theMeshName,theEntity,theFieldName,int(theIteration))){ - TPrs3d_i* aPresent = new TPrs3d_i(pResult,theAddToStudy); - if(aPresent->Create(theMeshName,theEntity,theFieldName,int(theIteration)) != NULL) - return aPresent->_this(); - else - aPresent->_remove_ref(); + Mutex mt(myMutex); + if(Result_i* pResult = dynamic_cast(GetServant(theResult).in())){ + if(TPrs3d_i::IsPossible(pResult,theMeshName,theEntity,theFieldName,int(theIteration))){ + TPrs3d_i* aPresent = new TPrs3d_i(pResult,theAddToStudy); + if(aPresent->Create(theMeshName,theEntity,theFieldName,int(theIteration)) != NULL) + return aPresent->_this(); + else + aPresent->_remove_ref(); + } } return TPrs3d::_nil(); } @@ -139,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_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 5046a1fe..9a71122e 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -51,7 +51,7 @@ VISU::Prs3d_i::Prs3d_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject) : myAddToStudy = true; myPipeLine = NULL; CORBA::String_var aName = myStudy->Name(); - MESSAGE("Prs3d_i - this = "<getRenderer(); @@ -280,7 +281,6 @@ void VISU_TimeAnimation::clearView() { MESSAGE("Viewer is nod defined for animation"); return; } - VISU::Mutex mt(myMutex,qApp,MYDELAY); vtkRenderer* aRen = myView->getRenderer(); for (int i = 0; i < getNbFields(); i++) { FieldData& aData = myFieldsLst[i]; @@ -294,7 +294,8 @@ void VISU_TimeAnimation::clearView() { aData.myActors.clear(); } } - myView->update(); + myView->getRW()->getRenderWindow()->Render(); + //myView->update(); } //************************************************************************ @@ -544,3 +545,171 @@ double VISU_TimeAnimation::getTimeValue(SALOMEDS::SObject_var theTimeStamp) { void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed) { mySpeed = (theSpeed<1)? 1 : theSpeed; } + + +//======================================================================== +VISU_TimeAnimation_i::VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy, VISU::View3D_ptr theView3D){ + myAnim = new VISU_TimeAnimation(theStudy,theView3D); +} + + +VISU_TimeAnimation_i::~VISU_TimeAnimation_i(){ + delete myAnim; +} + + +void VISU_TimeAnimation_i::addField(SALOMEDS::SObject_ptr theField){ + myAnim->addField(theField); +} + + +CORBA::Boolean VISU_TimeAnimation_i::generateFrames(){ + return ProcessEvent(new TMemFunEvent(myAnim,&VISU_TimeAnimation::generateFrames)); +} + + +void VISU_TimeAnimation_i::generatePresentations(CORBA::Long theFieldNum){ + myAnim->generatePresentations(theFieldNum); +} + + +void VISU_TimeAnimation_i::clearView(){ + ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::clearView)); +} + + +void VISU_TimeAnimation_i::stopAnimation(){ + ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::stopAnimation)); +} + + +void VISU_TimeAnimation_i::startAnimation(){ + ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::startAnimation)); +} + + +void VISU_TimeAnimation_i::nextFrame(){ + ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::nextFrame)); +} + + +void VISU_TimeAnimation_i::prevFrame(){ + ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::prevFrame)); +} + + +void VISU_TimeAnimation_i::firstFrame(){ + ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::firstFrame)); +} + + +void VISU_TimeAnimation_i::lastFrame(){ + ProcessVoidEvent(new TVoidMemFunEvent(myAnim,&VISU_TimeAnimation::lastFrame)); +} + + +void VISU_TimeAnimation_i::gotoFrame(CORBA::Long theFrame){ + ProcessVoidEvent(new TVoidMemFun1ArgEvent(myAnim,&VISU_TimeAnimation::gotoFrame,theFrame)); +} + + +CORBA::Long VISU_TimeAnimation_i::getNbFields(){ + return myAnim->getNbFields(); +} + + +CORBA::Long VISU_TimeAnimation_i::getNbFrames(){ + return myAnim->getNbFrames(); +} + + +CORBA::Boolean VISU_TimeAnimation_i::isRunning(){ + return myAnim->isRunning(); +} + + +CORBA::Long VISU_TimeAnimation_i::getCurrentFrame(){ + return myAnim->getCurrentFrame(); +} + + +VISU::ScalarMap_ptr VISU_TimeAnimation_i::getPresentation(CORBA::Long theField, CORBA::Long theFrame){ + return myAnim->getPresentation(theField,theFrame); +} + + +void VISU_TimeAnimation_i::setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType){ + myAnim->setPresentationType(theFieldNum,theType); +} + + +VISU::VISUType VISU_TimeAnimation_i::getPresentationType(CORBA::Long theFieldNum){ + return myAnim->getPresentationType(theFieldNum); +} + + +void VISU_TimeAnimation_i::setSpeed(CORBA::Long theSpeed){ + myAnim->setSpeed(theSpeed); +} + + +CORBA::Long VISU_TimeAnimation_i::getSpeed(){ + return myAnim->getSpeed(); +} + + +CORBA::Boolean VISU_TimeAnimation_i::isProportional(){ + return myAnim->isProportional(); +} + + +void VISU_TimeAnimation_i::setAnimationRange(CORBA::Double theMin, CORBA::Double theMax){ + myAnim->setAnimationRange(theMin,theMax); +} + + +CORBA::Double VISU_TimeAnimation_i::getMinRange(){ + return myAnim->getMinRange(); +} + + +CORBA::Double VISU_TimeAnimation_i::getMaxRange(){ + return myAnim->getMaxRange(); +} + + +CORBA::Boolean VISU_TimeAnimation_i::isRangeDefined(){ + return myAnim->isRangeDefined(); +} + + +void VISU_TimeAnimation_i::dumpTo(const char* thePath){ + myAnim->dumpTo(thePath); +} + + +CORBA::Boolean VISU_TimeAnimation_i::isCycling(){ + return myAnim->isCycling(); +} + + +CORBA::Double VISU_TimeAnimation_i::getMinTime(){ + return myAnim->getMinTime(); +} + + +CORBA::Double VISU_TimeAnimation_i::getMaxTime(){ + return myAnim->getMaxTime(); +} + + +void VISU_TimeAnimation_i::setProportional(CORBA::Boolean theProp){ + myAnim->setProportional(theProp); +} + + +void VISU_TimeAnimation_i::setCycling(CORBA::Boolean theCycle){ + myAnim->setCycling(theCycle); +} + + diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index f5c0a07b..01de4065 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -37,9 +37,7 @@ struct FieldData }; -class VISU_TimeAnimation: public QObject, public QThread, - public virtual POA_VISU::Animation, - public virtual VISU::Base_i +class VISU_TimeAnimation: public QObject, public QThread { Q_OBJECT; public: @@ -47,7 +45,7 @@ class VISU_TimeAnimation: public QObject, public QThread, static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject); static double getTimeValue(SALOMEDS::SObject_var theTimestamp); - VISU_TimeAnimation(SALOMEDS::Study_var theStudy, VISU::View3D_ptr theView3D = VISU::View3D::_nil()); + VISU_TimeAnimation(SALOMEDS::Study_ptr theStudy, VISU::View3D_ptr theView3D = VISU::View3D::_nil()); ~VISU_TimeAnimation(); virtual VISU::VISUType GetType() { return VISU::TNONE;}; @@ -132,4 +130,64 @@ class VISU_TimeAnimation: public QObject, public QThread, VTKViewer_ViewFrame* myView; }; + +class VISU_TimeAnimation_i: public virtual POA_VISU::Animation, + public virtual VISU::Base_i +{ + VISU_TimeAnimation* myAnim; +public: + VISU_TimeAnimation_i(SALOMEDS::Study_ptr theStudy, + VISU::View3D_ptr theView3D = VISU::View3D::_nil()); + ~VISU_TimeAnimation_i(); + + virtual VISU::VISUType GetType(){ return VISU::TNONE;} + + virtual void addField(SALOMEDS::SObject_ptr theField); + + virtual CORBA::Boolean generateFrames(); + virtual void generatePresentations(CORBA::Long theFieldNum); + + virtual void clearView(); + + virtual void stopAnimation(); + virtual void startAnimation(); + virtual void nextFrame(); + virtual void prevFrame(); + virtual void firstFrame(); + virtual void lastFrame(); + virtual void gotoFrame(CORBA::Long theFrame); + + virtual CORBA::Long getNbFields(); + virtual CORBA::Long getNbFrames(); + virtual CORBA::Boolean isRunning(); + virtual CORBA::Long getCurrentFrame(); + + virtual VISU::ScalarMap_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame); + + virtual void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType); + virtual VISU::VISUType getPresentationType(CORBA::Long theFieldNum); + + virtual void setSpeed(CORBA::Long theSpeed); + virtual CORBA::Long getSpeed(); + + virtual CORBA::Boolean isProportional(); + + virtual void setAnimationRange(CORBA::Double theMin, CORBA::Double theMax); + + virtual CORBA::Double getMinRange(); + virtual CORBA::Double getMaxRange(); + virtual CORBA::Boolean isRangeDefined(); + + virtual void dumpTo(const char* thePath); + + virtual CORBA::Boolean isCycling(); + + virtual CORBA::Double getMinTime(); + virtual CORBA::Double getMaxTime(); + + virtual void setProportional(CORBA::Boolean theProp); + virtual void setCycling(CORBA::Boolean theCycle); +}; + + #endif //VISU_TIMEANIMATION_H diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index 26691ed0..65d7d1af 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -43,6 +43,8 @@ #include "VISU_ScalarBarActor.hxx" #include "VISU_Actor.h" +#include "SALOME_Event.hxx" + #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Tools.h" @@ -78,6 +80,67 @@ static int MYDELAY = 1; namespace VISU{ //=========================================================================== + typedef TVoidMemFunEvent TFrameActionEvent; + + template + class TSetBackgroundEvent: public SALOME_Event{ + TObject* myView; + const SALOMEDS::Color& myColor; + public: + TSetBackgroundEvent(TObject* theView, const SALOMEDS::Color& theColor): + myView(theView), myColor(theColor) + {} + virtual void Execute(){ + int aColor[3]; + aColor[0] = int(255.0*myColor.R); + aColor[1] = int(255.0*myColor.G); + aColor[2] = int(255.0*myColor.B); + QColor aNewColor(aColor[0],aColor[1],aColor[2]); + myView->setBackgroundColor(aNewColor); + } + }; + + + class TSavePictureEvent: public SALOME_Event{ + QWidget* myWidget; + const char* myFileName; + public: + typedef CORBA::Boolean TResult; + TResult myResult; + TSavePictureEvent(QWidget* theWidget, const char* theFileName): + myWidget(theWidget), + myFileName(theFileName), + myResult(false) + {} + virtual void Execute(){ + if(myWidget){ + QPixmap px = QPixmap::grabWindow(myWidget->winId()); + if (!QString(myFileName).isNull()) { + QString fmt = QAD_Tools::getFileExtensionFromPath(myFileName).upper(); + if (fmt.isEmpty()) + fmt = QString("BMP"); // default format + if (fmt == "JPG") + fmt = "JPEG"; + myResult = px.save(myFileName, fmt.latin1()); + } + } + } + }; + + + void RepaintView(QAD_StudyFrame* theStudyFrame); + class TRepaintViewEvent: public SALOME_Event{ + QAD_StudyFrame* myStudyFrame; + public: + TRepaintViewEvent(QAD_StudyFrame* theStudyFrame): + myStudyFrame(theStudyFrame) + {} + virtual void Execute(){ + RepaintView(myStudyFrame); + } + }; + + VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){ return dynamic_cast(theStudyFrame->getRightFrame()->getViewFrame()); } @@ -87,11 +150,15 @@ namespace VISU{ vtkCamera* GetCamera(QAD_StudyFrame* theStudyFrame){ return GetRenderer(theStudyFrame)->GetActiveCamera(); } + + void RepaintView(QAD_StudyFrame* theStudyFrame){ GetRenderer(theStudyFrame)->ResetCameraClippingRange(); GetViewFrame(theStudyFrame)->getRW()->getRenderWindow()->Render(); //GetViewFrame(theStudyFrame)->Repaint(); } + + VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){ VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame); if (!vf) return NULL; @@ -213,126 +280,153 @@ namespace VISU{ } } } - //=========================================================================== - /* - #include - class TViewManager: public QThread{ - public: - TViewManager(SALOMEDS::Study_ptr theStudy) : myStudyDocument(theStudy) {}; - virtual void run(){ - qApp->lock(); - QAD_Desktop* aDesktop = QAD_Application::getDesktop(); - QAD_Study* aStudy = aDesktop->findStudy(myStudyDocument); - if(!aStudy){ - CORBA::String_var aName = myStudyDocument->Name(); - aFileInfo.setFile(aName.in()); + + QAD_Study* CheckStudy( SALOMEDS::Study_ptr theStudy ) { + QAD_Desktop* aDesktop = QAD_Application::getDesktop(); + QAD_Study* aStudy = aDesktop->findStudy(theStudy); + if(!aStudy){ + CORBA::String_var aName = theStudy->Name(); + aFileInfo.setFile(aName.in()); + if (aFileInfo.exists()) aStudy = aDesktop->loadStudy(aFileInfo.baseName()); + else + aStudy = aDesktop->loadStudy(aName.in()); + if (!aStudy) { + MESSAGE("CheckStudy()::ERROR: Can't load study"); } - qApp->unlock(); } - SALOMEDS::Study_ptr myStudyDocument; - }; - */ + return aStudy; + } + //=========================================================================== ViewManager_i::ViewManager_i(SALOMEDS::Study_ptr theStudy) { if(MYDEBUG) MESSAGE("ViewManager_i::ViewManager_i"); - Mutex mt(myMutex,qApp,MYDELAY); myStudyDocument = SALOMEDS::Study::_duplicate(theStudy); - //TViewManager* aTViewManager = new TViewManager(theStudy); - //aTViewManager->start(); - QAD_Desktop* aDesktop = QAD_Application::getDesktop(); - QAD_Study* aStudy = aDesktop->findStudy(theStudy); - if(!aStudy){ - CORBA::String_var aName = theStudy->Name(); - aFileInfo.setFile(aName.in()); - if (aFileInfo.exists()) - aStudy = aDesktop->loadStudy(aFileInfo.baseName()); - else aStudy = aDesktop->loadStudy(aName.in()); - if (!aStudy) - MESSAGE("ViewManager_i::ERROR: Can't load study"); - } } - VISU::View3D_ptr ViewManager_i::Create3DView(){ - Mutex mt(myMutex,qApp,MYDELAY); - if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView"); - VISU::View3D_i* pView = new View3D_i(myStudyDocument); - if(pView->Create(1) != NULL) - return VISU::View3D::_duplicate(pView->_this()); - return VISU::View3D::_nil(); + VISU::View_ptr ViewManager_i::GetCurrentView(){ + class TEvent: public SALOME_Event{ + SALOMEDS::Study_ptr myStudyDocument; + public: + TEvent( SALOMEDS::Study_ptr theStudy): + myStudyDocument(theStudy) + {} + virtual void Execute(){ + if(QAD_Study* aStudy = QAD_Application::getDesktop()->findStudy( myStudyDocument )){ + if ( QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame() ) { + if(MYDEBUG) + MESSAGE("GetCurrentView::Execute - TypeView = "<getTypeView()); + if ( aStudyFrame->getTypeView() == VIEW_VTK ) { + VISU::View3D_i* pView = new View3D_i(myStudyDocument); + if(pView->Create(0)) + myResult = pView->_this(); + } else if ( aStudyFrame->getTypeView() == VIEW_PLOT2D ) { + VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument); + if(pView->Create(0)) + myResult = pView->_this(); + } + } + } + } + typedef VISU::View_var TResult; + TResult myResult; + }; + TEvent* ve = new TEvent( myStudyDocument ); + ve->process(); + TEvent::TResult aResult = ve->myResult; + ve->release(); + return aResult._retn(); } + + + class TCreateViewEvent: public SALOME_Event{ + public: + TCreateViewEvent( SALOMEDS::Study_ptr theStudy): + myStudyDocument(theStudy) + {}; + protected: + SALOMEDS::Study_ptr myStudyDocument; + }; - VISU::View_ptr ViewManager_i::GetCurrentView(){ - Mutex mt(myMutex,qApp,MYDELAY); - QAD_Study* Study = QAD_Application::getDesktop()->findStudy( myStudyDocument ); - if(MYDEBUG) MESSAGE("ViewManager_i::GetCurrent3DView - Study = "<getActiveStudyFrame() ) ) { - if(MYDEBUG) - MESSAGE("ViewManager_i::GetCurrent3DView - TypeView = "<getTypeView()); - if ( StudyFrame->getTypeView() == VIEW_VTK ) { - VISU::View3D_i* pView = new View3D_i(myStudyDocument); - if(pView->Create(0) != NULL) - return VISU::View3D::_duplicate(pView->_this()); - } - else if ( StudyFrame->getTypeView() == VIEW_PLOT2D ) { - VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument); - if(pView->Create(0) != NULL) - return VISU::XYPlot::_duplicate(pView->_this()); + template + class TCreateViewFrameEvent: public TCreateViewEvent{ + public: + typedef typename TViewFrame::TInterface TInterface; + typedef typename TInterface::_ptr_type TResult; + TResult myResult; + TCreateViewFrameEvent(SALOMEDS::Study_ptr theStudy): + TCreateViewEvent(theStudy), + myResult(TInterface::_nil()) + {} + virtual void Execute(){ + if(CheckStudy(myStudyDocument)){ + TViewFrame* pView = new TViewFrame(myStudyDocument); + if(pView->Create(1)) + myResult = pView->_this(); } } - return VISU::View::_nil(); - } + }; + + VISU::View3D_ptr ViewManager_i::Create3DView(){ + if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView"); + return ProcessEvent(new TCreateViewFrameEvent(myStudyDocument)); + } + VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){ if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot"); - Mutex mt(myMutex,qApp,MYDELAY); - VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument); - if(pView->Create(1) != NULL) - return VISU::XYPlot::_duplicate(pView->_this()); - return VISU::XYPlot::_nil(); + return ProcessEvent(new TCreateViewFrameEvent(myStudyDocument)); } VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){ + class TEvent: public TCreateViewEvent{ + Table_ptr myTable; + public: + TEvent(SALOMEDS::Study_ptr theStudy, + Table_ptr theTable): + TCreateViewEvent(theStudy), + myTable(theTable) + {} + virtual void Execute(){ + if ( CheckStudy( myStudyDocument ) ) { + VISU::TableView_i* pView = new TableView_i(myStudyDocument); + if(pView->Create(myTable) != NULL) + myResult = pView->_this(); + } + } + typedef VISU::TableView_var TResult; + TResult myResult; + }; if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView"); - Mutex mt(myMutex,qApp,MYDELAY); - VISU::TableView_i* pView = new TableView_i(myStudyDocument); - if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL) - return VISU::TableView::_duplicate(pView->_this()); - return VISU::TableView::_nil(); + TEvent* ve = new TEvent(myStudyDocument,theTable); + ve->process(); + TEvent::TResult aResult = ve->myResult; + ve->release(); + return aResult._retn(); } void ViewManager_i::Destroy(View_ptr theView){ - if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<_is_nil()); - if(theView->_is_nil()) return; - CORBA::Object_var aView = VISU::View::_narrow(theView); - if(!CORBA::is_nil(aView)){ - if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - VISU::View"<<(!CORBA::is_nil(aView))); - VISU::View_i* pView = dynamic_cast(VISU::GetServant(aView).in()); - if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - dynamic_cast"<Close(); - pView->_remove_ref(); + class TEvent: public SALOME_Event{ + View_ptr myView; + public: + TEvent(View_ptr theView): + myView(theView) + {} + virtual void Execute(){ + if(!CORBA::is_nil(myView)){ + if(VISU::View_i* pView = dynamic_cast(VISU::GetServant(myView).in())) { + pView->Close(); + pView->_remove_ref(); + } + } } - //if(pView) delete pView; - return; - } - } - - - void ViewManager_i::ProcessEvents() { - while (true) { - qApp->lock(); - qApp->syncX(); - qApp->flushX(); - qApp->processEvents(); - qApp->unlock(); - //sleep(1); - } + }; + if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<_is_nil()); + ProcessVoidEvent(new TEvent(theView)); } @@ -340,14 +434,7 @@ namespace VISU{ View_i::View_i(SALOMEDS::Study_ptr theStudy) { if(MYDEBUG) MESSAGE("View_i::View_i"); CORBA::String_var aName = theStudy->Name(); - QAD_Desktop* aDesktop = QAD_Application::getDesktop(); - myStudy = aDesktop->findStudy(theStudy); - if(!myStudy){ - aFileInfo.setFile(aName.in()); - if ( aFileInfo.exists() ) - myStudy = aDesktop->loadStudy(aFileInfo.baseName()); - else myStudy = aDesktop->loadStudy(aName.in()); - } + myStudy = CheckStudy(theStudy); if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<getStudyDocument()->FindObjectIOR(GetID()); CORBA::String_var anEntry = aSObject->GetID(); - string aString(anEntry); - if(MYDEBUG) MESSAGE("Result_i::GetEntry - "<newWindow3d("",VIEW_PLOT2D); else myStudyFrame = myStudy->getActiveStudyFrame(); myView = dynamic_cast(myStudyFrame->getRightFrame()->getViewFrame()); - Update(); + myView->Repaint(); return this; } + + void XYPlot_i::Update() { - if(MYDEBUG) MESSAGE("XYPlot_i::Update"); - Mutex mt(myMutex,qApp,MYDELAY); - myName = (const char*)(myStudyFrame->title()); - myView->Repaint(); + ProcessVoidEvent(new TVoidMemFunEvent(myView,&Plot2d_ViewFrame::Repaint)); } + + void XYPlot_i::Close(){ - if(MYDEBUG) MESSAGE("XYPlot_i::Close"); - Mutex mt(myMutex,qApp,MYDELAY); myStudyFrame->close(); } + XYPlot_i::~XYPlot_i() { if(MYDEBUG) MESSAGE("XYPlot_i::~XYPlot_i"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->close(); } + + void XYPlot_i::SetTitle(const char* theTitle){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myName = theTitle; - myStudyFrame->setCaption(myName.c_str()); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myStudyFrame,&QAD_StudyFrame::setCaption,QString(theTitle))); } char* XYPlot_i::GetTitle() { - if(MYDEBUG) MESSAGE("XYPlot_i::GetTitle"); - Mutex mt(myMutex,qApp); - myName = (const char*)(myStudyFrame->title()); - return CORBA::string_dup(myName.c_str()); + return CORBA::string_dup(myStudyFrame->title().latin1()); } + void XYPlot_i::SetSubTitle(const char* theTitle){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetSubTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setTitle(theTitle); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myView,&Plot2d_ViewFrame::setTitle,QString(theTitle))); } char* XYPlot_i::GetSubTitle() { - if(MYDEBUG) MESSAGE("XYPlot_i::GetSubTitle"); - Mutex mt(myMutex,qApp,MYDELAY); return CORBA::string_dup(myView->getTitle()); } + void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetCurveType"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setCurveType(theType); + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (myView,&Plot2d_ViewFrame::setCurveType,theType,true)); } VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){ - if(MYDEBUG) MESSAGE("XYPlot_i::GetCurveType"); - Mutex mt(myMutex,qApp); return (VISU::XYPlot::CurveType)myView->getCurveType(); } + void XYPlot_i::SetMarkerSize(CORBA::Long theSize){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetMarkerSize"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setMarkerSize(theSize); + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true)); } CORBA::Long XYPlot_i::GetMarkerSize(){ - if(MYDEBUG) MESSAGE("XYPlot_i::GetMarkerSize"); - Mutex mt(myMutex,qApp); return myView->getMarkerSize(); } + + class TEnbleGridEvent: public SALOME_Event{ + public: + typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool = true); + TEnbleGridEvent(Plot2d_ViewFrame* theView, TFun theFun, + CORBA::Boolean theMajor, CORBA::Long theNumMajor, + CORBA::Boolean theMinor, CORBA::Long theNumMinor): + myView(theView), myFun(theFun), + myMajor(theMajor), myNumMajor(theNumMajor), + myMinor(theMinor), myNumMinor(theNumMinor) + {} + virtual void Execute(){ + (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor); + } + protected: + Plot2d_ViewFrame* myView; + TFun myFun; + CORBA::Boolean myMajor, myNumMajor; + CORBA::Boolean myMinor, myNumMinor; + }; + + void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor){ - if(MYDEBUG) MESSAGE("XYPlot_i::EnableXGrid"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setXGrid(theMajor,theNumMajor,theMinor,theNumMinor); + CORBA::Boolean theMinor, CORBA::Long theNumMinor) + { + ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setXGrid, + theMajor,theNumMajor,theMinor,theNumMinor)); } void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor){ - if(MYDEBUG) MESSAGE("XYPlot_i::EnableYGrid"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setYGrid(theMajor,theNumMajor,theMinor,theNumMinor); + CORBA::Boolean theMinor, CORBA::Long theNumMinor) + { + ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setYGrid, + theMajor,theNumMajor,theMinor,theNumMinor)); } + + class TSetScaleModeEvent: public SALOME_Event{ + public: + typedef void (Plot2d_ViewFrame::* TFun)(const int, bool = true); + TSetScaleModeEvent(Plot2d_ViewFrame* theView, TFun theFun, int theScaling): + myView(theView), myFun(theFun), myScaling(theScaling) + {} + virtual void Execute(){ + (myView->*myFun)(myScaling); + } + protected: + Plot2d_ViewFrame* myView; + TFun myFun; + int myScaling; + }; + + void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetHorScaling"); - Mutex mt(myMutex,qApp,MYDELAY); - if(theScaling == VISU::LOGARITHMIC) - myView->setHorScaleMode(1); - else - myView->setHorScaleMode(0); + ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode, + theScaling == VISU::LOGARITHMIC)); } VISU::Scaling XYPlot_i::GetHorScaling(){ - if(MYDEBUG) MESSAGE("XYPlot_i::GetHorScaling"); - Mutex mt(myMutex,qApp,MYDELAY); return (VISU::Scaling)myView->getHorScaleMode(); } + void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling"); - Mutex mt(myMutex,qApp,MYDELAY); - if(theScaling == VISU::LOGARITHMIC) - myView->setVerScaleMode(1); - else - myView->setVerScaleMode(0); + ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode, + theScaling == VISU::LOGARITHMIC)); } VISU::Scaling XYPlot_i::GetVerScaling(){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling"); - Mutex mt(myMutex,qApp); return (VISU::Scaling)myView->getVerScaleMode(); } + + class TSetTitleEvent: public SALOME_Event{ + public: + typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true); + TSetTitleEvent(Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle): + myView(theView), myFun(theFun), myTitle(theTitle) + {} + virtual void Execute(){ + (myView->*myFun)(true,myTitle); + } + protected: + Plot2d_ViewFrame* myView; + TFun myFun; + const char* myTitle; + }; + + void XYPlot_i::SetXTitle(const char* theTitle){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetXTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setXTitle(true,theTitle); + ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setXTitle,theTitle)); } char* XYPlot_i::GetXTitle() { - if(MYDEBUG) MESSAGE("XYPlot_i::GetXTitle"); - Mutex mt(myMutex,qApp); return CORBA::string_dup(myView->getXTitle()); } + void XYPlot_i::SetYTitle(const char* theTitle){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetYTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setYTitle(true,theTitle); + ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setYTitle,theTitle)); } char* XYPlot_i::GetYTitle() { - if(MYDEBUG) MESSAGE("XYPlot_i::GetYTitle"); - Mutex mt(myMutex,qApp); return CORBA::string_dup(myView->getYTitle()); } + void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){ - if(MYDEBUG) MESSAGE("XYPlot_i::ShowLegend"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->showLegend(theShowing); + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (myView,&Plot2d_ViewFrame::showLegend,theShowing,true)); } + void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetBackground"); - Mutex mt(myMutex,qApp,MYDELAY); - int aColor[3]; - aColor[0] = (int)(255.0*theColor.R); - aColor[1] = (int)(255.0*theColor.G); - aColor[2] = (int)(255.0*theColor.B); - QColor aNewColor(aColor[0],aColor[1],aColor[2]); - myView->setBackgroundColor(aNewColor); + ProcessVoidEvent(new TSetBackgroundEvent(myView,theColor)); } SALOMEDS::Color XYPlot_i::GetBackground() { - if(MYDEBUG) MESSAGE("XYPlot_i::GetBackground"); - Mutex mt(myMutex,qApp); SALOMEDS::Color aColor; aColor.R = myView->backgroundColor().red()/255.0; aColor.G = myView->backgroundColor().green()/255.0; aColor.B = myView->backgroundColor().blue()/255.0; return aColor; } + void XYPlot_i::Minimize() { - if(MYDEBUG) MESSAGE("XYPlot_i::Minimize"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->showMinimized(); + ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized)); } + void XYPlot_i::Restore() { - if(MYDEBUG) MESSAGE("XYPlot_i::Restore"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->showNormal(); + ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal)); } + void XYPlot_i::Maximize() { - if(MYDEBUG) MESSAGE("XYPlot_i::Maximize"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->showMaximized(); + ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized)); } - void XYPlot_i::Display(PrsObject_ptr thePrsObj) { - if(MYDEBUG) MESSAGE("XYPlot_i::Display"); - Mutex mt(myMutex,qApp,MYDELAY); - CORBA::Object_ptr anObj = thePrsObj; - // is it Curve ? - if(Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObj).in())) { - UpdatePlot2d(myView,eDisplay,aCurve); - } - // is it Container ? - if(Container_i* aContainer = dynamic_cast(VISU::GetServant(anObj).in())) { - int nbCurves = aContainer->GetNbCurves(); - for ( int i = 1; i <= nbCurves; i++ ) { - VISU::Curve_i* aCurve = aContainer->GetCurve( i ); - if ( aCurve && aCurve->IsValid() ) { - UpdatePlot2d(myView,eDisplay,aCurve); - } + + + class TXYPlotViewEvent: public SALOME_Event{ + QAD_Study* myStudy; + Plot2d_ViewFrame* myView; + PrsObject_ptr myPrsObj; + int myDisplaing; + public: + TXYPlotViewEvent(QAD_Study* theStudy, + Plot2d_ViewFrame* theView, + PrsObject_ptr thePrsObj, + int theDisplaing): + myStudy(theStudy), + myView(theView), + myPrsObj(thePrsObj), + myDisplaing(theDisplaing) + {} + virtual void Execute(){ + // is it Curve ? + if(Curve_i* aCurve = dynamic_cast(VISU::GetServant(myPrsObj).in())) { + UpdatePlot2d(myView,myDisplaing,aCurve); } - myView->Repaint(); - } - // is it Table ? - if(Table_i* aTable = dynamic_cast(VISU::GetServant(anObj).in())) { - SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() ); - if ( !TableSO->_is_nil() ) { - SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO ); - for ( ; Iter->More(); Iter->Next() ) { - CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() ); - if( !CORBA::is_nil( childObject ) ) { - CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject ); - if( !CORBA::is_nil( aCurve ) ) - UpdatePlot2d(myView,eDisplay,dynamic_cast( VISU::GetServant(aCurve).in())); + // is it Container ? + if(Container_i* aContainer = dynamic_cast(VISU::GetServant(myPrsObj).in())) { + int nbCurves = aContainer->GetNbCurves(); + for ( int i = 1; i <= nbCurves; i++ ) { + VISU::Curve_i* aCurve = aContainer->GetCurve( i ); + if ( aCurve && aCurve->IsValid() ) { + UpdatePlot2d(myView,myDisplaing,aCurve); } } myView->Repaint(); } - } - } - void XYPlot_i::Erase(PrsObject_ptr thePrsObj) { - if(MYDEBUG) MESSAGE("XYPlot_i::Erase"); - Mutex mt(myMutex,qApp,MYDELAY); - CORBA::Object_ptr anObj = thePrsObj; - // is it Curve ? - if(Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObj).in())) { - UpdatePlot2d(myView,eErase,aCurve); - } - // is it Container ? - if(Container_i* aContainer = dynamic_cast(VISU::GetServant(anObj).in())) { - int nbCurves = aContainer->GetNbCurves(); - for ( int i = 1; i <= nbCurves; i++ ) { - VISU::Curve_i* aCurve = aContainer->GetCurve( i ); - if ( aCurve && aCurve->IsValid() ) { - UpdatePlot2d(myView,eErase,aCurve); - } - } - myView->Repaint(); - } - // is it Table ? - if(Table_i* aTable = dynamic_cast(VISU::GetServant(anObj).in())) { - SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() ); - if ( !TableSO->_is_nil() ) { - SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO ); + // is it Table ? + if(Table_i* aTable = dynamic_cast(VISU::GetServant(myPrsObj).in())) { + SALOMEDS::Study_var aStudy = myStudy->getStudyDocument(); + SALOMEDS::SObject_var TableSO = aStudy->FindObjectID( aTable->GetEntry() ); + if ( !TableSO->_is_nil() ) { + SALOMEDS::ChildIterator_var Iter = aStudy->NewChildIterator( TableSO ); for ( ; Iter->More(); Iter->Next() ) { - CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() ); - if( !CORBA::is_nil( childObject ) ) { - CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject ); - if( !CORBA::is_nil( aCurve ) ) - UpdatePlot2d(myView,eErase,dynamic_cast( VISU::GetServant(aCurve).in())); + CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() ); + if( !CORBA::is_nil( childObject ) ) { + CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject ); + if( !CORBA::is_nil( aCurve ) ) + UpdatePlot2d(myView,myDisplaing,dynamic_cast( VISU::GetServant(aCurve).in())); + } } + myView->Repaint(); } - myView->Repaint(); } } + }; + + + void XYPlot_i::Display(PrsObject_ptr thePrsObj) { + ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplay)); } - void XYPlot_i::EraseAll() { - if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->EraseAll(); + + + void XYPlot_i::Erase(PrsObject_ptr thePrsObj) { + ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eErase)); } + + void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) { - if(MYDEBUG) MESSAGE("XYPlot_i::DisplayOnly"); - Mutex mt(myMutex,qApp,MYDELAY); - CORBA::Object_ptr anObj = thePrsObj; - // is it Curve ? - if(Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObj).in())) { - UpdatePlot2d(myView,eDisplayOnly,aCurve); - } - // is it Container ? - if(Container_i* aContainer = dynamic_cast(VISU::GetServant(anObj).in())) { - int nbCurves = aContainer->GetNbCurves(); - for ( int i = 1; i <= nbCurves; i++ ) { - VISU::Curve_i* aCurve = aContainer->GetCurve( i ); - if ( aCurve && aCurve->IsValid() ) { - UpdatePlot2d(myView,eDisplayOnly,aCurve); - } - } - myView->Repaint(); - } - // is it Table ? - if(Table_i* aTable = dynamic_cast(VISU::GetServant(anObj).in())) { - SALOMEDS::SObject_var TableSO = myStudy->getStudyDocument()->FindObjectID( aTable->GetEntry() ); - if ( !TableSO->_is_nil() ) { - SALOMEDS::ChildIterator_var Iter = myStudy->getStudyDocument()->NewChildIterator( TableSO ); - for ( ; Iter->More(); Iter->Next() ) { - CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() ); - if( !CORBA::is_nil( childObject ) ) { - CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject ); - if( !CORBA::is_nil( aCurve ) ) - UpdatePlot2d(myView,eDisplayOnly,dynamic_cast( VISU::GetServant(aCurve).in())); - } - } - myView->Repaint(); - } - } + ProcessVoidEvent(new TXYPlotViewEvent(myStudy,myView,thePrsObj,eDisplayOnly)); + } + + + void XYPlot_i::EraseAll() { + ProcessVoidEvent(new TVoidMemFunEvent(myView,&Plot2d_ViewFrame::EraseAll)); } + + void XYPlot_i::FitAll() { - if(MYDEBUG) MESSAGE("XYPlot_i::FitAll"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->fitAll(); + ProcessVoidEvent(new TVoidMemFunEvent(myView,&Plot2d_ViewFrame::fitAll)); } + + CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) { - if(MYDEBUG) MESSAGE("XYPlot_i::SavePicture"); - Mutex mt(myMutex,qApp,MYDELAY); - if (!myView->getViewWidget()) - return false; - - QApplication::setOverrideCursor( Qt::waitCursor ); - QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId()); - QApplication::restoreOverrideCursor(); - - if (!QString(theFileName).isNull()) { - QApplication::setOverrideCursor( Qt::waitCursor ); - QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper(); - if (fmt.isEmpty()) - fmt = QString("BMP"); // default format - if (fmt == "JPG") - fmt = "JPEG"; - bool bOk = px.save(theFileName, fmt.latin1()); - QApplication::restoreOverrideCursor(); - return bOk; - } - return false; + TSavePictureEvent* ve = new TSavePictureEvent(myView->getViewWidget(),theFileName); + ve->process(); + TSavePictureEvent::TResult aResult = ve->myResult; + ve->release(); + return aResult; } + //=========================================================================== TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {} - Storable* TableView_i::Create(VISU::Table_var theTable){ + Storable* TableView_i::Create(VISU::Table_ptr theTable){ if(MYDEBUG) MESSAGE("TableView_i::Create - "<<(!theTable->_is_nil())); - Mutex mt(myMutex,qApp,MYDELAY); if(!theTable->_is_nil()){ - VISU::Table_i* table = dynamic_cast(VISU::GetServant(theTable.in()).in()); + VISU::Table_i* table = dynamic_cast(VISU::GetServant(theTable).in()); if(MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = "<getStudyDocument()->FindObjectID(table->GetObjectEntry()); @@ -718,36 +765,36 @@ namespace VISU{ SALOMEGUI_TableDlg::ttAuto, Qt::Vertical); myView->show(); - myName = (myView->caption()).latin1(); return this; } } } return NULL; } + + + TableView_i::~TableView_i() { + if(MYDEBUG) MESSAGE("TableView_i::~TableView_i"); + delete myView; + } + + void TableView_i::SetTitle(const char* theTitle){ - if(MYDEBUG) MESSAGE("TableView_i::SetTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myName = theTitle; - myView->setCaption(myName.c_str()); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myView,&SALOMEGUI_TableDlg::setCaption,QString(theTitle))); } + + char* TableView_i::GetTitle() { - if(MYDEBUG) MESSAGE("TableView_i::GetTitle"); - Mutex mt(myMutex,qApp); - myName = (myView->caption()).latin1(); - return CORBA::string_dup(myName.c_str()); + return CORBA::string_dup(myView->caption().latin1()); } + + void TableView_i::Close(){ - if(MYDEBUG) MESSAGE("TableView_i::Close"); - Mutex mt(myMutex,qApp,MYDELAY); myView->close(); } - TableView_i::~TableView_i() { - if(MYDEBUG) MESSAGE("TableView_i::~TableView_i"); - Mutex mt(myMutex,qApp,MYDELAY); - Close(); - delete myView; - } + + //=========================================================================== int View3D_i::myNbViewParams = 0; const string View3D_i::myComment = "VIEW3D"; @@ -766,131 +813,86 @@ namespace VISU{ myStudyFrame = myStudy->newWindow3d("",VIEW_VTK); else myStudyFrame = myStudy->getActiveStudyFrame(); + return this; + } - //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor); - - return this; //Build(false); - } - -// Storable* View3D_i::Build(int theRestoring){ -// if(MYDEBUG) MESSAGE("View3D_i::Build"); -// if(theRestoring){ -// myStudyFrame->setTitle(myName.c_str()); -// SetBackground(myColor); -// SetPointOfView(myPosition); -// SetViewUp(myViewUp); -// SetFocalPoint(myFocalPnt); -// SetParallelScale(myParallelScale); -// ScaleView(VISU::View3D::XAxis,myScaleFactor[0]); -// ScaleView(VISU::View3D::YAxis,myScaleFactor[1]); -// ScaleView(VISU::View3D::ZAxis,myScaleFactor[2]); -// RepaintView(myStudyFrame); -// }else{ -// Update(); - -// SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(myStudyDocument); -// CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID()); -// string anEntry = CreateAttributes(myStudyDocument,aSComponentEntry,"",anIOR,myName.c_str(),"",GetComment()); - -// } -// return this; -// } void View3D_i::Update(){ - if(MYDEBUG) MESSAGE("View3D_i::Update"); - Mutex mt(myMutex,qApp,MYDELAY); - myName = (const char*)myStudyFrame->title(); -// myColor = GetBackground(); -// GetCamera(myStudyFrame)->GetPosition(myPosition); -// GetCamera(myStudyFrame)->GetViewUp(myViewUp); -// GetCamera(myStudyFrame)->GetFocalPoint(myFocalPnt); -// myParallelScale = GetCamera(myStudyFrame)->GetParallelScale(); - //RepaintView(myStudyFrame); - - //GetViewFrame(myStudyFrame)->GetScale(myScaleFactor); - - VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame); - vtkRenderer* Renderer = vf->getRenderer(); - vtkActorCollection* theActors = Renderer->GetActors(); - theActors->InitTraversal(); - vtkActor *actor; - while(actor = theActors->GetNextActor()){ - if(VISU_Actor* anActor = dynamic_cast(actor)){ - VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d(); - if(anActor->GetVisibility() && aPrs3d){ - aPrs3d->Update(); - aPrs3d->UpdateActor(anActor); + class TEvent: public SALOME_Event{ + QAD_StudyFrame* myStudyFrame; + public: + TEvent(QAD_StudyFrame* theStudyFrame): + myStudyFrame(theStudyFrame) + {} + virtual void Execute(){ + VTKViewer_ViewFrame* vf = GetViewFrame(myStudyFrame); + vtkRenderer* Renderer = vf->getRenderer(); + vtkActorCollection* theActors = Renderer->GetActors(); + theActors->InitTraversal(); + vtkActor *actor; + while(actor = theActors->GetNextActor()){ + if(VISU_Actor* anActor = dynamic_cast(actor)){ + VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d(); + if(anActor->GetVisibility() && aPrs3d){ + aPrs3d->Update(); + aPrs3d->UpdateActor(anActor); + } + } } + RepaintView(myStudyFrame); } - } + }; + ProcessVoidEvent(new TEvent(myStudyFrame)); } + CORBA::Boolean View3D_i::SavePicture(const char* theFileName) { - if(MYDEBUG) MESSAGE("View3D_i::SavePicture"); - Mutex mt(myMutex,qApp,MYDELAY); - if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()) - return false; - - QApplication::setOverrideCursor( Qt::waitCursor ); - QPixmap px = QPixmap::grabWindow(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()->winId()); - QApplication::restoreOverrideCursor(); - - if (!QString(theFileName).isNull()) { - QApplication::setOverrideCursor( Qt::waitCursor ); - QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper(); - if (fmt.isEmpty()) - fmt = QString("BMP"); // default format - if (fmt == "JPG") - fmt = "JPEG"; - bool bOk = px.save(theFileName, fmt.latin1()); - QApplication::restoreOverrideCursor(); - return bOk; - } - return false; + TSavePictureEvent* ve = new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName); + ve->process(); + TSavePictureEvent::TResult aResult = ve->myResult; + ve->release(); + return aResult; } - CORBA::Boolean View3D_i::SaveViewParams(const char* theName){ - if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint"); - Mutex mt(myMutex,qApp,MYDELAY); + + bool View3D_i::SaveViewParams(QAD_StudyFrame* theStudyFrame, const char* theName){ + QAD_Study* aStudy = theStudyFrame->getStudy(); + SALOMEDS::Study_var aStudyDoc = aStudy->getStudyDocument(); if ( theName ) { SALOMEDS::Study::ListOfSObject_var aList = - myStudy->getStudyDocument()->FindObjectByName(theName,"VISU"); + aStudyDoc->FindObjectByName(theName,"VISU"); SALOMEDS::GenericAttribute_var anAttr; int iEnd = aList->length(); for(int i = 0; i < iEnd; i++){ SALOMEDS::SObject_var anObj = aList[i]; CORBA::String_var aString = anObj->GetID(); string anEntry(aString); - if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - anEntry = "<Value(); string aComm(aString); if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint - aComm = "<= 0){ - aCmnt->SetValue(ToString().c_str()); - return 1; + aCmnt->SetValue(ToString(theStudyFrame).c_str()); + return true; } } } } - QString newName; - if ( theName ) - newName = QString( theName ); - else - newName = QString( GenerateViewParamsName() ); - SALOMEDS::SComponent_var aSComponent = - FindOrCreateVisuComponent(myStudy->getStudyDocument()); - CORBA::String_var aSComponentEntry = aSComponent->GetID(), anIOR(GetID()); - string anEntry = CreateAttributes(myStudy->getStudyDocument(),aSComponentEntry,"","",newName.latin1(),"",ToString().c_str()); - return 1; + SALOMEDS::SComponent_var aSComponent = FindOrCreateVisuComponent(aStudyDoc); + CORBA::String_var aSComponentEntry = aSComponent->GetID(); + string anEntry = CreateAttributes(aStudyDoc,aSComponentEntry.in(),"","",theName,"",ToString(theStudyFrame).c_str()); + return true; + } + CORBA::Boolean View3D_i::SaveViewParams(const char* theName){ + return SaveViewParams(myStudyFrame,theName); } - CORBA::Boolean View3D_i::RestoreViewParams(const char* theName){ - if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - "<getStudyDocument()->FindObjectByName(theName,"VISU"); + theStudyFrame->getStudy()->getStudyDocument()->FindObjectByName(theName,"VISU"); SALOMEDS::GenericAttribute_var anAttr; int iEnd = aList->length(); if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - iEnd = "<= 0 ) { if(MYDEBUG) MESSAGE("View3D_i::RestoreViewPoint - aComm = "<process(); + TEvent::TResult aResult = ve->myResult; + ve->release(); + return aResult; + } + + + void View3D_i::Restore(QAD_StudyFrame* theStudyFrame, const Storable::TRestoringMap& theMap){ SALOMEDS::Color aColor; aColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); aColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble(); @@ -945,112 +970,96 @@ namespace VISU{ aScaleFactor[1] = VISU::Storable::FindValue(theMap,"myScaleFactor[1]").toDouble(); aScaleFactor[2] = VISU::Storable::FindValue(theMap,"myScaleFactor[2]").toDouble(); - //myStudyFrame->setTitle(myName.c_str()); - SetBackground(aColor); - SetPointOfView(aPosition); - SetViewUp(aViewUp); - SetFocalPoint(aFocalPnt); - SetParallelScale(aParallelScale); - ScaleView(VISU::View3D::XAxis,aScaleFactor[0]); - ScaleView(VISU::View3D::YAxis,aScaleFactor[1]); - ScaleView(VISU::View3D::ZAxis,aScaleFactor[2]); - RepaintView(myStudyFrame); - return this; + SetBackground(theStudyFrame,aColor); + SetPointOfView(theStudyFrame,aPosition); + SetViewUp(theStudyFrame,aViewUp); + SetFocalPoint(theStudyFrame,aFocalPnt); + SetParallelScale(theStudyFrame,aParallelScale); + ScaleView(theStudyFrame,VISU::View3D::XAxis,aScaleFactor[0]); + ScaleView(theStudyFrame,VISU::View3D::YAxis,aScaleFactor[1]); + ScaleView(theStudyFrame,VISU::View3D::ZAxis,aScaleFactor[2]); } - void View3D_i::ToStream(std::ostringstream& theStr) { + string View3D_i::ToString(QAD_StudyFrame* theStudyFrame){ + ostringstream strOut; + Storable::DataToStream( strOut, "myComment", myComment.c_str() ); + ToStream(theStudyFrame,strOut); + strOut<GetBackground(backint); + GetRenderer(theStudyFrame)->GetBackground(backint); Storable::DataToStream(theStr,"myColor.R",backint[0]); Storable::DataToStream(theStr,"myColor.G",backint[1]); Storable::DataToStream(theStr,"myColor.B",backint[2]); double aPosition[3]; - GetPointOfView(myStudyFrame,aPosition); + GetPointOfView(theStudyFrame,aPosition); Storable::DataToStream(theStr,"myPosition[0]",aPosition[0]); Storable::DataToStream(theStr,"myPosition[1]",aPosition[1]); Storable::DataToStream(theStr,"myPosition[2]",aPosition[2]); double aFocalPnt[3]; - GetFocalPoint(myStudyFrame,aFocalPnt); + GetFocalPoint(theStudyFrame,aFocalPnt); Storable::DataToStream(theStr,"myFocalPnt[0]",aFocalPnt[0]); Storable::DataToStream(theStr,"myFocalPnt[1]",aFocalPnt[1]); Storable::DataToStream(theStr,"myFocalPnt[2]",aFocalPnt[2]); double aViewUp[3]; - GetCamera(myStudyFrame)->GetViewUp(aViewUp); + GetCamera(theStudyFrame)->GetViewUp(aViewUp); Storable::DataToStream(theStr,"myViewUp[0]",aViewUp[0]); Storable::DataToStream(theStr,"myViewUp[1]",aViewUp[1]); Storable::DataToStream(theStr,"myViewUp[2]",aViewUp[2]); - Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(myStudyFrame)); + Storable::DataToStream(theStr,"myParallelScale",GetParallelScale(theStudyFrame)); double aScaleFactor[3]; - GetViewFrame(myStudyFrame)->GetScale(aScaleFactor); + GetViewFrame(theStudyFrame)->GetScale(aScaleFactor); Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]); Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]); Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]); } + void View3D_i::ToStream(std::ostringstream& theStr) { + ToStream(myStudyFrame,theStr); + } -// Storable* VISU::View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy, -// const char* thePrefix, const Storable::TRestoringMap& theMap) -// { -// try{ -// View3D_i* pView3D = new View3D_i(theStudy); -// return pView3D->Restore(theMap); -// }catch(std::logic_error& exc){ -// MESSAGE("Follow exception was accured :\n"<close(); } View3D_i::~View3D_i() { if(MYDEBUG) MESSAGE("View3D_i::~View3D_i"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->close(); } //-------------------- View interface -------------------- void View3D_i::SetTitle(const char* theTitle){ - if(MYDEBUG) MESSAGE("View3D_i::SetTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myName = theTitle; - myStudyFrame->setTitle(myName.c_str()); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myStudyFrame,&QAD_StudyFrame::setTitle,QString(theTitle))); } char* View3D_i::GetTitle() { - if(MYDEBUG) MESSAGE("View3D_i::GetTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myName = (const char*)myStudyFrame->title(); - return CORBA::string_dup(myName.c_str()); + return CORBA::string_dup(myStudyFrame->title().latin1()); } + void View3D_i::SetBackground(QAD_StudyFrame* theStudyFrame, const SALOMEDS::Color& theColor) { int aColor[3]; - aColor[0] = (int)(255.0*theColor.R); - aColor[1] = (int)(255.0*theColor.G); - aColor[2] = (int)(255.0*theColor.B); + aColor[0] = int(255.0*theColor.R); + aColor[1] = int(255.0*theColor.G); + aColor[2] = int(255.0*theColor.B); QColor aNewColor(aColor[0],aColor[1],aColor[2]); GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor); } void View3D_i::SetBackground(const SALOMEDS::Color& theColor) { - if(MYDEBUG) MESSAGE("View3D_i::SetBackground"); - Mutex mt(myMutex,qApp,MYDELAY); - //myColor.R = theColor.R; myColor.G = theColor.G; myColor.B = theColor.B; - SetBackground(myStudyFrame,theColor); + ProcessVoidEvent(new TSetBackgroundEvent(GetViewFrame(myStudyFrame),theColor)); } + SALOMEDS::Color View3D_i::GetBackground(QAD_StudyFrame* theStudyFrame) { SALOMEDS::Color aColor; float backint[3]; @@ -1059,160 +1068,219 @@ namespace VISU{ return aColor; } SALOMEDS::Color View3D_i::GetBackground() { - if(MYDEBUG) MESSAGE("View3D_i::GetBackground"); - Mutex mt(myMutex,qApp,MYDELAY); - //myColor = GetBackground(myStudyFrame); - return GetBackground(myStudyFrame); //myColor; + return GetBackground(myStudyFrame); } + void View3D_i::Minimize() { - if(MYDEBUG) MESSAGE("View3D_i::Minimize"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->showMinimized(); + ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized)); } void View3D_i::Restore() { - if(MYDEBUG) MESSAGE("View3D_i::Restore"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->showNormal(); + ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal)); } void View3D_i::Maximize() { - if(MYDEBUG) MESSAGE("View3D_i::Maximize"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->showMaximized(); + ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized)); } + + //=========================================================================== + class TUpdateViewerEvent: public SALOME_Event{ + QAD_StudyFrame* myStudyFrame; + Prs3d_i* myPrs3d; + int myDisplaing; + public: + TUpdateViewerEvent(QAD_StudyFrame* theStudyFrame, + Prs3d_i* thePrs3d, + int theDisplaing): + myStudyFrame(theStudyFrame), + myPrs3d(thePrs3d), + myDisplaing(theDisplaing) + {} + virtual void Execute(){ + UpdateViewer(myStudyFrame,myDisplaing,myPrs3d); + } + }; + void View3D_i::EraseAll() { if(MYDEBUG) MESSAGE("View3D_i::EraseAll"); - Mutex mt(myMutex,qApp,MYDELAY); - UpdateViewer(myStudyFrame,eEraseAll); + ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eEraseAll)); } + void View3D_i::DisplayAll() { if(MYDEBUG) MESSAGE("View3D_i::DisplayAll"); - Mutex mt(myMutex,qApp,MYDELAY); - UpdateViewer(myStudyFrame,eDisplayAll); + ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,NULL,eDisplayAll)); } + void View3D_i::Erase(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("View3D_i::Erase"); - Mutex mt(myMutex,qApp,MYDELAY); CORBA::Object_ptr anObj = thePrsObj; - if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in())) - UpdateViewer(myStudyFrame,eErase,aPrs); + if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in())){ + ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eErase)); + } } + void View3D_i::Display(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("View3D_i::Display"); - Mutex mt(myMutex,qApp,MYDELAY); CORBA::Object_ptr anObj = thePrsObj; - if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in())) - UpdateViewer(myStudyFrame,eDisplay,aPrs); + if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in())){ + ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplay)); + } } + void View3D_i::DisplayOnly(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("View3D_i::DisplayOnly"); - Mutex mt(myMutex,qApp,MYDELAY); CORBA::Object_ptr anObj = thePrsObj; - if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in())) - UpdateViewer(myStudyFrame,eDisplayOnly,aPrs); + if(Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(anObj).in())){ + ProcessVoidEvent(new TUpdateViewerEvent(myStudyFrame,aPrs,eDisplayOnly)); + } } //-------------------- View3D interface -------------------- void View3D_i::FitAll() { - if(MYDEBUG) MESSAGE("View3D_i::FitAll"); - Mutex mt(myMutex,qApp,MYDELAY); - GetViewFrame(myStudyFrame)->onViewFitAll(); + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll)); Update(); } + + void View3D_i::SetView(VISU::View3D::ViewType theType) { - if(MYDEBUG) MESSAGE("View3D_i::SetView"); - Mutex mt(myMutex,qApp,MYDELAY); switch(theType){ - case VISU::View3D::FRONT : GetViewFrame(myStudyFrame)->onViewFront(); break; - case VISU::View3D::BACK : GetViewFrame(myStudyFrame)->onViewBack(); break; - case VISU::View3D::LEFT : GetViewFrame(myStudyFrame)->onViewLeft(); break; - case VISU::View3D::RIGHT : GetViewFrame(myStudyFrame)->onViewRight(); break; - case VISU::View3D::TOP : GetViewFrame(myStudyFrame)->onViewTop(); break; - case VISU::View3D::BOTTOM : GetViewFrame(myStudyFrame)->onViewBottom(); break; + case VISU::View3D::FRONT : + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront)); + break; + case VISU::View3D::BACK : + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack)); + break; + case VISU::View3D::LEFT : + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft)); + break; + case VISU::View3D::RIGHT : + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight)); + break; + case VISU::View3D::TOP : + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop)); + break; + case VISU::View3D::BOTTOM : + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom)); + break; } Update(); } + + class TSet3DViewParamEvent: public SALOME_Event{ + public: + typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, const CORBA::Double theParam[3]); + TSet3DViewParamEvent(TFun theFun, + QAD_StudyFrame* theStudyFrame, + const CORBA::Double theParam[3]): + myFun(theFun), + myStudyFrame(theStudyFrame), + myParam(theParam) + {} + virtual void Execute(){ + myFun(myStudyFrame,myParam); + } + private: + TFun myFun; + QAD_StudyFrame* myStudyFrame; + const CORBA::Double* myParam; + }; + + void View3D_i::SetPointOfView(QAD_StudyFrame* theStudyFrame, const CORBA::Double thePosition[3]) { GetCamera(theStudyFrame)->SetPosition(thePosition); } - void View3D_i::SetPointOfView(const VISU::View3D::XYZ theCoord) { + void View3D_i::SetPointOfView(const VISU::View3D::XYZ thePosition) { if(MYDEBUG) MESSAGE("View3D_i::SetPointOfView"); - Mutex mt(myMutex,qApp,MYDELAY); - //VISU::View3D::XYZ_copy(myPosition,theCoord); - SetPointOfView(myStudyFrame, theCoord); + ProcessVoidEvent(new TSet3DViewParamEvent(&SetPointOfView,myStudyFrame,thePosition)); } + void View3D_i::GetPointOfView(QAD_StudyFrame* theStudyFrame, CORBA::Double thePosition[3]) { GetCamera(theStudyFrame)->GetPosition(thePosition); } VISU::View3D::XYZ_slice* View3D_i::GetPointOfView() { if(MYDEBUG) MESSAGE("View3D_i::GetPointOfView"); - Mutex mt(myMutex,qApp,MYDELAY); CORBA::Double aPosition[3]; GetPointOfView(myStudyFrame,aPosition); return VISU::View3D::XYZ_dup(aPosition); } + void View3D_i::SetViewUp(QAD_StudyFrame* theStudyFrame, const CORBA::Double theViewUp[3]) { GetCamera(theStudyFrame)->SetViewUp(theViewUp); } - void View3D_i::SetViewUp(const VISU::View3D::XYZ theDir) { + void View3D_i::SetViewUp(const VISU::View3D::XYZ theViewUp) { if(MYDEBUG) MESSAGE("View3D_i::SetViewUp"); - Mutex mt(myMutex,qApp,MYDELAY); - //VISU::View3D::XYZ_copy(myViewUp,theDir); - SetViewUp(myStudyFrame, theDir); + ProcessVoidEvent(new TSet3DViewParamEvent(&SetViewUp,myStudyFrame,theViewUp)); } + void View3D_i::GetViewUp(QAD_StudyFrame* theStudyFrame, CORBA::Double theViewUp[3]) { GetCamera(theStudyFrame)->GetViewUp(theViewUp); } VISU::View3D::XYZ_slice* View3D_i::GetViewUp() { if(MYDEBUG) MESSAGE("View3D_i::GetViewUp"); - Mutex mt(myMutex,qApp,MYDELAY); CORBA::Double aViewUp[3]; GetCamera(myStudyFrame)->GetViewUp(aViewUp); return VISU::View3D::XYZ_dup(aViewUp); } + void View3D_i::SetFocalPoint(QAD_StudyFrame* theStudyFrame, const CORBA::Double theFocalPnt[3]) { GetCamera(theStudyFrame)->SetFocalPoint(theFocalPnt); } void View3D_i::SetFocalPoint(const VISU::View3D::XYZ theCoord) { if(MYDEBUG) MESSAGE("View3D_i::SetFocalPoint"); - Mutex mt(myMutex,qApp,MYDELAY); - //VISU::View3D::XYZ_copy(myFocalPnt,theCoord); - SetFocalPoint(myStudyFrame,theCoord); + ProcessVoidEvent(new TSet3DViewParamEvent(&SetFocalPoint,myStudyFrame,theCoord)); } + void View3D_i::GetFocalPoint(QAD_StudyFrame* theStudyFrame, CORBA::Double theFocalPnt[3]) { GetCamera(theStudyFrame)->GetFocalPoint(theFocalPnt); } VISU::View3D::XYZ_slice* View3D_i::GetFocalPoint() { if(MYDEBUG) MESSAGE("View3D_i::GetFocalPoint"); - Mutex mt(myMutex,qApp,MYDELAY); CORBA::Double aFocalPnt[3]; GetFocalPoint(myStudyFrame,aFocalPnt); return VISU::View3D::XYZ_dup(aFocalPnt); } + + class TSetViewParamEvent: public SALOME_Event{ + public: + typedef void (*TFun)(QAD_StudyFrame* theStudyFrame, CORBA::Double theParam); + TSetViewParamEvent(TFun theFun, + QAD_StudyFrame* theStudyFrame, + CORBA::Double theParam): + myFun(theFun), + myStudyFrame(theStudyFrame), + myParam(theParam) + {} + virtual void Execute(){ + myFun(myStudyFrame,myParam); + } + private: + TFun myFun; + QAD_StudyFrame* myStudyFrame; + CORBA::Double myParam; + }; + + void View3D_i::SetParallelScale(QAD_StudyFrame* theStudyFrame, CORBA::Double theScale) { GetCamera(theStudyFrame)->SetParallelScale(theScale); } void View3D_i::SetParallelScale(CORBA::Double theScale) { if(MYDEBUG) MESSAGE("View3D_i::SetParallelScale"); - Mutex mt(myMutex,qApp,MYDELAY); - //myParallelScale = theScale; - SetParallelScale(myStudyFrame, theScale); + ProcessVoidEvent(new TSetViewParamEvent(&SetParallelScale,myStudyFrame,theScale)); } + CORBA::Double View3D_i::GetParallelScale(QAD_StudyFrame* theStudyFrame) { return GetCamera(theStudyFrame)->GetParallelScale(); } CORBA::Double View3D_i::GetParallelScale() { if(MYDEBUG) MESSAGE("View3D_i::GetParallelScale"); - Mutex mt(myMutex,qApp); return GetParallelScale(myStudyFrame); } @@ -1223,18 +1291,107 @@ namespace VISU{ aScaleFactor[theAxis] = theParam; aViewFrame->SetScale(aScaleFactor); } + + void SetScaleView(QAD_StudyFrame* theStudyFrame, const CORBA::Double theScale[3]){ + double aScale[3] = {theScale[0], theScale[1], theScale[2]}; + GetViewFrame(theStudyFrame)->SetScale(aScale); + } void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) { if(MYDEBUG) MESSAGE("View3D_i::ScaleView"); - Mutex mt(myMutex,qApp); - //myScaleFactor[theAxis] = theParam; - ScaleView(myStudyFrame,theAxis,theParam); + double aScale[3]; + GetViewFrame(myStudyFrame)->GetScale(aScale); + aScale[theAxis] = theParam; + ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,myStudyFrame,aScale)); } void View3D_i::RemoveScale() { if(MYDEBUG) MESSAGE("View3D_i::RemoveScale"); - Mutex mt(myMutex,qApp); - double aScaleFactor[]={1,1,1}; - //myScaleFactor[0] = myScaleFactor[0] = myScaleFactor[0] = 1.0; - GetViewFrame(myStudyFrame)->SetScale(aScaleFactor); + double aScale[3] = {1.0, 1.0, 1.0}; + 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 c5189783..b399434d 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -51,12 +51,11 @@ namespace VISU{ virtual ~ViewManager_i() {}; virtual VISU::VISUType GetType() { return VISU::TVIEWMANAGER;}; - virtual View3D_ptr Create3DView(); - virtual View_ptr GetCurrentView(); + virtual View3D_ptr Create3DView(); + virtual View_ptr GetCurrentView(); virtual TableView_ptr CreateTableView(VISU::Table_ptr theTable); - virtual XYPlot_ptr CreateXYPlot(); - virtual void Destroy(View_ptr theView); - virtual void ProcessEvents(); + virtual XYPlot_ptr CreateXYPlot(); + virtual void Destroy(View_ptr theView); protected: SALOMEDS::Study_var myStudyDocument; @@ -68,7 +67,6 @@ namespace VISU{ { protected: QAD_Study* myStudy; - string myName; public: View_i(SALOMEDS::Study_ptr theStudy); virtual ~View_i(); @@ -90,7 +88,7 @@ namespace VISU{ virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; public: - virtual const char* View_i::GetEntry(); + virtual std::string View_i::GetEntry(); }; //=========================================================================== @@ -98,6 +96,7 @@ namespace VISU{ public virtual View_i { public: + typedef VISU::XYPlot TInterface; XYPlot_i(SALOMEDS::Study_ptr theStudy); virtual ~XYPlot_i(); virtual VISU::VISUType GetType() { return VISU::TXYPLOT;}; @@ -160,6 +159,7 @@ namespace VISU{ public virtual View_i { public: + typedef VISU::TableView TInterface; TableView_i(SALOMEDS::Study_ptr theStudy); virtual ~TableView_i(); virtual VISU::VISUType GetType() { return VISU::TTABLEVIEW;}; @@ -171,7 +171,7 @@ namespace VISU{ protected: SALOMEGUI_TableDlg* myView; public: - virtual Storable* Create(VISU::Table_var theTable); + virtual Storable* Create(VISU::Table_ptr theTable); }; //=========================================================================== @@ -179,6 +179,7 @@ namespace VISU{ public virtual View_i { public: + typedef VISU::View3D TInterface; View3D_i(SALOMEDS::Study_ptr theStudy); virtual ~View3D_i(); virtual VISU::VISUType GetType() { return VISU::TVIEW3D;}; @@ -237,29 +238,29 @@ namespace VISU{ virtual void ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam); virtual void RemoveScale(); - virtual QString GenerateViewParamsName(); + static std::string ToString(QAD_StudyFrame* theStudyFrame); + static void ToStream(QAD_StudyFrame* theStudyFrame, std::ostringstream& theStr); + static bool SaveViewParams(QAD_StudyFrame* theStudyFrame, const char* theName); virtual CORBA::Boolean SaveViewParams(const char* theName); + static QString GenerateViewParamsName(); + + static void Restore(QAD_StudyFrame* theStudyFrame, const Storable::TRestoringMap& theMap); + static bool RestoreViewParams(QAD_StudyFrame* theStudyFrame, const char* theName); virtual CORBA::Boolean RestoreViewParams(const char* theName); virtual void Close(); + protected: QAD_StudyFrame* myStudyFrame; - //SALOMEDS::Color myColor; - //CORBA::Double myPosition[3], myFocalPnt[3], myViewUp[3], myParallelScale, myScaleFactor[3]; - - //Storable* Build(int theRestoring); static int myNbViewParams; public: virtual Storable* Create(int theNew); - virtual Storable* Restore(const Storable::TRestoringMap& theMap) ; virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; static const string myComment; QAD_StudyFrame* GetStudyFrame() const { return myStudyFrame;} }; - //Storable* View3DRestore(SALOMEDS::SComponent_var& theSComponent, SALOMEDS::Study_var& theStudy, - // const char* thePrefix, const Storable::TRestoringMap& theMap); VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame); vtkRenderer* GetRenderer(QAD_StudyFrame* theStudyFrame); diff --git a/src/VISU_SWIG/Makefile.in b/src/VISU_SWIG/Makefile.in index ff40e7bc..d4b0ac36 100644 --- a/src/VISU_SWIG/Makefile.in +++ b/src/VISU_SWIG/Makefile.in @@ -44,7 +44,7 @@ SWIG_DEF = libVISU_Swig.i EXPORT_PYSCRIPTS = libVISU_Swig.py batchmode_visu.py batchmode_visu_table.py batchmode_visu_view3d.py \ visu_med.py visu_view3d.py visu.py visu_gui.py visu_prs_example.py\ visu_table.py visu_big_table.py visu_view.py \ - visu_swig_test.py + visu_swig_test.py test_events.py batch_test_events.py EXPORT_SHAREDPYSCRIPTS = VISU_shared_modules.py LIB_CLIENT_IDL = diff --git a/src/VISU_SWIG/batch_test_events.py b/src/VISU_SWIG/batch_test_events.py new file mode 100644 index 00000000..df7f3c3c --- /dev/null +++ b/src/VISU_SWIG/batch_test_events.py @@ -0,0 +1,14 @@ +############################################################### +# +# File : batch_test_events.py +# Description : Test postEvent() functionality for VISU module +# +############################################################### + +import batchmode_visu + +for i in range ( 10 ): + batchmode_visu.myVisu.CreateTestView() + for j in range ( 10 ): + batchmode_visu.myVisu.ShowTestObject(); + diff --git a/src/VISU_SWIG/batchmode_visu_view.py b/src/VISU_SWIG/batchmode_visu_view.py new file mode 100644 index 00000000..4bc74a8b --- /dev/null +++ b/src/VISU_SWIG/batchmode_visu_view.py @@ -0,0 +1,57 @@ +# VISU VISU_SWIG : binding of C++ implementation and Python +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : test_table.py +# Author : Alexey Petrov +# Module : VISU +# $Header: + +from VISU import * +from batchmode_visu_table import * + +myViewMan = myVisu.GetViewManager() + +myTable = myViewMan.CreateTableView(myVisuTableReal) +myTitle = myTable.GetTitle() +myTable.SetTitle('Changed Title') + +myPlot = myViewMan.CreateXYPlot() +myTitle = myPlot.GetTitle() +myPlot.SetTitle('Change the title from python') + +mySubTitle = myPlot.GetSubTitle() +myPlot.SetSubTitle(myTitle) + +myXTitle = myPlot.GetXTitle() +myYTitle = myPlot.GetYTitle() +myPlot.SetXTitle(myYTitle) +myPlot.SetYTitle(myXTitle) + +myPlot.GetMarkerSize() +myPlot.SetMarkerSize(20) +myPlot.GetMarkerSize() +myPlot.ShowLegend(0) + +myPlot.SetCurveType(VISU.XYPlot.POINTS) +myPlot.SetCurveType(VISU.XYPlot.MULTYLINE) +myPlot.GetCurveType() +myPlot.SetCurveType(VISU.XYPlot.SPLINE) + +myPlot.SetHorScaling(VISU.LOGARITHMIC) +myPlot.EnableXGrid(1,3,1,4) +myPlot.SetHorScaling(VISU.LINEAR) +myPlot.EnableXGrid(1,10,1,10) +myPlot.GetHorScaling() + +myPlot.SetVerScaling(VISU.LOGARITHMIC) +myPlot.GetVerScaling() +myPlot.EnableYGrid(1,2,1,10) + +myPlot.ShowLegend(1) +myPlot.SetMarkerSize(5) +myPlot.GetMarkerSize() + +myPlot.Display(myContainer) diff --git a/src/VISU_SWIG/batchmode_visu_view3d.py b/src/VISU_SWIG/batchmode_visu_view3d.py index 33f8d269..0d41aa6d 100644 --- a/src/VISU_SWIG/batchmode_visu_view3d.py +++ b/src/VISU_SWIG/batchmode_visu_view3d.py @@ -8,78 +8,261 @@ # Module : VISU import os -import batchmode_visu +import time +import math import VISU import SALOMEDS +from batchmode_visu import * + +aDelay = 0 #mySession = batchmode_visu.mySession -myVisu = batchmode_visu.myVisu + +myViewManager = myVisu.GetViewManager(); + +myView = myViewManager.Create3DView(); +myView.SetTitle("The window will be soon destroyed!") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +myView.Maximize() +print "myView.Maximize()" +time.sleep(aDelay) + +myView.Restore() +print "myView.Restore()" +time.sleep(aDelay) + +myView.Minimize() +print "myView.Minimize()" +time.sleep(aDelay) + +myViewManager.Destroy(myView) +print "myViewManager.Destroy(myView)" +time.sleep(aDelay) + + medFile = "fra.med" myFieldName = "VITESSE"; -#medFile = "minimail.dat" -#myFieldName = "Pressures"; - -#medFile = "brideResultats.dat" -#myFieldName = "VM_Elem."; +aMeshName ="LE VOLUME" +anEntity = VISU.NODE +aTimeStampId = 1 medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile myResult = myVisu.ImportFile(medFile) -aMeshName ="LE VOLUME" -anEntity = VISU.NODE -aMesh = myVisu.MeshOnEntity(myResult, aMeshName, anEntity) -aTimeStampId = 1 +myView = myViewManager.Create3DView(); -# -aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) -if aScalarMap is not None: - aScalarMap.SetScaling(VISU.LOGARITHMIC) -else: - print "Null scalar map is created" +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.0,0.3,1.0) +myView.SetBackground(aColor); -# -aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) -if aCutPlanes is not None: - aCutPlanes.SetScaling(VISU.LOGARITHMIC) -else: print "Null aCutPlanes is created" +myView.SetTitle("The viewer will display ScalarMap") +print "myViewManager.Create3DView()" -# -aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) -if aIsoSurfaces is not None: - aIsoSurfaces.SetScaling(VISU.LINEAR) -else: print "Null aIsoSurfaces is created" +aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) -myViewManager = myVisu.GetViewManager(); -#myView = myViewManager.Create3DView(); -myView = myViewManager.GetCurrentView(); +myView.Display(aScalarMap); +print "myView.Display(aScalarMap)" myView.SetFocalPoint([0,0,0]); +print "myView.SetFocalPoint(...)" myView.SetParallelScale(2); +print "myView.SetParallelScale(...)" +myView.FitAll(); + +aMax = aScalarMap.GetMax() +aMin = aScalarMap.GetMin() +aDelta = (aMax - aMin)/2.0 +aNbColors = aScalarMap.GetNbColors() +aNbColors = 64 +for i in range(2,aNbColors) : + aScalarMap.SetNbColors(i) + aX = aMin + aDelta*i/aNbColors + aY = aMax - aDelta*i/aNbColors + aScalarMap.SetRange(aX,aY) + myView.Update(); + time.sleep(aDelay) + +aScalarMap.SetRange(aMin,aMax) + +print "myView.Update()" +myView.Update(); +print "myView.FitAll()" +myView.FitAll(); + + + +myView = myViewManager.Create3DView(); +myView.SetTitle("Here we will display CutPlanes") + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.0,0.7,0.0) +myView.SetBackground(aColor); + +aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) +print "myVisu.CutPlanesOnField(...)" + +myView.DisplayOnly(aCutPlanes); +print "myView.DisplayOnly(aCutPlanes)" + aPoint = myView.GetPointOfView(); aPoint[0] = aPoint[0] + 10; myView.SetPointOfView(aPoint); +print "myView.SetPointOfView(...)" myView.ScaleView(VISU.View3D.YAxis,10.0); myView.ScaleView(VISU.View3D.XAxis,3.0); -aColor = SALOMEDS.Color(0.0,0.3,1.0) -myView.SetBackground(aColor); -myView.Update(); -myView.Display(aScalarMap); -#myView.Erase(aScalarMap); -#myView.DisplayOnly(aCutPlanes); +print "myView.ScaleView(...)" +time.sleep(aDelay) + +myView.FitAll(); + +aNbPlanes = aCutPlanes.GetNbPlanes() +aNbPlanes = 30 +aXAngle = aCutPlanes.GetRotateX() +aYAngle = aCutPlanes.GetRotateY() +anOrientation = aCutPlanes.GetOrientationType() +for i in range(aNbPlanes,1,-1) : + aCutPlanes.SetNbPlanes(i) + aX = math.pi/2.0*(aNbPlanes-i)/aNbPlanes + aY = math.pi/2.0*(aNbPlanes-i)/aNbPlanes + aCutPlanes.SetOrientation(anOrientation,aX,aY) + myView.Update(); + time.sleep(aDelay) + +aNbPlanes = 10 +aCutPlanes.SetOrientation(VISU.CutPlanes.ZX,0,0) +for i in range(1,aNbPlanes) : + aCutPlanes.SetNbPlanes(i) + myView.Update(); + time.sleep(aDelay) + myView.SaveViewParams('AAA') +print "myView.SaveViewParams('AAA')" +time.sleep(aDelay) +aCutPlanes.SetOrientation(VISU.CutPlanes.XY,0,0) myView.RemoveScale(); + +print "myView.Update()" +myView.Update(); +print "myView.FitAll()" myView.FitAll(); -aColor = SALOMEDS.Color(0.0,0.0,0.0) + + + +myView = myViewManager.Create3DView(); +print "myViewManager.Create3DView()" + +myView.SetTitle("IsoSurface's viewer") + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(1.0,0.7,0.0) myView.SetBackground(aColor); -myView.SaveViewParams('BBB'); +time.sleep(aDelay) + +aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) + +myView.DisplayOnly(aIsoSurfaces); +myView.FitAll(); +print "myView.DisplayOnly(aCutPlanes)" +time.sleep(aDelay) + +aNbSurfaces = aIsoSurfaces.GetNbSurfaces() +aNbSurfaces = 32 +for i in range(2,aNbSurfaces) : + aIsoSurfaces.SetNbSurfaces(i) + myView.Update(); + time.sleep(aDelay) + +aIsoSurfaces.SetNbSurfaces(10) + +print "myView.Update()" +myView.Update(); +print "myView.FitAll()" +myView.FitAll(); + + -aColor = SALOMEDS.Color(1.0,1.0,1.0) +myView = myViewManager.Create3DView(); +myView.SetTitle("The viewer for CutLines") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.7,0.7,0.7) myView.SetBackground(aColor); -myView.ScaleView(VISU.View3D.ZAxis,0.5); -myView.SaveViewParams('CCC'); +time.sleep(aDelay) + +aCutLines = myVisu.CutLinesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) +aCutLines.SetOrientation(VISU.CutPlanes.ZX,0,0) +aCutLines.SetOrientation2(VISU.CutPlanes.YZ,0,0) + +myView.DisplayOnly(aCutLines); +myView.FitAll(); +print "myView.DisplayOnly(aCutLines)" +time.sleep(aDelay) + +aSObj = myStudy.FindObjectIOR(aCutLines.GetID()) +aTable = myVisu.CreateTable( aSObj.GetID() ) +print "myVisu.CreateTable(...)" + +aTableView = myViewManager.CreateTableView(aTable) +aTableView.SetTitle('Changed Title') + +aContainer = myVisu.CreateContainer() +print "myVisu.CreateContainer(...)" + +aNbCurve = aTable.GetNbRows() - 1 +for i in range(2,aNbCurve): + aCurve = myVisu.CreateCurve( aTable, 1, i ) + print i, aCurve + aContainer.AddCurve(aCurve) + + +myView = myViewManager.CreateXYPlot(); +myView.SetTitle("The viewer for Curves from CutLines") +print "myViewManager.CreateXYPlot()" +time.sleep(aDelay) + +myView.Display(aContainer) + + + +myView = myViewManager.Create3DView(); +myView.SetTitle("The viewer for Animation") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +medFile = "TimeStamps.med" +myFieldName = "vitesse"; + +medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile +myResult = myVisu.ImportFile(medFile) + +anAnim = myVisu.CreateAnimation(myView); +aSObj = myStudy.FindObjectIOR(myResult.GetID()) +aSObj = aSObj.FindSubObject(1)[1] +aSObj = aSObj.FindSubObject(2)[1] +aSObj = aSObj.FindSubObject(2)[1] +anAnim.addField(aSObj) +anAnim.setPresentationType(0,VISU.TISOSURFACE) +print "Generate presentations" +anAnim.generatePresentations(0) +print "Generate frames" +anAnim.generateFrames() +print "Start Animation" +anAnim.setSpeed(99) +#anAnim.setCycling(1) +anAnim.startAnimation() +myView.FitAll() +while 1: + time.sleep(1+aDelay) + if not anAnim.isRunning(): + anAnim.stopAnimation() + break -myView.RestoreViewParams('AAA'); +#anAnim.clearView() diff --git a/src/VISU_SWIG/test_events.py b/src/VISU_SWIG/test_events.py new file mode 100755 index 00000000..c553eae5 --- /dev/null +++ b/src/VISU_SWIG/test_events.py @@ -0,0 +1,22 @@ +############################################################### +# +# File : test_events.py +# Description : Test postEvent() functionality for VISU module +# This script can be run from GUI Python console only! +############################################################### + +import salome + +# it's necessary to load VISU engine, this will cause VisuGUI to be loaded +salome.lcc.FindOrLoadComponent("FactoryServer","VISU") + +# this can be done only after VISU engine has been loaded +from libVISU_Swig import * + +visu=VISU_Swig() + +for i in range ( 10 ): + visu.CreateTestView() + for j in range ( 10 ): + visu.ShowTestObject(); + diff --git a/src/VISU_SWIG/visu_view3d.py b/src/VISU_SWIG/visu_view3d.py index cb4fecf1..8073e354 100644 --- a/src/VISU_SWIG/visu_view3d.py +++ b/src/VISU_SWIG/visu_view3d.py @@ -4,82 +4,265 @@ # # # -# File : visu_view3d.py +# File : batchmode_visu_view3d.py # Module : VISU -import visu_gui import os +import time +import math import VISU import SALOMEDS +from visu_gui import * + +aDelay = 0 + +#mySession = batchmode_visu.mySession + +myViewManager = myVisu.GetViewManager(); + +myView = myViewManager.Create3DView(); +myView.SetTitle("The window will be soon destroyed!") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +myView.Maximize() +print "myView.Maximize()" +time.sleep(aDelay) + +myView.Restore() +print "myView.Restore()" +time.sleep(aDelay) + +myView.Minimize() +print "myView.Minimize()" +time.sleep(aDelay) + +myViewManager.Destroy(myView) +print "myViewManager.Destroy(myView)" +time.sleep(aDelay) -from libSALOME_Swig import * -sg = SALOMEGUI_Swig() -myVisu = visu_gui.myVisu medFile = "fra.med" myFieldName = "VITESSE"; +aMeshName ="LE VOLUME" +anEntity = VISU.NODE +aTimeStampId = 1 + medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile myResult = myVisu.ImportFile(medFile) -aMeshName ="LE VOLUME" -anEntity = VISU.NODE -aMesh = myVisu.MeshOnEntity(myResult, aMeshName, anEntity) -aTimeStampId = 1 -# -aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) -if aScalarMap is not None: - aScalarMap.SetScaling(VISU.LOGARITHMIC) -else: - print "Null scalar map is created" +myView = myViewManager.Create3DView(); -# -aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) -if aCutPlanes is not None: - aCutPlanes.SetScaling(VISU.LOGARITHMIC) -else: print "Null aCutPlanes is created" +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.0,0.3,1.0) +myView.SetBackground(aColor); -# -aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) -if aIsoSurfaces is not None: - aIsoSurfaces.SetScaling(VISU.LINEAR) -else: print "Null aIsoSurfaces is created" +myView.SetTitle("The viewer will display ScalarMap") +print "myViewManager.Create3DView()" -myViewManager = myVisu.GetViewManager(); -#myView = myViewManager.Create3DView(); -myView = myViewManager.GetCurrentView(); +aScalarMap = myVisu.ScalarMapOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) + +myView.Display(aScalarMap); +print "myView.Display(aScalarMap)" myView.SetFocalPoint([0,0,0]); +print "myView.SetFocalPoint(...)" myView.SetParallelScale(2); +print "myView.SetParallelScale(...)" +myView.FitAll(); + +aMax = aScalarMap.GetMax() +aMin = aScalarMap.GetMin() +aDelta = (aMax - aMin)/2.0 +aNbColors = aScalarMap.GetNbColors() +aNbColors = 64 +for i in range(2,aNbColors) : + aScalarMap.SetNbColors(i) + aX = aMin + aDelta*i/aNbColors + aY = aMax - aDelta*i/aNbColors + aScalarMap.SetRange(aX,aY) + myView.Update(); + time.sleep(aDelay) + +aScalarMap.SetRange(aMin,aMax) + +print "myView.Update()" +myView.Update(); +print "myView.FitAll()" +myView.FitAll(); + + + +myView = myViewManager.Create3DView(); +myView.SetTitle("Here we will display CutPlanes") + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.0,0.7,0.0) +myView.SetBackground(aColor); + +aCutPlanes = myVisu.CutPlanesOnField(myResult,aMeshName,anEntity,myFieldName,aTimeStampId) +print "myVisu.CutPlanesOnField(...)" + +myView.DisplayOnly(aCutPlanes); +print "myView.DisplayOnly(aCutPlanes)" + aPoint = myView.GetPointOfView(); aPoint[0] = aPoint[0] + 10; myView.SetPointOfView(aPoint); +print "myView.SetPointOfView(...)" myView.ScaleView(VISU.View3D.YAxis,10.0); myView.ScaleView(VISU.View3D.XAxis,3.0); -aColor = SALOMEDS.Color(0.0,0.3,1.0) -myView.SetBackground(aColor); -myView.Update(); -myView.Display(aScalarMap); -#myView.Erase(aScalarMap); -#myView.DisplayOnly(aCutPlanes); +print "myView.ScaleView(...)" +time.sleep(aDelay) + +myView.FitAll(); + +aNbPlanes = aCutPlanes.GetNbPlanes() +aNbPlanes = 30 +aXAngle = aCutPlanes.GetRotateX() +aYAngle = aCutPlanes.GetRotateY() +anOrientation = aCutPlanes.GetOrientationType() +for i in range(aNbPlanes,1,-1) : + aCutPlanes.SetNbPlanes(i) + aX = math.pi/2.0*(aNbPlanes-i)/aNbPlanes + aY = math.pi/2.0*(aNbPlanes-i)/aNbPlanes + aCutPlanes.SetOrientation(anOrientation,aX,aY) + myView.Update(); + time.sleep(aDelay) + +aNbPlanes = 10 +aCutPlanes.SetOrientation(VISU.CutPlanes.ZX,0,0) +for i in range(1,aNbPlanes) : + aCutPlanes.SetNbPlanes(i) + myView.Update(); + time.sleep(aDelay) + myView.SaveViewParams('AAA') +print "myView.SaveViewParams('AAA')" +time.sleep(aDelay) +aCutPlanes.SetOrientation(VISU.CutPlanes.XY,0,0) myView.RemoveScale(); + +print "myView.Update()" +myView.Update(); +print "myView.FitAll()" myView.FitAll(); -aColor = SALOMEDS.Color(0.0,0.0,0.0) + + + +myView = myViewManager.Create3DView(); +print "myViewManager.Create3DView()" + +myView.SetTitle("IsoSurface's viewer") + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(1.0,0.7,0.0) myView.SetBackground(aColor); -myView.SaveViewParams('BBB'); +time.sleep(aDelay) + +aIsoSurfaces = myVisu.IsoSurfacesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) + +myView.DisplayOnly(aIsoSurfaces); +myView.FitAll(); +print "myView.DisplayOnly(aCutPlanes)" +time.sleep(aDelay) + +aNbSurfaces = aIsoSurfaces.GetNbSurfaces() +aNbSurfaces = 32 +for i in range(2,aNbSurfaces) : + aIsoSurfaces.SetNbSurfaces(i) + myView.Update(); + time.sleep(aDelay) -aColor = SALOMEDS.Color(1.0,1.0,1.0) +aIsoSurfaces.SetNbSurfaces(10) + +print "myView.Update()" +myView.Update(); +print "myView.FitAll()" +myView.FitAll(); + + + +myView = myViewManager.Create3DView(); +myView.SetTitle("The viewer for CutLines") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +print "myView.SetBackground(...)" +aColor = SALOMEDS.Color(0.7,0.7,0.7) myView.SetBackground(aColor); -myView.ScaleView(VISU.View3D.ZAxis,0.5); -myView.SaveViewParams('CCC'); +time.sleep(aDelay) + +aCutLines = myVisu.CutLinesOnField(myResult, aMeshName, anEntity, myFieldName, aTimeStampId) +aCutLines.SetOrientation(VISU.CutPlanes.ZX,0,0) +aCutLines.SetOrientation2(VISU.CutPlanes.YZ,0,0) + +myView.DisplayOnly(aCutLines); +myView.FitAll(); +print "myView.DisplayOnly(aCutLines)" +time.sleep(aDelay) + +aSObj = myStudy.FindObjectIOR(aCutLines.GetID()) +aTable = myVisu.CreateTable( aSObj.GetID() ) +print "myVisu.CreateTable(...)" -myView.RestoreViewParams('AAA'); +aTableView = myViewManager.CreateTableView(aTable) +aTableView.SetTitle('Changed Title') -sg.updateObjBrowser(0) +aContainer = myVisu.CreateContainer() +print "myVisu.CreateContainer(...)" +aNbCurve = aTable.GetNbRows() - 1 +for i in range(2,aNbCurve): + aCurve = myVisu.CreateCurve( aTable, 1, i ) + print i, aCurve + aContainer.AddCurve(aCurve) + + +myView = myViewManager.CreateXYPlot(); +myView.SetTitle("The viewer for Curves from CutLines") +print "myViewManager.CreateXYPlot()" +time.sleep(aDelay) + +myView.Display(aContainer) + + + +myView = myViewManager.Create3DView(); +myView.SetTitle("The viewer for Animation") +print "myViewManager.Create3DView()" +time.sleep(aDelay) + +medFile = "TimeStamps.med" +myFieldName = "vitesse"; + +medFile = os.getenv('KERNEL_ROOT_DIR') + '/examples/' + medFile +myResult = myVisu.ImportFile(medFile) +anAnim = myVisu.CreateAnimation(myView); +aSObj = myStudy.FindObjectIOR(myResult.GetID()) +aSObj = aSObj.FindSubObject(1)[1] +aSObj = aSObj.FindSubObject(2)[1] +aSObj = aSObj.FindSubObject(2)[1] +anAnim.addField(aSObj) +anAnim.setPresentationType(0,VISU.TISOSURFACE) +print "Generate presentations" +anAnim.generatePresentations(0) +print "Generate frames" +anAnim.generateFrames() +print "Start Animation" +anAnim.setSpeed(99) +#anAnim.setCycling(1) +anAnim.startAnimation() +myView.FitAll() +while 1: + time.sleep(1+aDelay) + if not anAnim.isRunning(): + anAnim.stopAnimation() + break +#anAnim.clearView() -- 2.39.2