From b2d26e5ae887148e27c4999c46c91f8320189fc3 Mon Sep 17 00:00:00 2001 From: dismine Date: Tue, 11 Mar 2014 17:04:04 +0200 Subject: [PATCH] toPixel and fromPixel with units support - mm, cm, inch. --HG-- branch : feature --- src/container/vcontainer.cpp | 4 +- src/dialogs/tools/dialogdetail.cpp | 8 +-- src/dialogs/tools/dialogsinglepoint.cpp | 16 ++--- src/main.cpp | 3 +- src/mainwindow.cpp | 4 +- src/options.h | 60 ++++++++++++++----- src/tablewindow.cpp | 2 +- src/tools/drawTools/vtoolalongline.cpp | 8 +-- src/tools/drawTools/vtoolbisector.cpp | 8 +-- src/tools/drawTools/vtoolcutarc.cpp | 8 +-- src/tools/drawTools/vtoolcutspline.cpp | 16 ++--- src/tools/drawTools/vtoolcutsplinepath.cpp | 16 ++--- src/tools/drawTools/vtoolendline.cpp | 8 +-- src/tools/drawTools/vtoolheight.cpp | 8 +-- src/tools/drawTools/vtoollineintersect.cpp | 8 +-- src/tools/drawTools/vtoolnormal.cpp | 8 +-- src/tools/drawTools/vtoolpoint.cpp | 4 +- src/tools/drawTools/vtoolpointofcontact.cpp | 8 +-- .../drawTools/vtoolpointofintersection.cpp | 8 +-- src/tools/drawTools/vtoolshoulderpoint.cpp | 8 +-- src/tools/drawTools/vtoolsinglepoint.cpp | 24 ++++---- src/tools/drawTools/vtoolspline.cpp | 4 +- src/tools/drawTools/vtoolsplinepath.cpp | 4 +- src/tools/drawTools/vtooltriangle.cpp | 8 +-- src/tools/nodeDetails/vnodepoint.cpp | 12 ++-- src/tools/vtooldetail.cpp | 12 ++-- src/tools/vtooluniondetails.cpp | 4 +- 27 files changed, 156 insertions(+), 125 deletions(-) diff --git a/src/container/vcontainer.cpp b/src/container/vcontainer.cpp index 499460a9a..2f2f4a0d9 100644 --- a/src/container/vcontainer.cpp +++ b/src/container/vcontainer.cpp @@ -239,7 +239,7 @@ void VContainer::AddLengthSpline(const QString &name, const qreal &value) void VContainer::AddLengthArc(const quint32 &id) { const VArc * arc = GeometricObject(id); - lengthArcs[arc->name()] = toMM(arc->GetLength()); + lengthArcs[arc->name()] = fromPixel(arc->GetLength()); } void VContainer::AddLineAngle(const QString &name, const qreal &value) @@ -352,7 +352,7 @@ void VContainer::AddLine(const quint32 &firstPointId, const quint32 &secondPoint QString nameLine = GetNameLine(firstPointId, secondPointId); const VPointF *first = GeometricObject(firstPointId); const VPointF *second = GeometricObject(secondPointId); - AddLengthLine(nameLine, toMM(QLineF(first->toQPointF(), second->toQPointF()).length())); + AddLengthLine(nameLine, fromPixel(QLineF(first->toQPointF(), second->toQPointF()).length())); nameLine = GetNameLineAngle(firstPointId, secondPointId); AddLineAngle(nameLine, QLineF(first->toQPointF(), second->toQPointF()).angle()); } diff --git a/src/dialogs/tools/dialogdetail.cpp b/src/dialogs/tools/dialogdetail.cpp index df0a1e044..7813037fc 100644 --- a/src/dialogs/tools/dialogdetail.cpp +++ b/src/dialogs/tools/dialogdetail.cpp @@ -150,8 +150,8 @@ void DialogDetail::NewItem(quint32 id, const Valentina::Tools &typeTool, const N this, &DialogDetail::BiasXChanged); disconnect(ui.spinBoxBiasY, static_cast(&QSpinBox::valueChanged), this, &DialogDetail::BiasYChanged); - ui.spinBoxBiasX->setValue(static_cast(toMM(node.getMx()))); - ui.spinBoxBiasY->setValue(static_cast(toMM(node.getMy()))); + ui.spinBoxBiasX->setValue(static_cast(fromPixel(node.getMx()))); + ui.spinBoxBiasY->setValue(static_cast(fromPixel(node.getMy()))); connect(ui.spinBoxBiasX, static_cast(&QSpinBox::valueChanged), this, &DialogDetail::BiasXChanged); connect(ui.spinBoxBiasY, static_cast(&QSpinBox::valueChanged), @@ -218,8 +218,8 @@ void DialogDetail::ObjectChanged(int row) } QListWidgetItem *item = ui.listWidget->item( row ); VNodeDetail node = qvariant_cast(item->data(Qt::UserRole)); - ui.spinBoxBiasX->setValue(static_cast(toMM(node.getMx()))); - ui.spinBoxBiasY->setValue(static_cast(toMM(node.getMy()))); + ui.spinBoxBiasX->setValue(static_cast(fromPixel(node.getMx()))); + ui.spinBoxBiasY->setValue(static_cast(fromPixel(node.getMy()))); } void DialogDetail::DeleteItem() diff --git a/src/dialogs/tools/dialogsinglepoint.cpp b/src/dialogs/tools/dialogsinglepoint.cpp index 570758d28..4cc21750d 100644 --- a/src/dialogs/tools/dialogsinglepoint.cpp +++ b/src/dialogs/tools/dialogsinglepoint.cpp @@ -36,8 +36,8 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) point(QPointF()) { ui->setupUi(this); - ui->doubleSpinBoxX->setRange(0, toMM(SceneSize)); - ui->doubleSpinBoxY->setRange(0, toMM(SceneSize)); + ui->doubleSpinBoxX->setRange(0, fromPixel(SceneSize)); + ui->doubleSpinBoxY->setRange(0, fromPixel(SceneSize)); labelEditNamePoint = ui->labelEditName; InitOkCansel(ui); @@ -51,14 +51,14 @@ void DialogSinglePoint::mousePress(const QPointF &scenePos) { if (isInitialized == false) { - ui->doubleSpinBoxX->setValue(toMM(scenePos.x())); - ui->doubleSpinBoxY->setValue(toMM(scenePos.y())); + ui->doubleSpinBoxX->setValue(fromPixel(scenePos.x())); + ui->doubleSpinBoxY->setValue(fromPixel(scenePos.y())); this->show(); } else { - ui->doubleSpinBoxX->setValue(toMM(scenePos.x())); - ui->doubleSpinBoxY->setValue(toMM(scenePos.y())); + ui->doubleSpinBoxX->setValue(fromPixel(scenePos.x())); + ui->doubleSpinBoxY->setValue(fromPixel(scenePos.y())); } } @@ -75,8 +75,8 @@ void DialogSinglePoint::setData(const QString &name, const QPointF &point) this->point = point; isInitialized = true; ui->lineEditName->setText(name); - ui->doubleSpinBoxX->setValue(toMM(point.x())); - ui->doubleSpinBoxY->setValue(toMM(point.y())); + ui->doubleSpinBoxX->setValue(fromPixel(point.x())); + ui->doubleSpinBoxY->setValue(fromPixel(point.y())); } DialogSinglePoint::~DialogSinglePoint() diff --git a/src/main.cpp b/src/main.cpp index bf6e7159e..aaedb8c55 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,8 @@ #include "tablewindow.h" #include "options.h" -Valentina::Units patternUnit = Valentina::Cm; +//Default pattern unit. +Valentina::Units patternUnit = Valentina::Mm; #ifdef Q_OS_WIN const QString translationsPath = QString("/translations"); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 098a82c18..591c56d5e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -621,8 +621,8 @@ void MainWindow::currentDrawChanged( int index ) void MainWindow::mouseMove(const QPointF &scenePos) { QString string = QString("%1, %2") - .arg(static_cast(toMM(scenePos.x()))) - .arg(static_cast(toMM(scenePos.y()))); + .arg(static_cast(fromPixel(scenePos.x()))) + .arg(static_cast(fromPixel(scenePos.y()))); mouseCoordinate->setText(string); } diff --git a/src/options.h b/src/options.h index 6580940f4..d07c656eb 100644 --- a/src/options.h +++ b/src/options.h @@ -34,21 +34,6 @@ #define SceneSize 50000 -#define PrintDPI 96.0 - -inline double toPixel(double mm) -{ - return (mm / 25.4) * PrintDPI; -} - -inline double toMM(double pix) -{ - return (pix / PrintDPI) * 25.4; -} - -#define widthMainLine 1.2 //mm -#define widthHairLine widthMainLine/3 - extern const QString translationsPath; namespace Valentina @@ -118,4 +103,49 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Units ) extern Valentina::Units patternUnit; +#define PrintDPI 96.0 + +inline double toPixel(double unit) +{ + double result = 0; + switch (patternUnit) + { + case Valentina::Mm: + result = (unit / 25.4) * PrintDPI; + break; + case Valentina::Cm: + result = ((unit * 10.0) / 25.4) * PrintDPI; + break; + case Valentina::In: + result = unit * PrintDPI; + break; + default: + break; + } + return result; +} + +inline double fromPixel(double pix) +{ + double result = 0; + switch (patternUnit) + { + case Valentina::Mm: + result = (pix / PrintDPI) * 25.4; + break; + case Valentina::Cm: + result = ((pix / PrintDPI) * 25.4) / 10.0; + break; + case Valentina::In: + result = pix / PrintDPI; + break; + default: + break; + } + return result; +} + +#define widthMainLine 1.2 //mm +#define widthHairLine widthMainLine/3 + #endif // OPTIONS_H diff --git a/src/tablewindow.cpp b/src/tablewindow.cpp index de0598f80..06e23ce0e 100644 --- a/src/tablewindow.cpp +++ b/src/tablewindow.cpp @@ -474,7 +474,7 @@ void TableWindow::PdfFile(const QString &name) const qreal x=0, y=0, w=0, h=0; r.getRect(&x, &y, &w, &h);// Re-shrink the scene to it's bounding contents printer.setResolution(PrintDPI); - printer.setPaperSize ( QSizeF(toMM(w), toMM(h)), QPrinter::Millimeter ); + printer.setPaperSize ( QSizeF(fromPixel(w), fromPixel(h)), QPrinter::Millimeter ); QPainter painter; if (painter.begin( &printer ) == false) { // failed to open file diff --git a/src/tools/drawTools/vtoolalongline.cpp b/src/tools/drawTools/vtoolalongline.cpp index 961e2bf1b..325a28ca4 100644 --- a/src/tools/drawTools/vtoolalongline.cpp +++ b/src/tools/drawTools/vtoolalongline.cpp @@ -87,8 +87,8 @@ void VToolAlongLine::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); @@ -104,8 +104,8 @@ void VToolAlongLine::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrName, point->name()); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); diff --git a/src/tools/drawTools/vtoolbisector.cpp b/src/tools/drawTools/vtoolbisector.cpp index 373f140ec..9e6147e18 100644 --- a/src/tools/drawTools/vtoolbisector.cpp +++ b/src/tools/drawTools/vtoolbisector.cpp @@ -185,8 +185,8 @@ void VToolBisector::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); @@ -203,8 +203,8 @@ void VToolBisector::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrName, point->name()); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); diff --git a/src/tools/drawTools/vtoolcutarc.cpp b/src/tools/drawTools/vtoolcutarc.cpp index 2c19e1be2..9e830059f 100644 --- a/src/tools/drawTools/vtoolcutarc.cpp +++ b/src/tools/drawTools/vtoolcutarc.cpp @@ -208,8 +208,8 @@ void VToolCutArc::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrLength, formula); doc->SetAttribute(domElement, AttrArc, arcId); @@ -224,8 +224,8 @@ void VToolCutArc::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrLength, formula); doc->SetAttribute(domElement, AttrArc, arcId); } diff --git a/src/tools/drawTools/vtoolcutspline.cpp b/src/tools/drawTools/vtoolcutspline.cpp index 6d6c5e97b..fbebbf04a 100644 --- a/src/tools/drawTools/vtoolcutspline.cpp +++ b/src/tools/drawTools/vtoolcutspline.cpp @@ -110,11 +110,11 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve()); spl1id = data->AddGObject(spline1); - data->AddLengthSpline(spline1->name(), toMM(spline1->GetLength())); + data->AddLengthSpline(spline1->name(), fromPixel(spline1->GetLength())); VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4(), spl->GetKcurve()); spl2id = data->AddGObject(spline2); - data->AddLengthSpline(spline2->name(), toMM(spline2->GetLength())); + data->AddLengthSpline(spline2->name(), fromPixel(spline2->GetLength())); } else { @@ -126,11 +126,11 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, VSpline *spline1 = new VSpline(spl->GetP1(), spl1p2, spl1p3, *p, spl->GetKcurve()); data->UpdateGObject(spl1id, spline1); - data->AddLengthSpline(spline1->name(), toMM(spline1->GetLength())); + data->AddLengthSpline(spline1->name(), fromPixel(spline1->GetLength())); VSpline *spline2 = new VSpline(*p, spl2p2, spl2p3, spl->GetP4(), spl->GetKcurve()); data->UpdateGObject(spl2id, spline2); - data->AddLengthSpline(spline2->name(), toMM(spline2->GetLength())); + data->AddLengthSpline(spline2->name(), fromPixel(spline2->GetLength())); if (parse != Document::FullParse) { @@ -204,8 +204,8 @@ void VToolCutSpline::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrLength, formula); doc->SetAttribute(domElement, AttrSpline, splineId); @@ -220,8 +220,8 @@ void VToolCutSpline::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrLength, formula); doc->SetAttribute(domElement, AttrSpline, splineId); } diff --git a/src/tools/drawTools/vtoolcutsplinepath.cpp b/src/tools/drawTools/vtoolcutsplinepath.cpp index c29c921cf..f99b09179 100644 --- a/src/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/tools/drawTools/vtoolcutsplinepath.cpp @@ -159,10 +159,10 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, con splPath2->setMaxCountPoints(splPath->CountPoint()); splPath1id = data->AddGObject(splPath1); - data->AddLengthSpline(splPath1->name(), toMM(splPath1->GetLength())); + data->AddLengthSpline(splPath1->name(), fromPixel(splPath1->GetLength())); splPath2id = data->AddGObject(splPath2); - data->AddLengthSpline(splPath2->name(), toMM(splPath2->GetLength())); + data->AddLengthSpline(splPath2->name(), fromPixel(splPath2->GetLength())); } else { @@ -200,10 +200,10 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, con splPath2->setMaxCountPoints(splPath->CountPoint()); data->UpdateGObject(splPath1id, splPath1); - data->AddLengthSpline(splPath1->name(), toMM(splPath1->GetLength())); + data->AddLengthSpline(splPath1->name(), fromPixel(splPath1->GetLength())); data->UpdateGObject(splPath2id, splPath2); - data->AddLengthSpline(splPath2->name(), toMM(splPath2->GetLength())); + data->AddLengthSpline(splPath2->name(), fromPixel(splPath2->GetLength())); if (parse != Document::FullParse) { @@ -278,8 +278,8 @@ void VToolCutSplinePath::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrLength, formula); doc->SetAttribute(domElement, AttrSplinePath, splinePathId); @@ -294,8 +294,8 @@ void VToolCutSplinePath::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrLength, formula); doc->SetAttribute(domElement, AttrSplinePath, splinePathId); } diff --git a/src/tools/drawTools/vtoolendline.cpp b/src/tools/drawTools/vtoolendline.cpp index 3448387ae..81213c3cf 100644 --- a/src/tools/drawTools/vtoolendline.cpp +++ b/src/tools/drawTools/vtoolendline.cpp @@ -151,8 +151,8 @@ void VToolEndLine::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); @@ -169,8 +169,8 @@ void VToolEndLine::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); doc->SetAttribute(domElement, AttrAngle, angle); diff --git a/src/tools/drawTools/vtoolheight.cpp b/src/tools/drawTools/vtoolheight.cpp index c468180a6..475d127aa 100644 --- a/src/tools/drawTools/vtoolheight.cpp +++ b/src/tools/drawTools/vtoolheight.cpp @@ -157,8 +157,8 @@ void VToolHeight::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrBasePoint, basePointId); @@ -176,8 +176,8 @@ void VToolHeight::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrBasePoint, basePointId); doc->SetAttribute(domElement, AttrP1Line, p1LineId); diff --git a/src/tools/drawTools/vtoollineintersect.cpp b/src/tools/drawTools/vtoollineintersect.cpp index 7688e8414..255ea5048 100644 --- a/src/tools/drawTools/vtoollineintersect.cpp +++ b/src/tools/drawTools/vtoollineintersect.cpp @@ -168,8 +168,8 @@ void VToolLineIntersect::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrP1Line1, p1Line1); doc->SetAttribute(domElement, AttrP2Line1, p2Line1); @@ -186,8 +186,8 @@ void VToolLineIntersect::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrP1Line1, p1Line1); doc->SetAttribute(domElement, AttrP2Line1, p2Line1); doc->SetAttribute(domElement, AttrP1Line2, p1Line2); diff --git a/src/tools/drawTools/vtoolnormal.cpp b/src/tools/drawTools/vtoolnormal.cpp index 03edae31f..1af5c1fa4 100644 --- a/src/tools/drawTools/vtoolnormal.cpp +++ b/src/tools/drawTools/vtoolnormal.cpp @@ -171,8 +171,8 @@ void VToolNormal::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); @@ -190,8 +190,8 @@ void VToolNormal::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); doc->SetAttribute(domElement, AttrAngle, angle); diff --git a/src/tools/drawTools/vtoolpoint.cpp b/src/tools/drawTools/vtoolpoint.cpp index 8ab589871..36fc194db 100644 --- a/src/tools/drawTools/vtoolpoint.cpp +++ b/src/tools/drawTools/vtoolpoint.cpp @@ -62,8 +62,8 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - doc->SetAttribute(domElement, AttrMx, toMM(mx)); - doc->SetAttribute(domElement, AttrMy, toMM(my)); + doc->SetAttribute(domElement, AttrMx, fromPixel(mx)); + doc->SetAttribute(domElement, AttrMy, fromPixel(my)); emit toolhaveChange(); } } diff --git a/src/tools/drawTools/vtoolpointofcontact.cpp b/src/tools/drawTools/vtoolpointofcontact.cpp index d72235f0a..132be01d3 100644 --- a/src/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/tools/drawTools/vtoolpointofcontact.cpp @@ -191,8 +191,8 @@ void VToolPointOfContact::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrRadius, arcRadius); doc->SetAttribute(domElement, AttrCenter, center); @@ -209,8 +209,8 @@ void VToolPointOfContact::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrRadius, arcRadius); doc->SetAttribute(domElement, AttrCenter, center); doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); diff --git a/src/tools/drawTools/vtoolpointofintersection.cpp b/src/tools/drawTools/vtoolpointofintersection.cpp index 1fe8457a5..8c94e118d 100644 --- a/src/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/tools/drawTools/vtoolpointofintersection.cpp @@ -141,8 +141,8 @@ void VToolPointOfIntersection::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); @@ -157,8 +157,8 @@ void VToolPointOfIntersection::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); doc->SetAttribute(domElement, AttrSecondPoint, secondPointId); } diff --git a/src/tools/drawTools/vtoolshoulderpoint.cpp b/src/tools/drawTools/vtoolshoulderpoint.cpp index 1c35b3d40..140c62550 100644 --- a/src/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/tools/drawTools/vtoolshoulderpoint.cpp @@ -193,8 +193,8 @@ void VToolShoulderPoint::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); @@ -212,8 +212,8 @@ void VToolShoulderPoint::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrName, toMM(point->mx())); - doc->SetAttribute(domElement, AttrName, toMM(point->my())); + doc->SetAttribute(domElement, AttrName, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrName, fromPixel(point->my())); doc->SetAttribute(domElement, AttrTypeLine, typeLine); doc->SetAttribute(domElement, AttrLength, formula); doc->SetAttribute(domElement, AttrP1Line, basePointId); diff --git a/src/tools/drawTools/vtoolsinglepoint.cpp b/src/tools/drawTools/vtoolsinglepoint.cpp index 4447f1fa7..1b86768f5 100644 --- a/src/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/tools/drawTools/vtoolsinglepoint.cpp @@ -69,10 +69,10 @@ void VToolSinglePoint::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrX, toMM(point->x())); - doc->SetAttribute(domElement, AttrY, toMM(point->y())); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrX, fromPixel(point->x())); + doc->SetAttribute(domElement, AttrY, fromPixel(point->y())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); AddToCalculation(domElement); } @@ -84,10 +84,10 @@ void VToolSinglePoint::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrX, QString().setNum(toMM(point->x()))); - doc->SetAttribute(domElement, AttrY, QString().setNum(toMM(point->y()))); - doc->SetAttribute(domElement, AttrMx, QString().setNum(toMM(point->mx()))); - doc->SetAttribute(domElement, AttrMy, QString().setNum(toMM(point->my()))); + doc->SetAttribute(domElement, AttrX, QString().setNum(fromPixel(point->x()))); + doc->SetAttribute(domElement, AttrY, QString().setNum(fromPixel(point->y()))); + doc->SetAttribute(domElement, AttrMx, QString().setNum(fromPixel(point->mx()))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(fromPixel(point->my()))); } } @@ -113,8 +113,8 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - doc->SetAttribute(domElement, AttrX, QString().setNum(toMM(newPos.x()))); - doc->SetAttribute(domElement, AttrY, QString().setNum(toMM(newPos.y()))); + doc->SetAttribute(domElement, AttrX, QString().setNum(fromPixel(newPos.x()))); + doc->SetAttribute(domElement, AttrY, QString().setNum(fromPixel(newPos.y()))); QList list = this->scene()->views(); VAbstractTool::NewSceneRect(this->scene(), list[0]); @@ -143,8 +143,8 @@ void VToolSinglePoint::SaveDialog(QDomElement &domElement) QPointF p = dialogTool->getPoint(); QString name = dialogTool->getName(); doc->SetAttribute(domElement, AttrName, name); - doc->SetAttribute(domElement, AttrX, QString().setNum(toMM(p.x()))); - doc->SetAttribute(domElement, AttrY, QString().setNum(toMM(p.y()))); + doc->SetAttribute(domElement, AttrX, QString().setNum(fromPixel(p.x()))); + doc->SetAttribute(domElement, AttrY, QString().setNum(fromPixel(p.y()))); } void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color) diff --git a/src/tools/drawTools/vtoolspline.cpp b/src/tools/drawTools/vtoolspline.cpp index b3db920ea..1f3c9599f 100644 --- a/src/tools/drawTools/vtoolspline.cpp +++ b/src/tools/drawTools/vtoolspline.cpp @@ -115,12 +115,12 @@ void VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4 if (typeCreation == Valentina::FromGui) { id = data->AddGObject(spline); - data->AddLengthSpline(spline->name(), toMM(spline->GetLength())); + data->AddLengthSpline(spline->name(), fromPixel(spline->GetLength())); } else { data->UpdateGObject(id, spline); - data->AddLengthSpline(spline->name(), toMM(spline->GetLength())); + data->AddLengthSpline(spline->name(), fromPixel(spline->GetLength())); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/tools/drawTools/vtoolsplinepath.cpp b/src/tools/drawTools/vtoolsplinepath.cpp index b5aaf2378..28fc4a1ee 100644 --- a/src/tools/drawTools/vtoolsplinepath.cpp +++ b/src/tools/drawTools/vtoolsplinepath.cpp @@ -102,12 +102,12 @@ void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphics if (typeCreation == Valentina::FromGui) { id = data->AddGObject(path); - data->AddLengthSpline(path->name(), toMM(path->GetLength())); + data->AddLengthSpline(path->name(), fromPixel(path->GetLength())); } else { data->UpdateGObject(id, path); - data->AddLengthSpline(path->name(), toMM(path->GetLength())); + data->AddLengthSpline(path->name(), fromPixel(path->GetLength())); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/tools/drawTools/vtooltriangle.cpp b/src/tools/drawTools/vtooltriangle.cpp index 9529d0d7c..c86753455 100644 --- a/src/tools/drawTools/vtooltriangle.cpp +++ b/src/tools/drawTools/vtooltriangle.cpp @@ -197,8 +197,8 @@ void VToolTriangle::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrAxisP1, axisP1Id); doc->SetAttribute(domElement, AttrAxisP2, axisP2Id); @@ -215,8 +215,8 @@ void VToolTriangle::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); doc->SetAttribute(domElement, AttrAxisP1, axisP1Id); doc->SetAttribute(domElement, AttrAxisP2, axisP2Id); doc->SetAttribute(domElement, AttrFirstPoint, firstPointId); diff --git a/src/tools/nodeDetails/vnodepoint.cpp b/src/tools/nodeDetails/vnodepoint.cpp index 9928d87c9..92c7e2139 100644 --- a/src/tools/nodeDetails/vnodepoint.cpp +++ b/src/tools/nodeDetails/vnodepoint.cpp @@ -107,8 +107,8 @@ void VNodePoint::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrType, ToolType); doc->SetAttribute(domElement, AttrIdObject, idNode); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); if (idTool != 0) { doc->SetAttribute(domElement, AttrIdTool, idTool); @@ -124,8 +124,8 @@ void VNodePoint::RefreshDataInFile() if (domElement.isElement()) { doc->SetAttribute(domElement, AttrIdObject, idNode); - doc->SetAttribute(domElement, AttrMx, toMM(point->mx())); - doc->SetAttribute(domElement, AttrMy, toMM(point->my())); + doc->SetAttribute(domElement, AttrMx, fromPixel(point->mx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(point->my())); if (idTool != 0) { doc->SetAttribute(domElement, AttrIdTool, idTool); @@ -171,8 +171,8 @@ void VNodePoint::UpdateNamePosition(qreal mx, qreal my) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - doc->SetAttribute(domElement, AttrMx, QString().setNum(toMM(mx))); - doc->SetAttribute(domElement, AttrMy, QString().setNum(toMM(my))); + doc->SetAttribute(domElement, AttrMx, QString().setNum(fromPixel(mx))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(fromPixel(my))); emit toolhaveChange(); } } diff --git a/src/tools/vtooldetail.cpp b/src/tools/vtooldetail.cpp index 60504c451..4415a0ac1 100644 --- a/src/tools/vtooldetail.cpp +++ b/src/tools/vtooldetail.cpp @@ -230,8 +230,8 @@ void VToolDetail::AddToFile() doc->SetAttribute(domElement, AttrId, id); doc->SetAttribute(domElement, AttrName, detail.getName()); - doc->SetAttribute(domElement, AttrMx, toMM(detail.getMx())); - doc->SetAttribute(domElement, AttrMy, toMM(detail.getMy())); + doc->SetAttribute(domElement, AttrMx, fromPixel(detail.getMx())); + doc->SetAttribute(domElement, AttrMy, fromPixel(detail.getMy())); doc->SetAttribute(domElement, AttrSupplement, detail.getSeamAllowance()); doc->SetAttribute(domElement, AttrClosed, detail.getClosed()); doc->SetAttribute(domElement, AttrWidth, detail.getWidth()); @@ -277,8 +277,8 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - doc->SetAttribute(domElement, AttrMx, QString().setNum(toMM(newPos.x()))); - doc->SetAttribute(domElement, AttrMy, QString().setNum(toMM(newPos.y()))); + doc->SetAttribute(domElement, AttrMx, QString().setNum(fromPixel(newPos.x()))); + doc->SetAttribute(domElement, AttrMy, QString().setNum(fromPixel(newPos.y()))); QList list = this->scene()->views(); VAbstractTool::NewSceneRect(this->scene(), list[0]); @@ -370,8 +370,8 @@ void VToolDetail::AddNode(QDomElement &domElement, const VNodeDetail &node) QDomElement nod = doc->createElement(TagNode); doc->SetAttribute(nod, AttrIdObject, node.getId()); - doc->SetAttribute(nod, AttrMx, toMM(node.getMx())); - doc->SetAttribute(nod, AttrMy, toMM(node.getMy())); + doc->SetAttribute(nod, AttrMx, fromPixel(node.getMx())); + doc->SetAttribute(nod, AttrMy, fromPixel(node.getMy())); if (node.getTypeNode() == NodeDetail::Contour) { doc->SetAttribute(nod, AttrNodeType, NodeTypeContour); diff --git a/src/tools/vtooluniondetails.cpp b/src/tools/vtooluniondetails.cpp index 2c0c44e0b..2d3d8b952 100644 --- a/src/tools/vtooluniondetails.cpp +++ b/src/tools/vtooluniondetails.cpp @@ -657,8 +657,8 @@ void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node QDomElement nod = doc->createElement(TagNode); doc->SetAttribute(nod, AttrIdObject, node.getId()); - doc->SetAttribute(nod, AttrMx, toMM(node.getMx())); - doc->SetAttribute(nod, AttrMy, toMM(node.getMy())); + doc->SetAttribute(nod, AttrMx, fromPixel(node.getMx())); + doc->SetAttribute(nod, AttrMy, fromPixel(node.getMy())); if (node.getTypeNode() == NodeDetail::Contour) { doc->SetAttribute(nod, AttrNodeType, NodeTypeContour);