From 8c15ec5031cd6ebc61c165e6466224a8caf963e0 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 27 Jun 2019 18:54:11 +0300 Subject: [PATCH] Provide user preferences for ColorScale --- src/ModuleBase/ModuleBase_Preferences.cpp | 37 ++++++++++++++++++++++- src/PartSet/PartSet_FieldStepPrs.cpp | 5 +-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Preferences.cpp b/src/ModuleBase/ModuleBase_Preferences.cpp index c616449e3..1cbe486e2 100644 --- a/src/ModuleBase/ModuleBase_Preferences.cpp +++ b/src/ModuleBase/ModuleBase_Preferences.cpp @@ -263,7 +263,7 @@ ModuleBase_PreferencesDlg::ModuleBase_PreferencesDlg(SUIT_ResourceMgr* theResurc createEditors(); myPreferences->retrieve(); - setMinimumSize(800, 300); + setMinimumSize(820, 300); } ModuleBase_PreferencesDlg::~ModuleBase_PreferencesDlg() @@ -340,6 +340,41 @@ void ModuleBase_PreferencesDlg::createViewerPage(int thePageId) SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-3d"); myPreferences->addItem(tr("In 2d mode"), highlightGroup, SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-2d"); + + int colorScaleGroup = myPreferences->addItem(tr("Color scale"), viewTab); + myPreferences->setItemProperty("columns", 4, colorScaleGroup); + int aItem = myPreferences->addItem(tr("X position"), colorScaleGroup, + SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_x_position"); + myPreferences->setItemProperty("min", 0, aItem); + myPreferences->setItemProperty("max", 1, aItem); + + aItem = myPreferences->addItem(tr("Y position"), colorScaleGroup, + SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_y_position"); + myPreferences->setItemProperty("min", 0, aItem); + myPreferences->setItemProperty("max", 1, aItem); + + aItem = myPreferences->addItem(tr("Width"), colorScaleGroup, + SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_width"); + myPreferences->setItemProperty("min", 0, aItem); + myPreferences->setItemProperty("max", 1, aItem); + + aItem = myPreferences->addItem(tr("Height"), colorScaleGroup, + SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_height"); + myPreferences->setItemProperty("min", 0, aItem); + myPreferences->setItemProperty("max", 1, aItem); + + aItem = myPreferences->addItem(tr("Intervals number"), colorScaleGroup, + SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_nb_intervals"); + myPreferences->setItemProperty("min", 0, aItem); + myPreferences->setItemProperty("max", 100, aItem); + + aItem = myPreferences->addItem(tr("Text height"), colorScaleGroup, + SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_height"); + myPreferences->setItemProperty("min", 0, aItem); + myPreferences->setItemProperty("max", 100, aItem); + + aItem = myPreferences->addItem(tr("Text color"), colorScaleGroup, + SUIT_PreferenceMgr::Color, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_color"); } void ModuleBase_PreferencesDlg::createMenuPage(int thePageId) diff --git a/src/PartSet/PartSet_FieldStepPrs.cpp b/src/PartSet/PartSet_FieldStepPrs.cpp index 2c0981dbc..1d751d016 100644 --- a/src/PartSet/PartSet_FieldStepPrs.cpp +++ b/src/PartSet/PartSet_FieldStepPrs.cpp @@ -146,6 +146,7 @@ QList 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(); ModelAPI_AttributeTables::ValueType aType = dataType(); DataPtr aData = myFeature->data(); switch (aType) { @@ -154,7 +155,6 @@ void PartSet_FieldStepPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t { double aMin, aMax; QList aShapeData = range(aMin, aMax); - SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr(); int aNbIntertvals = aResMgr->integerValue("Viewer", "scalar_bar_nb_intervals", 20); AttributeSelectionListPtr aSelList = aData->selectionList(CollectionPlugin_Field::SELECTED_ID()); @@ -203,8 +203,9 @@ void PartSet_FieldStepPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t anAspectText3d->SetColor(myLabelColor); 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); } } } -- 2.39.2