\image html evolution_restore.png
+
+Our TUI Scripts provide you with \subpage tui_evolution_page.
+
*/
--- /dev/null
+/*!
+
+\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
+
+*/
VisuGUI
::OnPointEvolution()
{
- SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( 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;
VisuGUI
::OnShowEvolution()
{
- SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( this );
- if( !aViewWindow )
- return;
-
LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( this );
SALOME_ListIO aListIO;
aSelectionMgr->selectedObjects( aListIO );
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();
}
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'}";
VISU::VISUType aType = VISU::Storable::RestoringMap2Type( aMap );
if (aType == VISU::TANIMATION) {
theMenu->addAction( action( VISU_SHOW_ANIMATION ) );
- } else if (aType == VISU::TEVOLUTION && GetActiveViewWindow<SVTK_ViewWindow>(this)) {
+ } else if (aType == VISU::TEVOLUTION) {
theMenu->addAction( action( VISU_SHOW_EVOLUTION ) );
} else if (isOBClient) {
if (IsSObjectTable(aSObject)) {
#include <QComboBox>
#include <QGroupBox>
+#include <QIntValidator>
#include <QKeyEvent>
#include <QLabel>
#include <QLayout>
#include <vtkDataSetMapper.h>
-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" ) );
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 );
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<SVTK_ViewWindow>( myModule );
+ if( myViewWindow )
+ {
+ connect( myViewWindow, SIGNAL( destroyed() ), this, SLOT( onViewWindowClosed() ) );
+ connect( myViewWindow, SIGNAL( closing( SUIT_ViewWindow* ) ), this, SLOT( onViewWindowClosed() ) );
+ }
}
//------------------------------------------------------------------------
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();
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()
{
}
}
+//------------------------------------------------------------------------
+void VisuGUI_EvolutionDlg::onViewWindowClosed()
+{
+ if( myViewWindow )
+ {
+ if( myPreviewActor )
+ {
+ myPreviewActor->Delete();
+ myPreviewActor = 0;
+ }
+ myViewWindow = 0;
+ }
+}
+
//------------------------------------------------------------------------
void VisuGUI_EvolutionDlg::onHelp()
{
#include <SVTK_Selection.h>
class QComboBox;
+class QIntValidator;
class QKeyEvent;
class QLineEdit;
Q_OBJECT
public:
- VisuGUI_EvolutionDlg( VisuGUI* theModule,
- SVTK_ViewWindow* theViewWindow,
- _PTR(Study) theStudy );
+ VisuGUI_EvolutionDlg( VisuGUI* theModule, _PTR(Study) theStudy );
~VisuGUI_EvolutionDlg();
public:
void updateFromEngine();
private slots:
+ void onPointEdited( const QString& );
void onSelectionEvent();
+ void onViewWindowClosed();
void onHelp();
private:
QLineEdit* myPointLE;
QComboBox* myComponentCB;
+ QIntValidator* myPointValidator;
+
SVTK_ViewWindow* myViewWindow;
SALOME_Actor* myPreviewActor;
Selection_Mode myStoredSelectionMode;
#include <SALOME_Event.h>
//------------------------------------------------------------------------
-template<int EDataType> bool ProcessValForTime( VISU::PValForTimeImpl aValForTime,
+template<int EDataType> bool ProcessValForTime( VISU::PValForTimeImpl theValForTime,
VISU::Elem2Comp2Value& theElem2Comp2Value )
{
theElem2Comp2Value.clear();
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;
return true;
}
+//------------------------------------------------------------------------
+template<int EDataType> 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 )
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<VTK_DOUBLE>( aValForTime );
+ case VTK_FLOAT : return GetNbPoints<VTK_FLOAT>( aValForTime );
+ case VTK_INT : return GetNbPoints<VTK_INT>( aValForTime );
+ case VTK_LONG: return GetNbPoints<VTK_LONG>( aValForTime );
+ default: return 0;
+ }
+ }
+
+ return 0;
+}
+
//------------------------------------------------------------------------
bool VISU_Evolution::extractData( int thePointId,
int theComponentId,
bool setField( _PTR(SObject) theField );
bool setField( SALOMEDS::SObject_ptr theField );
+ int getNbPoints() const;
+
void setPointId( int thePointId );
int getPointId() const { return myPointId; }