toPixel and fromPixel with units support - mm, cm, inch.

--HG--
branch : feature
This commit is contained in:
dismine 2014-03-11 17:04:04 +02:00
parent 8f5e01fbb2
commit b2d26e5ae8
27 changed files with 156 additions and 125 deletions

View File

@ -239,7 +239,7 @@ void VContainer::AddLengthSpline(const QString &name, const qreal &value)
void VContainer::AddLengthArc(const quint32 &id)
{
const VArc * arc = GeometricObject<const VArc *>(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<const VPointF *>(firstPointId);
const VPointF *second = GeometricObject<const VPointF *>(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());
}

View File

@ -150,8 +150,8 @@ void DialogDetail::NewItem(quint32 id, const Valentina::Tools &typeTool, const N
this, &DialogDetail::BiasXChanged);
disconnect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
this, &DialogDetail::BiasYChanged);
ui.spinBoxBiasX->setValue(static_cast<qint32>(toMM(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(toMM(node.getMy())));
ui.spinBoxBiasX->setValue(static_cast<qint32>(fromPixel(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(fromPixel(node.getMy())));
connect(ui.spinBoxBiasX, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
this, &DialogDetail::BiasXChanged);
connect(ui.spinBoxBiasY, static_cast<void (QSpinBox::*)(qint32)>(&QSpinBox::valueChanged),
@ -218,8 +218,8 @@ void DialogDetail::ObjectChanged(int row)
}
QListWidgetItem *item = ui.listWidget->item( row );
VNodeDetail node = qvariant_cast<VNodeDetail>(item->data(Qt::UserRole));
ui.spinBoxBiasX->setValue(static_cast<qint32>(toMM(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(toMM(node.getMy())));
ui.spinBoxBiasX->setValue(static_cast<qint32>(fromPixel(node.getMx())));
ui.spinBoxBiasY->setValue(static_cast<qint32>(fromPixel(node.getMy())));
}
void DialogDetail::DeleteItem()

View File

@ -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()

View File

@ -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");

View File

@ -621,8 +621,8 @@ void MainWindow::currentDrawChanged( int index )
void MainWindow::mouseMove(const QPointF &scenePos)
{
QString string = QString("%1, %2")
.arg(static_cast<qint32>(toMM(scenePos.x())))
.arg(static_cast<qint32>(toMM(scenePos.y())));
.arg(static_cast<qint32>(fromPixel(scenePos.x())))
.arg(static_cast<qint32>(fromPixel(scenePos.y())));
mouseCoordinate->setText(string);
}

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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<QGraphicsView*> 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)

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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<QGraphicsView*> 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);

View File

@ -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);