#include <vtkCellType.h>
+#ifdef WNT
+#include <float.h>
+#define isnan _isnan
+#endif
+
using MED::TInt;
using MED::TFloat;
using MED::EBooleen;
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;
}
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);
: VisuGUI_ScalarBarBaseDlg(theModule),
myIsAnimation(false),
myUpdateScalars(true),
+ myIsScalarFieldValid(true),
myVisuGUI(theModule)
{
setWindowTitle(tr("DLG_TITLE"));
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);
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)));
{
QApplication::setOverrideCursor(Qt::WaitCursor);
- if( save_scalar_pane )
+ if( save_scalar_pane && IsScalarFieldValid() )
GetScalarPane()->storeToPrsObject(myPrsCopy);
QString aFieldName;
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();
}
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(){
}
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 );
+}
VISU::Entity getCurrentScalarEntity();
void SetScalarField(int theIter,QString theFieldName=QString(""), const bool = true );
+ bool IsScalarFieldValid() const { return myIsScalarFieldValid; }
+
protected:
virtual QString GetContextHelpFilePath();
VisuGUI_InputPane* myInputPane;
QComboBox *myFieldsCombo;
QComboBox *myTimeStampsCombo;
+ QPushButton* myButtonOk;
typedef std::map<int, QString> TTimeStampNumber2Time; // Times map definition (iteration time, real value of time)
typedef std::map<QString, TTimeStampNumber2Time> TFieldName2TimeStamps; // Field name and enity to Times
_PTR(SObject) mySelectionObj;
SALOME::GenericObjPtr<VISU::DeformedShapeAndScalarMap_i> myPrsCopy;
SalomeApp_Module* myVisuGUI;
+
+ bool myIsScalarFieldValid;
protected:
void UpdateScalarField();
QString GetFloatValueOfTimeStamp(VISU::Entity theEntity,
const std::string& theFieldName,
int theTimeStampNumber);
+ void updateControls();
};
#endif // VISUGUI_DEFORMEDSHAPEDLS_H