From ab5d666a987372fad8eca4351fb4720e163db76a Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 26 Jul 2019 13:08:24 +0300 Subject: [PATCH] Issue #2964: Coloring of a step field on a part --- src/PartSet/PartSet_FieldStepPrs.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/PartSet/PartSet_FieldStepPrs.cpp b/src/PartSet/PartSet_FieldStepPrs.cpp index 04c38b959..20dd7ca98 100644 --- a/src/PartSet/PartSet_FieldStepPrs.cpp +++ b/src/PartSet/PartSet_FieldStepPrs.cpp @@ -123,7 +123,7 @@ QList PartSet_FieldStepPrs::range(double& theMin, double& theMax) const } QList aShapeData; double aRangeMin = aFieldStepData.first(), aRangeMax = aFieldStepData.last(); - for (int aRow = 0; aRow < aRows - 1; aRow++) { + for (int aRow = 0; aRow < aRows - aStart; aRow++) { double aNorm = 0; int aBaseIndex = aRow * aCols; for (int aCol = 0; aCol < aCols; aCol++) { @@ -158,18 +158,27 @@ void PartSet_FieldStepPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t { double aMin, aMax; QList aShapeData = range(aMin, aMax); - int aNbIntertvals = aResMgr->integerValue("Viewer", "scalar_bar_nb_intervals", 20); AttributeSelectionListPtr aSelList = aData->selectionList(CollectionPlugin_Field::SELECTED_ID()); - for (int i = 0; i < aSelList->size(); i++) { - AttributeSelectionPtr aSelection = aSelList->value(i); - GeomShapePtr aShapePtr = aSelection->value(); - TopoDS_Shape aShape = aShapePtr->impl(); - double aValue = aShapeData.at(i); + std::string aTypeStr = aSelList->selectionType(); + if (aTypeStr == "part") { Quantity_Color aColor; - if (AIS_ColorScale::FindColor(aValue, aMin, aMax, aNbIntertvals, aColor)) - SetCustomColor(aShape, aColor); + if (AIS_ColorScale::FindColor(aMin, aMin, aMax, 1, aColor)) { + SetColor(aColor); + } + } + else { + int aNbIntertvals = aResMgr->integerValue("Viewer", "scalar_bar_nb_intervals", 20); + for (int i = 0; i < aSelList->size(); i++) { + AttributeSelectionPtr aSelection = aSelList->value(i); + GeomShapePtr aShapePtr = aSelection->value(); + TopoDS_Shape aShape = aShapePtr->impl(); + double aValue = aShapeData.at(i); + Quantity_Color aColor; + if (AIS_ColorScale::FindColor(aValue, aMin, aMax, aNbIntertvals, aColor)) + SetCustomColor(aShape, aColor); + } } } break; -- 2.39.2