Refactoring. Make class VDetail more independent.
--HG-- branch : feature
This commit is contained in:
parent
8e8422c5fd
commit
0322457ece
|
@ -47,8 +47,8 @@ QSet<const QString> VContainer::uniqueNames = QSet<const QString>();
|
|||
/**
|
||||
* @brief VContainer create empty container
|
||||
*/
|
||||
VContainer::VContainer(const VTranslateVars *trVars)
|
||||
:d(new VContainerData(trVars))
|
||||
VContainer::VContainer(const VTranslateVars *trVars, const Unit *patternUnit)
|
||||
:d(new VContainerData(trVars, patternUnit))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -465,6 +465,12 @@ bool VContainer::IsUnique(const QString &name)
|
|||
return (!uniqueNames.contains(name) && !builInFunctions.contains(name));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const Unit *VContainer::GetPatternUnit() const
|
||||
{
|
||||
return d->patternUnit;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VariableExist check if exist variable this same name.
|
||||
|
|
|
@ -51,15 +51,15 @@ class VContainerData : public QSharedData
|
|||
{
|
||||
public:
|
||||
|
||||
VContainerData(const VTranslateVars *trVars)
|
||||
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit)
|
||||
:sizeName(size_M), heightName(height_M), gObjects(QHash<quint32, QSharedPointer<VGObject> >()),
|
||||
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()), details(QHash<quint32, VDetail>()),
|
||||
trVars(trVars)
|
||||
trVars(trVars), patternUnit(patternUnit)
|
||||
{}
|
||||
|
||||
VContainerData(const VContainerData &data)
|
||||
:QSharedData(data), sizeName(data.sizeName), heightName(data.heightName), gObjects(data.gObjects),
|
||||
variables(data.variables), details(data.details), trVars(data.trVars)
|
||||
variables(data.variables), details(data.details), trVars(data.trVars), patternUnit(data.patternUnit)
|
||||
{}
|
||||
|
||||
virtual ~VContainerData();
|
||||
|
@ -81,6 +81,7 @@ public:
|
|||
QHash<quint32, VDetail> details;
|
||||
|
||||
const VTranslateVars *trVars;
|
||||
const Unit *patternUnit;
|
||||
};
|
||||
|
||||
#ifdef Q_CC_GNU
|
||||
|
@ -94,7 +95,7 @@ class VContainer
|
|||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VContainer)
|
||||
public:
|
||||
VContainer(const VTranslateVars *trVars);
|
||||
VContainer(const VTranslateVars *trVars, const Unit *patternUnit);
|
||||
VContainer &operator=(const VContainer &data);
|
||||
VContainer(const VContainer &data);
|
||||
~VContainer();
|
||||
|
@ -159,6 +160,8 @@ public:
|
|||
|
||||
static bool IsUnique(const QString &name);
|
||||
|
||||
const Unit *GetPatternUnit() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief _id current id. New object will have value +1. For empty class equal 0.
|
||||
|
|
|
@ -143,8 +143,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
const qreal VApplication::PrintDPI = 96.0;
|
||||
|
||||
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||
const QString VApplication::GistFileName = QStringLiteral("gist.json");
|
||||
#endif // defined(Q_OS_WIN) && defined(Q_CC_GNU)
|
||||
|
@ -288,56 +286,6 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
|
|||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
double VApplication::toPixel(double val, const Unit &unit) const
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case Unit::Mm:
|
||||
return (val / 25.4) * PrintDPI;
|
||||
case Unit::Cm:
|
||||
return ((val * 10.0) / 25.4) * PrintDPI;
|
||||
case Unit::Inch:
|
||||
return val * PrintDPI;
|
||||
case Unit::Px:
|
||||
return val;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
double VApplication::toPixel(double val) const
|
||||
{
|
||||
return toPixel(val, _patternUnit);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
double VApplication::fromPixel(double pix, const Unit &unit) const
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case Unit::Mm:
|
||||
return (pix / PrintDPI) * 25.4;
|
||||
case Unit::Cm:
|
||||
return ((pix / PrintDPI) * 25.4) / 10.0;
|
||||
case Unit::Inch:
|
||||
return pix / PrintDPI;
|
||||
case Unit::Px:
|
||||
return pix;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
double VApplication::fromPixel(double pix) const
|
||||
{
|
||||
return fromPixel(pix, _patternUnit);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VApplication::TryLock(QLockFile *lock)
|
||||
|
@ -612,6 +560,18 @@ void VApplication::InitOptions()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
double VApplication::toPixel(double val) const
|
||||
{
|
||||
return ToPixel(val, _patternUnit);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
double VApplication::fromPixel(double pix) const
|
||||
{
|
||||
return FromPixel(pix, _patternUnit);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QWidget *VApplication::getMainWindow() const
|
||||
{
|
||||
|
|
|
@ -62,22 +62,20 @@ public:
|
|||
static void CheckFactor(qreal &oldFactor, const qreal &Newfactor);
|
||||
virtual bool notify(QObject * receiver, QEvent * event);
|
||||
Unit patternUnit() const;
|
||||
const Unit *patternUnitP() const;
|
||||
void setPatternUnit(const Unit &patternUnit);
|
||||
MeasurementsType patternType() const;
|
||||
void setPatternType(const MeasurementsType &patternType);
|
||||
|
||||
void InitOptions();
|
||||
|
||||
double toPixel(double val, const Unit &unit) const;
|
||||
double toPixel(double val) const;
|
||||
double fromPixel(double pix, const Unit &unit) const;
|
||||
double fromPixel(double pix) const;
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
static bool TryLock(QLockFile *lock);
|
||||
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
|
||||
static const qreal PrintDPI;
|
||||
QString translationsPath() const;
|
||||
qreal widthMainLine() const;
|
||||
qreal widthHairLine() const;
|
||||
|
@ -188,6 +186,12 @@ inline Unit VApplication::patternUnit() const
|
|||
return _patternUnit;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline const Unit *VApplication::patternUnitP() const
|
||||
{
|
||||
return &_patternUnit;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline MeasurementsType VApplication::patternType() const
|
||||
{
|
||||
|
|
|
@ -254,8 +254,8 @@ void DialogLayoutSettings::ConvertPaperSize()
|
|||
const qreal width = ui->doubleSpinBoxPaperWidth->value();
|
||||
const qreal height = ui->doubleSpinBoxPaperHeight->value();
|
||||
|
||||
ui->doubleSpinBoxPaperWidth->setMaximum(qApp->fromPixel(QIMAGE_MAX, paperUnit));
|
||||
ui->doubleSpinBoxPaperHeight->setMaximum(qApp->fromPixel(QIMAGE_MAX, paperUnit));
|
||||
ui->doubleSpinBoxPaperWidth->setMaximum(FromPixel(QIMAGE_MAX, paperUnit));
|
||||
ui->doubleSpinBoxPaperHeight->setMaximum(FromPixel(QIMAGE_MAX, paperUnit));
|
||||
|
||||
ui->doubleSpinBoxPaperWidth->setValue(VAbstractMeasurements::UnitConvertor(width, oldPaperUnit, paperUnit));
|
||||
ui->doubleSpinBoxPaperHeight->setValue(VAbstractMeasurements::UnitConvertor(height, oldPaperUnit, paperUnit));
|
||||
|
@ -271,8 +271,8 @@ void DialogLayoutSettings::ConvertLayoutSize()
|
|||
const qreal layoutWidth = ui->doubleSpinBoxLayoutWidth->value();
|
||||
const qreal shift = ui->doubleSpinBoxShift->value();
|
||||
|
||||
ui->doubleSpinBoxLayoutWidth->setMaximum(qApp->fromPixel(QIMAGE_MAX, unit));
|
||||
ui->doubleSpinBoxShift->setMaximum(qApp->fromPixel(QIMAGE_MAX, unit));
|
||||
ui->doubleSpinBoxLayoutWidth->setMaximum(FromPixel(QIMAGE_MAX, unit));
|
||||
ui->doubleSpinBoxShift->setMaximum(FromPixel(QIMAGE_MAX, unit));
|
||||
|
||||
ui->doubleSpinBoxLayoutWidth->setValue(VAbstractMeasurements::UnitConvertor(layoutWidth, oldLayoutUnit, unit));
|
||||
ui->doubleSpinBoxShift->setValue(VAbstractMeasurements::UnitConvertor(shift, oldLayoutUnit, unit));
|
||||
|
@ -389,7 +389,7 @@ void DialogLayoutSettings::InitTemplates()
|
|||
{
|
||||
const QIcon icoPaper("://icon/16x16/template.png");
|
||||
const QIcon icoRoll("://icon/16x16/roll.png");
|
||||
const QString pdi = QString("(%1ppi)").arg(VApplication::PrintDPI);
|
||||
const QString pdi = QString("(%1ppi)").arg(PrintDPI);
|
||||
|
||||
ui->comboBoxTemplates->addItem(icoPaper, "A0 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A0)));
|
||||
ui->comboBoxTemplates->addItem(icoPaper, "A1 "+pdi, QVariant(static_cast<char>(PaperSizeTemplate::A1)));
|
||||
|
@ -582,7 +582,7 @@ void DialogLayoutSettings::Label()
|
|||
Unit::Px));
|
||||
const int height = qFloor(VAbstractMeasurements::UnitConvertor(ui->doubleSpinBoxPaperHeight->value(),
|
||||
PaperUnit(), Unit::Px));
|
||||
QString text = QString("%1 x %2 px, \n%3 ppi").arg(width).arg(height).arg(VApplication::PrintDPI);
|
||||
QString text = QString("%1 x %2 px, \n%3 ppi").arg(width).arg(height).arg(PrintDPI);
|
||||
ui->labelSizeDescription->setText(text);
|
||||
}
|
||||
|
||||
|
@ -645,8 +645,8 @@ void DialogLayoutSettings::WriteSettings() const
|
|||
void DialogLayoutSettings::SheetSize(const QSizeF &size)
|
||||
{
|
||||
oldPaperUnit = PaperUnit();
|
||||
ui->doubleSpinBoxPaperWidth->setMaximum(qApp->fromPixel(QIMAGE_MAX, oldPaperUnit));
|
||||
ui->doubleSpinBoxPaperHeight->setMaximum(qApp->fromPixel(QIMAGE_MAX, oldPaperUnit));
|
||||
ui->doubleSpinBoxPaperWidth->setMaximum(FromPixel(QIMAGE_MAX, oldPaperUnit));
|
||||
ui->doubleSpinBoxPaperHeight->setMaximum(FromPixel(QIMAGE_MAX, oldPaperUnit));
|
||||
|
||||
ui->doubleSpinBoxPaperWidth->setValue(size.width());
|
||||
ui->doubleSpinBoxPaperHeight->setValue(size.height());
|
||||
|
|
|
@ -179,7 +179,7 @@ void DialogCurveIntersectAxis::ShowDialog(bool click)
|
|||
QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
|
||||
|
||||
//Radius of point circle, but little bigger. Need handle with hover sizes.
|
||||
qreal radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
|
||||
qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
|
||||
if (line.length() <= radius)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -278,7 +278,7 @@ void DialogEndLine::ShowDialog(bool click)
|
|||
QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
|
||||
|
||||
//Radius of point circle, but little bigger. Need handle with hover sizes.
|
||||
qreal radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
|
||||
qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
|
||||
if (line.length() <= radius)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -203,7 +203,7 @@ void DialogLineIntersectAxis::ShowDialog(bool click)
|
|||
QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
|
||||
|
||||
//Radius of point circle, but little bigger. Need handle with hover sizes.
|
||||
qreal radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
|
||||
qreal radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm)*1.5;
|
||||
if (line.length() <= radius)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
#include "vdetail.h"
|
||||
#include "vdetail_p.h"
|
||||
#include "../container/vcontainer.h"
|
||||
#include "vpointf.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../libs/vgeometry/vpointf.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
|
@ -428,11 +427,13 @@ QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
|
|||
|
||||
if (getClosed() == true)
|
||||
{
|
||||
pointsEkv = Equidistant(pointsEkv, EquidistantType::CloseEquidistant, qApp->toPixel(getWidth()));
|
||||
pointsEkv = Equidistant(pointsEkv, EquidistantType::CloseEquidistant, ToPixel(getWidth(),
|
||||
*data->GetPatternUnit()));
|
||||
}
|
||||
else
|
||||
{
|
||||
pointsEkv = Equidistant(pointsEkv, EquidistantType::OpenEquidistant, qApp->toPixel(getWidth()));
|
||||
pointsEkv = Equidistant(pointsEkv, EquidistantType::OpenEquidistant, ToPixel(getWidth(),
|
||||
*data->GetPatternUnit()));
|
||||
}
|
||||
return pointsEkv;
|
||||
}
|
||||
|
|
|
@ -57,9 +57,10 @@
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
|
||||
: QMainWindow(parent), listDetails(QVector<VLayoutDetail>()), currentScene(nullptr), tempSceneLayout(nullptr),
|
||||
pattern(new VContainer(qApp->TrVars())), doc(nullptr), papers(QList<QGraphicsItem *>()), shadows(QList<QGraphicsItem *>()),
|
||||
scenes(QList<QGraphicsScene *>()), details(QList<QList<QGraphicsItem *> >()), undoAction(nullptr),
|
||||
redoAction(nullptr), actionDockWidgetToolOptions(nullptr), curFile(QString()), isLayoutStale(true), isTiled(false)
|
||||
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())), doc(nullptr), papers(QList<QGraphicsItem *>()),
|
||||
shadows(QList<QGraphicsItem *>()), scenes(QList<QGraphicsScene *>()), details(QList<QList<QGraphicsItem *> >()),
|
||||
undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), curFile(QString()),
|
||||
isLayoutStale(true), isTiled(false)
|
||||
{
|
||||
InitTempLayoutScene();
|
||||
}
|
||||
|
@ -502,7 +503,7 @@ void MainWindowsNoGUI::SvgFile(const QString &name, int i) const
|
|||
generator.setViewBox(paper->rect());
|
||||
generator.setTitle("Valentina. Pattern layout");
|
||||
generator.setDescription(doc->GetDescription());
|
||||
generator.setResolution(static_cast<int>(qApp->PrintDPI));
|
||||
generator.setResolution(static_cast<int>(PrintDPI));
|
||||
QPainter painter;
|
||||
painter.begin(&generator);
|
||||
painter.setFont( QFont( "Arial", 8, QFont::Normal ) );
|
||||
|
@ -556,7 +557,7 @@ void MainWindowsNoGUI::PdfFile(const QString &name, int i) const
|
|||
printer.setOutputFileName(name);
|
||||
printer.setDocName(FileName());
|
||||
const QRectF r = paper->rect();
|
||||
printer.setResolution(static_cast<int>(qApp->PrintDPI));
|
||||
printer.setResolution(static_cast<int>(PrintDPI));
|
||||
// Set orientation
|
||||
if (paper->rect().height()>= paper->rect().width())
|
||||
{
|
||||
|
@ -566,7 +567,7 @@ void MainWindowsNoGUI::PdfFile(const QString &name, int i) const
|
|||
{
|
||||
printer.setOrientation(QPrinter::Landscape);
|
||||
}
|
||||
printer.setPaperSize ( QSizeF(qApp->fromPixel(r.width(), Unit::Mm), qApp->fromPixel(r.height(), Unit::Mm)),
|
||||
printer.setPaperSize ( QSizeF(FromPixel(r.width(), Unit::Mm), FromPixel(r.height(), Unit::Mm)),
|
||||
QPrinter::Millimeter );
|
||||
QPainter painter;
|
||||
if (painter.begin( &printer ) == false)
|
||||
|
@ -652,7 +653,7 @@ void MainWindowsNoGUI::ObjFile(const QString &name, int i) const
|
|||
VObjPaintDevice generator;
|
||||
generator.setFileName(name);
|
||||
generator.setSize(paper->rect().size().toSize());
|
||||
generator.setResolution(static_cast<int>(qApp->PrintDPI));
|
||||
generator.setResolution(static_cast<int>(PrintDPI));
|
||||
QPainter painter;
|
||||
painter.begin(&generator);
|
||||
scenes.at(i)->render(&painter, paper->rect(), paper->rect(), Qt::IgnoreAspectRatio);
|
||||
|
@ -730,7 +731,7 @@ void MainWindowsNoGUI::SaveLayoutAs()
|
|||
qApp->getSettings()->SetPathLayout(f.absolutePath());
|
||||
|
||||
printer.setOutputFileName(fileName);
|
||||
printer.setResolution(static_cast<int>(VApplication::PrintDPI));
|
||||
printer.setResolution(static_cast<int>(PrintDPI));
|
||||
PrintPages( &printer );
|
||||
}
|
||||
}
|
||||
|
@ -764,7 +765,7 @@ void MainWindowsNoGUI::PrintPreview()
|
|||
}
|
||||
|
||||
QPrinter printer(def, QPrinter::ScreenResolution);
|
||||
printer.setResolution(static_cast<int>(VApplication::PrintDPI));
|
||||
printer.setResolution(static_cast<int>(PrintDPI));
|
||||
SetPrinterSettings(&printer);
|
||||
// display print preview dialog
|
||||
QPrintPreviewDialog preview(&printer);
|
||||
|
@ -790,7 +791,7 @@ void MainWindowsNoGUI::LayoutPrint()
|
|||
dialog.setOption(QPrintDialog::PrintCurrentPage, false);
|
||||
if ( dialog.exec() == QDialog::Accepted )
|
||||
{
|
||||
printer.setResolution(static_cast<int>(VApplication::PrintDPI));
|
||||
printer.setResolution(static_cast<int>(PrintDPI));
|
||||
PrintPages( &printer );
|
||||
}
|
||||
}
|
||||
|
@ -820,8 +821,8 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer)
|
|||
{
|
||||
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(0));
|
||||
SCASSERT(paper != nullptr)
|
||||
printer->setPaperSize ( QSizeF(qApp->fromPixel(paper->rect().width(), Unit::Mm),
|
||||
qApp->fromPixel(paper->rect().height(), Unit::Mm)), QPrinter::Millimeter );
|
||||
printer->setPaperSize ( QSizeF(FromPixel(paper->rect().width(), Unit::Mm),
|
||||
FromPixel(paper->rect().height(), Unit::Mm)), QPrinter::Millimeter );
|
||||
}
|
||||
|
||||
printer->setDocName(FileName());
|
||||
|
|
|
@ -50,7 +50,7 @@ VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsIte
|
|||
:VDrawTool(doc, data, id), QGraphicsEllipseItem(parent), radius(DefPointRadius), namePoint(nullptr),
|
||||
lineName(nullptr)
|
||||
{
|
||||
radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm);
|
||||
radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm);
|
||||
namePoint = new VGraphicsSimpleTextItem(this);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolPoint::contextMenuEvent);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolPoint::DeleteFromLabel);
|
||||
|
@ -279,7 +279,7 @@ void VToolPoint::RefreshLine()
|
|||
lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||
lineName->setPen(QPen(CorrectColor(Qt::black), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
|
||||
if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4, Unit::Mm))
|
||||
if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4, Unit::Mm))
|
||||
{
|
||||
lineName->setVisible(false);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo
|
|||
:VAbstractNode(doc, data, id, idPoint, idTool, qoParent), QGraphicsEllipseItem(parent), radius(0),
|
||||
namePoint(nullptr), lineName(nullptr)
|
||||
{
|
||||
radius = qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm);
|
||||
radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm);
|
||||
namePoint = new VGraphicsSimpleTextItem(this);
|
||||
lineName = new QGraphicsLineItem(this);
|
||||
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
|
||||
|
@ -286,7 +286,7 @@ void VNodePoint::RefreshLine()
|
|||
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2);
|
||||
QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
|
||||
lineName->setLine(QLineF(p1, pRec - scenePos()));
|
||||
if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4, Unit::Mm))
|
||||
if (QLineF(p1, pRec - scenePos()).length() <= ToPixel(4, Unit::Mm))
|
||||
{
|
||||
lineName->setVisible(false);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointP
|
|||
:QGraphicsEllipseItem(parent), radius(0), controlLine(nullptr), indexSpline(indexSpline), position(position)
|
||||
{
|
||||
//create circle
|
||||
radius = (1.5/*mm*/ / 25.4) * VApplication::PrintDPI;
|
||||
radius = (1.5/*mm*/ / 25.4) * PrintDPI;
|
||||
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||
rec.translate(-rec.center().x(), -rec.center().y());
|
||||
this->setRect(rec);
|
||||
|
|
|
@ -110,7 +110,7 @@ QGraphicsEllipseItem *Visualization::InitPoint(const QColor &color, QGraphicsIte
|
|||
point->setZValue(1);
|
||||
point->setBrush(QBrush(Qt::NoBrush));
|
||||
point->setPen(QPen(color, qApp->toPixel(qApp->widthMainLine())/factor));
|
||||
point->setRect(PointRect(qApp->toPixel(DefPointRadius/*mm*/, Unit::Mm)));
|
||||
point->setRect(PointRect(ToPixel(DefPointRadius/*mm*/, Unit::Mm)));
|
||||
point->setFlags(QGraphicsItem::ItemStacksBehindParent);
|
||||
point->setVisible(false);
|
||||
return point;
|
||||
|
|
|
@ -216,7 +216,7 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const
|
|||
case Unit::Inch:
|
||||
return value / 25.4;
|
||||
case Unit::Px:
|
||||
return (value / 25.4) * VApplication::PrintDPI;
|
||||
return (value / 25.4) * PrintDPI;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const
|
|||
case Unit::Inch:
|
||||
return value / 2.54;
|
||||
case Unit::Px:
|
||||
return ((value * 10.0) / 25.4) * VApplication::PrintDPI;
|
||||
return ((value * 10.0) / 25.4) * PrintDPI;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const
|
|||
case Unit::Inch:
|
||||
return value;
|
||||
case Unit::Px:
|
||||
return value * VApplication::PrintDPI;
|
||||
return value * PrintDPI;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -255,11 +255,11 @@ qreal VAbstractMeasurements::UnitConvertor(qreal value, const Unit &from, const
|
|||
switch (to)
|
||||
{
|
||||
case Unit::Mm:
|
||||
return (value / VApplication::PrintDPI) * 25.4;
|
||||
return (value / PrintDPI) * 25.4;
|
||||
case Unit::Cm:
|
||||
return ((value / VApplication::PrintDPI) * 25.4) / 10.0;
|
||||
return ((value / PrintDPI) * 25.4) / 10.0;
|
||||
case Unit::Inch:
|
||||
return value / VApplication::PrintDPI;
|
||||
return value / PrintDPI;
|
||||
case Unit::Px:
|
||||
return value;
|
||||
default:
|
||||
|
|
|
@ -10,4 +10,5 @@ HEADERS += \
|
|||
$$PWD/ifcdef.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/stable.cpp
|
||||
$$PWD/stable.cpp \
|
||||
ifcdef.cpp
|
||||
|
|
31
src/libs/ifc/ifcdef.cpp
Normal file
31
src/libs/ifc/ifcdef.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file ifcdef.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 11 6, 2015
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "ifcdef.h"
|
||||
|
||||
const qreal PrintDPI = 96.0;
|
|
@ -59,4 +59,44 @@ static const quint32 null_id = 0;
|
|||
# define V_NOEXCEPT_EXPR(x)
|
||||
# endif
|
||||
|
||||
extern const qreal PrintDPI;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline double ToPixel(double val, const Unit &unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case Unit::Mm:
|
||||
return (val / 25.4) * PrintDPI;
|
||||
case Unit::Cm:
|
||||
return ((val * 10.0) / 25.4) * PrintDPI;
|
||||
case Unit::Inch:
|
||||
return val * PrintDPI;
|
||||
case Unit::Px:
|
||||
return val;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline double FromPixel(double pix, const Unit &unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case Unit::Mm:
|
||||
return (pix / PrintDPI) * 25.4;
|
||||
case Unit::Cm:
|
||||
return ((pix / PrintDPI) * 25.4) / 10.0;
|
||||
case Unit::Inch:
|
||||
return pix / PrintDPI;
|
||||
case Unit::Px:
|
||||
return pix;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // IFCDEF_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user