Refactoring.

Code style.
This commit is contained in:
Roman Telezhynskyi 2023-08-12 10:31:10 +03:00
parent ff6689f247
commit baf4f1a08b
39 changed files with 4461 additions and 3860 deletions

View File

@ -41,11 +41,13 @@ QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
VPUndoCommand::VPUndoCommand(QUndoCommand *parent)
: QUndoCommand(parent)
{}
: QUndoCommand(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
VPUndoCommand::VPUndoCommand(bool allowMerge, QUndoCommand *parent)
: QUndoCommand(parent),
m_allowMerge(allowMerge)
{}
: QUndoCommand(parent),
m_allowMerge(allowMerge)
{
}

View File

@ -27,9 +27,9 @@
*************************************************************************/
#include "dialogmdatabase.h"
#include "ui_dialogmdatabase.h"
#include "../mapplication.h"
#include "../vpatterndb/measurements.h"
#include "ui_dialogmdatabase.h"
#include "../vmisc/compatibility.h"
#include <QKeyEvent>
@ -39,10 +39,10 @@
//---------------------------------------------------------------------------------------------------------------------
DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
:QDialog(parent),
ui(new Ui::DialogMDataBase),
m_selectMode(true),
m_list(list)
: QDialog(parent),
ui(new Ui::DialogMDataBase),
m_selectMode(true),
m_list(list)
{
ui->setupUi(this);
@ -64,9 +64,9 @@ DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
//---------------------------------------------------------------------------------------------------------------------
DialogMDataBase::DialogMDataBase(QWidget *parent)
:QDialog(parent),
ui(new Ui::DialogMDataBase),
m_selectMode(false)
: QDialog(parent),
ui(new Ui::DialogMDataBase),
m_selectMode(false)
{
ui->setupUi(this);
@ -100,7 +100,7 @@ auto DialogMDataBase::GetNewNames() const -> QStringList
{
QStringList newNames;
QTreeWidgetItemIterator it(ui->treeWidget,
QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Checked );
QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Checked);
while (*it)
{
const QString name = (*it)->data(0, Qt::UserRole).toString();
@ -119,22 +119,22 @@ auto DialogMDataBase::GetNewNames() const -> QStringList
//---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::RetranslateGroups()
{
RetranslateGroup(m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA());
RetranslateGroup(m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB());
RetranslateGroup(m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC());
RetranslateGroup(m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD());
RetranslateGroup(m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE());
RetranslateGroup(m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF());
RetranslateGroup(m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG());
RetranslateGroup(m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH());
RetranslateGroup(m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI());
RetranslateGroup(m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ());
RetranslateGroup(m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK());
RetranslateGroup(m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL());
RetranslateGroup(m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM());
RetranslateGroup(m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN());
RetranslateGroup(m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO());
RetranslateGroup(m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP());
RetranslateGroup(m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA());
RetranslateGroup(m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB());
RetranslateGroup(m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC());
RetranslateGroup(m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD());
RetranslateGroup(m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE());
RetranslateGroup(m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF());
RetranslateGroup(m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG());
RetranslateGroup(m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH());
RetranslateGroup(m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI());
RetranslateGroup(m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ());
RetranslateGroup(m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK());
RetranslateGroup(m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL());
RetranslateGroup(m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM());
RetranslateGroup(m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN());
RetranslateGroup(m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO());
RetranslateGroup(m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP());
RetranslateGroup(m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ());
ShowDescription(ui->treeWidget->currentItem(), 0);
@ -144,8 +144,8 @@ void DialogMDataBase::RetranslateGroups()
auto DialogMDataBase::ImgTag(const QString &number) -> QString
{
QString imgUrl(QStringLiteral("<img src=\"wrong.png\" align=\"center\"/>")); // In case of error
const QString filePath = QStringLiteral("://diagrams/%1.svg")
.arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number));
const QString filePath =
QStringLiteral("://diagrams/%1.svg").arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number));
if (QFileInfo::exists(filePath))
{
// Load your SVG
@ -203,7 +203,7 @@ auto DialogMDataBase::eventFilter(QObject *target, QEvent *event) -> bool
if (target == ui->treeWidget && event->type() == QEvent::KeyPress)
{
auto *keyEvent = static_cast<QKeyEvent *>(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
switch(keyEvent->key())
switch (keyEvent->key())
{
case Qt::Key_Up:
{
@ -262,8 +262,7 @@ void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
}
for (int j = 0; j < parent->childCount(); ++j)
{
if (j != parent->indexOfChild(item)
&& item->checkState(0) != parent->child(j)->checkState(0))
if (j != parent->indexOfChild(item) && item->checkState(0) != parent->child(j)->checkState(0))
{
diff = true;
}
@ -379,22 +378,22 @@ void DialogMDataBase::FilterMeasurements(const QString &search)
//---------------------------------------------------------------------------------------------------------------------
void DialogMDataBase::InitDataBase(const QStringList &list)
{
InitGroup(&m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list);
InitGroup(&m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list);
InitGroup(&m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list);
InitGroup(&m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list);
InitGroup(&m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list);
InitGroup(&m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list);
InitGroup(&m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list);
InitGroup(&m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list);
InitGroup(&m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list);
InitGroup(&m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list);
InitGroup(&m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list);
InitGroup(&m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list);
InitGroup(&m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list);
InitGroup(&m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list);
InitGroup(&m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list);
InitGroup(&m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list);
InitGroup(&m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list);
InitGroup(&m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list);
InitGroup(&m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list);
InitGroup(&m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list);
InitGroup(&m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list);
InitGroup(&m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list);
InitGroup(&m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list);
InitGroup(&m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list);
InitGroup(&m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list);
InitGroup(&m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list);
InitGroup(&m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list);
InitGroup(&m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list);
InitGroup(&m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list);
InitGroup(&m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list);
InitGroup(&m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list);
InitGroup(&m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list);
InitGroup(&m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ(), list);
}
@ -415,14 +414,14 @@ void DialogMDataBase::FilterGroup(QTreeWidgetItem *group, const QString &search)
SCASSERT(group != nullptr)
bool match = false;
for (int i=0; i < group->childCount(); ++i)
for (int i = 0; i < group->childCount(); ++i)
{
QTreeWidgetItem *childItem = group->child(i);
const QString description = QTextDocumentFragment::fromHtml(ItemFullDescription(childItem, false))
.toPlainText();
const QString description =
QTextDocumentFragment::fromHtml(ItemFullDescription(childItem, false)).toPlainText();
const bool hidden = not childItem->text(0).contains(search, Qt::CaseInsensitive)
&& not description.contains(search, Qt::CaseInsensitive);
const bool hidden = not childItem->text(0).contains(search, Qt::CaseInsensitive) &&
not description.contains(search, Qt::CaseInsensitive);
childItem->setHidden(hidden);
if (not hidden)
@ -474,7 +473,7 @@ void DialogMDataBase::AddMeasurement(QTreeWidgetItem *group, const QString &name
}
const QString text = VAbstractApplication::VApp()->TrVars()->MNumber(name) + ". " +
VAbstractApplication::VApp()->TrVars()->MToUser(name);
VAbstractApplication::VApp()->TrVars()->MToUser(name);
m->setText(0, text);
m->setToolTip(0, text);
m->setData(0, Qt::UserRole, name);
@ -518,8 +517,8 @@ auto DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showImage)
"normal\"> %1 <br clear=\"left\"><b>%2</b>. <i>%3</i></p>"
"<p align=\"left\" style=\"font-variant: normal; font-style: normal; font-weight: "
"normal\">%4</p>")
.arg(imgTag, number, VAbstractApplication::VApp()->TrVars()->GuiText(name),
VAbstractApplication::VApp()->TrVars()->Description(name));
.arg(imgTag, number, VAbstractApplication::VApp()->TrVars()->GuiText(name),
VAbstractApplication::VApp()->TrVars()->Description(name));
return text;
}
@ -530,7 +529,7 @@ void DialogMDataBase::RetranslateGroup(QTreeWidgetItem *group, const QString &gr
group->setText(0, groupText);
group->setToolTip(0, groupText);
for (int i=0; i<list.size(); ++i)
for (int i = 0; i < list.size(); ++i)
{
RetranslateMeasurement(group, i, list.at(i));
}
@ -540,7 +539,7 @@ void DialogMDataBase::RetranslateGroup(QTreeWidgetItem *group, const QString &gr
void DialogMDataBase::RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name)
{
const QString text = VAbstractApplication::VApp()->TrVars()->MNumber(name) + ". " +
VAbstractApplication::VApp()->TrVars()->MToUser(name);
VAbstractApplication::VApp()->TrVars()->MToUser(name);
QTreeWidgetItem *m = group->child(index);
m->setText(0, text);
@ -577,43 +576,27 @@ auto DialogMDataBase::GlobalCheckState() const -> Qt::CheckState
if (m_selectMode)
{
if (m_groupA->checkState(0) == Qt::Unchecked &&
m_groupB->checkState(0) == Qt::Unchecked &&
m_groupC->checkState(0) == Qt::Unchecked &&
m_groupD->checkState(0) == Qt::Unchecked &&
m_groupE->checkState(0) == Qt::Unchecked &&
m_groupF->checkState(0) == Qt::Unchecked &&
m_groupG->checkState(0) == Qt::Unchecked &&
m_groupH->checkState(0) == Qt::Unchecked &&
m_groupI->checkState(0) == Qt::Unchecked &&
m_groupJ->checkState(0) == Qt::Unchecked &&
m_groupK->checkState(0) == Qt::Unchecked &&
m_groupL->checkState(0) == Qt::Unchecked &&
m_groupM->checkState(0) == Qt::Unchecked &&
m_groupN->checkState(0) == Qt::Unchecked &&
m_groupO->checkState(0) == Qt::Unchecked &&
m_groupP->checkState(0) == Qt::Unchecked &&
if (m_groupA->checkState(0) == Qt::Unchecked && m_groupB->checkState(0) == Qt::Unchecked &&
m_groupC->checkState(0) == Qt::Unchecked && m_groupD->checkState(0) == Qt::Unchecked &&
m_groupE->checkState(0) == Qt::Unchecked && m_groupF->checkState(0) == Qt::Unchecked &&
m_groupG->checkState(0) == Qt::Unchecked && m_groupH->checkState(0) == Qt::Unchecked &&
m_groupI->checkState(0) == Qt::Unchecked && m_groupJ->checkState(0) == Qt::Unchecked &&
m_groupK->checkState(0) == Qt::Unchecked && m_groupL->checkState(0) == Qt::Unchecked &&
m_groupM->checkState(0) == Qt::Unchecked && m_groupN->checkState(0) == Qt::Unchecked &&
m_groupO->checkState(0) == Qt::Unchecked && m_groupP->checkState(0) == Qt::Unchecked &&
m_groupQ->checkState(0) == Qt::Unchecked)
{
return Qt::Checked;
}
if (m_groupA->checkState(0) == Qt::Checked &&
m_groupB->checkState(0) == Qt::Checked &&
m_groupC->checkState(0) == Qt::Checked &&
m_groupD->checkState(0) == Qt::Checked &&
m_groupE->checkState(0) == Qt::Checked &&
m_groupF->checkState(0) == Qt::Checked &&
m_groupG->checkState(0) == Qt::Checked &&
m_groupH->checkState(0) == Qt::Checked &&
m_groupI->checkState(0) == Qt::Checked &&
m_groupJ->checkState(0) == Qt::Checked &&
m_groupK->checkState(0) == Qt::Checked &&
m_groupL->checkState(0) == Qt::Checked &&
m_groupM->checkState(0) == Qt::Checked &&
m_groupN->checkState(0) == Qt::Checked &&
m_groupO->checkState(0) == Qt::Checked &&
m_groupP->checkState(0) == Qt::Checked &&
if (m_groupA->checkState(0) == Qt::Checked && m_groupB->checkState(0) == Qt::Checked &&
m_groupC->checkState(0) == Qt::Checked && m_groupD->checkState(0) == Qt::Checked &&
m_groupE->checkState(0) == Qt::Checked && m_groupF->checkState(0) == Qt::Checked &&
m_groupG->checkState(0) == Qt::Checked && m_groupH->checkState(0) == Qt::Checked &&
m_groupI->checkState(0) == Qt::Checked && m_groupJ->checkState(0) == Qt::Checked &&
m_groupK->checkState(0) == Qt::Checked && m_groupL->checkState(0) == Qt::Checked &&
m_groupM->checkState(0) == Qt::Checked && m_groupN->checkState(0) == Qt::Checked &&
m_groupO->checkState(0) == Qt::Checked && m_groupP->checkState(0) == Qt::Checked &&
m_groupQ->checkState(0) == Qt::Checked)
{
return Qt::Unchecked;

View File

@ -28,13 +28,14 @@
#include "dialogsavelayout.h"
#include "../core/vapplication.h"
#include "../ifc/exception/vexception.h"
#include "../vlayout/vlayoutexporter.h"
#include "../vmisc/vvalentinasettings.h"
#include "ui_dialogsavelayout.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../ifc/exception/vexception.h"
#include "../vlayout/vlayoutexporter.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"

View File

@ -35,20 +35,20 @@
#include <QDomNode>
#include <QHash>
#include <QLatin1String>
#include <QString>
#include <QtGlobal>
#include <QLocale>
#include <QLoggingCategory>
#include <functional>
#include <QString>
#include <QtCore/qcontainerfwd.h>
#include <QtGlobal>
#include <functional>
#include "../ifcdef.h"
#include "../qmuparser/qmudef.h"
#include "../vmisc/def.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/literals.h"
#include "../qmuparser/qmudef.h"
class QDomElement;
class QDomNode;
@ -84,6 +84,7 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
class VDomDocument : public QObject, public QDomDocument
{
Q_OBJECT // NOLINT
public:
static const QString AttrId;
static const QString AttrText;
@ -100,19 +101,18 @@ public:
virtual ~VDomDocument();
auto elementById(quint32 id, const QString &tagName = QString(), bool updateCache = true) -> QDomElement;
template <typename T>
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
template <typename T> void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
template <typename T>
void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
const std::function<bool(const T&)> &removeCondition) const;
const std::function<bool(const T &)> &removeCondition) const;
static auto GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue) -> quint32;
static auto GetParametrInt(const QDomElement &domElement, const QString &name, const QString &defValue) -> int;
static auto GetParametrBool(const QDomElement &domElement, const QString &name, const QString &defValue) -> bool;
static auto GetParametrUsage(const QDomElement &domElement, const QString &name) -> NodeUsage;
static void SetParametrUsage(QDomElement& domElement, const QString &name, const NodeUsage &value);
static void SetParametrUsage(QDomElement &domElement, const QString &name, const NodeUsage &value);
static auto GetParametrString(const QDomElement &domElement, const QString &name,
const QString &defValue = QString()) -> QString;
@ -120,7 +120,7 @@ public:
static auto GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue) -> qreal;
static auto GetParametrId(const QDomElement &domElement) -> quint32;
virtual void setXMLContent(const QString &fileName);
virtual void setXMLContent(const QString &fileName);
static auto UnitsHelpString() -> QString;
auto CreateElementWithText(const QString &tagName, const QString &text) -> QDomElement;
@ -131,7 +131,7 @@ public:
auto Patch() const -> QString;
virtual auto GetFormatVersionStr() const -> QString;
static auto GetFormatVersion(const QString &version) -> unsigned;
static void RemoveAllChildren(QDomElement &domElement);
static void RemoveAllChildren(QDomElement &domElement);
auto ParentNodeById(const quint32 &nodeId) -> QDomNode;
auto CloneNodeById(const quint32 &nodeId) -> QDomElement;
@ -140,9 +140,9 @@ public:
static auto SafeCopy(const QString &source, const QString &destination, QString &error) -> bool;
auto GetLabelTemplate(const QDomElement &element) const -> QVector<VLabelTemplateLine>;
void SetLabelTemplate(QDomElement &element, const QVector<VLabelTemplateLine> &lines);
void SetLabelTemplate(QDomElement &element, const QVector<VLabelTemplateLine> &lines);
void TestUniqueId() const;
void TestUniqueId() const;
void RefreshElementIdCache();
@ -153,7 +153,7 @@ protected:
auto setTagText(QDomElement &domElement, const QString &text) -> bool;
auto UniqueTag(const QString &tagName) const -> QDomElement;
auto UniqueTagText(const QString &tagName, const QString &defVal = QString()) const -> QString;
void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
void CollectId(const QDomElement &node, QVector<quint32> &vector) const;
static void ValidateVersion(const QString &version);
@ -164,7 +164,7 @@ private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(VDomDocument) // NOLINT
/** @brief Map used for finding element by id. */
QHash<quint32, QDomElement> m_elementIdCache;
QHash<quint32, QDomElement> m_elementIdCache;
QFutureWatcher<QHash<quint32, QDomElement>> *m_watcher;
static auto find(QHash<quint32, QDomElement> &cache, const QDomElement &node, quint32 id) -> bool;
@ -223,14 +223,14 @@ template <>
inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement, const QString &name,
const MeasurementsType &value) const
{
domElement.setAttribute(name, value == MeasurementsType::Multisize ? QStringLiteral("multisize") :
QStringLiteral("individual"));
domElement.setAttribute(name, value == MeasurementsType::Multisize ? QStringLiteral("multisize")
: QStringLiteral("individual"));
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
inline void VDomDocument::SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
const std::function<bool(const T&)> &removeCondition) const
const std::function<bool(const T &)> &removeCondition) const
{
not removeCondition(value) ? SetAttribute(domElement, name, value) : domElement.removeAttribute(name);
}

View File

@ -90,6 +90,10 @@
Class &operator=(Class &&) = delete;
#endif
#ifndef Q_DISABLE_ASSIGN
#define Q_DISABLE_ASSIGN(Class) Class &operator=(const Class &) = delete;
#endif
#ifndef Q_DISABLE_ASSIGN_MOVE
#define Q_DISABLE_ASSIGN_MOVE(Class) \
Q_DISABLE_ASSIGN(Class) \

View File

@ -34,7 +34,7 @@ namespace qmu
//---------------------------------------------------------------------------------------------------------------------
QmuFormulaBase::QmuFormulaBase()
:QmuParser()
: QmuParser()
{
}
@ -55,22 +55,25 @@ void QmuFormulaBase::InitCharSets()
{
QString symbolsStr;
{
//String with all unique symbols for supported alphabets.
//See script alphabets.py for generation and more information.
//Note. MSVC doesn't support normal string concatenation for long string. That's why we use QStringList in this
//case.
const QStringList symbols
{
QStringLiteral("ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥĦШҫ̆έجگĮаҳѕεشԶиһνԾрÃυلՆӝшËύՎїPÓՖXӛӟŞãզhëҔծpóӞնxßվāŁЃֆĉЋΊCŬđҐГΒęҘЛΚŘġҠУGا"),
QStringLiteral("հЫΪŪدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփӣІĈΏЎґĐΗЖҙĘȚΟОҡĠآΧЦتίЮұİزηжԸغẽοоÁՀقχц"),
QStringLiteral("ÉՈيюÑՐђӋіәťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċΌБӸēłΔҖЙŤěΜӜDСձģΤӰЩīņحάҮбưԳصδHйԻŇμӴсՃمτƠщՋόєLQŹՓŕÖYśÞaգĽ"),
QStringLiteral("æiŽիӓîqճöyջþĂօЄӦΉĊЌΑĒДҗјΙȘĚМΡéĵĢФūӚΩبĪЬүќαذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇΆčŃЏΎĕӯЗΖEțŮ"),
QStringLiteral("ĝПΞأĥĹЧΦثÆӳЯήIسŲԵзζԽпξكՅÄчφNMՍӌяώӢӲՕÔWÎŝÜџёźեägխoӒյôwĶBžսüЂĄև̈ЊČƏљΓВҕĔӮΛКĜΣТҥĤکΫЪƯخγвŅԴϊضλкԼ"),
QStringLiteral("ĴσтÅՄنϋъÍՌRӕՔZÝŜbåդjíլļrӵմӱzýռپêЅքćچΈЍďΐҒЕůėژșΘØҚНğńءΠFҢХħΨҪЭųįҶرΰҲеԷňعθҺнԿفπÂхՇψÊэšՏÒUəÚѝ"),
QStringLiteral("ŻşҤӑâeէŐımկòuշÕúտŔ")
};
// String with all unique symbols for supported alphabets.
// See script alphabets.py for generation and more information.
// Note. MSVC doesn't support normal string concatenation for long string. That's why we use QStringList in this
// case.
const QStringList symbols{
QStringLiteral(
"ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥĦШҫ̆έجگĮаҳѕεشԶиһνԾрÃυلՆӝшËύՎїPÓՖXӛӟŞãզhëҔծpóӞնxßվāŁЃֆĉЋΊCŬđҐГΒęҘЛΚŘġҠУGا"),
QStringLiteral("հЫΪŪدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփӣІĈΏЎґĐΗЖҙĘȚΟОҡĠآΧЦتίЮұİزηжԸغẽοоÁՀقχц"),
QStringLiteral(
"ÉՈيюÑՐђӋіәťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċΌБӸēłΔҖЙŤěΜӜDСձģΤӰЩīņحάҮбưԳصδHйԻŇμӴсՃمτƠщՋόєLQŹՓŕÖYśÞaգĽ"),
QStringLiteral(
"æiŽիӓîqճöyջþĂօЄӦΉĊЌΑĒДҗјΙȘĚМΡéĵĢФūӚΩبĪЬүќαذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇΆčŃЏΎĕӯЗΖEțŮ"),
QStringLiteral(
"ĝПΞأĥĹЧΦثÆӳЯήIسŲԵзζԽпξكՅÄчφNMՍӌяώӢӲՕÔWÎŝÜџёźեägխoӒյôwĶBžսüЂĄև̈ЊČƏљΓВҕĔӮΛКĜΣТҥĤکΫЪƯخγвŅԴϊضλкԼ"),
QStringLiteral(
"ĴσтÅՄنϋъÍՌRӕՔZÝŜbåդjíլļrӵմӱzýռپêЅքćچΈЍďΐҒЕůėژșΘØҚНğńءΠFҢХħΨҪЭųįҶرΰҲеԷňعθҺнԿفπÂхՇψÊэšՏÒUəÚѝ"),
QStringLiteral("ŻşҤӑâeէŐımկòuշÕúտŔ")};
symbolsStr = symbols.join(QString());
symbolsStr = symbols.join(QString());
}
INIT_LOCALE_VARIABLES(m_locale);
@ -153,7 +156,7 @@ void QmuFormulaBase::SetSepForTr(bool osSeparator, bool fromUser)
}
}
SetSepForEval();//Same separators (internal) as for eval.
SetSepForEval(); // Same separators (internal) as for eval.
}
//---------------------------------------------------------------------------------------------------------------------
@ -177,13 +180,13 @@ void QmuFormulaBase::SetSepForEval()
* @param map map with tokens
* @param val token that need delete
*/
void QmuFormulaBase::RemoveAll(QMap<vsizetype, QString> &map, const QString &val)
void QmuFormulaBase::RemoveAll(QMap<qmusizetype, QString> &map, const QString &val)
{
const QList<vsizetype> listKeys = map.keys(val);//Take all keys that contain token.
const QList<qmusizetype> listKeys = map.keys(val); // Take all keys that contain token.
for (auto key : listKeys)
{
map.remove(key);
}
}
}// namespace qmu
} // namespace qmu

View File

@ -43,7 +43,7 @@ public:
void SetSepForTr(bool osSeparator, bool fromUser);
static void RemoveAll(QMap<vsizetype, QString> &map, const QString &val);
static void RemoveAll(QMap<qmusizetype, QString> &map, const QString &val);
protected:
static auto AddVariable(const QString &a_szName, void *a_pUserData) -> qreal *;

View File

@ -43,13 +43,13 @@ QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wunused-variable")
QT_WARNING_DISABLE_CLANG("-Wunused-variable")
//static auto endl Q_DECL_UNUSED = ::endl; // NOLINT
//static auto flush Q_DECL_UNUSED = ::flush; // NOLINT
// static auto endl Q_DECL_UNUSED = ::endl; // NOLINT
// static auto flush Q_DECL_UNUSED = ::flush; // NOLINT
static auto dec Q_DECL_UNUSED = ::dec; // NOLINT
//static auto SkipEmptyParts Q_DECL_UNUSED = QString::SkipEmptyParts; // NOLINT
// static auto SkipEmptyParts Q_DECL_UNUSED = QString::SkipEmptyParts; // NOLINT
QT_WARNING_POP
} // namespace Qt
} // namespace Qt
#endif

File diff suppressed because it is too large Load Diff

View File

@ -16,8 +16,8 @@
#include <cstring>
#include "drw_entities.h"
#include "drw_objects.h"
#include "drw_header.h"
#include "drw_objects.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
@ -34,27 +34,27 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods")
*
* @author Rallaz
*/
class DRW_Interface {
class DRW_Interface
{
public:
DRW_Interface() {
}
DRW_Interface() {}
virtual ~DRW_Interface() = default;
/** Called when header is parsed. */
virtual void addHeader(const DRW_Header *) { }
virtual void addHeader(const DRW_Header *) {}
/** Called for every line Type. */
virtual void addLType(const DRW_LType &) { }
virtual void addLType(const DRW_LType &) {}
/** Called for every layer. */
virtual void addLayer(const DRW_Layer &) { }
virtual void addLayer(const DRW_Layer &) {}
/** Called for every dim style. */
virtual void addDimStyle(const DRW_Dimstyle &) { }
virtual void addDimStyle(const DRW_Dimstyle &) {}
/** Called for every VPORT table. */
virtual void addVport(const DRW_Vport &) { }
virtual void addVport(const DRW_Vport &) {}
/** Called for every text style. */
virtual void addTextStyle(const DRW_Textstyle &) { }
virtual void addTextStyle(const DRW_Textstyle &) {}
/** Called for every AppId entry. */
virtual void addAppId(const DRW_AppId &) { }
virtual void addAppId(const DRW_AppId &) {}
/**
* Called for every block. Note: all entities added after this
@ -62,143 +62,142 @@ public:
*
* @see endBlock()
*/
virtual void addBlock(const DRW_Block &) { }
virtual void addBlock(const DRW_Block &) {}
/** Called to end the current block */
virtual void endBlock() { }
virtual void endBlock() {}
/** Called for every point */
virtual void addPoint(const DRW_Point &) { }
virtual void addPoint(const DRW_Point &) {}
/** Called for every line */
virtual void addLine(const DRW_Line &) { }
virtual void addLine(const DRW_Line &) {}
/** Called for every ray */
virtual void addRay(const DRW_Ray &) { }
virtual void addRay(const DRW_Ray &) {}
/** Called for every xline */
virtual void addXline(const DRW_Xline &) { }
virtual void addXline(const DRW_Xline &) {}
/** Called for every arc */
virtual void addArc(const DRW_Arc &) { }
virtual void addArc(const DRW_Arc &) {}
/** Called for every circle */
virtual void addCircle(const DRW_Circle &) { }
virtual void addCircle(const DRW_Circle &) {}
/** Called for every ellipse */
virtual void addEllipse(const DRW_Ellipse &) { }
virtual void addEllipse(const DRW_Ellipse &) {}
/** Called for every lwpolyline */
virtual void addLWPolyline(const DRW_LWPolyline &) { }
virtual void addLWPolyline(const DRW_LWPolyline &) {}
/** Called for every polyline start */
virtual void addPolyline(const DRW_Polyline &) { }
virtual void addPolyline(const DRW_Polyline &) {}
/** Called for every spline */
virtual void addSpline(const DRW_Spline *) { }
virtual void addSpline(const DRW_Spline *) {}
/** Called for every spline knot value */
virtual void addKnot(const DRW_Entity &) { }
/** Called for every spline knot value */
virtual void addKnot(const DRW_Entity &) {}
/** Called for every insert. */
virtual void addInsert(const DRW_Insert &) { }
virtual void addInsert(const DRW_Insert &) {}
/** Called for every trace start */
virtual void addTrace(const DRW_Trace &) { }
virtual void addTrace(const DRW_Trace &) {}
/** Called for every 3dface start */
virtual void add3dFace(const DRW_3Dface &) { }
virtual void add3dFace(const DRW_3Dface &) {}
/** Called for every solid start */
virtual void addSolid(const DRW_Solid &) { }
virtual void addSolid(const DRW_Solid &) {}
/** Called for every Multi Text entity. */
virtual void addMText(const DRW_MText &) { }
virtual void addMText(const DRW_MText &) {}
/** Called for every Text entity. */
virtual void addText(const DRW_Text &) { }
virtual void addText(const DRW_Text &) {}
/**
* Called for every aligned dimension entity.
*/
virtual void addDimAlign(const DRW_DimAligned *) { }
virtual void addDimAlign(const DRW_DimAligned *) {}
/**
* Called for every linear or rotated dimension entity.
*/
virtual void addDimLinear(const DRW_DimLinear *) { }
virtual void addDimLinear(const DRW_DimLinear *) {}
/**
/**
* Called for every radial dimension entity.
*/
virtual void addDimRadial(const DRW_DimRadial *) { }
virtual void addDimRadial(const DRW_DimRadial *) {}
/**
/**
* Called for every diametric dimension entity.
*/
virtual void addDimDiametric(const DRW_DimDiametric *) { }
virtual void addDimDiametric(const DRW_DimDiametric *) {}
/**
/**
* Called for every angular dimension (2 lines version) entity.
*/
virtual void addDimAngular(const DRW_DimAngular *) { }
virtual void addDimAngular(const DRW_DimAngular *) {}
/**
/**
* Called for every angular dimension (3 points version) entity.
*/
virtual void addDimAngular3P(const DRW_DimAngular3p *) { }
virtual void addDimAngular3P(const DRW_DimAngular3p *) {}
/**
* Called for every ordinate dimension entity.
*/
virtual void addDimOrdinate(const DRW_DimOrdinate *) { }
virtual void addDimOrdinate(const DRW_DimOrdinate *) {}
/**
* Called for every leader start.
*/
virtual void addLeader(const DRW_Leader *) { }
* Called for every leader start.
*/
virtual void addLeader(const DRW_Leader *) {}
/**
* Called for every hatch entity.
*/
virtual void addHatch(const DRW_Hatch *) { }
/**
* Called for every hatch entity.
*/
virtual void addHatch(const DRW_Hatch *) {}
/**
* Called for every viewport entity.
*/
virtual void addViewport(const DRW_Viewport &) { }
virtual void addViewport(const DRW_Viewport &) {}
/**
* Called for every image entity.
*/
virtual void addImage(const DRW_Image *) { }
* Called for every image entity.
*/
virtual void addImage(const DRW_Image *) {}
/**
* Called for every image definition.
*/
virtual void linkImage(const DRW_ImageDef *) { }
/**
* Called for every image definition.
*/
virtual void linkImage(const DRW_ImageDef *) {}
/**
* Called for every comment in the DXF file (code 999).
*/
virtual void addComment(const char *) { }
virtual void addComment(const char *) {}
/**
* Called for PLOTSETTINGS object definition.
*/
virtual void addPlotSettings(const DRW_PlotSettings *) {}
virtual void writeHeader(DRW_Header &) { }
virtual void writeBlocks() { }
virtual void writeBlockRecords() { }
virtual void writeEntities() { }
virtual void writeLTypes() { }
virtual void writeLayers() { }
virtual void writeTextstyles() { }
virtual void writeVports() { }
virtual void writeDimstyles() { }
virtual void writeHeader(DRW_Header &) {}
virtual void writeBlocks() {}
virtual void writeBlockRecords() {}
virtual void writeEntities() {}
virtual void writeLTypes() {}
virtual void writeLayers() {}
virtual void writeTextstyles() {}
virtual void writeVports() {}
virtual void writeDimstyles() {}
virtual void writeObjects() {}
virtual void writeAppId() { }
virtual void writeAppId() {}
};
QT_WARNING_POP

File diff suppressed because it is too large Load Diff

View File

@ -29,17 +29,17 @@
#ifndef VABSTRACTPIECE_H
#define VABSTRACTPIECE_H
#include <QtGlobal>
#include <QSharedDataPointer>
#include <QPointF>
#include <QDebug>
#include <QCoreApplication>
#include <QDebug>
#include <QPainterPath>
#include <QPointF>
#include <QSharedDataPointer>
#include <QtGlobal>
#include "../vmisc/compatibility.h"
#include "../vgeometry/vgobject.h"
#include "vsapoint.h"
#include "../vmisc/compatibility.h"
#include "vrawsapoint.h"
#include "vsapoint.h"
class VAbstractPieceData;
class QPainterPath;
@ -48,11 +48,12 @@ class VContainer;
class VRawSAPoint;
class VLayoutPlaceLabel;
using PlaceLabelImg = QVector<QVector<VLayoutPoint> >;
using PlaceLabelImg = QVector<QVector<VLayoutPoint>>;
class VAbstractPiece
{
Q_DECLARE_TR_FUNCTIONS(VAbstractPiece) // NOLINT
public:
VAbstractPiece();
VAbstractPiece(const VAbstractPiece &piece);
@ -109,28 +110,27 @@ public:
static auto Equidistant(QVector<VSAPoint> points, qreal width, const QString &name) -> QVector<VLayoutPoint>;
static auto SumTrapezoids(const QVector<QPointF> &points) -> qreal;
template <class T>
static auto CheckLoops(QVector<T> points) -> QVector<T>;
template <class T> static auto CheckLoops(QVector<T> points) -> QVector<T>;
static auto EkvPoint(QVector<VRawSAPoint> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1,
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width,
bool *needRollback = nullptr) -> QVector<VRawSAPoint>;
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width, bool *needRollback = nullptr)
-> QVector<VRawSAPoint>;
static auto ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width) -> QLineF;
static auto IsAllowanceValid(const QVector<QPointF> &base, const QVector<QPointF> &allowance) -> bool;
template <class T>
static auto IsInsidePolygon(const QVector<T> &path, const QVector<T> &polygon,
qreal accuracy = accuracyPointOnLine) -> bool;
static auto IsInsidePolygon(const QVector<T> &path, const QVector<T> &polygon, qreal accuracy = accuracyPointOnLine)
-> bool;
template <class T>
static auto CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast = true) -> QVector<T>;
static auto RollbackSeamAllowance(QVector<VRawSAPoint> points, const QLineF &cuttingEdge,
bool *success) -> QVector<VRawSAPoint>;
static auto RollbackSeamAllowance(QVector<VRawSAPoint> points, const QLineF &cuttingEdge, bool *success)
-> QVector<VRawSAPoint>;
static auto GrainlineMainLine(const VGrainlineData &geom, const VContainer *pattern,
const QRectF &boundingRect) -> QLineF;
static auto GrainlineMainLine(const VGrainlineData &geom, const VContainer *pattern, const QRectF &boundingRect)
-> QLineF;
friend auto operator<< (QDataStream& dataStream, const VAbstractPiece& piece) -> QDataStream&;
friend auto operator>> (QDataStream& dataStream, VAbstractPiece& piece) -> QDataStream&;
friend auto operator<<(QDataStream &dataStream, const VAbstractPiece &piece) -> QDataStream &;
friend auto operator>>(QDataStream &dataStream, VAbstractPiece &piece) -> QDataStream &;
static auto PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLabelImg;
static auto LabelShapePath(const VLayoutPlaceLabel &label) -> QPainterPath;
@ -144,19 +144,17 @@ protected:
template <class T>
static auto CheckPointOnLine(QVector<T> &points, const T &iPoint, const T &prevPoint, const T &nextPoint) -> bool;
static auto IsItemContained(const QRectF &parentBoundingRect, const QVector<QPointF> &shape, qreal &dX,
qreal &dY) -> bool;
static auto IsItemContained(const QRectF &parentBoundingRect, const QVector<QPointF> &shape, qreal &dX, qreal &dY)
-> bool;
static auto CorrectPosition(const QRectF &parentBoundingRect, QVector<QPointF> points) -> QVector<QPointF>;
static auto FindGrainlineGeometry(const VGrainlineData& geom, const VContainer *pattern, qreal &length,
static auto FindGrainlineGeometry(const VGrainlineData &geom, const VContainer *pattern, qreal &length,
qreal &rotationAngle, QPointF &pos) -> bool;
template <class T>
static auto ComparePoints(QVector<T> &points, const T &p1, const T &p2, qreal accuracy) -> bool;
template <class T>
static auto CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void;
template <class T>
static auto CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>;
template <class T> static auto ComparePoints(QVector<T> &points, const T &p1, const T &p2, qreal accuracy) -> bool;
template <class T> static auto CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void;
template <class T> static auto CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>;
template <class T>
static auto IntersectionPoint(QPointF crosPoint, const T &l1p1, const T &l1p2, const T &l2p1, const T &l2p2) -> T;
private:
QSharedDataPointer<VAbstractPieceData> d;
};
@ -210,17 +208,17 @@ inline auto VAbstractPiece::CheckPointOnLine<QPointF>(QVector<QPointF> &points,
template <class T>
inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast) -> QVector<T>
{
// DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
if (points.size()<4)//Better don't check if only three points. We can destroy equidistant.
// DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
if (points.size() < 4) // Better don't check if only three points. We can destroy equidistant.
{
qDebug()<<"Only three points.";
qDebug() << "Only three points.";
return points;
}
//Clear equivalent points
// Clear equivalent points
QVector<T> buf1 = RemoveDublicates(points, removeFirstAndLast);
if (buf1.size()<3)
if (buf1.size() < 3)
{
return buf1;
}
@ -229,10 +227,10 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, b
vsizetype next = -1;
QVector<T> buf2;
//Remove point on line
// Remove point on line
for (qint32 i = 0; i < buf1.size(); ++i)
{// In this case we alwayse will have bounded intersection, so all is need is to check if point is on line.
// Unfortunatelly QLineF::intersect can't be used in this case because of the floating-point accuraccy problem.
{ // In this case we alwayse will have bounded intersection, so all is need is to check if point is on line.
// Unfortunatelly QLineF::intersect can't be used in this case because of the floating-point accuraccy problem.
if (prev == -1)
{
if (i == 0)
@ -247,7 +245,7 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, b
}
else
{
prev = i-1;
prev = i - 1;
}
}
@ -263,7 +261,7 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, b
}
else
{
next = i+1;
next = i + 1;
}
const T &iPoint = buf1.at(i);
@ -283,7 +281,7 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, b
buf2 = RemoveDublicates(buf2, false);
// DumpVector(buf2, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
// DumpVector(buf2, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
return buf2;
}
@ -306,11 +304,11 @@ inline auto VAbstractPiece::RemoveDublicates(const QVector<T> &points, bool remo
for (int i = 0; i < points.size(); ++i)
{
for (int j = i+1; j < points.size(); ++j)
for (int j = i + 1; j < points.size(); ++j)
{
if (not ComparePoints(p, points.at(i), points.at(j), accuracy))
{
i = j-1;
i = j - 1;
break;
}
}
@ -403,16 +401,15 @@ inline auto VAbstractPiece::ComparePoints<QPointF>(QVector<QPointF> &points, con
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void
template <class T> inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void
{
if (points.isEmpty())
{
return;
}
const T& first = ConstFirst(points);
const T& last = ConstLast(points);
const T &first = ConstFirst(points);
const T &last = ConstLast(points);
qreal testAccuracy = accuracy;
if (last.TurnPoint())
@ -437,16 +434,15 @@ inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<VRawSAPoint> &points, qreal accuracy) -> void
template <> inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<VRawSAPoint> &points, qreal accuracy) -> void
{
if (points.isEmpty())
{
return;
}
const VRawSAPoint& first = ConstFirst(points);
const VRawSAPoint& last = ConstLast(points);
const VRawSAPoint &first = ConstFirst(points);
const VRawSAPoint &last = ConstLast(points);
qreal testAccuracy = accuracy;
if ((first.Primary() && last.Primary()) || last.TurnPoint())
@ -493,7 +489,7 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVecto
for (auto i = 0; i < path.count(); ++i)
{
int nextI = -1;
if (i < path.count()-1)
if (i < path.count() - 1)
{
nextI = i + 1;
}
@ -511,7 +507,7 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVecto
for (auto j = 0; j < polygon.count(); ++j)
{
int nextJ = -1;
if (j < polygon.count()-1)
if (j < polygon.count() - 1)
{
nextJ = j + 1;
}
@ -529,13 +525,11 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVecto
QPointF crosPoint;
const auto type = Intersects(baseSegment, allowanceSegment, &crosPoint);
if (type == QLineF::BoundedIntersection
&& not VFuzzyComparePoints(baseSegment.p1(), crosPoint, accuracy)
&& not VFuzzyComparePoints(baseSegment.p2(), crosPoint, accuracy)
&& not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2(),
accuracy)
&& not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2(),
accuracy))
if (type == QLineF::BoundedIntersection && not VFuzzyComparePoints(baseSegment.p1(), crosPoint, accuracy) &&
not VFuzzyComparePoints(baseSegment.p2(), crosPoint, accuracy) &&
not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2(),
accuracy) &&
not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2(), accuracy))
{
return false;
}
@ -544,7 +538,8 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVecto
// Just instersection edges is not enough. The base must be inside of the allowance.
QPolygonF allowancePolygon(polygon);
return std::all_of(path.begin(), path.end(), [allowancePolygon](const T &point)
return std::all_of(path.begin(), path.end(),
[allowancePolygon](const T &point)
{ return allowancePolygon.containsPoint(point, Qt::WindingFill); });
}
@ -554,10 +549,9 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVecto
* @param points vector of points of equidistant.
* @return vector of points of equidistant.
*/
template <class T>
inline auto VAbstractPiece::CheckLoops(QVector<T> points) -> QVector<T>
template <class T> inline auto VAbstractPiece::CheckLoops(QVector<T> points) -> QVector<T>
{
// DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
// DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
/*If we got less than 4 points no need seek loops.*/
if (points.size() < 4)
@ -578,13 +572,12 @@ inline auto VAbstractPiece::CheckLoops(QVector<T> points) -> QVector<T>
}
}
// DumpVector(ekvPoints, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
// DumpVector(ekvPoints, QStringLiteral("output.json.XXXXXX")); // Uncomment for dumping test data
return points;
}
//---------------------------------------------------------------------------------------------------------------------
template<class T>
inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>
template <class T> inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>
{
loopFound = false;
@ -598,23 +591,28 @@ inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound)
{
/*Last three points no need to check.*/
/*Triangle can not contain a loop*/
if (loopFound || i > points.size()-4)
if (loopFound || i > points.size() - 4)
{
ekvPoints.append(points.at(i));
continue;
}
enum LoopIntersectType { NoIntersection, BoundedIntersection, ParallelIntersection };
enum LoopIntersectType
{
NoIntersection,
BoundedIntersection,
ParallelIntersection
};
QPointF crosPoint;
LoopIntersectType status = NoIntersection;
const QLineF line1(points.at(i), points.at(i+1));
const QLineF line1(points.at(i), points.at(i + 1));
const int limit = pathClosed && i == 0 ? 2 : 1;
qint32 j;
for (j = i+2; j < points.size()-limit; ++j)
for (j = i + 2; j < points.size() - limit; ++j)
{
QLineF line2(points.at(j), points.at(j+1));
QLineF line2(points.at(j), points.at(j + 1));
const QLineF::IntersectType intersect = Intersects(line1, line2, &crosPoint);
if (intersect == QLineF::NoIntersection)
@ -622,7 +620,7 @@ inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound)
// i.e. they are parallel. But parallel also mean they can be on the same line.
// Method IsLineSegmentOnLineSegment will check it.
if (VGObject::IsLineSegmentOnLineSegment(line1, line2))
{// Now we really sure that segments are on the same line and have real intersections.
{ // Now we really sure that segments are on the same line and have real intersections.
status = ParallelIntersection;
break;
}
@ -636,32 +634,33 @@ inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound)
switch (status)
{
case ParallelIntersection:
/*We have found a loop.*/
ekvPoints.append(points.at(i));
ekvPoints.append(points.at(j+1));
i = j+1; // Skip a loop
loopFound = true;
break;
case BoundedIntersection:
ekvPoints.append(points.at(i));
ekvPoints.append(IntersectionPoint(crosPoint, points.at(i), points.at(i+1), points.at(j), points.at(j+1)));
i = j;
loopFound = true;
break;
case NoIntersection:
/*We have not found loop.*/
ekvPoints.append(points.at(i));
break;
default:
break;
case ParallelIntersection:
/*We have found a loop.*/
ekvPoints.append(points.at(i));
ekvPoints.append(points.at(j + 1));
i = j + 1; // Skip a loop
loopFound = true;
break;
case BoundedIntersection:
ekvPoints.append(points.at(i));
ekvPoints.append(
IntersectionPoint(crosPoint, points.at(i), points.at(i + 1), points.at(j), points.at(j + 1)));
i = j;
loopFound = true;
break;
case NoIntersection:
/*We have not found loop.*/
ekvPoints.append(points.at(i));
break;
default:
break;
}
}
return ekvPoints;
}
//---------------------------------------------------------------------------------------------------------------------
template<class T>
template <class T>
inline auto VAbstractPiece::IntersectionPoint(QPointF crosPoint, const T &l1p1, const T &l1p2, const T &l2p1,
const T &l2p2) -> T
{
@ -683,7 +682,7 @@ inline auto VAbstractPiece::IntersectionPoint(QPointF crosPoint, const T &l1p1,
}
//---------------------------------------------------------------------------------------------------------------------
template<>
template <>
inline auto VAbstractPiece::IntersectionPoint<QPointF>(QPointF crosPoint, const QPointF & /*unused*/,
const QPointF & /*unused*/, const QPointF & /*unused*/,
const QPointF & /*unused*/) -> QPointF

View File

@ -33,42 +33,42 @@
#include <QRectF>
#include <QThreadPool>
#include "../vmisc/def.h"
#include "../vmisc/vmath.h"
#include "../vmisc/compatibility.h"
#include "vlayoutpiece.h"
#include "vlayoutpaper.h"
#include "../ifc/exception/vexceptionterminatedposition.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/def.h"
#include "vlayoutpaper.h"
#include "vlayoutpiece.h"
//---------------------------------------------------------------------------------------------------------------------
VLayoutGenerator::VLayoutGenerator(QObject *parent)
: QObject(parent),
papers(),
bank(new VBank()),
paperHeight(0),
paperWidth(0),
margins(),
usePrinterFields(true),
: QObject(parent),
papers(),
bank(new VBank()),
paperHeight(0),
paperWidth(0),
margins(),
usePrinterFields(true),
#ifdef Q_CC_MSVC
// See https://stackoverflow.com/questions/15750917/initializing-stdatomic-bool
stopGeneration(ATOMIC_VAR_INIT(false)),
// See https://stackoverflow.com/questions/15750917/initializing-stdatomic-bool
stopGeneration(ATOMIC_VAR_INIT(false)),
#else
stopGeneration(false),
stopGeneration(false),
#endif
state(LayoutErrors::NoError),
shift(0),
rotate(true),
followGrainline(false),
rotationNumber(2),
autoCropLength(false),
autoCropWidth(false),
saveLength(false),
unitePages(false),
stripOptimizationEnabled(false),
multiplier(1),
stripOptimization(false),
textAsPaths(false)
{}
state(LayoutErrors::NoError),
shift(0),
rotate(true),
followGrainline(false),
rotationNumber(2),
autoCropLength(false),
autoCropWidth(false),
saveLength(false),
unitePages(false),
stripOptimizationEnabled(false),
multiplier(1),
stripOptimization(false),
textAsPaths(false)
{
}
//---------------------------------------------------------------------------------------------------------------------
VLayoutGenerator::~VLayoutGenerator()
@ -149,10 +149,10 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
auto SetStrip = [this, b](int &side)
{
if (side >= b*2)
if (side >= b * 2)
{
stripOptimizationEnabled = true;
side = qFloor(side / qFloor(side/b));
side = qFloor(side / qFloor(side / b));
}
};
@ -224,7 +224,7 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
{
return;
}
} while(bank->LeftToArrange() > 0);
} while (bank->LeftToArrange() > 0);
if (stopGeneration.load())
{
@ -329,7 +329,7 @@ auto VLayoutGenerator::GetGlobalContours() const -> QList<QGraphicsItem *>
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutGenerator::GetAllDetailsItems() const -> QList<QList<QGraphicsItem *>>
{
QList<QList<QGraphicsItem *> > list;
QList<QList<QGraphicsItem *>> list;
list.reserve(papers.count());
for (const auto &paper : papers)
{
@ -341,7 +341,7 @@ auto VLayoutGenerator::GetAllDetailsItems() const -> QList<QList<QGraphicsItem *
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutGenerator::GetAllDetails() const -> QVector<QVector<VLayoutPiece>>
{
QVector<QVector<VLayoutPiece> > list;
QVector<QVector<VLayoutPiece>> list;
list.reserve(papers.count());
for (const auto &paper : papers)
{
@ -459,9 +459,9 @@ void VLayoutGenerator::GatherPages()
{
int paperHeight = qRound(rec.y() + rec.height());
if (i != papers.size()-1)
if (i != papers.size() - 1)
{
paperHeight += qRound(bank->GetLayoutWidth()*2);
paperHeight += qRound(bank->GetLayoutWidth() * 2);
}
if (length + paperHeight <= PageHeight())
@ -472,7 +472,7 @@ void VLayoutGenerator::GatherPages()
else
{
length = 0; // Start new paper
++j;// New paper
++j; // New paper
UniteDetails(j, nDetails, length, i);
length += paperHeight;
}
@ -481,9 +481,9 @@ void VLayoutGenerator::GatherPages()
{
int paperWidth = qRound(rec.x() + rec.width());
if (i != papers.size()-1)
if (i != papers.size() - 1)
{
paperWidth += qRound(bank->GetLayoutWidth()*2);
paperWidth += qRound(bank->GetLayoutWidth() * 2);
}
if (length + paperWidth <= PageWidth())
@ -494,7 +494,7 @@ void VLayoutGenerator::GatherPages()
else
{
length = 0; // Start new paper
++j;// New paper
++j; // New paper
UniteDetails(j, nDetails, length, i);
length += paperWidth;
}
@ -534,7 +534,7 @@ void VLayoutGenerator::OptimizeWidth()
newDetails.reserve(details.size());
for (auto &d : details)
{
IsPortrait() ? d.Translate(-rec.x()+1, 0) : d.Translate(0, -rec.y()+1);
IsPortrait() ? d.Translate(-rec.x() + 1, 0) : d.Translate(0, -rec.y() + 1);
newDetails.append(d);
}
@ -551,7 +551,7 @@ void VLayoutGenerator::UnitePages()
}
QList<qreal> papersLength;
QList<QList<VLayoutPiece> > nDetails;
QList<QList<VLayoutPiece>> nDetails;
qreal length = 0;
int j = 0; // papers count
@ -570,9 +570,9 @@ void VLayoutGenerator::UnitePages()
paperHeight = papers.at(i).GetHeight();
}
if (i != papers.size()-1)
if (i != papers.size() - 1)
{
paperHeight = qRound(paperHeight + bank->GetLayoutWidth()*2);
paperHeight = qRound(paperHeight + bank->GetLayoutWidth() * 2);
}
if (length + paperHeight <= QIMAGE_MAX)
@ -584,7 +584,7 @@ void VLayoutGenerator::UnitePages()
else
{
length = 0; // Start new paper
++j;// New paper
++j; // New paper
UniteDetails(j, nDetails, length, i);
length += paperHeight;
UnitePapers(j, papersLength, length);
@ -603,9 +603,9 @@ void VLayoutGenerator::UnitePages()
paperWidth = papers.at(i).GetWidth();
}
if (i != papers.size()-1)
if (i != papers.size() - 1)
{
paperWidth = qRound(paperWidth + bank->GetLayoutWidth()*2);
paperWidth = qRound(paperWidth + bank->GetLayoutWidth() * 2);
}
if (length + paperWidth <= QIMAGE_MAX)
@ -617,7 +617,7 @@ void VLayoutGenerator::UnitePages()
else
{
length = 0; // Start new paper
++j;// New paper
++j; // New paper
UniteDetails(j, nDetails, length, i);
length += paperWidth;
UnitePapers(j, papersLength, length);
@ -629,8 +629,8 @@ void VLayoutGenerator::UnitePages()
nPapers.reserve(nDetails.size());
for (int i = 0; i < nDetails.size(); ++i)
{
const int height = IsPortrait() ? qRound(papersLength.at(i)+accuracyPointOnLine*4) : PageHeight();
const int width = IsPortrait() ? PageWidth() : qRound(papersLength.at(i)+accuracyPointOnLine*4);
const int height = IsPortrait() ? qRound(papersLength.at(i) + accuracyPointOnLine * 4) : PageHeight();
const int width = IsPortrait() ? PageWidth() : qRound(papersLength.at(i) + accuracyPointOnLine * 4);
VLayoutPaper paper(height, width, bank->GetLayoutWidth());
paper.SetShift(shift);
@ -649,10 +649,10 @@ void VLayoutGenerator::UnitePages()
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::UniteDetails(int j, QList<QList<VLayoutPiece> > &nDetails, qreal length, int i) const
void VLayoutGenerator::UniteDetails(int j, QList<QList<VLayoutPiece>> &nDetails, qreal length, int i) const
{
if ((j == 0 && nDetails.isEmpty()) || j >= nDetails.size())
{//First or new details in paper
{ // First or new details in paper
nDetails.insert(j, MoveDetails(length, papers.at(i).GetDetails()));
}
else
@ -708,7 +708,7 @@ auto VLayoutGenerator::MasterPage() const -> VLayoutPaper
return ConstFirst(papers);
}
QList<QList<VLayoutPiece> > nDetails;
QList<QList<VLayoutPiece>> nDetails;
qreal length = 0;
const int j = 0; // papers count. Always 1.
@ -727,9 +727,9 @@ auto VLayoutGenerator::MasterPage() const -> VLayoutPaper
paperHeight = papers.at(i).GetHeight();
}
if (i != papers.size()-1)
if (i != papers.size() - 1)
{
paperHeight = qRound(paperHeight + bank->GetLayoutWidth()*2);
paperHeight = qRound(paperHeight + bank->GetLayoutWidth() * 2);
}
UniteDetails(j, nDetails, length, i);
@ -748,9 +748,9 @@ auto VLayoutGenerator::MasterPage() const -> VLayoutPaper
paperWidth = papers.at(i).GetWidth();
}
if (i != papers.size()-1)
if (i != papers.size() - 1)
{
paperWidth = qRound(paperWidth + bank->GetLayoutWidth()*2);
paperWidth = qRound(paperWidth + bank->GetLayoutWidth() * 2);
}
UniteDetails(j, nDetails, length, i);
@ -758,8 +758,8 @@ auto VLayoutGenerator::MasterPage() const -> VLayoutPaper
}
}
const int height = IsPortrait() ? qRound(length+accuracyPointOnLine*4) : PageHeight();
const int width = IsPortrait() ? PageWidth() : qRound(length+accuracyPointOnLine*4);
const int height = IsPortrait() ? qRound(length + accuracyPointOnLine * 4) : PageHeight();
const int width = IsPortrait() ? PageWidth() : qRound(length + accuracyPointOnLine * 4);
VLayoutPaper paper(height, width, bank->GetLayoutWidth());
paper.SetShift(shift);

View File

@ -28,10 +28,10 @@
#ifndef VLAYOUTPOINT_H
#define VLAYOUTPOINT_H
#include <QtGlobal>
#include <QPointF>
#include <QMetaType>
#include <QPointF>
#include <QVector>
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
@ -62,20 +62,19 @@ private:
bool m_curvePoint{false};
};
Q_DECLARE_METATYPE(VLayoutPoint) // NOLINT
Q_DECLARE_METATYPE(VLayoutPoint) // NOLINT
Q_DECLARE_TYPEINFO(VLayoutPoint, Q_MOVABLE_TYPE); // NOLINT
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline auto CastTo(const QVector<T> &points, QVector<T> &casted) -> void
template <class T> inline auto CastTo(const QVector<T> &points, QVector<T> &casted) -> void
{
Q_UNUSED(points)
Q_UNUSED(casted)
}
//---------------------------------------------------------------------------------------------------------------------
//upcast
template <class Derived, class Base, typename std::enable_if<std::is_base_of<Base, Derived>::value>::type* = nullptr>
// upcast
template <class Derived, class Base, typename std::enable_if<std::is_base_of<Base, Derived>::value>::type * = nullptr>
inline auto CastTo(const QVector<Base> &points, QVector<Derived> &casted) -> void
{
casted.clear();
@ -87,8 +86,8 @@ inline auto CastTo(const QVector<Base> &points, QVector<Derived> &casted) -> voi
}
//---------------------------------------------------------------------------------------------------------------------
//downcast
template <class Base, class Derived, typename std::enable_if<std::is_base_of<Base, Derived>::value>::type* = nullptr>
// downcast
template <class Base, class Derived, typename std::enable_if<std::is_base_of<Base, Derived>::value>::type * = nullptr>
inline auto CastTo(const QVector<Derived> &points, QVector<Base> &casted) -> void
{
casted.clear();
@ -109,13 +108,15 @@ auto operator>>(QDataStream &, VLayoutPoint &) -> QDataStream &;
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VLayoutPoint::VLayoutPoint(qreal xpos, qreal ypos)
: QPointF(xpos, ypos)
{}
: QPointF(xpos, ypos)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VLayoutPoint::VLayoutPoint(QPointF p)
: QPointF(p)
{}
: QPointF(p)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VLayoutPoint::TurnPoint() const -> bool

View File

@ -27,31 +27,30 @@
*************************************************************************/
#include "vprintlayout.h"
#include <QPrinterInfo>
#include <QMessageBox>
#include <QSpacerItem>
#include <QGridLayout>
#include <QPrintDialog>
#include <QGuiApplication>
#include <QDir>
#include <QDebug>
#include <QDir>
#include <QGraphicsRectItem>
#include <QGraphicsScene>
#include <QGridLayout>
#include <QGuiApplication>
#include <QMessageBox>
#include <QPageSize>
#include <QPainter>
#include <QPixmapCache>
#include <QGraphicsScene>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include <QPageSize>
#include <QPrinterInfo>
#include <QSpacerItem>
#include "dialogs/dialoglayoutscale.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/xml/vwatermarkconverter.h"
#include "../vformat/vwatermark.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "dialogs/dialoglayoutscale.h"
#include "dialogs/vabstractlayoutdialog.h"
#include "vposter.h"
#include "../vformat/vwatermark.h"
#include "../ifc/xml/vwatermarkconverter.h"
#include "../ifc/exception/vexception.h"
#include "../vmisc/vmath.h"
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "../vmisc/compatibility.h"
namespace
{
@ -59,9 +58,7 @@ namespace
auto FindPageSizeId(QSizeF size) -> QPageSize::PageSizeId
{
auto TestSize = [size](float width, float height)
{
return size == QSizeF(width, height) || size == QSizeF(height, width);
};
{ return size == QSizeF(width, height) || size == QSizeF(height, width); };
constexpr int A0Width = 841;
constexpr int A0Height = 1189;
@ -116,15 +113,15 @@ auto FindPageSizeId(QSizeF size) -> QPageSize::PageSizeId
}
//---------------------------------------------------------------------------------------------------------------------
Q_REQUIRED_RESULT auto PreparePrinter(
const QPrinterInfo &info, QPrinter::PrinterMode mode = QPrinter::ScreenResolution) -> QSharedPointer<QPrinter>;
Q_REQUIRED_RESULT auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode = QPrinter::ScreenResolution)
-> QSharedPointer<QPrinter>;
auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSharedPointer<QPrinter>
{
QPrinterInfo tmpInfo = info;
if(tmpInfo.isNull() || tmpInfo.printerName().isEmpty())
if (tmpInfo.isNull() || tmpInfo.printerName().isEmpty())
{
const QStringList list = QPrinterInfo::availablePrinterNames();
if(list.isEmpty())
if (list.isEmpty())
{
return {};
}
@ -136,12 +133,13 @@ auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSh
printer->setResolution(static_cast<int>(PrintDPI));
return printer;
}
} // namespace
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VPrintLayout::VPrintLayout(QObject *parent)
: QObject(parent)
{}
: QObject(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
VPrintLayout::~VPrintLayout()
@ -161,7 +159,7 @@ void VPrintLayout::PrintOrigin()
{
if (not IsPagesUniform())
{
qCritical()<<tr("For printing multipages document all sheet should have the same size.");
qCritical() << tr("For printing multipages document all sheet should have the same size.");
return;
}
@ -181,7 +179,7 @@ void VPrintLayout::PrintPreviewOrigin()
{
if (not IsPagesUniform())
{
qCritical()<<tr("For previewing multipage document all sheet should have the same size.");
qCritical() << tr("For previewing multipage document all sheet should have the same size.");
return;
}
@ -207,7 +205,7 @@ void VPrintLayout::PdfTiledFile(const QString &name)
// Call IsPagesFit after setting a printer settings and check if pages is not bigger than printer's paper size
if (not m_isTiled && not IsPagesFit(printer.pageLayout().paintRectPixels(printer.resolution()).size()))
{
qWarning()<<tr("Pages will be cropped because they do not fit printer paper size.");
qWarning() << tr("Pages will be cropped because they do not fit printer paper size.");
}
printer.setResolution(static_cast<int>(PrintDPI));
@ -235,7 +233,7 @@ void VPrintLayout::PrintLayout()
}
// display print dialog and if accepted print
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
if(info.isNull() || info.printerName().isEmpty())
if (info.isNull() || info.printerName().isEmpty())
{
info = QPrinterInfo::defaultPrinter();
}
@ -280,7 +278,7 @@ void VPrintLayout::PrintPreview()
}
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
if(info.isNull() || info.printerName().isEmpty())
if (info.isNull() || info.printerName().isEmpty())
{
info = QPrinterInfo::defaultPrinter();
}
@ -324,7 +322,7 @@ void VPrintLayout::PrintPages(QPrinter *printer)
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthMainLine(), Qt::SolidLine,
Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) );
painter.setBrush(QBrush(Qt::NoBrush));
vsizetype count = 0;
QSharedPointer<QVector<PosterData>> poster;
@ -334,7 +332,7 @@ void VPrintLayout::PrintPages(QPrinter *printer)
{
// when isTiled, the landscape tiles have to be rotated, because the pages
// stay portrait in the pdf
if(m_tiledPDFOrientation == PageOrientation::Landscape)
if (m_tiledPDFOrientation == PageOrientation::Landscape)
{
const int angle = -90;
painter.rotate(angle);
@ -344,7 +342,7 @@ void VPrintLayout::PrintPages(QPrinter *printer)
poster = QSharedPointer<QVector<PosterData>>(new QVector<PosterData>());
posterazor = QSharedPointer<VPoster>(new VPoster(printer));
for (int i=0; i < m_layoutScenes.size(); ++i)
for (int i = 0; i < m_layoutScenes.size(); ++i)
{
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(i));
if (paper != nullptr)
@ -421,8 +419,8 @@ void VPrintLayout::PrintPages(QPrinter *printer)
if (m_isTiled)
{
// Draw tile
posterData = posterazor->Tile(paper, poster->at(index), m_layoutScenes.size(), data,
m_watermarkPath);
posterData =
posterazor->Tile(paper, poster->at(index), m_layoutScenes.size(), data, m_watermarkPath);
}
PreparePaper(paperIndex);
@ -431,8 +429,8 @@ void VPrintLayout::PrintPages(QPrinter *printer)
QRectF source;
m_isTiled ? source = poster->at(index).rect : source = paper->rect();
m_layoutScenes.at(paperIndex)->render(&painter, VPrintLayout::SceneTargetRect(printer, source), source,
Qt::IgnoreAspectRatio);
m_layoutScenes.at(paperIndex)
->render(&painter, VPrintLayout::SceneTargetRect(printer, source), source, Qt::IgnoreAspectRatio);
if (m_isTiled)
{
@ -475,12 +473,12 @@ void VPrintLayout::SetPrinterPrinterMargins(QPrinter *printer)
}
else
{
if(m_tiledPDFOrientation == PageOrientation::Landscape)
if (m_tiledPDFOrientation == PageOrientation::Landscape)
{
// because when painting we have a -90rotation in landscape mode,
// see function PrintPages.
printerMargins = QMarginsF(m_tiledMargins.bottom(), m_tiledMargins.left(), m_tiledMargins.top(),
m_tiledMargins.right());
printerMargins =
QMarginsF(m_tiledMargins.bottom(), m_tiledMargins.left(), m_tiledMargins.top(), m_tiledMargins.right());
}
else
{
@ -500,12 +498,12 @@ void VPrintLayout::SetPrinterOutputFileName(QPrinter *printer, PrintType printTy
{
SCASSERT(printer != nullptr)
switch(printType)
switch (printType)
{
case PrintType::PrintPDF:
{
const QString outputFileName = filePath.isEmpty() ? QDir::homePath() + QDir::separator() + DocName()
: filePath;
const QString outputFileName =
filePath.isEmpty() ? QDir::homePath() + QDir::separator() + DocName() : filePath;
printer->setOutputFileName(outputFileName + QStringLiteral(".pdf"));
#ifdef Q_OS_MAC
@ -516,7 +514,7 @@ void VPrintLayout::SetPrinterOutputFileName(QPrinter *printer, PrintType printTy
break;
}
case PrintType::PrintNative:
printer->setOutputFileName(QString());//Disable printing to file if was enabled.
printer->setOutputFileName(QString()); // Disable printing to file if was enabled.
printer->setOutputFormat(QPrinter::NativeFormat);
break;
case PrintType::PrintPreview: /*do nothing*/
@ -542,13 +540,13 @@ void VPrintLayout::SetPrinterPageSize(QPrinter *printer)
{
if (m_isLayoutPortrait)
{
height = FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(),
Unit::Mm);
height =
FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(), Unit::Mm);
}
else
{
width = FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(),
Unit::Mm);
width =
FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(), Unit::Mm);
}
}
}
@ -560,13 +558,13 @@ void VPrintLayout::SetPrinterPageSize(QPrinter *printer)
{
if (m_isLayoutPortrait)
{
width = FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(),
Unit::Mm);
width =
FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(), Unit::Mm);
}
else
{
height = FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(),
Unit::Mm);
height =
FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(), Unit::Mm);
}
}
}
@ -619,7 +617,7 @@ void VPrintLayout::PreparePaper(vsizetype index) const
m_layoutScenes.at(index)->setBackgroundBrush(brush);
m_layoutShadows.at(index)->setVisible(false);
const float thinPen = 0.1F;
paper->setPen(QPen(Qt::white, thinPen, Qt::NoPen));// border
paper->setPen(QPen(Qt::white, thinPen, Qt::NoPen)); // border
}
QTransform matrix;
@ -648,7 +646,7 @@ void VPrintLayout::RestorePaper(vsizetype index) const
}
QTransform matrix;
matrix.scale(1./m_xscale, 1./m_yscale);
matrix.scale(1. / m_xscale, 1. / m_yscale);
QList<QGraphicsItem *> paperDetails = m_layoutDetails.at(index);
for (auto *detail : paperDetails)
@ -670,12 +668,13 @@ auto VPrintLayout::IsPagesUniform() const -> bool
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(0));
SCASSERT(paper != nullptr)
return std::all_of(m_layoutPapers.begin(), m_layoutPapers.end(), [paper](QGraphicsItem *paperItem)
{
auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(paperItem);
SCASSERT(p != nullptr)
return paper->rect() == p->rect();
});
return std::all_of(m_layoutPapers.begin(), m_layoutPapers.end(),
[paper](QGraphicsItem *paperItem)
{
auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(paperItem);
SCASSERT(p != nullptr)
return paper->rect() == p->rect();
});
}
//---------------------------------------------------------------------------------------------------------------------
@ -711,8 +710,9 @@ auto VPrintLayout::WatermarkData() const -> VWatermarkData
catch (VException &e)
{
const QString errorMsg = tr("File error.\n\n%1\n\n%2").arg(e.ErrorMessage(), e.DetailedInformation());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
}
@ -730,10 +730,10 @@ auto VPrintLayout::ContinueIfLayoutStale(QWidget *parent) -> int
}
Utils::CheckableMessageBox msgBox(parent);
msgBox.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32) );
msgBox.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32));
msgBox.setWindowTitle(tr("The layout is stale."));
msgBox.setText(tr("The layout was not updated since last pattern modification. Do you want to continue?"));
msgBox.setStandardButtons(QDialogButtonBox::Yes|QDialogButtonBox::No);
msgBox.setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
msgBox.setDefaultButton(QDialogButtonBox::No);
int dialogResult = msgBox.exec();
@ -756,7 +756,7 @@ auto VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source) -> Q
qreal x;
qreal y;
if(printer->fullPage())
if (printer->fullPage())
{
QPageLayout layout = printer->pageLayout();
layout.setUnits(QPageLayout::Millimeter);
@ -766,7 +766,8 @@ auto VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source) -> Q
}
else
{
x = 0; y = 0;
x = 0;
y = 0;
}
QPair<qreal, qreal> scaleDiff = PrinterScaleDiff(printer);

View File

@ -64,27 +64,30 @@ private:
bool m_primary{false};
};
Q_DECLARE_METATYPE(VRawSAPoint) // NOLINT
Q_DECLARE_METATYPE(VRawSAPoint) // NOLINT
Q_DECLARE_TYPEINFO(VRawSAPoint, Q_MOVABLE_TYPE); // NOLINT
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(qreal xpos, qreal ypos)
: VLayoutPoint(xpos, ypos)
{}
: VLayoutPoint(xpos, ypos)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p)
: VLayoutPoint(p)
{}
: VLayoutPoint(p)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(const VLayoutPoint &p)
: VLayoutPoint(p)
{}
: VLayoutPoint(p)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p, bool curvePoint, bool turnPoint)
: VLayoutPoint(p)
: VLayoutPoint(p)
{
SetCurvePoint(curvePoint);
SetTurnPoint(turnPoint);
@ -92,8 +95,8 @@ Q_DECL_RELAXED_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p, bool curvePo
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p, bool curvePoint, bool turnPoint, bool loopPoint)
: VLayoutPoint(p),
m_loopPoint(loopPoint)
: VLayoutPoint(p),
m_loopPoint(loopPoint)
{
SetCurvePoint(curvePoint);
SetTurnPoint(turnPoint);

View File

@ -28,15 +28,16 @@
#ifndef VSAPOINT_H
#define VSAPOINT_H
#include <QtGlobal>
#include <QMetaType>
#include <QtGlobal>
#include "../vgeometry/vgeometrydef.h"
#include "../vmisc/def.h"
#include "vlayoutpoint.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/def.h"
#include "../vgeometry/vgeometrydef.h"
#include "vlayoutpoint.h"
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
@ -99,7 +100,7 @@ public:
static constexpr qreal passmarkFactor{0.5};
static constexpr qreal maxPassmarkLength{MmToPixel(10.)};
static constexpr qreal minSAWidth{accuracyPointOnLine + accuracyPointOnLine*0.5};
static constexpr qreal minSAWidth{accuracyPointOnLine + accuracyPointOnLine * 0.5};
private:
qreal m_before{-1};
@ -114,23 +115,26 @@ private:
bool m_passmarkClockwiseOpening{false};
};
Q_DECLARE_METATYPE(VSAPoint) // NOLINT
Q_DECLARE_METATYPE(VSAPoint) // NOLINT
Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); // NOLINT
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
: VLayoutPoint(xpos, ypos)
{}
: VLayoutPoint(xpos, ypos)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(QPointF p)
: VLayoutPoint(p)
{}
: VLayoutPoint(p)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(const VLayoutPoint &p)
: VLayoutPoint(p)
{}
: VLayoutPoint(p)
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VSAPoint::GetSABefore() const -> qreal

View File

@ -40,45 +40,48 @@
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
template <typename... Args>
struct QNonConstOverload
template <typename... Args> struct QNonConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const noexcept -> decltype(ptr)
{ return ptr; }
{
return ptr;
}
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr)
{ return ptr; }
template <typename R, typename T> static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr)
{
return ptr;
}
};
template <typename... Args>
struct QConstOverload
template <typename... Args> struct QConstOverload
{
template <typename R, typename T>
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const noexcept -> decltype(ptr)
{ return ptr; }
{
return ptr;
}
template <typename R, typename T>
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) noexcept -> decltype(ptr)
{ return ptr; }
{
return ptr;
}
};
template <typename... Args>
struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
template <typename... Args> struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
{
using QConstOverload<Args...>::of;
using QConstOverload<Args...>::operator();
using QNonConstOverload<Args...>::of;
using QNonConstOverload<Args...>::operator();
template <typename R>
Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr)
{ return ptr; }
template <typename R> Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr)
{
return ptr;
}
template <typename R>
static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) noexcept -> decltype(ptr)
{ return ptr; }
template <typename R> static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) noexcept -> decltype(ptr) { return ptr; }
};
#if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 // C++14

View File

@ -43,13 +43,13 @@ QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wunused-variable")
QT_WARNING_DISABLE_CLANG("-Wunused-variable")
static auto endl Q_DECL_UNUSED = ::endl; // NOLINT
static auto flush Q_DECL_UNUSED = ::flush; // NOLINT
static auto dec Q_DECL_UNUSED = ::dec; // NOLINT
static auto endl Q_DECL_UNUSED = ::endl; // NOLINT
static auto flush Q_DECL_UNUSED = ::flush; // NOLINT
static auto dec Q_DECL_UNUSED = ::dec; // NOLINT
static auto SkipEmptyParts Q_DECL_UNUSED = QString::SkipEmptyParts; // NOLINT
QT_WARNING_POP
} // namespace Qt
} // namespace Qt
#endif

View File

@ -1,17 +1,13 @@
#ifndef FPM_FIXED_HPP
#define FPM_FIXED_HPP
#include <QtGlobal>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <functional>
#include <limits>
#include <type_traits>
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace fpm
{
@ -21,8 +17,7 @@ namespace fpm
//! unsigned type.
//! \tparam IntermediateType the integer type used to store intermediate results during calculations.
//! \tparam FractionBits the number of bits of the BaseType used to store the fraction
template <typename BaseType, typename IntermediateType, unsigned int FractionBits>
class fixed
template <typename BaseType, typename IntermediateType, unsigned int FractionBits> class fixed
{
static_assert(std::is_integral<BaseType>::value, "BaseType must be an integral type");
static_assert(FractionBits > 0, "FractionBits must be greater than zero");
@ -36,42 +31,50 @@ class fixed
// is incorrect (flips from positive to negative), so we must extend the size to IntermediateType.
static constexpr IntermediateType FRACTION_MULT = IntermediateType(1) << FractionBits;
struct raw_construct_tag {};
constexpr inline fixed(BaseType val, raw_construct_tag /*unused*/) noexcept : m_value(val) {}
struct raw_construct_tag
{
};
constexpr inline fixed(BaseType val, raw_construct_tag /*unused*/) noexcept
: m_value(val)
{
}
public:
inline fixed() noexcept = default;
// Converts an integral number to the fixed-point type.
// Like static_cast, this truncates bits that don't fit.
template <typename T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
template <typename T, typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline explicit fixed(T val) noexcept
: m_value(static_cast<BaseType>(val * FRACTION_MULT))
{}
: m_value(static_cast<BaseType>(val * FRACTION_MULT))
{
}
// Converts an floating-point number to the fixed-point type.
// Like static_cast, this truncates bits that don't fit.
template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type * = nullptr>
constexpr inline explicit fixed(T val) noexcept
: m_value(static_cast<BaseType>((val >= 0.0) ? (val * FRACTION_MULT + T{0.5}) : (val * FRACTION_MULT - T{0.5})))
{}
: m_value(static_cast<BaseType>((val >= 0.0) ? (val * FRACTION_MULT + T{0.5}) : (val * FRACTION_MULT - T{0.5})))
{
}
// Constructs from another fixed-point type with possibly different underlying representation.
// Like static_cast, this truncates bits that don't fit.
template <typename B, typename I, unsigned int F>
constexpr inline explicit fixed(fixed<B,I,F> val) noexcept
: m_value(from_fixed_point<F>(val.raw_value()).raw_value())
{}
constexpr inline explicit fixed(fixed<B, I, F> val) noexcept
: m_value(from_fixed_point<F>(val.raw_value()).raw_value())
{
}
// Explicit conversion to a floating-point type
template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr>
template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type * = nullptr>
constexpr inline explicit operator T() const noexcept
{
return static_cast<T>(m_value) / FRACTION_MULT;
}
// Explicit conversion to an integral type
template <typename T, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
template <typename T, typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline explicit operator T() const noexcept
{
return static_cast<T>(m_value / FRACTION_MULT);
@ -79,33 +82,27 @@ public:
// Returns the raw underlying value of this type.
// Do not use this unless you know what you're doing.
constexpr inline auto raw_value() const noexcept -> BaseType
{
return m_value;
}
constexpr inline auto raw_value() const noexcept -> BaseType { return m_value; }
//! Constructs a fixed-point number from another fixed-point number.
//! \tparam NumFractionBits the number of bits used by the fraction in \a value.
//! \param value the integer fixed-point number
template <unsigned int NumFractionBits, typename T,
typename std::enable_if<(NumFractionBits > FractionBits)>::type* = nullptr>
typename std::enable_if<(NumFractionBits > FractionBits)>::type * = nullptr>
static constexpr inline auto from_fixed_point(T value) noexcept -> fixed
{
// To correctly round the last bit in the result, we need one more bit of information.
// We do this by multiplying by two before dividing and adding the LSB to the real result.
return fixed(static_cast<BaseType>(
value / (T(1) << (NumFractionBits - FractionBits)) +
(value / (T(1) << (NumFractionBits - FractionBits - 1)) % 2)),
raw_construct_tag{});
return fixed(static_cast<BaseType>(value / (T(1) << (NumFractionBits - FractionBits)) +
(value / (T(1) << (NumFractionBits - FractionBits - 1)) % 2)),
raw_construct_tag{});
}
template <unsigned int NumFractionBits, typename T,
typename std::enable_if<(NumFractionBits <= FractionBits)>::type* = nullptr>
typename std::enable_if<(NumFractionBits <= FractionBits)>::type * = nullptr>
static constexpr inline auto from_fixed_point(T value) noexcept -> fixed
{
return fixed(static_cast<BaseType>(
value * (T(1) << (FractionBits - NumFractionBits))),
raw_construct_tag{});
return fixed(static_cast<BaseType>(value * (T(1) << (FractionBits - NumFractionBits))), raw_construct_tag{});
}
// Constructs a fixed-point number from its raw underlying value.
@ -127,56 +124,53 @@ public:
// Arithmetic member operators
//
constexpr inline auto operator-() const noexcept -> fixed
{
return fixed::from_raw_value(-m_value);
}
constexpr inline auto operator-() const noexcept -> fixed { return fixed::from_raw_value(-m_value); }
inline auto operator+=(const fixed& y) noexcept -> fixed&
inline auto operator+=(const fixed &y) noexcept -> fixed &
{
m_value += y.m_value;
return *this;
}
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
inline auto operator+=(I y) noexcept -> fixed&
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
inline auto operator+=(I y) noexcept -> fixed &
{
m_value += y * FRACTION_MULT;
return *this;
}
inline auto operator-=(const fixed& y) noexcept -> fixed&
inline auto operator-=(const fixed &y) noexcept -> fixed &
{
m_value -= y.m_value;
return *this;
}
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
inline auto operator-=(I y) noexcept -> fixed&
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
inline auto operator-=(I y) noexcept -> fixed &
{
m_value -= y * FRACTION_MULT;
return *this;
}
inline auto operator*=(const fixed& y) noexcept -> fixed&
inline auto operator*=(const fixed &y) noexcept -> fixed &
{
// Normal fixed-point multiplication is: x * y / 2**FractionBits.
// To correctly round the last bit in the result, we need one more bit of information.
// We do this by multiplying by two before dividing and adding the LSB to the real result.
auto value = static_cast<IntermediateType>(
auto value = static_cast<IntermediateType>(
static_cast<double>(static_cast<IntermediateType>(m_value) * y.m_value) / (FRACTION_MULT / 2));
m_value = static_cast<BaseType>((value / 2) + (value % 2));
return *this;
}
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
inline auto operator*=(I y) noexcept -> fixed&
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
inline auto operator*=(I y) noexcept -> fixed &
{
m_value *= y;
return *this;
}
inline auto operator/=(const fixed& y) noexcept -> fixed&
inline auto operator/=(const fixed &y) noexcept -> fixed &
{
assert(y.m_value != 0);
// Normal fixed-point division is: x * 2**FractionBits / y.
@ -187,8 +181,8 @@ public:
return *this;
}
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
inline auto operator/=(I y) noexcept -> fixed&
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
inline auto operator/=(I y) noexcept -> fixed &
{
m_value /= y;
return *this;
@ -198,15 +192,15 @@ public:
// Shift operators
//
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
inline auto operator>>=(I y) noexcept -> fixed&
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
inline auto operator>>=(I y) noexcept -> fixed &
{
m_value >>= y;
return *this;
}
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
inline auto operator<<=(I y) noexcept -> fixed&
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
inline auto operator<<=(I y) noexcept -> fixed &
{
m_value <<= y;
return *this;
@ -229,21 +223,21 @@ using fixed_8_24 = fixed<std::int32_t, std::int64_t, 24>;
//
template <typename B, typename I, unsigned int F>
constexpr inline auto operator+(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
constexpr inline auto operator+(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) += y;
}
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator+(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator+(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) += y;
}
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator+(T x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator+(T x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(y) += x;
}
@ -253,21 +247,21 @@ constexpr inline auto operator+(T x, const fixed<B, I, F>& y) noexcept -> fixed<
//
template <typename B, typename I, unsigned int F>
constexpr inline auto operator-(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
constexpr inline auto operator-(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) -= y;
}
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator-(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator-(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) -= y;
}
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator-(T x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator-(T x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) -= y;
}
@ -277,21 +271,21 @@ constexpr inline auto operator-(T x, const fixed<B, I, F>& y) noexcept -> fixed<
//
template <typename B, typename I, unsigned int F>
constexpr inline auto operator*(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
constexpr inline auto operator*(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) *= y;
}
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator*(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator*(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) *= y;
}
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator*(T x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator*(T x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(y) *= x;
}
@ -301,21 +295,21 @@ constexpr inline auto operator*(T x, const fixed<B, I, F>& y) noexcept -> fixed<
//
template <typename B, typename I, unsigned int F>
constexpr inline auto operator/(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
constexpr inline auto operator/(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) /= y;
}
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator/(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator/(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) /= y;
}
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator/(T x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator/(T x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) /= y;
}
@ -325,15 +319,15 @@ constexpr inline auto operator/(T x, const fixed<B, I, F>& y) noexcept -> fixed<
//
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator>>(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator>>(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) >>= y;
}
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
constexpr inline auto operator<<(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline auto operator<<(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
{
return fixed<B, I, F>(x) <<= y;
}
@ -343,37 +337,37 @@ constexpr inline auto operator<<(const fixed<B, I, F>& x, T y) noexcept -> fixed
//
template <typename B, typename I, unsigned int F>
constexpr inline auto operator==(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> bool
constexpr inline auto operator==(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> bool
{
return x.raw_value() == y.raw_value();
}
template <typename B, typename I, unsigned int F>
constexpr inline auto operator!=(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> bool
constexpr inline auto operator!=(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> bool
{
return x.raw_value() != y.raw_value();
}
template <typename B, typename I, unsigned int F>
constexpr inline auto operator<(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> bool
constexpr inline auto operator<(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> bool
{
return x.raw_value() < y.raw_value();
}
template <typename B, typename I, unsigned int F>
constexpr inline auto operator>(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> bool
constexpr inline auto operator>(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> bool
{
return x.raw_value() > y.raw_value();
}
template <typename B, typename I, unsigned int F>
constexpr inline auto operator<=(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> bool
constexpr inline auto operator<=(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> bool
{
return x.raw_value() <= y.raw_value();
}
template <typename B, typename I, unsigned int F>
constexpr inline auto operator>=(const fixed<B, I, F>& x, const fixed<B, I, F>& y) noexcept -> bool
constexpr inline auto operator>=(const fixed<B, I, F> &x, const fixed<B, I, F> &y) noexcept -> bool
{
return x.raw_value() >= y.raw_value();
}
@ -388,7 +382,7 @@ QT_WARNING_DISABLE_CLANG("-Wunneeded-internal-declaration")
static constexpr auto max_digits10(int bits) -> int
{
// 8.24 fixed-point equivalent of (int)ceil(bits * std::log10(2));
using T = long long; // NOLINT(google-runtime-int)
using T = long long; // NOLINT(google-runtime-int)
return static_cast<int>((T{bits} * 5050445 + (T{1} << 24) - 1) >> 24); // NOLINT(hicpp-signed-bitwise)
}
@ -396,8 +390,8 @@ static constexpr auto max_digits10(int bits) -> int
static constexpr auto digits10(int bits) -> int
{
// 8.24 fixed-point equivalent of (int)(bits * std::log10(2));
using T = long long; // NOLINT(google-runtime-int)
return static_cast<int>((T{bits} * 5050445) >> 24); //NOLINT(hicpp-signed-bitwise)
using T = long long; // NOLINT(google-runtime-int)
return static_cast<int>((T{bits} * 5050445) >> 24); // NOLINT(hicpp-signed-bitwise)
}
QT_WARNING_POP
@ -409,8 +403,7 @@ QT_WARNING_POP
namespace std // NOLINT(cert-dcl58-cpp)
{
template <typename B, typename I, unsigned int F>
struct hash<fpm::fixed<B,I,F>>
template <typename B, typename I, unsigned int F> struct hash<fpm::fixed<B, I, F>>
{
using argument_type = fpm::fixed<B, I, F>;
using result_type = std::size_t;
@ -425,8 +418,7 @@ private:
std::hash<B> m_hash;
};
template <typename B, typename I, unsigned int F>
struct numeric_limits<fpm::fixed<B,I,F>>
template <typename B, typename I, unsigned int F> struct numeric_limits<fpm::fixed<B, I, F>>
{
static constexpr bool is_specialized = true;
static constexpr bool is_signed = std::numeric_limits<B>::is_signed;
@ -461,87 +453,77 @@ struct numeric_limits<fpm::fixed<B,I,F>>
static constexpr bool traps = true;
static constexpr bool tinyness_before = false;
static constexpr auto lowest() noexcept -> fpm::fixed<B,I,F>
static constexpr auto lowest() noexcept -> fpm::fixed<B, I, F>
{
return fpm::fixed<B,I,F>::from_raw_value(std::numeric_limits<B>::lowest());
return fpm::fixed<B, I, F>::from_raw_value(std::numeric_limits<B>::lowest());
}
static constexpr auto min() noexcept -> fpm::fixed<B,I,F>
static constexpr auto min() noexcept -> fpm::fixed<B, I, F> { return lowest(); }
static constexpr auto max() noexcept -> fpm::fixed<B, I, F>
{
return lowest();
return fpm::fixed<B, I, F>::from_raw_value(std::numeric_limits<B>::max());
}
static constexpr auto max() noexcept -> fpm::fixed<B,I,F>
{
return fpm::fixed<B,I,F>::from_raw_value(std::numeric_limits<B>::max());
}
static constexpr auto epsilon() noexcept -> fpm::fixed<B, I, F> { return fpm::fixed<B, I, F>::from_raw_value(1); }
static constexpr auto epsilon() noexcept -> fpm::fixed<B,I,F>
{
return fpm::fixed<B,I,F>::from_raw_value(1);
}
static constexpr auto round_error() noexcept -> fpm::fixed<B, I, F> { return fpm::fixed<B, I, F>(1) / 2; }
static constexpr auto round_error() noexcept -> fpm::fixed<B,I,F>
{
return fpm::fixed<B,I,F>(1) / 2;
}
static constexpr auto denorm_min() noexcept -> fpm::fixed<B,I,F>
{
return min();
}
static constexpr auto denorm_min() noexcept -> fpm::fixed<B, I, F> { return min(); }
};
// See https://stackoverflow.com/a/46719572/3045403
#if __cplusplus < 201703L
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::is_specialized; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::is_specialized; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::is_signed; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::is_signed; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::is_integer; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::is_integer; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::is_exact; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::is_exact; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::has_infinity; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::has_infinity; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::has_quiet_NaN; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::has_quiet_NaN; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::has_signaling_NaN; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::has_signaling_NaN; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr std::float_denorm_style numeric_limits<fpm::fixed<B,I,F>>::has_denorm; // NOLINT(readability-redundant-declaration)
constexpr std::float_denorm_style
numeric_limits<fpm::fixed<B, I, F>>::has_denorm; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::has_denorm_loss; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::has_denorm_loss; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr std::float_round_style numeric_limits<fpm::fixed<B,I,F>>::round_style; // NOLINT(readability-redundant-declaration)
constexpr std::float_round_style
numeric_limits<fpm::fixed<B, I, F>>::round_style; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::is_iec_559; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::is_iec_559; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::is_bounded; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::is_bounded; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::is_modulo; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::is_modulo; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr int numeric_limits<fpm::fixed<B,I,F>>::digits; // NOLINT(readability-redundant-declaration)
constexpr int numeric_limits<fpm::fixed<B, I, F>>::digits; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr int numeric_limits<fpm::fixed<B,I,F>>::digits10; // NOLINT(readability-redundant-declaration)
constexpr int numeric_limits<fpm::fixed<B, I, F>>::digits10; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr int numeric_limits<fpm::fixed<B,I,F>>::max_digits10; // NOLINT(readability-redundant-declaration)
constexpr int numeric_limits<fpm::fixed<B, I, F>>::max_digits10; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr int numeric_limits<fpm::fixed<B,I,F>>::radix; // NOLINT(readability-redundant-declaration)
constexpr int numeric_limits<fpm::fixed<B, I, F>>::radix; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr int numeric_limits<fpm::fixed<B,I,F>>::min_exponent; // NOLINT(readability-redundant-declaration)
constexpr int numeric_limits<fpm::fixed<B, I, F>>::min_exponent; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr int numeric_limits<fpm::fixed<B,I,F>>::min_exponent10; // NOLINT(readability-redundant-declaration)
constexpr int numeric_limits<fpm::fixed<B, I, F>>::min_exponent10; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr int numeric_limits<fpm::fixed<B,I,F>>::max_exponent; // NOLINT(readability-redundant-declaration)
constexpr int numeric_limits<fpm::fixed<B, I, F>>::max_exponent; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr int numeric_limits<fpm::fixed<B,I,F>>::max_exponent10; // NOLINT(readability-redundant-declaration)
constexpr int numeric_limits<fpm::fixed<B, I, F>>::max_exponent10; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::traps; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::traps; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B,I,F>>::tinyness_before; // NOLINT(readability-redundant-declaration)
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::tinyness_before; // NOLINT(readability-redundant-declaration)
#endif
} // namespace std
} // namespace std
#endif

View File

@ -37,9 +37,12 @@ inline auto find_highest_bit(unsigned long long value) noexcept -> long
#if defined(_WIN64)
_BitScanReverse64(&index, value);
#else
if (_BitScanReverse(&index, static_cast<unsigned long>(value >> 32)) != 0) {
if (_BitScanReverse(&index, static_cast<unsigned long>(value >> 32)) != 0)
{
index += 32;
} else {
}
else
{
_BitScanReverse(&index, static_cast<unsigned long>(value & 0xfffffffflu));
}
#endif
@ -47,20 +50,19 @@ inline auto find_highest_bit(unsigned long long value) noexcept -> long
#elif defined(__GNUC__) || defined(__clang__)
return sizeof(value) * 8 - 1 - __builtin_clzll(value); // NOLINT
#else
# error "your platform does not support find_highest_bit()"
#error "your platform does not support find_highest_bit()"
#endif
}
QT_WARNING_POP
} // namespace detail
} // namespace detail
//
// Classification methods
//
template <typename B, typename I, unsigned int F>
constexpr inline auto fpclassify(fixed<B, I, F> x) noexcept -> int
template <typename B, typename I, unsigned int F> constexpr inline auto fpclassify(fixed<B, I, F> x) noexcept -> int
{
return (x.raw_value() == 0) ? FP_ZERO : FP_NORMAL;
}
@ -83,14 +85,12 @@ constexpr inline auto isnan(fixed<B, I, F> /*unused*/) noexcept -> bool
return false;
}
template <typename B, typename I, unsigned int F>
constexpr inline auto isnormal(fixed<B, I, F> x) noexcept -> bool
template <typename B, typename I, unsigned int F> constexpr inline auto isnormal(fixed<B, I, F> x) noexcept -> bool
{
return x.raw_value() != 0;
}
template <typename B, typename I, unsigned int F>
constexpr inline auto signbit(fixed<B, I, F> x) noexcept -> bool
template <typename B, typename I, unsigned int F> constexpr inline auto signbit(fixed<B, I, F> x) noexcept -> bool
{
return x.raw_value() < 0;
}
@ -126,7 +126,7 @@ constexpr inline auto islessgreater(fixed<B, I, F> x, fixed<B, I, F> y) noexcept
}
template <typename B, typename I, unsigned int F>
constexpr inline auto isunordered(fixed<B, I, F> /*x*/, fixed<B, I, F> /*y*/) noexcept -> bool
constexpr inline auto isunordered(fixed<B, I, F> /*x*/, fixed<B, I, F> /*y*/) noexcept -> bool
{
return false;
}
@ -134,8 +134,7 @@ constexpr inline auto isunordered(fixed<B, I, F> /*x*/, fixed<B, I, F> /*y*/)
//
// Nearest integer operations
//
template <typename B, typename I, unsigned int F>
inline auto ceil(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto ceil(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
constexpr auto FRAC = B(1) << F;
auto value = x.raw_value();
@ -146,8 +145,7 @@ inline auto ceil(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return fixed<B, I, F>::from_raw_value(value / FRAC * FRAC);
}
template <typename B, typename I, unsigned int F>
inline auto floor(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto floor(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
constexpr auto FRAC = B(1) << F;
auto value = x.raw_value();
@ -158,23 +156,20 @@ inline auto floor(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return fixed<B, I, F>::from_raw_value(value / FRAC * FRAC);
}
template <typename B, typename I, unsigned int F>
inline auto trunc(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto trunc(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
constexpr auto FRAC = B(1) << F;
return fixed<B, I, F>::from_raw_value(x.raw_value() / FRAC * FRAC);
}
template <typename B, typename I, unsigned int F>
inline auto round(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto round(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
constexpr auto FRAC = B(1) << F;
auto value = x.raw_value() / (FRAC / 2);
return fixed<B, I, F>::from_raw_value(((value / 2) + (value % 2)) * FRAC);
}
template <typename B, typename I, unsigned int F>
auto nearbyint(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto nearbyint(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
// Rounding mode is assumed to be FE_TONEAREST
constexpr auto FRAC = B(1) << F;
@ -196,8 +191,7 @@ constexpr inline auto rint(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
//
// Mathematical functions
//
template <typename B, typename I, unsigned int F>
constexpr inline auto abs(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> constexpr inline auto abs(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
return (x >= fixed<B, I, F>{0}) ? x : -x;
}
@ -205,21 +199,17 @@ constexpr inline auto abs(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F>
constexpr inline auto fmod(fixed<B, I, F> x, fixed<B, I, F> y) noexcept -> fixed<B, I, F>
{
return
assert(y.raw_value() != 0),
fixed<B, I, F>::from_raw_value(x.raw_value() % y.raw_value());
return assert(y.raw_value() != 0), fixed<B, I, F>::from_raw_value(x.raw_value() % y.raw_value());
}
template <typename B, typename I, unsigned int F>
constexpr inline auto remainder(fixed<B, I, F> x, fixed<B, I, F> y) noexcept -> fixed<B, I, F>
{
return
assert(y.raw_value() != 0),
x - nearbyint(x / y) * y;
return assert(y.raw_value() != 0), x - nearbyint(x / y) * y;
}
template <typename B, typename I, unsigned int F>
inline auto remquo(fixed<B, I, F> x, fixed<B, I, F> y, int* quo) noexcept -> fixed<B, I, F>
inline auto remquo(fixed<B, I, F> x, fixed<B, I, F> y, int *quo) noexcept -> fixed<B, I, F>
{
assert(y.raw_value() != 0);
assert(quo != nullptr);
@ -234,17 +224,15 @@ inline auto remquo(fixed<B, I, F> x, fixed<B, I, F> y, int* quo) noexcept -> fix
template <typename B, typename I, unsigned int F, typename C, typename J, unsigned int G>
constexpr inline auto copysign(fixed<B, I, F> x, fixed<C, J, G> y) noexcept -> fixed<B, I, F>
{
return
x = abs(x),
(y >= fixed<C, J, G>{0}) ? x : -x;
return x = abs(x), (y >= fixed<C, J, G>{0}) ? x : -x;
}
template <typename B, typename I, unsigned int F>
constexpr inline auto nextafter(fixed<B, I, F> from, fixed<B, I, F> to) noexcept -> fixed<B, I, F>
{
return from == to ? to :
to > from ? fixed<B, I, F>::from_raw_value(from.raw_value() + 1)
: fixed<B, I, F>::from_raw_value(from.raw_value() - 1);
return from == to ? to
: to > from ? fixed<B, I, F>::from_raw_value(from.raw_value() + 1)
: fixed<B, I, F>::from_raw_value(from.raw_value() - 1);
}
template <typename B, typename I, unsigned int F>
@ -254,7 +242,7 @@ constexpr inline auto nexttoward(fixed<B, I, F> from, fixed<B, I, F> to) noexcep
}
template <typename B, typename I, unsigned int F>
inline auto modf(fixed<B, I, F> x, fixed<B, I, F>* iptr) noexcept -> fixed<B, I, F>
inline auto modf(fixed<B, I, F> x, fixed<B, I, F> *iptr) noexcept -> fixed<B, I, F>
{
const auto raw = x.raw_value();
constexpr auto FRAC = B{1} << F;
@ -262,23 +250,23 @@ inline auto modf(fixed<B, I, F> x, fixed<B, I, F>* iptr) noexcept -> fixed<B, I,
return fixed<B, I, F>::from_raw_value(raw % FRAC);
}
//
// Power functions
//
template <typename B, typename I, unsigned int F, typename T,
typename std::enable_if<std::is_integral<T>::value>::type* = nullptr>
typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
auto pow(fixed<B, I, F> base, T exp) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (base == Fixed(0)) {
if (base == Fixed(0))
{
assert(exp > 0);
return Fixed(0);
}
Fixed result {1};
Fixed result{1};
if (exp < 0)
{
for (Fixed intermediate = base; exp != 0; exp /= 2, intermediate *= intermediate)
@ -307,7 +295,8 @@ auto pow(fixed<B, I, F> base, fixed<B, I, F> exp) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (base == Fixed(0)) {
if (base == Fixed(0))
{
assert(exp > Fixed(0));
return Fixed(0);
}
@ -331,11 +320,11 @@ auto pow(fixed<B, I, F> base, fixed<B, I, F> exp) noexcept -> fixed<B, I, F>
return exp2(log2(base) * exp);
}
template <typename B, typename I, unsigned int F>
auto exp(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto exp(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (x < Fixed(0)) {
if (x < Fixed(0))
{
return 1 / exp(-x);
}
constexpr auto FRAC = B(1) << F;
@ -343,8 +332,8 @@ auto exp(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
x -= x_int;
assert(x >= Fixed(0) && x < Fixed(1));
constexpr auto fA = Fixed::template from_fixed_point<63>( 128239257017632854LL); // 1.3903728105644451e-2
constexpr auto fB = Fixed::template from_fixed_point<63>( 320978614890280666LL); // 3.4800571158543038e-2
constexpr auto fA = Fixed::template from_fixed_point<63>(128239257017632854LL); // 1.3903728105644451e-2
constexpr auto fB = Fixed::template from_fixed_point<63>(320978614890280666LL); // 3.4800571158543038e-2
constexpr auto fC = Fixed::template from_fixed_point<63>(1571680799599592947LL); // 1.7040197373796334e-1
constexpr auto fD = Fixed::template from_fixed_point<63>(4603349000587966862LL); // 4.9909609871464493e-1
constexpr auto fE = Fixed::template from_fixed_point<62>(4612052447974689712LL); // 1.0000794567422495
@ -352,11 +341,11 @@ auto exp(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return pow(Fixed::e(), x_int) * (((((fA * x + fB) * x + fC) * x + fD) * x + fE) * x + fF);
}
template <typename B, typename I, unsigned int F>
auto exp2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto exp2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (x < Fixed(0)) {
if (x < Fixed(0))
{
return 1 / exp2(-x);
}
constexpr auto FRAC = B(1) << F;
@ -364,23 +353,21 @@ auto exp2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
x -= x_int;
assert(x >= Fixed(0) && x < Fixed(1));
constexpr auto fA = Fixed::template from_fixed_point<63>( 17491766697771214LL); // 1.8964611454333148e-3
constexpr auto fB = Fixed::template from_fixed_point<63>( 82483038782406547LL); // 8.9428289841091295e-3
constexpr auto fC = Fixed::template from_fixed_point<63>( 515275173969157690LL); // 5.5866246304520701e-2
constexpr auto fA = Fixed::template from_fixed_point<63>(17491766697771214LL); // 1.8964611454333148e-3
constexpr auto fB = Fixed::template from_fixed_point<63>(82483038782406547LL); // 8.9428289841091295e-3
constexpr auto fC = Fixed::template from_fixed_point<63>(515275173969157690LL); // 5.5866246304520701e-2
constexpr auto fD = Fixed::template from_fixed_point<63>(2214897896212987987LL); // 2.4013971109076949e-1
constexpr auto fE = Fixed::template from_fixed_point<63>(6393224161192452326LL); // 6.9315475247516736e-1
constexpr auto fF = Fixed::template from_fixed_point<63>(9223371050976163566LL); // 9.9999989311082668e-1
return Fixed(1 << x_int) * (((((fA * x + fB) * x + fC) * x + fD) * x + fE) * x + fF);
}
template <typename B, typename I, unsigned int F>
auto expm1(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto expm1(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
return exp(x) - 1; // cppcheck-suppress unpreciseMathCall
}
template <typename B, typename I, unsigned int F>
auto log2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto log2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
assert(x > Fixed(0));
@ -399,37 +386,33 @@ auto log2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
x = Fixed::from_raw_value(value);
assert(x >= Fixed(1) && x < Fixed(2));
constexpr auto fA = Fixed::template from_fixed_point<63>( 413886001457275979LL); // 4.4873610194131727e-2
constexpr auto fA = Fixed::template from_fixed_point<63>(413886001457275979LL); // 4.4873610194131727e-2
constexpr auto fB = Fixed::template from_fixed_point<63>(-3842121857793256941LL); // -4.1656368651734915e-1
constexpr auto fC = Fixed::template from_fixed_point<62>( 7522345947206307744LL); // 1.6311487636297217
constexpr auto fC = Fixed::template from_fixed_point<62>(7522345947206307744LL); // 1.6311487636297217
constexpr auto fD = Fixed::template from_fixed_point<61>(-8187571043052183818LL); // -3.5507929249026341
constexpr auto fE = Fixed::template from_fixed_point<60>( 5870342889289496598LL); // 5.0917108110420042
constexpr auto fE = Fixed::template from_fixed_point<60>(5870342889289496598LL); // 5.0917108110420042
constexpr auto fF = Fixed::template from_fixed_point<61>(-6457199832668582866LL); // -2.8003640347009253
return Fixed(highest - F) + (((((fA * x + fB) * x + fC) * x + fD) * x + fE) * x + fF);
}
template <typename B, typename I, unsigned int F>
auto log(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto log(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
return log2(x) / log2(Fixed::e());
}
template <typename B, typename I, unsigned int F>
auto log10(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto log10(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
return log2(x) / log2(Fixed(10));
}
template <typename B, typename I, unsigned int F>
auto log1p(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto log1p(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
return log(1 + x); // cppcheck-suppress unpreciseMathCall
}
template <typename B, typename I, unsigned int F>
auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
@ -447,7 +430,7 @@ auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
// based on the square root algorithm.
// We start at the greatest power of eight that's less than the argument.
int ofs = ((detail::find_highest_bit(x.raw_value()) + 2*F) / 3 * 3);
int ofs = ((detail::find_highest_bit(x.raw_value()) + 2 * F) / 3 * 3);
I num = I{x.raw_value()};
I res = 0;
@ -456,7 +439,7 @@ auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
for (; ofs >= 0; ofs -= 3)
{
res += res;
const I val = (3*res*(res + 1) + 1) << ofs;
const I val = (3 * res * (res + 1) + 1) << ofs;
if (num >= val)
{
num -= val;
@ -480,8 +463,7 @@ auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return Fixed::from_raw_value(static_cast<B>(res));
}
template <typename B, typename I, unsigned int F>
auto sqrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto sqrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
@ -523,15 +505,14 @@ template <typename B, typename I, unsigned int F>
auto hypot(fixed<B, I, F> x, fixed<B, I, F> y) noexcept -> fixed<B, I, F>
{
assert(x != 0 || y != 0);
return sqrt(x*x + y*y);
return sqrt(x * x + y * y);
}
//
// Trigonometry functions
//
template <typename B, typename I, unsigned int F>
auto sin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto sin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
// This sine uses a fifth-order curve-fitting approximation originally
// described by Jasper Vijn on coranac.com which has a worst-case
@ -543,34 +524,35 @@ auto sin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
x = x / Fixed::half_pi();
// Take x modulo one rotation, so [-4..+4].
if (x < Fixed(0)) {
if (x < Fixed(0))
{
x += Fixed(4);
}
int sign = +1;
if (x > Fixed(2)) {
if (x > Fixed(2))
{
// Reduce domain to [0..2].
sign = -1;
x -= Fixed(2);
}
if (x > Fixed(1)) {
if (x > Fixed(1))
{
// Reduce domain to [0..1].
x = Fixed(2) - x;
}
const Fixed x2 = x*x;
return sign * x * (Fixed::pi() - x2*(Fixed::two_pi() - 5 - x2*(Fixed::pi() - 3)))/2;
const Fixed x2 = x * x;
return sign * x * (Fixed::pi() - x2 * (Fixed::two_pi() - 5 - x2 * (Fixed::pi() - 3))) / 2;
}
template <typename B, typename I, unsigned int F>
inline auto cos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto cos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
return sin(fixed<B, I, F>::half_pi() + x);
}
template <typename B, typename I, unsigned int F>
inline auto tan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto tan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
auto cx = cos(x);
@ -581,21 +563,22 @@ inline auto tan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return sin(x) / cx;
}
namespace detail {
namespace detail
{
// Calculates atan(x) assuming that x is in the range [0,1]
template <typename B, typename I, unsigned int F>
auto atan_sanitized(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto atan_sanitized(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
assert(x >= Fixed(0) && x <= Fixed(1));
constexpr auto fA = Fixed::template from_fixed_point<63>( 716203666280654660LL); // 0.0776509570923569
constexpr auto fA = Fixed::template from_fixed_point<63>(716203666280654660LL); // 0.0776509570923569
constexpr auto fB = Fixed::template from_fixed_point<63>(-2651115102768076601LL); // -0.287434475393028
constexpr auto fC = Fixed::template from_fixed_point<63>( 9178930894564541004LL); // 0.995181681698119 (PI/4 - A - B)
constexpr auto fC =
Fixed::template from_fixed_point<63>(9178930894564541004LL); // 0.995181681698119 (PI/4 - A - B)
const auto xx = x * x;
return ((fA*xx + fB)*xx + fC)*x;
return ((fA * xx + fB) * xx + fC) * x;
}
// Calculate atan(y / x), assuming x != 0.
@ -613,28 +596,31 @@ auto atan_div(fixed<B, I, F> y, fixed<B, I, F> x) noexcept -> fixed<B, I, F>
// Make sure y and x are positive.
// If y / x is negative (when y or x, but not both, are negative), negate the result to
// keep the correct outcome.
if (y < Fixed(0)) {
if (x < Fixed(0)) {
if (y < Fixed(0))
{
if (x < Fixed(0))
{
return atan_div(-y, -x);
}
return -atan_div(-y, x);
}
if (x < Fixed(0)) {
if (x < Fixed(0))
{
return -atan_div(y, -x);
}
assert(y >= Fixed(0));
assert(x > Fixed(0));
assert(x > Fixed(0));
if (y > x) {
if (y > x)
{
return Fixed::half_pi() - detail::atan_sanitized(x / y);
}
return detail::atan_sanitized(y / x);
}
} // namespace detail
} // namespace detail
template <typename B, typename I, unsigned int F>
auto atan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto atan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (x < Fixed(0))
@ -650,8 +636,7 @@ auto atan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return detail::atan_sanitized(x);
}
template <typename B, typename I, unsigned int F>
auto asin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto asin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
assert(x >= Fixed(-1) && x <= Fixed(+1));
@ -664,8 +649,7 @@ auto asin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return detail::atan_div(x, sqrt(yy));
}
template <typename B, typename I, unsigned int F>
auto acos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto acos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
assert(x >= Fixed(-1) && x <= Fixed(+1));
@ -675,7 +659,7 @@ auto acos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return Fixed::pi();
}
const auto yy = Fixed(1) - x * x;
return Fixed(2)*detail::atan_div(sqrt(yy), Fixed(1) + x);
return Fixed(2) * detail::atan_div(sqrt(yy), Fixed(1) + x);
}
template <typename B, typename I, unsigned int F>
@ -697,6 +681,6 @@ auto atan2(fixed<B, I, F> y, fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return ret;
}
} // namespace fpm
} // namespace fpm
#endif

View File

@ -38,19 +38,18 @@ namespace
//---------------------------------------------------------------------------------------------------------------------
auto QtCodecs() -> QMap<QStringConverter::Encoding, QStringList>
{
static auto codecs = QMap<QStringConverter::Encoding, QStringList>
{
{QStringConverter::Latin1, {"ISO-8859-1", "ANSI_1252", "CP1252", "windows-1252", "LATIN1", "CP819", "CSISO",
"IBM819", "ISO_8859-1", "APPLE ROMAN", "ISO8859-1", "ISO8859-15", "ISO-IR-100", "L1", "IBM 850",
"850"}}, // Western Europe
static auto codecs = QMap<QStringConverter::Encoding, QStringList>{
{QStringConverter::Latin1,
{"ISO-8859-1", "ANSI_1252", "CP1252", "windows-1252", "LATIN1", "CP819", "CSISO", "IBM819", "ISO_8859-1",
"APPLE ROMAN", "ISO8859-1", "ISO8859-15", "ISO-IR-100", "L1", "IBM 850", "850"}}, // Western Europe
{QStringConverter::Utf8, {"UTF-8", "UTF8", "UTF8-BIT"}},
{QStringConverter::Utf16, {"UTF-16", "UTF16", "UTF16-BIT"}},
{QStringConverter::Utf16BE, {"UTF-16BE"}},
{QStringConverter::Utf16BE, {"UTF-16BE"}},
{QStringConverter::Utf16LE, {"UTF-16LE"}},
{QStringConverter::Utf32, {"UTF-32"}},
{QStringConverter::Utf32BE, {"UTF-32BE"}},
{QStringConverter::Utf32LE, {"UTF-32LE"}},
{QStringConverter::System, {"System"}},
{QStringConverter::Utf32, {"UTF-32"}},
{QStringConverter::Utf32BE, {"UTF-32BE"}},
{QStringConverter::Utf32LE, {"UTF-32LE"}},
{QStringConverter::System, {"System"}},
};
return codecs;
@ -59,27 +58,21 @@ auto QtCodecs() -> QMap<QStringConverter::Encoding, QStringList>
//---------------------------------------------------------------------------------------------------------------------
auto CodecMibs() -> QMap<QStringConverter::Encoding, int>
{
static auto mibs = QMap<QStringConverter::Encoding, int>
{
{QStringConverter::Utf8, 106},
{QStringConverter::Utf16, 1015},
{QStringConverter::Utf16BE, 1013},
{QStringConverter::Utf16LE, 1014},
{QStringConverter::Utf32, 1017},
{QStringConverter::Utf32BE, 1018},
{QStringConverter::Utf32LE, 1019},
{QStringConverter::Latin1, 4},
{QStringConverter::System, 0},
static auto mibs = QMap<QStringConverter::Encoding, int>{
{QStringConverter::Utf8, 106}, {QStringConverter::Utf16, 1015}, {QStringConverter::Utf16BE, 1013},
{QStringConverter::Utf16LE, 1014}, {QStringConverter::Utf32, 1017}, {QStringConverter::Utf32BE, 1018},
{QStringConverter::Utf32LE, 1019}, {QStringConverter::Latin1, 4}, {QStringConverter::System, 0},
};
return mibs;
}
} // namespace
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VTextCodec::VTextCodec(QStringConverter::Encoding encoding)
: m_encoding(encoding)
{}
: m_encoding(encoding)
{
}
//---------------------------------------------------------------------------------------------------------------------
auto VTextCodec::codecForName(const QString &name) -> VTextCodec *

File diff suppressed because it is too large Load Diff

View File

@ -107,10 +107,6 @@
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_MSVC(4701)
// cppcheck-suppress unknownMacro
@ -136,7 +132,7 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
/* To try this out, write "#define INEXACT volatile" below. Normally, */
/* however, INEXACT should be defined to be nothing. ("#define INEXACT".) */
#define INEXACT /* Nothing */
#define INEXACT /* Nothing */
/* #define INEXACT volatile */
#define REALPRINT doubleprint
@ -150,10 +146,9 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
/* which is disastrously slow. A faster way on IEEE machines might be to */
/* mask the appropriate bit, but that's difficult to do in C. */
#define Absolute(a) ((a) >= 0.0 ? (a) : -(a))
#define Absolute(a) ((a) >= 0.0 ? (a) : -(a))
/* #define Absolute(a) fabs(a) */
/* Many of the operations are broken up into two pieces, a main part that */
/* performs an approximate operation, and a "tail" that computes the */
/* roundoff error of that operation. */
@ -167,98 +162,98 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
/* The input parameter `x' (or the highest numbered `x_' parameter) must */
/* also be declared `INEXACT'. */
#define Fast_Two_Sum_Tail(a, b, x, y) \
bvirt = x - a; \
y = b - bvirt
#define Fast_Two_Sum_Tail(a, b, x, y) \
bvirt = x - a; \
y = b - bvirt
#define Fast_Two_Sum(a, b, x, y) \
x = (qreal) (a + b); \
Fast_Two_Sum_Tail(a, b, x, y)
#define Fast_Two_Sum(a, b, x, y) \
x = (qreal)(a + b); \
Fast_Two_Sum_Tail(a, b, x, y)
#define Two_Sum_Tail(a, b, x, y) \
bvirt = (qreal) (x - a); \
avirt = x - bvirt; \
bround = b - bvirt; \
around = a - avirt; \
y = around + bround
#define Two_Sum_Tail(a, b, x, y) \
bvirt = (qreal)(x - a); \
avirt = x - bvirt; \
bround = b - bvirt; \
around = a - avirt; \
y = around + bround
#define Two_Sum(a, b, x, y) \
x = (qreal) (a + b); \
Two_Sum_Tail(a, b, x, y)
#define Two_Sum(a, b, x, y) \
x = (qreal)(a + b); \
Two_Sum_Tail(a, b, x, y)
#define Two_Diff_Tail(a, b, x, y) \
bvirt = (qreal) (a - x); \
avirt = x + bvirt; \
bround = bvirt - b; \
around = a - avirt; \
y = around + bround
#define Two_Diff_Tail(a, b, x, y) \
bvirt = (qreal)(a - x); \
avirt = x + bvirt; \
bround = bvirt - b; \
around = a - avirt; \
y = around + bround
#define Two_Diff(a, b, x, y) \
x = (qreal) (a - b); \
Two_Diff_Tail(a, b, x, y)
#define Two_Diff(a, b, x, y) \
x = (qreal)(a - b); \
Two_Diff_Tail(a, b, x, y)
#define Split(a, ahi, alo) \
c = (qreal) (splitter * a); \
abig = (qreal) (c - a); \
ahi = c - abig; \
alo = a - ahi
#define Split(a, ahi, alo) \
c = (qreal)(splitter * a); \
abig = (qreal)(c - a); \
ahi = c - abig; \
alo = a - ahi
#define Two_Product_Tail(a, b, x, y) \
Split(a, ahi, alo); \
Split(b, bhi, blo); \
err1 = x - (ahi * bhi); \
err2 = err1 - (alo * bhi); \
err3 = err2 - (ahi * blo); \
y = (alo * blo) - err3
#define Two_Product_Tail(a, b, x, y) \
Split(a, ahi, alo); \
Split(b, bhi, blo); \
err1 = x - (ahi * bhi); \
err2 = err1 - (alo * bhi); \
err3 = err2 - (ahi * blo); \
y = (alo * blo) - err3
#define Two_Product(a, b, x, y) \
x = (qreal) (a * b); \
Two_Product_Tail(a, b, x, y)
#define Two_Product(a, b, x, y) \
x = (qreal)(a * b); \
Two_Product_Tail(a, b, x, y)
/* Two_Product_Presplit() is Two_Product() where one of the inputs has */
/* already been split. Avoids redundant splitting. */
#define Two_Product_Presplit(a, b, bhi, blo, x, y) \
x = (qreal) (a * b); \
Split(a, ahi, alo); \
err1 = x - (ahi * bhi); \
err2 = err1 - (alo * bhi); \
err3 = err2 - (ahi * blo); \
y = (alo * blo) - err3
#define Two_Product_Presplit(a, b, bhi, blo, x, y) \
x = (qreal)(a * b); \
Split(a, ahi, alo); \
err1 = x - (ahi * bhi); \
err2 = err1 - (alo * bhi); \
err3 = err2 - (ahi * blo); \
y = (alo * blo) - err3
/* Square() can be done more quickly than Two_Product(). */
#define Square_Tail(a, x, y) \
Split(a, ahi, alo); \
err1 = x - (ahi * ahi); \
err3 = err1 - ((ahi + ahi) * alo); \
y = (alo * alo) - err3
#define Square_Tail(a, x, y) \
Split(a, ahi, alo); \
err1 = x - (ahi * ahi); \
err3 = err1 - ((ahi + ahi) * alo); \
y = (alo * alo) - err3
#define Square(a, x, y) \
x = (qreal) (a * a); \
Square_Tail(a, x, y)
#define Square(a, x, y) \
x = (qreal)(a * a); \
Square_Tail(a, x, y)
/* Macros for summing expansions of various fixed lengths. These are all */
/* unrolled versions of Expansion_Sum(). */
#define Two_One_Sum(a1, a0, b, x2, x1, x0) \
Two_Sum(a0, b , _i, x0); \
Two_Sum(a1, _i, x2, x1)
#define Two_One_Sum(a1, a0, b, x2, x1, x0) \
Two_Sum(a0, b, _i, x0); \
Two_Sum(a1, _i, x2, x1)
#define Two_One_Diff(a1, a0, b, x2, x1, x0) \
Two_Diff(a0, b , _i, x0); \
Two_Sum( a1, _i, x2, x1)
#define Two_One_Diff(a1, a0, b, x2, x1, x0) \
Two_Diff(a0, b, _i, x0); \
Two_Sum(a1, _i, x2, x1)
#define Two_Two_Sum(a1, a0, b1, b0, x3, x2, x1, x0) \
Two_One_Sum(a1, a0, b0, _j, _0, x0); \
Two_One_Sum(_j, _0, b1, x3, x2, x1)
#define Two_Two_Sum(a1, a0, b1, b0, x3, x2, x1, x0) \
Two_One_Sum(a1, a0, b0, _j, _0, x0); \
Two_One_Sum(_j, _0, b1, x3, x2, x1)
#define Two_Two_Diff(a1, a0, b1, b0, x3, x2, x1, x0) \
Two_One_Diff(a1, a0, b0, _j, _0, x0); \
Two_One_Diff(_j, _0, b1, x3, x2, x1)
#define Two_Two_Diff(a1, a0, b1, b0, x3, x2, x1, x0) \
Two_One_Diff(a1, a0, b0, _j, _0, x0); \
Two_One_Diff(_j, _0, b1, x3, x2, x1)
qreal splitter; /* = 2^ceiling(p / 2) + 1. Used to split floats in half. */
qreal epsilon; /* = 2^(-p). Used to estimate roundoff errors. */
qreal splitter; /* = 2^ceiling(p / 2) + 1. Used to split floats in half. */
qreal epsilon; /* = 2^(-p). Used to estimate roundoff errors. */
/* A set of coefficients used to calculate maximum roundoff errors. */
qreal resulterrbound;
qreal ccwerrboundA, ccwerrboundB, ccwerrboundC;
@ -463,8 +458,9 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
Split(b, bhi, blo);
Two_Product_Presplit(e[0], b, bhi, blo, Q, hh);
hindex = 0;
if (hh != 0) {
h[hindex++] = hh;
if (hh != 0)
{
h[hindex++] = hh;
}
for (eindex = 1; eindex < elen; eindex++)
{
@ -579,12 +575,12 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
INEXACT qreal _i, _j;
qreal _0;
adx = (qreal) (pa[0] - pd[0]);
bdx = (qreal) (pb[0] - pd[0]);
cdx = (qreal) (pc[0] - pd[0]);
ady = (qreal) (pa[1] - pd[1]);
bdy = (qreal) (pb[1] - pd[1]);
cdy = (qreal) (pc[1] - pd[1]);
adx = (qreal)(pa[0] - pd[0]);
bdx = (qreal)(pb[0] - pd[0]);
cdx = (qreal)(pc[0] - pd[0]);
ady = (qreal)(pa[1] - pd[1]);
bdy = (qreal)(pb[1] - pd[1]);
cdy = (qreal)(pc[1] - pd[1]);
Two_Product(bdx, cdy, bdxcdy1, bdxcdy0);
Two_Product(cdx, bdy, cdxbdy1, cdxbdy0);
@ -632,19 +628,19 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
Two_Diff_Tail(pb[1], pd[1], bdy, bdytail);
Two_Diff_Tail(pc[0], pd[0], cdx, cdxtail);
Two_Diff_Tail(pc[1], pd[1], cdy, cdytail);
if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0)
&& (adytail == 0.0) && (bdytail == 0.0) && (cdytail == 0.0))
if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0) && (adytail == 0.0) && (bdytail == 0.0) &&
(cdytail == 0.0))
{
return det;
}
errbound = iccerrboundC * permanent + resulterrbound * Absolute(det);
det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail) - (bdy * cdxtail + cdx * bdytail))
+ 2.0 * (adx * adxtail + ady * adytail) * (bdx * cdy - bdy * cdx))
+ ((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail) - (cdy * adxtail + adx * cdytail))
+ 2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx))
+ ((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - (ady * bdxtail + bdx * adytail))
+ 2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx));
det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail) - (bdy * cdxtail + cdx * bdytail)) +
2.0 * (adx * adxtail + ady * adytail) * (bdx * cdy - bdy * cdx)) +
((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail) - (cdy * adxtail + adx * cdytail)) +
2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx)) +
((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - (ady * bdxtail + bdx * adytail)) +
2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx));
if ((det >= errbound) || (-det >= errbound))
{
return det;
@ -689,7 +685,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (adytail != 0.0)
{
@ -705,7 +703,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (bdxtail != 0.0)
{
@ -721,7 +721,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (bdytail != 0.0)
{
@ -737,7 +739,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (cdxtail != 0.0)
{
@ -750,13 +754,12 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
cxtaalen = scale_expansion_zeroelim(4, aa, cdxtail, cxtaa);
temp16clen = scale_expansion_zeroelim(cxtaalen, cxtaa, -bdy, temp16c);
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a,
temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c,
temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len,
temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (cdytail != 0.0)
{
@ -772,7 +775,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if ((adxtail != 0.0) || (adytail != 0.0))
@ -812,20 +817,26 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = scale_expansion_zeroelim(axtbctlen, axtbct, 2.0 * adx, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
if (bdytail != 0.0)
{
temp8len = scale_expansion_zeroelim(4, cc, adxtail, temp8);
temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (cdytail != 0.0)
{
temp8len = scale_expansion_zeroelim(4, bb, -adxtail, temp8);
temp16alen = scale_expansion_zeroelim(temp8len, temp8, cdytail, temp16a);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
temp32alen = scale_expansion_zeroelim(axtbctlen, axtbct, adxtail, temp32a);
@ -835,7 +846,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (adytail != 0.0)
{
@ -844,8 +857,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, 2.0 * ady, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, adytail, temp32a);
aytbcttlen = scale_expansion_zeroelim(bcttlen, bctt, adytail, aytbctt);
@ -854,7 +868,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
}
if ((bdxtail != 0.0) || (bdytail != 0.0))
@ -923,7 +939,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (bdytail != 0.0)
{
@ -936,7 +954,6 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
finnow = finother;
finother = finswap;
temp32alen = scale_expansion_zeroelim(bytcatlen, bytcat, bdytail, temp32a);
bytcattlen = scale_expansion_zeroelim(cattlen, catt, bdytail, bytcatt);
temp16alen = scale_expansion_zeroelim(bytcattlen, bytcatt, 2.0 * bdy, temp16a);
@ -1003,7 +1020,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp8len = scale_expansion_zeroelim(4, aa, -cdxtail, temp8);
temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
temp32alen = scale_expansion_zeroelim(cxtabtlen, cxtabt, cdxtail, temp32a);
@ -1028,7 +1047,6 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
finnow = finother;
finother = finswap;
temp32alen = scale_expansion_zeroelim(cytabtlen, cytabt, cdytail, temp32a);
cytabttlen = scale_expansion_zeroelim(abttlen, abtt, cdytail, cytabtt);
temp16alen = scale_expansion_zeroelim(cytabttlen, cytabtt, 2.0 * cdy, temp16a);
@ -1036,7 +1054,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
}
@ -1070,13 +1090,10 @@ auto incircle(qreal *pa, qreal *pb, qreal *pc, qreal *pd) -> qreal
bdxady = bdx * ady;
clift = cdx * cdx + cdy * cdy;
det = alift * (bdxcdy - cdxbdy)
+ blift * (cdxady - adxcdy)
+ clift * (adxbdy - bdxady);
det = alift * (bdxcdy - cdxbdy) + blift * (cdxady - adxcdy) + clift * (adxbdy - bdxady);
permanent = (Absolute(bdxcdy) + Absolute(cdxbdy)) * alift
+ (Absolute(cdxady) + Absolute(adxcdy)) * blift
+ (Absolute(adxbdy) + Absolute(bdxady)) * clift;
permanent = (Absolute(bdxcdy) + Absolute(cdxbdy)) * alift + (Absolute(cdxady) + Absolute(adxcdy)) * blift +
(Absolute(adxbdy) + Absolute(bdxady)) * clift;
errbound = iccerrboundA * permanent;
if ((det > errbound) || (-det > errbound))
{

View File

@ -37,7 +37,10 @@
//---------------------------------------------------------------------------------------------------------------------
VObjPaintDevice::VObjPaintDevice()
:QPaintDevice(), engine(new VObjEngine()), fileName(), owns_iodevice(1)
: QPaintDevice(),
engine(new VObjEngine()),
fileName(),
owns_iodevice(1)
{
owns_iodevice = static_cast<int>(false);
}

View File

@ -61,11 +61,11 @@ auto GetSeamPassmarkSAPoint(const VPiecePassmarkData &passmarkData, const QVecto
if (needRollback && not seamAllowance.isEmpty())
{
ekvPoints.clear();
ekvPoints += VRawSAPoint(seamAllowance.at(seamAllowance.size()-1));
ekvPoints += VRawSAPoint(seamAllowance.at(seamAllowance.size() - 1));
}
if (ekvPoints.isEmpty())
{ // Just in case
{ // Just in case
return PassmarkStatus::Error; // Something wrong
}
@ -80,9 +80,9 @@ auto PointsToSegments(const QVector<QPointF> &points) -> QVector<QLineF>
if (points.size() >= 2)
{
lines.reserve(points.size() - 1);
for (int i=0; i < points.size()-1; ++i)
for (int i = 0; i < points.size() - 1; ++i)
{
QLineF segment = QLineF(points.at(i), points.at(i+1));
QLineF segment = QLineF(points.at(i), points.at(i + 1));
if (segment.length() > 0)
{
lines.append(segment);
@ -604,15 +604,14 @@ auto VPiecePassmarkData::toJson() const -> QJsonObject
//---------------------------------------------------------------------------------------------------------------------
VPassmark::VPassmark(const VPiecePassmarkData &data)
: m_data(data),
m_null(false)
: m_data(data),
m_null(false)
{
// Correct distorsion
if (VGObject::IsPointOnLineSegment(m_data.passmarkSAPoint, m_data.previousSAPoint,
m_data.nextSAPoint))
if (VGObject::IsPointOnLineSegment(m_data.passmarkSAPoint, m_data.previousSAPoint, m_data.nextSAPoint))
{
const QPointF p = VGObject::CorrectDistortion(m_data.passmarkSAPoint, m_data.previousSAPoint,
m_data.nextSAPoint);
const QPointF p =
VGObject::CorrectDistortion(m_data.passmarkSAPoint, m_data.previousSAPoint, m_data.nextSAPoint);
m_data.passmarkSAPoint.setX(p.x());
m_data.passmarkSAPoint.setY(p.y());
}
@ -630,16 +629,14 @@ auto VPassmark::FullPassmark(const VPiece &piece, const VContainer *data) const
{
QVector<QLineF> lines;
lines += SAPassmark(piece, data, PassmarkSide::All);
if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark()
&& (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath())
&& m_data.isMainPathNode
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection
&& m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft
&& m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyRight
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection2
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyLeft
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight
&& m_data.isShowSecondPassmark)
if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark() &&
(VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath()) &&
m_data.isMainPathNode && m_data.passmarkAngleType != PassmarkAngleType::Intersection &&
m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft &&
m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyRight &&
m_data.passmarkAngleType != PassmarkAngleType::Intersection2 &&
m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyLeft &&
m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight && m_data.isShowSecondPassmark)
{
lines += BuiltInSAPassmark(piece, data);
}
@ -713,7 +710,7 @@ auto VPassmark::Data() const -> VPiecePassmarkData
auto VPassmark::FindIntersection(const QLineF &line, const QVector<QPointF> &seamAllowance) -> QLineF
{
QLineF testLine = line;
testLine.setLength(testLine.length()*10);
testLine.setLength(testLine.length() * 10);
QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(seamAllowance, testLine);
if (not intersections.isEmpty())
{
@ -940,10 +937,10 @@ auto VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const -> QVector<
{
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2' with built "
"in seam allowance. User must manually provide length.")
.arg(m_data.nodeName, m_data.pieceName);
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return {};
}
}
@ -952,7 +949,7 @@ auto VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const -> QVector<
QLineF edge1 = QLineF(m_data.passmarkSAPoint, m_data.previousSAPoint);
QLineF edge2 = QLineF(m_data.passmarkSAPoint, m_data.nextSAPoint);
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2)/2.);
edge1.setAngle(edge1.angle() + edge1.angleTo(edge2) / 2.);
edge1.setLength(length);
return {edge1};
@ -994,9 +991,11 @@ auto VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowance, const
if (rotatedSeamAllowance.size() < 2)
{
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Seam allowance is "
"empty.").arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
"empty.")
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return {}; // Something wrong
}
@ -1007,12 +1006,13 @@ auto VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowance, const
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find "
"position for a notch.")
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return {}; // Something wrong
}
const QVector<QPointF>& path = (m_data.passmarkAngleType == PassmarkAngleType::Straightforward ||
const QVector<QPointF> &path = (m_data.passmarkAngleType == PassmarkAngleType::Straightforward ||
m_data.passmarkAngleType == PassmarkAngleType::Bisector)
? rotatedSeamAllowance
: seamAllowance;
@ -1022,8 +1022,9 @@ auto VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowance, const
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Unable to fix a "
"notch position.")
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward)

View File

@ -21,7 +21,6 @@
#ifndef VFILEPROPERTYEDITOR_H
#define VFILEPROPERTYEDITOR_H
#include <QLineEdit>
#include <QMetaObject>
#include <QMimeData>
@ -49,10 +48,9 @@ class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget
Q_OBJECT // NOLINT
public:
explicit VFileEditWidget(QWidget* parent, bool is_directory = false);
explicit VFileEditWidget(QWidget *parent, bool is_directory = false);
virtual ~VFileEditWidget() override;
//! This function returns the file currently set to this editor
auto getFile() const -> QString;
@ -67,12 +65,11 @@ signals:
//! This signal is emitted when the user changed the curret file.
//! Actions triggering this signal are either using the file dialog
//! to select a new file or changing the file path in the line edit.
void dataChangedByUser(const QString &getFile, VFileEditWidget* editor);
void dataChangedByUser(const QString &getFile, VFileEditWidget *editor);
//! This signal is emitted whenever dataChangedByUser() gets emmitted
//! and is connected to the delegate's commitData() signal
void commitData(QWidget* editor);
void commitData(QWidget *editor);
public slots:
//! Sets the current file, does not check if it is valid
@ -84,7 +81,7 @@ public slots:
//! Sets a filter for the file field
//! \param dialog_filter The filter used for the File Dialog
//! \param filter_list The list of file endings. The filters are being checked using regular expressions
void setFilter(const QString& dialog_filter = QString(), const QStringList& filter_list = QStringList());
void setFilter(const QString &dialog_filter = QString(), const QStringList &filter_list = QStringList());
//! Sets whether the property stores a directory or a file
void setDirectory(bool dir);
@ -94,10 +91,10 @@ private slots:
void onToolButtonClicked();
protected:
virtual void dragEnterEvent(QDragEnterEvent* event) override;
virtual void dragMoveEvent(QDragMoveEvent* event) override;
virtual void dragLeaveEvent(QDragLeaveEvent* event) override;
virtual void dropEvent(QDropEvent* event) override;
virtual void dragEnterEvent(QDragEnterEvent *event) override;
virtual void dragMoveEvent(QDragMoveEvent *event) override;
virtual void dragLeaveEvent(QDragLeaveEvent *event) override;
virtual void dropEvent(QDropEvent *event) override;
//! This function checks the mime data, if it is compatible with the filters
virtual auto checkMimeData(const QMimeData *data, QString &file) const -> bool;
@ -106,8 +103,8 @@ protected:
virtual auto checkFileFilter(const QString &file) const -> bool;
QString CurrentFilePath;
QToolButton* ToolButton;
QLineEdit* FileLineEdit;
QToolButton *ToolButton;
QLineEdit *FileLineEdit;
QString FileDialogFilter;
QStringList FilterList;
@ -120,6 +117,6 @@ private:
QT_WARNING_POP
}
} // namespace VPE
#endif // VFILEPROPERTYEDITOR_H

View File

@ -50,6 +50,6 @@ public:
QT_WARNING_POP
}
} // namespace VPE
#endif // VABSTRACTPROPERTYFACTORY_H

View File

@ -38,10 +38,10 @@ class VPropertyFormViewPrivate : public VPropertyFormWidgetPrivate
{
public:
//! The current property model
VPropertyModel* Model;
VPropertyModel *Model;
//! The currently used property set
VPropertySet* PropertySet;
VPropertySet *PropertySet;
//! Determines whether the widget needs to be rebuild
bool NeedsRebuild;
@ -50,19 +50,31 @@ public:
bool IgnoreDataChangedSignal;
VPropertyFormViewPrivate()
: VPropertyFormWidgetPrivate(), Model(nullptr), PropertySet(nullptr), NeedsRebuild(false),
IgnoreDataChangedSignal(false)
{}
: VPropertyFormWidgetPrivate(),
Model(nullptr),
PropertySet(nullptr),
NeedsRebuild(false),
IgnoreDataChangedSignal(false)
{
}
explicit VPropertyFormViewPrivate(VPropertyModel* prop_model)
: VPropertyFormWidgetPrivate(), Model(prop_model), PropertySet(nullptr), NeedsRebuild(false),
IgnoreDataChangedSignal(false)
{}
explicit VPropertyFormViewPrivate(VPropertyModel *prop_model)
: VPropertyFormWidgetPrivate(),
Model(prop_model),
PropertySet(nullptr),
NeedsRebuild(false),
IgnoreDataChangedSignal(false)
{
}
explicit VPropertyFormViewPrivate(VPropertySet* prop_set)
: VPropertyFormWidgetPrivate(), Model(nullptr), PropertySet(prop_set), NeedsRebuild(false),
IgnoreDataChangedSignal(false)
{}
explicit VPropertyFormViewPrivate(VPropertySet *prop_set)
: VPropertyFormWidgetPrivate(),
Model(nullptr),
PropertySet(prop_set),
NeedsRebuild(false),
IgnoreDataChangedSignal(false)
{
}
virtual ~VPropertyFormViewPrivate() override {}
@ -72,6 +84,6 @@ private:
QT_WARNING_POP
}
} // namespace VPE
#endif // VPROPERTYFORMVIEW_P_H

View File

@ -23,8 +23,8 @@
// ONLY INCLUDE THIS IN .CPP FILES
#include <QList>
#include "vproperty.h"
#include <QList>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
@ -41,16 +41,28 @@ public:
//! Stores either another VPropertyFormWidget (then Editor is null) or an editor widget (then FormWidget is null)
struct SEditorWidget
{
SEditorWidget() : FormWidget(nullptr), Editor(nullptr) {}
explicit SEditorWidget(VPropertyFormWidget* form_widget) : FormWidget(form_widget), Editor(nullptr) {}
explicit SEditorWidget(QWidget* editor_widget) : FormWidget(nullptr), Editor(editor_widget) {}
SEditorWidget()
: FormWidget(nullptr),
Editor(nullptr)
{
}
explicit SEditorWidget(VPropertyFormWidget *form_widget)
: FormWidget(form_widget),
Editor(nullptr)
{
}
explicit SEditorWidget(QWidget *editor_widget)
: FormWidget(nullptr),
Editor(editor_widget)
{
}
VPropertyFormWidget* FormWidget;
QWidget* Editor;
VPropertyFormWidget *FormWidget;
QWidget *Editor;
};
//! The root property to use
QList<VProperty*> Properties;
QList<VProperty *> Properties;
//! Binds the properties to their editors
QList<SEditorWidget> EditorWidgets;
@ -61,19 +73,25 @@ public:
//! Default constructor
VPropertyFormWidgetPrivate()
: Properties(QList<VProperty*>()), EditorWidgets(QList<SEditorWidget>()), UpdateEditors(true)
{}
: Properties(QList<VProperty *>()),
EditorWidgets(QList<SEditorWidget>()),
UpdateEditors(true)
{
}
//! Constructor
explicit VPropertyFormWidgetPrivate(const QList<VProperty*>& properties)
: Properties(properties), EditorWidgets(QList<SEditorWidget>()), UpdateEditors(true)
{}
explicit VPropertyFormWidgetPrivate(const QList<VProperty *> &properties)
: Properties(properties),
EditorWidgets(QList<SEditorWidget>()),
UpdateEditors(true)
{
}
virtual ~VPropertyFormWidgetPrivate() {}
};
QT_WARNING_POP
}
} // namespace VPE
#endif // VPROPERTYFORMWIDGET_P_H

View File

@ -44,18 +44,24 @@ public:
QPointer<QWidget> Widget;
//! Constructor passing name and type
VWidgetPropertyPrivate(const QString& name,
VWidgetPropertyPrivate(const QString &name,
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QMetaType::Type type,
#else
QVariant::Type type,
#endif
QWidget* widget = nullptr)
: VPropertyPrivate(name, type), Widget(widget) {}
QWidget *widget = nullptr)
: VPropertyPrivate(name, type),
Widget(widget)
{
}
//! Constructor
VWidgetPropertyPrivate()
: VPropertyPrivate(), Widget(nullptr) {}
: VPropertyPrivate(),
Widget(nullptr)
{
}
//! Destructor
virtual ~VWidgetPropertyPrivate() override
@ -69,6 +75,6 @@ public:
QT_WARNING_POP
} // namespace VPE
} // namespace VPE
#endif // VWIDGETPROPERTY_P_H

View File

@ -28,8 +28,6 @@
#include "vtoolflippingbyaxis.h"
#include <climits>
#include <qiterator.h>
#include <QColor>
#include <QDomNode>
#include <QDomNodeList>
@ -37,28 +35,27 @@
#include <QPoint>
#include <QSharedPointer>
#include <QUndoStack>
#include <climits>
#include <new>
#include <qiterator.h>
#include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../dialogs/tools/dialogflippingbyaxis.h"
#include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../visualization/line/operation/vistoolflippingbyaxis.h"
#include "../../../../visualization/visualization.h"
#include "../vgeometry/vpointf.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../ifc/ifcdef.h"
#include "../ifc/exception/vexception.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../../../vabstracttool.h"
#include "../../../vdatatool.h"
#include "../../vdrawtool.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/ifcdef.h"
#include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
template <class T> class QSharedPointer;
@ -102,7 +99,7 @@ auto VToolFlippingByAxis::Create(const QPointer<DialogTool> &dialog, VMainGraphi
initData.typeCreation = Source::FromGui;
initData.notes = dialogTool->GetNotes();
VToolFlippingByAxis* operation = Create(initData);
VToolFlippingByAxis *operation = Create(initData);
if (operation != nullptr)
{
operation->m_dialog = dialog;
@ -191,10 +188,10 @@ void VToolFlippingByAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *event,
{
ContextMenu<DialogFlippingByAxis>(event, id);
}
catch(const VExceptionToolWasDeleted &e)
catch (const VExceptionToolWasDeleted &e)
{
Q_UNUSED(e)
return;//Leave this method immediately!!!
return; // Leave this method immediately!!!
}
}
@ -229,7 +226,7 @@ void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList<quint32> &ol
doc->SetAttribute(domElement, AttrAxisType, QString().setNum(static_cast<int>(dialogTool->GetAxisType())));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
[](const QString &notes) noexcept {return notes.isEmpty();});
[](const QString &notes) noexcept { return notes.isEmpty(); });
source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement);
@ -262,15 +259,15 @@ auto VToolFlippingByAxis::MakeToolTip() const -> QString
{
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>"
"%3")
.arg(tr("Origin point"), OriginPointName()) // 1, 2
.arg(VisibilityGroupToolTip()); // 3
.arg(tr("Origin point"), OriginPointName()) // 1, 2
.arg(VisibilityGroupToolTip()); // 3
}
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent)
: VAbstractFlipping(initData, parent),
m_originPointId(initData.originPointId),
m_axisType(initData.axisType)
: VAbstractFlipping(initData, parent),
m_originPointId(initData.originPointId),
m_axisType(initData.axisType)
{
InitOperatedObjects();
ToolCreation(initData.typeCreation);

View File

@ -28,8 +28,6 @@
#include "vtoolflippingbyline.h"
#include <climits>
#include <qiterator.h>
#include <QColor>
#include <QDomNode>
#include <QDomNodeList>
@ -37,14 +35,20 @@
#include <QPoint>
#include <QSharedPointer>
#include <QUndoStack>
#include <climits>
#include <new>
#include <qiterator.h>
#include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../dialogs/tools/dialogflippingbyline.h"
#include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../visualization/line/operation/vistoolflippingbyline.h"
#include "../../../../visualization/visualization.h"
#include "../../../vabstracttool.h"
#include "../../../vdatatool.h"
#include "../../vdrawtool.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/ifcdef.h"
#include "../vgeometry/vpointf.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
@ -52,13 +56,9 @@
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../ifc/ifcdef.h"
#include "../ifc/exception/vexception.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../../../vabstracttool.h"
#include "../../../vdatatool.h"
#include "../../vdrawtool.h"
template <class T> class QSharedPointer;
@ -102,7 +102,7 @@ auto VToolFlippingByLine::Create(const QPointer<DialogTool> &dialog, VMainGraphi
initData.typeCreation = Source::FromGui;
initData.notes = dialogTool->GetNotes();
VToolFlippingByLine* operation = Create(initData);
VToolFlippingByLine *operation = Create(initData);
if (operation != nullptr)
{
operation->m_dialog = dialog;
@ -176,10 +176,10 @@ void VToolFlippingByLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event,
{
ContextMenu<DialogFlippingByLine>(event, id);
}
catch(const VExceptionToolWasDeleted &e)
catch (const VExceptionToolWasDeleted &e)
{
Q_UNUSED(e)
return;//Leave this method immediately!!!
return; // Leave this method immediately!!!
}
}
@ -216,7 +216,7 @@ void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList<quint32> &ol
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId()));
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
[](const QString &notes) noexcept {return notes.isEmpty();});
[](const QString &notes) noexcept { return notes.isEmpty(); });
source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement);
@ -250,16 +250,15 @@ auto VToolFlippingByLine::MakeToolTip() const -> QString
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>"
"<tr> <td><b>%3:</b> %4</td> </tr>"
"%5")
.arg(tr("First line point"), FirstLinePointName(),
tr("Second line point"), SecondLinePointName()) // 1, 2, 3, 4
.arg(VisibilityGroupToolTip()); // 5
.arg(tr("First line point"), FirstLinePointName(), tr("Second line point"), SecondLinePointName()) // 1, 2, 3, 4
.arg(VisibilityGroupToolTip()); // 5
}
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByLine::VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent)
: VAbstractFlipping(initData, parent),
m_firstLinePointId(initData.firstLinePointId),
m_secondLinePointId(initData.secondLinePointId)
: VAbstractFlipping(initData, parent),
m_firstLinePointId(initData.firstLinePointId),
m_secondLinePointId(initData.secondLinePointId)
{
InitOperatedObjects();
ToolCreation(initData.typeCreation);

View File

@ -28,8 +28,6 @@
#include "vtoolmove.h"
#include <climits>
#include <qiterator.h>
#include <QColor>
#include <QDomNode>
#include <QDomNodeList>
@ -37,37 +35,39 @@
#include <QPoint>
#include <QSharedPointer>
#include <QUndoStack>
#include <climits>
#include <new>
#include <qiterator.h>
#include "../../../dialogs/tools/dialogtool.h"
#include "../../../dialogs/tools/dialogmove.h"
#include "../../../dialogs/tools/dialogtool.h"
#include "../../../visualization/line/operation/vistoolmove.h"
#include "../../../visualization/visualization.h"
#include "../../vabstracttool.h"
#include "../../vdatatool.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/ifcdef.h"
#include "../vdrawtool.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vspline.h"
#include "../vgeometry/vsplinepath.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/compatibility.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../ifc/ifcdef.h"
#include "../ifc/exception/vexception.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../../vabstracttool.h"
#include "../../vdatatool.h"
#include "../vdrawtool.h"
template <class T> class QSharedPointer;
@ -89,7 +89,7 @@ auto GetOriginPoint(const QVector<SourceItem> &objects, const VContainer *data,
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
switch(static_cast<GOType>(obj->getType()))
switch (static_cast<GOType>(obj->getType()))
{
case GOType::Point:
originObjects.append(data->GeometricObject<VPointF>(object.id)->toQPointF());
@ -110,12 +110,12 @@ auto GetOriginPoint(const QVector<SourceItem> &objects, const VContainer *data,
}
QPointF rotationOrigin = originObjects.boundingRect().center();
QLineF move(rotationOrigin, QPointF(rotationOrigin.x()+calcLength, rotationOrigin.y()));
QLineF move(rotationOrigin, QPointF(rotationOrigin.x() + calcLength, rotationOrigin.y()));
move.setAngle(calcAngle);
return move.p2();
}
QT_WARNING_POP
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::SetDialog()
@ -159,7 +159,7 @@ auto VToolMove::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *s
initData.typeCreation = Source::FromGui;
initData.notes = dialogTool->GetNotes();
VToolMove* operation = Create(initData);
VToolMove *operation = Create(initData);
if (operation != nullptr)
{
operation->m_dialog = dialog;
@ -176,8 +176,8 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove *
calcAngle = CheckFormula(initData.id, initData.formulaAngle, initData.data);
calcRotationAngle = CheckFormula(initData.id, initData.formulaRotationAngle, initData.data);
calcLength = VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formulaLength,
initData.data));
calcLength =
VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data));
QPointF rotationOrigin;
QSharedPointer<VPointF> originPoint;
@ -194,9 +194,9 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove *
if (initData.typeCreation == Source::FromGui)
{
initData.destination.clear();// Try to avoid mistake, value must be empty
initData.destination.clear(); // Try to avoid mistake, value must be empty
initData.id = initData.data->getNextId();//Just reserve id for tool
initData.id = initData.data->getNextId(); // Just reserve id for tool
for (auto object : qAsConst(initData.source))
{
@ -205,9 +205,9 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove *
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch (static_cast<GOType>(obj->getType()))
{
case GOType::Point:
initData.destination.append(CreatePoint(initData.id, object, calcAngle, calcLength,
@ -230,10 +230,9 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
initData.data));
break;
case GOType::SplinePath:
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle,
calcLength, calcRotationAngle,
rotationOrigin, initData.suffix,
initData.data));
initData.destination.append(CreateCurveWithSegments<VSplinePath>(
initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix,
initData.data));
break;
case GOType::CubicBezier:
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength,
@ -241,19 +240,16 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
initData.suffix, initData.data));
break;
case GOType::CubicBezierPath:
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object,
calcAngle, calcLength,
calcRotationAngle,
rotationOrigin,
initData.suffix,
initData.data));
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(
initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix,
initData.data));
break;
case GOType::Unknown:
case GOType::PlaceLabel:
Q_UNREACHABLE();
break;
}
QT_WARNING_POP
QT_WARNING_POP
}
}
else
@ -266,9 +262,9 @@ QT_WARNING_POP
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch (static_cast<GOType>(obj->getType()))
{
case GOType::Point:
UpdatePoint(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
@ -284,31 +280,30 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
initData.destination.at(i).id);
break;
case GOType::Spline:
UpdateCurve<VSpline>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
rotationOrigin, initData.suffix, initData.data, initData.destination.at(i).id);
UpdateCurve<VSpline>(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
initData.suffix, initData.data, initData.destination.at(i).id);
break;
case GOType::SplinePath:
UpdateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle, calcLength,
calcRotationAngle, rotationOrigin,initData.suffix,
initData.data, initData.destination.at(i).id);
UpdateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
rotationOrigin, initData.suffix, initData.data,
initData.destination.at(i).id);
break;
case GOType::CubicBezier:
UpdateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
rotationOrigin,initData.suffix, initData.data,
rotationOrigin, initData.suffix, initData.data,
initData.destination.at(i).id);
break;
case GOType::CubicBezierPath:
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, object, calcAngle, calcLength,
calcRotationAngle, rotationOrigin,
initData.suffix, initData.data,
initData.destination.at(i).id);
calcRotationAngle, rotationOrigin, initData.suffix,
initData.data, initData.destination.at(i).id);
break;
case GOType::Unknown:
case GOType::PlaceLabel:
Q_UNREACHABLE();
break;
}
QT_WARNING_POP
QT_WARNING_POP
}
if (initData.parse != Document::FullParse)
{
@ -445,10 +440,10 @@ void VToolMove::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 i
{
ContextMenu<DialogMove>(event, id);
}
catch(const VExceptionToolWasDeleted &e)
catch (const VExceptionToolWasDeleted &e)
{
Q_UNUSED(e)
return;//Leave this method immediately!!!
return; // Leave this method immediately!!!
}
}
@ -489,7 +484,7 @@ void VToolMove::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependenc
doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetRotationOrigPointId()));
doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle());
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
[](const QString &notes) noexcept {return notes.isEmpty();});
[](const QString &notes) noexcept { return notes.isEmpty(); });
source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement);
@ -529,25 +524,25 @@ auto VToolMove::MakeToolTip() const -> QString
"<tr> <td><b>%6:</b> %7°</td> </tr>"
"<tr> <td><b>%8:</b> %9</td> </tr>"
"%10")
.arg(tr("Angle")) // 1
.arg(GetFormulaAngle().getDoubleValue()) // 2
.arg(tr("Length")) // 3
.arg(GetFormulaLength().getDoubleValue()) // 4
.arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), // 5
tr("Rotation angle")) // 6
.arg(GetFormulaRotationAngle().getDoubleValue()) // 7
.arg(tr("Rotation origin point"), // 8
OriginPointName()) // 9
.arg(VisibilityGroupToolTip()); // 10
.arg(tr("Angle")) // 1
.arg(GetFormulaAngle().getDoubleValue()) // 2
.arg(tr("Length")) // 3
.arg(GetFormulaLength().getDoubleValue()) // 4
.arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), // 5
tr("Rotation angle")) // 6
.arg(GetFormulaRotationAngle().getDoubleValue()) // 7
.arg(tr("Rotation origin point"), // 8
OriginPointName()) // 9
.arg(VisibilityGroupToolTip()); // 10
}
//---------------------------------------------------------------------------------------------------------------------
VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
: VAbstractOperation(initData, parent),
formulaAngle(initData.formulaAngle),
formulaRotationAngle(initData.formulaRotationAngle),
formulaLength(initData.formulaLength),
origPointId(initData.rotationOrigin)
: VAbstractOperation(initData, parent),
formulaAngle(initData.formulaAngle),
formulaRotationAngle(initData.formulaRotationAngle),
formulaLength(initData.formulaLength),
origPointId(initData.rotationOrigin)
{
InitOperatedObjects();
ToolCreation(initData.typeCreation);
@ -579,8 +574,8 @@ template <class Item>
auto VToolMove::CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data) -> DestinationItem
{
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
data);
const DestinationItem item =
CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data);
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
return item;
}
@ -648,8 +643,8 @@ template <class Item>
auto VToolMove::CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data) -> DestinationItem
{
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
data);
const DestinationItem item =
CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data);
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
return item;
}
@ -660,8 +655,8 @@ auto VToolMove::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem,
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
VContainer *data) -> DestinationItem
{
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
data);
const DestinationItem item =
CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data);
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
return item;
}

View File

@ -42,6 +42,11 @@
#include "../../../dialogs/tools/dialogtool.h"
#include "../../../visualization/line/operation/vistoolrotation.h"
#include "../../../visualization/visualization.h"
#include "../../vabstracttool.h"
#include "../../vdatatool.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/ifcdef.h"
#include "../vdrawtool.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
@ -52,17 +57,12 @@
#include "../vgeometry/vsplinepath.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../vpatterndb/vtranslatevars.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../../vabstracttool.h"
#include "../../vdatatool.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/ifcdef.h"
#include "../vdrawtool.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../vwidgets/vmaingraphicsscene.h"
class QDomElement;

View File

@ -27,23 +27,23 @@
*************************************************************************/
#include "vabstractmainwindow.h"
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/def.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vsysexits.h"
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "dialogs/dialogexporttocsv.h"
#include <QStyle>
#include <QToolBar>
#include <QFileDialog>
#include <QAction>
#include <QFileDialog>
#include <QLockFile>
#include <QMessageBox>
#include <QStyle>
#include <QToolBar>
//#ifdef Q_OS_WIN
//extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
//#endif /*Q_OS_WIN*/
// #ifdef Q_OS_WIN
// extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
// #endif /*Q_OS_WIN*/
#if defined(Q_OS_MAC)
#include <QStyleFactory>
@ -75,7 +75,7 @@ auto RecentFiles(const QStringList &paths) -> QStringList
QVector<QStringList> table;
table.reserve(paths.size());
for(const auto &path : paths)
for (const auto &path : paths)
{
table.append(SplitFilePaths(path));
}
@ -83,7 +83,7 @@ auto RecentFiles(const QStringList &paths) -> QStringList
auto CreateOptimized = [table](int tableRow)
{
QStringList optimized;
const QStringList& path = table.at(tableRow);
const QStringList &path = table.at(tableRow);
for (int count = 1; count <= path.size(); ++count)
{
bool isUnique = true;
@ -130,20 +130,20 @@ auto RecentFiles(const QStringList &paths) -> QStringList
QStringList recentFiles;
recentFiles.reserve(paths.size());
for(auto &path : optimizedPaths)
for (auto &path : optimizedPaths)
{
recentFiles.append(path.join(QDir::separator()));
}
return recentFiles;
}
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VAbstractMainWindow::VAbstractMainWindow(QWidget *parent)
: QMainWindow(parent),
m_curFileFormatVersion(0x0),
m_curFileFormatVersionStr(QLatin1String("0.0.0"))
: QMainWindow(parent),
m_curFileFormatVersion(0x0),
m_curFileFormatVersionStr(QLatin1String("0.0.0"))
{
for (int i = 0; i < MaxRecentFiles; ++i)
{
@ -169,7 +169,8 @@ auto VAbstractMainWindow::ContinueFormatRewrite(const QString &currentFormatVers
msgBox.setText(tr("This file is using previous format version v%1. The current is v%2. "
"Saving the file with this app version will update the format version for this "
"file. This may prevent you from be able to open the file with older app versions. "
"Do you really want to continue?").arg(currentFormatVersion, maxFormatVersion));
"Do you really want to continue?")
.arg(currentFormatVersion, maxFormatVersion));
msgBox.setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
msgBox.setDefaultButton(QDialogButtonBox::No);
msgBox.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32));
@ -212,7 +213,7 @@ auto VAbstractMainWindow::CSVFilePath() -> QString
return fileName;
}
QFileInfo f( fileName );
QFileInfo f(fileName);
if (f.suffix().isEmpty() && f.suffix() != suffix)
{
fileName += QChar('.') + suffix;
@ -250,7 +251,7 @@ void VAbstractMainWindow::UpdateRecentFileActions()
}
}
m_separatorAct->setVisible(numRecentFiles>0);
m_separatorAct->setVisible(numRecentFiles > 0);
}
//---------------------------------------------------------------------------------------------------------------------
@ -258,9 +259,9 @@ auto VAbstractMainWindow::CheckFilePermissions(const QString &path, QWidget *mes
{
QFileInfo info(path);
//#ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup++; // turn checking on
//#endif /*Q_OS_WIN32*/
// #ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup++; // turn checking on
// #endif /*Q_OS_WIN32*/
if (not info.exists())
{
@ -269,9 +270,9 @@ auto VAbstractMainWindow::CheckFilePermissions(const QString &path, QWidget *mes
const bool isFileWritable = info.isWritable();
//#ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup--; // turn it off again
//#endif /*Q_OS_WIN32*/
// #ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup--; // turn it off again
// #endif /*Q_OS_WIN32*/
if (not isFileWritable)
{
@ -284,13 +285,13 @@ auto VAbstractMainWindow::CheckFilePermissions(const QString &path, QWidget *mes
if (messageBox.exec() == QMessageBox::Yes)
{
//#ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup++; // turn checking on
//#endif /*Q_OS_WIN32*/
// #ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup++; // turn checking on
// #endif /*Q_OS_WIN32*/
bool changed = QFile::setPermissions(path, QFileInfo(path).permissions() | QFileDevice::WriteUser);
//#ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup--; // turn it off again
//#endif /*Q_OS_WIN32*/
// #ifdef Q_OS_WIN32
// qt_ntfs_permission_lookup--; // turn it off again
// #endif /*Q_OS_WIN32*/
if (not changed)
{
@ -317,27 +318,27 @@ auto VAbstractMainWindow::IgnoreLocking(int error, const QString &path, bool gui
QMessageBox::StandardButton answer = QMessageBox::Abort;
if (guiMode)
{
switch(error)
switch (error)
{
case QLockFile::LockFailedError:
answer = QMessageBox::warning(this, tr("Locking file"),
tr("This file already opened in another window. Ignore if you want "
"to continue (not recommended, can cause a data corruption)."),
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
QMessageBox::Abort | QMessageBox::Ignore, QMessageBox::Abort);
break;
case QLockFile::PermissionError:
answer = QMessageBox::question(this, tr("Locking file"),
tr("The lock file could not be created, for lack of permissions. "
"Ignore if you want to continue (not recommended, can cause "
"a data corruption)."),
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
QMessageBox::Abort | QMessageBox::Ignore, QMessageBox::Abort);
break;
case QLockFile::UnknownError:
answer = QMessageBox::question(this, tr("Locking file"),
tr("Unknown error happened, for instance a full partition "
"prevented writing out the lock file. Ignore if you want to "
"continue (not recommended, can cause a data corruption)."),
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
QMessageBox::Abort | QMessageBox::Ignore, QMessageBox::Abort);
break;
default:
answer = QMessageBox::Abort;
@ -351,7 +352,7 @@ auto VAbstractMainWindow::IgnoreLocking(int error, const QString &path, bool gui
qCDebug(abstactMainWindow, "Error type: %d", error);
if (not guiMode)
{
switch(error)
switch (error)
{
case QLockFile::LockFailedError:
qCCritical(abstactMainWindow, "%s",

View File

@ -27,10 +27,10 @@
*************************************************************************/
#include "tst_vabstractpiece.h"
#include "../vlayout/vabstractpiece.h"
#include "../vlayout/vrawsapoint.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vpointf.h"
#include "../vlayout/vabstractpiece.h"
#include "../vlayout/vrawsapoint.h"
#include <QPointF>
#include <QVector>
@ -39,8 +39,9 @@
//---------------------------------------------------------------------------------------------------------------------
TST_VAbstractPiece::TST_VAbstractPiece(QObject *parent)
: AbstractTest(parent)
{}
: AbstractTest(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VAbstractPiece::EquidistantRemoveLoop_data()
@ -57,20 +58,17 @@ void TST_VAbstractPiece::EquidistantRemoveLoop_data()
};
// See file src/app/share/collection/test/seamtest1.val
ASSERT_TEST_CASE("Seam test 1. Piece. By angle.",
QStringLiteral("://seamtest1_by_angle/input.json"),
ASSERT_TEST_CASE("Seam test 1. Piece. By angle.", QStringLiteral("://seamtest1_by_angle/input.json"),
QStringLiteral("://seamtest1_by_angle/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/test/seamtest1.val
ASSERT_TEST_CASE("Seam test 1. Piece. By angle 2.",
QStringLiteral("://seamtest1_by_angle_2/input.json"),
ASSERT_TEST_CASE("Seam test 1. Piece. By angle 2.", QStringLiteral("://seamtest1_by_angle_2/input.json"),
QStringLiteral("://seamtest1_by_angle_2/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/test/seamtest1.val
ASSERT_TEST_CASE("Seam test 1. Piece. By intersection.",
QStringLiteral("://seamtest1_by_intersection/input.json"),
ASSERT_TEST_CASE("Seam test 1. Piece. By intersection.", QStringLiteral("://seamtest1_by_intersection/input.json"),
QStringLiteral("://seamtest1_by_intersection/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
@ -99,206 +97,167 @@ void TST_VAbstractPiece::EquidistantRemoveLoop_data()
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/test/seamtest2.val
ASSERT_TEST_CASE("Seam test 2",
QStringLiteral("://seamtest2/input.json"),
QStringLiteral("://seamtest2/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
ASSERT_TEST_CASE("Seam test 2", QStringLiteral("://seamtest2/input.json"),
QStringLiteral("://seamtest2/output.json"), 37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/test/seamtest3.val
ASSERT_TEST_CASE("Seam test 3",
QStringLiteral("://seamtest3/input.json"),
QStringLiteral("://seamtest3/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
ASSERT_TEST_CASE("Seam test 3", QStringLiteral("://seamtest3/input.json"),
QStringLiteral("://seamtest3/output.json"), 37.795275590551185 /*seam allowance width (1.0 cm)*/);
// These are two real cases where equdistant has loop.
// See issue #298. Segmented Curve isn't selected in Seam Allowance tool.
// https://bitbucket.org/dismine/valentina/issue/298/segmented-curve-isnt-selected-in-seam
// See file src/app/share/collection/TestPuzzle.val
// Code should clean loops in path.
ASSERT_TEST_CASE("Issue 298. Case1",
QStringLiteral("://Issue_298_case1/input.json"),
QStringLiteral("://Issue_298_case1/output.json"),
75.59055118110237 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue 298. Case1", QStringLiteral("://Issue_298_case1/input.json"),
QStringLiteral("://Issue_298_case1/output.json"), 75.59055118110237 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue 298. Case2",
QStringLiteral("://Issue_298_case2/input.json"),
QStringLiteral("://Issue_298_case2/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue 298. Case2", QStringLiteral("://Issue_298_case2/input.json"),
QStringLiteral("://Issue_298_case2/output.json"), 37.795275590551185 /*seam allowance width*/);
// See issue #548. Bug Detail tool. Case when seam allowance is wrong.
// https://bitbucket.org/dismine/valentina/issues/548/bug-detail-tool-case-when-seam-allowance
// Files: Steampunk_trousers.val and marie.vit
// Actually buggy detail see in file src/app/share/collection/bugs/Steampunk_trousers_issue_#548.val
// Code should clean loops in path.
ASSERT_TEST_CASE("Issue 548. Case1",
QStringLiteral("://Issue_548_case1/input.json"),
ASSERT_TEST_CASE("Issue 548. Case1", QStringLiteral("://Issue_548_case1/input.json"),
QStringLiteral("://Issue_548_case1/output.json"),
11.338582677165354 /*seam allowance width (0.3 cm)*/);
ASSERT_TEST_CASE("Issue 548. Case2",
QStringLiteral("://Issue_548_case2/input.json"),
ASSERT_TEST_CASE("Issue 548. Case2", QStringLiteral("://Issue_548_case2/input.json"),
QStringLiteral("://Issue_548_case2/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
ASSERT_TEST_CASE("Issue 548. Case3",
QStringLiteral("://Issue_548_case3/input.json"),
ASSERT_TEST_CASE("Issue 548. Case3", QStringLiteral("://Issue_548_case3/input.json"),
QStringLiteral("://Issue_548_case3/output.json"),
75.59055118110237 /*seam allowance width (2.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#646.val
ASSERT_TEST_CASE("Issue 646.",
QStringLiteral("://Issue_646/input.json"),
QStringLiteral("://Issue_646/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
ASSERT_TEST_CASE("Issue 646.", QStringLiteral("://Issue_646/input.json"),
QStringLiteral("://Issue_646/output.json"), 37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 1",
QStringLiteral("://Issue_923_test1/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 1", QStringLiteral("://Issue_923_test1/input.json"),
QStringLiteral("://Issue_923_test1/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 2",
QStringLiteral("://Issue_923_test2/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 2", QStringLiteral("://Issue_923_test2/input.json"),
QStringLiteral("://Issue_923_test2/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 3",
QStringLiteral("://Issue_923_test3/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 3", QStringLiteral("://Issue_923_test3/input.json"),
QStringLiteral("://Issue_923_test3/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 4",
QStringLiteral("://Issue_923_test4/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 4", QStringLiteral("://Issue_923_test4/input.json"),
QStringLiteral("://Issue_923_test4/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 5",
QStringLiteral("://Issue_923_test5/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 5", QStringLiteral("://Issue_923_test5/input.json"),
QStringLiteral("://Issue_923_test5/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 6",
QStringLiteral("://Issue_923_test6/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 6", QStringLiteral("://Issue_923_test6/input.json"),
QStringLiteral("://Issue_923_test6/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 1.1",
QStringLiteral("://Issue_923_test1_1/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 1.1", QStringLiteral("://Issue_923_test1_1/input.json"),
QStringLiteral("://Issue_923_test1_1/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 2.2",
QStringLiteral("://Issue_923_test2_2/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 2.2", QStringLiteral("://Issue_923_test2_2/input.json"),
QStringLiteral("://Issue_923_test2_2/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 3.3",
QStringLiteral("://Issue_923_test3_3/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 3.3", QStringLiteral("://Issue_923_test3_3/input.json"),
QStringLiteral("://Issue_923_test3_3/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 4.4",
QStringLiteral("://Issue_923_test4_4/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 4.4", QStringLiteral("://Issue_923_test4_4/input.json"),
QStringLiteral("://Issue_923_test4_4/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 5.5",
QStringLiteral("://Issue_923_test5_5/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 5.5", QStringLiteral("://Issue_923_test5_5/input.json"),
QStringLiteral("://Issue_923_test5_5/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923.val
ASSERT_TEST_CASE("Issue 923. Test 6.6",
QStringLiteral("://Issue_923_test6_6/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 6.6", QStringLiteral("://Issue_923_test6_6/input.json"),
QStringLiteral("://Issue_923_test6_6/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923_test7.val
ASSERT_TEST_CASE("Issue 923. Test 7.1",
QStringLiteral("://Issue_923_test7_1/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 7.1", QStringLiteral("://Issue_923_test7_1/input.json"),
QStringLiteral("://Issue_923_test7_1/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923_test7.val
ASSERT_TEST_CASE("Issue 923. Test 7.2",
QStringLiteral("://Issue_923_test7_2/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 7.2", QStringLiteral("://Issue_923_test7_2/input.json"),
QStringLiteral("://Issue_923_test7_2/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/Issue_#923_test7.val
ASSERT_TEST_CASE("Issue 923. Test 7.3",
QStringLiteral("://Issue_923_test7_3/input.json"),
ASSERT_TEST_CASE("Issue 923. Test 7.3", QStringLiteral("://Issue_923_test7_3/input.json"),
QStringLiteral("://Issue_923_test7_3/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/loop_by_intersection.val
ASSERT_TEST_CASE("Loop for angle by intersection",
QStringLiteral("://loop_by_intersection/input.json"),
ASSERT_TEST_CASE("Loop for angle by intersection", QStringLiteral("://loop_by_intersection/input.json"),
QStringLiteral("://loop_by_intersection/output.json"),
39.685039370078741 /*seam allowance width (1.05 cm)*/);
// See file valentina_private_collection/bugs/loop_start_point_on_line/loop_start_point_on_line.val
// (private collection)
ASSERT_TEST_CASE("Loop for start point on line",
QStringLiteral("://loop_start_point_on_line/input.json"),
ASSERT_TEST_CASE("Loop for start point on line", QStringLiteral("://loop_start_point_on_line/input.json"),
QStringLiteral("://loop_start_point_on_line/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
ASSERT_TEST_CASE("By length",
QStringLiteral("://DP_6_hem_by_length/input.json"),
ASSERT_TEST_CASE("By length", QStringLiteral("://DP_6_hem_by_length/input.json"),
QStringLiteral("://DP_6_hem_by_length/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
ASSERT_TEST_CASE("By intersection",
QStringLiteral("://DP_6_hem_by_intersection/input.json"),
ASSERT_TEST_CASE("By intersection", QStringLiteral("://DP_6_hem_by_intersection/input.json"),
QStringLiteral("://DP_6_hem_by_intersection/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
ASSERT_TEST_CASE("By first edge symmetry",
QStringLiteral("://DP_6_hem_by_first_edge_symmetry/input.json"),
ASSERT_TEST_CASE("By first edge symmetry", QStringLiteral("://DP_6_hem_by_first_edge_symmetry/input.json"),
QStringLiteral("://DP_6_hem_by_first_edge_symmetry/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
ASSERT_TEST_CASE("By second edge symmetry",
QStringLiteral("://DP_6_hem_by_second_edge_symmetry/input.json"),
ASSERT_TEST_CASE("By second edge symmetry", QStringLiteral("://DP_6_hem_by_second_edge_symmetry/input.json"),
QStringLiteral("://DP_6_hem_by_second_edge_symmetry/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
ASSERT_TEST_CASE("By first edge right angle",
QStringLiteral("://DP_6_hem_by_first_edge_right_angle/input.json"),
ASSERT_TEST_CASE("By first edge right angle", QStringLiteral("://DP_6_hem_by_first_edge_right_angle/input.json"),
QStringLiteral("://DP_6_hem_by_first_edge_right_angle/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
ASSERT_TEST_CASE("By second edge right angle",
QStringLiteral("://DP_6_hem_by_second_edge_right_angle/input.json"),
ASSERT_TEST_CASE("By second edge right angle", QStringLiteral("://DP_6_hem_by_second_edge_right_angle/input.json"),
QStringLiteral("://DP_6_hem_by_second_edge_right_angle/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file valentina_private_collection/bugs/DP_6/DP_6.val
ASSERT_TEST_CASE("Hem by seam allowance",
QStringLiteral("://DP_6/input.json"),
QStringLiteral("://DP_6/output.json"),
37.795275590551185 /*seam allowance width (1.0 cm)*/);
ASSERT_TEST_CASE("Hem by seam allowance", QStringLiteral("://DP_6/input.json"),
QStringLiteral("://DP_6/output.json"), 37.795275590551185 /*seam allowance width (1.0 cm)*/);
// See file src/app/share/collection/bugs/smart_pattern_#36.val
ASSERT_TEST_CASE("Incorrect position of a notch",
QStringLiteral("://smart_pattern_#36/input.json"),
ASSERT_TEST_CASE("Incorrect position of a notch", QStringLiteral("://smart_pattern_#36/input.json"),
QStringLiteral("://smart_pattern_#36/output.json"),
30.236220472440944 /*seam allowance width (0.8 cm)*/);
}
@ -332,28 +291,21 @@ void TST_VAbstractPiece::LayoutAllowanceRemoveLoop_data()
};
// See file valentina_private_collection/bugs/smart_pattern_#58/smart_pattern_#58.val
ASSERT_TEST_CASE("Loop in layout allowance",
QStringLiteral("://smart_pattern_#58/input.json"),
ASSERT_TEST_CASE("Loop in layout allowance", QStringLiteral("://smart_pattern_#58/input.json"),
QStringLiteral("://smart_pattern_#58/output.json"),
18.897637795275593 /*seam allowance width (0.5 cm)*/);
// See file src/app/share/collection/bugs/smart_pattern_#99.val
ASSERT_TEST_CASE("Incorrect fix of distortion",
QStringLiteral("://smart_pattern_#99/input.json"),
QStringLiteral("://smart_pattern_#99/output.json"),
28.346456692913389 /*seam allowance width*/);
ASSERT_TEST_CASE("Incorrect fix of distortion", QStringLiteral("://smart_pattern_#99/input.json"),
QStringLiteral("://smart_pattern_#99/output.json"), 28.346456692913389 /*seam allowance width*/);
// See file valentina_private_collection/test/smart_pattern_#120/smart_pattern_#120.val
ASSERT_TEST_CASE("Piece 1",
QStringLiteral("://smart_pattern_#120_piece_1/input.json"),
QStringLiteral("://smart_pattern_#120_piece_1/output.json"),
37.795275590551185);
ASSERT_TEST_CASE("Piece 1", QStringLiteral("://smart_pattern_#120_piece_1/input.json"),
QStringLiteral("://smart_pattern_#120_piece_1/output.json"), 37.795275590551185);
// See file valentina_private_collection/test/smart_pattern_#120/smart_pattern_#120.val
ASSERT_TEST_CASE("Piece 2",
QStringLiteral("://smart_pattern_#120_piece_2/input.json"),
QStringLiteral("://smart_pattern_#120_piece_2/output.json"),
37.795275590551185);
ASSERT_TEST_CASE("Piece 2", QStringLiteral("://smart_pattern_#120_piece_2/input.json"),
QStringLiteral("://smart_pattern_#120_piece_2/output.json"), 37.795275590551185);
}
//---------------------------------------------------------------------------------------------------------------------
@ -388,37 +340,30 @@ void TST_VAbstractPiece::TestAreaCalculation_data()
QTest::addColumn<qreal>("excpectedArea");
{
QVector<QPointF> rect
{
QPointF(),
QPointF(100, 0),
QPointF(100, 50),
QPointF(0, 50),
QPointF()
};
QVector<QPointF> rect{QPointF(), QPointF(100, 0), QPointF(100, 50), QPointF(0, 50), QPointF()};
QTest::newRow("Rectangle 100 x 50") << rect << 100.0 * 50.0;
QTest::newRow("Rectangle 100 x 50") << rect << 100.0 * 50.0;
}
{
VArc circle(VPointF(100, 100, QChar('C'), 0, 0), 100, 35, 35);
circle.SetApproximationScale(maxCurveApproximationScale);
QVector<QPointF> circlePath = circle.GetPoints();
if (not circlePath.isEmpty() && not VFuzzyComparePoints(ConstFirst(circlePath), ConstLast(circlePath)))
{
circlePath.append(ConstFirst(circlePath));
}
QTest::newRow("Circle radis 100") << circlePath << M_PI * pow(100, 2);
VArc circle(VPointF(100, 100, QChar('C'), 0, 0), 100, 35, 35);
circle.SetApproximationScale(maxCurveApproximationScale);
QVector<QPointF> circlePath = circle.GetPoints();
if (not circlePath.isEmpty() && not VFuzzyComparePoints(ConstFirst(circlePath), ConstLast(circlePath)))
{
circlePath.append(ConstFirst(circlePath));
}
QTest::newRow("Circle radis 100") << circlePath << M_PI * pow(100, 2);
}
{
VPointF sectorCenter(100, 100, QChar('C'), 0, 0);
VArc sector(sectorCenter, 100, 15, 45);
sector.SetApproximationScale(maxCurveApproximationScale);
QVector<QPointF> sectorPath = sector.GetPoints();
sectorPath.append(sectorCenter.toQPointF());
sectorPath.append(ConstFirst(sectorPath));
QTest::newRow("Sector radius 100, 30 degree") << sectorPath << (M_PI * pow(100, 2) * 30.0) / 360.0;
VPointF sectorCenter(100, 100, QChar('C'), 0, 0);
VArc sector(sectorCenter, 100, 15, 45);
sector.SetApproximationScale(maxCurveApproximationScale);
QVector<QPointF> sectorPath = sector.GetPoints();
sectorPath.append(sectorCenter.toQPointF());
sectorPath.append(ConstFirst(sectorPath));
QTest::newRow("Sector radius 100, 30 degree") << sectorPath << (M_PI * pow(100, 2) * 30.0) / 360.0;
}
}
@ -428,7 +373,7 @@ void TST_VAbstractPiece::TestAreaCalculation() const
QFETCH(QVector<QPointF>, path);
QFETCH(qreal, excpectedArea);
const qreal result = qAbs(VAbstractPiece::SumTrapezoids(path)/2.0);
const qreal result = qAbs(VAbstractPiece::SumTrapezoids(path) / 2.0);
QVERIFY(qAbs(result - excpectedArea) < MmToPixel(1.0));
}
@ -446,8 +391,7 @@ void TST_VAbstractPiece::RawPathRemoveLoop_data() const
};
// See file src/app/share/collection/bugs/smart_pattern_#112.val (private collection)
ASSERT_TEST_CASE("Loop intersection",
QStringLiteral("://smart_pattern_#112/input.json"),
ASSERT_TEST_CASE("Loop intersection", QStringLiteral("://smart_pattern_#112/input.json"),
QStringLiteral("://smart_pattern_#112/output.json"));
}
@ -936,27 +880,20 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data()
};
// See the file "collection/bugs/Issue_#604.val" (since 0.5.0)
ASSERT_TEST_CASE("Issue #604.",
QStringLiteral("://Issue_604/input.json"),
QStringLiteral("://Issue_604/output.json"),
11.338582677165354 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue #604.", QStringLiteral("://Issue_604/input.json"),
QStringLiteral("://Issue_604/output.json"), 11.338582677165354 /*seam allowance width*/);
// See the file "collection/bugs/Issue_#627.val"
ASSERT_TEST_CASE("Issue #627.",
QStringLiteral("://Issue_627/input.json"),
QStringLiteral("://Issue_627/output.json"),
56.692913385826778 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue #627.", QStringLiteral("://Issue_627/input.json"),
QStringLiteral("://Issue_627/output.json"), 56.692913385826778 /*seam allowance width*/);
// See the file "collection/bugs/Issue_#687.val"
ASSERT_TEST_CASE("Issue #687.",
QStringLiteral("://Issue_687/input.json"),
QStringLiteral("://Issue_687/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue #687.", QStringLiteral("://Issue_687/input.json"),
QStringLiteral("://Issue_687/output.json"), 37.795275590551185 /*seam allowance width*/);
// See private test cases in file jacket_issue_#767.val, piece "Fabric_TopCollar"
// Curve approximation scale 0.5
ASSERT_TEST_CASE("Issue #767. Fabric_TopCollar.",
QStringLiteral("://Issue_767_Fabric_TopCollar/input.json"),
ASSERT_TEST_CASE("Issue #767. Fabric_TopCollar.", QStringLiteral("://Issue_767_Fabric_TopCollar/input.json"),
QStringLiteral("://Issue_767_Fabric_TopCollar/output.json"),
37.795275590551185 /*seam allowance width*/);
@ -968,63 +905,47 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data()
37.795275590551185 /*seam allowance width*/);
// See private test cases in file collection/bugs/Issue_#883_case1.val, piece "ledge"
ASSERT_TEST_CASE("Issue #883. Piece 'ledge'",
QStringLiteral("://Issue_883_ledge/input.json"),
QStringLiteral("://Issue_883_ledge/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue #883. Piece 'ledge'", QStringLiteral("://Issue_883_ledge/input.json"),
QStringLiteral("://Issue_883_ledge/output.json"), 37.795275590551185 /*seam allowance width*/);
// See private test cases in file collection/bugs/Issue_#883_case1.val, piece "prong"
ASSERT_TEST_CASE("Issue #883. Piece 'prong'",
QStringLiteral("://Issue_883_prong/input.json"),
QStringLiteral("://Issue_883_prong/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue #883. Piece 'prong'", QStringLiteral("://Issue_883_prong/input.json"),
QStringLiteral("://Issue_883_prong/output.json"), 37.795275590551185 /*seam allowance width*/);
// See the file "collection/bugs/smart_pattern_#145.val"
ASSERT_TEST_CASE("Issue #145",
QStringLiteral("://smart_pattern_#145/input.json"),
QStringLiteral("://smart_pattern_#145/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue #145", QStringLiteral("://smart_pattern_#145/input.json"),
QStringLiteral("://smart_pattern_#145/output.json"), 37.795275590551185 /*seam allowance width*/);
// See private test cases in file valentina_private_collection/bugs/women_jacket/women_jacket.val
// Point A38, size 32
ASSERT_TEST_CASE("women_jacket_A38",
QStringLiteral("://women_jacket/input.json"),
QStringLiteral("://women_jacket/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("women_jacket_A38", QStringLiteral("://women_jacket/input.json"),
QStringLiteral("://women_jacket/output.json"), 37.795275590551185 /*seam allowance width*/);
// See private test cases in file valentina_private_collection/bugs/hood_1/hood_1.val
ASSERT_TEST_CASE("hood_1",
QStringLiteral("://hood_1/input.json"),
QStringLiteral("://hood_1/output.json"),
ASSERT_TEST_CASE("hood_1", QStringLiteral("://hood_1/input.json"), QStringLiteral("://hood_1/output.json"),
37.795275590551185 /*seam allowance width*/);
// See private test cases in file valentina_private_collection/bugs/hood_2/hood_2.val
ASSERT_TEST_CASE("hood_2",
QStringLiteral("://hood_2/input.json"),
QStringLiteral("://hood_2/output.json"),
ASSERT_TEST_CASE("hood_2", QStringLiteral("://hood_2/input.json"), QStringLiteral("://hood_2/output.json"),
37.795275590551185 /*seam allowance width*/);
// See the file "collection/bugs/smart_pattern_#184_case1.val"
ASSERT_TEST_CASE("Issue #184 case 1",
QStringLiteral("://smart_pattern_#184_case1/input.json"),
ASSERT_TEST_CASE("Issue #184 case 1", QStringLiteral("://smart_pattern_#184_case1/input.json"),
QStringLiteral("://smart_pattern_#184_case1/output.json"),
0.88157480314960635 /*seam allowance width*/);
// See the file "collection/bugs/smart_pattern_#184_case2.val"
ASSERT_TEST_CASE("Issue #184 case 2",
QStringLiteral("://smart_pattern_#184_case2/input.json"),
ASSERT_TEST_CASE("Issue #184 case 2", QStringLiteral("://smart_pattern_#184_case2/input.json"),
QStringLiteral("://smart_pattern_#184_case2/output.json"),
37.795275590551185 /*seam allowance width*/);
// See the file "valentina_private_collection/bugs/custom_seam_allwance_exclude/custom_seam_allwance_exclude.val"
ASSERT_TEST_CASE("Piece 1. CSA Exclude",
QStringLiteral("://custom_seam_allwance_exclude_p1/input.json"),
ASSERT_TEST_CASE("Piece 1. CSA Exclude", QStringLiteral("://custom_seam_allwance_exclude_p1/input.json"),
QStringLiteral("://custom_seam_allwance_exclude_p1/output.json"),
37.795275590551185 /*seam allowance width 1 cm*/);
// See the file "valentina_private_collection/bugs/custom_seam_allwance_exclude/custom_seam_allwance_exclude.val"
ASSERT_TEST_CASE("Piece 2. CSA Exclude",
QStringLiteral("://custom_seam_allwance_exclude_p2/input.json"),
ASSERT_TEST_CASE("Piece 2. CSA Exclude", QStringLiteral("://custom_seam_allwance_exclude_p2/input.json"),
QStringLiteral("://custom_seam_allwance_exclude_p2/output.json"),
37.795275590551185 /*seam allowance width 1 cm*/);
}
@ -1037,7 +958,7 @@ void TST_VAbstractPiece::BrokenDetailEquidistant() const
QFETCH(QVector<QPointF>, ekvOrig);
QVector<QPointF> ekv;
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv);// Take result
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv); // Take result
// Begin comparison
ComparePaths(ekv, ekvOrig);
@ -1058,93 +979,63 @@ void TST_VAbstractPiece::EquidistantAngleType_data()
};
// See the file "collection/bugs/Issue_#880.val"
ASSERT_TEST_CASE("Issue #880. Piece: Detail.",
QStringLiteral("://Issue_880_Detail/input.json"),
QStringLiteral("://Issue_880_Detail/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue #880. Piece: Detail.", QStringLiteral("://Issue_880_Detail/input.json"),
QStringLiteral("://Issue_880_Detail/output.json"), 37.795275590551185 /*seam allowance width*/);
// See the file "collection/bugs/Issue_#880.val"
ASSERT_TEST_CASE("Issue #880. Piece: Detail_1.",
QStringLiteral("://Issue_880_Detail_1/input.json"),
QStringLiteral("://Issue_880_Detail_1/output.json"),
75.59055118110237 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue #880. Piece: Detail_1.", QStringLiteral("://Issue_880_Detail_1/input.json"),
QStringLiteral("://Issue_880_Detail_1/output.json"), 75.59055118110237 /*seam allowance width*/);
// See file src/app/share/collection/bugs/Issue_#937.val
ASSERT_TEST_CASE("Issue 937. Case1",
QStringLiteral("://Issue_937_case_1/input.json"),
QStringLiteral("://Issue_937_case_1/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue 937. Case1", QStringLiteral("://Issue_937_case_1/input.json"),
QStringLiteral("://Issue_937_case_1/output.json"), 37.795275590551185 /*seam allowance width*/);
// See file src/app/share/collection/bugs/Issue_#937a.val
ASSERT_TEST_CASE("Issue 937. Case1a",
QStringLiteral("://Issue_937_case_1a/input.json"),
QStringLiteral("://Issue_937_case_1a/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue 937. Case1a", QStringLiteral("://Issue_937_case_1a/input.json"),
QStringLiteral("://Issue_937_case_1a/output.json"), 37.795275590551185 /*seam allowance width*/);
// See file src/app/share/collection/bugs/Issue_#937.val
ASSERT_TEST_CASE("Issue 937. Case2",
QStringLiteral("://Issue_937_case_2/input.json"),
QStringLiteral("://Issue_937_case_2/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue 937. Case2", QStringLiteral("://Issue_937_case_2/input.json"),
QStringLiteral("://Issue_937_case_2/output.json"), 37.795275590551185 /*seam allowance width*/);
// See file src/app/share/collection/bugs/Issue_#937.val
ASSERT_TEST_CASE("Issue 937. Case3",
QStringLiteral("://Issue_937_case_3/input.json"),
QStringLiteral("://Issue_937_case_3/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue 937. Case3", QStringLiteral("://Issue_937_case_3/input.json"),
QStringLiteral("://Issue_937_case_3/output.json"), 37.795275590551185 /*seam allowance width*/);
// See file src/app/share/collection/bugs/Issue_#937.val
ASSERT_TEST_CASE("Issue 937. Case4",
QStringLiteral("://Issue_937_case_4/input.json"),
QStringLiteral("://Issue_937_case_4/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue 937. Case4", QStringLiteral("://Issue_937_case_4/input.json"),
QStringLiteral("://Issue_937_case_4/output.json"), 37.795275590551185 /*seam allowance width*/);
// See file src/app/share/collection/bugs/Issue_#937_case5.val
ASSERT_TEST_CASE("Issue 937. Case5",
QStringLiteral("://Issue_937_case_5/input.json"),
QStringLiteral("://Issue_937_case_5/output.json"),
37.795275590551185 /*seam allowance width*/);
ASSERT_TEST_CASE("Issue 937. Case5", QStringLiteral("://Issue_937_case_5/input.json"),
QStringLiteral("://Issue_937_case_5/output.json"), 37.795275590551185 /*seam allowance width*/);
// See file valentina_private_collection/bugs/busty/busty.val
ASSERT_TEST_CASE("Busty",
QStringLiteral("://busty/input.json"),
QStringLiteral("://busty/output.json"),
ASSERT_TEST_CASE("Busty", QStringLiteral("://busty/input.json"), QStringLiteral("://busty/output.json"),
0 /*seam allowance width*/);
// See file valentina_private_collection/bugs/panties/panties.val
ASSERT_TEST_CASE("Panties. Piece Case 1",
QStringLiteral("://panties_case1/input.json"),
QStringLiteral("://panties_case1/output.json"),
26.45669291338583 /*seam allowance width*/);
ASSERT_TEST_CASE("Panties. Piece Case 1", QStringLiteral("://panties_case1/input.json"),
QStringLiteral("://panties_case1/output.json"), 26.45669291338583 /*seam allowance width*/);
// See file valentina_private_collection/bugs/panties/panties.val
ASSERT_TEST_CASE("Panties. Piece Case 2",
QStringLiteral("://panties_case2/input.json"),
QStringLiteral("://panties_case2/output.json"),
26.45669291338583 /*seam allowance width*/);
ASSERT_TEST_CASE("Panties. Piece Case 2", QStringLiteral("://panties_case2/input.json"),
QStringLiteral("://panties_case2/output.json"), 26.45669291338583 /*seam allowance width*/);
// See file valentina_private_collection/bugs/smart_pattern_#113/smart_pattern_#113.val
ASSERT_TEST_CASE("Эдит 6",
QStringLiteral("://smart_pattern_#113/input.json"),
QStringLiteral("://smart_pattern_#113/output.json"),
0.56692913385826771 /*seam allowance width*/);
ASSERT_TEST_CASE("Эдит 6", QStringLiteral("://smart_pattern_#113/input.json"),
QStringLiteral("://smart_pattern_#113/output.json"), 0.56692913385826771 /*seam allowance width*/);
// See file valentina_private_collection/bugs/smart_pattern_#118/smart_pattern_#118.val
ASSERT_TEST_CASE("Ретро стринги 3",
QStringLiteral("://smart_pattern_#118/input.json"),
QStringLiteral("://smart_pattern_#118/output.json"),
26.45669291338583 /*seam allowance width*/);
ASSERT_TEST_CASE("Ретро стринги 3", QStringLiteral("://smart_pattern_#118/input.json"),
QStringLiteral("://smart_pattern_#118/output.json"), 26.45669291338583 /*seam allowance width*/);
// See file valentina_private_collection/bugs/smart_pattern_#133/smart_pattern_#133.val
ASSERT_TEST_CASE("Эдит 1",
QStringLiteral("://smart_pattern_#133/input.json"),
QStringLiteral("://smart_pattern_#133/output.json"),
26.45669291338583 /*seam allowance width*/);
ASSERT_TEST_CASE("Эдит 1", QStringLiteral("://smart_pattern_#133/input.json"),
QStringLiteral("://smart_pattern_#133/output.json"), 26.45669291338583 /*seam allowance width*/);
// See file valentina_private_collection/bugs/hat/hat.val
ASSERT_TEST_CASE("hat",
QStringLiteral("://hat/input.json"),
QStringLiteral("://hat/output.json"),
ASSERT_TEST_CASE("hat", QStringLiteral("://hat/input.json"), QStringLiteral("://hat/output.json"),
26.45669291338583 /*seam allowance width*/);
}
@ -1156,7 +1047,7 @@ void TST_VAbstractPiece::EquidistantAngleType() const
QFETCH(QVector<QPointF>, ekvOrig);
QVector<QPointF> ekv;
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv);// Take result
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv); // Take result
// Begin comparison
ComparePaths(ekv, ekvOrig);
@ -1213,13 +1104,11 @@ void TST_VAbstractPiece::TestCorrectEquidistantPoints_data()
};
// See file src/app/share/collection/bugs/Steampunk_trousers_issue_#548.val
ASSERT_TEST_CASE("Test case issue #548",
QStringLiteral("://Issue_548/input.json"),
ASSERT_TEST_CASE("Test case issue #548", QStringLiteral("://Issue_548/input.json"),
QStringLiteral("://Issue_548/output.json"));
// See the file "collection/bugs/Issue_#642.val"
ASSERT_TEST_CASE("Test case issue #642",
QStringLiteral("://Issue_642/input.json"),
ASSERT_TEST_CASE("Test case issue #642", QStringLiteral("://Issue_642/input.json"),
QStringLiteral("://Issue_642/output.json"));
}
@ -1361,14 +1250,12 @@ void TST_VAbstractPiece::IsAllowanceValid_data() const
{
QVector<QPointF> basePoints = AbstractTest::VectorFromJson<QPointF>(base);
QVector<QPointF> allowancePoints = AbstractTest::VectorFromJson<QPointF>(allowance);
QTest::newRow(title) << basePoints << allowancePoints << valid ;
QTest::newRow(title) << basePoints << allowancePoints << valid;
};
// See file src/app/share/collection/valid_allowance/case3.val (private collection)
ASSERT_TEST_CASE("Valid seam allowance. Case 3",
QStringLiteral("://valid_allowance_case3/base.json"),
QStringLiteral("://valid_allowance_case3/allowance.json"),
true);
ASSERT_TEST_CASE("Valid seam allowance. Case 3", QStringLiteral("://valid_allowance_case3/base.json"),
QStringLiteral("://valid_allowance_case3/allowance.json"), true);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -38,28 +38,33 @@ void PrepareTestCase(const QPointF &center, qreal startAngle, qreal endAngle)
{
qreal radius = UnitConvertor(1, Unit::Cm, Unit::Px);
const qreal threshold = UnitConvertor(2000, Unit::Cm, Unit::Px);
while(radius <= threshold)
while (radius <= threshold)
{
VArc arc(VPointF(center), radius, startAngle, endAngle);
const QVector<QPointF> points = arc.GetPoints();
const QString testStartAngle = QString("Test start angel. Arc radius %1, start angle %2, end angle %3")
.arg(radius).arg(startAngle).arg(endAngle);
.arg(radius)
.arg(startAngle)
.arg(endAngle);
QTest::newRow(qUtf8Printable(testStartAngle)) << center << startAngle << points << ConstFirst(points) << true;
const QString testEndAngle = QString("Test end angel. Arc radius %1, start angle %2, end angle %3")
.arg(radius).arg(startAngle).arg(endAngle);
.arg(radius)
.arg(startAngle)
.arg(endAngle);
QTest::newRow(qUtf8Printable(testEndAngle)) << center << endAngle << points << ConstLast(points) << true;
radius += UnitConvertor(5, Unit::Cm, Unit::Px);
}
}
} // namespace
} // namespace
//---------------------------------------------------------------------------------------------------------------------
TST_VArc::TST_VArc(QObject *parent)
:AbstractTest(parent)
{}
: AbstractTest(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
@ -69,7 +74,7 @@ void TST_VArc::CompareTwoWays()
const qreal radius = 100;
const qreal f1 = 1;
const qreal f2 = 46;
const qreal length = M_PI*radius/180*(f2-f1);
const qreal length = M_PI * radius / 180 * (f2 - f1);
VArc arc1(center, radius, f1, f2);
VArc arc2(length, center, radius, f1);
@ -92,7 +97,7 @@ void TST_VArc::NegativeArc()
const qreal radius = 100;
const qreal f1 = 1;
const qreal f2 = 316;
const qreal length = M_PI*radius/180*45;
const qreal length = M_PI * radius / 180 * 45;
VArc arc(-length, center, radius, f1);
QCOMPARE(arc.GetLength(), -length);
@ -209,30 +214,31 @@ void TST_VArc::TestGetPoints()
const qreal value = qAbs(rLine.length() - radius);
// cppcheck-suppress unreadVariable
const QString errorMsg = QString("Broken the first rule. All points should be on the same distance from "
"the center. Error ='%1'.").arg(value);
"the center. Error ='%1'.")
.arg(value);
QVERIFY2(value <= epsRadius, qUtf8Printable(errorMsg));
}
}
{
qreal gSquare = 0.0;// geometry square
qreal gSquare = 0.0; // geometry square
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
{// circle square
{ // circle square
gSquare = M_PI * radius * radius;
}
else
{// sector square
{ // sector square
gSquare = (M_PI * radius * radius) / 360.0 * arc.AngleArc();
points.append(static_cast<QPointF>(center));
}
// calculated square
const qreal cSquare = qAbs(VAbstractPiece::SumTrapezoids(points)/2.0);
const qreal cSquare = qAbs(VAbstractPiece::SumTrapezoids(points) / 2.0);
const qreal value = qAbs(gSquare - cSquare);
// cppcheck-suppress unreadVariable
const QString errorMsg =
QString("Broken the second rule. Interpolation has too big computing error. Error ='%1'.").arg(value);
QString("Broken the second rule. Interpolation has too big computing error. Error ='%1'.").arg(value);
const qreal epsSquare = gSquare * 0.24 / 100; // computing error 0.24 % from origin square
QVERIFY2(value <= epsSquare, qUtf8Printable(errorMsg));
}
@ -311,7 +317,7 @@ void TST_VArc::TestFlip_data()
l.setAngle(225);
p1 = l.p2();
l.setAngle(45+90);
l.setAngle(45 + 90);
l.setLength(5);
const QPointF p1Axis = l.p2();
@ -341,7 +347,7 @@ void TST_VArc::TestFlip()
QVERIFY2(res.IsFlipped(), qUtf8Printable("The arc is not flipped"));
QCOMPARE(originArc.GetLength()*-1, res.GetLength());
QCOMPARE(originArc.GetLength() * -1, res.GetLength());
QCOMPARE(originArc.GetRadius(), res.GetRadius());
QCOMPARE(originArc.AngleArc(), res.AngleArc());
}
@ -356,7 +362,7 @@ void TST_VArc::TestCutArc_data()
QTest::addColumn<qreal>("cutLength");
QTest::addColumn<QPointF>("cutPoint");
QPointF center (189.13625196850393, 344.1267401574803);
QPointF center(189.13625196850393, 344.1267401574803);
qreal radius = ToPixel(10, Unit::Cm);
qreal startAngle = 45.0;
qreal length = ToPixel(-10, Unit::Cm);
@ -364,14 +370,14 @@ void TST_VArc::TestCutArc_data()
QPointF cutPoint(539.3657292513009, 202.04366960088566);
// See file <root>/src/app/share/collection/bugs/Issue_#957.val
QTest::newRow("Arc -10 cm length, cut length 6 cm") << center << radius << startAngle << length << cutLength
<< cutPoint;
QTest::newRow("Arc -10 cm length, cut length 6 cm")
<< center << radius << startAngle << length << cutLength << cutPoint;
cutLength = ToPixel(-4, Unit::Cm);
// Opposite case
QTest::newRow("Arc -10 cm length, cut length -4 cm") << center << radius << startAngle << length << cutLength
<< cutPoint;
QTest::newRow("Arc -10 cm length, cut length -4 cm")
<< center << radius << startAngle << length << cutLength << cutPoint;
startAngle = 135;
length = ToPixel(10, Unit::Cm);
@ -379,13 +385,13 @@ void TST_VArc::TestCutArc_data()
cutPoint = QPointF(-145.1588983496871, 167.78888781060192);
// See file <root>/src/app/share/collection/bugs/Issue_#957.val
QTest::newRow("Arc 10 cm length, cut length -7 cm") << center << radius << startAngle << length << cutLength
<< cutPoint;
QTest::newRow("Arc 10 cm length, cut length -7 cm")
<< center << radius << startAngle << length << cutLength << cutPoint;
// Opposite case
cutLength = ToPixel(3, Unit::Cm);
QTest::newRow("Arc 10 cm length, cut length 3 cm") << center << radius << startAngle << length << cutLength
<< cutPoint;
QTest::newRow("Arc 10 cm length, cut length 3 cm")
<< center << radius << startAngle << length << cutLength << cutPoint;
}
//---------------------------------------------------------------------------------------------------------------------
@ -398,7 +404,7 @@ void TST_VArc::TestCutArc()
QFETCH(qreal, cutLength);
QFETCH(QPointF, cutPoint);
VArc arc (length, VPointF(center), radius, startAngle);
VArc arc(length, VPointF(center), radius, startAngle);
arc.SetApproximationScale(0.5);
VArc arc1;

View File

@ -34,8 +34,10 @@
#include <QtTest>
//---------------------------------------------------------------------------------------------------------------------
TST_VEllipticalArc::TST_VEllipticalArc(QObject *parent) : AbstractTest(parent)
{}
TST_VEllipticalArc::TST_VEllipticalArc(QObject *parent)
: AbstractTest(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VEllipticalArc::CompareTwoWays_data()
@ -87,7 +89,7 @@ void TST_VEllipticalArc::CompareTwoWays()
// cppcheck-suppress unreadVariable
QString errorLengthMsg =
QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3");
QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3");
QVERIFY2(qAbs(arc2.GetLength() - length) <= lengthEps,
qUtf8Printable(errorLengthMsg.arg(lengthEps).arg(arc2.GetLength()).arg(length)));
QVERIFY2(qAbs(arc1.GetLength() - arc2.GetLength()) <= lengthEps,
@ -96,10 +98,10 @@ void TST_VEllipticalArc::CompareTwoWays()
const qreal angleEps = 0.4;
// cppcheck-suppress unreadVariable
const QString errorAngleMsg =
QString("Difference between real and computing angles bigger than eps = %1. f1 = %2; f2 = %3");
QString("Difference between real and computing angles bigger than eps = %1. f1 = %2; f2 = %3");
// compare angles
const qreal diff = qAbs(arc1.GetEndAngle() - arc2.GetEndAngle());
QVERIFY2(qAbs(diff - 360.0*(diff/360.0)) <= angleEps,
QVERIFY2(qAbs(diff - 360.0 * (diff / 360.0)) <= angleEps,
qUtf8Printable(errorAngleMsg.arg(angleEps).arg(arc1.GetEndAngle()).arg(arc2.GetEndAngle())));
}
@ -115,21 +117,19 @@ void TST_VEllipticalArc::NegativeArc()
const qreal rotationAngle = 0;
// Full ellipse
const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2));
const qreal length = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h)))/2;
const qreal h = ((radius1 - radius2) * (radius1 - radius2)) / ((radius1 + radius2) * (radius1 + radius2));
const qreal length = M_PI * (radius1 + radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h))) / 2;
VEllipticalArc arc(-length, center, radius1, radius2, f1, rotationAngle);
const qreal eps = ToPixel(0.45, Unit::Mm); // computing error
// cppcheck-suppress unreadVariable
const QString errorMsg =
QString("Difference between real and computing lengthes bigger than eps = %1. v1 = %2; v2 = %3");
QString("Difference between real and computing lengthes bigger than eps = %1. v1 = %2; v2 = %3");
QVERIFY2(qAbs(arc.GetLength() + length) <= eps,
qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length)));
QVERIFY2(qAbs(arc.GetLength() + length) <= eps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length)));
const qreal angleEps = 0.4;
QVERIFY2(arc.GetEndAngle() - f2 <= angleEps,
qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2)));
QVERIFY2(arc.GetEndAngle() - f2 <= angleEps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2)));
}
// cppcheck-suppress unusedFunction
@ -171,23 +171,23 @@ void TST_VEllipticalArc::TestData()
QTest::newRow("Full circle: radiuses 150, 200, rotation 30; start 0") << 150.0 << 200.0 << 0.0 << 360.0 << 30.0;
QTest::newRow("Full circle: radiuses 1500, 1000; start 0") << 1500.0 << 1000.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 0") << 1500.0 << 1000.0 << 0.0 << 360.0 << 50.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 0") << 15000.0 << 10000.0 << 0.0 << 360.0
<< 90.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 0")
<< 15000.0 << 10000.0 << 0.0 << 360.0 << 90.0;
QTest::newRow("Full circle: radiuses 10, 20; start 90") << 10.0 << 20.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, 200; start 90") << 150.0 << 200.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, 200, rotation 30; start 90") << 150.0 << 200.0 << 90.0 << 90.0 << 30.0;
QTest::newRow("Full circle: radiuses 1500, 1000; start 90") << 1500.0 << 1000.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90") << 1500.0 << 1000.0 << 90.0 << 90.0
<< 50.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 90") << 15000.0 << 10000.0 << 90.0 << 90.0
<< 90.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90")
<< 1500.0 << 1000.0 << 90.0 << 90.0 << 50.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 90")
<< 15000.0 << 10000.0 << 90.0 << 90.0 << 90.0;
QTest::newRow("Arc less than 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc less than 45 degree, radiuses 150, 50, rotation 180") << 150.0 << 50.0 << 0.0 << 10.5 << 180.0;
QTest::newRow("Arc less than 45 degree, radiuses 1500, 800, rotation 90") << 1500.0 << 800.0 << 0.0 << 10.5 << 90.0;
QTest::newRow("Arc less than 45 degree, radiuses 15000, 10000, rotation 40")
<< 50000.0 << 10000.0 << 0.0 << 10.5 << 40.0;
<< 50000.0 << 10000.0 << 0.0 << 10.5 << 40.0;
QTest::newRow("Arc less than 45 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc 45 degree, radiuses 100, 50, rotation 45") << 100.0 << 50.0 << 0.0 << 45.0 << 45.0;
@ -199,11 +199,11 @@ void TST_VEllipticalArc::TestData()
QTest::newRow("Arc less than 90 degree, radiuses 100, 400, rotation 50") << 100.0 << 400.0 << 0.0 << 75.0 << 50.0;
QTest::newRow("Arc less than 90 degree, radiuses 150, 400, rotation 90") << 150.0 << 400.0 << 0.0 << 75.0 << 90.0;
QTest::newRow("Arc less than 90 degree, radiuses 1500, 50000, rotation 180")
<< 1500.0 << 50000.0 << 0.0 << 75.0 << 180.0;
<< 1500.0 << 50000.0 << 0.0 << 75.0 << 180.0;
QTest::newRow("Arc less than 90 degree, radiuses 50000, 5000, rotation 30")
<< 50000.0 << 5000.0 << 0.0 << 75.0 << 30.0;
<< 50000.0 << 5000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc less than 90 degree, radiuses 90000, 50000, rotation 30")
<< 90000.0 << 50000.0 << 0.0 << 75.0 << 30.0;
<< 90000.0 << 50000.0 << 0.0 << 75.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses 100, 50, rotation 30") << 100.0 << 50.0 << 0.0 << 90.0 << 30.0;
QTest::newRow("Arc 90 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 90.0 << 0.0;
@ -213,11 +213,11 @@ void TST_VEllipticalArc::TestData()
QTest::newRow("Arc less than 135 degree, radiuses 100, 50, rotation 60") << 100.0 << 50.0 << 0.0 << 110.6 << 60.0;
QTest::newRow("Arc less than 135 degree, radiuses 150, 400, rotation 300")
<< 150.0 << 400.0 << 0.0 << 110.6 << 300.0;
<< 150.0 << 400.0 << 0.0 << 110.6 << 300.0;
QTest::newRow("Arc less than 135 degree, radiuses 1500, 800, rotation 360")
<< 1500.0 << 800.0 << 0.0 << 110.6 << 360.0;
<< 1500.0 << 800.0 << 0.0 << 110.6 << 360.0;
QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500, rotation 290")
<< 15000.0 << 1500.0 << 0.0 << 110.6 << 290.0;
<< 15000.0 << 1500.0 << 0.0 << 110.6 << 290.0;
QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500") << 15000.0 << 1500.0 << 0.0 << 110.6 << 0.0;
QTest::newRow("Arc 135 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 135.0 << 0.0;
@ -230,7 +230,7 @@ void TST_VEllipticalArc::TestData()
QTest::newRow("Arc less than 180 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc less than 180 degree, radiuses 15000, 1500, rotation 270")
<< 15000.0 << 1500.0 << 0.0 << 160.7 << 270.0;
<< 15000.0 << 1500.0 << 0.0 << 160.7 << 270.0;
QTest::newRow("Arc less than 180 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 160.7 << 0.0;
QTest::newRow("Arc 180 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 180.0 << 0.0;
@ -243,7 +243,7 @@ void TST_VEllipticalArc::TestData()
QTest::newRow("Arc less than 270 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc less than 270 degree, radiuses 15000, 1500, rotation 20")
<< 15000.0 << 1500.0 << 0.0 << 150.3 << 20.0;
<< 15000.0 << 1500.0 << 0.0 << 150.3 << 20.0;
QTest::newRow("Arc less than 270 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 150.3 << 0.0;
QTest::newRow("Arc 270 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 270.0 << 0.0;
@ -256,24 +256,24 @@ void TST_VEllipticalArc::TestData()
QTest::newRow("Arc less than 360 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc less than 360 degree, radiuses 12000, 1200, rotation 30")
<< 12000.0 << 1200.0 << 0.0 << 340.0 << 30.0;
<< 12000.0 << 1200.0 << 0.0 << 340.0 << 30.0;
QTest::newRow("Arc less than 360 degree, radiuses 12000, 10000") << 15000.0 << 10000.0 << 0.0 << 340.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 150, 400") << 150.0 << 400.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 1500, 800")
<< 1500.0 << 800.0 << 90.0 << 135.0 << 0.0;
<< 1500.0 << 800.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 13000, 1000")
<< 15000.0 << 1000.0 << 90.0 << 135.0 << 0.0;
<< 15000.0 << 1000.0 << 90.0 << 135.0 << 0.0;
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 15000, 10000")
<< 15000.0 << 10000.0 << 90.0 << 135.0 << 0.0;
<< 15000.0 << 10000.0 << 90.0 << 135.0 << 0.0;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
void TST_VEllipticalArc::TestGetPoints1()
{
//Any point must satisfy the equation of ellipse
// Any point must satisfy the equation of ellipse
QFETCH(qreal, radius1);
QFETCH(qreal, radius2);
QFETCH(qreal, startAngle);
@ -291,12 +291,14 @@ void TST_VEllipticalArc::TestGetPoints1()
for (auto p : points)
{
const qreal equationRes = p.rx()*p.rx()/(radius1*radius1) + p.ry()*p.ry()/(radius2*radius2);
const qreal equationRes = p.rx() * p.rx() / (radius1 * radius1) + p.ry() * p.ry() / (radius2 * radius2);
const qreal diff = qAbs(equationRes - 1);
// cppcheck-suppress unreadVariable
const QString errorMsg = QString("Broken the first rule. Any point must satisfy the equation of ellipse."
"diff = '%1' > eps = '%2'").number(diff).number(eps);
QVERIFY2( diff <= eps, qUtf8Printable(errorMsg));
"diff = '%1' > eps = '%2'")
.number(diff)
.number(eps);
QVERIFY2(diff <= eps, qUtf8Printable(errorMsg));
}
}
}
@ -317,7 +319,7 @@ void TST_VEllipticalArc::TestGetPoints2()
arc.SetApproximationScale(maxCurveApproximationScale);
QVector<QPointF> points = arc.GetPoints();
const qreal c = qSqrt(qAbs(radius2*radius2 - radius1*radius1));
const qreal c = qSqrt(qAbs(radius2 * radius2 - radius1 * radius1));
// distance from the center to the focus
QPointF focus1 = static_cast<QPointF>(center);
@ -358,19 +360,23 @@ void TST_VEllipticalArc::TestGetPoints2()
const qreal distance = distance1.length() + distance2.length();
const qreal eps = distance * 1.1 / 100; // computing error 1.1 % from origin distance
for (int i=0; i < points.size(); ++i)
for (int i = 0; i < points.size(); ++i)
{
const QLineF rLine1(focus1, points.at(i));
const QLineF rLine2(focus2, points.at(i));
const qreal resultingDistance = rLine1.length()+rLine2.length();
const qreal resultingDistance = rLine1.length() + rLine2.length();
const qreal diff = qAbs(resultingDistance - distance);
// cppcheck-suppress unreadVariable
const QString errorMsg = QString("Broken the first rule, part 2. Distance from the any point to the focus1"
" plus distance from this point to the focus2 should be the same. Problem"
" with point '%1'. The disired distance is '%2', but resulting distance"
" is '%3'. Difference is '%4' and it biggest than eps '%5')").number(i)
.number(distance).number(resultingDistance).number(diff).number(eps);
QVERIFY2( diff <= eps, qUtf8Printable(errorMsg));
" is '%3'. Difference is '%4' and it biggest than eps '%5')")
.number(i)
.number(distance)
.number(resultingDistance)
.number(diff)
.number(eps);
QVERIFY2(diff <= eps, qUtf8Printable(errorMsg));
}
}
@ -391,14 +397,16 @@ void TST_VEllipticalArc::TestGetPoints3()
QVector<QPointF> points = arc.GetPoints();
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
{// calculated full ellipse square
{ // calculated full ellipse square
const qreal ellipseSquare = M_PI * radius1 * radius2;
const qreal epsSquare = ellipseSquare * 1.7 / 100; // computing error 1.7 % from origin square
const qreal arcSquare = qAbs(VAbstractPiece::SumTrapezoids(points)/2.0);
const qreal arcSquare = qAbs(VAbstractPiece::SumTrapezoids(points) / 2.0);
const qreal diffSquare = qAbs(ellipseSquare - arcSquare);
// cppcheck-suppress unreadVariable
const QString errorMsg1 = QString("Broken the second rule. Interpolation has too big computing error. "
"Difference ='%1' bigger than eps = '%2'.").arg(diffSquare).arg(epsSquare);
"Difference ='%1' bigger than eps = '%2'.")
.arg(diffSquare)
.arg(epsSquare);
QVERIFY2(diffSquare <= epsSquare, qUtf8Printable(errorMsg1));
}
}
@ -419,15 +427,17 @@ void TST_VEllipticalArc::TestGetPoints4()
arc.SetApproximationScale(maxCurveApproximationScale);
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
{// calculated full ellipse length
const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2));
const qreal ellipseLength = M_PI*(radius1+radius2)*(1+3*h/(10+qSqrt(4-3*h)));
{ // calculated full ellipse length
const qreal h = ((radius1 - radius2) * (radius1 - radius2)) / ((radius1 + radius2) * (radius1 + radius2));
const qreal ellipseLength = M_PI * (radius1 + radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h)));
const qreal epsLength = ToPixel(1, Unit::Mm); // computing error
const qreal arcLength = VEllipticalArc(center, radius1, radius2, 0, 360, 0).GetLength();
const qreal diffLength = qAbs(arcLength - ellipseLength);
// cppcheck-suppress unreadVariable
const QString errorMsg2 = QString("Difference between real and computing lengthes "
"(diff = '%1') bigger than eps = '%2'.").arg(diffLength).arg(epsLength);
"(diff = '%1') bigger than eps = '%2'.")
.arg(diffLength)
.arg(epsLength);
QVERIFY2(diffLength <= epsLength, qUtf8Printable(errorMsg2));
}
}
@ -452,8 +462,8 @@ void TST_VEllipticalArc::TestGetPoints5()
VEllipticalArc arc(center, radius1, radius2, startAngle, endAngle, rotationAngle);
arc.SetApproximationScale(maxCurveApproximationScale);
const qreal stAngle = VEllipticalArc::OptimizeAngle(arc.GetStartAngle()+arc.GetRotationAngle());
const qreal enAngle = VEllipticalArc::OptimizeAngle(arc.GetEndAngle()+arc.GetRotationAngle());
const qreal stAngle = VEllipticalArc::OptimizeAngle(arc.GetStartAngle() + arc.GetRotationAngle());
const qreal enAngle = VEllipticalArc::OptimizeAngle(arc.GetEndAngle() + arc.GetRotationAngle());
qreal f1 = QLineF(static_cast<QPointF>(center), arc.GetP1()).angle();
if ((qFuzzyIsNull(f1) && VFuzzyComparePossibleNulls(360, stAngle)) ||
@ -503,17 +513,17 @@ void TST_VEllipticalArc::TestRotation_data()
QTest::addColumn<qreal>("degrees");
QTest::addColumn<QString>("prefix");
QTest::newRow("Test el arc 1") << QPointF() << 10. << 20.0 << 1. << 91. << 0.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 2") << QPointF() << 10. << 20.0 << 0. << 90. << 0.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.2") << QPointF(10, 10) << 10. << 20.0 << 0. << 90. << 0.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.1") << QPointF(10, 10) << 10. << 20.0 << 1. << 91. << 0.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3") << QPointF(10, 10) << 10. << 20.0 << 1. << 91. << 90.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 4") << QPointF(10, 10) << 10. << 20.0 << 0. << 90. << 90.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 5") << QPointF(10, 10) << 10. << 20.0 << 0. << 180. << 90.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 6") << QPointF(10, 10) << 10. << 20.0 << 1. << 181. << 90.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 7") << QPointF(10, 10) << 10. << 20.0 << 0. << 270. << 90.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 8") << QPointF(10, 10) << 10. << 20.0 << 1. << 271. << 90.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 9") << QPointF(10, 10) << 10. << 20.0 << 0. << 360. << 90.<< QPointF() << 90. << "_r";
QTest::newRow("Test el arc 1") << QPointF() << 10. << 20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 2") << QPointF() << 10. << 20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.2") << QPointF(10, 10) << 10. << 20.0 << 0. << 90. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3.1") << QPointF(10, 10) << 10. << 20.0 << 1. << 91. << 0. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 3") << QPointF(10, 10) << 10. << 20.0 << 1. << 91. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 4") << QPointF(10, 10) << 10. << 20.0 << 0. << 90. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 5") << QPointF(10, 10) << 10. << 20.0 << 0. << 180. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 6") << QPointF(10, 10) << 10. << 20.0 << 1. << 181. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 7") << QPointF(10, 10) << 10. << 20.0 << 0. << 270. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 8") << QPointF(10, 10) << 10. << 20.0 << 1. << 271. << 90. << QPointF() << 90. << "_r";
QTest::newRow("Test el arc 9") << QPointF(10, 10) << 10. << 20.0 << 0. << 360. << 90. << QPointF() << 90. << "_r";
}
//---------------------------------------------------------------------------------------------------------------------
@ -533,15 +543,14 @@ void TST_VEllipticalArc::TestRotation()
const VEllipticalArc rotatedArc = arcOrigin.Rotate(rotatePoint, degrees, prefix);
QVERIFY2(qAbs(arcOrigin.AngleArc() - rotatedArc.AngleArc()) <= 1.6,
qUtf8Printable(QString("a1 = %1, a2 - %2").arg(arcOrigin.AngleArc()).arg(rotatedArc.AngleArc())));
qUtf8Printable(QString("a1 = %1, a2 - %2").arg(arcOrigin.AngleArc()).arg(rotatedArc.AngleArc())));
// cppcheck-suppress unreadVariable
QString errorLengthMsg =
QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3");
QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3");
QVERIFY2(qAbs(arcOrigin.GetLength() - rotatedArc.GetLength()) <= ToPixel(1, Unit::Mm),
qUtf8Printable(errorLengthMsg.arg(ToPixel(1, Unit::Mm))
.arg(arcOrigin.GetLength())
.arg(rotatedArc.GetLength())));
qUtf8Printable(
errorLengthMsg.arg(ToPixel(1, Unit::Mm)).arg(arcOrigin.GetLength()).arg(rotatedArc.GetLength())));
QCOMPARE(arcOrigin.GetRadius1(), rotatedArc.GetRadius1());
QCOMPARE(arcOrigin.GetRadius2(), rotatedArc.GetRadius2());
@ -587,7 +596,7 @@ void TST_VEllipticalArc::TestFlip()
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
QCOMPARE(qRound(elArc.GetLength()*-1), qRound(res.GetLength()));
QCOMPARE(qRound(elArc.GetLength() * -1), qRound(res.GetLength()));
QCOMPARE(elArc.GetRadius1(), res.GetRadius1());
QCOMPARE(elArc.GetRadius2(), res.GetRadius2());
}
@ -600,8 +609,8 @@ void TST_VEllipticalArc::EmptyArc_data()
QTest::addColumn<qreal>("length");
QTest::newRow("Empty elArc") << 0. << 0. << 0.;
QTest::newRow("Radius1 correct") << 50. << 0. << 50.*4;
QTest::newRow("Radius2 correct") << 0. << 30. << 30.*4;
QTest::newRow("Radius1 correct") << 50. << 0. << 50. * 4;
QTest::newRow("Radius2 correct") << 0. << 30. << 30. * 4;
}
//---------------------------------------------------------------------------------------------------------------------