From 03e21a6ff53f9efc01bb1680c701a02e47589caa Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 27 Jul 2005 07:16:41 +0000 Subject: [PATCH] PAL8501: open-close Animation db 5 times - exception; IPAL8983: close study during animation playing - SIGILL --- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 170 +++++++++++++------------- src/VISUGUI/VisuGUI_TimeAnimation.h | 35 +++--- src/VISU_I/VISU_TimeAnimation.cxx | 17 ++- 3 files changed, 115 insertions(+), 107 deletions(-) diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index d4465510..d30063bf 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -9,32 +9,15 @@ // Module : VISU #include "VisuGUI_TimeAnimation.h" -#include "VisuGUI.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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" @@ -43,22 +26,39 @@ #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 +#include +#include +#include +#include +#include +#include +#include +#include -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); @@ -66,7 +66,7 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) 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); @@ -77,7 +77,7 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) myMinVal->setValue( myAnimator->getMinRange() ); else myMinVal->setValue( myAnimator->getMinTime() ); - + connect(myMinVal, SIGNAL( valueChanged(double)), this, SLOT( onMinValue(double) )); aRangeLayout->addWidget(myMinVal, 1, 1); @@ -95,7 +95,7 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) 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)), @@ -105,11 +105,11 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) 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 @@ -118,34 +118,34 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) } 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); } @@ -185,7 +185,7 @@ void SetupDlg::onFieldChange(int theIndex) { myTypeCombo->setCurrentItem(5); aData.myPrsType = VISU::TSTREAMLINES; break; - } + } //myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP); } @@ -222,7 +222,7 @@ void SetupDlg::onTypeChanged(int theIndex) { /*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(); @@ -294,7 +294,7 @@ void SetupDlg::onPreferencesDlg() { //************************************************************************ 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); @@ -304,7 +304,7 @@ void SetupDlg::onRangeCheck(bool 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 @@ -319,7 +319,7 @@ void SetupDlg::onMinValue(double theVal) { 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()); } @@ -331,7 +331,7 @@ void SetupDlg::onMaxValue(double theVal) { 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); } @@ -445,42 +445,41 @@ static const char * pauseIco[] = { 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 ); @@ -493,41 +492,41 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) 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); @@ -539,9 +538,9 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) 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); @@ -571,7 +570,7 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) 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)), @@ -592,12 +591,14 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) 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); @@ -614,7 +615,7 @@ VisuGUI_TimeAnimationDlg::~VisuGUI_TimeAnimationDlg() { void VisuGUI_TimeAnimationDlg::onTypeChange(int index) { stopAnimation(); myPropBtn->setEnabled(index != 0); - + clearView(); myPlayFrame->setEnabled(false); } @@ -634,28 +635,28 @@ void VisuGUI_TimeAnimationDlg::createFrames() { 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() { @@ -711,6 +712,7 @@ void VisuGUI_TimeAnimationDlg::clearView() { //************************************************************************ void VisuGUI_TimeAnimationDlg::closeEvent(QCloseEvent* theEvent) { myAnimator->stopAnimation(); + myAnimator->wait(500); if (myAnimator->running() && (! myAnimator->finished())) { isClosing = true; myEvent = theEvent; @@ -731,7 +733,7 @@ void VisuGUI_TimeAnimationDlg::onFrameChanged(int index) { void VisuGUI_TimeAnimationDlg::onSpeedChange(double theSpeed) { myAnimator->setSpeed((int)theSpeed); } - + //************************************************************************ void VisuGUI_TimeAnimationDlg::stopAnimation() { diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index 1480326c..44bdcf69 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -35,10 +35,10 @@ class SetupDlg: public QDialog { public: SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator); ~SetupDlg() {}; - + private slots: void onFieldChange(int theIndex); - void onTypeChanged(int theIndex); + void onTypeChanged(int theIndex); // void onScalarBarDlg(); void onPreferencesDlg(); void onRangeCheck(bool theCheck); @@ -58,10 +58,10 @@ private: class VisuGUI_TimeAnimationDlg: public QDialog -{ +{ Q_OBJECT public: - VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy); + VisuGUI_TimeAnimationDlg(SALOMEDS::Study_ptr theStudy); ~VisuGUI_TimeAnimationDlg(); void addField(SALOMEDS::SObject_var theField); @@ -72,19 +72,19 @@ class VisuGUI_TimeAnimationDlg: public QDialog void stopAnimation(); private slots: - void onTypeChange(int index); - void onPlayPressed(); - void onBackPressed(); - void onForvardPressed(); - void onLastPressed(); - void onFirstPressed(); - void onSetupDlg(); - void onFrameChanged(int index); - void createFrames(); - void onSpeedChange(double theSpeed); - void onExecution(long theNewFrame, double theTime); - void onBrowse(); - void onStop(); + void onTypeChange(int index); + void onPlayPressed(); + void onBackPressed(); + void onForvardPressed(); + void onLastPressed(); + void onFirstPressed(); + void onSetupDlg(); + void onFrameChanged(int index); + void createFrames(); + void onSpeedChange(double theSpeed); + void onExecution(long theNewFrame, double theTime); + void onBrowse(); + void onStop(); private: QSlider* mySlider; @@ -104,4 +104,5 @@ class VisuGUI_TimeAnimationDlg: public QDialog bool isClosing; QCloseEvent* myEvent; }; + #endif //VISUGUI_TIMEANIMATION_H diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 23e22671..bab5863b 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -31,15 +31,17 @@ using namespace std; //************************************************************************ -VISU_TimeAnimation::VISU_TimeAnimation(SALOMEDS::Study_ptr theStudy, VISU::View3D_ptr theView3D) { - myStudy = theStudy; +VISU_TimeAnimation::VISU_TimeAnimation (SALOMEDS::Study_ptr theStudy, + VISU::View3D_ptr theView3D) +{ + myStudy = SALOMEDS::Study::_duplicate(theStudy); myIsActive = false; myFrame = 0; mySpeed = 1; myProportional = false; myView = 0; - if(!CORBA::is_nil(theView3D)){ + if (!CORBA::is_nil(theView3D)) { VISU::View3D_i* pView = dynamic_cast(GetServant(theView3D).in()); QAD_StudyFrame* aStudyFrame = pView->GetStudyFrame(); myView = VISU::GetViewFrame(aStudyFrame); @@ -55,7 +57,8 @@ VISU_TimeAnimation::VISU_TimeAnimation(SALOMEDS::Study_ptr theStudy, VISU::View3 //************************************************************************ -VISU_TimeAnimation::~VISU_TimeAnimation() { +VISU_TimeAnimation::~VISU_TimeAnimation() +{ for (int i = 0; i < getNbFields(); i++) { clearData(myFieldsLst[i]); } @@ -63,7 +66,8 @@ VISU_TimeAnimation::~VISU_TimeAnimation() { //************************************************************************ -void VISU_TimeAnimation::addField(SALOMEDS::SObject_ptr theField) { +void VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField) +{ FieldData aNewData; aNewData.myField = SALOMEDS::SObject::_duplicate(theField); aNewData.myNbFrames = 0; @@ -86,7 +90,8 @@ void VISU_TimeAnimation::addField(SALOMEDS::SObject_ptr theField) { //************************************************************************ -void VISU_TimeAnimation::clearData(FieldData& theData) { +void VISU_TimeAnimation::clearData (FieldData& theData) +{ theData.myTiming.clear(); vtkRenderer* aRen = myView->getRenderer(); if (!theData.myActors.empty()) { -- 2.39.2