From 9f22bbf1c5429e2d2c34d80e5ea0c3e707815641 Mon Sep 17 00:00:00 2001 From: ouv Date: Mon, 15 Jun 2009 07:42:08 +0000 Subject: [PATCH] Fix of issue 0020380: EDF 1048 VISU: Presentation with negative time stamps --- src/CONVERTOR/VISU_MedConvertor.cxx | 13 ++++-- .../VISU_DeformedShapeAndScalarMapPL.cxx | 3 ++ src/VISUGUI/VISU_msg_en.po | 3 ++ .../VisuGUI_DeformedShapeAndScalarMapDlg.cxx | 44 +++++++++++++------ .../VisuGUI_DeformedShapeAndScalarMapDlg.h | 6 +++ 5 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 27a7c0a8..39a3a6c1 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -45,6 +45,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 = min(aMin,aVal); - aMax = max(aMax,aVal); + aMin = isnan(aVal) ? aVal : min(aMin,aVal); + aMax = isnan(aVal) ? aVal : max(aMax,aVal); if(isAverageByGaussPoints){ anAverageValue += aVal; } @@ -1626,8 +1631,8 @@ BuildTimeStampMinMax(MED::SharedPtr theTimeStampValue, aValue += aVal*aVal; } aValue = sqrt(aValue); - aMin = min(aMin,aValue); - aMax = max(aMax,aValue); + aMin = isnan(aValue) ? aValue : min(aMin,aValue); + aMax = isnan(aValue) ? aValue : 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 732f522c..55e0c78a 100644 --- a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx @@ -413,6 +413,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.po b/src/VISUGUI/VISU_msg_en.po index b4e99cbd..d09cf559 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -737,6 +737,9 @@ msgstr "Scalar Field:" msgid "VisuGUI_DeformedShapeAndScalarMapDlg::TIMESTAMP_ITEM" msgstr "Current Time Stamp:" +msgid "VisuGUI_DeformedShapeAndScalarMapDlg::ERR_SCALAR_DATA_INCONSISTENT" +msgstr "Scalar data on the selected field is inconsistent.\nPlease select another field." + #: VisuGUI_EditContainerDlg.cxx msgid "VisuGUI_EditContainerDlg::&Cancel" diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx index 5990ea31..a98a1182 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx @@ -65,6 +65,7 @@ VisuGUI_DeformedShapeAndScalarMapDlg::VisuGUI_DeformedShapeAndScalarMapDlg (Salo : VisuGUI_ScalarBarBaseDlg(theModule), myIsAnimation(false), myUpdateScalars(true), + myIsScalarFieldValid(true), myVisuGUI(theModule) { setCaption(tr("DLG_TITLE")); @@ -135,10 +136,10 @@ VisuGUI_DeformedShapeAndScalarMapDlg::VisuGUI_DeformedShapeAndScalarMapDlg (Salo GroupButtonsLayout->setSpacing(6); GroupButtonsLayout->setMargin(11); - QPushButton* buttonOk = new QPushButton (tr("&OK"), GroupButtons, "buttonOk"); - buttonOk->setAutoDefault(TRUE); - buttonOk->setDefault(TRUE); - GroupButtonsLayout->addWidget(buttonOk, 0, 0); + myButtonOk = new QPushButton (tr("&OK"), GroupButtons, "buttonOk"); + myButtonOk->setAutoDefault(TRUE); + myButtonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(myButtonOk, 0, 0); GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1); @@ -156,7 +157,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))); @@ -361,7 +362,7 @@ VisuGUI_DeformedShapeAndScalarMapDlg { QApplication::setOverrideCursor(Qt::waitCursor); - if( save_scalar_pane ) + if( save_scalar_pane && IsScalarFieldValid() ) GetScalarPane()->storeToPrsObject(myPrsCopy); QString aFieldName; @@ -373,12 +374,20 @@ VisuGUI_DeformedShapeAndScalarMapDlg VISU::Entity anEntity = getCurrentScalarEntity(); - myPrsCopy->SetScalarField(anEntity, - aFieldName.latin1(), - theIter); + try { + myPrsCopy->SetScalarField(anEntity, + aFieldName.latin1(), + theIter); - if( save_scalar_pane ) - UpdateScalarField(); + if( save_scalar_pane ) + UpdateScalarField(); + myIsScalarFieldValid = true; + } catch( std::exception& exc ) { + INFOS( exc.what() ); + SUIT_MessageBox::warn1( this, tr( "WRN_WARNING" ), tr( "ERR_SCALAR_DATA_INCONSISTENT" ), tr( "BUT_OK" ) ); + myIsScalarFieldValid = false; + } + updateControls(); QApplication::restoreOverrideCursor(); } @@ -440,12 +449,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(){ @@ -476,3 +485,12 @@ VisuGUI_DeformedShapeAndScalarMapDlg } return aTime; } + +void VisuGUI_DeformedShapeAndScalarMapDlg::updateControls() +{ + bool isScalarFieldValid = IsScalarFieldValid(); + myTabBox->setTabEnabled( GetScalarPane(), isScalarFieldValid ); + myTabBox->setTabEnabled( myInputPane, isScalarFieldValid ); + myTimeStampsCombo->setEnabled( isScalarFieldValid ); + myButtonOk->setEnabled( isScalarFieldValid ); +} diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h index ba2e47a6..52ff1f71 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h @@ -75,6 +75,8 @@ public: VISU::Entity getCurrentScalarEntity(); void SetScalarField(int theIter,QString theFieldName=QString(""), const bool = true ); + bool IsScalarFieldValid() const { return myIsScalarFieldValid; } + protected: virtual QString GetContextHelpFilePath(); @@ -93,6 +95,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 @@ -107,6 +110,8 @@ private: _PTR(SObject) mySelectionObj; SALOME::GenericObjPtr myPrsCopy; SalomeApp_Module* myVisuGUI; + + bool myIsScalarFieldValid; protected: void UpdateScalarField(); @@ -116,6 +121,7 @@ protected: QString GetFloatValueOfTimeStamp(VISU::Entity theEntity, const std::string& theFieldName, int theTimeStampNumber); + void updateControls(); }; #endif // VISUGUI_DEFORMEDSHAPEDLS_H -- 2.39.2