Fix support Visual Studio 2015.

This commit is contained in:
Roman Telezhynskyi 2022-09-02 17:14:03 +03:00
parent daf7574f39
commit 70168ebe6c
14 changed files with 37 additions and 36 deletions

View File

@ -49,9 +49,9 @@ QT_WARNING_POP
namespace
{
constexpr qreal minStickyDistance = 3 / 25.4 * PrintDPI; // 3 mm
constexpr qreal maxStickyDistance = 10 / 25.4 * PrintDPI; // 10 mm
constexpr qreal stickyShift = 1 / 25.4 * PrintDPI; // 1 mm
constexpr qreal minStickyDistance = MmToPixel(3.);
constexpr qreal maxStickyDistance = MmToPixel(10.);
constexpr qreal stickyShift = MmToPixel(1.);
//---------------------------------------------------------------------------------------------------------------------
auto CutEdge(const QLineF &edge) -> QVector<QPointF>

View File

@ -95,7 +95,7 @@ public:
/**
* @brief tileStripeWidth the width of the info / glueing stripe in Px
*/
static constexpr qreal tileStripeWidth = 10.0 / 25.4 * PrintDPI; // 1 cm to pixels
static constexpr qreal tileStripeWidth = CmToPixel(1.0);
auto WatermarkData() const -> const VWatermarkData &;

View File

@ -40,10 +40,6 @@
#include "../vmisc/compatibility.h"
#include "../ifc/exception/vexceptionobjecterror.h"
#if defined(__cpp_constexpr) && __cpp_constexpr-0 < 201304
const qreal VAbstractCurve::minLength = ToPixel(1, Unit::Mm);
#endif
VAbstractCurve::VAbstractCurve(const GOType &type, const quint32 &idObject, const Draw &mode)
:VGObject(type, idObject, mode), d (new VAbstractCurveData())
{}

View File

@ -112,11 +112,7 @@ public:
void SetAliasSuffix(const QString &aliasSuffix) override;
#if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304
static constexpr qreal minLength = ToPixel(1, Unit::Mm);
#else
static const qreal minLength;
#endif
static constexpr qreal minLength = MmToPixel(1.);
protected:
virtual void CreateName() =0;

View File

@ -214,7 +214,7 @@ auto JoinVectors(const QVector<QPointF> &v1, const QVector<QPointF> &v2) -> QVec
v = v1;
constexpr qreal accuracy = (0.0001/*mm*/ / 25.4) * PrintDPI;
constexpr qreal accuracy = MmToPixel(0.0001);
for (auto p : v2)
{

View File

@ -97,7 +97,7 @@ private:
};
Q_DECLARE_METATYPE(VLayoutPassmark)
constexpr qreal accuracyPointOnLine = (0.1555/*mm*/ / 25.4) * PrintDPI;
constexpr qreal accuracyPointOnLine = MmToPixel(0.1555);
Q_REQUIRED_RESULT static inline bool VFuzzyComparePoints(const QPointF &p1, const QPointF &p2,
qreal accuracy = accuracyPointOnLine);

View File

@ -54,7 +54,7 @@ const quint16 VAbstractPieceData::classVersion = 3;
const qreal maxL = 3.5;
const qreal VSAPoint::passmarkFactor = 0.5;
const qreal VSAPoint::maxPassmarkLength = (10/*mm*/ / 25.4) * PrintDPI;
const qreal VSAPoint::maxPassmarkLength = MmToPixel(10.);
const qreal VSAPoint::minSAWidth = accuracyPointOnLine + accuracyPointOnLine*0.5;
namespace

View File

@ -246,7 +246,7 @@ auto VAbstractPiece::RemoveDublicates(const QVector<T> &points, bool removeFirst
p.append(ConstFirst(points));
// Default accuracy is not enough
constexpr qreal accuracy = (0.5/*mm*/ / 25.4) * PrintDPI;
constexpr qreal accuracy = MmToPixel(0.5);
for (int i = 0; i < points.size(); ++i)
{

View File

@ -120,7 +120,7 @@ QPixmap WatermarkImageFromCache(const VWatermarkData &watermarkData, const QStri
//---------------------------------------------------------------------------------------------------------------------
VPoster::VPoster(const QPrinter *printer)
:printer(printer), allowance(static_cast<quint32>(qRound(10./25.4*PrintDPI)))//1 cm
:printer(printer), allowance(static_cast<quint32>(qRound(CmToPixel(1.))))
{
}

View File

@ -375,17 +375,21 @@ const int userMaterialPlaceholdersQuantity = 20;
QPixmap QPixmapFromCache(const QString &pixmapPath);
void SetItemOverrideCursor(QGraphicsItem *item, const QString & pixmapPath, int hotX = -1, int hotY = -1);
template<typename T> Q_DECL_CONSTEXPR inline auto MmToPixel(T val) -> T { return (val / 25.4) * PrintDPI; }
template<typename T> Q_DECL_CONSTEXPR inline auto CmToPixel(T val) -> T { return ((val * 10.0) / 25.4) * PrintDPI; }
template<typename T> Q_DECL_CONSTEXPR inline auto InchToPixel(T val) -> T { return val * PrintDPI; }
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline double ToPixel(double val, const Unit &unit)
Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel(double val, const Unit &unit) -> double
{
switch (unit)
{
case Unit::Mm:
return (val / 25.4) * PrintDPI;
return MmToPixel(val);
case Unit::Cm:
return ((val * 10.0) / 25.4) * PrintDPI;
return CmToPixel(val);
case Unit::Inch:
return val * PrintDPI;
return InchToPixel(val);
case Unit::Px:
return val;
default:
@ -394,17 +398,21 @@ Q_DECL_RELAXED_CONSTEXPR inline double ToPixel(double val, const Unit &unit)
return 0;
}
template<typename T> Q_DECL_CONSTEXPR inline auto PixelToMm(T pix) -> T { return (pix / PrintDPI) * 25.4; }
template<typename T> Q_DECL_CONSTEXPR inline auto PixelToCm(T pix) -> T { return ((pix / PrintDPI) * 25.4) / 10.0; }
template<typename T> Q_DECL_CONSTEXPR inline auto PixelToInch(T pix) -> T { return pix / PrintDPI; }
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline double FromPixel(double pix, const Unit &unit)
Q_DECL_RELAXED_CONSTEXPR inline auto FromPixel(double pix, const Unit &unit) -> double
{
switch (unit)
{
case Unit::Mm:
return (pix / PrintDPI) * 25.4;
return PixelToMm(pix);
case Unit::Cm:
return ((pix / PrintDPI) * 25.4) / 10.0;
return PixelToCm(pix);
case Unit::Inch:
return pix / PrintDPI;
return PixelToInch(pix);
case Unit::Px:
return pix;
default:
@ -414,7 +422,7 @@ Q_DECL_RELAXED_CONSTEXPR inline double FromPixel(double pix, const Unit &unit)
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline qreal UnitConvertor(qreal value, const Unit &from, const Unit &to)
Q_DECL_RELAXED_CONSTEXPR inline auto UnitConvertor(qreal value, const Unit &from, const Unit &to) -> qreal
{
switch (from)
{
@ -489,14 +497,15 @@ Q_DECL_RELAXED_CONSTEXPR inline qreal UnitConvertor(qreal value, const Unit &fro
* @brief UnitConvertor Converts the values of the given margin from given unit to the new unit.
* returns a new instand of QMarginsF.
*/
Q_DECL_RELAXED_CONSTEXPR inline QMarginsF UnitConvertor(const QMarginsF &margins, const Unit &from, const Unit &to)
Q_DECL_RELAXED_CONSTEXPR inline auto UnitConvertor(const QMarginsF &margins, const Unit &from,
const Unit &to) -> QMarginsF
{
const qreal left = UnitConvertor(margins.left(), from, to);
const qreal top = UnitConvertor(margins.top(), from, to);
const qreal right = UnitConvertor(margins.right(), from, to);
const qreal bottom = UnitConvertor(margins.bottom(), from, to);
return QMarginsF(left, top, right, bottom);
return {left, top, right, bottom};
}
void InitLanguages(QComboBox *combobox);

View File

@ -141,7 +141,7 @@ bool FixNotchPoint(const QVector<QPointF> &seamAllowance, const QPointF &notchBa
return fixed;
}
const qreal passmarkGap = (1.5/*mm*/ / 25.4) * PrintDPI;
const qreal passmarkGap = MmToPixel(1.5);
//---------------------------------------------------------------------------------------------------------------------
QVector<QLineF> CreateOnePassmarkLines(const QLineF &line)

View File

@ -312,7 +312,7 @@ void AbstractTest::Comparison(const QVector<QPointF> &ekv, const QVector<QPointF
{
// Begin comparison
QCOMPARE(ekv.size(), ekvOrig.size());// First check if sizes equal
const qreal testAccuracy = (1.0/*mm*/ / 25.4) * PrintDPI;
const qreal testAccuracy = MmToPixel(1.);
for (int i=0; i < ekv.size(); i++)
{

View File

@ -155,7 +155,7 @@ void VMainGraphicsScene::InitOrigins()
{
origins.clear();
QPen originsPen(Qt::green, (1.2 / 3.0) /*mm*/ / 25.4 * PrintDPI, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
QPen originsPen(Qt::green, MmToPixel(1.2 / 3.0), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
QBrush axisTextBrush(Qt::green);
const qreal arrowAngle = 35.0;
const qreal arrowLength = 12.0;

View File

@ -45,12 +45,12 @@
#include "../vmisc/compatibility.h"
#include "vtextgraphicsitem.h"
const qreal resizeSquare = (3./*mm*/ / 25.4) * PrintDPI;
const qreal rotateCircle = (2./*mm*/ / 25.4) * PrintDPI;
const qreal resizeSquare = MmToPixel(3.);
const qreal rotateCircle = MmToPixel(2.);
#define ROTATE_RECT 60
#define ROTATE_ARC 50
const qreal minW = (4./*mm*/ / 25.4) * PrintDPI + resizeSquare;
const qreal minH = (4./*mm*/ / 25.4) * PrintDPI + resizeSquare;
const qreal minW = MmToPixel(4.) + resizeSquare;
const qreal minH = MmToPixel(4.) + resizeSquare;
#define ACTIVE_Z 10
namespace