]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix of issue 0020380: EDF 1048 VISU: Presentation with negative time stamps
authorouv <ouv@opencascade.com>
Mon, 15 Jun 2009 07:42:08 +0000 (07:42 +0000)
committerouv <ouv@opencascade.com>
Mon, 15 Jun 2009 07:42:08 +0000 (07:42 +0000)
src/CONVERTOR/VISU_MedConvertor.cxx
src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx
src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h

index 27a7c0a8e15055d6670b44d13376ad244e7781a1..39a3a6c16707c679a7a2890d606b9a5df8668781 100644 (file)
 
 #include <vtkCellType.h>
 
+#ifdef WNT
+#include <float.h>
+#define isnan _isnan
+#endif
+
 using MED::TInt;
 using MED::TFloat;
 using MED::EBooleen;
@@ -1591,8 +1596,8 @@ BuildTimeStampMinMax(MED::SharedPtr<TimeStampValueType> 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<TimeStampValueType> 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);
index 732f522c7a14078f51db3574b5f88d0ff1fe926c..55e0c78a7d0ec91a4dfc68d4200ec8b9584eb385 100644 (file)
@@ -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;
 
index b4e99cbd6b4ce7b07d4d53d2e173e50afe3b4000..d09cf559487a381e83f4ede2481e715bf9cc7f22 100644 (file)
@@ -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"
index 5990ea31ce826df8e75e2ee7a1b9e805903c5f2c..a98a1182a7c7af0b667a65fcaf200b35848dbd09 100644 (file)
@@ -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 );
+}
index ba2e47a63fb17d7927188a615d8fca4b048a5a46..52ff1f718549b36ccd170710f677519f30575560 100644 (file)
@@ -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<int, QString> TTimeStampNumber2Time; // Times map definition (iteration time, real value of time)
  typedef std::map<QString, TTimeStampNumber2Time> TFieldName2TimeStamps; // Field name and enity to Times
@@ -107,6 +110,8 @@ private:
  _PTR(SObject) mySelectionObj;
  SALOME::GenericObjPtr<VISU::DeformedShapeAndScalarMap_i> 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