Measure: Fix delta label text size scaling (#21467)
* Measure: Fix delta label font size - Add font size field to ViewProviderMeasureBase which connects to other fields - Remove dead code in DimensionLinear which internally is using FrameLabel - Connect FrameLabels's fontsize property to DimensionLinear's property * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -194,6 +194,7 @@ ViewProviderMeasureBase::ViewProviderMeasureBase()
|
||||
TextBackgroundColor.touch();
|
||||
FontSize.touch();
|
||||
LineColor.touch();
|
||||
fieldFontSize.setValue(FontSize.getValue());
|
||||
}
|
||||
|
||||
ViewProviderMeasureBase::~ViewProviderMeasureBase()
|
||||
@@ -251,6 +252,7 @@ void ViewProviderMeasureBase::onChanged(const App::Property* prop)
|
||||
}
|
||||
else if (prop == &FontSize) {
|
||||
pLabel->size = FontSize.getValue();
|
||||
fieldFontSize.setValue(FontSize.getValue());
|
||||
}
|
||||
ViewProviderDocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,9 @@ public:
|
||||
App::PropertyInteger FontSize;
|
||||
// NOLINTEND
|
||||
|
||||
// Fields
|
||||
SoSFFloat fieldFontSize;
|
||||
|
||||
/**
|
||||
* Attaches the document object to this view provider.
|
||||
*/
|
||||
|
||||
@@ -212,16 +212,13 @@ void MeasureGui::DimensionLinear::setupDimension()
|
||||
textTransform->translation.connectFrom(&textVecCalc->oA);
|
||||
textSep->addChild(textTransform);
|
||||
|
||||
SoFont* fontNode = new SoFont();
|
||||
fontNode->name.setValue("Helvetica : Bold");
|
||||
fontNode->size.connectFrom(&fontSize);
|
||||
textSep->addChild(fontNode);
|
||||
|
||||
auto textNode = new SoFrameLabel();
|
||||
textNode->justification = SoText2::CENTER;
|
||||
textNode->string.connectFrom(&text);
|
||||
textNode->textColor.connectFrom(&dColor);
|
||||
textNode->backgroundColor.connectFrom(&backgroundColor);
|
||||
textNode->size.connectFrom(&fontSize);
|
||||
textNode->name.setValue("Helvetica");
|
||||
textSep->addChild(textNode);
|
||||
|
||||
// this prevents the 2d text from screwing up the bounding box for a viewall
|
||||
@@ -416,18 +413,21 @@ ViewProviderMeasureDistance::ViewProviderMeasureDistance()
|
||||
dimDeltaX->point2.connectFrom(&composeVecDelta1->vector);
|
||||
dimDeltaX->setupDimension();
|
||||
dimDeltaX->dColor.setValue(colorX);
|
||||
dimDeltaX->fontSize.connectFrom(&fieldFontSize);
|
||||
|
||||
auto dimDeltaY = new MeasureGui::DimensionLinear();
|
||||
dimDeltaY->point1.connectFrom(&composeVecDelta1->vector);
|
||||
dimDeltaY->point2.connectFrom(&composeVecDelta2->vector);
|
||||
dimDeltaY->setupDimension();
|
||||
dimDeltaY->dColor.setValue(colorY);
|
||||
dimDeltaY->fontSize.connectFrom(&fieldFontSize);
|
||||
|
||||
auto dimDeltaZ = new MeasureGui::DimensionLinear();
|
||||
dimDeltaZ->point2.connectFrom(&composeVecDelta2->vector);
|
||||
dimDeltaZ->point1.connectFrom(&fieldPosition2);
|
||||
dimDeltaZ->setupDimension();
|
||||
dimDeltaZ->dColor.setValue(colorZ);
|
||||
dimDeltaZ->fontSize.connectFrom(&fieldFontSize);
|
||||
|
||||
pDeltaDimensionSwitch = new SoSwitch();
|
||||
pDeltaDimensionSwitch->ref();
|
||||
@@ -507,14 +507,6 @@ void ViewProviderMeasureDistance::onChanged(const App::Property* prop)
|
||||
pDeltaDimensionSwitch->whichChild.setValue(ShowDelta.getValue() ? SO_SWITCH_ALL
|
||||
: SO_SWITCH_NONE);
|
||||
}
|
||||
else if (prop == &FontSize) {
|
||||
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(0))
|
||||
->fontSize.setValue(FontSize.getValue());
|
||||
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(1))
|
||||
->fontSize.setValue(FontSize.getValue());
|
||||
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(2))
|
||||
->fontSize.setValue(FontSize.getValue());
|
||||
}
|
||||
else if (prop == &TextBackgroundColor) {
|
||||
auto bColor = TextBackgroundColor.getValue();
|
||||
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(0))
|
||||
|
||||
Reference in New Issue
Block a user