From 576f56ddf84ccb8f8dae93f8197058f7f0f52a32 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 22 Nov 2010 17:49:43 +0000 Subject: [PATCH] 0020948]: EDF 1468 SMESH: Histogram of the quality controls Take into account the range of values of histogram --- src/OBJECT/SMESH_Actor.cxx | 4 +++- src/SMESHGUI/SMESHGUI.cxx | 8 ++++++-- src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx | 9 +++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 99eeb5d3d..bba1f3b32 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -2036,7 +2036,9 @@ void SMESH_ActorDef::UpdateDistribution() std::vector 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(myScalarBarActor->GetLookupTable()); + double * range = lookupTable->GetRange(); + fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range); myScalarBarActor->SetDistribution(nbEvents); } } diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 6addd5664..59c9179c2 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -140,6 +140,7 @@ #include #include #include +#include // SALOME KERNEL includes #include @@ -799,10 +800,13 @@ elements[i] = ids[i]; } } - int nbRanges = aScalarBarActor->GetMaximumNumberOfColors(); + int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors(); + vtkLookupTable* lookupTable = + static_cast(aScalarBarActor->GetLookupTable()); + double * minmax = lookupTable->GetRange(); std::vector nbEvents; std::vector funValues; - aNumFun->GetHistogram( nbRanges, nbEvents, funValues, elements ); + aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax ); QString anInitialPath = ""; if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() ) anInitialPath = QDir::currentPath(); diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx index d66c98237..547e611d3 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx @@ -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(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; } -- 2.39.2