]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Implementation of the sweep functionality
authorapo <apo@opencascade.com>
Thu, 15 May 2008 12:47:36 +0000 (12:47 +0000)
committerapo <apo@opencascade.com>
Thu, 15 May 2008 12:47:36 +0000 (12:47 +0000)
src/VISUGUI/Makefile.am
src/VISUGUI/VISU_images.ts
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_Sweep.cxx [new file with mode: 0644]
src/VISUGUI/VisuGUI_Sweep.h [new file with mode: 0644]
src/VISUGUI/VisuGUI_Tools.h

index aed0f5679250e2d0aaff36737dfc915d1ff12177..e0544ae6db12b9b9b9ee17e0dc2e98a0dbd0ff9f 100644 (file)
@@ -72,6 +72,7 @@ dist_libVISU_la_SOURCES= \
        VisuGUI_TransparencyDlg.cxx \
        VisuGUI_Timer.cxx \
        VisuGUI_Slider.cxx \
+       VisuGUI_Sweep.cxx \
        VisuGUI_InputPane.cxx \
        VisuGUI_CacheDlg.cxx \
        VisuGUI_FieldFilter.cxx \
@@ -109,6 +110,7 @@ MOC_FILES= \
        VisuGUI_BuildProgressDlg_moc.cxx \
        VisuGUI_TransparencyDlg_moc.cxx \
        VisuGUI_Slider_moc.cxx \
+       VisuGUI_Sweep_moc.cxx \
        VisuGUI_InputPane_moc.cxx \
        VisuGUI_CacheDlg_moc.cxx \
        VisuGUI_ViewExtender_moc.cxx \
index dd7a9d46468f324d9b563e71ffce9da0d4ba08ab..46aac25d2b6f93adb6600902f10e112f8d77216f 100644 (file)
             <source>ICON_VVTK_RECORDING_STOP</source>
             <translation>Visu_recording_stop.png</translation>
         </message>
+        <message>
+            <source>ICON_SWEEP_STOP</source>
+            <translation>Visu_recording_stop.png</translation>
+        </message>
         <message>
             <source>ICON_VVTK_SELECTION_MODE_SWITCH</source>
             <translation>Visu_points.png</translation>
index 96593c8cd2e1d7c3dc52ca82582694a21e172241..57f26ebcbb859307747d54d0abe5027ef40a50ba 100644 (file)
@@ -2825,6 +2825,31 @@ Please, provide non-empty resulting presentation.</translation>
             <translation>Do you want to choose all items with the same units for vertical axis?</translation>
         </message>
     </context>
+    <context>
+        <name>VisuGUI_Sweep</name>
+
+        <message><source>TITLE</source><translation>Sweep</translation></message>
+
+        <message><source>NAVIGATION_TAB</source><translation>Navigation</translation></message>
+        <message><source>START_SWEEP_POSITION</source><translation>0 %</translation></message>
+        <message><source>END_SWEEP_POSITION</source><translation>100 %</translation></message>
+        <message><source>IS_CYCLED</source><translation>Cycled</translation></message>
+
+        <message><source>PROPERTIES_TAB</source><translation>Properties</translation></message>
+
+        <message><source>MODE</source><translation>Mode:</translation></message>
+        <message><source>LINEAR</source><translation>Linear</translation></message>
+        <message><source>COSINUSOIDAL</source><translation>1 - cos( t ) / 2</translation></message>
+        <message><source>SINUSOIDAL</source><translation>sin( t - Pi / 2 )</translation></message>
+
+        <message><source>NUMBER_OF_STEPS</source><translation>Number Steps:</translation></message>
+
+        <message><source>INTERVAL</source><translation>Interval</translation></message>
+        <message><source>[ 0, +PI ]</source><translation>[ 0, +PI ]</translation></message>
+        <message><source>[ -PI, +PI ]</source><translation>[ -PI, +PI ]</translation></message>
+
+        <message><source>DELAY_BETWEEN_STEPS</source><translation>Step Dealy [ sec ]:</translation></message>
+    </context>
     <context>
         <name>VisuGUI_Slider</name>
 
index 4c299b75f0e5c212b79c3d739114da6f90986851..6cb20abfdf62e008683cd71d35dc623fa00d98c1 100644 (file)
@@ -1008,36 +1008,6 @@ VisuGUI
 }
 
 
-namespace
-{
-  //----------------------------------------------------------------------------
-  bool
-  GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
-                       VISU::Prs3d_i*& thePrs3d,
-                       SVTK_ViewWindow*& theViewWindow,
-                       VISU_Actor*& thenActor)
-  {
-    VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
-    if(aSelectionInfo.empty())
-      return false;
-
-    VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
-    thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
-    if(!thePrs3d)
-      return false;
-
-    theViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
-    if(!theViewWindow)
-      return false;
-
-    thenActor = FindActor(theViewWindow, thePrs3d);
-    if(!thenActor)
-      return false;
-
-    return true;
-  }
-}
-
 //----------------------------------------------------------------------------
 void
 VisuGUI
@@ -1670,64 +1640,7 @@ void
 VisuGUI
 ::OnSweep()
 {
-  VISU_Actor* anActor = NULL;
-  VISU::Prs3d_i* aPrs3d = NULL;
-  SVTK_ViewWindow* aViewWindow = NULL;
-  if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
-    return;
-
-  VISU::ScalarMap_i* aScalarMap = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
-  if(!aScalarMap)
-    return;
-
-  if(!anActor->GetVisibility())
-    anActor->VisibilityOn();
-
-  // Get sweep parameters
-  SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
-
-  double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
-  int aTemp = int(1.E6 * aTempoDbl);
-
-  int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
-  int aSteps  = aResourceMgr->integerValue("VISU", "sweeping_number_steps", 40);
-
-  int aMode = aResourceMgr->integerValue("VISU", "sweeping_modes", 0);
-
-  int is2Pi = aResourceMgr->integerValue("VISU", "sweeping_is2PI", 0);
-
-  // Sweep
-  QApplication::setOverrideCursor(Qt::WaitCursor);
-
-  for (int j = 0; j < aCycles; j++) {
-    for (int i = 0; i <= aSteps; i++) {
-      try {
-        float aPercents;
-       float aT;
-       if( aMode >= 1 )
-         aT = ( is2Pi == 1 ? -PI + 2. * PI * float(i)/aSteps : PI * float(i)/aSteps );
-        if( aMode == 1 ){  //if selected Periodic cosinusoidal mode of sweeping
-          //This is necessary in order for animation to return to the initial picture
-         aPercents = (1.-cos( aT ))/2.;
-        }
-        else if( aMode == 2 ){  //if selected Periodic sinusoidal mode of sweeping
-          //This is necessary in order for animation to return to the initial picture
-         aPercents = sin( aT - PI/2 );
-        }
-        else //if selected Linear mode of sweeping
-          aPercents = float(i)/aSteps;
-        aScalarMap->SetMapScale(aPercents);
-        aScalarMap->UpdateActor(anActor);
-        aViewWindow->getRenderWindow()->Render();
-        usleep(aTemp);
-      } catch (std::exception& exc) {
-        INFOS("Follow exception was occured :\n" << exc.what());
-      } catch (...) {
-        INFOS("Unknown exception was occured!");
-      }
-    }
-  }
-  QApplication::restoreOverrideCursor();
+  new VisuGUI_Sweep( this, getApp()->desktop(), getApp()->selectionMgr() );
 }
 
 //----------------------------------------------------------------------------
diff --git a/src/VISUGUI/VisuGUI_Sweep.cxx b/src/VISUGUI/VisuGUI_Sweep.cxx
new file mode 100644 (file)
index 0000000..54b8d2e
--- /dev/null
@@ -0,0 +1,499 @@
+//  VISU VISUGUI : GUI of VISU component
+//
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : VisuGUI_Slider.cxx
+//  Author : Oleg UVAROV
+//  Module : VISU
+
+#include "VisuGUI_Sweep.h"
+
+#include "SUIT_ResourceMgr.h"
+
+#include "LightApp_SelectionMgr.h"
+
+#include "VISU_Actor.h"
+
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_Actor.h"
+
+#include "QtxDockWidget.h"
+#include "QtxIntSpinBox.h"
+#include "QtxDoubleSpinBox.h"
+
+#include <QMainWindow>
+#include <QComboBox>
+#include <QFont>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QToolButton>
+#include <QToolTip>
+#include <QSlider>
+#include <QGroupBox>
+#include <QCheckBox>
+#include <QRadioButton>
+#include <QTimer>
+
+#include <vtkMath.h>
+
+/*!
+  Constructor
+*/
+VisuGUI_Sweep::VisuGUI_Sweep( VisuGUI* theModule, 
+                             QMainWindow* theParent,
+                             LightApp_SelectionMgr* theSelectionMgr )
+  : QWidget( theParent )
+  , myModule( theModule )
+  , myViewWindow( NULL )
+  , myScalarMap( NULL )
+  , myActor( NULL )
+{
+  setWindowTitle( tr("TITLE") );
+
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+  //----------------------------------------------------------------------------
+  QVBoxLayout* aVBoxLayout = new QVBoxLayout( this );
+
+  QTabWidget* aTabWidget = new QTabWidget( this );
+  aVBoxLayout->addWidget( aTabWidget );
+
+  {
+    QWidget* aNavigationTab = new QWidget();
+    {
+      QVBoxLayout* aVBoxLayout = new QVBoxLayout( aNavigationTab );
+      {
+       QHBoxLayout* aHBoxLayout = new QHBoxLayout();
+       
+       QLabel* aStartSweepPosition = new QLabel( aNavigationTab );
+       aStartSweepPosition->setText( tr( "START_SWEEP_POSITION" ) );
+       aHBoxLayout->addWidget( aStartSweepPosition );
+      
+       mySweepSlider = new QSlider( aNavigationTab );
+       mySweepSlider->setOrientation( Qt::Horizontal );
+       mySweepSlider->setMinimum( 0 );
+       aHBoxLayout->addWidget( mySweepSlider );
+       
+       QLabel* anEndSweepPosition = new QLabel( aNavigationTab );
+       anEndSweepPosition->setText( tr( "END_SWEEP_POSITION" ) );
+       aHBoxLayout->addWidget( anEndSweepPosition );
+       
+       aVBoxLayout->addLayout( aHBoxLayout );
+      }
+      {
+       QHBoxLayout* aHBoxLayout = new QHBoxLayout();
+      
+       myFirstButton = new QToolButton( aNavigationTab );
+       myFirstButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_FIRST" ) ) );
+       myFirstButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+       connect( myFirstButton, SIGNAL( clicked() ), SLOT( onFirst() ) );
+       aHBoxLayout->addWidget( myFirstButton );
+       
+       myPreviousButton = new QToolButton( aNavigationTab );
+       myPreviousButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PREVIOUS" ) ) );
+       myPreviousButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+       connect( myPreviousButton, SIGNAL( clicked() ), SLOT( onPrevious() ) );
+       aHBoxLayout->addWidget( myPreviousButton );
+       
+       myPlayButton = new QToolButton( aNavigationTab );
+       myPlayButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PLAY" ) ) );
+       myPlayButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+       myPlayButton->setCheckable( true );
+       aHBoxLayout->addWidget( myPlayButton );
+       
+       myNextButton = new QToolButton( aNavigationTab );
+       myNextButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_NEXT" ) ) );
+       myNextButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+       connect( myNextButton, SIGNAL( clicked() ), SLOT( onNext() ) );
+       aHBoxLayout->addWidget( myNextButton );
+       
+       myLastButton = new QToolButton( aNavigationTab );
+       myLastButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_LAST" ) ) );
+       myLastButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+       connect( myLastButton, SIGNAL( clicked() ), SLOT( onLast() ) );
+       aHBoxLayout->addWidget( myLastButton );
+       
+       aVBoxLayout->addLayout( aHBoxLayout );
+      }
+      {
+       QHBoxLayout* aHBoxLayout = new QHBoxLayout();
+      
+       QToolButton* aStopButton = new QToolButton( aNavigationTab );
+       aStopButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SWEEP_STOP" ) ) );
+       aStopButton->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+       aStopButton->setCheckable( true );
+       connect( aStopButton, SIGNAL( toggled( bool ) ), SLOT( onStop( bool ) ) );
+       aHBoxLayout->addWidget( aStopButton );
+       
+       myIsCycled = new QCheckBox( aNavigationTab );
+       myIsCycled->setText( tr( "IS_CYCLED" ) );
+       myIsCycled->setChecked( true );
+       aHBoxLayout->addWidget( myIsCycled );
+       
+       aVBoxLayout->addLayout( aHBoxLayout );
+      }
+      {
+       QSpacerItem* aSpacerItem = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );     
+       aVBoxLayout->addItem( aSpacerItem );
+      }
+
+      aTabWidget->addTab( aNavigationTab, tr( "NAVIGATION_TAB" ) );
+    }
+  }
+  {
+    QWidget* aPropertiesTab = new QWidget();
+
+    QVBoxLayout* aVBoxLayout = new QVBoxLayout( aPropertiesTab );
+    {
+      QGridLayout* aGridLayout = new QGridLayout( aPropertiesTab );
+
+      QLabel* aModeAnnotation = new QLabel( aPropertiesTab );
+      aModeAnnotation->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
+      aModeAnnotation->setText( tr( "MODE" ) );
+      aGridLayout->addWidget( aModeAnnotation, 0, 0 );
+         
+      mySweepMode = new QComboBox( aPropertiesTab );
+      mySweepMode->insertItems( 0, QStringList() 
+                               << tr( "LINEAR" ) 
+                               << tr( "COSINUSOIDAL" ) 
+                               << tr( "SINUSOIDAL" ) );
+      mySweepMode->setCurrentIndex( aResourceMgr->integerValue( "VISU", "sweeping_modes", 0 ) );
+      aGridLayout->addWidget( mySweepMode, 0, 1 );
+         
+      myIntervals = new QComboBox( aPropertiesTab );
+      myIntervals->insertItems( 0, QStringList() 
+                               << tr( "[ 0, +PI ]" ) 
+                               << tr( "[ -PI, +PI ]" ) );
+      myIntervals->setCurrentIndex( aResourceMgr->integerValue( "VISU", "sweeping_is2PI", 0 ) );
+      aGridLayout->addWidget( myIntervals, 0, 2 );
+
+      QLabel* aNumberOfStepsAnnotation = new QLabel( aPropertiesTab );
+      aNumberOfStepsAnnotation->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
+      aNumberOfStepsAnnotation->setText( tr( "NUMBER_OF_STEPS" ) );
+      aGridLayout->addWidget( aNumberOfStepsAnnotation, 1, 0 );
+
+      myNumberOfSteps = new QtxIntSpinBox( aPropertiesTab );
+      connect( myNumberOfSteps, SIGNAL( valueChanged( int ) ), SLOT( onNumberOfStepsChanged( int ) ) );
+      myNumberOfSteps->setValue( aResourceMgr->integerValue( "VISU", "sweeping_number_steps", 40 ) );
+      aGridLayout->addWidget( myNumberOfSteps, 1, 1, 1, 2 );
+
+      QLabel* aStepDelayAnnotation = new QLabel( aPropertiesTab );
+      aStepDelayAnnotation->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
+      aStepDelayAnnotation->setText( tr( "DELAY_BETWEEN_STEPS" ) );
+      aGridLayout->addWidget( aStepDelayAnnotation, 2, 0 );
+         
+      myStepDelay = new QtxDoubleSpinBox( aPropertiesTab );
+      myStepDelay->setValue( aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1) );
+      aGridLayout->addWidget( myStepDelay, 2, 1, 1, 2 );
+
+      QSpacerItem* aSpacerItem = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );      
+      aGridLayout->addItem( aSpacerItem, 3, 0 );
+
+      aVBoxLayout->addLayout( aGridLayout );
+    }
+
+    aTabWidget->addTab( aPropertiesTab, tr( "PROPERTIES_TAB" ) );
+  }
+
+  {
+    QSpacerItem* aSpacerItem = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+    aVBoxLayout->addItem( aSpacerItem );
+  }
+
+
+  //----------------------------------------------------------------------------
+  QtxDockWidget* aQtxDockWidget = new QtxDockWidget( true, theParent );
+  theParent->addDockWidget( Qt::BottomDockWidgetArea , aQtxDockWidget );
+  aQtxDockWidget->setWidget( this );
+  aQtxDockWidget->show();
+
+
+  //----------------------------------------------------------------------------
+  myTimer = new QTimer( this );
+
+  connect( myTimer, SIGNAL( timeout() ), SLOT( onTimeout() ) );
+
+  connect( myPlayButton, SIGNAL( toggled( bool ) ), SLOT( onPlay( bool ) ) );
+
+  connect( mySweepSlider, SIGNAL( valueChanged( int ) ), SLOT( onValueChanged( int ) ) );
+
+  connect( myStepDelay, SIGNAL( valueChanged( double ) ), SLOT( onDelayChanged( double ) ) );
+
+  connect( mySweepMode, SIGNAL( currentIndexChanged( int ) ), SLOT( onModeChanged( int ) ) );
+
+  connect( theModule, SIGNAL( moduleDeactivated() ), SLOT( onModuleDeactivated() ) );
+
+  connect( theModule, SIGNAL( moduleActivated() ), SLOT( onModuleActivated() ) );
+
+  connect( theSelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionChanged() ) );
+
+  onSelectionChanged();
+  
+  onModeChanged( mySweepMode->currentIndex() );
+
+  onPlay( true );
+}
+
+
+//----------------------------------------------------------------------------
+VisuGUI_Sweep::~VisuGUI_Sweep()
+{}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onModuleDeactivated()
+{
+  setHidden( true );
+
+  onStop( true );
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onModuleActivated()
+{
+  setHidden( false );
+}
+
+
+//----------------------------------------------------------------------------
+namespace
+{
+  struct TEnabler
+  {
+    VisuGUI_Sweep* myWidget;
+    VISU_Actor*& myActor;
+
+    TEnabler( VisuGUI_Sweep* theWidget, VISU_Actor*& theActor )
+      : myWidget( theWidget )
+      , myActor( theActor )
+    {}
+    
+    ~TEnabler()
+    {
+      myWidget->setEnabled( myActor );
+      myWidget->onStop( !myActor );
+    }
+  };
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onSelectionChanged()
+{
+  VISU_Actor* anActor = NULL;
+  VISU::Prs3d_i* aPrs3d = NULL;
+  SVTK_ViewWindow* aViewWindow = NULL;
+
+  TEnabler anEnabler( this, anActor );
+
+  if( !VISU::GetPrs3dSelectionInfo( myModule, aPrs3d, aViewWindow, anActor ) )
+    return;
+
+  if ( anActor == myActor )
+    return;
+
+  VISU::ScalarMap_i* aScalarMap = dynamic_cast< VISU::ScalarMap_i* >( aPrs3d );
+  if ( !aScalarMap )
+    return;
+
+  if ( myActor ) {
+    myScalarMap->SetMapScale( 1.0 );
+    myScalarMap->UpdateActor( myActor );
+    myViewWindow->Repaint();
+  }
+
+  if ( anActor && !anActor->GetVisibility() )
+    anActor->VisibilityOn();
+
+  myViewWindow = aViewWindow;
+  myScalarMap = aScalarMap;
+  myActor = anActor;
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onValueChanged( int value )
+{
+  if ( !myActor )
+    return;
+
+  QApplication::setOverrideCursor(Qt::WaitCursor);
+
+  int aSweepMode = mySweepMode->currentIndex();
+  int aNbSteps = myNumberOfSteps->value();
+  
+  double anArgument = double( value ) / aNbSteps;
+
+  int anIntervalMode = myIntervals->currentIndex();
+  // To correct the input value according to the given interval mode
+  if ( aSweepMode != 0 ) {
+    switch ( anIntervalMode ) {
+    case 0 :
+      anArgument = vtkMath::Pi() * anArgument;
+      break;
+    case 1 :
+      anArgument = -vtkMath::Pi() + 2.0 * vtkMath::Pi() * anArgument;
+      break;
+    default :
+      break;
+    }
+  }
+  
+  // To correct the input value according to the given sweep mode
+  double aValue = anArgument;
+  switch ( aSweepMode ) {
+  case 1 :
+    aValue = ( 1.0 - cos( anArgument ) ) / 2.0;
+    break;
+  case 2 :
+    aValue = sin( anArgument - vtkMath::Pi() / 2.0 );
+    break;
+  default :
+    break;
+  }
+
+//  cout << "VisuGUI_Sweep::onValueChanged - ( " << value 
+//       << "; " << anArgument 
+//       << "; " << aValue 
+//       << ")" << endl;
+
+  try {
+    myScalarMap->SetMapScale( aValue );
+    myScalarMap->UpdateActor( myActor );
+    myViewWindow->Repaint();
+  } catch (std::exception& exc) {
+    INFOS( "Follow exception was occured :\n" << exc.what() );
+  } catch (...) {
+    INFOS( "Unknown exception was occured!" );
+  }
+
+  QApplication::restoreOverrideCursor();
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onDelayChanged( double value )
+{
+  myTimer->start( int( value * 1000 ) );
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onNumberOfStepsChanged( int value )
+{
+  int anOldNumberOfSteps = mySweepSlider->maximum();
+  mySweepSlider->setMaximum( value );
+
+  double aNewSweepValue = value / anOldNumberOfSteps * mySweepSlider->value();
+  mySweepSlider->setValue( int( aNewSweepValue ) );
+
+  double aNewPageStep = value / anOldNumberOfSteps * mySweepSlider->pageStep();
+  mySweepSlider->setPageStep( int( aNewPageStep ) );
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onModeChanged( int )
+{
+  myIntervals->setEnabled( mySweepMode->currentIndex() != 0 );
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onFirst()
+{
+  mySweepSlider->setValue( mySweepSlider->minimum() );
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onPrevious()
+{
+  mySweepSlider->setValue( mySweepSlider->value() - 1 );
+}
+
+void VisuGUI_Sweep::onNext()
+{
+  mySweepSlider->setValue( mySweepSlider->value() + 1 );
+}
+
+void VisuGUI_Sweep::onLast()
+{
+  mySweepSlider->setValue( mySweepSlider->maximum() );
+}
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onPlay( bool on )
+{
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+  if ( on ) {
+    myPlayButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PAUSE" ) ) );
+    myTimer->start( int( myStepDelay->value() * 1000 ) );
+    myPlayButton->setChecked( true );
+  } else {
+    myTimer->stop();
+    myPlayButton->setChecked( false );
+    myPlayButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_SLIDER_PLAY" ) ) );
+  }
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onStop( bool on )
+{
+  onPlay( false );
+
+  mySweepSlider->setValue( mySweepSlider->maximum() );
+
+  mySweepSlider->setEnabled( !on );
+
+  myFirstButton->setEnabled( !on );
+  myPreviousButton->setEnabled( !on );
+
+  myPlayButton->setEnabled( !on );
+
+  myNextButton->setEnabled( !on );
+  myLastButton->setEnabled( !on );
+}
+
+
+//----------------------------------------------------------------------------
+void VisuGUI_Sweep::onTimeout()
+{
+  int value = mySweepSlider->value();
+  if ( value < mySweepSlider->maximum() ) {
+    mySweepSlider->setValue( value + 1 );
+  } else {
+    if ( myIsCycled->isChecked() )
+      mySweepSlider->setValue( 0 );
+    else
+      myPlayButton->setChecked( false );
+    //myStopButton->setEnabled( false );
+  }
+}
+
+
+//----------------------------------------------------------------------------
diff --git a/src/VISUGUI/VisuGUI_Sweep.h b/src/VISUGUI/VisuGUI_Sweep.h
new file mode 100644 (file)
index 0000000..6d03d71
--- /dev/null
@@ -0,0 +1,127 @@
+//  VISU VISUGUI : GUI of VISU component
+//
+//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : VisuGUI_Sweep.h
+//  Author : Oleg UVAROV
+//  Module : VISU
+
+#ifndef VisuGUI_Sweep_HeaderFile
+#define VisuGUI_Sweep_HeaderFile
+
+#include <QWidget>
+
+class QComboBox;
+class QToolButton;
+class QSlider;
+class QSpinBox;
+class QCheckBox;
+class QMainWindow;
+class QTimer;
+
+class QtxIntSpinBox;
+class QtxDoubleSpinBox;
+
+class LightApp_SelectionMgr;
+class SVTK_ViewWindow;
+class VISU_Actor;
+class VisuGUI;
+
+
+namespace VISU
+{
+  class ScalarMap_i;
+}
+
+
+//----------------------------------------------------------------------------
+class VisuGUI_Sweep : public QWidget
+{
+  Q_OBJECT;
+
+public:
+  VisuGUI_Sweep( VisuGUI* theModule, 
+                QMainWindow* theParent,
+                LightApp_SelectionMgr* theSelectionMgr );
+
+  virtual ~VisuGUI_Sweep();
+
+public slots:
+  virtual void     onSelectionChanged();
+
+  virtual void     onFirst();
+
+  virtual void     onPrevious();
+
+  virtual void     onPlay( bool );
+
+  virtual void     onNext();
+
+  virtual void     onLast();
+
+  virtual void     onStop( bool );
+
+  virtual void     onValueChanged( int );
+
+  virtual void     onDelayChanged( double );
+
+  virtual void     onNumberOfStepsChanged( int );
+
+  virtual void     onModeChanged( int );
+
+  virtual void     onTimeout();
+
+  void             onModuleDeactivated();
+
+  void             onModuleActivated();
+
+private:
+  QSlider*          mySweepSlider;
+
+  QToolButton*      myFirstButton;
+  QToolButton*      myPreviousButton;
+  QToolButton*      myPlayButton;
+  QToolButton*      myNextButton;
+  QToolButton*      myLastButton;
+
+  QCheckBox*        myIsCycled;
+
+  QComboBox*        mySweepMode;
+  QtxIntSpinBox*    myNumberOfSteps;
+
+  QComboBox*        myIntervals;
+  QtxDoubleSpinBox* myStepDelay;
+
+  QTimer*           myTimer;
+
+  VisuGUI*          myModule;
+
+  VISU_Actor* myActor;
+  VISU::ScalarMap_i* myScalarMap;
+  SVTK_ViewWindow* myViewWindow;
+};
+
+
+//----------------------------------------------------------------------------
+
+
+#endif
index 8e69af3d4a5e81ff3daf00c76d8c2a3468aee254..2d68def7c8ad6ede4c85a76dcb569b6c3cc0dadb 100644 (file)
@@ -121,6 +121,11 @@ namespace VISU
 
   VISU::Prs3d_i*                       GetPrs3dFromBase(Base_i* theBase);
 
+  bool                                 GetPrs3dSelectionInfo( const SalomeApp_Module* theModule,
+                                                             VISU::Prs3d_i*& thePrs3d,
+                                                             SVTK_ViewWindow*& theViewWindow,
+                                                             VISU_Actor*& thenActor );
+
   //----------------------------------------------------------------------------
   void                                 Add(LightApp_SelectionMgr* theSelectionMgr,
                                           const Handle(SALOME_InteractiveObject)& theIO);