From: ouv Date: Wed, 4 Nov 2009 13:10:32 +0000 (+0000) Subject: Fix of remarks to issue 0020085: EDF 874 VISU : Visualize evolution of a variable... X-Git-Tag: V5_1_main_20091105~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1af3dcee818a9c49690d4a2a87807f76c80d98c1;p=modules%2Fvisu.git Fix of remarks to issue 0020085: EDF 874 VISU : Visualize evolution of a variable at a given location --- diff --git a/doc/salome/gui/VISU/input/evolution.doc b/doc/salome/gui/VISU/input/evolution.doc index baeef5af..86165f23 100644 --- a/doc/salome/gui/VISU/input/evolution.doc +++ b/doc/salome/gui/VISU/input/evolution.doc @@ -47,4 +47,7 @@ menu on the published object: \image html evolution_restore.png + +Our TUI Scripts provide you with \subpage tui_evolution_page. + */ diff --git a/doc/salome/gui/VISU/input/tui_evolution.doc b/doc/salome/gui/VISU/input/tui_evolution.doc new file mode 100644 index 00000000..ea149e33 --- /dev/null +++ b/doc/salome/gui/VISU/input/tui_evolution.doc @@ -0,0 +1,38 @@ +/*! + +\page tui_evolution_page Example of Evolution on Point + +\code +import os +import VISU +from visu_gui import * + +myViewManager = myVisu.GetViewManager(); + +myView = myViewManager.CreateXYPlot(); +myView.SetTitle("The viewer for Evolution") +print "myViewManager.CreateXYPlot()" + +medFile = "TimeStamps.med" +medFile = os.getenv('DATA_DIR') + '/MedFiles/' + medFile +myResult = myVisu.ImportFile(medFile) + +anEvolution = myVisu.CreateEvolution(myView); + +aSObj = myStudy.FindObjectIOR(myResult.GetID()) +aSObj = aSObj.FindSubObject(1)[1] # dom +aSObj = aSObj.FindSubObject(3)[1] # Fields +aSObj = aSObj.FindSubObject(2)[1] # vitesse +print "setField : ", anEvolution.setField(aSObj) + +anEvolution.setComponentId(1) # x component + +anEvolution.setPointId(500) + +print "Show Evolution" +anEvolution.showEvolution() + +myView.FitAll() +\endcode + +*/ diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 11b369d4..ebe7f5f2 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2132,12 +2132,8 @@ void VisuGUI ::OnPointEvolution() { - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow( this ); - if( !aViewWindow ) - return; - _PTR(Study) aCStudy = GetCStudy( GetAppStudy( this ) ); - VisuGUI_EvolutionDlg* aDlg = new VisuGUI_EvolutionDlg( this, aViewWindow, aCStudy ); + VisuGUI_EvolutionDlg* aDlg = new VisuGUI_EvolutionDlg( this, aCStudy ); LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( this ); SALOME_ListIO aListIO; @@ -2164,10 +2160,6 @@ void VisuGUI ::OnShowEvolution() { - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow( this ); - if( !aViewWindow ) - return; - LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( this ); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects( aListIO ); @@ -2186,7 +2178,7 @@ VisuGUI if( aType != VISU::TEVOLUTION ) return; - VisuGUI_EvolutionDlg* aDlg = new VisuGUI_EvolutionDlg( this, aViewWindow, aCStudy ); + VisuGUI_EvolutionDlg* aDlg = new VisuGUI_EvolutionDlg( this, aCStudy ); aDlg->restoreFromStudy( aSObj ); aDlg->show(); } @@ -3317,7 +3309,6 @@ VisuGUI aRule += " and $type in {'VISU::TFIELD'}"; aRule += " and medEntity='NODE_ENTITY'"; aRule += " and nbTimeStamps>1"; - aRule += " and activeView in {'VTKViewer' 'SVTK'}"; mgr->setRule( action( VISU_POINT_EVOLUTION ), aRule ); aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}"; @@ -3493,7 +3484,7 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QStrin VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aMap ); if (aType == VISU::TANIMATION) { theMenu->addAction( action( VISU_SHOW_ANIMATION ) ); - } else if (aType == VISU::TEVOLUTION && GetActiveViewWindow(this)) { + } else if (aType == VISU::TEVOLUTION) { theMenu->addAction( action( VISU_SHOW_EVOLUTION ) ); } else if (isOBClient) { if (IsSObjectTable(aSObject)) { diff --git a/src/VISUGUI/VisuGUI_EvolutionDlg.cxx b/src/VISUGUI/VisuGUI_EvolutionDlg.cxx index 07cbefac..b5298f14 100644 --- a/src/VISUGUI/VisuGUI_EvolutionDlg.cxx +++ b/src/VISUGUI/VisuGUI_EvolutionDlg.cxx @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -56,12 +57,10 @@ #include -VisuGUI_EvolutionDlg::VisuGUI_EvolutionDlg( VisuGUI* theModule, - SVTK_ViewWindow* theViewWindow, - _PTR(Study) theStudy ) : +VisuGUI_EvolutionDlg::VisuGUI_EvolutionDlg( VisuGUI* theModule, _PTR(Study) theStudy ) : QtxDialog( VISU::GetDesktop( theModule ), false, false, QtxDialog::Standard, Qt::Dialog ), myModule( theModule ), - myViewWindow( theViewWindow ), + myViewWindow( NULL ), myPreviewActor( NULL ) { setWindowTitle( tr( "TITLE" ) ); @@ -80,7 +79,9 @@ VisuGUI_EvolutionDlg::VisuGUI_EvolutionDlg( VisuGUI* theModule, QLabel* aPointLabel = new QLabel( tr( "POINT" ) ); myPointLE = new QLineEdit( aParamGrp ); - myPointLE->setReadOnly( true ); + + myPointValidator = new QIntValidator( this ); + myPointLE->setValidator( myPointValidator ); QLabel* aComponentLabel = new QLabel( tr( "COMPONENT" ) ); myComponentCB = new QComboBox( aParamGrp ); @@ -102,12 +103,22 @@ VisuGUI_EvolutionDlg::VisuGUI_EvolutionDlg( VisuGUI* theModule, aMainLayout->setSpacing( 0 ); aMainLayout->addWidget( aParamGrp ); - connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); + connect( myPointLE, SIGNAL( textEdited( const QString& ) ), + this, SLOT( onPointEdited( const QString& ) ) ); connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionEvent() ) ); + connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); + myStoredSelectionMode = ActorSelection; + + myViewWindow = VISU::GetActiveViewWindow( myModule ); + if( myViewWindow ) + { + connect( myViewWindow, SIGNAL( destroyed() ), this, SLOT( onViewWindowClosed() ) ); + connect( myViewWindow, SIGNAL( closing( SUIT_ViewWindow* ) ), this, SLOT( onViewWindowClosed() ) ); + } } //------------------------------------------------------------------------ @@ -137,6 +148,9 @@ void VisuGUI_EvolutionDlg::updateFromEngine() std::string aFieldName = myEngine->getFieldName(); myFieldLE->setText( QString( aFieldName.c_str() ) ); + int aNbPoints = myEngine->getNbPoints(); + myPointValidator->setRange( 0, aNbPoints-1 ); + QStringList aComponentList; VISU::ComponentDataList aComponentDataList = myEngine->getComponentDataList(); int aNbComp = aComponentDataList.size(); @@ -311,6 +325,32 @@ void VisuGUI_EvolutionDlg::restoreFromStudy( _PTR(SObject) theEvolution ) myComponentCB->setCurrentIndex( myEngine->getComponentId() ); } +//------------------------------------------------------------------------ +void VisuGUI_EvolutionDlg::onPointEdited( const QString& theText ) +{ + if( !myViewWindow ) + return; + + if( !myPreviewActor || !myPreviewActor->hasIO() ) + return; + + bool ok = false; + int aPointId = theText.toInt( &ok ); + if( !ok ) + return; + + Handle(SALOME_InteractiveObject) anIO = myPreviewActor->getIO(); + + SVTK_Selector* aSelector = myViewWindow->GetSelector(); + aSelector->ClearIObjects(); + aSelector->AddOrRemoveIndex( anIO, aPointId, false ); + aSelector->AddIObject( anIO ); + + myPreviewActor->Highlight( true ); + + myViewWindow->Repaint(); +} + //------------------------------------------------------------------------ void VisuGUI_EvolutionDlg::onSelectionEvent() { @@ -345,6 +385,20 @@ void VisuGUI_EvolutionDlg::onSelectionEvent() } } +//------------------------------------------------------------------------ +void VisuGUI_EvolutionDlg::onViewWindowClosed() +{ + if( myViewWindow ) + { + if( myPreviewActor ) + { + myPreviewActor->Delete(); + myPreviewActor = 0; + } + myViewWindow = 0; + } +} + //------------------------------------------------------------------------ void VisuGUI_EvolutionDlg::onHelp() { diff --git a/src/VISUGUI/VisuGUI_EvolutionDlg.h b/src/VISUGUI/VisuGUI_EvolutionDlg.h index 0cc5663d..bf86a0bb 100644 --- a/src/VISUGUI/VisuGUI_EvolutionDlg.h +++ b/src/VISUGUI/VisuGUI_EvolutionDlg.h @@ -33,6 +33,7 @@ #include class QComboBox; +class QIntValidator; class QKeyEvent; class QLineEdit; @@ -47,9 +48,7 @@ class VisuGUI_EvolutionDlg: public QtxDialog Q_OBJECT public: - VisuGUI_EvolutionDlg( VisuGUI* theModule, - SVTK_ViewWindow* theViewWindow, - _PTR(Study) theStudy ); + VisuGUI_EvolutionDlg( VisuGUI* theModule, _PTR(Study) theStudy ); ~VisuGUI_EvolutionDlg(); public: @@ -68,7 +67,9 @@ private: void updateFromEngine(); private slots: + void onPointEdited( const QString& ); void onSelectionEvent(); + void onViewWindowClosed(); void onHelp(); private: @@ -79,6 +80,8 @@ private: QLineEdit* myPointLE; QComboBox* myComponentCB; + QIntValidator* myPointValidator; + SVTK_ViewWindow* myViewWindow; SALOME_Actor* myPreviewActor; Selection_Mode myStoredSelectionMode; diff --git a/src/VISU_I/VISU_Evolution.cxx b/src/VISU_I/VISU_Evolution.cxx index c9301429..75e971cd 100644 --- a/src/VISU_I/VISU_Evolution.cxx +++ b/src/VISU_I/VISU_Evolution.cxx @@ -43,7 +43,7 @@ #include //------------------------------------------------------------------------ -template bool ProcessValForTime( VISU::PValForTimeImpl aValForTime, +template bool ProcessValForTime( VISU::PValForTimeImpl theValForTime, VISU::Elem2Comp2Value& theElem2Comp2Value ) { theElem2Comp2Value.clear(); @@ -52,7 +52,7 @@ template bool ProcessValForTime( VISU::PValForTimeImpl aValForTim typedef VISU::TTMeshValue< TVTKBasicType > TMeshValue; typedef MED::SharedPtr< TMeshValue > TMeshValuePtr; - const TMeshValuePtr aMeshValue = aValForTime->GetMeshValue( VISU::ePOINT1 ); + const TMeshValuePtr aMeshValue = theValForTime->GetMeshValue( VISU::ePOINT1 ); if( !aMeshValue ) return false; @@ -91,6 +91,20 @@ template bool ProcessValForTime( VISU::PValForTimeImpl aValForTim return true; } +//------------------------------------------------------------------------ +template int GetNbPoints( VISU::PValForTimeImpl theValForTime ) +{ + typedef typename VISU::TL::TEnum2VTKBasicType< EDataType >::TResult TVTKBasicType; + typedef VISU::TTMeshValue< TVTKBasicType > TMeshValue; + typedef MED::SharedPtr< TMeshValue > TMeshValuePtr; + + const TMeshValuePtr aMeshValue = theValForTime->GetMeshValue( VISU::ePOINT1 ); + if( !aMeshValue ) + return 0; + + return aMeshValue->GetNbElem(); +} + //------------------------------------------------------------------------ VISU_Evolution::VISU_Evolution( _PTR(Study) theStudy, VISU::XYPlot_ptr theXYPlot ) @@ -222,6 +236,39 @@ void VISU_Evolution::setComponentId( int theComponentId ) myComponentId = theComponentId; } +//------------------------------------------------------------------------ +int VISU_Evolution::getNbPoints() const +{ + if( !myFieldImpl ) + return 0; + + vtkIdType aDataType = myFieldImpl->GetDataType(); + const VISU::TValField& aValField = myFieldImpl->myValField; + if( aValField.empty() ) + return 0; + + VISU::TValField::const_iterator aValFieldIter = aValField.begin(); + for( ; aValFieldIter != aValField.end(); aValFieldIter++ ) + { + const vtkIdType& aTimeStamp = aValFieldIter->first; + VISU::PValForTimeImpl aValForTime = aValFieldIter->second; + + // to force method VISU::MedConvertor::FillValForTime() to be called + myResult->GetInput()->GetTimeStampOnMesh( myMeshName, myEntity, myFieldName, aTimeStamp ); + + switch( aDataType ) + { + case VTK_DOUBLE : return GetNbPoints( aValForTime ); + case VTK_FLOAT : return GetNbPoints( aValForTime ); + case VTK_INT : return GetNbPoints( aValForTime ); + case VTK_LONG: return GetNbPoints( aValForTime ); + default: return 0; + } + } + + return 0; +} + //------------------------------------------------------------------------ bool VISU_Evolution::extractData( int thePointId, int theComponentId, diff --git a/src/VISU_I/VISU_Evolution.h b/src/VISU_I/VISU_Evolution.h index 27301345..b40e9aec 100644 --- a/src/VISU_I/VISU_Evolution.h +++ b/src/VISU_I/VISU_Evolution.h @@ -83,6 +83,8 @@ public: bool setField( _PTR(SObject) theField ); bool setField( SALOMEDS::SObject_ptr theField ); + int getNbPoints() const; + void setPointId( int thePointId ); int getPointId() const { return myPointId; }