]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix of remarks to issue 0020085: EDF 874 VISU : Visualize evolution of a variable...
authorouv <ouv@opencascade.com>
Wed, 4 Nov 2009 13:10:32 +0000 (13:10 +0000)
committerouv <ouv@opencascade.com>
Wed, 4 Nov 2009 13:10:32 +0000 (13:10 +0000)
doc/salome/gui/VISU/input/evolution.doc
doc/salome/gui/VISU/input/tui_evolution.doc [new file with mode: 0644]
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_EvolutionDlg.cxx
src/VISUGUI/VisuGUI_EvolutionDlg.h
src/VISU_I/VISU_Evolution.cxx
src/VISU_I/VISU_Evolution.h

index baeef5af20b33019b4a8cc7a168ad59fc1653804..86165f23f4b3f751ffb700d0f2f71edf8db548b9 100644 (file)
@@ -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 (file)
index 0000000..ea149e3
--- /dev/null
@@ -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
+
+*/
index 11b369d44152d03d00efb82fb20eef02edd18fb8..ebe7f5f2cdf08069252e1fa9c0e72c22cab16ea2 100644 (file)
@@ -2132,12 +2132,8 @@ void
 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;
@@ -2164,10 +2160,6 @@ void
 VisuGUI
 ::OnShowEvolution()
 {
-  SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( 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<SVTK_ViewWindow>(this)) {
+  } else if (aType == VISU::TEVOLUTION) {
     theMenu->addAction( action( VISU_SHOW_EVOLUTION ) );
   } else if (isOBClient) {
     if (IsSObjectTable(aSObject)) {
index 07cbefac5519349238d42b1e2f7ca29c89528384..b5298f1461c83ea40131554aff1c8438267620c2 100644 (file)
@@ -49,6 +49,7 @@
 
 #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" ) );
@@ -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<SVTK_ViewWindow>( 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()
 {
index 0cc5663de757ad51d3fe8e41bb969d12c60a9910..bf86a0bbf678de2493de2e3db012ec3893ec991d 100644 (file)
@@ -33,6 +33,7 @@
 #include <SVTK_Selection.h>
 
 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;
index c9301429563f180060f3fb168ea5b12b3955e410..75e971cd4a72634b0991657d75ad59b58309aa19 100644 (file)
@@ -43,7 +43,7 @@
 #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();
@@ -52,7 +52,7 @@ template<int EDataType> 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<int EDataType> bool ProcessValForTime( VISU::PValForTimeImpl aValForTim
   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 )
@@ -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<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,
index 273013451182de47eb99e6977be71a0ec7fd84ab..b40e9aec0a331984470172859b89a83df5759a37 100644 (file)
@@ -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; }