// Module : VISU
#include "VisuGUI_TimeAnimation.h"
-#include "VisuGUI.h"
-
-#include <qlayout.h>
-#include <qhbox.h>
-#include <qhgroupbox.h>
-#include <qmessagebox.h>
-#include <qwt_wheel.h>
-#include <qlcdnumber.h>
-#include <qlistbox.h>
-#include <qvgroupbox.h>
-#include <qthread.h>
-
-#include "QAD_Application.h"
-#include "QAD_Desktop.h"
-#include "QAD_FileDlg.h"
-
-#include "VTKViewer_ViewFrame.h"
-#include "VISU_ScalarBarActor.hxx"
+#include "VisuGUI.h"
#include "VisuGUI_MagnitudeDlg.h"
#include "VisuGUI_CutPlanesDlg.h"
#include "VisuGUI_VectorsDlg.h"
#include "VisuGUI_IsoSurfacesDlg.h"
#include "VisuGUI_StreamLinesDlg.h"
-#include "VISU_TimeAnimation.h"
+#include "VISU_TimeAnimation.h"
#include "VISU_ScalarMap_i.hh"
#include "VISU_IsoSurfaces_i.hh"
#include "VISU_DeformedShape_i.hh"
#include "VISU_Vectors_i.hh"
#include "VISU_StreamLines_i.hh"
-static double MAXVALUE = 1.0E+300;
+#include "VISU_ScalarBarActor.hxx"
+
+#include "VTKViewer_ViewFrame.h"
+
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "QAD_FileDlg.h"
+
+#include <qlayout.h>
+#include <qhbox.h>
+#include <qhgroupbox.h>
+#include <qmessagebox.h>
+#include <qwt_wheel.h>
+#include <qlcdnumber.h>
+#include <qlistbox.h>
+#include <qvgroupbox.h>
+#include <qthread.h>
-SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator)
- : QDialog( theParent, "SetupDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+SetupDlg::SetupDlg (QWidget* theParent, VISU_TimeAnimation* theAnimator)
+ : QDialog(theParent, "SetupDlg", true, WStyle_Customize |
+ WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
{
setCaption("Setup Animation");
setSizeGripEnabled( TRUE );
myAnimator = theAnimator;
-
+
QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
aMainLayout->setSpacing(5);
QFrame* aRangeGrp = new QFrame(this);
- QGridLayout* aRangeLayout = new QGridLayout( aRangeGrp );
+ QGridLayout* aRangeLayout = new QGridLayout( aRangeGrp );
aRangeLayout->setSpacing( 6 );
aRangeLayout->setMargin( 11 );
aRangeGrp->setFrameStyle(QFrame::Box | QFrame::Raised);
myUseRangeChk = new QCheckBox("Use range of time stamps", aRangeGrp);
aRangeLayout->addMultiCellWidget(myUseRangeChk, 0, 0, 0, 3);
myUseRangeChk->setChecked(myAnimator->isRangeDefined());
-
+
QLabel* aMinLbl = new QLabel("From", aRangeGrp);
aMinLbl->setEnabled(myUseRangeChk->isChecked());
aRangeLayout->addWidget(aMinLbl, 1, 0);
myMinVal->setValue( myAnimator->getMinRange() );
else
myMinVal->setValue( myAnimator->getMinTime() );
-
+
connect(myMinVal, SIGNAL( valueChanged(double)),
this, SLOT( onMinValue(double) ));
aRangeLayout->addWidget(myMinVal, 1, 1);
connect(myMaxVal, SIGNAL( valueChanged(double)),
this, SLOT( onMaxValue(double) ));
aRangeLayout->addWidget(myMaxVal, 1, 3);
-
+
connect(myUseRangeChk, SIGNAL( toggled(bool)),
aMinLbl, SLOT( setEnabled(bool) ));
connect(myUseRangeChk, SIGNAL( toggled(bool)),
aMainLayout->addWidget(aRangeGrp);
-
+
QHBox* aPropFrame = new QHBox(this);
aPropFrame->setSpacing(5);
-
- QVGroupBox* aNamesBox = new QVGroupBox("Fields",aPropFrame);
+
+ QVGroupBox* aNamesBox = new QVGroupBox("Fields",aPropFrame);
myFieldLst = new QListBox(aNamesBox);
QStringList aFieldNames;
// Find names of fields
}
myFieldLst->insertStringList(aFieldNames);
myFieldLst->setSelected(0, true);
- connect( myFieldLst, SIGNAL( highlighted(int) ),
+ connect( myFieldLst, SIGNAL( highlighted(int) ),
this, SLOT( onFieldChange(int) ) );
-
- QVGroupBox* aPropBox = new QVGroupBox("Properties", aPropFrame);
+
+ QVGroupBox* aPropBox = new QVGroupBox("Properties", aPropFrame);
myTypeCombo = new QComboBox(aPropBox);
- connect( myTypeCombo, SIGNAL( activated(int) ),
+ connect( myTypeCombo, SIGNAL( activated(int) ),
this, SLOT( onTypeChanged(int) ) );
-
+
// QPushButton* aBarBtn = new QPushButton("Scalar Bar...", aPropBox);
- //connect( aBarBtn, SIGNAL( clicked() ),
+ //connect( aBarBtn, SIGNAL( clicked() ),
// this, SLOT( onScalarBarDlg() ) );
-
+
myPropBtn = new QPushButton("Properties...", aPropBox);
// myPropBtn->setEnabled(theAnimator->getFieldData(0).myPrsType != VISU::TSCALARMAP);
- connect( myPropBtn, SIGNAL( clicked() ),
+ connect( myPropBtn, SIGNAL( clicked() ),
this, SLOT( onPreferencesDlg() ) );
onFieldChange(0);
aMainLayout->addWidget(aPropFrame);
-
+
QHBox* aBtnBox = new QHBox(this);
- QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout());
+ QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout());
aBtnLayout->addStretch();
-
+
QPushButton* aCloseBtn = new QPushButton(tr("VISU_BUT_OK"), aBtnBox);
connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
-
+
aMainLayout->addWidget(aBtnBox);
}
myTypeCombo->setCurrentItem(5);
aData.myPrsType = VISU::TSTREAMLINES;
break;
- }
+ }
//myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP);
}
/*void SetupDlg::onScalarBarDlg() {
QApplication::setOverrideCursor( Qt::waitCursor );
FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem());
- if (aData.myPrs == 0)
+ if (aData.myPrs == 0)
myAnimator->generatePresentations(myFieldLst->currentItem());
QApplication::restoreOverrideCursor();
//************************************************************************
void SetupDlg::onRangeCheck(bool theCheck) {
- for (int i = 0; i < myAnimator->getNbFields(); i++)
+ for (int i = 0; i < myAnimator->getNbFields(); i++)
myAnimator->clearData(myAnimator->getFieldData(i));
myMinVal->setEnabled(theCheck);
myAnimator->setAnimationRange(0, 0);
else {
// if (myMinVal->value() < myMaxVal->value())
- myAnimator->setAnimationRange(myMinVal->value(), myMaxVal->value());
+ myAnimator->setAnimationRange(myMinVal->value(), myMaxVal->value());
// else if (myMinVal->value() > myMaxVal->value())
// myAnimator->setAnimationRange(myMaxVal->value(), myMinVal->value());
// else // equal case
myMinVal->setFocus();
return;
}
- for (int i = 0; i < myAnimator->getNbFields(); i++)
+ for (int i = 0; i < myAnimator->getNbFields(); i++)
myAnimator->clearData(myAnimator->getFieldData(i));
myAnimator->setAnimationRange(theVal, myAnimator->getMaxRange());
}
myMaxVal->setFocus();
return;
}
- for (int i = 0; i < myAnimator->getNbFields(); i++)
+ for (int i = 0; i < myAnimator->getNbFields(); i++)
myAnimator->clearData(myAnimator->getFieldData(i));
myAnimator->setAnimationRange(myAnimator->getMinRange(), theVal);
}
static QPixmap MYpausePixmap(pauseIco);
-VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy)
- : QDialog( QAD_Application::getDesktop(), "VisuGUI_TimeAnimationDlg", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose)
+VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (SALOMEDS::Study_ptr theStudy)
+ : QDialog(QAD_Application::getDesktop(), "VisuGUI_TimeAnimationDlg", false, WStyle_Customize |
+ WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose)
{
setCaption("Animation");
setSizeGripEnabled( TRUE );
- myStudy = theStudy;
+ myStudy = SALOMEDS::Study::_duplicate(theStudy);
isClosing = false;
- myAnimator = new VISU_TimeAnimation(theStudy);
+ myAnimator = new VISU_TimeAnimation (theStudy);
myAnimator->setSpeed(1);
myAnimator->setViewer(VisuGUI::GetVtkViewFrame());
- connect( myAnimator, SIGNAL( frameChanged(long, double) ),
- this, SLOT( onExecution(long, double) ) );
- connect( myAnimator, SIGNAL( stopped() ),
- this, SLOT( onStop() ) );
+ connect(myAnimator, SIGNAL(frameChanged(long, double)), this, SLOT(onExecution(long, double)));
+ connect(myAnimator, SIGNAL(stopped()) , this, SLOT(onStop()));
QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
aMainLayout->setSpacing(5);
mySetupBtn = new QPushButton("Setup Animation...", this);
- connect( mySetupBtn, SIGNAL( clicked() ),
+ connect( mySetupBtn, SIGNAL( clicked() ),
this, SLOT( onSetupDlg() ) );
- aMainLayout->addWidget(mySetupBtn);
-
+ aMainLayout->addWidget(mySetupBtn);
+
myGenBtn = new QPushButton("Generate frames", this);
- connect( myGenBtn, SIGNAL( clicked() ),
+ connect( myGenBtn, SIGNAL( clicked() ),
this, SLOT( createFrames() ) );
aMainLayout->addWidget(myGenBtn);
myPlayFrame = new QFrame(this);
myPlayFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
myPlayFrame->setLineWidth( 1 );
-
+
// --- Play controls ---
- QGridLayout* TopLayout = new QGridLayout( myPlayFrame );
+ QGridLayout* TopLayout = new QGridLayout( myPlayFrame );
TopLayout->setSpacing( 6 );
TopLayout->setMargin( 11 );
mySlider->setTickInterval(1);
//mySlider->setTickmarks(QSlider::Below);
mySlider->setTracking(false);
- connect( mySlider, SIGNAL( valueChanged(int) ),
+ connect( mySlider, SIGNAL( valueChanged(int) ),
this, SLOT( onFrameChanged(int) ) );
TopLayout->addMultiCellWidget(mySlider, 1, 1, 0, 2);
myPlayBtn = new QToolButton(myPlayFrame);
myPlayBtn->setIconSet(MYplayPixmap);
myPlayBtn->setToggleButton(true);
- connect( myPlayBtn, SIGNAL( clicked() ),
+ connect( myPlayBtn, SIGNAL( clicked() ),
this, SLOT( onPlayPressed() ) );
TopLayout->addMultiCellWidget(myPlayBtn, 2, 2, 0, 1);
QToolButton* aBackBtn = new QToolButton(myPlayFrame);
aBackBtn->setIconSet(QPixmap(leftIco));
- connect( aBackBtn, SIGNAL( clicked() ),
+ connect( aBackBtn, SIGNAL( clicked() ),
this, SLOT( onBackPressed() ) );
TopLayout->addWidget(aBackBtn, 3, 0);
QToolButton* aForvardBtn = new QToolButton(myPlayFrame);
aForvardBtn->setIconSet(QPixmap(rightIco));
- connect( aForvardBtn, SIGNAL( clicked() ),
+ connect( aForvardBtn, SIGNAL( clicked() ),
this, SLOT( onForvardPressed() ) );
TopLayout->addWidget(aForvardBtn, 3, 1);
QToolButton* aFirstBtn = new QToolButton(myPlayFrame);
aFirstBtn->setIconSet(QPixmap(firstIco));
- connect( aFirstBtn, SIGNAL( clicked() ),
+ connect( aFirstBtn, SIGNAL( clicked() ),
this, SLOT( onFirstPressed() ) );
TopLayout->addWidget(aFirstBtn, 4, 0);
-
+
QToolButton* aLastBtn = new QToolButton(myPlayFrame);
aLastBtn->setIconSet(QPixmap(lastIco));
- connect( aLastBtn, SIGNAL( clicked() ),
+ connect( aLastBtn, SIGNAL( clicked() ),
this, SLOT( onLastPressed() ) );
TopLayout->addWidget(aLastBtn, 4, 1);
-
+
QLabel* aSpeedLbl = new QLabel("Speed", myPlayFrame);
TopLayout->addWidget(aSpeedLbl, 4, 2, Qt::AlignRight);
QwtWheel* aWheel = new QwtWheel(myPlayFrame);
aWheel->setOrientation(Qt::Vertical);
aWheel->setRange(1, 99, 1);
- connect( aWheel, SIGNAL(valueChanged(double)),
+ connect( aWheel, SIGNAL(valueChanged(double)),
aSpeedNum, SLOT(display(double)) );
- connect( aWheel, SIGNAL(valueChanged(double)),
+ connect( aWheel, SIGNAL(valueChanged(double)),
this, SLOT(onSpeedChange(double)) );
TopLayout->addMultiCellWidget(aWheel, 1, 3, 3, 3, Qt::AlignRight);
connect(mySaveCheck, SIGNAL( toggled(bool)),
aPathLbl, SLOT( setEnabled(bool) ));
aSaveLay->addWidget(aPathLbl, 1, 0);
-
+
myPathEdit = new QLineEdit(aSaveBox);
myPathEdit->setEnabled(false);
connect(mySaveCheck, SIGNAL( toggled(bool)),
aMainLayout->addWidget(myPlayFrame);
QHBox* aBtnBox = new QHBox(this);
- QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout());
+ QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout());
aBtnLayout->addStretch();
QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox);
connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
-
+
+ connect(VisuGUI::GetActiveStudy(), SIGNAL(closed()), this, SLOT(close()));
+
aMainLayout->addWidget(aBtnBox);
myPlayFrame->setEnabled(false);
void VisuGUI_TimeAnimationDlg::onTypeChange(int index) {
stopAnimation();
myPropBtn->setEnabled(index != 0);
-
+
clearView();
myPlayFrame->setEnabled(false);
}
QApplication::setOverrideCursor( Qt::waitCursor );
for (int i = 0; i < myAnimator->getNbFields(); i++) {
- if (myAnimator->getFieldData(i).myPrs.empty())
+ if (myAnimator->getFieldData(i).myPrs.empty())
myAnimator->generatePresentations(i);
}
if (myAnimator->getNbFrames() == 0) {
myPlayFrame->setEnabled(false);
QApplication::restoreOverrideCursor();
- QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_NO_ANIMATIONDATA"));
- return;
- }
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_NO_ANIMATIONDATA"));
+ return;
+ }
mySlider->setMaxValue(myAnimator->getNbFrames()-1);
myPlayFrame->setEnabled(true);
if (!myAnimator->generateFrames()) {
QApplication::restoreOverrideCursor();
//myPlayFrame->setEnabled(false);
- QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), myAnimator->getLastErrorMsg());
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), myAnimator->getLastErrorMsg());
return;
}
//myPlayFrame->setEnabled(true);
QApplication::restoreOverrideCursor();
}
-
-
+
+
//************************************************************************
void VisuGUI_TimeAnimationDlg::onPlayPressed() {
//************************************************************************
void VisuGUI_TimeAnimationDlg::closeEvent(QCloseEvent* theEvent) {
myAnimator->stopAnimation();
+ myAnimator->wait(500);
if (myAnimator->running() && (! myAnimator->finished())) {
isClosing = true;
myEvent = theEvent;
void VisuGUI_TimeAnimationDlg::onSpeedChange(double theSpeed) {
myAnimator->setSpeed((int)theSpeed);
}
-
+
//************************************************************************
void VisuGUI_TimeAnimationDlg::stopAnimation() {