#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 = 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;
}
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);
: VisuGUI_ScalarBarBaseDlg(theModule),
myIsAnimation(false),
myUpdateScalars(true),
+ myIsScalarFieldValid(true),
myVisuGUI(theModule)
{
setCaption(tr("DLG_TITLE"));
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);
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.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();
}
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( GetScalarPane(), isScalarFieldValid );
+ myTabBox->setTabEnabled( myInputPane, isScalarFieldValid );
+ 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