From: ouv Date: Mon, 15 Jun 2009 07:40:31 +0000 (+0000) Subject: Fix of issue 0020380: EDF 1048 VISU: Presentation with negative time stamps X-Git-Tag: V5_1_2rc2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a7f0311045c77d6654ed9ccd59c0d62a2ef8634e;p=modules%2Fvisu.git Fix of issue 0020380: EDF 1048 VISU: Presentation with negative time stamps --- diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 8d0f0e6a..f87ed8aa 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -46,6 +46,11 @@ #include +#ifdef WNT +#include +#define isnan _isnan +#endif + using MED::TInt; using MED::TFloat; using MED::EBooleen; @@ -1591,8 +1596,8 @@ BuildTimeStampMinMax(MED::SharedPtr theTimeStampValue, vtkFloatingPointType anAverageValue = 0.0; for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){ const vtkFloatingPointType& aVal = aMValueSlice[iGauss]; - aMin = std::min(aMin,aVal); - aMax = std::max(aMax,aVal); + aMin = isnan(aVal) ? aVal : std::min(aMin,aVal); + aMax = isnan(aVal) ? aVal : std::max(aMax,aVal); if(isAverageByGaussPoints){ anAverageValue += aVal; } @@ -1626,8 +1631,8 @@ BuildTimeStampMinMax(MED::SharedPtr theTimeStampValue, aValue += aVal*aVal; } aValue = sqrt(aValue); - aMin = std::min(aMin,aValue); - aMax = std::max(aMax,aValue); + aMin = isnan(aValue) ? aValue : std::min(aMin,aValue); + aMax = isnan(aValue) ? aValue : std::max(aMax,aValue); } if(isAverageByGaussPoints){ typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMCompValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem); diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx index 34f1a8ae..50a545bf 100644 --- a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx @@ -434,6 +434,9 @@ void VISU_DeformedShapeAndScalarMapPL ::SetScalarRange(vtkFloatingPointType theRange[2]) { + if (isnan(theRange[0]) || isnan(theRange[1])) + throw std::runtime_error("Arithmetic exception detected"); + if(VISU::CheckIsSameRange(theRange, GetScalarRange())) return; diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 642865fe..1c75f4a1 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -3035,6 +3035,11 @@ Please, provide non-empty resulting presentation. DLG_TITLE Deformed Shape and Scalar Map + + ERR_SCALAR_DATA_INCONSISTENT + Scalar data on the selected field is inconsistent. +Please select another field. + FIELD_ITEM Scalar Field: diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx index 3d57aa32..b5415a4c 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx @@ -71,6 +71,7 @@ VisuGUI_DeformedShapeAndScalarMapDlg::VisuGUI_DeformedShapeAndScalarMapDlg (Salo : VisuGUI_ScalarBarBaseDlg(theModule), myIsAnimation(false), myUpdateScalars(true), + myIsScalarFieldValid(true), myVisuGUI(theModule) { setWindowTitle(tr("DLG_TITLE")); @@ -136,15 +137,15 @@ VisuGUI_DeformedShapeAndScalarMapDlg::VisuGUI_DeformedShapeAndScalarMapDlg (Salo GroupButtonsLayout->setSpacing(6); GroupButtonsLayout->setMargin(11); - QPushButton* buttonOk = new QPushButton (tr("&OK"), GroupButtons); - buttonOk->setAutoDefault(true); - buttonOk->setDefault(true); + myButtonOk = new QPushButton (tr("&OK"), GroupButtons); + myButtonOk->setAutoDefault(true); + myButtonOk->setDefault(true); QPushButton* buttonCancel = new QPushButton (tr("&Cancel") , GroupButtons); buttonCancel->setAutoDefault(true); QPushButton* buttonHelp = new QPushButton (tr("&Help") , GroupButtons); buttonHelp->setAutoDefault(true); - GroupButtonsLayout->addWidget(buttonOk); + GroupButtonsLayout->addWidget(myButtonOk); GroupButtonsLayout->addSpacing(10); GroupButtonsLayout->addStretch(); GroupButtonsLayout->addWidget(buttonCancel); @@ -155,7 +156,7 @@ VisuGUI_DeformedShapeAndScalarMapDlg::VisuGUI_DeformedShapeAndScalarMapDlg (Salo TopLayout->addWidget(GroupButtons); // signals and slots connections - connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(myButtonOk, SIGNAL(clicked()), this, SLOT(accept())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); connect(myFieldsCombo, SIGNAL(activated(int)), this, SLOT(onFieldChanged(int))); @@ -378,7 +379,7 @@ VisuGUI_DeformedShapeAndScalarMapDlg { QApplication::setOverrideCursor(Qt::WaitCursor); - if( save_scalar_pane ) + if( save_scalar_pane && IsScalarFieldValid() ) GetScalarPane()->storeToPrsObject(myPrsCopy); QString aFieldName; @@ -390,12 +391,19 @@ VisuGUI_DeformedShapeAndScalarMapDlg VISU::Entity anEntity = getCurrentScalarEntity(); - myPrsCopy->SetScalarField(anEntity, - aFieldName.toLatin1().constData(), - theIter); - - if( save_scalar_pane ) - UpdateScalarField(); + try { + myPrsCopy->SetScalarField(anEntity, + aFieldName.toLatin1().constData(), + theIter); + if( save_scalar_pane ) + UpdateScalarField(); + myIsScalarFieldValid = true; + } catch( std::exception& exc ) { + INFOS( exc.what() ); + SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ), tr( "ERR_SCALAR_DATA_INCONSISTENT" ) ); + myIsScalarFieldValid = false; + } + updateControls(); QApplication::restoreOverrideCursor(); } @@ -461,12 +469,12 @@ void VisuGUI_DeformedShapeAndScalarMapDlg::AddAllTimes(const QString& theFieldNa void VisuGUI_DeformedShapeAndScalarMapDlg::onFieldChanged(int){ AddAllTimes(myFieldsCombo->currentText()); SetScalarField(); - UpdateScalarField(); + //UpdateScalarField(); // it is called from SetScalarField() method } void VisuGUI_DeformedShapeAndScalarMapDlg::onTimeStampChanged(int){ SetScalarField(); - UpdateScalarField(); + //UpdateScalarField(); // it is called from SetScalarField() method } void VisuGUI_DeformedShapeAndScalarMapDlg::UpdateScalarField(){ @@ -497,3 +505,12 @@ VisuGUI_DeformedShapeAndScalarMapDlg } return aTime; } + +void VisuGUI_DeformedShapeAndScalarMapDlg::updateControls() +{ + bool isScalarFieldValid = IsScalarFieldValid(); + myTabBox->setTabEnabled( 1, isScalarFieldValid ); // "Scalar Bar" tab + myTabBox->setTabEnabled( 2, isScalarFieldValid ); // "Input" tab + myTimeStampsCombo->setEnabled( isScalarFieldValid ); + myButtonOk->setEnabled( isScalarFieldValid ); +} diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h index c8d53ef3..51dfa3f3 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h @@ -69,6 +69,8 @@ public: VISU::Entity getCurrentScalarEntity(); void SetScalarField(int theIter,QString theFieldName=QString(""), const bool = true ); + bool IsScalarFieldValid() const { return myIsScalarFieldValid; } + protected: virtual QString GetContextHelpFilePath(); @@ -87,6 +89,7 @@ private: VisuGUI_InputPane* myInputPane; QComboBox *myFieldsCombo; QComboBox *myTimeStampsCombo; + QPushButton* myButtonOk; typedef std::map TTimeStampNumber2Time; // Times map definition (iteration time, real value of time) typedef std::map TFieldName2TimeStamps; // Field name and enity to Times @@ -101,6 +104,8 @@ private: _PTR(SObject) mySelectionObj; SALOME::GenericObjPtr myPrsCopy; SalomeApp_Module* myVisuGUI; + + bool myIsScalarFieldValid; protected: void UpdateScalarField(); @@ -110,6 +115,7 @@ protected: QString GetFloatValueOfTimeStamp(VISU::Entity theEntity, const std::string& theFieldName, int theTimeStampNumber); + void updateControls(); }; #endif // VISUGUI_DEFORMEDSHAPEDLS_H