Refactoring.
Code style.
This commit is contained in:
parent
c39c5b884e
commit
1e2f1f7708
|
@ -67,7 +67,7 @@ auto CutEdge(const QLineF &edge) -> QVector<QPointF>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int n = qFloor(edge.length()/stickyShift);
|
const int n = qFloor(edge.length() / stickyShift);
|
||||||
|
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
{
|
{
|
||||||
|
@ -77,11 +77,11 @@ auto CutEdge(const QLineF &edge) -> QVector<QPointF>
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
points.reserve(n);
|
points.reserve(n);
|
||||||
const qreal nShift = edge.length()/n;
|
const qreal nShift = edge.length() / n;
|
||||||
for (int i = 1; i <= n+1; ++i)
|
for (int i = 1; i <= n + 1; ++i)
|
||||||
{
|
{
|
||||||
QLineF l1 = edge;
|
QLineF l1 = edge;
|
||||||
l1.setLength(nShift*(i-1));
|
l1.setLength(nShift * (i - 1));
|
||||||
points.append(l1.p2());
|
points.append(l1.p2());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,9 +99,9 @@ auto PrepareStickyPath(const QVector<QPointF> &path) -> QVector<QPointF>
|
||||||
|
|
||||||
QVector<QPointF> stickyPath;
|
QVector<QPointF> stickyPath;
|
||||||
|
|
||||||
for (int i=0; i<path.size(); ++i)
|
for (int i = 0; i < path.size(); ++i)
|
||||||
{
|
{
|
||||||
stickyPath += CutEdge(QLineF(path.at(i), path.at(i < path.size()-1 ? i+1 : 0)));
|
stickyPath += CutEdge(QLineF(path.at(i), path.at(i < path.size() - 1 ? i + 1 : 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return stickyPath;
|
return stickyPath;
|
||||||
|
@ -375,14 +375,14 @@ auto VPPiece::StickyPosition(qreal &dx, qreal &dy) const -> bool
|
||||||
QVector<QPointF> path;
|
QVector<QPointF> path;
|
||||||
CastTo(GetMappedExternalContourPoints(), path);
|
CastTo(GetMappedExternalContourPoints(), path);
|
||||||
QRectF boundingRect = VLayoutPiece::BoundingRect(path);
|
QRectF boundingRect = VLayoutPiece::BoundingRect(path);
|
||||||
const qreal stickyDistance = pieceGap+minStickyDistance;
|
const qreal stickyDistance = pieceGap + minStickyDistance;
|
||||||
QRectF stickyZone = QRectF(boundingRect.topLeft().x()-stickyDistance, boundingRect.topLeft().y()-stickyDistance,
|
QRectF stickyZone = QRectF(boundingRect.topLeft().x() - stickyDistance, boundingRect.topLeft().y() - stickyDistance,
|
||||||
boundingRect.width()+stickyDistance*2, boundingRect.height()+stickyDistance*2);
|
boundingRect.width() + stickyDistance * 2, boundingRect.height() + stickyDistance * 2);
|
||||||
|
|
||||||
QVector<QPointF> stickyPath = PrepareStickyPath(path);
|
QVector<QPointF> stickyPath = PrepareStickyPath(path);
|
||||||
QLineF closestDistance;
|
QLineF closestDistance;
|
||||||
|
|
||||||
for (const auto& piece : allPieces)
|
for (const auto &piece : allPieces)
|
||||||
{
|
{
|
||||||
if (piece.isNull() || piece->GetUniqueID() == GetUniqueID())
|
if (piece.isNull() || piece->GetUniqueID() == GetUniqueID())
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,13 +28,13 @@
|
||||||
#ifndef VPPIECE_H
|
#ifndef VPPIECE_H
|
||||||
#define VPPIECE_H
|
#define VPPIECE_H
|
||||||
|
|
||||||
#include <QUuid>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
#include "../vlayout/vlayoutpiece.h"
|
|
||||||
#include "../layout/layoutdef.h"
|
#include "../layout/layoutdef.h"
|
||||||
|
#include "../vlayout/vlayoutpiece.h"
|
||||||
#include "vpiecegrainline.h"
|
#include "vpiecegrainline.h"
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||||
|
@ -47,6 +47,7 @@ class VPSheet;
|
||||||
class VPPiece : public VLayoutPiece
|
class VPPiece : public VLayoutPiece
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(VPPiece) // NOLINT
|
Q_DECLARE_TR_FUNCTIONS(VPPiece) // NOLINT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VPPiece() = default;
|
VPPiece() = default;
|
||||||
explicit VPPiece(const VLayoutPiece &layoutPiece);
|
explicit VPPiece(const VLayoutPiece &layoutPiece);
|
||||||
|
|
|
@ -497,7 +497,7 @@ void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails)
|
||||||
QString::number(i + 1) +
|
QString::number(i + 1) +
|
||||||
VLayoutExporter::ExportFormatSuffix(m_dialogSaveLayout->Format());
|
VLayoutExporter::ExportFormatSuffix(m_dialogSaveLayout->Format());
|
||||||
|
|
||||||
QGraphicsRectItem *paper =
|
auto *paper =
|
||||||
qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutSettings->LayoutPapers().at(i));
|
qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutSettings->LayoutPapers().at(i));
|
||||||
SCASSERT(paper != nullptr)
|
SCASSERT(paper != nullptr)
|
||||||
|
|
||||||
|
|
|
@ -104,16 +104,11 @@ QT_WARNING_POP
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto PieceOutline(const VLayoutPiece &detail) -> QVector<VLayoutPoint>
|
auto PieceOutline(const VLayoutPiece &detail) -> QVector<VLayoutPoint>
|
||||||
{
|
{
|
||||||
QVector<VLayoutPoint> outline;
|
|
||||||
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
|
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
|
||||||
{
|
{
|
||||||
outline = detail.GetMappedSeamAllowancePoints();
|
return detail.GetMappedSeamAllowancePoints();
|
||||||
}
|
}
|
||||||
else
|
return detail.GetMappedContourPoints();
|
||||||
{
|
|
||||||
outline = detail.GetMappedContourPoints();
|
|
||||||
}
|
|
||||||
return outline;
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,9 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
#include "vwatermark.h"
|
#include "vwatermark.h"
|
||||||
|
|
||||||
#include "../vmisc/projectversion.h"
|
|
||||||
#include "../ifc/xml/vwatermarkconverter.h"
|
#include "../ifc/xml/vwatermarkconverter.h"
|
||||||
|
#include "../vmisc/compatibility.h"
|
||||||
|
#include "../vmisc/projectversion.h"
|
||||||
|
|
||||||
const QString VWatermark::TagWatermark = QStringLiteral("watermark");
|
const QString VWatermark::TagWatermark = QStringLiteral("watermark");
|
||||||
const QString VWatermark::TagText = QStringLiteral("text");
|
const QString VWatermark::TagText = QStringLiteral("text");
|
||||||
|
@ -46,14 +47,14 @@ namespace
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto FileComment() -> QString
|
auto FileComment() -> QString
|
||||||
{
|
{
|
||||||
return QString("Watermark created with Valentina v%1 (https://smart-pattern.com.ua/).")
|
return QString("Watermark created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR);
|
||||||
.arg(APP_VERSION_STR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VWatermark::VWatermark()
|
VWatermark::VWatermark()
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VWatermark::CreateEmptyWatermark()
|
void VWatermark::CreateEmptyWatermark()
|
||||||
|
@ -67,8 +68,9 @@ void VWatermark::CreateEmptyWatermark()
|
||||||
wElement.appendChild(createElement(TagImage));
|
wElement.appendChild(createElement(TagImage));
|
||||||
|
|
||||||
appendChild(wElement);
|
appendChild(wElement);
|
||||||
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
|
insertBefore(
|
||||||
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild());
|
createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")),
|
||||||
|
this->firstChild());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -138,11 +140,11 @@ void VWatermark::SetWatermark(const VWatermarkData &data)
|
||||||
{
|
{
|
||||||
SetAttribute(text, AttrShow, data.showText);
|
SetAttribute(text, AttrShow, data.showText);
|
||||||
SetAttributeOrRemoveIf<QString>(text, AttrText, data.text,
|
SetAttributeOrRemoveIf<QString>(text, AttrText, data.text,
|
||||||
[](const QString &text) noexcept {return text.isEmpty();});
|
[](const QString &text) noexcept { return text.isEmpty(); });
|
||||||
SetAttributeOrRemoveIf<int>(text, AttrRotation, data.textRotation,
|
SetAttributeOrRemoveIf<int>(text, AttrRotation, data.textRotation,
|
||||||
[](int textRotation) noexcept {return textRotation == 0;});
|
[](int textRotation) noexcept { return textRotation == 0; });
|
||||||
SetAttributeOrRemoveIf<QString>(text, AttrFont, data.font.toString(),
|
SetAttributeOrRemoveIf<QString>(text, AttrFont, data.font.toString(),
|
||||||
[](const QString &fontString) noexcept {return fontString.isEmpty();});
|
[](const QString &fontString) noexcept { return fontString.isEmpty(); });
|
||||||
SetAttribute(text, AttrColor, data.textColor.name());
|
SetAttribute(text, AttrColor, data.textColor.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,11 +153,11 @@ void VWatermark::SetWatermark(const VWatermarkData &data)
|
||||||
{
|
{
|
||||||
SetAttribute(image, AttrShow, data.showImage);
|
SetAttribute(image, AttrShow, data.showImage);
|
||||||
SetAttributeOrRemoveIf<QString>(image, AttrPath, data.path,
|
SetAttributeOrRemoveIf<QString>(image, AttrPath, data.path,
|
||||||
[](const QString &path) noexcept {return path.isEmpty();});
|
[](const QString &path) noexcept { return path.isEmpty(); });
|
||||||
SetAttributeOrRemoveIf<int>(image, AttrRotation, data.imageRotation,
|
SetAttributeOrRemoveIf<int>(image, AttrRotation, data.imageRotation,
|
||||||
[](int imageRotation) noexcept {return imageRotation == 0;});
|
[](int imageRotation) noexcept { return imageRotation == 0; });
|
||||||
SetAttributeOrRemoveIf<bool>(image, AttrGrayscale, data.grayscale,
|
SetAttributeOrRemoveIf<bool>(image, AttrGrayscale, data.grayscale,
|
||||||
[](bool grayscale) noexcept {return not grayscale;});
|
[](bool grayscale) noexcept { return not grayscale; });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStringLiteral>
|
#include <QString>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
|
@ -37,10 +37,11 @@
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
|
||||||
#include "../vmisc/compatibility.h"
|
#include "../vmisc/compatibility.h"
|
||||||
#include "vgobject_p.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
#include "vgeometry/vgeometrydef.h"
|
||||||
|
#include "vgobject_p.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -89,8 +90,9 @@ auto GetEpsilon(const QPointF &t, QPointF p1, QPointF p2, qreal accuracy) -> dou
|
||||||
* @brief VGObject default constructor.
|
* @brief VGObject default constructor.
|
||||||
*/
|
*/
|
||||||
VGObject::VGObject()
|
VGObject::VGObject()
|
||||||
:d(new VGObjectData)
|
: d(new VGObjectData)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -100,8 +102,9 @@ VGObject::VGObject()
|
||||||
* @param mode mode creation. Used in modeling mode.
|
* @param mode mode creation. Used in modeling mode.
|
||||||
*/
|
*/
|
||||||
VGObject::VGObject(const GOType &type, const quint32 &idObject, const Draw &mode)
|
VGObject::VGObject(const GOType &type, const quint32 &idObject, const Draw &mode)
|
||||||
:d(new VGObjectData(type, idObject, mode))
|
: d(new VGObjectData(type, idObject, mode))
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -109,8 +112,9 @@ VGObject::VGObject(const GOType &type, const quint32 &idObject, const Draw &mode
|
||||||
* @param obj object.
|
* @param obj object.
|
||||||
*/
|
*/
|
||||||
VGObject::VGObject(const VGObject &obj) // NOLINT(modernize-use-equals-default)
|
VGObject::VGObject(const VGObject &obj) // NOLINT(modernize-use-equals-default)
|
||||||
:d (obj.d)
|
: d(obj.d)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -120,7 +124,7 @@ VGObject::VGObject(const VGObject &obj) // NOLINT(modernize-use-equals-default)
|
||||||
*/
|
*/
|
||||||
auto VGObject::operator=(const VGObject &obj) -> VGObject &
|
auto VGObject::operator=(const VGObject &obj) -> VGObject &
|
||||||
{
|
{
|
||||||
if ( &obj == this )
|
if (&obj == this)
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -130,12 +134,13 @@ auto VGObject::operator=(const VGObject &obj) -> VGObject &
|
||||||
|
|
||||||
#ifdef Q_COMPILER_RVALUE_REFS
|
#ifdef Q_COMPILER_RVALUE_REFS
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VGObject::VGObject(VGObject &&obj) Q_DECL_NOTHROW
|
VGObject::VGObject(VGObject &&obj) noexcept
|
||||||
:d (std::move(obj.d))
|
: d(std::move(obj.d))
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VGObject::operator=(VGObject &&obj) Q_DECL_NOTHROW -> VGObject &
|
auto VGObject::operator=(VGObject &&obj) noexcept -> VGObject &
|
||||||
{
|
{
|
||||||
std::swap(d, obj.d);
|
std::swap(d, obj.d);
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -144,7 +149,8 @@ auto VGObject::operator=(VGObject &&obj) Q_DECL_NOTHROW -> VGObject &
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VGObject::~VGObject() // NOLINT(modernize-use-equals-default)
|
VGObject::~VGObject() // NOLINT(modernize-use-equals-default)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -293,8 +299,7 @@ auto VGObject::getIdTool() const -> quint32
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VGObject::ToJson() const -> QJsonObject
|
auto VGObject::ToJson() const -> QJsonObject
|
||||||
{
|
{
|
||||||
QJsonObject object
|
QJsonObject object{
|
||||||
{
|
|
||||||
{"id", static_cast<qint64>(id())},
|
{"id", static_cast<qint64>(id())},
|
||||||
{"type", static_cast<int>(getType())},
|
{"type", static_cast<int>(getType())},
|
||||||
};
|
};
|
||||||
|
@ -307,7 +312,7 @@ auto VGObject::BuildLine(const QPointF &p1, const qreal &length, const qreal &an
|
||||||
{
|
{
|
||||||
QLineF line = QLineF();
|
QLineF line = QLineF();
|
||||||
line.setP1(p1);
|
line.setP1(p1);
|
||||||
line.setAngle(angle);// First set angle then length. Length can have negative value.
|
line.setAngle(angle); // First set angle then length. Length can have negative value.
|
||||||
line.setLength(length);
|
line.setLength(length);
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +329,8 @@ auto VGObject::BuildRay(const QPointF &firstPoint, const qreal &angle, const QRe
|
||||||
if (not rect.contains(firstPoint))
|
if (not rect.contains(firstPoint))
|
||||||
{
|
{
|
||||||
// If point outside of scene rect create one around point and unite two rects.
|
// If point outside of scene rect create one around point and unite two rects.
|
||||||
QRectF rectangle(firstPoint.x()-rect.width()/2, firstPoint.y()-rect.height()/2, rect.width(), rect.height());
|
QRectF rectangle(firstPoint.x() - rect.width() / 2, firstPoint.y() - rect.height() / 2, rect.width(),
|
||||||
|
rect.height());
|
||||||
rect = rect.united(rectangle);
|
rect = rect.united(rectangle);
|
||||||
}
|
}
|
||||||
const qreal diagonal = qSqrt(pow(rect.height(), 2) + pow(rect.width(), 2));
|
const qreal diagonal = qSqrt(pow(rect.height(), 2) + pow(rect.width(), 2));
|
||||||
|
@ -336,7 +342,7 @@ auto VGObject::BuildRay(const QPointF &firstPoint, const qreal &angle, const QRe
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VGObject::BuildAxis(const QPointF &p, const qreal &angle, const QRectF &scRect) -> QLineF
|
auto VGObject::BuildAxis(const QPointF &p, const qreal &angle, const QRectF &scRect) -> QLineF
|
||||||
{
|
{
|
||||||
const QPointF endP1 = BuildRay(p, angle+180, scRect);
|
const QPointF endP1 = BuildRay(p, angle + 180, scRect);
|
||||||
const QPointF endP2 = BuildRay(p, angle, scRect);
|
const QPointF endP2 = BuildRay(p, angle, scRect);
|
||||||
return {endP1, endP2};
|
return {endP1, endP2};
|
||||||
}
|
}
|
||||||
|
@ -363,8 +369,8 @@ auto VGObject::ContactPoints(const QPointF &p, const QPointF ¢er, qreal radi
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double d = QLineF (p, center).length();
|
const double d = QLineF(p, center).length();
|
||||||
const double k = sqrt (d * d - radius * radius);
|
const double k = sqrt(d * d - radius * radius);
|
||||||
return IntersectionCircles(p, k, center, radius, p1, p2);
|
return IntersectionCircles(p, k, center, radius, p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,28 +388,28 @@ auto VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line) -> QPoin
|
||||||
QPointF point;
|
QPointF point;
|
||||||
QLineF::IntersectType type = Intersects(line, QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point);
|
QLineF::IntersectType type = Intersects(line, QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point);
|
||||||
|
|
||||||
if ( type == QLineF::BoundedIntersection )
|
if (type == QLineF::BoundedIntersection)
|
||||||
{
|
{
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = Intersects(line, QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point);
|
type = Intersects(line, QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point);
|
||||||
|
|
||||||
if ( type == QLineF::BoundedIntersection )
|
if (type == QLineF::BoundedIntersection)
|
||||||
{
|
{
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = Intersects(line, QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point);
|
type = Intersects(line, QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point);
|
||||||
|
|
||||||
if ( type == QLineF::BoundedIntersection )
|
if (type == QLineF::BoundedIntersection)
|
||||||
{
|
{
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = Intersects(line, QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point);
|
type = Intersects(line, QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point);
|
||||||
|
|
||||||
if ( type == QLineF::BoundedIntersection )
|
if (type == QLineF::BoundedIntersection)
|
||||||
{
|
{
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
@ -411,33 +417,34 @@ auto VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line) -> QPoin
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VGObject::IntersectionCircles(const QPointF &c1, double r1, const QPointF &c2, double r2, QPointF &p1, QPointF &p2) -> int
|
auto VGObject::IntersectionCircles(const QPointF &c1, double r1, const QPointF &c2, double r2, QPointF &p1, QPointF &p2)
|
||||||
|
-> int
|
||||||
{
|
{
|
||||||
if (VFuzzyComparePossibleNulls(c1.x(), c2.x()) && VFuzzyComparePossibleNulls(c1.y(), c2.y())
|
if (VFuzzyComparePossibleNulls(c1.x(), c2.x()) && VFuzzyComparePossibleNulls(c1.y(), c2.y()) &&
|
||||||
&& VFuzzyComparePossibleNulls(r1, r2))
|
VFuzzyComparePossibleNulls(r1, r2))
|
||||||
{
|
{
|
||||||
return 3;// Circles are equal
|
return 3; // Circles are equal
|
||||||
}
|
}
|
||||||
const double a = - 2.0 * (c2.x() - c1.x());
|
const double a = -2.0 * (c2.x() - c1.x());
|
||||||
const double b = - 2.0 * (c2.y() - c1.y());
|
const double b = -2.0 * (c2.y() - c1.y());
|
||||||
const double c = (c2.x() - c1.x())* (c2.x() - c1.x()) + (c2.y() - c1.y()) * (c2.y() - c1.y()) + r1 * r1 - r2 * r2;
|
const double c = (c2.x() - c1.x()) * (c2.x() - c1.x()) + (c2.y() - c1.y()) * (c2.y() - c1.y()) + r1 * r1 - r2 * r2;
|
||||||
|
|
||||||
const double x0 = -a*c/(a*a+b*b);
|
const double x0 = -a * c / (a * a + b * b);
|
||||||
const double y0 = -b*c/(a*a+b*b);
|
const double y0 = -b * c / (a * a + b * b);
|
||||||
|
|
||||||
if (c*c > r1*r1*(a*a+b*b))
|
if (c * c > r1 * r1 * (a * a + b * b))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VFuzzyComparePossibleNulls(c*c, r1*r1*(a*a+b*b)))
|
if (VFuzzyComparePossibleNulls(c * c, r1 * r1 * (a * a + b * b)))
|
||||||
{
|
{
|
||||||
p1 = QPointF(x0 + c1.x(), y0 + c1.y());
|
p1 = QPointF(x0 + c1.x(), y0 + c1.y());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double d = r1*r1 - c*c/(a*a+b*b);
|
const double d = r1 * r1 - c * c / (a * a + b * b);
|
||||||
const double mult = sqrt (d / (a*a+b*b));
|
const double mult = sqrt(d / (a * a + b * b));
|
||||||
|
|
||||||
const double ax = x0 + b * mult;
|
const double ax = x0 + b * mult;
|
||||||
const double bx = x0 - b * mult;
|
const double bx = x0 - b * mult;
|
||||||
|
@ -459,8 +466,8 @@ auto VGObject::IntersectionCircles(const QPointF &c1, double r1, const QPointF &
|
||||||
* @param p2 second intersection point.
|
* @param p2 second intersection point.
|
||||||
* @return 0 - intersection doesn't exist, 1 - one intersection point, 2 - two intersection points.
|
* @return 0 - intersection doesn't exist, 1 - one intersection point, 2 - two intersection points.
|
||||||
*/
|
*/
|
||||||
auto VGObject::LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1,
|
auto VGObject::LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, QPointF &p2)
|
||||||
QPointF &p2) -> qint32
|
-> qint32
|
||||||
{
|
{
|
||||||
// Fix for issue #485. https://bitbucket.org/dismine/valentina/issues/485/error-when-drawing-a-curved-path
|
// Fix for issue #485. https://bitbucket.org/dismine/valentina/issues/485/error-when-drawing-a-curved-path
|
||||||
if (qFuzzyIsNull(line.length()))
|
if (qFuzzyIsNull(line.length()))
|
||||||
|
@ -468,14 +475,14 @@ auto VGObject::LineIntersectCircle(const QPointF ¢er, qreal radius, const QL
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//coefficient for equation of segment
|
// coefficient for equation of segment
|
||||||
qreal a = 0, b = 0, c = 0;
|
qreal a = 0, b = 0, c = 0;
|
||||||
LineCoefficients(line, &a, &b, &c);
|
LineCoefficients(line, &a, &b, &c);
|
||||||
// projection center of circle on to line
|
// projection center of circle on to line
|
||||||
const QPointF p = ClosestPoint (line, center);
|
const QPointF p = ClosestPoint(line, center);
|
||||||
// how many solutions?
|
// how many solutions?
|
||||||
qint32 flag = 0;
|
qint32 flag = 0;
|
||||||
const qreal d = QLineF (center, p).length();
|
const qreal d = QLineF(center, p).length();
|
||||||
if (VFuzzyComparePossibleNulls(d, radius))
|
if (VFuzzyComparePossibleNulls(d, radius))
|
||||||
{
|
{
|
||||||
flag = 1;
|
flag = 1;
|
||||||
|
@ -492,11 +499,11 @@ auto VGObject::LineIntersectCircle(const QPointF ¢er, qreal radius, const QL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// find distance from projection to points of intersection
|
// find distance from projection to points of intersection
|
||||||
const qreal k = qSqrt (qAbs(radius * radius - d * d));
|
const qreal k = qSqrt(qAbs(radius * radius - d * d));
|
||||||
const qreal t = QLineF (QPointF (0, 0), QPointF (b, - a)).length();
|
const qreal t = QLineF(QPointF(0, 0), QPointF(b, -a)).length();
|
||||||
// add to projection a vectors aimed to points of intersection
|
// add to projection a vectors aimed to points of intersection
|
||||||
p1 = addVector (p, QPointF (0, 0), QPointF (- b, a), k / t);
|
p1 = addVector(p, QPointF(0, 0), QPointF(-b, a), k / t);
|
||||||
p2 = addVector (p, QPointF (0, 0), QPointF (b, - a), k / t);
|
p2 = addVector(p, QPointF(0, 0), QPointF(b, -a), k / t);
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +519,7 @@ auto VGObject::ClosestPoint(const QLineF &line, const QPointF &point) -> QPointF
|
||||||
LineCoefficients(line, &a, &b, &c);
|
LineCoefficients(line, &a, &b, &c);
|
||||||
qreal x = point.x() + a;
|
qreal x = point.x() + a;
|
||||||
qreal y = b + point.y();
|
qreal y = b + point.y();
|
||||||
QLineF lin (point, QPointF(x, y));
|
QLineF lin(point, QPointF(x, y));
|
||||||
QPointF p;
|
QPointF p;
|
||||||
QLineF::IntersectType intersect = Intersects(line, lin, &p);
|
QLineF::IntersectType intersect = Intersects(line, lin, &p);
|
||||||
|
|
||||||
|
@ -540,11 +547,11 @@ auto VGObject::addVector(const QPointF &p, const QPointF &p1, const QPointF &p2,
|
||||||
*/
|
*/
|
||||||
void VGObject::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c)
|
void VGObject::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c)
|
||||||
{
|
{
|
||||||
//coefficient for equation of segment
|
// coefficient for equation of segment
|
||||||
QPointF p1 = line.p1();
|
QPointF p1 = line.p1();
|
||||||
*a = line.p2().y() - p1.y();
|
*a = line.p2().y() - p1.y();
|
||||||
*b = p1.x() - line.p2().x();
|
*b = p1.x() - line.p2().x();
|
||||||
*c = - *a * p1.x() - *b * p1.y();
|
*c = -*a * p1.x() - *b * p1.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -572,33 +579,33 @@ auto VGObject::IsPointOnLineSegment(const QPointF &t, const QPointF &p1, const Q
|
||||||
// should be good enough for us.
|
// should be good enough for us.
|
||||||
const qreal degrees = 90;
|
const qreal degrees = 90;
|
||||||
QLineF edge(p1, p2);
|
QLineF edge(p1, p2);
|
||||||
edge.setAngle(edge.angle()+degrees);
|
edge.setAngle(edge.angle() + degrees);
|
||||||
edge.setLength(accuracy);
|
edge.setLength(accuracy);
|
||||||
QPointF sP1 = edge.p2();
|
QPointF sP1 = edge.p2();
|
||||||
|
|
||||||
edge = QLineF(p2, p1);
|
edge = QLineF(p2, p1);
|
||||||
edge.setAngle(edge.angle()-degrees);
|
edge.setAngle(edge.angle() - degrees);
|
||||||
edge.setLength(accuracy);
|
edge.setLength(accuracy);
|
||||||
QPointF sP2 = edge.p2();
|
QPointF sP2 = edge.p2();
|
||||||
|
|
||||||
edge = QLineF(p2, p1);
|
edge = QLineF(p2, p1);
|
||||||
edge.setAngle(edge.angle()+degrees);
|
edge.setAngle(edge.angle() + degrees);
|
||||||
edge.setLength(accuracy);
|
edge.setLength(accuracy);
|
||||||
QPointF sP3 = edge.p2();
|
QPointF sP3 = edge.p2();
|
||||||
|
|
||||||
edge = QLineF(p1, p2);
|
edge = QLineF(p1, p2);
|
||||||
edge.setAngle(edge.angle()-degrees);
|
edge.setAngle(edge.angle() - degrees);
|
||||||
edge.setLength(accuracy);
|
edge.setLength(accuracy);
|
||||||
QPointF sP4 = edge.p2();
|
QPointF sP4 = edge.p2();
|
||||||
|
|
||||||
QVector<QPointF> shape{sP1, sP2, sP3, sP4, sP1};
|
QVector<QPointF> shape{sP1, sP2, sP3, sP4, sP1};
|
||||||
|
|
||||||
for (int i=0; i < shape.size()-1; ++i)
|
for (int i = 0; i < shape.size() - 1; ++i)
|
||||||
{
|
{
|
||||||
const QPointF &sp1 = shape.at(i);
|
const QPointF &sp1 = shape.at(i);
|
||||||
const QPointF &sp2 = shape.at(i+1);
|
const QPointF &sp2 = shape.at(i + 1);
|
||||||
// This formula helps to determine on which side of a vector lies a point.
|
// This formula helps to determine on which side of a vector lies a point.
|
||||||
qreal position = (sp2.x()-sp1.x())*(t.y()-sp1.y())-(sp2.y()-sp1.y())*(t.x()-sp1.x());
|
qreal position = (sp2.x() - sp1.x()) * (t.y() - sp1.y()) - (sp2.y() - sp1.y()) * (t.x() - sp1.x());
|
||||||
if (position < 0)
|
if (position < 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -654,7 +661,7 @@ auto VGObject::IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QP
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VGObject::PointInCircle(const QPointF &p, const QPointF ¢er, qreal radius) -> int
|
auto VGObject::PointInCircle(const QPointF &p, const QPointF ¢er, qreal radius) -> int
|
||||||
{
|
{
|
||||||
const double d = QLineF (p, center).length();
|
const double d = QLineF(p, center).length();
|
||||||
if (VFuzzyComparePossibleNulls(radius, d))
|
if (VFuzzyComparePossibleNulls(radius, d))
|
||||||
{
|
{
|
||||||
return 1; // on circle
|
return 1; // on circle
|
||||||
|
@ -681,9 +688,9 @@ auto VGObject::GetLengthContour(const QVector<QPointF> &contour, const QVector<Q
|
||||||
qreal length = 0;
|
qreal length = 0;
|
||||||
QVector<QPointF> points;
|
QVector<QPointF> points;
|
||||||
points << contour << newPoints;
|
points << contour << newPoints;
|
||||||
for (qint32 i = 0; i < points.size()-1; ++i)
|
for (qint32 i = 0; i < points.size() - 1; ++i)
|
||||||
{
|
{
|
||||||
QLineF line(points.at(i), points.at(i+1));
|
QLineF line(points.at(i), points.at(i + 1));
|
||||||
length += line.length();
|
length += line.length();
|
||||||
}
|
}
|
||||||
return qFloor(length);
|
return qFloor(length);
|
||||||
|
@ -712,13 +719,13 @@ auto VGObject::FlippingMatrix(const QLineF &axis) -> QTransform
|
||||||
|
|
||||||
m.reset();
|
m.reset();
|
||||||
m.translate(p2.x(), p2.y());
|
m.translate(p2.x(), p2.y());
|
||||||
m.scale(m.m11(), m.m22()*-1);
|
m.scale(m.m11(), m.m22() * -1);
|
||||||
m.translate(-p2.x(), -p2.y());
|
m.translate(-p2.x(), -p2.y());
|
||||||
matrix *= m;
|
matrix *= m;
|
||||||
|
|
||||||
m.reset();
|
m.reset();
|
||||||
m.translate(p2.x(), p2.y());
|
m.translate(p2.x(), p2.y());
|
||||||
m.rotate(-(360-angle));
|
m.rotate(-(360 - angle));
|
||||||
m.translate(-p2.x(), -p2.y());
|
m.translate(-p2.x(), -p2.y());
|
||||||
matrix *= m;
|
matrix *= m;
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
#ifndef VLAYOUTDEF_H
|
#ifndef VLAYOUTDEF_H
|
||||||
#define VLAYOUTDEF_H
|
#define VLAYOUTDEF_H
|
||||||
|
|
||||||
|
#include <QPainterPath>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
#include <QPainterPath>
|
|
||||||
#include <ciso646>
|
#include <ciso646>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
|
||||||
|
@ -100,28 +100,34 @@ struct VCachedPositions
|
||||||
QPainterPath layoutAllowancePath{};
|
QPainterPath layoutAllowancePath{};
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Cases : qint8 { CaseThreeGroup = 0, CaseTwoGroup, CaseDesc, UnknownCase};
|
enum class Cases : qint8
|
||||||
|
{
|
||||||
|
CaseThreeGroup = 0,
|
||||||
|
CaseTwoGroup,
|
||||||
|
CaseDesc,
|
||||||
|
UnknownCase
|
||||||
|
};
|
||||||
|
|
||||||
/* Warning! Debugging doesn't work stable in debug mode. If you need big allocation use release mode. Or disable
|
/* Warning! Debugging doesn't work stable in debug mode. If you need big allocation use release mode. Or disable
|
||||||
* Address Sanitizer. See page https://bitbucket.org/dismine/valentina/wiki/developers/Address_Sanitizer
|
* Address Sanitizer. See page https://bitbucket.org/dismine/valentina/wiki/developers/Address_Sanitizer
|
||||||
*/
|
*/
|
||||||
//#define LAYOUT_DEBUG // Enable debug mode
|
// #define LAYOUT_DEBUG // Enable debug mode
|
||||||
|
|
||||||
// This block help rule debug mode. Don't turn all options at the same time!
|
// This block help rule debug mode. Don't turn all options at the same time!
|
||||||
#ifdef LAYOUT_DEBUG
|
#ifdef LAYOUT_DEBUG
|
||||||
// Nice looking
|
// Nice looking
|
||||||
# define SHOW_VERTICES // Show contour vertices
|
#define SHOW_VERTICES // Show contour vertices
|
||||||
# define SHOW_DIRECTION // Show contour direction
|
#define SHOW_DIRECTION // Show contour direction
|
||||||
# define ARRANGED_DETAILS // Show already arranged details
|
#define ARRANGED_DETAILS // Show already arranged details
|
||||||
# define SHOW_SHEET // Show sheet rect
|
#define SHOW_SHEET // Show sheet rect
|
||||||
# define SHOW_CANDIDATE // Show each position
|
#define SHOW_CANDIDATE // Show each position
|
||||||
|
|
||||||
// Debugging
|
// Debugging
|
||||||
//# define SHOW_ROTATION // For each position show rotation part
|
// # define SHOW_ROTATION // For each position show rotation part
|
||||||
//# define SHOW_COMBINE // For each position show edge combine part
|
// # define SHOW_COMBINE // For each position show edge combine part
|
||||||
//# define SHOW_MIRROR // For each position show mirror part
|
// # define SHOW_MIRROR // For each position show mirror part
|
||||||
//# define SHOW_CANDIDATE_BEST // For only correct positions that pass checks
|
// # define SHOW_CANDIDATE_BEST // For only correct positions that pass checks
|
||||||
# define SHOW_BEST // Show only best position for workpiece
|
#define SHOW_BEST // Show only best position for workpiece
|
||||||
#endif//LAYOUT_DEBUG
|
#endif // LAYOUT_DEBUG
|
||||||
|
|
||||||
#endif // VLAYOUTDEF_H
|
#endif // VLAYOUTDEF_H
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QGraphicsPathItem>
|
#include <QGraphicsPathItem>
|
||||||
|
#include <QLine>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMessageLogger>
|
#include <QMessageLogger>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
@ -46,6 +47,8 @@
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
|
#include "../vformat/vsinglelineoutlinechar.h"
|
||||||
|
#include "../vgeometry/vgobject.h"
|
||||||
#include "../vgeometry/vlayoutplacelabel.h"
|
#include "../vgeometry/vlayoutplacelabel.h"
|
||||||
#include "../vgeometry/vplacelabelitem.h"
|
#include "../vgeometry/vplacelabelitem.h"
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
|
@ -62,15 +65,10 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vpatterndb/vpassmark.h"
|
#include "../vpatterndb/vpassmark.h"
|
||||||
#include "../vpatterndb/vpiecenode.h"
|
#include "../vpatterndb/vpiecenode.h"
|
||||||
#include "../vwidgets/global.h"
|
#include "../vwidgets/vpiecegrainline.h"
|
||||||
#include "vgobject.h"
|
|
||||||
#include "vgraphicsfillitem.h"
|
#include "vgraphicsfillitem.h"
|
||||||
#include "vlayoutpiece_p.h"
|
#include "vlayoutpiece_p.h"
|
||||||
#include "vpiecegrainline.h"
|
|
||||||
#include "vsinglelineoutlinechar.h"
|
|
||||||
#include "vtextmanager.h"
|
#include "vtextmanager.h"
|
||||||
#include <QLine>
|
|
||||||
#include <QPainterPath>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -773,7 +771,7 @@ auto VLayoutPiece::Map(const GrainlineShape &shape) const -> GrainlineShape
|
||||||
GrainlineShape mappedShape;
|
GrainlineShape mappedShape;
|
||||||
mappedShape.reserve(shape.size());
|
mappedShape.reserve(shape.size());
|
||||||
|
|
||||||
for (auto subShape : shape)
|
for (const auto &subShape : shape)
|
||||||
{
|
{
|
||||||
mappedShape.append(Map(subShape));
|
mappedShape.append(Map(subShape));
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "../vmisc/typedef.h"
|
#include "../vmisc/typedef.h"
|
||||||
#include "../vpatterndb/floatItemData/floatitemdef.h"
|
|
||||||
#include "../vwidgets/vpiecegrainline.h"
|
#include "../vwidgets/vpiecegrainline.h"
|
||||||
#include "qpainterpath.h"
|
#include "qpainterpath.h"
|
||||||
#include "vabstractpiece.h"
|
#include "vabstractpiece.h"
|
||||||
|
|
|
@ -30,9 +30,9 @@
|
||||||
#define VLAYOUTPIECEPATH_H
|
#define VLAYOUTPIECEPATH_H
|
||||||
|
|
||||||
#include "vlayoutpoint.h"
|
#include "vlayoutpoint.h"
|
||||||
|
#include <QMetaType>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QSharedDataPointer>
|
#include <QSharedDataPointer>
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
class VLayoutPiecePathData;
|
class VLayoutPiecePathData;
|
||||||
class QPainterPath;
|
class QPainterPath;
|
||||||
|
@ -48,8 +48,8 @@ public:
|
||||||
|
|
||||||
auto operator=(const VLayoutPiecePath &path) -> VLayoutPiecePath &;
|
auto operator=(const VLayoutPiecePath &path) -> VLayoutPiecePath &;
|
||||||
#ifdef Q_COMPILER_RVALUE_REFS
|
#ifdef Q_COMPILER_RVALUE_REFS
|
||||||
VLayoutPiecePath(VLayoutPiecePath &&path) Q_DECL_NOTHROW;
|
VLayoutPiecePath(VLayoutPiecePath &&path) noexcept;
|
||||||
auto operator=(VLayoutPiecePath &&path) Q_DECL_NOTHROW->VLayoutPiecePath &;
|
auto operator=(VLayoutPiecePath &&path) noexcept -> VLayoutPiecePath &;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto GetPainterPath() const -> QPainterPath;
|
auto GetPainterPath() const -> QPainterPath;
|
||||||
|
@ -70,7 +70,7 @@ private:
|
||||||
QSharedDataPointer<VLayoutPiecePathData> d;
|
QSharedDataPointer<VLayoutPiecePathData> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(VLayoutPiecePath)
|
Q_DECLARE_METATYPE(VLayoutPiecePath) // NOLINT
|
||||||
Q_DECLARE_TYPEINFO(VLayoutPiecePath, Q_MOVABLE_TYPE); // NOLINT
|
Q_DECLARE_TYPEINFO(VLayoutPiecePath, Q_MOVABLE_TYPE); // NOLINT
|
||||||
|
|
||||||
#endif // VLAYOUTPIECEPATH_H
|
#endif // VLAYOUTPIECEPATH_H
|
||||||
|
|
|
@ -483,14 +483,19 @@ const int userMaterialPlaceholdersQuantity = 20;
|
||||||
auto QPixmapFromCache(const QString &pixmapPath) -> QPixmap;
|
auto QPixmapFromCache(const QString &pixmapPath) -> QPixmap;
|
||||||
void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int hotX = -1, int hotY = -1);
|
void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int hotX = -1, int hotY = -1);
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto MmToPixel(T val) noexcept -> T
|
template <typename T> constexpr inline auto MmToPixel(T val) noexcept -> T
|
||||||
{
|
{
|
||||||
return (val / 25.4) * PrintDPI;
|
return (val / 25.4) * PrintDPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto CmToPixel(T val) noexcept -> T
|
template <typename T> constexpr inline auto CmToPixel(T val) noexcept -> T
|
||||||
{
|
{
|
||||||
return ((val * 10.0) / 25.4) * PrintDPI;
|
return ((val * 10.0) / 25.4) * PrintDPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto InchToPixel(T val) noexcept -> T
|
template <typename T> constexpr inline auto InchToPixel(T val) noexcept -> T
|
||||||
{
|
{
|
||||||
return val * PrintDPI;
|
return val * PrintDPI;
|
||||||
|
@ -515,14 +520,19 @@ Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel(double val, const Unit &unit) -> do
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto PixelToInch(T pix) -> T
|
template <typename T> constexpr inline auto PixelToInch(T pix) -> T
|
||||||
{
|
{
|
||||||
return pix / PrintDPI;
|
return pix / PrintDPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto PixelToMm(T pix) -> T
|
template <typename T> constexpr inline auto PixelToMm(T pix) -> T
|
||||||
{
|
{
|
||||||
return PixelToInch(pix) * 25.4;
|
return PixelToInch(pix) * 25.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto PixelToCm(T pix) -> T
|
template <typename T> constexpr inline auto PixelToCm(T pix) -> T
|
||||||
{
|
{
|
||||||
return PixelToInch(pix) * 2.54;
|
return PixelToInch(pix) * 2.54;
|
||||||
|
@ -547,16 +557,23 @@ Q_DECL_RELAXED_CONSTEXPR inline auto FromPixel(double pix, const Unit &unit) ->
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto Inch2ToPixel2(T val) -> T
|
template <typename T> constexpr inline auto Inch2ToPixel2(T val) -> T
|
||||||
{
|
{
|
||||||
return val * (PrintDPI * PrintDPI);
|
return val * (PrintDPI * PrintDPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto Mm2ToPixel2(T val) -> T
|
template <typename T> constexpr inline auto Mm2ToPixel2(T val) -> T
|
||||||
{
|
{
|
||||||
|
// There are 0.15500031 square inches in a square centimeter.
|
||||||
return Inch2ToPixel2(val * 0.001550031);
|
return Inch2ToPixel2(val * 0.001550031);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto Cm2ToPixel2(T val) -> T
|
template <typename T> constexpr inline auto Cm2ToPixel2(T val) -> T
|
||||||
{
|
{
|
||||||
|
// There are 0.15500031 square inches in a square centimeter.
|
||||||
return Inch2ToPixel2(val * 0.15500031);
|
return Inch2ToPixel2(val * 0.15500031);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,16 +596,23 @@ Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel2(double val, const Unit &unit) -> d
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto Pixel2ToInch2(T pix) -> T
|
template <typename T> constexpr inline auto Pixel2ToInch2(T pix) -> T
|
||||||
{
|
{
|
||||||
return pix / (PrintDPI * PrintDPI);
|
return pix / (PrintDPI * PrintDPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto Pixel2ToMm2(T pix) -> T
|
template <typename T> constexpr inline auto Pixel2ToMm2(T pix) -> T
|
||||||
{
|
{
|
||||||
|
// There are 0.15500031 square inches in a square centimeter.
|
||||||
return Pixel2ToInch2(pix) / 0.001550031;
|
return Pixel2ToInch2(pix) / 0.001550031;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T> constexpr inline auto Pixel2ToCm2(T pix) -> T
|
template <typename T> constexpr inline auto Pixel2ToCm2(T pix) -> T
|
||||||
{
|
{
|
||||||
|
// There are 0.15500031 square inches in a square centimeter.
|
||||||
return Pixel2ToInch2(pix) / 0.15500031;
|
return Pixel2ToInch2(pix) / 0.15500031;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user