]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0020948]: EDF 1468 SMESH: Histogram of the quality controls
authoreap <eap@opencascade.com>
Mon, 22 Nov 2010 17:49:43 +0000 (17:49 +0000)
committereap <eap@opencascade.com>
Mon, 22 Nov 2010 17:49:43 +0000 (17:49 +0000)
   Take into account the range of values of histogram

src/OBJECT/SMESH_Actor.cxx
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx

index 99eeb5d3db495b240f674d8391375acd30d6cc02..bba1f3b32d290521b7609b50f47c0ba88ff143d7 100644 (file)
@@ -2036,7 +2036,9 @@ void SMESH_ActorDef::UpdateDistribution()
     std::vector<int> elemIds;
     for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
       elemIds.push_back( (*e)->GetID());
-    fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds);
+    vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
+    double * range = lookupTable->GetRange();
+    fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
     myScalarBarActor->SetDistribution(nbEvents);
   }
 }
index 6addd566422ae5ca42182d67b69e231652b497d3..59c9179c27342b4040da1fa56b942527eb580d10 100644 (file)
 #include <vtkRenderer.h>
 #include <vtkPlane.h>
 #include <vtkCallbackCommand.h>
+#include <vtkLookupTable.h>
 
 // SALOME KERNEL includes
 #include <SALOMEDS_Study.hxx>
                     elements[i] = ids[i];
                 }
               }
-              int nbRanges = aScalarBarActor->GetMaximumNumberOfColors();
+              int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
+              vtkLookupTable* lookupTable =
+                static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
+              double * minmax = lookupTable->GetRange();
               std::vector<int>    nbEvents;
               std::vector<double> funValues;
-              aNumFun->GetHistogram( nbRanges, nbEvents, funValues, elements );
+              aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
               QString anInitialPath = "";
               if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
                 anInitialPath = QDir::currentPath();
index d66c982370507ead1bcfd9dc7dbb9aaf06508f97..547e611d38163b3dad61f3adb70b7bad7220caf2 100644 (file)
@@ -509,8 +509,6 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
   myScalarBarActor->SetLabelTextProperty( aLabelsTextPrp );
 
   myScalarBarActor->SetNumberOfLabels( myLabelsSpin->value() );
-  if( myColorsSpin->value() != myScalarBarActor->GetMaximumNumberOfColors() )
-    myActor->UpdateDistribution();
 
   if ( myHorizRadioBtn->isChecked() )
     myScalarBarActor->SetOrientationToHorizontal();
@@ -540,9 +538,16 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
   double aMax = myMaxEdit->text().toDouble();
   vtkLookupTable* myLookupTable =
     static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
+  double oldMinMax[2] = { myLookupTable->GetRange()[0], myLookupTable->GetRange()[1] };
+  bool rangeChanges = ( fabs( oldMinMax[0] - aMin ) + fabs( oldMinMax[1] - aMax ) >
+                        0.001 * ( aMax-aMin + oldMinMax[1]-oldMinMax[0] ));
   myLookupTable->SetRange( aMin, aMax );
   myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
   myLookupTable->Build();
+
+  if( myColorsSpin->value() != myScalarBarActor->GetMaximumNumberOfColors() || rangeChanges)
+    myActor->UpdateDistribution();
+
   SMESH::RepaintCurrentView();
   return true;
 }