element-editor: limit decimal places for sizes and positions to two, when saving file

This commit is contained in:
plc-user
2025-02-09 12:33:24 +01:00
parent 706eba6612
commit 1fc33aa1ba
8 changed files with 67 additions and 29 deletions

View File

@@ -115,15 +115,22 @@ const QDomElement PartLine::toXml(QDomDocument &xml_document) const
QPointF p1(sceneP1());
QPointF p2(sceneP2());
p1.setX((qRound(p1.x() * 100.0)) / 100.0);
p1.setY((qRound(p1.y() * 100.0)) / 100.0);
p2.setX((qRound(p2.x() * 100.0)) / 100.0);
p2.setY((qRound(p2.y() * 100.0)) / 100.0);
qreal firstLength = ((qRound(first_length * 100.0)) / 100.0);
qreal secondLength = ((qRound(second_length * 100.0)) / 100.0);
QDomElement xml_element = xml_document.createElement("line");
xml_element.setAttribute("x1", QString("%1").arg(p1.x()));
xml_element.setAttribute("y1", QString("%1").arg(p1.y()));
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
xml_element.setAttribute("y2", QString("%1").arg(p2.y()));
xml_element.setAttribute("end1", Qet::endTypeToString(first_end));
xml_element.setAttribute("length1", QString("%1").arg(first_length));
xml_element.setAttribute("length1", QString("%1").arg(firstLength));
xml_element.setAttribute("end2", Qet::endTypeToString(second_end));
xml_element.setAttribute("length2", QString("%1").arg(second_length));
xml_element.setAttribute("length2", QString("%1").arg(secondLength));
stylesToXml(xml_element);
return(xml_element);