From f5950f7a3fbc02929a3c282570c4dd81e1811e1b Mon Sep 17 00:00:00 2001 From: IKhonakhbeeva Date: Thu, 22 Feb 2024 23:35:10 +0100 Subject: [PATCH] Trim precision for every functional operation in 2D interpreter --- .../common/trikKit/src/blocks/details/trikPrintTextBlock.cpp | 4 +--- .../interpreterCore/src/coreBlocks/details/printTextBlock.cpp | 4 +--- .../interpreterCore/src/textLanguage/robotsBlockParser.cpp | 4 +++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/plugins/robots/common/trikKit/src/blocks/details/trikPrintTextBlock.cpp b/plugins/robots/common/trikKit/src/blocks/details/trikPrintTextBlock.cpp index b147cbf2d3..872123c709 100644 --- a/plugins/robots/common/trikKit/src/blocks/details/trikPrintTextBlock.cpp +++ b/plugins/robots/common/trikKit/src/blocks/details/trikPrintTextBlock.cpp @@ -30,9 +30,7 @@ void TrikPrintTextBlock::doJob(kitBase::robotModel::robotParts::Display &display const int x = eval("XCoordinateText"); const int y = eval("YCoordinateText"); const int fontSize = eval("FontSize"); - const QString result = boolProperty("Evaluate") - ? QString::number(QString::number(eval("PrintText"), 'f', 6).toDouble()) - : stringProperty("PrintText"); + const QString result = boolProperty("Evaluate") ? eval("PrintText") : stringProperty("PrintText"); const bool redraw = boolProperty("Redraw"); if (!errorsOccured()) { diff --git a/plugins/robots/interpreters/interpreterCore/src/coreBlocks/details/printTextBlock.cpp b/plugins/robots/interpreters/interpreterCore/src/coreBlocks/details/printTextBlock.cpp index 5db320ac54..18632cf124 100644 --- a/plugins/robots/interpreters/interpreterCore/src/coreBlocks/details/printTextBlock.cpp +++ b/plugins/robots/interpreters/interpreterCore/src/coreBlocks/details/printTextBlock.cpp @@ -28,9 +28,7 @@ void PrintTextBlock::doJob(kitBase::robotModel::robotParts::Display &display) { const int x = eval("XCoordinateText"); const int y = eval("YCoordinateText"); - const QString result = boolProperty("Evaluate") - ? QString::number(QString::number(eval("PrintText"), 'f', 6).toDouble()) - : stringProperty("PrintText"); + const QString result = boolProperty("Evaluate") ? eval("PrintText") : stringProperty("PrintText"); const bool redraw = boolProperty("Redraw"); if (!errorsOccured()) { diff --git a/plugins/robots/interpreters/interpreterCore/src/textLanguage/robotsBlockParser.cpp b/plugins/robots/interpreters/interpreterCore/src/textLanguage/robotsBlockParser.cpp index b1a57f811b..a2d976cacf 100644 --- a/plugins/robots/interpreters/interpreterCore/src/textLanguage/robotsBlockParser.cpp +++ b/plugins/robots/interpreters/interpreterCore/src/textLanguage/robotsBlockParser.cpp @@ -161,7 +161,9 @@ void RobotsBlockParser::addIntrinsicFuctions() , std::function const &function) { add1aryFunction(name, new types::Float, new types::Float - , [function](const QVariant &arg) { return function(arg.toReal()); }); + , [function](const QVariant &arg) { + return QString::number(function(arg.toReal()), 'f').toDouble(); + }); }; const auto addIntegerFunction = [add1aryFunction] (const QString &name