diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScale.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScale.ui index 4a4c6549ac..3402bb854f 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScale.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScale.ui @@ -6,8 +6,8 @@ 0 0 - 440 - 342 + 457 + 481 @@ -49,6 +49,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -61,49 +74,15 @@ - - - - - 0 - 0 - - - - - 174 - 0 - - - - Default scale for new pages - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 2 - - - 1.000000000000000 - - - DefaultScale - - - Mod/TechDraw/General - - - - - + + true - View Scale Type + View Custom Scale @@ -150,30 +129,39 @@ - - - - - true - + + + + + 0 + 0 + - - View Custom Scale - - - - - - - Qt::Horizontal - - + - 40 - 20 + 174 + 0 - + + Default scale for new pages + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 2 + + + 1.000000000000000 + + + DefaultScale + + + Mod/TechDraw/General + + @@ -215,6 +203,39 @@ + + + + + true + + + + View Scale Type + + + + + + + + true + + + + <html><head/><body><p>If checked, Svg symbols, spreadsheet views and Draft views will use the original (incorrect) scaling method as used in v1.0 and earlier. If unchecked, a more accurate method will be used. </p></body></html> + + + Legacy Symbol Scaling + + + LegacySvgScaling + + + Mod/TechDraw/General + + + @@ -306,7 +327,7 @@ - + @@ -351,7 +372,7 @@ - + 0 @@ -367,10 +388,7 @@ Size of template field click handles - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + 3.000000000000000 @@ -410,7 +428,7 @@ - + @@ -424,7 +442,7 @@ - <html><head/><body><p><span style=" font-weight:600;">Note:</span> Items in <span style=" font-style:italic;">italics</span> are default values for new objects. They have no effect on existing objects.</p></body></html> + <html><head/><body><p><span style=" font-weight:600;">Note:</span> Items in <span style=" font-style:italic;">italics</span> are default values for new objects. They have no effect on existing objects.</p></body></html> true @@ -452,6 +470,11 @@ QWidget
Gui/QuantitySpinBox.h
+ + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
Gui::PrefComboBox QComboBox diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScaleImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScaleImp.cpp index 11c9ad0052..010f000f74 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScaleImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScaleImp.cpp @@ -67,6 +67,7 @@ void DlgPrefsTechDrawScaleImp::saveSettings() ui->pdsbCenterScale->onSave(); ui->pdsbTemplateMark->onSave(); ui->pdsbSymbolScale->onSave(); + ui->cbLegacyScale->onSave(); } void DlgPrefsTechDrawScaleImp::loadSettings() @@ -80,6 +81,7 @@ void DlgPrefsTechDrawScaleImp::loadSettings() ui->pdsbTemplateMark->setValue(markDefault); ui->pdsbTemplateMark->onRestore(); ui->pdsbSymbolScale->onRestore(); + ui->cbLegacyScale->onRestore(); } /** diff --git a/src/Mod/TechDraw/Gui/QGIViewSymbol.cpp b/src/Mod/TechDraw/Gui/QGIViewSymbol.cpp index aa5c9fccbf..133cb82451 100644 --- a/src/Mod/TechDraw/Gui/QGIViewSymbol.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewSymbol.cpp @@ -42,6 +42,7 @@ #include "QGCustomSvg.h" #include "QGDisplayArea.h" #include "Rez.h" +#include "ViewProviderSymbol.h" using namespace TechDrawGui; @@ -110,8 +111,14 @@ void QGIViewSymbol::drawSvg() return; } + auto vp = getViewProvider(viewSymbol); + auto vps = dynamic_cast(vp); + if (!vp || !vps) { + return; + } + double scaling{1}; - if (Preferences::useLegacySvgScaling()) { + if (vps->LegacyScaling.getValue()) { scaling = legacyScaler(viewSymbol); } else { scaling = symbolScaler(viewSymbol); @@ -206,18 +213,15 @@ double QGIViewSymbol::symbolScaler(TechDraw::DrawViewSymbol* feature) const matchUnits = matchHeight.captured(1); } - if (matchUnits.isEmpty() || - matchUnits == pxToken) { - scaling *= rezfactor; - } + // if there are no units specified, or the units are px, we just draw the symbol if (matchUnits == mmToken) { auto svgSize = m_svgItem->renderer()->defaultSize(); - auto vpSize = m_svgItem->renderer()->viewBox(); + auto vportSize = m_svgItem->renderer()->viewBox(); // wf: this calculation works, but I don't know why. :( // hints here: https://stackoverflow.com/questions/49866474/get-svg-size-from-qsvgrenderer // and here: https://stackoverflow.com/questions/7544921/qt-qgraphicssvgitem-renders-too-big-0-5-unit-on-each-side - scaling *= rezfactor * vpSize.width() / svgSize.width(); + scaling *= rezfactor * vportSize.width() / svgSize.width(); } return scaling; diff --git a/src/Mod/TechDraw/Gui/ViewProviderSymbol.cpp b/src/Mod/TechDraw/Gui/ViewProviderSymbol.cpp index d15b5f2adb..d41d311588 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderSymbol.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderSymbol.cpp @@ -24,9 +24,15 @@ #include "PreCompiled.h" #include + +#include + +#include "QGIViewSymbol.h" #include "ViewProviderSymbol.h" using namespace TechDrawGui; +using namespace TechDraw; + PROPERTY_SOURCE(TechDrawGui::ViewProviderSymbol, TechDrawGui::ViewProviderDrawingView) @@ -36,6 +42,11 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderSymbol, TechDrawGui::ViewProviderDrawin ViewProviderSymbol::ViewProviderSymbol() { sPixmap = "TechDraw_TreeSymbol"; + + ADD_PROPERTY_TYPE(LegacyScaling, (Preferences::useLegacySvgScaling()), "Svg Scaling", App::Prop_None, + "If true, Svg will be scaled using the original (v1.0 and earlier) scaling method.\ + If false, a more accurate method will be used."); + } ViewProviderSymbol::~ViewProviderSymbol() @@ -55,6 +66,18 @@ void ViewProviderSymbol::updateData(const App::Property* prop) ViewProviderDrawingView::updateData(prop); } +void ViewProviderSymbol::onChanged(const App::Property* prop) +{ + if (prop == &(LegacyScaling)) { + QGIView* qgiv = getQView(); + if (qgiv) { + qgiv->updateView(true); + } + } + + ViewProviderDrawingView::onChanged(prop); +} + TechDraw::DrawViewSymbol* ViewProviderSymbol::getViewObject() const { return dynamic_cast(pcObject); diff --git a/src/Mod/TechDraw/Gui/ViewProviderSymbol.h b/src/Mod/TechDraw/Gui/ViewProviderSymbol.h index 23053c601f..67e31603ab 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderSymbol.h +++ b/src/Mod/TechDraw/Gui/ViewProviderSymbol.h @@ -43,8 +43,11 @@ public: /// destructor ~ViewProviderSymbol() override; + App::PropertyBool LegacyScaling; + bool useNewSelectionModel() const override {return false;} void updateData(const App::Property*) override; + void onChanged(const App::Property* prop) override; TechDraw::DrawViewSymbol* getViewObject() const override; };