]> 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:40:31 +0000 (07:40 +0000)
committerouv <ouv@opencascade.com>
Mon, 15 Jun 2009 07:40:31 +0000 (07:40 +0000)
src/CONVERTOR/VISU_MedConvertor.cxx
src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx
src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.h

index 8d0f0e6a25923148fc944b5813a72a27d2d40edb..f87ed8aa6521809f98f7512efda87ddeb5c33ede 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 = 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<TimeStampValueType> 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);
index 34f1a8ae6232ffe10f5dcd50daa67d8a3a86f502..50a545bf0c4180e5d30c48a950673a7ed4274939 100644 (file)
@@ -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;
 
index 642865fe82dd43433bf7b975ceca039f835aa7df..1c75f4a16a62454967087ae636f07caa242986e1 100644 (file)
@@ -3035,6 +3035,11 @@ Please, provide non-empty resulting presentation.</translation>
             <source>DLG_TITLE</source>
             <translation>Deformed Shape and Scalar Map</translation>
         </message>
+        <message>
+            <source>ERR_SCALAR_DATA_INCONSISTENT</source>
+            <translation>Scalar data on the selected field is inconsistent.
+Please select another field.</translation>
+        </message>
         <message>
             <source>FIELD_ITEM</source>
             <translation>Scalar Field:</translation>
index 3d57aa320cbb31451a58c711d57205c2fdf51b12..b5415a4c88d872a19298e55204c2c1c0fb54cdd9 100644 (file)
@@ -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 );
+}
index c8d53ef3cd04d31bc0d4570559149a2d5a889cde..51dfa3f35ccc62e64843f73e2f0f8165e793f377 100644 (file)
@@ -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<int, QString> TTimeStampNumber2Time; // Times map definition (iteration time, real value of time)
  typedef std::map<QString, TTimeStampNumber2Time> TFieldName2TimeStamps; // Field name and enity to Times
@@ -101,6 +104,8 @@ private:
  _PTR(SObject) mySelectionObj;
  SALOME::GenericObjPtr<VISU::DeformedShapeAndScalarMap_i> 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