Refactoring.
Code style.
This commit is contained in:
parent
c39c5b884e
commit
1e2f1f7708
|
@ -28,13 +28,13 @@
|
|||
#ifndef VPPIECE_H
|
||||
#define VPPIECE_H
|
||||
|
||||
#include <QUuid>
|
||||
#include <QVector>
|
||||
#include <QPoint>
|
||||
#include <QTransform>
|
||||
#include <QUuid>
|
||||
#include <QVector>
|
||||
|
||||
#include "../vlayout/vlayoutpiece.h"
|
||||
#include "../layout/layoutdef.h"
|
||||
#include "../vlayout/vlayoutpiece.h"
|
||||
#include "vpiecegrainline.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
|
@ -47,6 +47,7 @@ class VPSheet;
|
|||
class VPPiece : public VLayoutPiece
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VPPiece) // NOLINT
|
||||
|
||||
public:
|
||||
VPPiece() = default;
|
||||
explicit VPPiece(const VLayoutPiece &layoutPiece);
|
||||
|
|
|
@ -497,7 +497,7 @@ void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails)
|
|||
QString::number(i + 1) +
|
||||
VLayoutExporter::ExportFormatSuffix(m_dialogSaveLayout->Format());
|
||||
|
||||
QGraphicsRectItem *paper =
|
||||
auto *paper =
|
||||
qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutSettings->LayoutPapers().at(i));
|
||||
SCASSERT(paper != nullptr)
|
||||
|
||||
|
|
|
@ -104,16 +104,11 @@ QT_WARNING_POP
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto PieceOutline(const VLayoutPiece &detail) -> QVector<VLayoutPoint>
|
||||
{
|
||||
QVector<VLayoutPoint> outline;
|
||||
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
|
||||
{
|
||||
outline = detail.GetMappedSeamAllowancePoints();
|
||||
return detail.GetMappedSeamAllowancePoints();
|
||||
}
|
||||
else
|
||||
{
|
||||
outline = detail.GetMappedContourPoints();
|
||||
}
|
||||
return outline;
|
||||
return detail.GetMappedContourPoints();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@
|
|||
*************************************************************************/
|
||||
#include "vwatermark.h"
|
||||
|
||||
#include "../vmisc/projectversion.h"
|
||||
#include "../ifc/xml/vwatermarkconverter.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
#include "../vmisc/projectversion.h"
|
||||
|
||||
const QString VWatermark::TagWatermark = QStringLiteral("watermark");
|
||||
const QString VWatermark::TagText = QStringLiteral("text");
|
||||
|
@ -46,14 +47,14 @@ namespace
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto FileComment() -> QString
|
||||
{
|
||||
return QString("Watermark created with Valentina v%1 (https://smart-pattern.com.ua/).")
|
||||
.arg(APP_VERSION_STR);
|
||||
}
|
||||
return QString("Watermark created with Valentina v%1 (https://smart-pattern.com.ua/).").arg(APP_VERSION_STR);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VWatermark::VWatermark()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VWatermark::CreateEmptyWatermark()
|
||||
|
@ -67,8 +68,9 @@ void VWatermark::CreateEmptyWatermark()
|
|||
wElement.appendChild(createElement(TagImage));
|
||||
|
||||
appendChild(wElement);
|
||||
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
|
||||
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild());
|
||||
insertBefore(
|
||||
createProcessingInstruction(QStringLiteral("xml"), QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")),
|
||||
this->firstChild());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include <QQueue>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
#include <QStringLiteral>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
#include <QUrlQuery>
|
||||
#include <QUuid>
|
||||
|
|
|
@ -37,10 +37,11 @@
|
|||
#include <QTransform>
|
||||
#include <QtMath>
|
||||
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vmisc/compatibility.h"
|
||||
#include "vgobject_p.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "vgeometry/vgeometrydef.h"
|
||||
#include "vgobject_p.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -90,7 +91,8 @@ auto GetEpsilon(const QPointF &t, QPointF p1, QPointF p2, qreal accuracy) -> dou
|
|||
*/
|
||||
VGObject::VGObject()
|
||||
: d(new VGObjectData)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -101,7 +103,8 @@ VGObject::VGObject()
|
|||
*/
|
||||
VGObject::VGObject(const GOType &type, const quint32 &idObject, const Draw &mode)
|
||||
: d(new VGObjectData(type, idObject, mode))
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -110,7 +113,8 @@ VGObject::VGObject(const GOType &type, const quint32 &idObject, const Draw &mode
|
|||
*/
|
||||
VGObject::VGObject(const VGObject &obj) // NOLINT(modernize-use-equals-default)
|
||||
: d(obj.d)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -130,12 +134,13 @@ auto VGObject::operator=(const VGObject &obj) -> VGObject &
|
|||
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VGObject::VGObject(VGObject &&obj) Q_DECL_NOTHROW
|
||||
VGObject::VGObject(VGObject &&obj) noexcept
|
||||
: 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);
|
||||
return *this;
|
||||
|
@ -144,7 +149,8 @@ auto VGObject::operator=(VGObject &&obj) Q_DECL_NOTHROW -> VGObject &
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VGObject::~VGObject() // NOLINT(modernize-use-equals-default)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -293,8 +299,7 @@ auto VGObject::getIdTool() const -> quint32
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VGObject::ToJson() const -> QJsonObject
|
||||
{
|
||||
QJsonObject object
|
||||
{
|
||||
QJsonObject object{
|
||||
{"id", static_cast<qint64>(id())},
|
||||
{"type", static_cast<int>(getType())},
|
||||
};
|
||||
|
@ -324,7 +329,8 @@ auto VGObject::BuildRay(const QPointF &firstPoint, const qreal &angle, const QRe
|
|||
if (not rect.contains(firstPoint))
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
const qreal diagonal = qSqrt(pow(rect.height(), 2) + pow(rect.width(), 2));
|
||||
|
@ -411,10 +417,11 @@ 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())
|
||||
&& VFuzzyComparePossibleNulls(r1, r2))
|
||||
if (VFuzzyComparePossibleNulls(c1.x(), c2.x()) && VFuzzyComparePossibleNulls(c1.y(), c2.y()) &&
|
||||
VFuzzyComparePossibleNulls(r1, r2))
|
||||
{
|
||||
return 3; // Circles are equal
|
||||
}
|
||||
|
@ -459,8 +466,8 @@ auto VGObject::IntersectionCircles(const QPointF &c1, double r1, const QPointF &
|
|||
* @param p2 second intersection point.
|
||||
* @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,
|
||||
QPointF &p2) -> qint32
|
||||
auto VGObject::LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, QPointF &p2)
|
||||
-> qint32
|
||||
{
|
||||
// Fix for issue #485. https://bitbucket.org/dismine/valentina/issues/485/error-when-drawing-a-curved-path
|
||||
if (qFuzzyIsNull(line.length()))
|
||||
|
|
|
@ -29,9 +29,9 @@
|
|||
#ifndef VLAYOUTDEF_H
|
||||
#define VLAYOUTDEF_H
|
||||
|
||||
#include <QPainterPath>
|
||||
#include <QSize>
|
||||
#include <QTransform>
|
||||
#include <QPainterPath>
|
||||
#include <ciso646>
|
||||
#include <climits>
|
||||
|
||||
|
@ -100,7 +100,13 @@ struct VCachedPositions
|
|||
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
|
||||
* Address Sanitizer. See page https://bitbucket.org/dismine/valentina/wiki/developers/Address_Sanitizer
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <QFontMetrics>
|
||||
#include <QFuture>
|
||||
#include <QGraphicsPathItem>
|
||||
#include <QLine>
|
||||
#include <QList>
|
||||
#include <QMessageLogger>
|
||||
#include <QPainterPath>
|
||||
|
@ -46,6 +47,8 @@
|
|||
#include <QtDebug>
|
||||
#include <QtMath>
|
||||
|
||||
#include "../vformat/vsinglelineoutlinechar.h"
|
||||
#include "../vgeometry/vgobject.h"
|
||||
#include "../vgeometry/vlayoutplacelabel.h"
|
||||
#include "../vgeometry/vplacelabelitem.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
@ -62,15 +65,10 @@
|
|||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vpatterndb/vpassmark.h"
|
||||
#include "../vpatterndb/vpiecenode.h"
|
||||
#include "../vwidgets/global.h"
|
||||
#include "vgobject.h"
|
||||
#include "../vwidgets/vpiecegrainline.h"
|
||||
#include "vgraphicsfillitem.h"
|
||||
#include "vlayoutpiece_p.h"
|
||||
#include "vpiecegrainline.h"
|
||||
#include "vsinglelineoutlinechar.h"
|
||||
#include "vtextmanager.h"
|
||||
#include <QLine>
|
||||
#include <QPainterPath>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -773,7 +771,7 @@ auto VLayoutPiece::Map(const GrainlineShape &shape) const -> GrainlineShape
|
|||
GrainlineShape mappedShape;
|
||||
mappedShape.reserve(shape.size());
|
||||
|
||||
for (auto subShape : shape)
|
||||
for (const auto &subShape : shape)
|
||||
{
|
||||
mappedShape.append(Map(subShape));
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include <QtGlobal>
|
||||
|
||||
#include "../vmisc/typedef.h"
|
||||
#include "../vpatterndb/floatItemData/floatitemdef.h"
|
||||
#include "../vwidgets/vpiecegrainline.h"
|
||||
#include "qpainterpath.h"
|
||||
#include "vabstractpiece.h"
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
#define VLAYOUTPIECEPATH_H
|
||||
|
||||
#include "vlayoutpoint.h"
|
||||
#include <QMetaType>
|
||||
#include <QPointF>
|
||||
#include <QSharedDataPointer>
|
||||
#include <QMetaType>
|
||||
|
||||
class VLayoutPiecePathData;
|
||||
class QPainterPath;
|
||||
|
@ -48,8 +48,8 @@ public:
|
|||
|
||||
auto operator=(const VLayoutPiecePath &path) -> VLayoutPiecePath &;
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
VLayoutPiecePath(VLayoutPiecePath &&path) Q_DECL_NOTHROW;
|
||||
auto operator=(VLayoutPiecePath &&path) Q_DECL_NOTHROW->VLayoutPiecePath &;
|
||||
VLayoutPiecePath(VLayoutPiecePath &&path) noexcept;
|
||||
auto operator=(VLayoutPiecePath &&path) noexcept -> VLayoutPiecePath &;
|
||||
#endif
|
||||
|
||||
auto GetPainterPath() const -> QPainterPath;
|
||||
|
@ -70,7 +70,7 @@ private:
|
|||
QSharedDataPointer<VLayoutPiecePathData> d;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(VLayoutPiecePath)
|
||||
Q_DECLARE_METATYPE(VLayoutPiecePath) // NOLINT
|
||||
Q_DECLARE_TYPEINFO(VLayoutPiecePath, Q_MOVABLE_TYPE); // NOLINT
|
||||
|
||||
#endif // VLAYOUTPIECEPATH_H
|
||||
|
|
|
@ -483,14 +483,19 @@ const int userMaterialPlaceholdersQuantity = 20;
|
|||
auto QPixmapFromCache(const QString &pixmapPath) -> QPixmap;
|
||||
void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int hotX = -1, int hotY = -1);
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T> constexpr inline auto MmToPixel(T val) noexcept -> T
|
||||
{
|
||||
return (val / 25.4) * PrintDPI;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T> constexpr inline auto CmToPixel(T val) noexcept -> T
|
||||
{
|
||||
return ((val * 10.0) / 25.4) * PrintDPI;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T> constexpr inline auto InchToPixel(T val) noexcept -> T
|
||||
{
|
||||
return val * PrintDPI;
|
||||
|
@ -515,14 +520,19 @@ Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel(double val, const Unit &unit) -> do
|
|||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T> constexpr inline auto PixelToInch(T pix) -> T
|
||||
{
|
||||
return pix / PrintDPI;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T> constexpr inline auto PixelToMm(T pix) -> T
|
||||
{
|
||||
return PixelToInch(pix) * 25.4;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T> constexpr inline auto PixelToCm(T pix) -> T
|
||||
{
|
||||
return PixelToInch(pix) * 2.54;
|
||||
|
@ -547,16 +557,23 @@ Q_DECL_RELAXED_CONSTEXPR inline auto FromPixel(double pix, const Unit &unit) ->
|
|||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T> constexpr inline auto Inch2ToPixel2(T val) -> T
|
||||
{
|
||||
return val * (PrintDPI * PrintDPI);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -579,16 +596,23 @@ Q_DECL_RELAXED_CONSTEXPR inline auto ToPixel2(double val, const Unit &unit) -> d
|
|||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template <typename T> constexpr inline auto Pixel2ToInch2(T pix) -> T
|
||||
{
|
||||
return pix / (PrintDPI * PrintDPI);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user