Salome HOME
Issue #2966: Redisplay text field on preferences change
[modules/shaper.git] / src / PartSet / PartSet_FieldStepPrs.cpp
index f99c796e2724624569fe4043d2af816dc5c0accc..8fb605186fbcc94dde02dc55aa8b6345fd4be09e 100644 (file)
 
 #include "PartSet_FieldStepPrs.h"
 
+#include <ModuleBase_Preferences.h>
+
 #include <CollectionPlugin_Field.h>
 
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_AttributeStringArray.h>
 
+#include <SUIT_ResourceMgr.h>
+
 #include <AIS_ColorScale.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_PointAspect.hxx>
@@ -59,16 +63,17 @@ PartSet_FieldStepPrs::PartSet_FieldStepPrs(FieldStepPtr theStep)
   std::shared_ptr<ModelAPI_ResultField> aFieldPtr(aField, emptyDeleter);
   myFeature = ModelAPI_Feature::feature(aFieldPtr);
 
-  Handle(Prs3d_Drawer) aDrawer = Attributes();
-  if (aDrawer->HasOwnPointAspect()) {
-    aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_POINT);
-    aDrawer->PointAspect()->SetScale(POINT_SIZE);
+  if (dataType() != ModelAPI_AttributeTables::STRING) {
+    Handle(Prs3d_Drawer) aDrawer = Attributes();
+    if (aDrawer->HasOwnPointAspect()) {
+      aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_POINT);
+      aDrawer->PointAspect()->SetScale(POINT_SIZE);
+    }
+    else
+      aDrawer->SetPointAspect(
+        new Prs3d_PointAspect(Aspect_TOM_POINT, Quantity_NOC_YELLOW, POINT_SIZE));
   }
-  else
-    aDrawer->SetPointAspect(
-      new Prs3d_PointAspect(Aspect_TOM_POINT, Quantity_NOC_YELLOW, POINT_SIZE));
-
-  myLabelColor = Quantity_Color(1, 1, 1, Quantity_TOC_RGB);
+  SetMaterial(Graphic3d_NOM_PLASTIC);
 }
 
 
@@ -136,6 +141,11 @@ QList<double> PartSet_FieldStepPrs::range(double& theMin, double& theMax) const
 void PartSet_FieldStepPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
   const Handle(Prs3d_Presentation)& thePrs, const Standard_Integer theMode)
 {
+  SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
+  QColor aQColor = aResMgr->colorValue("Viewer", "scalar_bar_text_color", Qt::black);
+  Quantity_Color aLabelColor = Quantity_Color(aQColor.redF(), aQColor.greenF(), aQColor.blueF(),
+    Quantity_TOC_RGB);
+
   ModelAPI_AttributeTables::ValueType aType = dataType();
   DataPtr aData = myFeature->data();
   switch (aType) {
@@ -144,9 +154,10 @@ void PartSet_FieldStepPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   {
     double aMin, aMax;
     QList<double> aShapeData = range(aMin, aMax);
-    int aNbIntertvals = 20;
+    int aNbIntertvals = aResMgr->integerValue("Viewer", "scalar_bar_nb_intervals", 20);
 
-    AttributeSelectionListPtr aSelList = aData->selectionList(CollectionPlugin_Field::SELECTED_ID());
+    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();
@@ -162,7 +173,8 @@ void PartSet_FieldStepPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   {
     QList<double> aShapeData = booleanValues();
 
-    AttributeSelectionListPtr aSelList = aData->selectionList(CollectionPlugin_Field::SELECTED_ID());
+    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();
@@ -177,7 +189,8 @@ void PartSet_FieldStepPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
   case ModelAPI_AttributeTables::STRING:
   {
     QStringList aValues = strings();
-    AttributeSelectionListPtr aSelList = aData->selectionList(CollectionPlugin_Field::SELECTED_ID());
+    AttributeSelectionListPtr aSelList =
+      aData->selectionList(CollectionPlugin_Field::SELECTED_ID());
     Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
     for (int i = 0; i < aSelList->size(); i++) {
       AttributeSelectionPtr aSelection = aSelList->value(i);
@@ -189,11 +202,12 @@ void PartSet_FieldStepPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
 
         Handle(Graphic3d_AspectText3d) anAspectText3d = new Graphic3d_AspectText3d();
         anAspectText3d->SetStyle(Aspect_TOST_ANNOTATION);
-        anAspectText3d->SetColor(myLabelColor);
+        anAspectText3d->SetColor(aLabelColor);
         aGroup->SetPrimitivesAspect(anAspectText3d);
 
+        int aT = aResMgr->integerValue("Viewer", "scalar_bar_text_height", 14);
         QString aString = aValues.at(i);
-        aGroup->Text(aString.toUtf8().constData(), aVertex, 14);
+        aGroup->Text(aString.toUtf8().constData(), aVertex, aT);
       }
     }
   }