From f46a05e668cbfc6825e10cf20682e0f849c674a6 Mon Sep 17 00:00:00 2001 From: stv Date: Thu, 4 Dec 2008 11:20:59 +0000 Subject: [PATCH] Bug fix for IPAL20319. --- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 177 +++++++++++++------------- src/VISUGUI/VisuGUI_TimeAnimation.h | 1 - 2 files changed, 91 insertions(+), 87 deletions(-) diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 86df91b6..1d4039d0 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -1,20 +1,20 @@ // 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 -// +// 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_TimeAnimation.cxx @@ -97,28 +97,28 @@ namespace { { theAnimator->generatePresentations(theFieldId); FieldData& aFieldData = theAnimator->getFieldData(theFieldId); - - + + int aRefFieldId = ( theAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) ? theFieldId : 0; if(VISU::ColoredPrs3d_i* aInitialPrs3d = dynamic_cast(theAnimator->getFieldData(aRefFieldId).myPrs[0])){ for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) { VISU::ColoredPrs3d_i* aColoredPrs3d = aFieldData.myPrs[aFrameId]; - + // Special case for DeformedShape And ScalarMap presentation // Restore time stamp number for all presentations VISU::DeformedShapeAndScalarMap_i* aDeformedAndScalPrs = dynamic_cast(aColoredPrs3d); int aTimeStampNum = -1; if(aDeformedAndScalPrs){ aTimeStampNum = aDeformedAndScalPrs->GetScalarTimeStampNumber(); - } + } aColoredPrs3d->SameAs(aInitialPrs3d); - + if(aDeformedAndScalPrs){ aDeformedAndScalPrs->SetScalarField(aDeformedAndScalPrs->GetScalarEntity(), aDeformedAndScalPrs->GetScalarFieldName(), aTimeStampNum); } - + std::string aTitle = aColoredPrs3d->GetCTitle(); if ( aFrameId != 0 && theAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) { aColoredPrs3d->SetTitle(aTitle.c_str()); @@ -152,11 +152,11 @@ ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) myFieldLst->setCurrentRow(0); } -ArrangeDlg::ArrangeDlg(QWidget* theParent, +ArrangeDlg::ArrangeDlg(QWidget* theParent, const SalomeApp_Module* theModule, SVTK_ViewWindow* theViewWindow) : QDialog(theParent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), - myAnimator(NULL), + myAnimator(NULL), myViewWindow(theViewWindow) { setModal( true ); @@ -236,7 +236,7 @@ void ArrangeDlg::init() QGroupBox* aBtnGB = new QGroupBox( this ); QHBoxLayout* aHBLay = new QHBoxLayout( aBtnGB ); aMainLayout->addWidget(aBtnGB); - + QRadioButton* aAutoBtn = new QRadioButton("Auto", aBtnGB); aHBLay->addWidget( aAutoBtn ); aBtnGrp->addButton(aAutoBtn, AutoMode); @@ -252,7 +252,7 @@ void ArrangeDlg::init() // AUTO Pane QWidget* aAutoPane = new QWidget(myStackWgt); - QVBoxLayout* aAutoLay = new QVBoxLayout( aAutoPane ); + QVBoxLayout* aAutoLay = new QVBoxLayout( aAutoPane ); aAutoLay->setSpacing(5); // Axis Group @@ -283,7 +283,7 @@ void ArrangeDlg::init() aHLay->addWidget( new QLabel("Relative Distance", aDistPane) ); myDistVal = new QtxDoubleSpinBox (-10,10, 0.5, aDistPane); myDistVal->setValue(1); - aHLay->addWidget( myDistVal ); + aHLay->addWidget( myDistVal ); aAutoLay->addWidget( aDistPane ); @@ -633,9 +633,9 @@ void ArrangeDlg::acceptViewWindow() //------------------------------------------------------------------------ //------------------------------------------------------------------------ SetupDlg::SetupDlg (QWidget* theParent, - VisuGUI* theModule, + VisuGUI* theModule, VISU_TimeAnimation* theAnimator) : - QDialog(theParent, + QDialog(theParent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), myAnimator(theAnimator), myModule(theModule), @@ -661,7 +661,7 @@ SetupDlg::SetupDlg (QWidget* theParent, double aMaxTime = myAnimator->getMaxTime(); double aMinTime = myAnimator->getMinTime(); double aStep = 1; - if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) + if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) aStep = (aMaxTime - aMinTime) / (myAnimator->getFieldData(0).myNbTimes - 1); else { // successive animation mode std::pair aLastFieldFrame(myAnimator->getNbFields() - 1, @@ -673,7 +673,7 @@ SetupDlg::SetupDlg (QWidget* theParent, aRangeLayout->addWidget(aMinLbl); //myMinVal = new QtxDoubleSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox ); myMinVal = new QLineEdit(myUseRangeBox); - myMinVal->setValidator(new QDoubleValidator(aMinTime, aMaxTime, VALPRECISION, myMinVal)); + myMinVal->setValidator( new QDoubleValidator( myMinVal ) ); if (myUseRangeBox->isChecked()) myMinVal->setText( QString::number(myAnimator->getMinRange()) ); else @@ -681,17 +681,16 @@ SetupDlg::SetupDlg (QWidget* theParent, // connect(myMinVal, SIGNAL( valueChanged(double)), // this, SLOT( onMinValue(double) )); - connect(myMinVal, SIGNAL( editingFinished()), - this, SLOT( onMinValue() )); - connect(myMinVal, SIGNAL( textChanged(const QString&)), - this, SLOT( onMinValueEdit(const QString&) )); + connect( myMinVal, SIGNAL( editingFinished() ), this, SLOT( onMinValue() ) ); +// connect( myMinVal, SIGNAL( textChanged(const QString&)), +// this, SLOT( onMinValueEdit(const QString&) )); aRangeLayout->addWidget(myMinVal); QLabel* aMaxLbl = new QLabel("To", myUseRangeBox); aRangeLayout->addWidget(aMaxLbl); //myMaxVal = new QtxDoubleSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox ); myMaxVal = new QLineEdit(myUseRangeBox); - myMaxVal->setValidator(new QDoubleValidator(aMinTime, aMaxTime, VALPRECISION, myMaxVal)); + myMaxVal->setValidator( new QDoubleValidator( myMaxVal ) ); if (myUseRangeBox->isChecked()) myMaxVal->setText( QString::number(myAnimator->getMaxRange()) ); else { @@ -699,10 +698,9 @@ SetupDlg::SetupDlg (QWidget* theParent, } // connect(myMaxVal, SIGNAL( valueChanged(double)), // this, SLOT( onMaxValue(double) )); - connect(myMaxVal, SIGNAL( editingFinished() ), - this, SLOT( onMaxValue() )); - connect(myMaxVal, SIGNAL( textChanged(const QString&)), - this, SLOT( onMaxValueEdit(const QString&) )); + connect( myMaxVal, SIGNAL( editingFinished() ), this, SLOT( onMaxValue() ) ); +// connect(myMaxVal, SIGNAL( textChanged(const QString&)), +// this, SLOT( onMaxValueEdit(const QString&) )); aRangeLayout->addWidget(myMaxVal); connect(myUseRangeBox, SIGNAL( toggled(bool)), @@ -750,7 +748,7 @@ SetupDlg::SetupDlg (QWidget* theParent, QGroupBox* aNamesBox = new QGroupBox("Fields",aPropFrame); aHPropLayout->addWidget( aNamesBox ); QVBoxLayout* aVBoxLayout = new QVBoxLayout( aNamesBox ); - + myFieldLst = new QListWidget(aNamesBox); aVBoxLayout->addWidget( myFieldLst ); QStringList aFieldNames; @@ -770,7 +768,7 @@ SetupDlg::SetupDlg (QWidget* theParent, } } myFieldLst->addItems(aFieldNames); - + if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) { myFieldLst->setCurrentRow(0); connect( myFieldLst, SIGNAL( currentRowChanged(int) ), @@ -778,7 +776,7 @@ SetupDlg::SetupDlg (QWidget* theParent, } else if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) myFieldLst->setSelectionMode(QAbstractItemView::NoSelection); - + QWidget* aSetupBox = new QWidget(aPropFrame); aHPropLayout->addWidget( aSetupBox ); aVBoxLayout = new QVBoxLayout( aSetupBox ); @@ -788,7 +786,7 @@ SetupDlg::SetupDlg (QWidget* theParent, QGroupBox* aPropBox = new QGroupBox("Properties", aSetupBox); aVBoxLayout->addWidget( aPropBox ); QVBoxLayout* aPropVBLay = new QVBoxLayout( aPropBox ); - + //QVGroupBox* aPropBox = new QVGroupBox("Properties", aPropFrame); myTypeCombo = new QComboBox(aPropBox); aPropVBLay->addWidget( myTypeCombo ); @@ -800,6 +798,7 @@ SetupDlg::SetupDlg (QWidget* theParent, // this, SLOT( onScalarBarDlg() ) ); myPropBtn = new QPushButton("Properties...", aPropBox); + myPropBtn->setAutoDefault( false ); aPropVBLay->addWidget( myPropBtn ); // myPropBtn->setEnabled(myAnimator->getFieldData(0).myPrsType != VISU::TSCALARMAP); connect( myPropBtn, SIGNAL( clicked() ), @@ -818,13 +817,15 @@ SetupDlg::SetupDlg (QWidget* theParent, QWidget* aBtnBox = new QWidget(this); QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox); aBtnLayout->setContentsMargins( 5, 5, 0, 5 ); - aBtnLayout->addStretch(); + // aBtnLayout->addStretch(); - QPushButton* aCloseBtn = new QPushButton(tr("BUT_OK"), aBtnBox); - aBtnLayout->addWidget( aCloseBtn ); - connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose())); + QPushButton* closeBtn = new QPushButton( tr( "BUT_CLOSE" ), aBtnBox ); + closeBtn->setAutoDefault( false ); + aBtnLayout->addStretch(); + aBtnLayout->addWidget( closeBtn ); + connect( closeBtn, SIGNAL( clicked() ), this, SLOT( onClose() ) ); - aMainLayout->addWidget(aBtnBox); + aMainLayout->addWidget( aBtnBox ); } //------------------------------------------------------------------------ @@ -837,7 +838,8 @@ void SetupDlg::initialize() FieldData& aData = myAnimator->getFieldData( 0 ); _PTR(SObject) aField = aData.myField; - if(!aField) return; + if ( !aField ) + return; _PTR(ChildIterator) anIter = aStudy->NewChildIterator(aField); anIter->Next(); // First is reference on support @@ -870,12 +872,18 @@ enum PrsComboItem { //------------------------------------------------------------------------ void SetupDlg::onClose() { - if( !myUseRangeBox->isChecked() ) + if ( !myUseRangeBox->isChecked() ) myAnimator->setAnimationRange( 0, 0 ); - - if( !myUseSequenceBox->isChecked() ) + else + { + double min = myMinVal->text().toDouble(); + double max = myMaxVal->text().toDouble(); + myAnimator->setAnimationRange( qMin( min, max ), qMax( min, max ) ); + } + + if ( !myUseSequenceBox->isChecked() ) myAnimator->setAnimationSequence( 0 ); - + close(); } @@ -911,13 +919,13 @@ void SetupDlg::onFieldChange (int theIndex) bool anEnableGP = false; VISU::VISUType aPrsType; if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) { // parallel animation mode - + FieldData& aData = myAnimator->getFieldData(theIndex); _PTR(SObject) aSObject = aData.myField; VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aSObject); long aNumComp = aRestoringMap["myNumComponent"].toLong(); anEnableItems = (aNumComp > 1); - + long anEntityId = aRestoringMap["myEntityId"].toLong(); anEnableGP = (anEntityId == VISU::CELL); @@ -925,13 +933,13 @@ void SetupDlg::onFieldChange (int theIndex) } else if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) { // successive animation mode - + for (int i = 0; i < myAnimator->getNbFields(); i++) { _PTR(SObject) aSO = myAnimator->getFieldData(i).myField; VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aSO); long aNumComp = aRestoringMap["myNumComponent"].toLong(); anEnableItems = (aNumComp > 1); - + long anEntityId = aRestoringMap["myEntityId"].toLong(); anEnableGP = (anEntityId == VISU::CELL); @@ -1006,7 +1014,7 @@ void SetupDlg::onFieldChange (int theIndex) void SetupDlg::onTypeChanged (int theIndex) { int aType = myComboId2TypeId[theIndex]; - + for (int i = 0; i < myAnimator->getNbFields(); i++) { FieldData& aData = ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) ? myAnimator->getFieldData(myFieldLst->currentRow()) : @@ -1097,12 +1105,12 @@ void SetupDlg::onPreferencesDlg() VISU::Animation::AnimationMode aMode = myAnimator->getAnimationMode(); int aRefFieldId = ( aMode == VISU::Animation::PARALLEL ) ? myFieldLst->currentRow() : 0; FieldData& aData = myAnimator->getFieldData(aRefFieldId); - if (aData.myPrs.empty()) + if (aData.myPrs.empty()) myAnimator->generatePresentations(aRefFieldId); if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) { for (int i = 0; i < myAnimator->getNbFields(); i++) { - if ( i != aRefFieldId && myAnimator->getFieldData(i).myPrs.empty() ) + if ( i != aRefFieldId && myAnimator->getFieldData(i).myPrs.empty() ) myAnimator->generatePresentations(i); } } @@ -1161,7 +1169,7 @@ void SetupDlg::onPreferencesDlg() aTimeStampNum); } - + if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) { for (int aFieldId = 1; aFieldId < myAnimator->getNbFields(); aFieldId++) { FieldData& aFieldData = myAnimator->getFieldData(aFieldId); @@ -1178,7 +1186,7 @@ void SetupDlg::onPreferencesDlg() } } - } + } } delete aDlg; } @@ -1225,32 +1233,29 @@ void SetupDlg::onRangeCheck (bool theCheck) } //------------------------------------------------------------------------ -void SetupDlg::onMinValue () +void SetupDlg::onMinValue() { double aVal = myMinVal->text().toDouble(); - if (aVal > myAnimator->getMaxRange()) { - myMinVal->setText( QString::number(myAnimator->getMinTime()) ); - myMinVal->setFocus(); - return; - } - myAnimator->setAnimationRange(aVal, myAnimator->getMaxRange()); + aVal = qMax( qMin( aVal, myAnimator->getMaxRange() ), myAnimator->getMinTime() ); + myAnimator->setAnimationRange( aVal, myAnimator->getMaxRange() ); + myMinVal->setText( QString::number( aVal ) ); + myMinVal->setFocus(); setIsRegenerate( true ); } //------------------------------------------------------------------------ -void SetupDlg::onMaxValue () +void SetupDlg::onMaxValue() { double aVal = myMaxVal->text().toDouble(); - if (aVal < myAnimator->getMinRange()) { - myMaxVal->setText( QString::number(myAnimator->getMaxTime()) ); - myMaxVal->setFocus(); - return; - } - myAnimator->setAnimationRange(myAnimator->getMinRange(), aVal); + aVal = qMin( qMax( aVal, myAnimator->getMinRange() ), myAnimator->getMaxTime() ); + myAnimator->setAnimationRange( myAnimator->getMinRange(), aVal ); + myMaxVal->setText( QString::number( aVal ) ); + myMaxVal->setFocus(); setIsRegenerate( true ); } + //------------------------------------------------------------------------ void SetupDlg::onMinValueEdit (const QString& theVal) { @@ -1269,7 +1274,7 @@ void SetupDlg::onMaxValueEdit (const QString& theVal) if ((aVal > myAnimator->getMaxRange()) || (aVal < myAnimator->getMinRange())) { myMaxVal->setText( QString::number(myAnimator->getMaxTime()) ); myMaxVal->setFocus(); - } + } } //------------------------------------------------------------------------ @@ -1324,7 +1329,7 @@ void SetupDlg::onIndicesChanged( const QString& theIndices ) myIndices->setPalette(palette); return; } - + palette.setColor(myIndices->foregroundRole(), Qt::black); myIndices->setPalette(palette); @@ -1375,7 +1380,7 @@ void SetupDlg::onValuesChanged() QPalette palette = myIndices->palette(); palette.setColor(myIndices->foregroundRole(), Qt::black); myIndices->setPalette(palette); - + myIndices->setText( anIndices ); myIndices->blockSignals( false ); @@ -1493,9 +1498,9 @@ static QPixmap MYpausePixmap(pauseIco); VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, - _PTR(Study) theStudy, + _PTR(Study) theStudy, VISU::Animation::AnimationMode theMode) : - QDialog(VISU::GetDesktop(theModule), + QDialog(VISU::GetDesktop(theModule), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), myModule(theModule), mySetupDlg(NULL) @@ -1850,7 +1855,7 @@ void VisuGUI_TimeAnimationDlg::onPlayPressed() if (mySaveCheck->isChecked()) { onPicsFormatChanged(); onPathChanged(); - + } else if (mySaveAVICheck->isChecked()) { myAnimator->setDumpFormat("AVI"); myAnimator->dumpTo(myPathAVIEdit->text().toLatin1().data()); @@ -1957,7 +1962,7 @@ void VisuGUI_TimeAnimationDlg::onExecution (long theNewFrame, double theTime) //------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onSetupDlg() { - if (myAnimator->getNbFrames() > 0) + if (myAnimator->getNbFrames() > 0) myAnimator->firstFrame(); mySetupDlg->exec(); myPlayFrame->setEnabled(false); @@ -1970,7 +1975,7 @@ void VisuGUI_TimeAnimationDlg::onBrowse() QString aDir; if (myPathEdit->text().isEmpty()) aDir = getenv("HOME"); - else + else aDir = myPathEdit->text(); QString aPath = SUIT_FileDlg::getExistingDirectory(this, aDir, "Select path"); if (!aPath.isEmpty()) @@ -2092,7 +2097,7 @@ void VisuGUI_TimeAnimationDlg::restoreFromStudy(_PTR(SObject) theAnimation) { myAnimator->restoreFromStudy(theAnimation); mySaveBtn->setEnabled(myAnimator->isSavedInStudy()); - if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) + if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) setWindowTitle(tr("SUCCESSIVE_ANIMATION")); } diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index 400f8513..3a7d9df2 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -176,7 +176,6 @@ class SetupDlg: public QDialog { QListWidget* myValues; }; - class VisuGUI_TimeAnimationDlg: public QDialog { Q_OBJECT -- 2.39.2