From aac48eb2f9ff485af6e7f8b7b7d4977f70fb7789 Mon Sep 17 00:00:00 2001 From: pavltom Date: Sat, 16 Mar 2024 10:50:35 +0100 Subject: [PATCH] [TechDraw] Issue #5903 - Autofill template information --- src/Mod/TechDraw/App/DrawSVGTemplate.cpp | 33 ++++--- src/Mod/TechDraw/App/DrawTemplate.cpp | 67 ++++++++++++++ src/Mod/TechDraw/App/DrawTemplate.h | 13 +++ src/Mod/TechDraw/App/DrawUtil.cpp | 74 +++++++++++++++ src/Mod/TechDraw/App/DrawUtil.h | 4 + src/Mod/TechDraw/App/DrawViewSymbol.cpp | 4 +- src/Mod/TechDraw/App/XMLQuery.cpp | 3 +- src/Mod/TechDraw/Gui/Command.cpp | 89 ++++++++----------- src/Mod/TechDraw/Gui/QGISVGTemplate.cpp | 4 +- src/Mod/TechDraw/Gui/TaskProjGroup.cpp | 78 +--------------- src/Mod/TechDraw/Gui/TaskProjGroup.h | 1 - src/Mod/TechDraw/Templates/A4_LandscapeTD.svg | 10 +-- .../TechDraw/Templates/ANSIC_Landscape.svg | 12 +-- 13 files changed, 236 insertions(+), 156 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawSVGTemplate.cpp b/src/Mod/TechDraw/App/DrawSVGTemplate.cpp index fe36964dcc..abd145f84c 100644 --- a/src/Mod/TechDraw/App/DrawSVGTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawSVGTemplate.cpp @@ -132,10 +132,10 @@ QString DrawSVGTemplate::processTemplate() query.processItems(QString::fromUtf8( "declare default element namespace \"" SVG_NS_URI "\"; " "declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; " - "//text[@freecad:editable]/tspan"), + "//text[@" FREECAD_ATTR_EDITABLE "]/tspan"), [&substitutions, &templateDocument](QDomElement& tspan) -> bool { // Replace the editable text spans with new nodes holding actual values - QString editableName = tspan.parentNode().toElement().attribute(QString::fromUtf8("freecad:editable")); + QString editableName = tspan.parentNode().toElement().attribute(QString::fromUtf8(FREECAD_ATTR_EDITABLE)); std::map::iterator item = substitutions.find(editableName.toStdString()); if (item != substitutions.end()) { @@ -296,15 +296,28 @@ std::map DrawSVGTemplate::getEditableTextsFromTemplate query.processItems(QString::fromUtf8( "declare default element namespace \"" SVG_NS_URI "\"; " "declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; " - "//text[@freecad:editable]/tspan"), - [&editables](QDomElement& tspan) -> bool { - QString editableName = tspan.parentNode().toElement().attribute(QString::fromUtf8("freecad:editable")); - QString editableValue = tspan.firstChild().nodeValue(); + "//text[@" FREECAD_ATTR_EDITABLE "]/tspan"), + [this, &editables](QDomElement& tspan) -> bool { + QDomElement parent = tspan.parentNode().toElement(); + QString editableName = parent.attribute(QString::fromUtf8(FREECAD_ATTR_EDITABLE)); - editables[std::string(editableName.toUtf8().constData())] = - std::string(editableValue.toUtf8().constData()); - return true; - }); + QString editableValue; + if (parent.hasAttribute(QString::fromUtf8(FREECAD_ATTR_AUTOFILL))) { + QString autofillValue = getAutofillValue(parent.attribute(QString::fromUtf8(FREECAD_ATTR_AUTOFILL))); + if (!autofillValue.isNull()) { + editableValue = autofillValue; + } + } + + // If the autofill value is not specified or unsupported, use the default text value + if (editableValue.isNull()) { + editableValue = tspan.firstChild().nodeValue(); + } + + editables[std::string(editableName.toUtf8().constData())] = + std::string(editableValue.toUtf8().constData()); + return true; + }); return editables; } diff --git a/src/Mod/TechDraw/App/DrawTemplate.cpp b/src/Mod/TechDraw/App/DrawTemplate.cpp index 35709cd26e..7ba1cfbe50 100644 --- a/src/Mod/TechDraw/App/DrawTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawTemplate.cpp @@ -24,13 +24,19 @@ #ifndef _PreComp_ # include +# include +# include #endif #include +#include +#include + #include "DrawTemplate.h" #include "DrawTemplatePy.h" #include "DrawPage.h" +#include "DrawUtil.h" using namespace TechDraw; @@ -94,6 +100,67 @@ DrawPage* DrawTemplate::getParentPage() const return page; } +QString DrawTemplate::getAutofillValue(const QString &id) const +{ + // author + if (id.compare(QString::fromUtf8(Autofill::Author)) == 0) { + std::string value = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences") + ->GetGroup("Document")->GetASCII("prefAuthor"); + if (!value.empty()) { + return QString::fromUtf8(value.c_str()); + } + } + // date + else if (id.compare(QString::fromUtf8(Autofill::Date)) == 0) { + QDateTime date = QDateTime::currentDateTime(); + return date.toString(QLocale().dateFormat(QLocale::ShortFormat)); + } + // organization + else if (id.compare(QString::fromUtf8(Autofill::Organization)) == 0) { + std::string value = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences") + ->GetGroup("Document")->GetASCII("prefCompany"); + if (!value.empty()) { + return QString::fromUtf8(value.c_str()); + } + } + // scale + else if (id.compare(QString::fromUtf8(Autofill::Scale)) == 0) { + DrawPage *page = getParentPage(); + if (page) { + std::pair scale = DrawUtil::nearestFraction(page->Scale.getValue()); + return QString::asprintf("%d : %d", scale.first, scale.second); + } + } + // sheet + else if (id.compare(QString::fromUtf8(Autofill::Sheet)) == 0) { + std::vector pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId()); + std::vector pageNames; + for (auto page : pages) { + pageNames.push_back(QString::fromUtf8(page->Label.getValue())); + } + + QCollator collator; + std::sort(pageNames.begin(), pageNames.end(), collator); + + int pos = 0; + DrawPage *page = getParentPage(); + if (page) { + auto it = std::find(pageNames.begin(), pageNames.end(), QString::fromUtf8(page->Label.getValue())); + if (it != pageNames.end()) { + pos = it - pageNames.begin() + 1; + } + } + + return QString::asprintf("%d / %d", pos, (int) pageNames.size()); + } + // title + else if (id.compare(QString::fromUtf8(Autofill::Title)) == 0) { + return QString::fromUtf8(getDocument()->Label.getValue()); + } + + return QString(); +} + // Python Template feature --------------------------------------------------------- namespace App { diff --git a/src/Mod/TechDraw/App/DrawTemplate.h b/src/Mod/TechDraw/App/DrawTemplate.h index 4849381aab..f2c6be5390 100644 --- a/src/Mod/TechDraw/App/DrawTemplate.h +++ b/src/Mod/TechDraw/App/DrawTemplate.h @@ -57,6 +57,8 @@ public: virtual DrawPage* getParentPage() const; + virtual QString getAutofillValue(const QString &id) const; + /// returns the type name of the ViewProvider const char* getViewProviderName(void) const override{ return "TechDrawGui::ViewProviderTemplate"; @@ -65,6 +67,17 @@ public: // from base class PyObject *getPyObject(void) override; + class Autofill + { + public: + static constexpr const char *Author = "author"; + static constexpr const char *Date = "date"; + static constexpr const char *Organization = "organization"; + static constexpr const char *Scale = "scale"; + static constexpr const char *Sheet = "sheet"; + static constexpr const char *Title = "title"; + }; + private: static const char* OrientationEnums[]; diff --git a/src/Mod/TechDraw/App/DrawUtil.cpp b/src/Mod/TechDraw/App/DrawUtil.cpp index e6c6385eb8..915e9e5807 100644 --- a/src/Mod/TechDraw/App/DrawUtil.cpp +++ b/src/Mod/TechDraw/App/DrawUtil.cpp @@ -1312,6 +1312,80 @@ double DrawUtil::angleDifference(double fi1, double fi2, bool reflex) return fi1; } +std::pair DrawUtil::nearestFraction(double val, int maxDenom) +{ +// Find rational approximation to given real number +// David Eppstein / UC Irvine / 8 Aug 1993 +// +// With corrections from Arno Formella, May 2008 +// and additional fiddles by WF 2017 +// usage: a.out r d +// r is real number to approx +// d is the maximum denominator allowed +// +// Based on the theory of continued fractions +// if x = a1 + 1/(a2 + 1/(a3 + 1/(a4 + ...))) +// then best approximation is found by truncating this series +// (with some adjustments in the last term). +// +// Note the fraction can be recovered as the first column of the matrix +// ( a1 1 ) ( a2 1 ) ( a3 1 ) ... +// ( 1 0 ) ( 1 0 ) ( 1 0 ) +// Instead of keeping the sequence of continued fraction terms, +// we just keep the last partial product of these matrices. + std::pair result; + long m[2][2]; + long maxden = maxDenom; + long ai; + double x = val; + double startx = x; + + /* initialize matrix */ + m[0][0] = m[1][1] = 1; + m[0][1] = m[1][0] = 0; + + /* loop finding terms until denom gets too big */ + while (m[1][0] * ( ai = (long)x ) + m[1][1] <= maxden) { + long t; + t = m[0][0] * ai + m[0][1]; + m[0][1] = m[0][0]; + m[0][0] = t; + t = m[1][0] * ai + m[1][1]; + m[1][1] = m[1][0]; + m[1][0] = t; + if(x == (double) ai) + break; // AF: division by zero + x = 1/(x - (double) ai); + if(x > (double) std::numeric_limits::max()) + break; // AF: representation failure + } + + /* now remaining x is between 0 and 1/ai */ + /* approx as either 0 or 1/m where m is max that will fit in maxden */ + /* first try zero */ + double error1 = startx - ((double) m[0][0] / (double) m[1][0]); + int n1 = m[0][0]; + int d1 = m[1][0]; + + /* now try other possibility */ + ai = (maxden - m[1][1]) / m[1][0]; + m[0][0] = m[0][0] * ai + m[0][1]; + m[1][0] = m[1][0] * ai + m[1][1]; + double error2 = startx - ((double) m[0][0] / (double) m[1][0]); + int n2 = m[0][0]; + int d2 = m[1][0]; + + if (std::fabs(error1) <= std::fabs(error2)) { + result.first = n1; + result.second = d1; + } else { + result.first = n2; + result.second = d2; + } + + return result; +} + // Interval marking functions // ========================== diff --git a/src/Mod/TechDraw/App/DrawUtil.h b/src/Mod/TechDraw/App/DrawUtil.h index 503de91462..c6b6bdd069 100644 --- a/src/Mod/TechDraw/App/DrawUtil.h +++ b/src/Mod/TechDraw/App/DrawUtil.h @@ -58,6 +58,9 @@ #define SVG_NS_URI "http://www.w3.org/2000/svg" #define FREECAD_SVG_NS_URI "https://www.freecad.org/wiki/index.php?title=Svg_Namespace" +#define FREECAD_ATTR_EDITABLE "freecad:editable" +#define FREECAD_ATTR_AUTOFILL "freecad:autofill" + //some shapes are being passed in where edges that should be connected are in fact //separated by more than 2*Precision::Confusion (expected tolerance for 2 TopoDS_Vertex) //this value is used in EdgeWalker, DrawProjectSplit and DrawUtil and needs to be in sync in @@ -217,6 +220,7 @@ public: static void angleNormalize(double& fi); static double angleComposition(double fi, double delta); static double angleDifference(double fi1, double fi2, bool reflex = false); + static std::pair nearestFraction(double val, int maxDenom = 999); // Interval marking functions static unsigned int intervalMerge(std::vector>& marking, diff --git a/src/Mod/TechDraw/App/DrawViewSymbol.cpp b/src/Mod/TechDraw/App/DrawViewSymbol.cpp index a7488fe082..d2bfa7d638 100644 --- a/src/Mod/TechDraw/App/DrawViewSymbol.cpp +++ b/src/Mod/TechDraw/App/DrawViewSymbol.cpp @@ -125,7 +125,7 @@ std::vector DrawViewSymbol::getEditableFields() // has "freecad:editable" attribute query.processItems(QString::fromUtf8("declare default element namespace \"" SVG_NS_URI "\"; " "declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; " - "//text[@freecad:editable]/tspan"), + "//text[@" FREECAD_ATTR_EDITABLE "]/tspan"), [&editables](QDomElement& tspan) -> bool { QString editableValue = tspan.firstChild().nodeValue(); editables.emplace_back(editableValue.toStdString()); @@ -154,7 +154,7 @@ void DrawViewSymbol::updateFieldsInSymbol() // has "freecad:editable" attribute query.processItems(QString::fromUtf8("declare default element namespace \"" SVG_NS_URI "\"; " "declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; " - "//text[@freecad:editable]/tspan"), + "//text[@" FREECAD_ATTR_EDITABLE "]/tspan"), [&symbolDocument, &editText, &count](QDomElement& tspanElement) -> bool { if (count >= editText.size()) { diff --git a/src/Mod/TechDraw/App/XMLQuery.cpp b/src/Mod/TechDraw/App/XMLQuery.cpp index 6a88c3b6a3..adae6bac12 100644 --- a/src/Mod/TechDraw/App/XMLQuery.cpp +++ b/src/Mod/TechDraw/App/XMLQuery.cpp @@ -27,6 +27,7 @@ #include #endif +#include "DrawUtil.h" #include "XMLQuery.h" @@ -51,7 +52,7 @@ static bool processElements(const QDomElement& element, const QString& queryStr, for(int i = 0; i < editable.count(); i++) { QDomNode node = editable.item(i); QDomElement element = node.toElement(); - if (element.hasAttribute(QString(QLatin1String("freecad:editable")))) { + if (element.hasAttribute(QString(QLatin1String(FREECAD_ATTR_EDITABLE)))) { if (find_tspan) { element = element.firstChildElement(); } diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index f6ba42655b..dea656de90 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -105,40 +106,33 @@ void CmdTechDrawPageDefault::activated(int iMsg) Q_UNUSED(iMsg); QString templateFileName = Preferences::defaultTemplate(); - - std::string PageName = getUniqueObjectName("Page"); - std::string TemplateName = getUniqueObjectName("Template"); - QFileInfo tfi(templateFileName); if (tfi.isReadable()) { Gui::WaitCursor wc; openCommand(QT_TRANSLATE_NOOP("Command", "Drawing create page")); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawPage', '%s')", - PageName.c_str()); - doCommand(Doc, "App.activeDocument().%s.translateLabel('DrawPage', 'Page', '%s')", - PageName.c_str(), PageName.c_str()); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawSVGTemplate', '%s')", - TemplateName.c_str()); - doCommand(Doc, "App.activeDocument().%s.translateLabel('DrawSVGTemplate', 'Template', '%s')", - TemplateName.c_str(), TemplateName.c_str()); + auto page = dynamic_cast + (getDocument()->addObject("TechDraw::DrawPage", "Page")); + if (!page) { + throw Base::TypeError("CmdTechDrawPageDefault - page not created"); + } + page->translateLabel("DrawPage", "Page", page->getNameInDocument()); - doCommand(Doc, "App.activeDocument().%s.Template = '%s'", TemplateName.c_str(), - templateFileName.toStdString().c_str()); - doCommand(Doc, "App.activeDocument().%s.Template = App.activeDocument().%s", - PageName.c_str(), TemplateName.c_str()); + auto svgTemplate = dynamic_cast + (getDocument()->addObject("TechDraw::DrawSVGTemplate", "Template")); + if (!svgTemplate) { + throw Base::TypeError("CmdTechDrawPageDefault - template not created"); + } + svgTemplate->translateLabel("DrawSVGTemplate", "Template", svgTemplate->getNameInDocument()); + + page->Template.setValue(svgTemplate); + svgTemplate->Template.setValue(templateFileName.toStdString()); updateActive(); commitCommand(); - TechDraw::DrawPage* fp = - dynamic_cast(getDocument()->getObject(PageName.c_str())); - if (!fp) { - throw Base::TypeError("CmdTechDrawPageDefault fp not found\n"); - } - Gui::ViewProvider* vp = - Gui::Application::Instance->getDocument(getDocument())->getViewProvider(fp); - TechDrawGui::ViewProviderPage* dvp = dynamic_cast(vp); + TechDrawGui::ViewProviderPage *dvp = dynamic_cast + (Gui::Application::Instance->getViewProvider(page)); if (dvp) { dvp->show(); } @@ -182,44 +176,33 @@ void CmdTechDrawPageTemplate::activated(int iMsg) return; } - std::string PageName = getUniqueObjectName("Page"); - std::string TemplateName = getUniqueObjectName("Template"); - QFileInfo tfi(templateFileName); if (tfi.isReadable()) { Gui::WaitCursor wc; openCommand(QT_TRANSLATE_NOOP("Command", "Drawing create page")); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawPage', '%s')", - PageName.c_str()); - doCommand(Doc, "App.activeDocument().%s.translateLabel('DrawPage', 'Page', '%s')", - PageName.c_str(), PageName.c_str()); - // Create the Template Object to attach to the page - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawSVGTemplate', '%s')", - TemplateName.c_str()); - doCommand(Doc, "App.activeDocument().%s.translateLabel('DrawSVGTemplate', 'Template', '%s')", - TemplateName.c_str(), TemplateName.c_str()); + auto page = dynamic_cast + (getDocument()->addObject("TechDraw::DrawPage", "Page")); + if (!page) { + throw Base::TypeError("CmdTechDrawPageTemplate - page not created"); + } + page->translateLabel("DrawPage", "Page", page->getNameInDocument()); - //why is "Template" property set twice? -wf - // once to set DrawSVGTemplate.Template to OS template file name - templateFileName = Base::Tools::escapeEncodeFilename(templateFileName); - doCommand(Doc, "App.activeDocument().%s.Template = \"%s\"", TemplateName.c_str(), - templateFileName.toUtf8().constData()); - // once to set Page.Template to DrawSVGTemplate.Name - doCommand(Doc, "App.activeDocument().%s.Template = App.activeDocument().%s", - PageName.c_str(), TemplateName.c_str()); - // consider renaming DrawSVGTemplate.Template property? + auto svgTemplate = dynamic_cast + (getDocument()->addObject("TechDraw::DrawSVGTemplate", "Template")); + if (!svgTemplate) { + throw Base::TypeError("CmdTechDrawPageTemplate - template not created"); + } + svgTemplate->translateLabel("DrawSVGTemplate", "Template", svgTemplate->getNameInDocument()); + + page->Template.setValue(svgTemplate); + svgTemplate->Template.setValue(templateFileName.toStdString()); updateActive(); commitCommand(); - TechDraw::DrawPage* fp = - dynamic_cast(getDocument()->getObject(PageName.c_str())); - if (!fp) { - throw Base::TypeError("CmdTechDrawNewPagePick fp not found\n"); - } - Gui::ViewProvider* vp = - Gui::Application::Instance->getDocument(getDocument())->getViewProvider(fp); - TechDrawGui::ViewProviderPage* dvp = dynamic_cast(vp); + + TechDrawGui::ViewProviderPage *dvp = dynamic_cast + (Gui::Application::Instance->getViewProvider(page)); if (dvp) { dvp->show(); } diff --git a/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp b/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp index 919616c9c1..1762ea90a2 100644 --- a/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp +++ b/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp @@ -178,9 +178,9 @@ void QGISVGTemplate::createClickHandles() // XPath query to select all nodes with "freecad:editable" attribute query.processItems(QString::fromUtf8("declare default element namespace \"" SVG_NS_URI "\"; " "declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; " - "//text[@freecad:editable]"), + "//text[@" FREECAD_ATTR_EDITABLE "]"), [&](QDomElement& textElement) -> bool { - QString name = textElement.attribute(QString::fromUtf8("freecad:editable")); + QString name = textElement.attribute(QString::fromUtf8(FREECAD_ATTR_EDITABLE)); double x = Rez::guiX( textElement.attribute(QString::fromUtf8("x"), QString::fromUtf8("0.0")).toDouble()); double y = Rez::guiX( diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index 0916dfc9f5..d2cc2638bb 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include "TaskProjGroup.h" #include "ui_TaskProjGroup.h" @@ -306,81 +307,6 @@ void TaskProjGroup::spacingChanged() multiView->recomputeFeature(); } -std::pair TaskProjGroup::nearestFraction(const double val, const long int maxDenom) const -{ -/* -** find rational approximation to given real number -** David Eppstein / UC Irvine / 8 Aug 1993 -** -** With corrections from Arno Formella, May 2008 -** and additional fiddles by WF 2017 -** usage: a.out r d -** r is real number to approx -** d is the maximum denominator allowed -** -** based on the theory of continued fractions -** if x = a1 + 1/(a2 + 1/(a3 + 1/(a4 + ...))) -** then best approximation is found by truncating this series -** (with some adjustments in the last term). -** -** Note the fraction can be recovered as the first column of the matrix -** ( a1 1 ) ( a2 1 ) ( a3 1 ) ... -** ( 1 0 ) ( 1 0 ) ( 1 0 ) -** Instead of keeping the sequence of continued fraction terms, -** we just keep the last partial product of these matrices. -*/ - std::pair result; - long m[2][2]; - long maxden = maxDenom; - long ai; - double x = val; - double startx = x; - - /* initialize matrix */ - m[0][0] = m[1][1] = 1; - m[0][1] = m[1][0] = 0; - - /* loop finding terms until denom gets too big */ - while (m[1][0] * ( ai = (long)x ) + m[1][1] <= maxden) { - long t; - t = m[0][0] * ai + m[0][1]; - m[0][1] = m[0][0]; - m[0][0] = t; - t = m[1][0] * ai + m[1][1]; - m[1][1] = m[1][0]; - m[1][0] = t; - if(x == (double) ai) - break; // AF: division by zero - x = 1/(x - (double) ai); - if(x > (double) std::numeric_limits::max()) - break; // AF: representation failure - } - - /* now remaining x is between 0 and 1/ai */ - /* approx as either 0 or 1/m where m is max that will fit in maxden */ - /* first try zero */ - double error1 = startx - ((double) m[0][0] / (double) m[1][0]); - int n1 = m[0][0]; - int d1 = m[1][0]; - - /* now try other possibility */ - ai = (maxden - m[1][1]) / m[1][0]; - m[0][0] = m[0][0] * ai + m[0][1]; - m[1][0] = m[1][0] * ai + m[1][1]; - double error2 = startx - ((double) m[0][0] / (double) m[1][0]); - int n2 = m[0][0]; - int d2 = m[1][0]; - - if (std::fabs(error1) <= std::fabs(error2)) { - result.first = n1; - result.second = d1; - } else { - result.first = n2; - result.second = d2; - } - return result; -} - void TaskProjGroup::updateTask() { // Update the scale type @@ -398,7 +324,7 @@ void TaskProjGroup::setFractionalScale(double newScale) { blockUpdate = true; - std::pair fraction = nearestFraction(newScale); + std::pair fraction = DrawUtil::nearestFraction(newScale); ui->sbScaleNum->setValue(fraction.first); ui->sbScaleDen->setValue(fraction.second); diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.h b/src/Mod/TechDraw/Gui/TaskProjGroup.h index 9e1dbfa3e3..7a3062443c 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.h +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.h @@ -60,7 +60,6 @@ public: QPushButton* btnApply); void updateTask(); - std::pair nearestFraction(double val, long int maxDenom = 999) const; // Sets the numerator and denominator widgets to match newScale void setFractionalScale(double newScale); void setCreateMode(bool mode) { m_createMode = mode;} diff --git a/src/Mod/TechDraw/Templates/A4_LandscapeTD.svg b/src/Mod/TechDraw/Templates/A4_LandscapeTD.svg index 1ea6c239bc..c3b68cf97a 100644 --- a/src/Mod/TechDraw/Templates/A4_LandscapeTD.svg +++ b/src/Mod/TechDraw/Templates/A4_LandscapeTD.svg @@ -192,13 +192,13 @@ - Designed by Name - Date - Scale + Designed by Name + Date + Scale Weight - Title + Title Subtitle Drawing number - Sheet + Sheet diff --git a/src/Mod/TechDraw/Templates/ANSIC_Landscape.svg b/src/Mod/TechDraw/Templates/ANSIC_Landscape.svg index 04981c38a7..50357387ce 100644 --- a/src/Mod/TechDraw/Templates/ANSIC_Landscape.svg +++ b/src/Mod/TechDraw/Templates/ANSIC_Landscape.svg @@ -314,18 +314,18 @@ - AUTHOR NAME - CREATION DATE + AUTHOR NAME + CREATION DATE SUPERVISOR NAME CHECK DATE ANSI C - SCALE + SCALE WEIGHT NUMBER - SHEET - TITLE + SHEET + TITLE SUBTITLE - COMPANY NAME + COMPANY NAME COPYRIGHT _________ _________