Refactoring.
Code style.
This commit is contained in:
parent
ff6689f247
commit
baf4f1a08b
src
app
puzzle/undocommands
tape/dialogs
valentina/dialogs
libs
ifc/xml
qmuparser
vdxf/libdxfrw
vlayout
vmisc
vobj
vpatterndb
vpropertyexplorer
vtools/tools/drawTools/operation
vwidgets
test/ValentinaTest
|
@ -42,10 +42,12 @@ QT_WARNING_POP
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPUndoCommand::VPUndoCommand(QUndoCommand *parent)
|
VPUndoCommand::VPUndoCommand(QUndoCommand *parent)
|
||||||
: QUndoCommand(parent)
|
: QUndoCommand(parent)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPUndoCommand::VPUndoCommand(bool allowMerge, QUndoCommand *parent)
|
VPUndoCommand::VPUndoCommand(bool allowMerge, QUndoCommand *parent)
|
||||||
: QUndoCommand(parent),
|
: QUndoCommand(parent),
|
||||||
m_allowMerge(allowMerge)
|
m_allowMerge(allowMerge)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "dialogmdatabase.h"
|
#include "dialogmdatabase.h"
|
||||||
#include "ui_dialogmdatabase.h"
|
|
||||||
#include "../mapplication.h"
|
#include "../mapplication.h"
|
||||||
#include "../vpatterndb/measurements.h"
|
#include "../vpatterndb/measurements.h"
|
||||||
|
#include "ui_dialogmdatabase.h"
|
||||||
#include "../vmisc/compatibility.h"
|
#include "../vmisc/compatibility.h"
|
||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
|
DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
|
||||||
:QDialog(parent),
|
: QDialog(parent),
|
||||||
ui(new Ui::DialogMDataBase),
|
ui(new Ui::DialogMDataBase),
|
||||||
m_selectMode(true),
|
m_selectMode(true),
|
||||||
m_list(list)
|
m_list(list)
|
||||||
|
@ -64,7 +64,7 @@ DialogMDataBase::DialogMDataBase(const QStringList &list, QWidget *parent)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogMDataBase::DialogMDataBase(QWidget *parent)
|
DialogMDataBase::DialogMDataBase(QWidget *parent)
|
||||||
:QDialog(parent),
|
: QDialog(parent),
|
||||||
ui(new Ui::DialogMDataBase),
|
ui(new Ui::DialogMDataBase),
|
||||||
m_selectMode(false)
|
m_selectMode(false)
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ auto DialogMDataBase::GetNewNames() const -> QStringList
|
||||||
{
|
{
|
||||||
QStringList newNames;
|
QStringList newNames;
|
||||||
QTreeWidgetItemIterator it(ui->treeWidget,
|
QTreeWidgetItemIterator it(ui->treeWidget,
|
||||||
QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Checked );
|
QTreeWidgetItemIterator::NoChildren | QTreeWidgetItemIterator::Checked);
|
||||||
while (*it)
|
while (*it)
|
||||||
{
|
{
|
||||||
const QString name = (*it)->data(0, Qt::UserRole).toString();
|
const QString name = (*it)->data(0, Qt::UserRole).toString();
|
||||||
|
@ -144,8 +144,8 @@ void DialogMDataBase::RetranslateGroups()
|
||||||
auto DialogMDataBase::ImgTag(const QString &number) -> QString
|
auto DialogMDataBase::ImgTag(const QString &number) -> QString
|
||||||
{
|
{
|
||||||
QString imgUrl(QStringLiteral("<img src=\"wrong.png\" align=\"center\"/>")); // In case of error
|
QString imgUrl(QStringLiteral("<img src=\"wrong.png\" align=\"center\"/>")); // In case of error
|
||||||
const QString filePath = QStringLiteral("://diagrams/%1.svg")
|
const QString filePath =
|
||||||
.arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number));
|
QStringLiteral("://diagrams/%1.svg").arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number));
|
||||||
if (QFileInfo::exists(filePath))
|
if (QFileInfo::exists(filePath))
|
||||||
{
|
{
|
||||||
// Load your SVG
|
// Load your SVG
|
||||||
|
@ -203,7 +203,7 @@ auto DialogMDataBase::eventFilter(QObject *target, QEvent *event) -> bool
|
||||||
if (target == ui->treeWidget && event->type() == QEvent::KeyPress)
|
if (target == ui->treeWidget && event->type() == QEvent::KeyPress)
|
||||||
{
|
{
|
||||||
auto *keyEvent = static_cast<QKeyEvent *>(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
|
auto *keyEvent = static_cast<QKeyEvent *>(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
|
||||||
switch(keyEvent->key())
|
switch (keyEvent->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
{
|
{
|
||||||
|
@ -262,8 +262,7 @@ void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
|
||||||
}
|
}
|
||||||
for (int j = 0; j < parent->childCount(); ++j)
|
for (int j = 0; j < parent->childCount(); ++j)
|
||||||
{
|
{
|
||||||
if (j != parent->indexOfChild(item)
|
if (j != parent->indexOfChild(item) && item->checkState(0) != parent->child(j)->checkState(0))
|
||||||
&& item->checkState(0) != parent->child(j)->checkState(0))
|
|
||||||
{
|
{
|
||||||
diff = true;
|
diff = true;
|
||||||
}
|
}
|
||||||
|
@ -415,14 +414,14 @@ void DialogMDataBase::FilterGroup(QTreeWidgetItem *group, const QString &search)
|
||||||
SCASSERT(group != nullptr)
|
SCASSERT(group != nullptr)
|
||||||
|
|
||||||
bool match = false;
|
bool match = false;
|
||||||
for (int i=0; i < group->childCount(); ++i)
|
for (int i = 0; i < group->childCount(); ++i)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *childItem = group->child(i);
|
QTreeWidgetItem *childItem = group->child(i);
|
||||||
const QString description = QTextDocumentFragment::fromHtml(ItemFullDescription(childItem, false))
|
const QString description =
|
||||||
.toPlainText();
|
QTextDocumentFragment::fromHtml(ItemFullDescription(childItem, false)).toPlainText();
|
||||||
|
|
||||||
const bool hidden = not childItem->text(0).contains(search, Qt::CaseInsensitive)
|
const bool hidden = not childItem->text(0).contains(search, Qt::CaseInsensitive) &&
|
||||||
&& not description.contains(search, Qt::CaseInsensitive);
|
not description.contains(search, Qt::CaseInsensitive);
|
||||||
|
|
||||||
childItem->setHidden(hidden);
|
childItem->setHidden(hidden);
|
||||||
if (not hidden)
|
if (not hidden)
|
||||||
|
@ -530,7 +529,7 @@ void DialogMDataBase::RetranslateGroup(QTreeWidgetItem *group, const QString &gr
|
||||||
group->setText(0, groupText);
|
group->setText(0, groupText);
|
||||||
group->setToolTip(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));
|
RetranslateMeasurement(group, i, list.at(i));
|
||||||
}
|
}
|
||||||
|
@ -577,43 +576,27 @@ auto DialogMDataBase::GlobalCheckState() const -> Qt::CheckState
|
||||||
|
|
||||||
if (m_selectMode)
|
if (m_selectMode)
|
||||||
{
|
{
|
||||||
if (m_groupA->checkState(0) == Qt::Unchecked &&
|
if (m_groupA->checkState(0) == Qt::Unchecked && m_groupB->checkState(0) == Qt::Unchecked &&
|
||||||
m_groupB->checkState(0) == Qt::Unchecked &&
|
m_groupC->checkState(0) == Qt::Unchecked && m_groupD->checkState(0) == Qt::Unchecked &&
|
||||||
m_groupC->checkState(0) == Qt::Unchecked &&
|
m_groupE->checkState(0) == Qt::Unchecked && m_groupF->checkState(0) == Qt::Unchecked &&
|
||||||
m_groupD->checkState(0) == Qt::Unchecked &&
|
m_groupG->checkState(0) == Qt::Unchecked && m_groupH->checkState(0) == Qt::Unchecked &&
|
||||||
m_groupE->checkState(0) == Qt::Unchecked &&
|
m_groupI->checkState(0) == Qt::Unchecked && m_groupJ->checkState(0) == Qt::Unchecked &&
|
||||||
m_groupF->checkState(0) == Qt::Unchecked &&
|
m_groupK->checkState(0) == Qt::Unchecked && m_groupL->checkState(0) == Qt::Unchecked &&
|
||||||
m_groupG->checkState(0) == Qt::Unchecked &&
|
m_groupM->checkState(0) == Qt::Unchecked && m_groupN->checkState(0) == Qt::Unchecked &&
|
||||||
m_groupH->checkState(0) == Qt::Unchecked &&
|
m_groupO->checkState(0) == Qt::Unchecked && m_groupP->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)
|
m_groupQ->checkState(0) == Qt::Unchecked)
|
||||||
{
|
{
|
||||||
return Qt::Checked;
|
return Qt::Checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_groupA->checkState(0) == Qt::Checked &&
|
if (m_groupA->checkState(0) == Qt::Checked && m_groupB->checkState(0) == Qt::Checked &&
|
||||||
m_groupB->checkState(0) == Qt::Checked &&
|
m_groupC->checkState(0) == Qt::Checked && m_groupD->checkState(0) == Qt::Checked &&
|
||||||
m_groupC->checkState(0) == Qt::Checked &&
|
m_groupE->checkState(0) == Qt::Checked && m_groupF->checkState(0) == Qt::Checked &&
|
||||||
m_groupD->checkState(0) == Qt::Checked &&
|
m_groupG->checkState(0) == Qt::Checked && m_groupH->checkState(0) == Qt::Checked &&
|
||||||
m_groupE->checkState(0) == Qt::Checked &&
|
m_groupI->checkState(0) == Qt::Checked && m_groupJ->checkState(0) == Qt::Checked &&
|
||||||
m_groupF->checkState(0) == Qt::Checked &&
|
m_groupK->checkState(0) == Qt::Checked && m_groupL->checkState(0) == Qt::Checked &&
|
||||||
m_groupG->checkState(0) == Qt::Checked &&
|
m_groupM->checkState(0) == Qt::Checked && m_groupN->checkState(0) == Qt::Checked &&
|
||||||
m_groupH->checkState(0) == Qt::Checked &&
|
m_groupO->checkState(0) == Qt::Checked && m_groupP->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)
|
m_groupQ->checkState(0) == Qt::Checked)
|
||||||
{
|
{
|
||||||
return Qt::Unchecked;
|
return Qt::Unchecked;
|
||||||
|
|
|
@ -28,13 +28,14 @@
|
||||||
|
|
||||||
#include "dialogsavelayout.h"
|
#include "dialogsavelayout.h"
|
||||||
#include "../core/vapplication.h"
|
#include "../core/vapplication.h"
|
||||||
|
#include "../ifc/exception/vexception.h"
|
||||||
|
#include "../vlayout/vlayoutexporter.h"
|
||||||
#include "../vmisc/vvalentinasettings.h"
|
#include "../vmisc/vvalentinasettings.h"
|
||||||
#include "ui_dialogsavelayout.h"
|
#include "ui_dialogsavelayout.h"
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
||||||
#include "../vmisc/backport/qoverload.h"
|
#include "../vmisc/backport/qoverload.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
#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)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
|
|
|
@ -35,20 +35,20 @@
|
||||||
#include <QDomNode>
|
#include <QDomNode>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QLatin1String>
|
#include <QLatin1String>
|
||||||
#include <QString>
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <functional>
|
#include <QString>
|
||||||
#include <QtCore/qcontainerfwd.h>
|
#include <QtCore/qcontainerfwd.h>
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#include "../ifcdef.h"
|
#include "../ifcdef.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/literals.h"
|
#include "../vmisc/literals.h"
|
||||||
#include "../qmuparser/qmudef.h"
|
|
||||||
|
|
||||||
class QDomElement;
|
class QDomElement;
|
||||||
class QDomNode;
|
class QDomNode;
|
||||||
|
@ -84,6 +84,7 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
||||||
class VDomDocument : public QObject, public QDomDocument
|
class VDomDocument : public QObject, public QDomDocument
|
||||||
{
|
{
|
||||||
Q_OBJECT // NOLINT
|
Q_OBJECT // NOLINT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const QString AttrId;
|
static const QString AttrId;
|
||||||
static const QString AttrText;
|
static const QString AttrText;
|
||||||
|
@ -100,19 +101,18 @@ public:
|
||||||
virtual ~VDomDocument();
|
virtual ~VDomDocument();
|
||||||
auto elementById(quint32 id, const QString &tagName = QString(), bool updateCache = true) -> QDomElement;
|
auto elementById(quint32 id, const QString &tagName = QString(), bool updateCache = true) -> QDomElement;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T> void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
|
||||||
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
|
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 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 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 GetParametrBool(const QDomElement &domElement, const QString &name, const QString &defValue) -> bool;
|
||||||
|
|
||||||
static auto GetParametrUsage(const QDomElement &domElement, const QString &name) -> NodeUsage;
|
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,
|
static auto GetParametrString(const QDomElement &domElement, const QString &name,
|
||||||
const QString &defValue = QString()) -> QString;
|
const QString &defValue = QString()) -> QString;
|
||||||
|
@ -153,7 +153,7 @@ protected:
|
||||||
auto setTagText(QDomElement &domElement, const QString &text) -> bool;
|
auto setTagText(QDomElement &domElement, const QString &text) -> bool;
|
||||||
auto UniqueTag(const QString &tagName) const -> QDomElement;
|
auto UniqueTag(const QString &tagName) const -> QDomElement;
|
||||||
auto UniqueTagText(const QString &tagName, const QString &defVal = QString()) const -> QString;
|
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);
|
static void ValidateVersion(const QString &version);
|
||||||
|
|
||||||
|
@ -223,14 +223,14 @@ template <>
|
||||||
inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement, const QString &name,
|
inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement, const QString &name,
|
||||||
const MeasurementsType &value) const
|
const MeasurementsType &value) const
|
||||||
{
|
{
|
||||||
domElement.setAttribute(name, value == MeasurementsType::Multisize ? QStringLiteral("multisize") :
|
domElement.setAttribute(name, value == MeasurementsType::Multisize ? QStringLiteral("multisize")
|
||||||
QStringLiteral("individual"));
|
: QStringLiteral("individual"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void VDomDocument::SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
|
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);
|
not removeCondition(value) ? SetAttribute(domElement, name, value) : domElement.removeAttribute(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,10 @@
|
||||||
Class &operator=(Class &&) = delete;
|
Class &operator=(Class &&) = delete;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef Q_DISABLE_ASSIGN
|
||||||
|
#define Q_DISABLE_ASSIGN(Class) Class &operator=(const Class &) = delete;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef Q_DISABLE_ASSIGN_MOVE
|
#ifndef Q_DISABLE_ASSIGN_MOVE
|
||||||
#define Q_DISABLE_ASSIGN_MOVE(Class) \
|
#define Q_DISABLE_ASSIGN_MOVE(Class) \
|
||||||
Q_DISABLE_ASSIGN(Class) \
|
Q_DISABLE_ASSIGN(Class) \
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace qmu
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QmuFormulaBase::QmuFormulaBase()
|
QmuFormulaBase::QmuFormulaBase()
|
||||||
:QmuParser()
|
: QmuParser()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,20 +55,23 @@ void QmuFormulaBase::InitCharSets()
|
||||||
{
|
{
|
||||||
QString symbolsStr;
|
QString symbolsStr;
|
||||||
{
|
{
|
||||||
//String with all unique symbols for supported alphabets.
|
// String with all unique symbols for supported alphabets.
|
||||||
//See script alphabets.py for generation and more information.
|
// 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
|
// Note. MSVC doesn't support normal string concatenation for long string. That's why we use QStringList in this
|
||||||
//case.
|
// case.
|
||||||
const QStringList symbols
|
const QStringList symbols{
|
||||||
{
|
QStringLiteral(
|
||||||
QStringLiteral("ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥĦШҫ̆έجگĮаҳѕεشԶиһνԾрÃυلՆӝшËύՎїPÓՖXӛӟŞãզhëҔծpóӞնxßվāŁЃֆĉЋΊCŬđҐГΒęҘЛΚŘġҠУGا"),
|
"ցЀĆЈVӧĎАғΕĖӅИқΝĞơРңњΥĦШҫ̆έجگĮаҳѕεشԶиһνԾрÃυلՆӝшËύՎїPÓՖXӛӟŞãզhëҔծpóӞնxßվāŁЃֆĉЋΊCŬđҐГΒęҘЛΚŘġҠУGا"),
|
||||||
QStringLiteral("հЫΪŪدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփӣІĈΏЎґĐΗЖҙĘȚΟОҡĠآΧЦتίЮұİزηжԸغẽοоÁՀقχц"),
|
QStringLiteral("հЫΪŪدԱҰгβطԹõлκKՁÀуςهՉÈыvیՑÐSOřӘћաőcӐթèkàѓżűðsķչøӥӔĀփӣІĈΏЎґĐΗЖҙĘȚΟОҡĠآΧЦتίЮұİزηжԸغẽοоÁՀقχц"),
|
||||||
QStringLiteral("ÉՈيюÑՐђӋіәťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċΌБӸēłΔҖЙŤěΜӜDСձģΤӰЩīņحάҮбưԳصδHйԻŇμӴсՃمτƠщՋόєLQŹՓŕÖYśÞaգĽ"),
|
QStringLiteral(
|
||||||
QStringLiteral("æiŽիӓîqճöyջþĂօЄӦΉĊЌΑĒДҗјΙȘĚМΡéĵĢФūӚΩبĪЬүќαذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇΆčŃЏΎĕӯЗΖEțŮ"),
|
"ÉՈيюÑՐђӋіәťӆўáŠĺѐfөըnñŰӤӨӹոľЁրăЉŭċΌБӸēłΔҖЙŤěΜӜDСձģΤӰЩīņحάҮбưԳصδHйԻŇμӴсՃمτƠщՋόєLQŹՓŕÖYśÞaգĽ"),
|
||||||
QStringLiteral("ĝПΞأĥĹЧΦثÆӳЯήIسŲԵзζԽпξكՅÄчφNMՍӌяώӢӲՕÔWÎŝÜџёźեägխoӒյôwĶBžսüЂĄև̈ЊČƏљΓВҕĔӮΛКĜΣТҥĤکΫЪƯخγвŅԴϊضλкԼ"),
|
QStringLiteral(
|
||||||
QStringLiteral("ĴσтÅՄنϋъÍՌRӕՔZÝŜbåդﻩjíլļrӵմӱzýռپêЅքćچΈЍďΐҒЕůėژșΘØҚНğńءΠFҢХħΨҪЭųįҶرΰҲеԷňعθҺнԿفπÂхՇψÊэšՏÒUəÚѝ"),
|
"æiŽիӓîqճöyջþĂօЄӦΉĊЌΑĒДҗјΙȘĚМΡéĵĢФūӚΩبĪЬүќαذԲдҷιظԺмρՂфÇωوՊьÏՒTŚĻJբdçժlïӪղtպӫAւąЇΆčŃЏΎĕӯЗΖEțŮ"),
|
||||||
QStringLiteral("ŻşҤӑâeէŐımկòuշÕúտŔ")
|
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());
|
||||||
}
|
}
|
||||||
|
@ -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 map map with tokens
|
||||||
* @param val token that need delete
|
* @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)
|
for (auto key : listKeys)
|
||||||
{
|
{
|
||||||
map.remove(key);
|
map.remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}// namespace qmu
|
} // namespace qmu
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
void SetSepForTr(bool osSeparator, bool fromUser);
|
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:
|
protected:
|
||||||
static auto AddVariable(const QString &a_szName, void *a_pUserData) -> qreal *;
|
static auto AddVariable(const QString &a_szName, void *a_pUserData) -> qreal *;
|
||||||
|
|
|
@ -43,10 +43,10 @@ QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Wunused-variable")
|
QT_WARNING_DISABLE_GCC("-Wunused-variable")
|
||||||
QT_WARNING_DISABLE_CLANG("-Wunused-variable")
|
QT_WARNING_DISABLE_CLANG("-Wunused-variable")
|
||||||
|
|
||||||
//static auto endl Q_DECL_UNUSED = ::endl; // NOLINT
|
// static auto endl Q_DECL_UNUSED = ::endl; // NOLINT
|
||||||
//static auto flush Q_DECL_UNUSED = ::flush; // NOLINT
|
// static auto flush Q_DECL_UNUSED = ::flush; // NOLINT
|
||||||
static auto dec Q_DECL_UNUSED = ::dec; // 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
|
QT_WARNING_POP
|
||||||
} // namespace Qt
|
} // namespace Qt
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include "drw_entities.h"
|
#include "drw_entities.h"
|
||||||
#include "intern/dxfreader.h"
|
|
||||||
#include "intern/drw_dbg.h"
|
|
||||||
#include "drw_reserve.h"
|
#include "drw_reserve.h"
|
||||||
|
#include "intern/drw_dbg.h"
|
||||||
|
#include "intern/dxfreader.h"
|
||||||
|
#include <cstdlib>
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
@ -23,22 +23,26 @@
|
||||||
|
|
||||||
//! Calculate arbitrary axis
|
//! Calculate arbitrary axis
|
||||||
/*!
|
/*!
|
||||||
* Calculate arbitrary axis for apply extrusions
|
* Calculate arbitrary axis for apply extrusions
|
||||||
* @author Rallaz
|
* @author Rallaz
|
||||||
*/
|
*/
|
||||||
void DRW_Entity::calculateAxis(DRW_Coord extPoint){
|
void DRW_Entity::calculateAxis(DRW_Coord extPoint)
|
||||||
//Follow the arbitrary DXF definitions for extrusion axes.
|
{
|
||||||
if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625) {
|
// Follow the arbitrary DXF definitions for extrusion axes.
|
||||||
//If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec.
|
if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625)
|
||||||
//The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x
|
{
|
||||||
//Factoring in the fixed values for Wy gives N.z,0,-N.x
|
// If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec.
|
||||||
|
// The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x
|
||||||
|
// Factoring in the fixed values for Wy gives N.z,0,-N.x
|
||||||
extAxisX.x = extPoint.z;
|
extAxisX.x = extPoint.z;
|
||||||
extAxisX.y = 0;
|
extAxisX.y = 0;
|
||||||
extAxisX.z = -extPoint.x;
|
extAxisX.z = -extPoint.x;
|
||||||
} else {
|
}
|
||||||
//Otherwise, implement Ax = Wz x N where Wz is [0,0,1] per the DXF spec.
|
else
|
||||||
//The cross product works out to Wz.y*N.z-Wz.z*N.y, Wz.z*N.x-Wz.x*N.z, Wz.x*N.y-Wz.y*N.x
|
{
|
||||||
//Factoring in the fixed values for Wz gives -N.y,N.x,0.
|
// Otherwise, implement Ax = Wz x N where Wz is [0,0,1] per the DXF spec.
|
||||||
|
// The cross product works out to Wz.y*N.z-Wz.z*N.y, Wz.z*N.x-Wz.x*N.z, Wz.x*N.y-Wz.y*N.x
|
||||||
|
// Factoring in the fixed values for Wz gives -N.y,N.x,0.
|
||||||
extAxisX.x = -extPoint.y;
|
extAxisX.x = -extPoint.y;
|
||||||
extAxisX.y = extPoint.x;
|
extAxisX.y = extPoint.x;
|
||||||
extAxisX.z = 0;
|
extAxisX.z = 0;
|
||||||
|
@ -46,7 +50,7 @@ void DRW_Entity::calculateAxis(DRW_Coord extPoint){
|
||||||
|
|
||||||
extAxisX.unitize();
|
extAxisX.unitize();
|
||||||
|
|
||||||
//Ay = N x Ax
|
// Ay = N x Ax
|
||||||
extAxisY.x = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z);
|
extAxisY.x = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z);
|
||||||
extAxisY.y = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x);
|
extAxisY.y = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x);
|
||||||
extAxisY.z = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y);
|
extAxisY.z = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y);
|
||||||
|
@ -56,14 +60,15 @@ void DRW_Entity::calculateAxis(DRW_Coord extPoint){
|
||||||
|
|
||||||
//! Extrude a point using arbitrary axis
|
//! Extrude a point using arbitrary axis
|
||||||
/*!
|
/*!
|
||||||
* apply extrusion in a point using arbitrary axis (previous calculated)
|
* apply extrusion in a point using arbitrary axis (previous calculated)
|
||||||
* @author Rallaz
|
* @author Rallaz
|
||||||
*/
|
*/
|
||||||
void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const{
|
void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const
|
||||||
|
{
|
||||||
double px, py, pz;
|
double px, py, pz;
|
||||||
px = (extAxisX.x*point->x)+(extAxisY.x*point->y)+(extPoint.x*point->z);
|
px = (extAxisX.x * point->x) + (extAxisY.x * point->y) + (extPoint.x * point->z);
|
||||||
py = (extAxisX.y*point->x)+(extAxisY.y*point->y)+(extPoint.y*point->z);
|
py = (extAxisX.y * point->x) + (extAxisY.y * point->y) + (extPoint.y * point->z);
|
||||||
pz = (extAxisX.z*point->x)+(extAxisY.z*point->y)+(extPoint.z*point->z);
|
pz = (extAxisX.z * point->x) + (extAxisY.z * point->y) + (extPoint.z * point->z);
|
||||||
|
|
||||||
point->x = px;
|
point->x = px;
|
||||||
point->y = py;
|
point->y = py;
|
||||||
|
@ -72,7 +77,8 @@ void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const{
|
||||||
|
|
||||||
auto DRW_Entity::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Entity::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 5:
|
case 5:
|
||||||
handle = static_cast<quint32>(reader->getHandleString());
|
handle = static_cast<quint32>(reader->getHandleString());
|
||||||
break;
|
break;
|
||||||
|
@ -140,16 +146,16 @@ auto DRW_Entity::parseCode(int code, dxfReader *reader) -> bool
|
||||||
case 1033:
|
case 1033:
|
||||||
if (curr)
|
if (curr)
|
||||||
curr->setCoordZ(reader->getDouble());
|
curr->setCoordZ(reader->getDouble());
|
||||||
curr=nullptr;
|
curr = nullptr;
|
||||||
break;
|
break;
|
||||||
case 1040:
|
case 1040:
|
||||||
case 1041:
|
case 1041:
|
||||||
case 1042:
|
case 1042:
|
||||||
extData.push_back(new DRW_Variant(code, reader->getDouble() ));
|
extData.push_back(new DRW_Variant(code, reader->getDouble()));
|
||||||
break;
|
break;
|
||||||
case 1070:
|
case 1070:
|
||||||
case 1071:
|
case 1071:
|
||||||
extData.push_back(new DRW_Variant(code, reader->getInt32() ));
|
extData.push_back(new DRW_Variant(code, reader->getInt32()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -157,24 +163,28 @@ auto DRW_Entity::parseCode(int code, dxfReader *reader) -> bool
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//parses dxf 102 groups to read entity
|
// parses dxf 102 groups to read entity
|
||||||
auto DRW_Entity::parseDxfGroups(int code, dxfReader *reader) -> bool
|
auto DRW_Entity::parseDxfGroups(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
std::list<DRW_Variant> ls;
|
std::list<DRW_Variant> ls;
|
||||||
DRW_Variant c;
|
DRW_Variant c;
|
||||||
int nc;
|
int nc;
|
||||||
std::string appName= reader->getString();
|
std::string appName = reader->getString();
|
||||||
if (!appName.empty() && appName.at(0)== '{'){
|
if (!appName.empty() && appName.at(0) == '{')
|
||||||
c.addString(appName.substr(1, static_cast<size_t>(appName.size()-1)));
|
{
|
||||||
|
c.addString(appName.substr(1, static_cast<size_t>(appName.size() - 1)));
|
||||||
c.code = code;
|
c.code = code;
|
||||||
ls.push_back(c);
|
ls.push_back(c);
|
||||||
while (code !=102 && appName.at(0)== '}'){
|
while (code != 102 && appName.at(0) == '}')
|
||||||
|
{
|
||||||
reader->readRec(&nc);
|
reader->readRec(&nc);
|
||||||
c.code = code;
|
c.code = code;
|
||||||
if (code == 330 || code == 360)
|
if (code == 330 || code == 360)
|
||||||
c.addInt(reader->getHandleString());
|
c.addInt(reader->getHandleString());
|
||||||
else {
|
else
|
||||||
switch (reader->type) {
|
{
|
||||||
|
switch (reader->type)
|
||||||
|
{
|
||||||
case dxfReader::STRING:
|
case dxfReader::STRING:
|
||||||
c.addString(reader->getString());
|
c.addString(reader->getString());
|
||||||
break;
|
break;
|
||||||
|
@ -202,7 +212,8 @@ auto DRW_Entity::parseDxfGroups(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Point::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Point::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 10:
|
case 10:
|
||||||
basePoint.x = reader->getDouble();
|
basePoint.x = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -234,7 +245,8 @@ auto DRW_Point::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_ASTMNotch::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_ASTMNotch::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 50:
|
case 50:
|
||||||
angle = reader->getDouble();
|
angle = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -247,7 +259,8 @@ auto DRW_ASTMNotch::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Line::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Line::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 11:
|
case 11:
|
||||||
secPoint.x = reader->getDouble();
|
secPoint.x = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -264,10 +277,12 @@ auto DRW_Line::parseCode(int code, dxfReader *reader) -> bool
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DRW_Circle::applyExtrusion(){
|
void DRW_Circle::applyExtrusion()
|
||||||
if (haveExtrusion) {
|
{
|
||||||
//NOTE: Commenting these out causes the the arcs being tested to be located
|
if (haveExtrusion)
|
||||||
//on the other side of the y axis (all x dimensions are negated).
|
{
|
||||||
|
// NOTE: Commenting these out causes the the arcs being tested to be located
|
||||||
|
// on the other side of the y axis (all x dimensions are negated).
|
||||||
calculateAxis(extPoint);
|
calculateAxis(extPoint);
|
||||||
extrudePoint(extPoint, &basePoint);
|
extrudePoint(extPoint, &basePoint);
|
||||||
}
|
}
|
||||||
|
@ -275,7 +290,8 @@ void DRW_Circle::applyExtrusion(){
|
||||||
|
|
||||||
auto DRW_Circle::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Circle::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 40:
|
case 40:
|
||||||
radious = reader->getDouble();
|
radious = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -286,34 +302,38 @@ auto DRW_Circle::parseCode(int code, dxfReader *reader) -> bool
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DRW_Arc::applyExtrusion(){
|
void DRW_Arc::applyExtrusion()
|
||||||
|
{
|
||||||
DRW_Circle::applyExtrusion();
|
DRW_Circle::applyExtrusion();
|
||||||
|
|
||||||
if(haveExtrusion){
|
if (haveExtrusion)
|
||||||
|
{
|
||||||
// If the extrusion vector has a z value less than 0, the angles for the arc
|
// If the extrusion vector has a z value less than 0, the angles for the arc
|
||||||
// have to be mirrored since DXF files use the right hand rule.
|
// have to be mirrored since DXF files use the right hand rule.
|
||||||
// Note that the following code only handles the special case where there is a 2D
|
// Note that the following code only handles the special case where there is a 2D
|
||||||
// drawing with the z axis heading into the paper (or rather screen). An arbitrary
|
// drawing with the z axis heading into the paper (or rather screen). An arbitrary
|
||||||
// extrusion axis (with x and y values greater than 1/64) may still have issues.
|
// extrusion axis (with x and y values greater than 1/64) may still have issues.
|
||||||
if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0) {
|
if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0)
|
||||||
staangle=M_PI-staangle;
|
{
|
||||||
endangle=M_PI-endangle;
|
staangle = M_PI - staangle;
|
||||||
|
endangle = M_PI - endangle;
|
||||||
|
|
||||||
double temp = staangle;
|
double temp = staangle;
|
||||||
staangle=endangle;
|
staangle = endangle;
|
||||||
endangle=temp;
|
endangle = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DRW_Arc::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Arc::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 50:
|
case 50:
|
||||||
staangle = reader->getDouble()/ ARAD;
|
staangle = reader->getDouble() / ARAD;
|
||||||
break;
|
break;
|
||||||
case 51:
|
case 51:
|
||||||
endangle = reader->getDouble()/ ARAD;
|
endangle = reader->getDouble() / ARAD;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return DRW_Circle::parseCode(code, reader);
|
return DRW_Circle::parseCode(code, reader);
|
||||||
|
@ -324,7 +344,8 @@ auto DRW_Arc::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Ellipse::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Ellipse::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 40:
|
case 40:
|
||||||
ratio = reader->getDouble();
|
ratio = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -341,69 +362,80 @@ auto DRW_Ellipse::parseCode(int code, dxfReader *reader) -> bool
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DRW_Ellipse::applyExtrusion(){
|
void DRW_Ellipse::applyExtrusion()
|
||||||
if (haveExtrusion) {
|
{
|
||||||
|
if (haveExtrusion)
|
||||||
|
{
|
||||||
calculateAxis(extPoint);
|
calculateAxis(extPoint);
|
||||||
extrudePoint(extPoint, &secPoint);
|
extrudePoint(extPoint, &secPoint);
|
||||||
double intialparam = staparam;
|
double intialparam = staparam;
|
||||||
if (extPoint.z < 0.){
|
if (extPoint.z < 0.)
|
||||||
|
{
|
||||||
staparam = M_PIx2 - endparam;
|
staparam = M_PIx2 - endparam;
|
||||||
endparam = M_PIx2 - intialparam;
|
endparam = M_PIx2 - intialparam;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if ratio > 1 minor axis are greather than major axis, correct it
|
// if ratio > 1 minor axis are greather than major axis, correct it
|
||||||
void DRW_Ellipse::correctAxis(){
|
void DRW_Ellipse::correctAxis()
|
||||||
|
{
|
||||||
bool complete = false;
|
bool complete = false;
|
||||||
if (DRW_FuzzyComparePossibleNulls(staparam, endparam)) {
|
if (DRW_FuzzyComparePossibleNulls(staparam, endparam))
|
||||||
|
{
|
||||||
staparam = 0.0;
|
staparam = 0.0;
|
||||||
endparam = M_PIx2; //2*M_PI;
|
endparam = M_PIx2; // 2*M_PI;
|
||||||
complete = true;
|
complete = true;
|
||||||
}
|
}
|
||||||
if (ratio > 1){
|
if (ratio > 1)
|
||||||
if ( fabs(endparam - staparam - M_PIx2) < 1.0e-10)
|
{
|
||||||
|
if (fabs(endparam - staparam - M_PIx2) < 1.0e-10)
|
||||||
complete = true;
|
complete = true;
|
||||||
double incX = secPoint.x;
|
double incX = secPoint.x;
|
||||||
secPoint.x = -(secPoint.y * ratio);
|
secPoint.x = -(secPoint.y * ratio);
|
||||||
secPoint.y = incX*ratio;
|
secPoint.y = incX * ratio;
|
||||||
ratio = 1/ratio;
|
ratio = 1 / ratio;
|
||||||
if (!complete){
|
if (!complete)
|
||||||
|
{
|
||||||
if (staparam < M_PI_2)
|
if (staparam < M_PI_2)
|
||||||
staparam += M_PI *2;
|
staparam += M_PI * 2;
|
||||||
if (endparam < M_PI_2)
|
if (endparam < M_PI_2)
|
||||||
endparam += M_PI *2;
|
endparam += M_PI * 2;
|
||||||
endparam -= M_PI_2;
|
endparam -= M_PI_2;
|
||||||
staparam -= M_PI_2;
|
staparam -= M_PI_2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//parts are the number of vertex to split polyline, default 128
|
// parts are the number of vertex to split polyline, default 128
|
||||||
void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
|
void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts)
|
||||||
|
{
|
||||||
double radMajor, radMinor, cosRot, sinRot, incAngle, curAngle;
|
double radMajor, radMinor, cosRot, sinRot, incAngle, curAngle;
|
||||||
radMajor = sqrt(secPoint.x*secPoint.x + secPoint.y*secPoint.y);
|
radMajor = sqrt(secPoint.x * secPoint.x + secPoint.y * secPoint.y);
|
||||||
radMinor = radMajor*ratio;
|
radMinor = radMajor * ratio;
|
||||||
//calculate sin & cos of included angle
|
// calculate sin & cos of included angle
|
||||||
incAngle = atan2(secPoint.y, secPoint.x);
|
incAngle = atan2(secPoint.y, secPoint.x);
|
||||||
cosRot = cos(incAngle);
|
cosRot = cos(incAngle);
|
||||||
sinRot = sin(incAngle);
|
sinRot = sin(incAngle);
|
||||||
incAngle = M_PIx2 / parts;
|
incAngle = M_PIx2 / parts;
|
||||||
curAngle = staparam;
|
curAngle = staparam;
|
||||||
int i = static_cast<int>(curAngle / incAngle);
|
int i = static_cast<int>(curAngle / incAngle);
|
||||||
do {
|
do
|
||||||
if (curAngle > endparam) {
|
{
|
||||||
|
if (curAngle > endparam)
|
||||||
|
{
|
||||||
curAngle = endparam;
|
curAngle = endparam;
|
||||||
i = parts+2;
|
i = parts + 2;
|
||||||
}
|
}
|
||||||
double cosCurr = cos(curAngle);
|
double cosCurr = cos(curAngle);
|
||||||
double sinCurr = sin(curAngle);
|
double sinCurr = sin(curAngle);
|
||||||
double x = basePoint.x + (cosCurr*cosRot*radMajor) - (sinCurr*sinRot*radMinor);
|
double x = basePoint.x + (cosCurr * cosRot * radMajor) - (sinCurr * sinRot * radMinor);
|
||||||
double y = basePoint.y + (cosCurr*sinRot*radMajor) + (sinCurr*cosRot*radMinor);
|
double y = basePoint.y + (cosCurr * sinRot * radMajor) + (sinCurr * cosRot * radMinor);
|
||||||
pol->addVertex( DRW_Vertex(x, y, 0.0, 0.0));
|
pol->addVertex(DRW_Vertex(x, y, 0.0, 0.0));
|
||||||
curAngle = (++i)*incAngle;
|
curAngle = (++i) * incAngle;
|
||||||
} while (i<parts);
|
} while (i < parts);
|
||||||
if ( fabs(endparam - staparam - M_PIx2) < 1.0e-10){
|
if (fabs(endparam - staparam - M_PIx2) < 1.0e-10)
|
||||||
|
{
|
||||||
pol->flags = 1;
|
pol->flags = 1;
|
||||||
}
|
}
|
||||||
pol->layer = this->layer;
|
pol->layer = this->layer;
|
||||||
|
@ -413,8 +445,10 @@ void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
|
||||||
pol->extPoint = this->extPoint;
|
pol->extPoint = this->extPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DRW_Trace::applyExtrusion(){
|
void DRW_Trace::applyExtrusion()
|
||||||
if (haveExtrusion) {
|
{
|
||||||
|
if (haveExtrusion)
|
||||||
|
{
|
||||||
calculateAxis(extPoint);
|
calculateAxis(extPoint);
|
||||||
extrudePoint(extPoint, &basePoint);
|
extrudePoint(extPoint, &basePoint);
|
||||||
extrudePoint(extPoint, &secPoint);
|
extrudePoint(extPoint, &secPoint);
|
||||||
|
@ -425,7 +459,8 @@ void DRW_Trace::applyExtrusion(){
|
||||||
|
|
||||||
auto DRW_Trace::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Trace::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 12:
|
case 12:
|
||||||
thirdPoint.x = reader->getDouble();
|
thirdPoint.x = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -453,7 +488,8 @@ auto DRW_Trace::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_3Dface::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_3Dface::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 70:
|
case 70:
|
||||||
invisibleflag = reader->getInt32();
|
invisibleflag = reader->getInt32();
|
||||||
break;
|
break;
|
||||||
|
@ -466,7 +502,8 @@ auto DRW_3Dface::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Block::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Block::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 2:
|
case 2:
|
||||||
name = reader->getUtf8String();
|
name = reader->getUtf8String();
|
||||||
break;
|
break;
|
||||||
|
@ -482,7 +519,8 @@ auto DRW_Block::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Insert::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Insert::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 2:
|
case 2:
|
||||||
name = reader->getUtf8String();
|
name = reader->getUtf8String();
|
||||||
break;
|
break;
|
||||||
|
@ -497,7 +535,7 @@ auto DRW_Insert::parseCode(int code, dxfReader *reader) -> bool
|
||||||
break;
|
break;
|
||||||
case 50:
|
case 50:
|
||||||
angle = reader->getDouble();
|
angle = reader->getDouble();
|
||||||
angle = angle/ARAD; //convert to radian
|
angle = angle / ARAD; // convert to radian
|
||||||
break;
|
break;
|
||||||
case 70:
|
case 70:
|
||||||
colcount = reader->getInt32();
|
colcount = reader->getInt32();
|
||||||
|
@ -518,10 +556,13 @@ auto DRW_Insert::parseCode(int code, dxfReader *reader) -> bool
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DRW_LWPolyline::applyExtrusion(){
|
void DRW_LWPolyline::applyExtrusion()
|
||||||
if (haveExtrusion) {
|
{
|
||||||
|
if (haveExtrusion)
|
||||||
|
{
|
||||||
calculateAxis(extPoint);
|
calculateAxis(extPoint);
|
||||||
for (unsigned int i=0; i<vertlist.size(); i++) {
|
for (unsigned int i = 0; i < vertlist.size(); i++)
|
||||||
|
{
|
||||||
DRW_Vertex2D *vert = vertlist.at(i);
|
DRW_Vertex2D *vert = vertlist.at(i);
|
||||||
DRW_Coord v(vert->x, vert->y, elevation);
|
DRW_Coord v(vert->x, vert->y, elevation);
|
||||||
extrudePoint(extPoint, &v);
|
extrudePoint(extPoint, &v);
|
||||||
|
@ -533,26 +574,29 @@ void DRW_LWPolyline::applyExtrusion(){
|
||||||
|
|
||||||
auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
case 10: {
|
{
|
||||||
|
case 10:
|
||||||
|
{
|
||||||
vertex = new DRW_Vertex2D();
|
vertex = new DRW_Vertex2D();
|
||||||
vertlist.push_back(vertex);
|
vertlist.push_back(vertex);
|
||||||
vertex->x = reader->getDouble();
|
vertex->x = reader->getDouble();
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
case 20:
|
case 20:
|
||||||
if(vertex != NULL)
|
if (vertex != NULL)
|
||||||
vertex->y = reader->getDouble();
|
vertex->y = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 40:
|
case 40:
|
||||||
if(vertex != NULL)
|
if (vertex != NULL)
|
||||||
vertex->stawidth = reader->getDouble();
|
vertex->stawidth = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 41:
|
case 41:
|
||||||
if(vertex != NULL)
|
if (vertex != NULL)
|
||||||
vertex->endwidth = reader->getDouble();
|
vertex->endwidth = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 42:
|
case 42:
|
||||||
if(vertex != NULL)
|
if (vertex != NULL)
|
||||||
vertex->bulge = reader->getDouble();
|
vertex->bulge = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 38:
|
case 38:
|
||||||
|
@ -569,7 +613,7 @@ auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
|
||||||
break;
|
break;
|
||||||
case 90:
|
case 90:
|
||||||
vertexnum = reader->getInt32();
|
vertexnum = reader->getInt32();
|
||||||
return DRW::reserve( vertlist, vertexnum);
|
return DRW::reserve(vertlist, vertexnum);
|
||||||
case 210:
|
case 210:
|
||||||
haveExtrusion = true;
|
haveExtrusion = true;
|
||||||
extPoint.x = reader->getDouble();
|
extPoint.x = reader->getDouble();
|
||||||
|
@ -589,7 +633,8 @@ auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Text::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Text::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 40:
|
case 40:
|
||||||
height = reader->getDouble();
|
height = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -626,7 +671,8 @@ auto DRW_Text::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 1:
|
case 1:
|
||||||
text += reader->getString();
|
text += reader->getString();
|
||||||
text = reader->toUtf8String(text);
|
text = reader->toUtf8String(text);
|
||||||
|
@ -640,14 +686,16 @@ auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
|
||||||
case 44:
|
case 44:
|
||||||
interlin = reader->getDouble();
|
interlin = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 71: {
|
case 71:
|
||||||
|
{
|
||||||
// Attachment point
|
// Attachment point
|
||||||
Attach a = static_cast<Attach>(reader->getInt32());
|
Attach a = static_cast<Attach>(reader->getInt32());
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
|
|
||||||
switch(a) {
|
switch (a)
|
||||||
|
{
|
||||||
case TopLeft:
|
case TopLeft:
|
||||||
alignV = VTop;
|
alignV = VTop;
|
||||||
alignH = HLeft;
|
alignH = HLeft;
|
||||||
|
@ -687,7 +735,8 @@ auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case 72:
|
case 72:
|
||||||
// To prevent redirection to DRW_Text::parseCode.
|
// To prevent redirection to DRW_Text::parseCode.
|
||||||
// This code meaning is different for MTEXT.
|
// This code meaning is different for MTEXT.
|
||||||
|
@ -705,15 +754,18 @@ auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DRW_MText::updateAngle(){
|
void DRW_MText::updateAngle()
|
||||||
if (hasXAxisVec) {
|
{
|
||||||
angle = atan2(secPoint.y, secPoint.x)*180/M_PI;
|
if (hasXAxisVec)
|
||||||
|
{
|
||||||
|
angle = atan2(secPoint.y, secPoint.x) * 180 / M_PI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DRW_Polyline::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Polyline::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 70:
|
case 70:
|
||||||
flags = reader->getInt32();
|
flags = reader->getInt32();
|
||||||
break;
|
break;
|
||||||
|
@ -747,7 +799,8 @@ auto DRW_Polyline::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Vertex::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Vertex::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 70:
|
case 70:
|
||||||
flags = reader->getInt32();
|
flags = reader->getInt32();
|
||||||
break;
|
break;
|
||||||
|
@ -787,7 +840,8 @@ auto DRW_Vertex::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 2:
|
case 2:
|
||||||
name = reader->getUtf8String();
|
name = reader->getUtf8String();
|
||||||
break;
|
break;
|
||||||
|
@ -798,61 +852,87 @@ auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
|
||||||
associative = reader->getInt32();
|
associative = reader->getInt32();
|
||||||
break;
|
break;
|
||||||
case 72: /*edge type*/
|
case 72: /*edge type*/
|
||||||
if (ispol){ //if is polyline is a as_bulge flag
|
if (ispol)
|
||||||
|
{ // if is polyline is a as_bulge flag
|
||||||
break;
|
break;
|
||||||
} else if (reader->getInt32() == 1){ //line
|
}
|
||||||
|
else if (reader->getInt32() == 1)
|
||||||
|
{ // line
|
||||||
addLine();
|
addLine();
|
||||||
} else if (reader->getInt32() == 2){ //arc
|
}
|
||||||
|
else if (reader->getInt32() == 2)
|
||||||
|
{ // arc
|
||||||
addArc();
|
addArc();
|
||||||
} else if (reader->getInt32() == 3){ //elliptic arc
|
}
|
||||||
|
else if (reader->getInt32() == 3)
|
||||||
|
{ // elliptic arc
|
||||||
addEllipse();
|
addEllipse();
|
||||||
} else if (reader->getInt32() == 4){ //spline
|
}
|
||||||
|
else if (reader->getInt32() == 4)
|
||||||
|
{ // spline
|
||||||
addSpline();
|
addSpline();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
if (pt) pt->basePoint.x = reader->getDouble();
|
if (pt)
|
||||||
else if (pline) {
|
pt->basePoint.x = reader->getDouble();
|
||||||
|
else if (pline)
|
||||||
|
{
|
||||||
plvert = pline->addVertex();
|
plvert = pline->addVertex();
|
||||||
plvert->x = reader->getDouble();
|
plvert->x = reader->getDouble();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 20:
|
case 20:
|
||||||
if (pt) pt->basePoint.y = reader->getDouble();
|
if (pt)
|
||||||
else if (plvert) plvert ->y = reader->getDouble();
|
pt->basePoint.y = reader->getDouble();
|
||||||
|
else if (plvert)
|
||||||
|
plvert->y = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
if (line) line->secPoint.x = reader->getDouble();
|
if (line)
|
||||||
else if (ellipse) ellipse->secPoint.x = reader->getDouble();
|
line->secPoint.x = reader->getDouble();
|
||||||
|
else if (ellipse)
|
||||||
|
ellipse->secPoint.x = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 21:
|
case 21:
|
||||||
if (line) line->secPoint.y = reader->getDouble();
|
if (line)
|
||||||
else if (ellipse) ellipse->secPoint.y = reader->getDouble();
|
line->secPoint.y = reader->getDouble();
|
||||||
|
else if (ellipse)
|
||||||
|
ellipse->secPoint.y = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 40:
|
case 40:
|
||||||
if (arc) arc->radious = reader->getDouble();
|
if (arc)
|
||||||
else if (ellipse) ellipse->ratio = reader->getDouble();
|
arc->radious = reader->getDouble();
|
||||||
|
else if (ellipse)
|
||||||
|
ellipse->ratio = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 41:
|
case 41:
|
||||||
scale = reader->getDouble();
|
scale = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 42:
|
case 42:
|
||||||
if (plvert) plvert ->bulge = reader->getDouble();
|
if (plvert)
|
||||||
|
plvert->bulge = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 50:
|
case 50:
|
||||||
if (arc) arc->staangle = reader->getDouble()/ARAD;
|
if (arc)
|
||||||
else if (ellipse) ellipse->staparam = reader->getDouble()/ARAD;
|
arc->staangle = reader->getDouble() / ARAD;
|
||||||
|
else if (ellipse)
|
||||||
|
ellipse->staparam = reader->getDouble() / ARAD;
|
||||||
break;
|
break;
|
||||||
case 51:
|
case 51:
|
||||||
if (arc) arc->endangle = reader->getDouble()/ARAD;
|
if (arc)
|
||||||
else if (ellipse) ellipse->endparam = reader->getDouble()/ARAD;
|
arc->endangle = reader->getDouble() / ARAD;
|
||||||
|
else if (ellipse)
|
||||||
|
ellipse->endparam = reader->getDouble() / ARAD;
|
||||||
break;
|
break;
|
||||||
case 52:
|
case 52:
|
||||||
angle = reader->getDouble();
|
angle = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 73:
|
case 73:
|
||||||
if (arc) arc->isccw = reader->getInt32();
|
if (arc)
|
||||||
else if (pline) pline->flags = reader->getInt32();
|
arc->isccw = reader->getInt32();
|
||||||
|
else if (pline)
|
||||||
|
pline->flags = reader->getInt32();
|
||||||
break;
|
break;
|
||||||
case 75:
|
case 75:
|
||||||
hstyle = reader->getInt32();
|
hstyle = reader->getInt32();
|
||||||
|
@ -868,22 +948,27 @@ auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
|
||||||
break;
|
break;
|
||||||
case 91:
|
case 91:
|
||||||
loopsnum = reader->getInt32();
|
loopsnum = reader->getInt32();
|
||||||
return DRW::reserve( looplist, loopsnum);
|
return DRW::reserve(looplist, loopsnum);
|
||||||
case 92:
|
case 92:
|
||||||
loop = new DRW_HatchLoop(reader->getInt32());
|
loop = new DRW_HatchLoop(reader->getInt32());
|
||||||
looplist.push_back(loop);
|
looplist.push_back(loop);
|
||||||
if (reader->getInt32() & 2) {
|
if (reader->getInt32() & 2)
|
||||||
|
{
|
||||||
ispol = true;
|
ispol = true;
|
||||||
clearEntities();
|
clearEntities();
|
||||||
pline = new DRW_LWPolyline;
|
pline = new DRW_LWPolyline;
|
||||||
loop->objlist.push_back(pline);
|
loop->objlist.push_back(pline);
|
||||||
} else ispol = false;
|
}
|
||||||
|
else
|
||||||
|
ispol = false;
|
||||||
break;
|
break;
|
||||||
case 93:
|
case 93:
|
||||||
if (pline) pline->vertexnum = reader->getInt32();
|
if (pline)
|
||||||
else if (loop) loop->numedges = reader->getInt32();//aqui reserve
|
pline->vertexnum = reader->getInt32();
|
||||||
|
else if (loop)
|
||||||
|
loop->numedges = reader->getInt32(); // aqui reserve
|
||||||
break;
|
break;
|
||||||
case 98: //seed points ??
|
case 98: // seed points ??
|
||||||
clearEntities();
|
clearEntities();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -895,7 +980,8 @@ auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 210:
|
case 210:
|
||||||
normalVec.x = reader->getDouble();
|
normalVec.x = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -947,30 +1033,34 @@ auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
|
||||||
case 44:
|
case 44:
|
||||||
tolfit = reader->getDouble();
|
tolfit = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 10: {
|
case 10:
|
||||||
|
{
|
||||||
controlpoint = new DRW_Coord();
|
controlpoint = new DRW_Coord();
|
||||||
controllist.push_back(controlpoint);
|
controllist.push_back(controlpoint);
|
||||||
controlpoint->x = reader->getDouble();
|
controlpoint->x = reader->getDouble();
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
case 20:
|
case 20:
|
||||||
if(controlpoint != NULL)
|
if (controlpoint != NULL)
|
||||||
controlpoint->y = reader->getDouble();
|
controlpoint->y = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 30:
|
case 30:
|
||||||
if(controlpoint != NULL)
|
if (controlpoint != NULL)
|
||||||
controlpoint->z = reader->getDouble();
|
controlpoint->z = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 11: {
|
case 11:
|
||||||
|
{
|
||||||
fitpoint = new DRW_Coord();
|
fitpoint = new DRW_Coord();
|
||||||
fitlist.push_back(fitpoint);
|
fitlist.push_back(fitpoint);
|
||||||
fitpoint->x = reader->getDouble();
|
fitpoint->x = reader->getDouble();
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
case 21:
|
case 21:
|
||||||
if(fitpoint != NULL)
|
if (fitpoint != NULL)
|
||||||
fitpoint->y = reader->getDouble();
|
fitpoint->y = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 31:
|
case 31:
|
||||||
if(fitpoint != NULL)
|
if (fitpoint != NULL)
|
||||||
fitpoint->z = reader->getDouble();
|
fitpoint->z = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 40:
|
case 40:
|
||||||
|
@ -988,7 +1078,8 @@ auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Image::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Image::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 12:
|
case 12:
|
||||||
vVector.x = reader->getDouble();
|
vVector.x = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -1028,7 +1119,8 @@ auto DRW_Image::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Dimension::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Dimension::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 1:
|
case 1:
|
||||||
text = reader->getUtf8String();
|
text = reader->getUtf8String();
|
||||||
break;
|
break;
|
||||||
|
@ -1150,7 +1242,8 @@ auto DRW_Dimension::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 3:
|
case 3:
|
||||||
style = reader->getUtf8String();
|
style = reader->getUtf8String();
|
||||||
break;
|
break;
|
||||||
|
@ -1181,17 +1274,19 @@ auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
|
||||||
case 41:
|
case 41:
|
||||||
textwidth = reader->getDouble();
|
textwidth = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 10: {
|
case 10:
|
||||||
|
{
|
||||||
vertexpoint = new DRW_Coord();
|
vertexpoint = new DRW_Coord();
|
||||||
vertexlist.push_back(vertexpoint);
|
vertexlist.push_back(vertexpoint);
|
||||||
vertexpoint->x = reader->getDouble();
|
vertexpoint->x = reader->getDouble();
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
case 20:
|
case 20:
|
||||||
if(vertexpoint != NULL)
|
if (vertexpoint != NULL)
|
||||||
vertexpoint->y = reader->getDouble();
|
vertexpoint->y = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 30:
|
case 30:
|
||||||
if(vertexpoint != NULL)
|
if (vertexpoint != NULL)
|
||||||
vertexpoint->z = reader->getDouble();
|
vertexpoint->z = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
case 340:
|
case 340:
|
||||||
|
@ -1242,7 +1337,8 @@ auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
|
||||||
|
|
||||||
auto DRW_Viewport::parseCode(int code, dxfReader *reader) -> bool
|
auto DRW_Viewport::parseCode(int code, dxfReader *reader) -> bool
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case 40:
|
case 40:
|
||||||
pswidth = reader->getDouble();
|
pswidth = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
@ -1255,9 +1351,11 @@ auto DRW_Viewport::parseCode(int code, dxfReader *reader) -> bool
|
||||||
case 69:
|
case 69:
|
||||||
vpID = reader->getInt32();
|
vpID = reader->getInt32();
|
||||||
break;
|
break;
|
||||||
case 12: {
|
case 12:
|
||||||
|
{
|
||||||
centerPX = reader->getDouble();
|
centerPX = reader->getDouble();
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
case 22:
|
case 22:
|
||||||
centerPY = reader->getDouble();
|
centerPY = reader->getDouble();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "drw_entities.h"
|
#include "drw_entities.h"
|
||||||
#include "drw_objects.h"
|
|
||||||
#include "drw_header.h"
|
#include "drw_header.h"
|
||||||
|
#include "drw_objects.h"
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
|
@ -34,27 +34,27 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods")
|
||||||
*
|
*
|
||||||
* @author Rallaz
|
* @author Rallaz
|
||||||
*/
|
*/
|
||||||
class DRW_Interface {
|
class DRW_Interface
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
DRW_Interface() {
|
DRW_Interface() {}
|
||||||
}
|
|
||||||
virtual ~DRW_Interface() = default;
|
virtual ~DRW_Interface() = default;
|
||||||
|
|
||||||
/** Called when header is parsed. */
|
/** Called when header is parsed. */
|
||||||
virtual void addHeader(const DRW_Header *) { }
|
virtual void addHeader(const DRW_Header *) {}
|
||||||
|
|
||||||
/** Called for every line Type. */
|
/** Called for every line Type. */
|
||||||
virtual void addLType(const DRW_LType &) { }
|
virtual void addLType(const DRW_LType &) {}
|
||||||
/** Called for every layer. */
|
/** Called for every layer. */
|
||||||
virtual void addLayer(const DRW_Layer &) { }
|
virtual void addLayer(const DRW_Layer &) {}
|
||||||
/** Called for every dim style. */
|
/** Called for every dim style. */
|
||||||
virtual void addDimStyle(const DRW_Dimstyle &) { }
|
virtual void addDimStyle(const DRW_Dimstyle &) {}
|
||||||
/** Called for every VPORT table. */
|
/** Called for every VPORT table. */
|
||||||
virtual void addVport(const DRW_Vport &) { }
|
virtual void addVport(const DRW_Vport &) {}
|
||||||
/** Called for every text style. */
|
/** Called for every text style. */
|
||||||
virtual void addTextStyle(const DRW_Textstyle &) { }
|
virtual void addTextStyle(const DRW_Textstyle &) {}
|
||||||
/** Called for every AppId entry. */
|
/** 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
|
* Called for every block. Note: all entities added after this
|
||||||
|
@ -62,143 +62,142 @@ public:
|
||||||
*
|
*
|
||||||
* @see endBlock()
|
* @see endBlock()
|
||||||
*/
|
*/
|
||||||
virtual void addBlock(const DRW_Block &) { }
|
virtual void addBlock(const DRW_Block &) {}
|
||||||
|
|
||||||
/** Called to end the current block */
|
/** Called to end the current block */
|
||||||
virtual void endBlock() { }
|
virtual void endBlock() {}
|
||||||
|
|
||||||
/** Called for every point */
|
/** Called for every point */
|
||||||
virtual void addPoint(const DRW_Point &) { }
|
virtual void addPoint(const DRW_Point &) {}
|
||||||
|
|
||||||
/** Called for every line */
|
/** Called for every line */
|
||||||
virtual void addLine(const DRW_Line &) { }
|
virtual void addLine(const DRW_Line &) {}
|
||||||
|
|
||||||
/** Called for every ray */
|
/** Called for every ray */
|
||||||
virtual void addRay(const DRW_Ray &) { }
|
virtual void addRay(const DRW_Ray &) {}
|
||||||
|
|
||||||
/** Called for every xline */
|
/** Called for every xline */
|
||||||
virtual void addXline(const DRW_Xline &) { }
|
virtual void addXline(const DRW_Xline &) {}
|
||||||
|
|
||||||
/** Called for every arc */
|
/** Called for every arc */
|
||||||
virtual void addArc(const DRW_Arc &) { }
|
virtual void addArc(const DRW_Arc &) {}
|
||||||
|
|
||||||
/** Called for every circle */
|
/** Called for every circle */
|
||||||
virtual void addCircle(const DRW_Circle &) { }
|
virtual void addCircle(const DRW_Circle &) {}
|
||||||
|
|
||||||
/** Called for every ellipse */
|
/** Called for every ellipse */
|
||||||
virtual void addEllipse(const DRW_Ellipse &) { }
|
virtual void addEllipse(const DRW_Ellipse &) {}
|
||||||
|
|
||||||
/** Called for every lwpolyline */
|
/** Called for every lwpolyline */
|
||||||
virtual void addLWPolyline(const DRW_LWPolyline &) { }
|
virtual void addLWPolyline(const DRW_LWPolyline &) {}
|
||||||
|
|
||||||
/** Called for every polyline start */
|
/** Called for every polyline start */
|
||||||
virtual void addPolyline(const DRW_Polyline &) { }
|
virtual void addPolyline(const DRW_Polyline &) {}
|
||||||
|
|
||||||
/** Called for every spline */
|
/** Called for every spline */
|
||||||
virtual void addSpline(const DRW_Spline *) { }
|
virtual void addSpline(const DRW_Spline *) {}
|
||||||
|
|
||||||
/** Called for every spline knot value */
|
/** Called for every spline knot value */
|
||||||
virtual void addKnot(const DRW_Entity &) { }
|
virtual void addKnot(const DRW_Entity &) {}
|
||||||
|
|
||||||
/** Called for every insert. */
|
/** Called for every insert. */
|
||||||
virtual void addInsert(const DRW_Insert &) { }
|
virtual void addInsert(const DRW_Insert &) {}
|
||||||
|
|
||||||
/** Called for every trace start */
|
/** Called for every trace start */
|
||||||
virtual void addTrace(const DRW_Trace &) { }
|
virtual void addTrace(const DRW_Trace &) {}
|
||||||
|
|
||||||
/** Called for every 3dface start */
|
/** Called for every 3dface start */
|
||||||
virtual void add3dFace(const DRW_3Dface &) { }
|
virtual void add3dFace(const DRW_3Dface &) {}
|
||||||
|
|
||||||
/** Called for every solid start */
|
/** Called for every solid start */
|
||||||
virtual void addSolid(const DRW_Solid &) { }
|
virtual void addSolid(const DRW_Solid &) {}
|
||||||
|
|
||||||
|
|
||||||
/** Called for every Multi Text entity. */
|
/** Called for every Multi Text entity. */
|
||||||
virtual void addMText(const DRW_MText &) { }
|
virtual void addMText(const DRW_MText &) {}
|
||||||
|
|
||||||
/** Called for every Text entity. */
|
/** Called for every Text entity. */
|
||||||
virtual void addText(const DRW_Text &) { }
|
virtual void addText(const DRW_Text &) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called for every aligned dimension entity.
|
* 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.
|
* 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.
|
* Called for every radial dimension entity.
|
||||||
*/
|
*/
|
||||||
virtual void addDimRadial(const DRW_DimRadial *) { }
|
virtual void addDimRadial(const DRW_DimRadial *) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called for every diametric dimension entity.
|
* 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.
|
* 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.
|
* 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.
|
* Called for every ordinate dimension entity.
|
||||||
*/
|
*/
|
||||||
virtual void addDimOrdinate(const DRW_DimOrdinate *) { }
|
virtual void addDimOrdinate(const DRW_DimOrdinate *) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called for every leader start.
|
* Called for every leader start.
|
||||||
*/
|
*/
|
||||||
virtual void addLeader(const DRW_Leader *) { }
|
virtual void addLeader(const DRW_Leader *) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called for every hatch entity.
|
* Called for every hatch entity.
|
||||||
*/
|
*/
|
||||||
virtual void addHatch(const DRW_Hatch *) { }
|
virtual void addHatch(const DRW_Hatch *) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called for every viewport entity.
|
* Called for every viewport entity.
|
||||||
*/
|
*/
|
||||||
virtual void addViewport(const DRW_Viewport &) { }
|
virtual void addViewport(const DRW_Viewport &) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called for every image entity.
|
* Called for every image entity.
|
||||||
*/
|
*/
|
||||||
virtual void addImage(const DRW_Image *) { }
|
virtual void addImage(const DRW_Image *) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called for every image definition.
|
* Called for every image definition.
|
||||||
*/
|
*/
|
||||||
virtual void linkImage(const DRW_ImageDef *) { }
|
virtual void linkImage(const DRW_ImageDef *) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called for every comment in the DXF file (code 999).
|
* 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.
|
* Called for PLOTSETTINGS object definition.
|
||||||
*/
|
*/
|
||||||
virtual void addPlotSettings(const DRW_PlotSettings *) {}
|
virtual void addPlotSettings(const DRW_PlotSettings *) {}
|
||||||
|
|
||||||
virtual void writeHeader(DRW_Header &) { }
|
virtual void writeHeader(DRW_Header &) {}
|
||||||
virtual void writeBlocks() { }
|
virtual void writeBlocks() {}
|
||||||
virtual void writeBlockRecords() { }
|
virtual void writeBlockRecords() {}
|
||||||
virtual void writeEntities() { }
|
virtual void writeEntities() {}
|
||||||
virtual void writeLTypes() { }
|
virtual void writeLTypes() {}
|
||||||
virtual void writeLayers() { }
|
virtual void writeLayers() {}
|
||||||
virtual void writeTextstyles() { }
|
virtual void writeTextstyles() {}
|
||||||
virtual void writeVports() { }
|
virtual void writeVports() {}
|
||||||
virtual void writeDimstyles() { }
|
virtual void writeDimstyles() {}
|
||||||
virtual void writeObjects() {}
|
virtual void writeObjects() {}
|
||||||
virtual void writeAppId() { }
|
virtual void writeAppId() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,17 +29,17 @@
|
||||||
#ifndef VABSTRACTPIECE_H
|
#ifndef VABSTRACTPIECE_H
|
||||||
#define VABSTRACTPIECE_H
|
#define VABSTRACTPIECE_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QSharedDataPointer>
|
|
||||||
#include <QPointF>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
#include <QPointF>
|
||||||
|
#include <QSharedDataPointer>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "../vmisc/compatibility.h"
|
|
||||||
#include "../vgeometry/vgobject.h"
|
#include "../vgeometry/vgobject.h"
|
||||||
#include "vsapoint.h"
|
#include "../vmisc/compatibility.h"
|
||||||
#include "vrawsapoint.h"
|
#include "vrawsapoint.h"
|
||||||
|
#include "vsapoint.h"
|
||||||
|
|
||||||
class VAbstractPieceData;
|
class VAbstractPieceData;
|
||||||
class QPainterPath;
|
class QPainterPath;
|
||||||
|
@ -48,11 +48,12 @@ class VContainer;
|
||||||
class VRawSAPoint;
|
class VRawSAPoint;
|
||||||
class VLayoutPlaceLabel;
|
class VLayoutPlaceLabel;
|
||||||
|
|
||||||
using PlaceLabelImg = QVector<QVector<VLayoutPoint> >;
|
using PlaceLabelImg = QVector<QVector<VLayoutPoint>>;
|
||||||
|
|
||||||
class VAbstractPiece
|
class VAbstractPiece
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(VAbstractPiece) // NOLINT
|
Q_DECLARE_TR_FUNCTIONS(VAbstractPiece) // NOLINT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VAbstractPiece();
|
VAbstractPiece();
|
||||||
VAbstractPiece(const VAbstractPiece &piece);
|
VAbstractPiece(const VAbstractPiece &piece);
|
||||||
|
@ -109,28 +110,27 @@ public:
|
||||||
|
|
||||||
static auto Equidistant(QVector<VSAPoint> points, qreal width, const QString &name) -> QVector<VLayoutPoint>;
|
static auto Equidistant(QVector<VSAPoint> points, qreal width, const QString &name) -> QVector<VLayoutPoint>;
|
||||||
static auto SumTrapezoids(const QVector<QPointF> &points) -> qreal;
|
static auto SumTrapezoids(const QVector<QPointF> &points) -> qreal;
|
||||||
template <class T>
|
template <class T> static auto CheckLoops(QVector<T> points) -> QVector<T>;
|
||||||
static auto CheckLoops(QVector<T> points) -> QVector<T>;
|
|
||||||
static auto EkvPoint(QVector<VRawSAPoint> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1,
|
static auto EkvPoint(QVector<VRawSAPoint> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1,
|
||||||
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width,
|
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width, bool *needRollback = nullptr)
|
||||||
bool *needRollback = nullptr) -> QVector<VRawSAPoint>;
|
-> QVector<VRawSAPoint>;
|
||||||
static auto ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width) -> QLineF;
|
static auto ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width) -> QLineF;
|
||||||
static auto IsAllowanceValid(const QVector<QPointF> &base, const QVector<QPointF> &allowance) -> bool;
|
static auto IsAllowanceValid(const QVector<QPointF> &base, const QVector<QPointF> &allowance) -> bool;
|
||||||
template <class T>
|
template <class T>
|
||||||
static auto IsInsidePolygon(const QVector<T> &path, const QVector<T> &polygon,
|
static auto IsInsidePolygon(const QVector<T> &path, const QVector<T> &polygon, qreal accuracy = accuracyPointOnLine)
|
||||||
qreal accuracy = accuracyPointOnLine) -> bool;
|
-> bool;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static auto CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast = true) -> QVector<T>;
|
static auto CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast = true) -> QVector<T>;
|
||||||
|
|
||||||
static auto RollbackSeamAllowance(QVector<VRawSAPoint> points, const QLineF &cuttingEdge,
|
static auto RollbackSeamAllowance(QVector<VRawSAPoint> points, const QLineF &cuttingEdge, bool *success)
|
||||||
bool *success) -> QVector<VRawSAPoint>;
|
-> QVector<VRawSAPoint>;
|
||||||
|
|
||||||
static auto GrainlineMainLine(const VGrainlineData &geom, const VContainer *pattern,
|
static auto GrainlineMainLine(const VGrainlineData &geom, const VContainer *pattern, const QRectF &boundingRect)
|
||||||
const QRectF &boundingRect) -> QLineF;
|
-> QLineF;
|
||||||
|
|
||||||
friend auto operator<< (QDataStream& dataStream, const VAbstractPiece& piece) -> QDataStream&;
|
friend auto operator<<(QDataStream &dataStream, const VAbstractPiece &piece) -> QDataStream &;
|
||||||
friend auto operator>> (QDataStream& dataStream, VAbstractPiece& piece) -> QDataStream&;
|
friend auto operator>>(QDataStream &dataStream, VAbstractPiece &piece) -> QDataStream &;
|
||||||
|
|
||||||
static auto PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLabelImg;
|
static auto PlaceLabelShape(const VLayoutPlaceLabel &label) -> PlaceLabelImg;
|
||||||
static auto LabelShapePath(const VLayoutPlaceLabel &label) -> QPainterPath;
|
static auto LabelShapePath(const VLayoutPlaceLabel &label) -> QPainterPath;
|
||||||
|
@ -144,19 +144,17 @@ protected:
|
||||||
template <class T>
|
template <class T>
|
||||||
static auto CheckPointOnLine(QVector<T> &points, const T &iPoint, const T &prevPoint, const T &nextPoint) -> bool;
|
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,
|
static auto IsItemContained(const QRectF &parentBoundingRect, const QVector<QPointF> &shape, qreal &dX, qreal &dY)
|
||||||
qreal &dY) -> bool;
|
-> bool;
|
||||||
static auto CorrectPosition(const QRectF &parentBoundingRect, QVector<QPointF> points) -> QVector<QPointF>;
|
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;
|
qreal &rotationAngle, QPointF &pos) -> bool;
|
||||||
template <class T>
|
template <class T> static auto ComparePoints(QVector<T> &points, const T &p1, const T &p2, qreal accuracy) -> bool;
|
||||||
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>
|
template <class T> static auto CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<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>
|
template <class T>
|
||||||
static auto IntersectionPoint(QPointF crosPoint, const T &l1p1, const T &l1p2, const T &l2p1, const T &l2p2) -> T;
|
static auto IntersectionPoint(QPointF crosPoint, const T &l1p1, const T &l1p2, const T &l2p1, const T &l2p2) -> T;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VAbstractPieceData> d;
|
QSharedDataPointer<VAbstractPieceData> d;
|
||||||
};
|
};
|
||||||
|
@ -210,17 +208,17 @@ inline auto VAbstractPiece::CheckPointOnLine<QPointF>(QVector<QPointF> &points,
|
||||||
template <class T>
|
template <class T>
|
||||||
inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast) -> QVector<T>
|
inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast) -> 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 (points.size()<4)//Better don't check if only three points. We can destroy equidistant.
|
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;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clear equivalent points
|
// Clear equivalent points
|
||||||
QVector<T> buf1 = RemoveDublicates(points, removeFirstAndLast);
|
QVector<T> buf1 = RemoveDublicates(points, removeFirstAndLast);
|
||||||
|
|
||||||
if (buf1.size()<3)
|
if (buf1.size() < 3)
|
||||||
{
|
{
|
||||||
return buf1;
|
return buf1;
|
||||||
}
|
}
|
||||||
|
@ -229,9 +227,9 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, b
|
||||||
vsizetype next = -1;
|
vsizetype next = -1;
|
||||||
|
|
||||||
QVector<T> buf2;
|
QVector<T> buf2;
|
||||||
//Remove point on line
|
// Remove point on line
|
||||||
for (qint32 i = 0; i < buf1.size(); ++i)
|
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.
|
{ // 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.
|
// Unfortunatelly QLineF::intersect can't be used in this case because of the floating-point accuraccy problem.
|
||||||
if (prev == -1)
|
if (prev == -1)
|
||||||
{
|
{
|
||||||
|
@ -247,7 +245,7 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, b
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prev = i-1;
|
prev = i - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +261,7 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, b
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
next = i+1;
|
next = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const T &iPoint = buf1.at(i);
|
const T &iPoint = buf1.at(i);
|
||||||
|
@ -283,7 +281,7 @@ inline auto VAbstractPiece::CorrectEquidistantPoints(const QVector<T> &points, b
|
||||||
|
|
||||||
buf2 = RemoveDublicates(buf2, false);
|
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;
|
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 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))
|
if (not ComparePoints(p, points.at(i), points.at(j), accuracy))
|
||||||
{
|
{
|
||||||
i = j-1;
|
i = j - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,16 +401,15 @@ inline auto VAbstractPiece::ComparePoints<QPointF>(QVector<QPointF> &points, con
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class T>
|
template <class T> inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void
|
||||||
inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void
|
|
||||||
{
|
{
|
||||||
if (points.isEmpty())
|
if (points.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const T& first = ConstFirst(points);
|
const T &first = ConstFirst(points);
|
||||||
const T& last = ConstLast(points);
|
const T &last = ConstLast(points);
|
||||||
|
|
||||||
qreal testAccuracy = accuracy;
|
qreal testAccuracy = accuracy;
|
||||||
if (last.TurnPoint())
|
if (last.TurnPoint())
|
||||||
|
@ -437,16 +434,15 @@ inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <>
|
template <> inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<VRawSAPoint> &points, qreal accuracy) -> void
|
||||||
inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<VRawSAPoint> &points, qreal accuracy) -> void
|
|
||||||
{
|
{
|
||||||
if (points.isEmpty())
|
if (points.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VRawSAPoint& first = ConstFirst(points);
|
const VRawSAPoint &first = ConstFirst(points);
|
||||||
const VRawSAPoint& last = ConstLast(points);
|
const VRawSAPoint &last = ConstLast(points);
|
||||||
|
|
||||||
qreal testAccuracy = accuracy;
|
qreal testAccuracy = accuracy;
|
||||||
if ((first.Primary() && last.Primary()) || last.TurnPoint())
|
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)
|
for (auto i = 0; i < path.count(); ++i)
|
||||||
{
|
{
|
||||||
int nextI = -1;
|
int nextI = -1;
|
||||||
if (i < path.count()-1)
|
if (i < path.count() - 1)
|
||||||
{
|
{
|
||||||
nextI = i + 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)
|
for (auto j = 0; j < polygon.count(); ++j)
|
||||||
{
|
{
|
||||||
int nextJ = -1;
|
int nextJ = -1;
|
||||||
if (j < polygon.count()-1)
|
if (j < polygon.count() - 1)
|
||||||
{
|
{
|
||||||
nextJ = j + 1;
|
nextJ = j + 1;
|
||||||
}
|
}
|
||||||
|
@ -529,13 +525,11 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVecto
|
||||||
QPointF crosPoint;
|
QPointF crosPoint;
|
||||||
const auto type = Intersects(baseSegment, allowanceSegment, &crosPoint);
|
const auto type = Intersects(baseSegment, allowanceSegment, &crosPoint);
|
||||||
|
|
||||||
if (type == QLineF::BoundedIntersection
|
if (type == QLineF::BoundedIntersection && not VFuzzyComparePoints(baseSegment.p1(), crosPoint, accuracy) &&
|
||||||
&& not VFuzzyComparePoints(baseSegment.p1(), crosPoint, accuracy)
|
not VFuzzyComparePoints(baseSegment.p2(), crosPoint, accuracy) &&
|
||||||
&& not VFuzzyComparePoints(baseSegment.p2(), crosPoint, accuracy)
|
not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2(),
|
||||||
&& not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2(),
|
accuracy) &&
|
||||||
accuracy)
|
not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2(), accuracy))
|
||||||
&& not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2(),
|
|
||||||
accuracy))
|
|
||||||
{
|
{
|
||||||
return false;
|
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.
|
// Just instersection edges is not enough. The base must be inside of the allowance.
|
||||||
QPolygonF allowancePolygon(polygon);
|
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); });
|
{ 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.
|
* @param points vector of points of equidistant.
|
||||||
* @return vector of points of equidistant.
|
* @return vector of points of equidistant.
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T> inline auto VAbstractPiece::CheckLoops(QVector<T> points) -> QVector<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 we got less than 4 points no need seek loops.*/
|
||||||
if (points.size() < 4)
|
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;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template<class T>
|
template <class T> inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>
|
||||||
inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>
|
|
||||||
{
|
{
|
||||||
loopFound = false;
|
loopFound = false;
|
||||||
|
|
||||||
|
@ -598,23 +591,28 @@ inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound)
|
||||||
{
|
{
|
||||||
/*Last three points no need to check.*/
|
/*Last three points no need to check.*/
|
||||||
/*Triangle can not contain a loop*/
|
/*Triangle can not contain a loop*/
|
||||||
if (loopFound || i > points.size()-4)
|
if (loopFound || i > points.size() - 4)
|
||||||
{
|
{
|
||||||
ekvPoints.append(points.at(i));
|
ekvPoints.append(points.at(i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum LoopIntersectType { NoIntersection, BoundedIntersection, ParallelIntersection };
|
enum LoopIntersectType
|
||||||
|
{
|
||||||
|
NoIntersection,
|
||||||
|
BoundedIntersection,
|
||||||
|
ParallelIntersection
|
||||||
|
};
|
||||||
|
|
||||||
QPointF crosPoint;
|
QPointF crosPoint;
|
||||||
LoopIntersectType status = NoIntersection;
|
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;
|
const int limit = pathClosed && i == 0 ? 2 : 1;
|
||||||
qint32 j;
|
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);
|
const QLineF::IntersectType intersect = Intersects(line1, line2, &crosPoint);
|
||||||
if (intersect == QLineF::NoIntersection)
|
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.
|
// i.e. they are parallel. But parallel also mean they can be on the same line.
|
||||||
// Method IsLineSegmentOnLineSegment will check it.
|
// Method IsLineSegmentOnLineSegment will check it.
|
||||||
if (VGObject::IsLineSegmentOnLineSegment(line1, line2))
|
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;
|
status = ParallelIntersection;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -639,13 +637,14 @@ inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound)
|
||||||
case ParallelIntersection:
|
case ParallelIntersection:
|
||||||
/*We have found a loop.*/
|
/*We have found a loop.*/
|
||||||
ekvPoints.append(points.at(i));
|
ekvPoints.append(points.at(i));
|
||||||
ekvPoints.append(points.at(j+1));
|
ekvPoints.append(points.at(j + 1));
|
||||||
i = j+1; // Skip a loop
|
i = j + 1; // Skip a loop
|
||||||
loopFound = true;
|
loopFound = true;
|
||||||
break;
|
break;
|
||||||
case BoundedIntersection:
|
case BoundedIntersection:
|
||||||
ekvPoints.append(points.at(i));
|
ekvPoints.append(points.at(i));
|
||||||
ekvPoints.append(IntersectionPoint(crosPoint, points.at(i), points.at(i+1), points.at(j), points.at(j+1)));
|
ekvPoints.append(
|
||||||
|
IntersectionPoint(crosPoint, points.at(i), points.at(i + 1), points.at(j), points.at(j + 1)));
|
||||||
i = j;
|
i = j;
|
||||||
loopFound = true;
|
loopFound = true;
|
||||||
break;
|
break;
|
||||||
|
@ -661,7 +660,7 @@ inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template<class T>
|
template <class T>
|
||||||
inline auto VAbstractPiece::IntersectionPoint(QPointF crosPoint, const T &l1p1, const T &l1p2, const T &l2p1,
|
inline auto VAbstractPiece::IntersectionPoint(QPointF crosPoint, const T &l1p1, const T &l1p2, const T &l2p1,
|
||||||
const T &l2p2) -> T
|
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*/,
|
inline auto VAbstractPiece::IntersectionPoint<QPointF>(QPointF crosPoint, const QPointF & /*unused*/,
|
||||||
const QPointF & /*unused*/, const QPointF & /*unused*/,
|
const QPointF & /*unused*/, const QPointF & /*unused*/,
|
||||||
const QPointF & /*unused*/) -> QPointF
|
const QPointF & /*unused*/) -> QPointF
|
||||||
|
|
|
@ -33,12 +33,11 @@
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QThreadPool>
|
#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 "../ifc/exception/vexceptionterminatedposition.h"
|
||||||
|
#include "../vmisc/compatibility.h"
|
||||||
|
#include "../vmisc/def.h"
|
||||||
|
#include "vlayoutpaper.h"
|
||||||
|
#include "vlayoutpiece.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VLayoutGenerator::VLayoutGenerator(QObject *parent)
|
VLayoutGenerator::VLayoutGenerator(QObject *parent)
|
||||||
|
@ -68,7 +67,8 @@ VLayoutGenerator::VLayoutGenerator(QObject *parent)
|
||||||
multiplier(1),
|
multiplier(1),
|
||||||
stripOptimization(false),
|
stripOptimization(false),
|
||||||
textAsPaths(false)
|
textAsPaths(false)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VLayoutGenerator::~VLayoutGenerator()
|
VLayoutGenerator::~VLayoutGenerator()
|
||||||
|
@ -149,10 +149,10 @@ void VLayoutGenerator::Generate(const QElapsedTimer &timer, qint64 timeout, Layo
|
||||||
|
|
||||||
auto SetStrip = [this, b](int &side)
|
auto SetStrip = [this, b](int &side)
|
||||||
{
|
{
|
||||||
if (side >= b*2)
|
if (side >= b * 2)
|
||||||
{
|
{
|
||||||
stripOptimizationEnabled = true;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
} while(bank->LeftToArrange() > 0);
|
} while (bank->LeftToArrange() > 0);
|
||||||
|
|
||||||
if (stopGeneration.load())
|
if (stopGeneration.load())
|
||||||
{
|
{
|
||||||
|
@ -329,7 +329,7 @@ auto VLayoutGenerator::GetGlobalContours() const -> QList<QGraphicsItem *>
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VLayoutGenerator::GetAllDetailsItems() const -> QList<QList<QGraphicsItem *>>
|
auto VLayoutGenerator::GetAllDetailsItems() const -> QList<QList<QGraphicsItem *>>
|
||||||
{
|
{
|
||||||
QList<QList<QGraphicsItem *> > list;
|
QList<QList<QGraphicsItem *>> list;
|
||||||
list.reserve(papers.count());
|
list.reserve(papers.count());
|
||||||
for (const auto &paper : papers)
|
for (const auto &paper : papers)
|
||||||
{
|
{
|
||||||
|
@ -341,7 +341,7 @@ auto VLayoutGenerator::GetAllDetailsItems() const -> QList<QList<QGraphicsItem *
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VLayoutGenerator::GetAllDetails() const -> QVector<QVector<VLayoutPiece>>
|
auto VLayoutGenerator::GetAllDetails() const -> QVector<QVector<VLayoutPiece>>
|
||||||
{
|
{
|
||||||
QVector<QVector<VLayoutPiece> > list;
|
QVector<QVector<VLayoutPiece>> list;
|
||||||
list.reserve(papers.count());
|
list.reserve(papers.count());
|
||||||
for (const auto &paper : papers)
|
for (const auto &paper : papers)
|
||||||
{
|
{
|
||||||
|
@ -459,9 +459,9 @@ void VLayoutGenerator::GatherPages()
|
||||||
{
|
{
|
||||||
int paperHeight = qRound(rec.y() + rec.height());
|
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())
|
if (length + paperHeight <= PageHeight())
|
||||||
|
@ -472,7 +472,7 @@ void VLayoutGenerator::GatherPages()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length = 0; // Start new paper
|
length = 0; // Start new paper
|
||||||
++j;// New paper
|
++j; // New paper
|
||||||
UniteDetails(j, nDetails, length, i);
|
UniteDetails(j, nDetails, length, i);
|
||||||
length += paperHeight;
|
length += paperHeight;
|
||||||
}
|
}
|
||||||
|
@ -481,9 +481,9 @@ void VLayoutGenerator::GatherPages()
|
||||||
{
|
{
|
||||||
int paperWidth = qRound(rec.x() + rec.width());
|
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())
|
if (length + paperWidth <= PageWidth())
|
||||||
|
@ -494,7 +494,7 @@ void VLayoutGenerator::GatherPages()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length = 0; // Start new paper
|
length = 0; // Start new paper
|
||||||
++j;// New paper
|
++j; // New paper
|
||||||
UniteDetails(j, nDetails, length, i);
|
UniteDetails(j, nDetails, length, i);
|
||||||
length += paperWidth;
|
length += paperWidth;
|
||||||
}
|
}
|
||||||
|
@ -534,7 +534,7 @@ void VLayoutGenerator::OptimizeWidth()
|
||||||
newDetails.reserve(details.size());
|
newDetails.reserve(details.size());
|
||||||
for (auto &d : details)
|
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);
|
newDetails.append(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +551,7 @@ void VLayoutGenerator::UnitePages()
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<qreal> papersLength;
|
QList<qreal> papersLength;
|
||||||
QList<QList<VLayoutPiece> > nDetails;
|
QList<QList<VLayoutPiece>> nDetails;
|
||||||
qreal length = 0;
|
qreal length = 0;
|
||||||
int j = 0; // papers count
|
int j = 0; // papers count
|
||||||
|
|
||||||
|
@ -570,9 +570,9 @@ void VLayoutGenerator::UnitePages()
|
||||||
paperHeight = papers.at(i).GetHeight();
|
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)
|
if (length + paperHeight <= QIMAGE_MAX)
|
||||||
|
@ -584,7 +584,7 @@ void VLayoutGenerator::UnitePages()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length = 0; // Start new paper
|
length = 0; // Start new paper
|
||||||
++j;// New paper
|
++j; // New paper
|
||||||
UniteDetails(j, nDetails, length, i);
|
UniteDetails(j, nDetails, length, i);
|
||||||
length += paperHeight;
|
length += paperHeight;
|
||||||
UnitePapers(j, papersLength, length);
|
UnitePapers(j, papersLength, length);
|
||||||
|
@ -603,9 +603,9 @@ void VLayoutGenerator::UnitePages()
|
||||||
paperWidth = papers.at(i).GetWidth();
|
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)
|
if (length + paperWidth <= QIMAGE_MAX)
|
||||||
|
@ -617,7 +617,7 @@ void VLayoutGenerator::UnitePages()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length = 0; // Start new paper
|
length = 0; // Start new paper
|
||||||
++j;// New paper
|
++j; // New paper
|
||||||
UniteDetails(j, nDetails, length, i);
|
UniteDetails(j, nDetails, length, i);
|
||||||
length += paperWidth;
|
length += paperWidth;
|
||||||
UnitePapers(j, papersLength, length);
|
UnitePapers(j, papersLength, length);
|
||||||
|
@ -629,8 +629,8 @@ void VLayoutGenerator::UnitePages()
|
||||||
nPapers.reserve(nDetails.size());
|
nPapers.reserve(nDetails.size());
|
||||||
for (int i = 0; i < nDetails.size(); ++i)
|
for (int i = 0; i < nDetails.size(); ++i)
|
||||||
{
|
{
|
||||||
const int height = IsPortrait() ? qRound(papersLength.at(i)+accuracyPointOnLine*4) : PageHeight();
|
const int height = IsPortrait() ? qRound(papersLength.at(i) + accuracyPointOnLine * 4) : PageHeight();
|
||||||
const int width = IsPortrait() ? PageWidth() : qRound(papersLength.at(i)+accuracyPointOnLine*4);
|
const int width = IsPortrait() ? PageWidth() : qRound(papersLength.at(i) + accuracyPointOnLine * 4);
|
||||||
|
|
||||||
VLayoutPaper paper(height, width, bank->GetLayoutWidth());
|
VLayoutPaper paper(height, width, bank->GetLayoutWidth());
|
||||||
paper.SetShift(shift);
|
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())
|
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()));
|
nDetails.insert(j, MoveDetails(length, papers.at(i).GetDetails()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -708,7 +708,7 @@ auto VLayoutGenerator::MasterPage() const -> VLayoutPaper
|
||||||
return ConstFirst(papers);
|
return ConstFirst(papers);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QList<VLayoutPiece> > nDetails;
|
QList<QList<VLayoutPiece>> nDetails;
|
||||||
qreal length = 0;
|
qreal length = 0;
|
||||||
const int j = 0; // papers count. Always 1.
|
const int j = 0; // papers count. Always 1.
|
||||||
|
|
||||||
|
@ -727,9 +727,9 @@ auto VLayoutGenerator::MasterPage() const -> VLayoutPaper
|
||||||
paperHeight = papers.at(i).GetHeight();
|
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);
|
UniteDetails(j, nDetails, length, i);
|
||||||
|
@ -748,9 +748,9 @@ auto VLayoutGenerator::MasterPage() const -> VLayoutPaper
|
||||||
paperWidth = papers.at(i).GetWidth();
|
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);
|
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 height = IsPortrait() ? qRound(length + accuracyPointOnLine * 4) : PageHeight();
|
||||||
const int width = IsPortrait() ? PageWidth() : qRound(length+accuracyPointOnLine*4);
|
const int width = IsPortrait() ? PageWidth() : qRound(length + accuracyPointOnLine * 4);
|
||||||
|
|
||||||
VLayoutPaper paper(height, width, bank->GetLayoutWidth());
|
VLayoutPaper paper(height, width, bank->GetLayoutWidth());
|
||||||
paper.SetShift(shift);
|
paper.SetShift(shift);
|
||||||
|
|
|
@ -28,10 +28,10 @@
|
||||||
#ifndef VLAYOUTPOINT_H
|
#ifndef VLAYOUTPOINT_H
|
||||||
#define VLAYOUTPOINT_H
|
#define VLAYOUTPOINT_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QPointF>
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
#include <QPointF>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
|
@ -66,16 +66,15 @@ Q_DECLARE_METATYPE(VLayoutPoint) // NOLINT
|
||||||
Q_DECLARE_TYPEINFO(VLayoutPoint, Q_MOVABLE_TYPE); // NOLINT
|
Q_DECLARE_TYPEINFO(VLayoutPoint, Q_MOVABLE_TYPE); // NOLINT
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template <class T>
|
template <class T> inline auto CastTo(const QVector<T> &points, QVector<T> &casted) -> void
|
||||||
inline auto CastTo(const QVector<T> &points, QVector<T> &casted) -> void
|
|
||||||
{
|
{
|
||||||
Q_UNUSED(points)
|
Q_UNUSED(points)
|
||||||
Q_UNUSED(casted)
|
Q_UNUSED(casted)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
//upcast
|
// upcast
|
||||||
template <class Derived, class Base, typename std::enable_if<std::is_base_of<Base, Derived>::value>::type* = nullptr>
|
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
|
inline auto CastTo(const QVector<Base> &points, QVector<Derived> &casted) -> void
|
||||||
{
|
{
|
||||||
casted.clear();
|
casted.clear();
|
||||||
|
@ -87,8 +86,8 @@ inline auto CastTo(const QVector<Base> &points, QVector<Derived> &casted) -> voi
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
//downcast
|
// downcast
|
||||||
template <class Base, class Derived, typename std::enable_if<std::is_base_of<Base, Derived>::value>::type* = nullptr>
|
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
|
inline auto CastTo(const QVector<Derived> &points, QVector<Base> &casted) -> void
|
||||||
{
|
{
|
||||||
casted.clear();
|
casted.clear();
|
||||||
|
@ -110,12 +109,14 @@ auto operator>>(QDataStream &, VLayoutPoint &) -> QDataStream &;
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline VLayoutPoint::VLayoutPoint(qreal xpos, qreal ypos)
|
Q_DECL_CONSTEXPR inline VLayoutPoint::VLayoutPoint(qreal xpos, qreal ypos)
|
||||||
: QPointF(xpos, ypos)
|
: QPointF(xpos, ypos)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline VLayoutPoint::VLayoutPoint(QPointF p)
|
Q_DECL_CONSTEXPR inline VLayoutPoint::VLayoutPoint(QPointF p)
|
||||||
: QPointF(p)
|
: QPointF(p)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline auto VLayoutPoint::TurnPoint() const -> bool
|
Q_DECL_CONSTEXPR inline auto VLayoutPoint::TurnPoint() const -> bool
|
||||||
|
|
|
@ -27,31 +27,30 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
#include "vprintlayout.h"
|
#include "vprintlayout.h"
|
||||||
|
|
||||||
#include <QPrinterInfo>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QSpacerItem>
|
|
||||||
#include <QGridLayout>
|
|
||||||
#include <QPrintDialog>
|
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
#include <QGraphicsRectItem>
|
#include <QGraphicsRectItem>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QPageSize>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include <QGraphicsScene>
|
#include <QPrintDialog>
|
||||||
#include <QPrintPreviewDialog>
|
#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 "../vmisc/vabstractvalapplication.h"
|
||||||
|
#include "../vpropertyexplorer/checkablemessagebox.h"
|
||||||
|
#include "dialogs/dialoglayoutscale.h"
|
||||||
#include "dialogs/vabstractlayoutdialog.h"
|
#include "dialogs/vabstractlayoutdialog.h"
|
||||||
#include "vposter.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
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -59,9 +58,7 @@ namespace
|
||||||
auto FindPageSizeId(QSizeF size) -> QPageSize::PageSizeId
|
auto FindPageSizeId(QSizeF size) -> QPageSize::PageSizeId
|
||||||
{
|
{
|
||||||
auto TestSize = [size](float width, float height)
|
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 A0Width = 841;
|
||||||
constexpr int A0Height = 1189;
|
constexpr int A0Height = 1189;
|
||||||
|
@ -116,15 +113,15 @@ auto FindPageSizeId(QSizeF size) -> QPageSize::PageSizeId
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_REQUIRED_RESULT auto PreparePrinter(
|
Q_REQUIRED_RESULT auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode = QPrinter::ScreenResolution)
|
||||||
const QPrinterInfo &info, QPrinter::PrinterMode mode = QPrinter::ScreenResolution) -> QSharedPointer<QPrinter>;
|
-> QSharedPointer<QPrinter>;
|
||||||
auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSharedPointer<QPrinter>
|
auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSharedPointer<QPrinter>
|
||||||
{
|
{
|
||||||
QPrinterInfo tmpInfo = info;
|
QPrinterInfo tmpInfo = info;
|
||||||
if(tmpInfo.isNull() || tmpInfo.printerName().isEmpty())
|
if (tmpInfo.isNull() || tmpInfo.printerName().isEmpty())
|
||||||
{
|
{
|
||||||
const QStringList list = QPrinterInfo::availablePrinterNames();
|
const QStringList list = QPrinterInfo::availablePrinterNames();
|
||||||
if(list.isEmpty())
|
if (list.isEmpty())
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -141,7 +138,8 @@ auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSh
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPrintLayout::VPrintLayout(QObject *parent)
|
VPrintLayout::VPrintLayout(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPrintLayout::~VPrintLayout()
|
VPrintLayout::~VPrintLayout()
|
||||||
|
@ -161,7 +159,7 @@ void VPrintLayout::PrintOrigin()
|
||||||
{
|
{
|
||||||
if (not IsPagesUniform())
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +179,7 @@ void VPrintLayout::PrintPreviewOrigin()
|
||||||
{
|
{
|
||||||
if (not IsPagesUniform())
|
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;
|
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
|
// 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()))
|
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));
|
printer.setResolution(static_cast<int>(PrintDPI));
|
||||||
|
@ -235,7 +233,7 @@ void VPrintLayout::PrintLayout()
|
||||||
}
|
}
|
||||||
// display print dialog and if accepted print
|
// display print dialog and if accepted print
|
||||||
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
|
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
|
||||||
if(info.isNull() || info.printerName().isEmpty())
|
if (info.isNull() || info.printerName().isEmpty())
|
||||||
{
|
{
|
||||||
info = QPrinterInfo::defaultPrinter();
|
info = QPrinterInfo::defaultPrinter();
|
||||||
}
|
}
|
||||||
|
@ -280,7 +278,7 @@ void VPrintLayout::PrintPreview()
|
||||||
}
|
}
|
||||||
|
|
||||||
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
|
QPrinterInfo info = QPrinterInfo::printerInfo(m_layoutPrinterName);
|
||||||
if(info.isNull() || info.printerName().isEmpty())
|
if (info.isNull() || info.printerName().isEmpty())
|
||||||
{
|
{
|
||||||
info = QPrinterInfo::defaultPrinter();
|
info = QPrinterInfo::defaultPrinter();
|
||||||
}
|
}
|
||||||
|
@ -324,7 +322,7 @@ void VPrintLayout::PrintPages(QPrinter *printer)
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthMainLine(), Qt::SolidLine,
|
painter.setPen(QPen(Qt::black, VAbstractApplication::VApp()->Settings()->WidthMainLine(), Qt::SolidLine,
|
||||||
Qt::RoundCap, Qt::RoundJoin));
|
Qt::RoundCap, Qt::RoundJoin));
|
||||||
painter.setBrush ( QBrush ( Qt::NoBrush ) );
|
painter.setBrush(QBrush(Qt::NoBrush));
|
||||||
|
|
||||||
vsizetype count = 0;
|
vsizetype count = 0;
|
||||||
QSharedPointer<QVector<PosterData>> poster;
|
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
|
// when isTiled, the landscape tiles have to be rotated, because the pages
|
||||||
// stay portrait in the pdf
|
// stay portrait in the pdf
|
||||||
if(m_tiledPDFOrientation == PageOrientation::Landscape)
|
if (m_tiledPDFOrientation == PageOrientation::Landscape)
|
||||||
{
|
{
|
||||||
const int angle = -90;
|
const int angle = -90;
|
||||||
painter.rotate(angle);
|
painter.rotate(angle);
|
||||||
|
@ -344,7 +342,7 @@ void VPrintLayout::PrintPages(QPrinter *printer)
|
||||||
poster = QSharedPointer<QVector<PosterData>>(new QVector<PosterData>());
|
poster = QSharedPointer<QVector<PosterData>>(new QVector<PosterData>());
|
||||||
posterazor = QSharedPointer<VPoster>(new VPoster(printer));
|
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));
|
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(i));
|
||||||
if (paper != nullptr)
|
if (paper != nullptr)
|
||||||
|
@ -421,8 +419,8 @@ void VPrintLayout::PrintPages(QPrinter *printer)
|
||||||
if (m_isTiled)
|
if (m_isTiled)
|
||||||
{
|
{
|
||||||
// Draw tile
|
// Draw tile
|
||||||
posterData = posterazor->Tile(paper, poster->at(index), m_layoutScenes.size(), data,
|
posterData =
|
||||||
m_watermarkPath);
|
posterazor->Tile(paper, poster->at(index), m_layoutScenes.size(), data, m_watermarkPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
PreparePaper(paperIndex);
|
PreparePaper(paperIndex);
|
||||||
|
@ -431,8 +429,8 @@ void VPrintLayout::PrintPages(QPrinter *printer)
|
||||||
QRectF source;
|
QRectF source;
|
||||||
m_isTiled ? source = poster->at(index).rect : source = paper->rect();
|
m_isTiled ? source = poster->at(index).rect : source = paper->rect();
|
||||||
|
|
||||||
m_layoutScenes.at(paperIndex)->render(&painter, VPrintLayout::SceneTargetRect(printer, source), source,
|
m_layoutScenes.at(paperIndex)
|
||||||
Qt::IgnoreAspectRatio);
|
->render(&painter, VPrintLayout::SceneTargetRect(printer, source), source, Qt::IgnoreAspectRatio);
|
||||||
|
|
||||||
if (m_isTiled)
|
if (m_isTiled)
|
||||||
{
|
{
|
||||||
|
@ -475,12 +473,12 @@ void VPrintLayout::SetPrinterPrinterMargins(QPrinter *printer)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(m_tiledPDFOrientation == PageOrientation::Landscape)
|
if (m_tiledPDFOrientation == PageOrientation::Landscape)
|
||||||
{
|
{
|
||||||
// because when painting we have a -90rotation in landscape mode,
|
// because when painting we have a -90rotation in landscape mode,
|
||||||
// see function PrintPages.
|
// see function PrintPages.
|
||||||
printerMargins = QMarginsF(m_tiledMargins.bottom(), m_tiledMargins.left(), m_tiledMargins.top(),
|
printerMargins =
|
||||||
m_tiledMargins.right());
|
QMarginsF(m_tiledMargins.bottom(), m_tiledMargins.left(), m_tiledMargins.top(), m_tiledMargins.right());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -500,12 +498,12 @@ void VPrintLayout::SetPrinterOutputFileName(QPrinter *printer, PrintType printTy
|
||||||
{
|
{
|
||||||
SCASSERT(printer != nullptr)
|
SCASSERT(printer != nullptr)
|
||||||
|
|
||||||
switch(printType)
|
switch (printType)
|
||||||
{
|
{
|
||||||
case PrintType::PrintPDF:
|
case PrintType::PrintPDF:
|
||||||
{
|
{
|
||||||
const QString outputFileName = filePath.isEmpty() ? QDir::homePath() + QDir::separator() + DocName()
|
const QString outputFileName =
|
||||||
: filePath;
|
filePath.isEmpty() ? QDir::homePath() + QDir::separator() + DocName() : filePath;
|
||||||
printer->setOutputFileName(outputFileName + QStringLiteral(".pdf"));
|
printer->setOutputFileName(outputFileName + QStringLiteral(".pdf"));
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
@ -516,7 +514,7 @@ void VPrintLayout::SetPrinterOutputFileName(QPrinter *printer, PrintType printTy
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PrintType::PrintNative:
|
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);
|
printer->setOutputFormat(QPrinter::NativeFormat);
|
||||||
break;
|
break;
|
||||||
case PrintType::PrintPreview: /*do nothing*/
|
case PrintType::PrintPreview: /*do nothing*/
|
||||||
|
@ -542,13 +540,13 @@ void VPrintLayout::SetPrinterPageSize(QPrinter *printer)
|
||||||
{
|
{
|
||||||
if (m_isLayoutPortrait)
|
if (m_isLayoutPortrait)
|
||||||
{
|
{
|
||||||
height = FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(),
|
height =
|
||||||
Unit::Mm);
|
FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(), Unit::Mm);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
width = FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(),
|
width =
|
||||||
Unit::Mm);
|
FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(), Unit::Mm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -560,13 +558,13 @@ void VPrintLayout::SetPrinterPageSize(QPrinter *printer)
|
||||||
{
|
{
|
||||||
if (m_isLayoutPortrait)
|
if (m_isLayoutPortrait)
|
||||||
{
|
{
|
||||||
width = FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(),
|
width =
|
||||||
Unit::Mm);
|
FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(), Unit::Mm);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
height = FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(),
|
height =
|
||||||
Unit::Mm);
|
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_layoutScenes.at(index)->setBackgroundBrush(brush);
|
||||||
m_layoutShadows.at(index)->setVisible(false);
|
m_layoutShadows.at(index)->setVisible(false);
|
||||||
const float thinPen = 0.1F;
|
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;
|
QTransform matrix;
|
||||||
|
@ -648,7 +646,7 @@ void VPrintLayout::RestorePaper(vsizetype index) const
|
||||||
}
|
}
|
||||||
|
|
||||||
QTransform matrix;
|
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);
|
QList<QGraphicsItem *> paperDetails = m_layoutDetails.at(index);
|
||||||
for (auto *detail : paperDetails)
|
for (auto *detail : paperDetails)
|
||||||
|
@ -670,7 +668,8 @@ auto VPrintLayout::IsPagesUniform() const -> bool
|
||||||
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(0));
|
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(0));
|
||||||
SCASSERT(paper != nullptr)
|
SCASSERT(paper != nullptr)
|
||||||
|
|
||||||
return std::all_of(m_layoutPapers.begin(), m_layoutPapers.end(), [paper](QGraphicsItem *paperItem)
|
return std::all_of(m_layoutPapers.begin(), m_layoutPapers.end(),
|
||||||
|
[paper](QGraphicsItem *paperItem)
|
||||||
{
|
{
|
||||||
auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(paperItem);
|
auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(paperItem);
|
||||||
SCASSERT(p != nullptr)
|
SCASSERT(p != nullptr)
|
||||||
|
@ -711,8 +710,9 @@ auto VPrintLayout::WatermarkData() const -> VWatermarkData
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
const QString errorMsg = tr("File error.\n\n%1\n\n%2").arg(e.ErrorMessage(), e.DetailedInformation());
|
const QString errorMsg = tr("File error.\n\n%1\n\n%2").arg(e.ErrorMessage(), e.DetailedInformation());
|
||||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
VAbstractApplication::VApp()->IsPedantic()
|
||||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
? throw VException(errorMsg)
|
||||||
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,10 +730,10 @@ auto VPrintLayout::ContinueIfLayoutStale(QWidget *parent) -> int
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::CheckableMessageBox msgBox(parent);
|
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.setWindowTitle(tr("The layout is stale."));
|
||||||
msgBox.setText(tr("The layout was not updated since last pattern modification. Do you want to continue?"));
|
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);
|
msgBox.setDefaultButton(QDialogButtonBox::No);
|
||||||
|
|
||||||
int dialogResult = msgBox.exec();
|
int dialogResult = msgBox.exec();
|
||||||
|
@ -756,7 +756,7 @@ auto VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source) -> Q
|
||||||
|
|
||||||
qreal x;
|
qreal x;
|
||||||
qreal y;
|
qreal y;
|
||||||
if(printer->fullPage())
|
if (printer->fullPage())
|
||||||
{
|
{
|
||||||
QPageLayout layout = printer->pageLayout();
|
QPageLayout layout = printer->pageLayout();
|
||||||
layout.setUnits(QPageLayout::Millimeter);
|
layout.setUnits(QPageLayout::Millimeter);
|
||||||
|
@ -766,7 +766,8 @@ auto VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source) -> Q
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = 0; y = 0;
|
x = 0;
|
||||||
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<qreal, qreal> scaleDiff = PrinterScaleDiff(printer);
|
QPair<qreal, qreal> scaleDiff = PrinterScaleDiff(printer);
|
||||||
|
|
|
@ -70,17 +70,20 @@ Q_DECLARE_TYPEINFO(VRawSAPoint, Q_MOVABLE_TYPE); // NOLINT
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(qreal xpos, qreal ypos)
|
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(qreal xpos, qreal ypos)
|
||||||
: VLayoutPoint(xpos, ypos)
|
: VLayoutPoint(xpos, ypos)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p)
|
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p)
|
||||||
: VLayoutPoint(p)
|
: VLayoutPoint(p)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(const 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)
|
Q_DECL_RELAXED_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p, bool curvePoint, bool turnPoint)
|
||||||
|
|
|
@ -28,15 +28,16 @@
|
||||||
#ifndef VSAPOINT_H
|
#ifndef VSAPOINT_H
|
||||||
#define VSAPOINT_H
|
#define VSAPOINT_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#include "../vgeometry/vgeometrydef.h"
|
||||||
|
#include "../vmisc/def.h"
|
||||||
|
#include "vlayoutpoint.h"
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#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_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||||
|
@ -99,7 +100,7 @@ public:
|
||||||
|
|
||||||
static constexpr qreal passmarkFactor{0.5};
|
static constexpr qreal passmarkFactor{0.5};
|
||||||
static constexpr qreal maxPassmarkLength{MmToPixel(10.)};
|
static constexpr qreal maxPassmarkLength{MmToPixel(10.)};
|
||||||
static constexpr qreal minSAWidth{accuracyPointOnLine + accuracyPointOnLine*0.5};
|
static constexpr qreal minSAWidth{accuracyPointOnLine + accuracyPointOnLine * 0.5};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal m_before{-1};
|
qreal m_before{-1};
|
||||||
|
@ -120,17 +121,20 @@ Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); // NOLINT
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
|
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
|
||||||
: VLayoutPoint(xpos, ypos)
|
: VLayoutPoint(xpos, ypos)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(QPointF p)
|
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(QPointF p)
|
||||||
: VLayoutPoint(p)
|
: VLayoutPoint(p)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(const VLayoutPoint &p)
|
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(const VLayoutPoint &p)
|
||||||
: VLayoutPoint(p)
|
: VLayoutPoint(p)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_CONSTEXPR inline auto VSAPoint::GetSABefore() const -> qreal
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetSABefore() const -> qreal
|
||||||
|
|
|
@ -40,45 +40,48 @@
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args> struct QNonConstOverload
|
||||||
struct QNonConstOverload
|
|
||||||
{
|
{
|
||||||
template <typename R, typename T>
|
template <typename R, typename T>
|
||||||
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const noexcept -> decltype(ptr)
|
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const noexcept -> decltype(ptr)
|
||||||
{ return ptr; }
|
{
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename R, typename T>
|
template <typename R, typename T> static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr)
|
||||||
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr)
|
{
|
||||||
{ return ptr; }
|
return ptr;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args> struct QConstOverload
|
||||||
struct QConstOverload
|
|
||||||
{
|
{
|
||||||
template <typename R, typename T>
|
template <typename R, typename T>
|
||||||
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const noexcept -> decltype(ptr)
|
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const noexcept -> decltype(ptr)
|
||||||
{ return ptr; }
|
{
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename R, typename T>
|
template <typename R, typename T>
|
||||||
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) noexcept -> decltype(ptr)
|
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) noexcept -> decltype(ptr)
|
||||||
{ return ptr; }
|
{
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args> struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
|
||||||
struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
|
|
||||||
{
|
{
|
||||||
using QConstOverload<Args...>::of;
|
using QConstOverload<Args...>::of;
|
||||||
using QConstOverload<Args...>::operator();
|
using QConstOverload<Args...>::operator();
|
||||||
using QNonConstOverload<Args...>::of;
|
using QNonConstOverload<Args...>::of;
|
||||||
using QNonConstOverload<Args...>::operator();
|
using QNonConstOverload<Args...>::operator();
|
||||||
|
|
||||||
template <typename R>
|
template <typename R> Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr)
|
||||||
Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr)
|
{
|
||||||
{ return ptr; }
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R> static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) noexcept -> decltype(ptr) { return ptr; }
|
||||||
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
|
#if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 // C++14
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
#ifndef FPM_FIXED_HPP
|
#ifndef FPM_FIXED_HPP
|
||||||
#define FPM_FIXED_HPP
|
#define FPM_FIXED_HPP
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <type_traits>
|
#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
|
namespace fpm
|
||||||
{
|
{
|
||||||
|
@ -21,8 +17,7 @@ namespace fpm
|
||||||
//! unsigned type.
|
//! unsigned type.
|
||||||
//! \tparam IntermediateType the integer type used to store intermediate results during calculations.
|
//! \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
|
//! \tparam FractionBits the number of bits of the BaseType used to store the fraction
|
||||||
template <typename BaseType, typename IntermediateType, unsigned int FractionBits>
|
template <typename BaseType, typename IntermediateType, unsigned int FractionBits> class fixed
|
||||||
class fixed
|
|
||||||
{
|
{
|
||||||
static_assert(std::is_integral<BaseType>::value, "BaseType must be an integral type");
|
static_assert(std::is_integral<BaseType>::value, "BaseType must be an integral type");
|
||||||
static_assert(FractionBits > 0, "FractionBits must be greater than zero");
|
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.
|
// is incorrect (flips from positive to negative), so we must extend the size to IntermediateType.
|
||||||
static constexpr IntermediateType FRACTION_MULT = IntermediateType(1) << FractionBits;
|
static constexpr IntermediateType FRACTION_MULT = IntermediateType(1) << FractionBits;
|
||||||
|
|
||||||
struct raw_construct_tag {};
|
struct raw_construct_tag
|
||||||
constexpr inline fixed(BaseType val, raw_construct_tag /*unused*/) noexcept : m_value(val) {}
|
{
|
||||||
|
};
|
||||||
|
constexpr inline fixed(BaseType val, raw_construct_tag /*unused*/) noexcept
|
||||||
|
: m_value(val)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline fixed() noexcept = default;
|
inline fixed() noexcept = default;
|
||||||
|
|
||||||
// Converts an integral number to the fixed-point type.
|
// Converts an integral number to the fixed-point type.
|
||||||
// Like static_cast, this truncates bits that don't fit.
|
// 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
|
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.
|
// Converts an floating-point number to the fixed-point type.
|
||||||
// Like static_cast, this truncates bits that don't fit.
|
// 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
|
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.
|
// Constructs from another fixed-point type with possibly different underlying representation.
|
||||||
// Like static_cast, this truncates bits that don't fit.
|
// Like static_cast, this truncates bits that don't fit.
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F>
|
||||||
constexpr inline explicit fixed(fixed<B,I,F> val) noexcept
|
constexpr inline explicit fixed(fixed<B, I, F> val) noexcept
|
||||||
: m_value(from_fixed_point<F>(val.raw_value()).raw_value())
|
: m_value(from_fixed_point<F>(val.raw_value()).raw_value())
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Explicit conversion to a floating-point type
|
// 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
|
constexpr inline explicit operator T() const noexcept
|
||||||
{
|
{
|
||||||
return static_cast<T>(m_value) / FRACTION_MULT;
|
return static_cast<T>(m_value) / FRACTION_MULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicit conversion to an integral type
|
// 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
|
constexpr inline explicit operator T() const noexcept
|
||||||
{
|
{
|
||||||
return static_cast<T>(m_value / FRACTION_MULT);
|
return static_cast<T>(m_value / FRACTION_MULT);
|
||||||
|
@ -79,33 +82,27 @@ public:
|
||||||
|
|
||||||
// Returns the raw underlying value of this type.
|
// Returns the raw underlying value of this type.
|
||||||
// Do not use this unless you know what you're doing.
|
// Do not use this unless you know what you're doing.
|
||||||
constexpr inline auto raw_value() const noexcept -> BaseType
|
constexpr inline auto raw_value() const noexcept -> BaseType { return m_value; }
|
||||||
{
|
|
||||||
return m_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Constructs a fixed-point number from another fixed-point number.
|
//! Constructs a fixed-point number from another fixed-point number.
|
||||||
//! \tparam NumFractionBits the number of bits used by the fraction in \a value.
|
//! \tparam NumFractionBits the number of bits used by the fraction in \a value.
|
||||||
//! \param value the integer fixed-point number
|
//! \param value the integer fixed-point number
|
||||||
template <unsigned int NumFractionBits, typename T,
|
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
|
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.
|
// 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.
|
// We do this by multiplying by two before dividing and adding the LSB to the real result.
|
||||||
return fixed(static_cast<BaseType>(
|
return fixed(static_cast<BaseType>(value / (T(1) << (NumFractionBits - FractionBits)) +
|
||||||
value / (T(1) << (NumFractionBits - FractionBits)) +
|
|
||||||
(value / (T(1) << (NumFractionBits - FractionBits - 1)) % 2)),
|
(value / (T(1) << (NumFractionBits - FractionBits - 1)) % 2)),
|
||||||
raw_construct_tag{});
|
raw_construct_tag{});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int NumFractionBits, typename T,
|
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
|
static constexpr inline auto from_fixed_point(T value) noexcept -> fixed
|
||||||
{
|
{
|
||||||
return fixed(static_cast<BaseType>(
|
return fixed(static_cast<BaseType>(value * (T(1) << (FractionBits - NumFractionBits))), raw_construct_tag{});
|
||||||
value * (T(1) << (FractionBits - NumFractionBits))),
|
|
||||||
raw_construct_tag{});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructs a fixed-point number from its raw underlying value.
|
// Constructs a fixed-point number from its raw underlying value.
|
||||||
|
@ -127,38 +124,35 @@ public:
|
||||||
// Arithmetic member operators
|
// Arithmetic member operators
|
||||||
//
|
//
|
||||||
|
|
||||||
constexpr inline auto operator-() const noexcept -> fixed
|
constexpr inline auto operator-() const noexcept -> fixed { return fixed::from_raw_value(-m_value); }
|
||||||
{
|
|
||||||
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;
|
m_value += y.m_value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
|
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
|
||||||
inline auto operator+=(I y) noexcept -> fixed&
|
inline auto operator+=(I y) noexcept -> fixed &
|
||||||
{
|
{
|
||||||
m_value += y * FRACTION_MULT;
|
m_value += y * FRACTION_MULT;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto operator-=(const fixed& y) noexcept -> fixed&
|
inline auto operator-=(const fixed &y) noexcept -> fixed &
|
||||||
{
|
{
|
||||||
m_value -= y.m_value;
|
m_value -= y.m_value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
|
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
|
||||||
inline auto operator-=(I y) noexcept -> fixed&
|
inline auto operator-=(I y) noexcept -> fixed &
|
||||||
{
|
{
|
||||||
m_value -= y * FRACTION_MULT;
|
m_value -= y * FRACTION_MULT;
|
||||||
return *this;
|
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.
|
// 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.
|
// To correctly round the last bit in the result, we need one more bit of information.
|
||||||
|
@ -169,14 +163,14 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
|
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
|
||||||
inline auto operator*=(I y) noexcept -> fixed&
|
inline auto operator*=(I y) noexcept -> fixed &
|
||||||
{
|
{
|
||||||
m_value *= y;
|
m_value *= y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto operator/=(const fixed& y) noexcept -> fixed&
|
inline auto operator/=(const fixed &y) noexcept -> fixed &
|
||||||
{
|
{
|
||||||
assert(y.m_value != 0);
|
assert(y.m_value != 0);
|
||||||
// Normal fixed-point division is: x * 2**FractionBits / y.
|
// Normal fixed-point division is: x * 2**FractionBits / y.
|
||||||
|
@ -187,8 +181,8 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
|
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
|
||||||
inline auto operator/=(I y) noexcept -> fixed&
|
inline auto operator/=(I y) noexcept -> fixed &
|
||||||
{
|
{
|
||||||
m_value /= y;
|
m_value /= y;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -198,15 +192,15 @@ public:
|
||||||
// Shift operators
|
// Shift operators
|
||||||
//
|
//
|
||||||
|
|
||||||
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
|
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
|
||||||
inline auto operator>>=(I y) noexcept -> fixed&
|
inline auto operator>>=(I y) noexcept -> fixed &
|
||||||
{
|
{
|
||||||
m_value >>= y;
|
m_value >>= y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type* = nullptr>
|
template <typename I, typename std::enable_if<std::is_integral<I>::value>::type * = nullptr>
|
||||||
inline auto operator<<=(I y) noexcept -> fixed&
|
inline auto operator<<=(I y) noexcept -> fixed &
|
||||||
{
|
{
|
||||||
m_value <<= y;
|
m_value <<= y;
|
||||||
return *this;
|
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>
|
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;
|
return fixed<B, I, F>(x) += y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
||||||
constexpr inline auto operator+(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator+(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(x) += y;
|
return fixed<B, I, F>(x) += y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
||||||
constexpr inline auto operator+(T x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator+(T x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(y) += x;
|
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>
|
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;
|
return fixed<B, I, F>(x) -= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
||||||
constexpr inline auto operator-(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator-(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(x) -= y;
|
return fixed<B, I, F>(x) -= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
||||||
constexpr inline auto operator-(T x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator-(T x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(x) -= y;
|
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>
|
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;
|
return fixed<B, I, F>(x) *= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
||||||
constexpr inline auto operator*(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator*(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(x) *= y;
|
return fixed<B, I, F>(x) *= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
||||||
constexpr inline auto operator*(T x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator*(T x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(y) *= x;
|
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>
|
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;
|
return fixed<B, I, F>(x) /= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
||||||
constexpr inline auto operator/(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator/(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(x) /= y;
|
return fixed<B, I, F>(x) /= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
||||||
constexpr inline auto operator/(T x, const fixed<B, I, F>& y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator/(T x, const fixed<B, I, F> &y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(x) /= y;
|
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,
|
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>
|
||||||
constexpr inline auto operator>>(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator>>(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(x) >>= y;
|
return fixed<B, I, F>(x) >>= y;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
||||||
constexpr inline auto operator<<(const fixed<B, I, F>& x, T y) noexcept -> fixed<B, I, F>
|
constexpr inline auto operator<<(const fixed<B, I, F> &x, T y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return fixed<B, I, F>(x) <<= y;
|
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>
|
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();
|
return x.raw_value() == y.raw_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
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();
|
return x.raw_value() != y.raw_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
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();
|
return x.raw_value() < y.raw_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
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();
|
return x.raw_value() > y.raw_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
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();
|
return x.raw_value() <= y.raw_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
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();
|
return x.raw_value() >= y.raw_value();
|
||||||
}
|
}
|
||||||
|
@ -397,7 +391,7 @@ static constexpr auto digits10(int bits) -> int
|
||||||
{
|
{
|
||||||
// 8.24 fixed-point equivalent of (int)(bits * std::log10(2));
|
// 8.24 fixed-point equivalent of (int)(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) >> 24); //NOLINT(hicpp-signed-bitwise)
|
return static_cast<int>((T{bits} * 5050445) >> 24); // NOLINT(hicpp-signed-bitwise)
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
@ -409,8 +403,7 @@ QT_WARNING_POP
|
||||||
namespace std // NOLINT(cert-dcl58-cpp)
|
namespace std // NOLINT(cert-dcl58-cpp)
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> struct hash<fpm::fixed<B, I, F>>
|
||||||
struct hash<fpm::fixed<B,I,F>>
|
|
||||||
{
|
{
|
||||||
using argument_type = fpm::fixed<B, I, F>;
|
using argument_type = fpm::fixed<B, I, F>;
|
||||||
using result_type = std::size_t;
|
using result_type = std::size_t;
|
||||||
|
@ -425,8 +418,7 @@ private:
|
||||||
std::hash<B> m_hash;
|
std::hash<B> m_hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> struct numeric_limits<fpm::fixed<B, I, F>>
|
||||||
struct numeric_limits<fpm::fixed<B,I,F>>
|
|
||||||
{
|
{
|
||||||
static constexpr bool is_specialized = true;
|
static constexpr bool is_specialized = true;
|
||||||
static constexpr bool is_signed = std::numeric_limits<B>::is_signed;
|
static constexpr bool is_signed = std::numeric_limits<B>::is_signed;
|
||||||
|
@ -461,85 +453,75 @@ struct numeric_limits<fpm::fixed<B,I,F>>
|
||||||
static constexpr bool traps = true;
|
static constexpr bool traps = true;
|
||||||
static constexpr bool tinyness_before = false;
|
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>
|
static constexpr auto epsilon() noexcept -> fpm::fixed<B, I, F> { return fpm::fixed<B, I, F>::from_raw_value(1); }
|
||||||
{
|
|
||||||
return fpm::fixed<B,I,F>::from_raw_value(std::numeric_limits<B>::max());
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr auto epsilon() noexcept -> fpm::fixed<B,I,F>
|
static constexpr auto round_error() noexcept -> fpm::fixed<B, I, F> { return fpm::fixed<B, I, F>(1) / 2; }
|
||||||
{
|
|
||||||
return fpm::fixed<B,I,F>::from_raw_value(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr auto round_error() noexcept -> fpm::fixed<B,I,F>
|
static constexpr auto denorm_min() noexcept -> fpm::fixed<B, I, F> { return min(); }
|
||||||
{
|
|
||||||
return fpm::fixed<B,I,F>(1) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
static constexpr auto denorm_min() noexcept -> fpm::fixed<B,I,F>
|
|
||||||
{
|
|
||||||
return min();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// See https://stackoverflow.com/a/46719572/3045403
|
// See https://stackoverflow.com/a/46719572/3045403
|
||||||
#if __cplusplus < 201703L
|
#if __cplusplus < 201703L
|
||||||
template <typename B, typename I, unsigned int F>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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>
|
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
|
#endif
|
||||||
|
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
|
@ -37,9 +37,12 @@ inline auto find_highest_bit(unsigned long long value) noexcept -> long
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
_BitScanReverse64(&index, value);
|
_BitScanReverse64(&index, value);
|
||||||
#else
|
#else
|
||||||
if (_BitScanReverse(&index, static_cast<unsigned long>(value >> 32)) != 0) {
|
if (_BitScanReverse(&index, static_cast<unsigned long>(value >> 32)) != 0)
|
||||||
|
{
|
||||||
index += 32;
|
index += 32;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_BitScanReverse(&index, static_cast<unsigned long>(value & 0xfffffffflu));
|
_BitScanReverse(&index, static_cast<unsigned long>(value & 0xfffffffflu));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -47,7 +50,7 @@ inline auto find_highest_bit(unsigned long long value) noexcept -> long
|
||||||
#elif defined(__GNUC__) || defined(__clang__)
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
return sizeof(value) * 8 - 1 - __builtin_clzll(value); // NOLINT
|
return sizeof(value) * 8 - 1 - __builtin_clzll(value); // NOLINT
|
||||||
#else
|
#else
|
||||||
# error "your platform does not support find_highest_bit()"
|
#error "your platform does not support find_highest_bit()"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +62,7 @@ QT_WARNING_POP
|
||||||
// Classification methods
|
// Classification methods
|
||||||
//
|
//
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> constexpr inline auto fpclassify(fixed<B, I, F> x) noexcept -> int
|
||||||
constexpr inline auto fpclassify(fixed<B, I, F> x) noexcept -> int
|
|
||||||
{
|
{
|
||||||
return (x.raw_value() == 0) ? FP_ZERO : FP_NORMAL;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> constexpr inline auto isnormal(fixed<B, I, F> x) noexcept -> bool
|
||||||
constexpr inline auto isnormal(fixed<B, I, F> x) noexcept -> bool
|
|
||||||
{
|
{
|
||||||
return x.raw_value() != 0;
|
return x.raw_value() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> constexpr inline auto signbit(fixed<B, I, F> x) noexcept -> bool
|
||||||
constexpr inline auto signbit(fixed<B, I, F> x) noexcept -> bool
|
|
||||||
{
|
{
|
||||||
return x.raw_value() < 0;
|
return x.raw_value() < 0;
|
||||||
}
|
}
|
||||||
|
@ -134,8 +134,7 @@ constexpr inline auto isunordered(fixed<B, I, F> /*x*/, fixed<B, I, F> /*y*/)
|
||||||
//
|
//
|
||||||
// Nearest integer operations
|
// Nearest integer operations
|
||||||
//
|
//
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> inline auto ceil(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
inline auto ceil(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
constexpr auto FRAC = B(1) << F;
|
constexpr auto FRAC = B(1) << F;
|
||||||
auto value = x.raw_value();
|
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);
|
return fixed<B, I, F>::from_raw_value(value / FRAC * FRAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> inline auto floor(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
inline auto floor(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
constexpr auto FRAC = B(1) << F;
|
constexpr auto FRAC = B(1) << F;
|
||||||
auto value = x.raw_value();
|
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);
|
return fixed<B, I, F>::from_raw_value(value / FRAC * FRAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> inline auto trunc(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
inline auto trunc(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
constexpr auto FRAC = B(1) << F;
|
constexpr auto FRAC = B(1) << F;
|
||||||
return fixed<B, I, F>::from_raw_value(x.raw_value() / FRAC * FRAC);
|
return fixed<B, I, F>::from_raw_value(x.raw_value() / FRAC * FRAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> inline auto round(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
inline auto round(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
constexpr auto FRAC = B(1) << F;
|
constexpr auto FRAC = B(1) << F;
|
||||||
auto value = x.raw_value() / (FRAC / 2);
|
auto value = x.raw_value() / (FRAC / 2);
|
||||||
return fixed<B, I, F>::from_raw_value(((value / 2) + (value % 2)) * FRAC);
|
return fixed<B, I, F>::from_raw_value(((value / 2) + (value % 2)) * FRAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto nearbyint(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto nearbyint(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
// Rounding mode is assumed to be FE_TONEAREST
|
// Rounding mode is assumed to be FE_TONEAREST
|
||||||
constexpr auto FRAC = B(1) << F;
|
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
|
// Mathematical functions
|
||||||
//
|
//
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> constexpr inline auto abs(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
constexpr inline auto abs(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
return (x >= fixed<B, I, F>{0}) ? x : -x;
|
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>
|
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>
|
constexpr inline auto fmod(fixed<B, I, F> x, fixed<B, I, F> y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return
|
return assert(y.raw_value() != 0), fixed<B, I, F>::from_raw_value(x.raw_value() % y.raw_value());
|
||||||
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>
|
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>
|
constexpr inline auto remainder(fixed<B, I, F> x, fixed<B, I, F> y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return
|
return assert(y.raw_value() != 0), x - nearbyint(x / y) * y;
|
||||||
assert(y.raw_value() != 0),
|
|
||||||
x - nearbyint(x / y) * y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
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(y.raw_value() != 0);
|
||||||
assert(quo != nullptr);
|
assert(quo != nullptr);
|
||||||
|
@ -234,16 +224,14 @@ 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>
|
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>
|
constexpr inline auto copysign(fixed<B, I, F> x, fixed<C, J, G> y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return
|
return x = abs(x), (y >= fixed<C, J, G>{0}) ? x : -x;
|
||||||
x = abs(x),
|
|
||||||
(y >= fixed<C, J, G>{0}) ? x : -x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
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>
|
constexpr inline auto nextafter(fixed<B, I, F> from, fixed<B, I, F> to) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
return from == to ? to :
|
return from == to ? to
|
||||||
to > from ? fixed<B, I, F>::from_raw_value(from.raw_value() + 1)
|
: to > from ? fixed<B, I, F>::from_raw_value(from.raw_value() + 1)
|
||||||
: fixed<B, I, F>::from_raw_value(from.raw_value() - 1);
|
: fixed<B, I, F>::from_raw_value(from.raw_value() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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>
|
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();
|
const auto raw = x.raw_value();
|
||||||
constexpr auto FRAC = B{1} << F;
|
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);
|
return fixed<B, I, F>::from_raw_value(raw % FRAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Power functions
|
// Power functions
|
||||||
//
|
//
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F, typename T,
|
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>
|
auto pow(fixed<B, I, F> base, T exp) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
|
|
||||||
if (base == Fixed(0)) {
|
if (base == Fixed(0))
|
||||||
|
{
|
||||||
assert(exp > 0);
|
assert(exp > 0);
|
||||||
return Fixed(0);
|
return Fixed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fixed result {1};
|
Fixed result{1};
|
||||||
if (exp < 0)
|
if (exp < 0)
|
||||||
{
|
{
|
||||||
for (Fixed intermediate = base; exp != 0; exp /= 2, intermediate *= intermediate)
|
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>;
|
using Fixed = fixed<B, I, F>;
|
||||||
|
|
||||||
if (base == Fixed(0)) {
|
if (base == Fixed(0))
|
||||||
|
{
|
||||||
assert(exp > Fixed(0));
|
assert(exp > Fixed(0));
|
||||||
return 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);
|
return exp2(log2(base) * exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto exp(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto exp(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
if (x < Fixed(0)) {
|
if (x < Fixed(0))
|
||||||
|
{
|
||||||
return 1 / exp(-x);
|
return 1 / exp(-x);
|
||||||
}
|
}
|
||||||
constexpr auto FRAC = B(1) << F;
|
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;
|
x -= x_int;
|
||||||
assert(x >= Fixed(0) && x < Fixed(1));
|
assert(x >= Fixed(0) && x < Fixed(1));
|
||||||
|
|
||||||
constexpr auto fA = Fixed::template from_fixed_point<63>( 128239257017632854LL); // 1.3903728105644451e-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 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 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 fD = Fixed::template from_fixed_point<63>(4603349000587966862LL); // 4.9909609871464493e-1
|
||||||
constexpr auto fE = Fixed::template from_fixed_point<62>(4612052447974689712LL); // 1.0000794567422495
|
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);
|
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>
|
template <typename B, typename I, unsigned int F> auto exp2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto exp2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
if (x < Fixed(0)) {
|
if (x < Fixed(0))
|
||||||
|
{
|
||||||
return 1 / exp2(-x);
|
return 1 / exp2(-x);
|
||||||
}
|
}
|
||||||
constexpr auto FRAC = B(1) << F;
|
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;
|
x -= x_int;
|
||||||
assert(x >= Fixed(0) && x < Fixed(1));
|
assert(x >= Fixed(0) && x < Fixed(1));
|
||||||
|
|
||||||
constexpr auto fA = Fixed::template from_fixed_point<63>( 17491766697771214LL); // 1.8964611454333148e-3
|
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 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 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 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 fE = Fixed::template from_fixed_point<63>(6393224161192452326LL); // 6.9315475247516736e-1
|
||||||
constexpr auto fF = Fixed::template from_fixed_point<63>(9223371050976163566LL); // 9.9999989311082668e-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);
|
return Fixed(1 << x_int) * (((((fA * x + fB) * x + fC) * x + fD) * x + fE) * x + fF);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto expm1(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto expm1(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
return exp(x) - 1; // cppcheck-suppress unpreciseMathCall
|
return exp(x) - 1; // cppcheck-suppress unpreciseMathCall
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto log2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto log2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
assert(x > Fixed(0));
|
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);
|
x = Fixed::from_raw_value(value);
|
||||||
assert(x >= Fixed(1) && x < Fixed(2));
|
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 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 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
|
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);
|
return Fixed(highest - F) + (((((fA * x + fB) * x + fC) * x + fD) * x + fE) * x + fF);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto log(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto log(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
return log2(x) / log2(Fixed::e());
|
return log2(x) / log2(Fixed::e());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto log10(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto log10(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
return log2(x) / log2(Fixed(10));
|
return log2(x) / log2(Fixed(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto log1p(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto log1p(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
return log(1 + x); // cppcheck-suppress unpreciseMathCall
|
return log(1 + x); // cppcheck-suppress unpreciseMathCall
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = 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.
|
// based on the square root algorithm.
|
||||||
|
|
||||||
// We start at the greatest power of eight that's less than the argument.
|
// 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 num = I{x.raw_value()};
|
||||||
I res = 0;
|
I res = 0;
|
||||||
|
|
||||||
|
@ -456,7 +439,7 @@ auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
for (; ofs >= 0; ofs -= 3)
|
for (; ofs >= 0; ofs -= 3)
|
||||||
{
|
{
|
||||||
res += res;
|
res += res;
|
||||||
const I val = (3*res*(res + 1) + 1) << ofs;
|
const I val = (3 * res * (res + 1) + 1) << ofs;
|
||||||
if (num >= val)
|
if (num >= val)
|
||||||
{
|
{
|
||||||
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));
|
return Fixed::from_raw_value(static_cast<B>(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto sqrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto sqrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = 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>
|
auto hypot(fixed<B, I, F> x, fixed<B, I, F> y) noexcept -> fixed<B, I, F>
|
||||||
{
|
{
|
||||||
assert(x != 0 || y != 0);
|
assert(x != 0 || y != 0);
|
||||||
return sqrt(x*x + y*y);
|
return sqrt(x * x + y * y);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Trigonometry functions
|
// Trigonometry functions
|
||||||
//
|
//
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto sin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto sin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
// This sine uses a fifth-order curve-fitting approximation originally
|
// This sine uses a fifth-order curve-fitting approximation originally
|
||||||
// described by Jasper Vijn on coranac.com which has a worst-case
|
// 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();
|
x = x / Fixed::half_pi();
|
||||||
|
|
||||||
// Take x modulo one rotation, so [-4..+4].
|
// Take x modulo one rotation, so [-4..+4].
|
||||||
if (x < Fixed(0)) {
|
if (x < Fixed(0))
|
||||||
|
{
|
||||||
x += Fixed(4);
|
x += Fixed(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sign = +1;
|
int sign = +1;
|
||||||
if (x > Fixed(2)) {
|
if (x > Fixed(2))
|
||||||
|
{
|
||||||
// Reduce domain to [0..2].
|
// Reduce domain to [0..2].
|
||||||
sign = -1;
|
sign = -1;
|
||||||
x -= Fixed(2);
|
x -= Fixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x > Fixed(1)) {
|
if (x > Fixed(1))
|
||||||
|
{
|
||||||
// Reduce domain to [0..1].
|
// Reduce domain to [0..1].
|
||||||
x = Fixed(2) - x;
|
x = Fixed(2) - x;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Fixed x2 = x*x;
|
const Fixed x2 = x * x;
|
||||||
return sign * x * (Fixed::pi() - x2*(Fixed::two_pi() - 5 - x2*(Fixed::pi() - 3)))/2;
|
return sign * x * (Fixed::pi() - x2 * (Fixed::two_pi() - 5 - x2 * (Fixed::pi() - 3))) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> inline auto cos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
inline auto cos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
return sin(fixed<B, I, F>::half_pi() + x);
|
return sin(fixed<B, I, F>::half_pi() + x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> inline auto tan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
inline auto tan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
auto cx = cos(x);
|
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;
|
return sin(x) / cx;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
// Calculates atan(x) assuming that x is in the range [0,1]
|
// Calculates atan(x) assuming that x is in the range [0,1]
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto atan_sanitized(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto atan_sanitized(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
assert(x >= Fixed(0) && x <= Fixed(1));
|
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 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;
|
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.
|
// Calculate atan(y / x), assuming x != 0.
|
||||||
|
@ -613,19 +596,23 @@ 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.
|
// 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
|
// If y / x is negative (when y or x, but not both, are negative), negate the result to
|
||||||
// keep the correct outcome.
|
// keep the correct outcome.
|
||||||
if (y < Fixed(0)) {
|
if (y < Fixed(0))
|
||||||
if (x < Fixed(0)) {
|
{
|
||||||
|
if (x < Fixed(0))
|
||||||
|
{
|
||||||
return atan_div(-y, -x);
|
return atan_div(-y, -x);
|
||||||
}
|
}
|
||||||
return -atan_div(-y, x);
|
return -atan_div(-y, x);
|
||||||
}
|
}
|
||||||
if (x < Fixed(0)) {
|
if (x < Fixed(0))
|
||||||
|
{
|
||||||
return -atan_div(y, -x);
|
return -atan_div(y, -x);
|
||||||
}
|
}
|
||||||
assert(y >= Fixed(0));
|
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 Fixed::half_pi() - detail::atan_sanitized(x / y);
|
||||||
}
|
}
|
||||||
return detail::atan_sanitized(y / x);
|
return detail::atan_sanitized(y / x);
|
||||||
|
@ -633,8 +620,7 @@ auto atan_div(fixed<B, I, F> y, fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto atan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto atan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
if (x < Fixed(0))
|
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);
|
return detail::atan_sanitized(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto asin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto asin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
assert(x >= Fixed(-1) && x <= Fixed(+1));
|
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));
|
return detail::atan_div(x, sqrt(yy));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F> auto acos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
auto acos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
|
||||||
{
|
{
|
||||||
using Fixed = fixed<B, I, F>;
|
using Fixed = fixed<B, I, F>;
|
||||||
assert(x >= Fixed(-1) && x <= Fixed(+1));
|
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();
|
return Fixed::pi();
|
||||||
}
|
}
|
||||||
const auto yy = Fixed(1) - x * x;
|
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>
|
template <typename B, typename I, unsigned int F>
|
||||||
|
|
|
@ -38,11 +38,10 @@ namespace
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto QtCodecs() -> QMap<QStringConverter::Encoding, QStringList>
|
auto QtCodecs() -> QMap<QStringConverter::Encoding, QStringList>
|
||||||
{
|
{
|
||||||
static auto codecs = QMap<QStringConverter::Encoding, QStringList>
|
static auto codecs = QMap<QStringConverter::Encoding, QStringList>{
|
||||||
{
|
{QStringConverter::Latin1,
|
||||||
{QStringConverter::Latin1, {"ISO-8859-1", "ANSI_1252", "CP1252", "windows-1252", "LATIN1", "CP819", "CSISO",
|
{"ISO-8859-1", "ANSI_1252", "CP1252", "windows-1252", "LATIN1", "CP819", "CSISO", "IBM819", "ISO_8859-1",
|
||||||
"IBM819", "ISO_8859-1", "APPLE ROMAN", "ISO8859-1", "ISO8859-15", "ISO-IR-100", "L1", "IBM 850",
|
"APPLE ROMAN", "ISO8859-1", "ISO8859-15", "ISO-IR-100", "L1", "IBM 850", "850"}}, // Western Europe
|
||||||
"850"}}, // Western Europe
|
|
||||||
{QStringConverter::Utf8, {"UTF-8", "UTF8", "UTF8-BIT"}},
|
{QStringConverter::Utf8, {"UTF-8", "UTF8", "UTF8-BIT"}},
|
||||||
{QStringConverter::Utf16, {"UTF-16", "UTF16", "UTF16-BIT"}},
|
{QStringConverter::Utf16, {"UTF-16", "UTF16", "UTF16-BIT"}},
|
||||||
{QStringConverter::Utf16BE, {"UTF-16BE"}},
|
{QStringConverter::Utf16BE, {"UTF-16BE"}},
|
||||||
|
@ -59,17 +58,10 @@ auto QtCodecs() -> QMap<QStringConverter::Encoding, QStringList>
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto CodecMibs() -> QMap<QStringConverter::Encoding, int>
|
auto CodecMibs() -> QMap<QStringConverter::Encoding, int>
|
||||||
{
|
{
|
||||||
static auto mibs = QMap<QStringConverter::Encoding, int>
|
static auto mibs = QMap<QStringConverter::Encoding, int>{
|
||||||
{
|
{QStringConverter::Utf8, 106}, {QStringConverter::Utf16, 1015}, {QStringConverter::Utf16BE, 1013},
|
||||||
{QStringConverter::Utf8, 106},
|
{QStringConverter::Utf16LE, 1014}, {QStringConverter::Utf32, 1017}, {QStringConverter::Utf32BE, 1018},
|
||||||
{QStringConverter::Utf16, 1015},
|
{QStringConverter::Utf32LE, 1019}, {QStringConverter::Latin1, 4}, {QStringConverter::System, 0},
|
||||||
{QStringConverter::Utf16BE, 1013},
|
|
||||||
{QStringConverter::Utf16LE, 1014},
|
|
||||||
{QStringConverter::Utf32, 1017},
|
|
||||||
{QStringConverter::Utf32BE, 1018},
|
|
||||||
{QStringConverter::Utf32LE, 1019},
|
|
||||||
{QStringConverter::Latin1, 4},
|
|
||||||
{QStringConverter::System, 0},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return mibs;
|
return mibs;
|
||||||
|
@ -79,7 +71,8 @@ auto CodecMibs() -> QMap<QStringConverter::Encoding, int>
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VTextCodec::VTextCodec(QStringConverter::Encoding encoding)
|
VTextCodec::VTextCodec(QStringConverter::Encoding encoding)
|
||||||
: m_encoding(encoding)
|
: m_encoding(encoding)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VTextCodec::codecForName(const QString &name) -> VTextCodec *
|
auto VTextCodec::codecForName(const QString &name) -> VTextCodec *
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
|
@ -54,19 +54,18 @@ struct face_s;
|
||||||
struct halfedge_s;
|
struct halfedge_s;
|
||||||
struct point2d_s;
|
struct point2d_s;
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_DOUBLE
|
#ifdef USE_DOUBLE
|
||||||
# define REAL_ZERO 0.0
|
#define REAL_ZERO 0.0
|
||||||
# define REAL_ONE 1.0
|
#define REAL_ONE 1.0
|
||||||
# define REAL_TWO 2.0
|
#define REAL_TWO 2.0
|
||||||
# define REAL_FOUR 4.0
|
#define REAL_FOUR 4.0
|
||||||
# define TOLERANCE (1024.0 * 1024.0)
|
#define TOLERANCE (1024.0 * 1024.0)
|
||||||
#else
|
#else
|
||||||
# define REAL_ZERO 0.0f
|
#define REAL_ZERO 0.0f
|
||||||
# define REAL_ONE 1.0f
|
#define REAL_ONE 1.0f
|
||||||
# define REAL_TWO 2.0f
|
#define REAL_TWO 2.0f
|
||||||
# define REAL_FOUR 4.0f
|
#define REAL_FOUR 4.0f
|
||||||
# define TOLERANCE (16.0f )
|
#define TOLERANCE (16.0f)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EPSILON (REAL_ONE / TOLERANCE)
|
#define EPSILON (REAL_ONE / TOLERANCE)
|
||||||
|
@ -80,45 +79,44 @@ typedef real mat3_t[3][3];
|
||||||
struct point2d_s
|
struct point2d_s
|
||||||
{
|
{
|
||||||
real x, y; /* point coordinates */
|
real x, y; /* point coordinates */
|
||||||
halfedge_t* he; /* point halfedge */
|
halfedge_t *he; /* point halfedge */
|
||||||
quint32 idx; /* point index in input buffer */
|
quint32 idx; /* point index in input buffer */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct face_s
|
struct face_s
|
||||||
{
|
{
|
||||||
/* real radius;
|
/* real radius;
|
||||||
real cx, cy;
|
real cx, cy;
|
||||||
point2d_t* p[3];
|
point2d_t* p[3];
|
||||||
*/
|
*/
|
||||||
halfedge_t* he; /* a pointing half edge */
|
halfedge_t *he; /* a pointing half edge */
|
||||||
quint32 num_verts; /* number of vertices on this face */
|
quint32 num_verts; /* number of vertices on this face */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct halfedge_s
|
struct halfedge_s
|
||||||
{
|
{
|
||||||
point2d_t* vertex; /* vertex */
|
point2d_t *vertex; /* vertex */
|
||||||
halfedge_t* pair; /* pair */
|
halfedge_t *pair; /* pair */
|
||||||
halfedge_t* next; /* next */
|
halfedge_t *next; /* next */
|
||||||
halfedge_t* prev; /* next^-1 */
|
halfedge_t *prev; /* next^-1 */
|
||||||
face_t* face; /* halfedge face */
|
face_t *face; /* halfedge face */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct delaunay_s
|
struct delaunay_s
|
||||||
{
|
{
|
||||||
halfedge_t* rightmost_he; /* right most halfedge */
|
halfedge_t *rightmost_he; /* right most halfedge */
|
||||||
halfedge_t* leftmost_he; /* left most halfedge */
|
halfedge_t *leftmost_he; /* left most halfedge */
|
||||||
point2d_t** points; /* pointer to points */
|
point2d_t **points; /* pointer to points */
|
||||||
face_t* faces; /* faces of delaunay */
|
face_t *faces; /* faces of delaunay */
|
||||||
quint32 num_faces; /* face count */
|
quint32 num_faces; /* face count */
|
||||||
quint32 start_point; /* start point index */
|
quint32 start_point; /* start point index */
|
||||||
quint32 end_point; /* end point index */
|
quint32 end_point; /* end point index */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 3x3 matrix determinant
|
* 3x3 matrix determinant
|
||||||
*/
|
*/
|
||||||
//static real det3( mat3_t *m )
|
// static real det3( mat3_t *m )
|
||||||
//{
|
//{
|
||||||
// real res;
|
// real res;
|
||||||
|
|
||||||
|
@ -130,77 +128,78 @@ struct delaunay_s
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* allocate a point
|
* allocate a point
|
||||||
*/
|
*/
|
||||||
static auto point_alloc() -> point2d_t *
|
static auto point_alloc() -> point2d_t *
|
||||||
{
|
{
|
||||||
point2d_t* p;
|
point2d_t *p;
|
||||||
|
|
||||||
p = (point2d_t*)malloc(sizeof(point2d_t));
|
p = (point2d_t *)malloc(sizeof(point2d_t));
|
||||||
assert( p != nullptr );
|
assert(p != nullptr);
|
||||||
// cppcheck-suppress memsetClassFloat
|
// cppcheck-suppress memsetClassFloat
|
||||||
memset(p, 0, sizeof(point2d_t));
|
memset(p, 0, sizeof(point2d_t));
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* free a point
|
* free a point
|
||||||
*/
|
*/
|
||||||
static void point_free( point2d_t* p )
|
static void point_free(point2d_t *p)
|
||||||
{
|
{
|
||||||
assert( p != nullptr );
|
assert(p != nullptr);
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* allocate a halfedge
|
* allocate a halfedge
|
||||||
*/
|
*/
|
||||||
static auto halfedge_alloc() -> halfedge_t *
|
static auto halfedge_alloc() -> halfedge_t *
|
||||||
{
|
{
|
||||||
halfedge_t* d;
|
halfedge_t *d;
|
||||||
|
|
||||||
d = (halfedge_t*)malloc(sizeof(halfedge_t));
|
d = (halfedge_t *)malloc(sizeof(halfedge_t));
|
||||||
assert( d != nullptr );
|
assert(d != nullptr);
|
||||||
memset(d, 0, sizeof(halfedge_t));
|
memset(d, 0, sizeof(halfedge_t));
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* free a halfedge
|
* free a halfedge
|
||||||
*/
|
*/
|
||||||
static void halfedge_free( halfedge_t* d )
|
static void halfedge_free(halfedge_t *d)
|
||||||
{
|
{
|
||||||
assert( d != nullptr );
|
assert(d != nullptr);
|
||||||
memset(d, 0, sizeof(halfedge_t));
|
memset(d, 0, sizeof(halfedge_t));
|
||||||
free(d);
|
free(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* free all delaunay halfedges
|
* free all delaunay halfedges
|
||||||
*/
|
*/
|
||||||
void del_free_halfedges( delaunay_t *del );
|
void del_free_halfedges(delaunay_t *del);
|
||||||
void del_free_halfedges( delaunay_t *del )
|
void del_free_halfedges(delaunay_t *del)
|
||||||
{
|
{
|
||||||
quint32 i;
|
quint32 i;
|
||||||
halfedge_t *d, *sig;
|
halfedge_t *d, *sig;
|
||||||
|
|
||||||
/* if there is nothing to do */
|
/* if there is nothing to do */
|
||||||
if( del->points == nullptr )
|
if (del->points == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for( i = 0; i <= (del->end_point - del->start_point); i++ )
|
for (i = 0; i <= (del->end_point - del->start_point); i++)
|
||||||
{
|
{
|
||||||
/* free all the halfedges around the point */
|
/* free all the halfedges around the point */
|
||||||
d = del->points[i]->he;
|
d = del->points[i]->he;
|
||||||
if( d != nullptr )
|
if (d != nullptr)
|
||||||
|
{
|
||||||
|
do
|
||||||
{
|
{
|
||||||
do {
|
|
||||||
sig = d->next;
|
sig = d->next;
|
||||||
halfedge_free( d );
|
halfedge_free(d);
|
||||||
d = sig;
|
d = sig;
|
||||||
} while( d != del->points[i]->he );
|
} while (d != del->points[i]->he);
|
||||||
del->points[i]->he = nullptr;
|
del->points[i]->he = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,48 +208,48 @@ void del_free_halfedges( delaunay_t *del )
|
||||||
/*
|
/*
|
||||||
* allocate memory for a face
|
* allocate memory for a face
|
||||||
*/
|
*/
|
||||||
//static face_t* face_alloc()
|
// static face_t* face_alloc()
|
||||||
//{
|
//{
|
||||||
// face_t *f = (face_t*)malloc(sizeof(face_t));
|
// face_t *f = (face_t*)malloc(sizeof(face_t));
|
||||||
// assert( f != nullptr );
|
// assert( f != nullptr );
|
||||||
// memset(f, 0, sizeof(face_t));
|
// memset(f, 0, sizeof(face_t));
|
||||||
// return f;
|
// return f;
|
||||||
//}
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* free a face
|
* free a face
|
||||||
*/
|
*/
|
||||||
//static void face_free(face_t *f)
|
// static void face_free(face_t *f)
|
||||||
//{
|
//{
|
||||||
// assert( f != nullptr );
|
// assert( f != nullptr );
|
||||||
// free(f);
|
// free(f);
|
||||||
//}
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* compare 2 points when sorting
|
* compare 2 points when sorting
|
||||||
*/
|
*/
|
||||||
static auto cmp_points(const void *_pt0, const void *_pt1) -> int
|
static auto cmp_points(const void *_pt0, const void *_pt1) -> int
|
||||||
{
|
{
|
||||||
point2d_t *pt0, *pt1;
|
point2d_t *pt0, *pt1;
|
||||||
|
|
||||||
pt0 = (point2d_t*)(*((point2d_t**)_pt0));
|
pt0 = (point2d_t *)(*((point2d_t **)_pt0));
|
||||||
pt1 = (point2d_t*)(*((point2d_t**)_pt1));
|
pt1 = (point2d_t *)(*((point2d_t **)_pt1));
|
||||||
|
|
||||||
if( pt0->x < pt1->x )
|
if (pt0->x < pt1->x)
|
||||||
return -1;
|
return -1;
|
||||||
else if( pt0->x > pt1->x )
|
else if (pt0->x > pt1->x)
|
||||||
return 1;
|
return 1;
|
||||||
else if( pt0->y < pt1->y )
|
else if (pt0->y < pt1->y)
|
||||||
return -1;
|
return -1;
|
||||||
else if( pt0->y > pt1->y )
|
else if (pt0->y > pt1->y)
|
||||||
return 1;
|
return 1;
|
||||||
assert(0 && "2 or more points share the same exact coordinate");
|
assert(0 && "2 or more points share the same exact coordinate");
|
||||||
return 0; /* Should not be given! */
|
return 0; /* Should not be given! */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* classify a point relative to a segment
|
* classify a point relative to a segment
|
||||||
*/
|
*/
|
||||||
static auto classify_point_seg(point2d_t *s, point2d_t *e, point2d_t *pt) -> int
|
static auto classify_point_seg(point2d_t *s, point2d_t *e, point2d_t *pt) -> int
|
||||||
{
|
{
|
||||||
point2d_t se, spt;
|
point2d_t se, spt;
|
||||||
|
@ -262,18 +261,18 @@ static auto classify_point_seg(point2d_t *s, point2d_t *e, point2d_t *pt) -> int
|
||||||
spt.x = pt->x - s->x;
|
spt.x = pt->x - s->x;
|
||||||
spt.y = pt->y - s->y;
|
spt.y = pt->y - s->y;
|
||||||
|
|
||||||
res = (( se.x * spt.y ) - ( se.y * spt.x ));
|
res = ((se.x * spt.y) - (se.y * spt.x));
|
||||||
if( res < REAL_ZERO )
|
if (res < REAL_ZERO)
|
||||||
return ON_RIGHT;
|
return ON_RIGHT;
|
||||||
else if( res > REAL_ZERO )
|
else if (res > REAL_ZERO)
|
||||||
return ON_LEFT;
|
return ON_LEFT;
|
||||||
|
|
||||||
return ON_SEG;
|
return ON_SEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* classify a point relative to a halfedge, -1 is left, 0 is on, 1 is right
|
* classify a point relative to a halfedge, -1 is left, 0 is on, 1 is right
|
||||||
*/
|
*/
|
||||||
static auto del_classify_point(halfedge_t *d, point2d_t *pt) -> int
|
static auto del_classify_point(halfedge_t *d, point2d_t *pt) -> int
|
||||||
{
|
{
|
||||||
point2d_t *s, *e;
|
point2d_t *s, *e;
|
||||||
|
@ -285,20 +284,20 @@ static auto del_classify_point(halfedge_t *d, point2d_t *pt) -> int
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return the absolute value
|
* return the absolute value
|
||||||
*/
|
*/
|
||||||
//static real dabs( real a )
|
// static real dabs( real a )
|
||||||
//{
|
//{
|
||||||
// if( a < REAL_ZERO )
|
// if( a < REAL_ZERO )
|
||||||
// return (-a);
|
// return (-a);
|
||||||
// return a;
|
// return a;
|
||||||
//}
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* compute the circle given 3 points
|
* compute the circle given 3 points
|
||||||
*/
|
*/
|
||||||
#if PREDICATE == LOOSE_PREDICATE
|
#if PREDICATE == LOOSE_PREDICATE
|
||||||
static void compute_circle( point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, real *cx, real *cy, real *radius )
|
static void compute_circle(point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, real *cx, real *cy, real *radius)
|
||||||
{
|
{
|
||||||
mat3_t ma, mbx, mby, mc;
|
mat3_t ma, mbx, mby, mc;
|
||||||
real x0y0, x1y1, x2y2;
|
real x0y0, x1y1, x2y2;
|
||||||
|
@ -360,15 +359,15 @@ static void compute_circle( point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, real
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test if a point is inside a circle given by 3 points, 1 if inside, 0 if outside
|
* test if a point is inside a circle given by 3 points, 1 if inside, 0 if outside
|
||||||
*/
|
*/
|
||||||
static auto in_circle(point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, point2d_t *p) -> int
|
static auto in_circle(point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, point2d_t *p) -> int
|
||||||
{
|
{
|
||||||
#if PREDICATE == EXACT_PREDICATE
|
#if PREDICATE == EXACT_PREDICATE
|
||||||
real res = incircle(&(pt0->x), &(pt1->x), &(pt2->x), &(p->x));
|
real res = incircle(&(pt0->x), &(pt1->x), &(pt2->x), &(p->x));
|
||||||
if( res > REAL_ZERO )
|
if (res > REAL_ZERO)
|
||||||
return INSIDE;
|
return INSIDE;
|
||||||
else if( res < REAL_ZERO )
|
else if (res < REAL_ZERO)
|
||||||
return OUTSIDE;
|
return OUTSIDE;
|
||||||
|
|
||||||
return ON_CIRCLE;
|
return ON_CIRCLE;
|
||||||
|
@ -378,9 +377,9 @@ static auto in_circle(point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, point2d_t
|
||||||
compute_circle(pt0, pt1, pt2, &cx, &cy, &radius);
|
compute_circle(pt0, pt1, pt2, &cx, &cy, &radius);
|
||||||
|
|
||||||
real distance = sqrt((p->x - cx) * (p->x - cx) + (p->y - cy) * (p->y - cy));
|
real distance = sqrt((p->x - cx) * (p->x - cx) + (p->y - cy) * (p->y - cy));
|
||||||
if( distance < radius - EPSILON )
|
if (distance < radius - EPSILON)
|
||||||
return INSIDE;
|
return INSIDE;
|
||||||
else if(distance > radius + EPSILON )
|
else if (distance > radius + EPSILON)
|
||||||
return OUTSIDE;
|
return OUTSIDE;
|
||||||
return ON_CIRCLE;
|
return ON_CIRCLE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -438,12 +437,11 @@ static auto in_circle(point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, point2d_t
|
||||||
by = -det3(&mby);
|
by = -det3(&mby);
|
||||||
c = -det3(&mc);
|
c = -det3(&mc);
|
||||||
|
|
||||||
res = a * (p->x * p->x + p->y * p->y ) - bx * p->x - by * p->y + c;
|
res = a * (p->x * p->x + p->y * p->y) - bx * p->x - by * p->y + c;
|
||||||
|
|
||||||
|
if (res < REAL_ZERO)
|
||||||
if( res < REAL_ZERO )
|
|
||||||
return INSIDE;
|
return INSIDE;
|
||||||
else if( res > REAL_ZERO )
|
else if (res > REAL_ZERO)
|
||||||
return OUTSIDE;
|
return OUTSIDE;
|
||||||
|
|
||||||
return ON_CIRCLE;
|
return ON_CIRCLE;
|
||||||
|
@ -451,8 +449,8 @@ static auto in_circle(point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, point2d_t
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize delaunay segment
|
* initialize delaunay segment
|
||||||
*/
|
*/
|
||||||
static auto del_init_seg(delaunay_t *del, int start) -> int
|
static auto del_init_seg(delaunay_t *del, int start) -> int
|
||||||
{
|
{
|
||||||
halfedge_t *d0, *d1;
|
halfedge_t *d0, *d1;
|
||||||
|
@ -485,13 +483,12 @@ static auto del_init_seg(delaunay_t *del, int start) -> int
|
||||||
del->rightmost_he = d1;
|
del->rightmost_he = d1;
|
||||||
del->leftmost_he = d0;
|
del->leftmost_he = d0;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize delaunay triangle
|
* initialize delaunay triangle
|
||||||
*/
|
*/
|
||||||
static auto del_init_tri(delaunay_t *del, int start) -> int
|
static auto del_init_tri(delaunay_t *del, int start) -> int
|
||||||
{
|
{
|
||||||
halfedge_t *d0, *d1, *d2, *d3, *d4, *d5;
|
halfedge_t *d0, *d1, *d2, *d3, *d4, *d5;
|
||||||
|
@ -514,7 +511,7 @@ static auto del_init_tri(delaunay_t *del, int start) -> int
|
||||||
d4 = halfedge_alloc();
|
d4 = halfedge_alloc();
|
||||||
d5 = halfedge_alloc();
|
d5 = halfedge_alloc();
|
||||||
|
|
||||||
if( classify_point_seg(pt0, pt2, pt1) == ON_LEFT ) /* first case */
|
if (classify_point_seg(pt0, pt2, pt1) == ON_LEFT) /* first case */
|
||||||
{
|
{
|
||||||
/* set halfedges points */
|
/* set halfedges points */
|
||||||
d0->vertex = pt0;
|
d0->vertex = pt0;
|
||||||
|
@ -561,8 +558,8 @@ static auto del_init_tri(delaunay_t *del, int start) -> int
|
||||||
|
|
||||||
del->rightmost_he = d1;
|
del->rightmost_he = d1;
|
||||||
del->leftmost_he = d0;
|
del->leftmost_he = d0;
|
||||||
|
}
|
||||||
} else /* 2nd case */
|
else /* 2nd case */
|
||||||
{
|
{
|
||||||
/* set halfedges points */
|
/* set halfedges points */
|
||||||
d0->vertex = pt0;
|
d0->vertex = pt0;
|
||||||
|
@ -615,9 +612,9 @@ static auto del_init_tri(delaunay_t *del, int start) -> int
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* remove an edge given a halfedge
|
* remove an edge given a halfedge
|
||||||
*/
|
*/
|
||||||
static void del_remove_edge( halfedge_t *d )
|
static void del_remove_edge(halfedge_t *d)
|
||||||
{
|
{
|
||||||
halfedge_t *next, *prev, *pair, *orig_pair;
|
halfedge_t *next, *prev, *pair, *orig_pair;
|
||||||
|
|
||||||
|
@ -633,13 +630,12 @@ static void del_remove_edge( halfedge_t *d )
|
||||||
next->prev = prev;
|
next->prev = prev;
|
||||||
prev->next = next;
|
prev->next = next;
|
||||||
|
|
||||||
|
|
||||||
/* check to see if we have already removed pair */
|
/* check to see if we have already removed pair */
|
||||||
if( pair )
|
if (pair)
|
||||||
pair->pair = nullptr;
|
pair->pair = nullptr;
|
||||||
|
|
||||||
/* check to see if the vertex points to this halfedge */
|
/* check to see if the vertex points to this halfedge */
|
||||||
if( d->vertex->he == d )
|
if (d->vertex->he == d)
|
||||||
d->vertex->he = next;
|
d->vertex->he = next;
|
||||||
|
|
||||||
d->vertex = nullptr;
|
d->vertex = nullptr;
|
||||||
|
@ -657,13 +653,12 @@ static void del_remove_edge( halfedge_t *d )
|
||||||
next->prev = prev;
|
next->prev = prev;
|
||||||
prev->next = next;
|
prev->next = next;
|
||||||
|
|
||||||
|
|
||||||
/* check to see if we have already removed pair */
|
/* check to see if we have already removed pair */
|
||||||
if( pair )
|
if (pair)
|
||||||
pair->pair = nullptr;
|
pair->pair = nullptr;
|
||||||
|
|
||||||
/* check to see if the vertex points to this halfedge */
|
/* check to see if the vertex points to this halfedge */
|
||||||
if( orig_pair->vertex->he == orig_pair )
|
if (orig_pair->vertex->he == orig_pair)
|
||||||
orig_pair->vertex->he = next;
|
orig_pair->vertex->he = next;
|
||||||
|
|
||||||
orig_pair->vertex = nullptr;
|
orig_pair->vertex = nullptr;
|
||||||
|
@ -671,15 +666,14 @@ static void del_remove_edge( halfedge_t *d )
|
||||||
orig_pair->prev = nullptr;
|
orig_pair->prev = nullptr;
|
||||||
orig_pair->pair = nullptr;
|
orig_pair->pair = nullptr;
|
||||||
|
|
||||||
|
|
||||||
/* finally free the halfedges */
|
/* finally free the halfedges */
|
||||||
halfedge_free(d);
|
halfedge_free(d);
|
||||||
halfedge_free(orig_pair);
|
halfedge_free(orig_pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pass through all the halfedges on the left side and validate them
|
* pass through all the halfedges on the left side and validate them
|
||||||
*/
|
*/
|
||||||
static auto del_valid_left(halfedge_t *b) -> halfedge_t *
|
static auto del_valid_left(halfedge_t *b) -> halfedge_t *
|
||||||
{
|
{
|
||||||
point2d_t *g, *d, *u, *v;
|
point2d_t *g, *d, *u, *v;
|
||||||
|
@ -696,12 +690,12 @@ static auto del_valid_left(halfedge_t *b) -> halfedge_t *
|
||||||
|
|
||||||
v = b->next->pair->vertex; /* pair(next(next(halfedge)) point */
|
v = b->next->pair->vertex; /* pair(next(next(halfedge)) point */
|
||||||
|
|
||||||
if( classify_point_seg(g, d, u) == ON_LEFT )
|
if (classify_point_seg(g, d, u) == ON_LEFT)
|
||||||
{
|
{
|
||||||
/* 3 points aren't colinear */
|
/* 3 points aren't colinear */
|
||||||
/* as long as the 4 points belong to the same circle, do the cleaning */
|
/* as long as the 4 points belong to the same circle, do the cleaning */
|
||||||
assert( v != u && "1: floating point precision error");
|
assert(v != u && "1: floating point precision error");
|
||||||
while( v != d && v != g && in_circle(g, d, u, v) == INSIDE )
|
while (v != d && v != g && in_circle(g, d, u, v) == INSIDE)
|
||||||
{
|
{
|
||||||
c = b->next;
|
c = b->next;
|
||||||
du = b->next->pair;
|
du = b->next->pair;
|
||||||
|
@ -711,13 +705,14 @@ static auto del_valid_left(halfedge_t *b) -> halfedge_t *
|
||||||
v = b->next->pair->vertex;
|
v = b->next->pair->vertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert( v != u && "2: floating point precision error");
|
assert(v != u && "2: floating point precision error");
|
||||||
if( v != d && v != g && in_circle(g, d, u, v) == ON_CIRCLE )
|
if (v != d && v != g && in_circle(g, d, u, v) == ON_CIRCLE)
|
||||||
{
|
{
|
||||||
du = du->prev;
|
du = du->prev;
|
||||||
del_remove_edge(b);
|
del_remove_edge(b);
|
||||||
}
|
}
|
||||||
} else /* treat the case where the 3 points are colinear */
|
}
|
||||||
|
else /* treat the case where the 3 points are colinear */
|
||||||
du = dg;
|
du = dg;
|
||||||
|
|
||||||
assert(du->pair);
|
assert(du->pair);
|
||||||
|
@ -725,8 +720,8 @@ static auto del_valid_left(halfedge_t *b) -> halfedge_t *
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pass through all the halfedges on the right side and validate them
|
* pass through all the halfedges on the right side and validate them
|
||||||
*/
|
*/
|
||||||
static auto del_valid_right(halfedge_t *b) -> halfedge_t *
|
static auto del_valid_right(halfedge_t *b) -> halfedge_t *
|
||||||
{
|
{
|
||||||
point2d_t *rv, *lv, *u, *v;
|
point2d_t *rv, *lv, *u, *v;
|
||||||
|
@ -742,10 +737,10 @@ static auto del_valid_right(halfedge_t *b) -> halfedge_t *
|
||||||
|
|
||||||
v = b->prev->pair->vertex;
|
v = b->prev->pair->vertex;
|
||||||
|
|
||||||
if( classify_point_seg(lv, rv, u) == ON_LEFT )
|
if (classify_point_seg(lv, rv, u) == ON_LEFT)
|
||||||
{
|
{
|
||||||
assert( v != u && "1: floating point precision error");
|
assert(v != u && "1: floating point precision error");
|
||||||
while( v != lv && v != rv && in_circle(lv, rv, u, v) == INSIDE )
|
while (v != lv && v != rv && in_circle(lv, rv, u, v) == INSIDE)
|
||||||
{
|
{
|
||||||
c = b->prev;
|
c = b->prev;
|
||||||
du = c->pair;
|
du = c->pair;
|
||||||
|
@ -755,23 +750,23 @@ static auto del_valid_right(halfedge_t *b) -> halfedge_t *
|
||||||
v = b->prev->pair->vertex;
|
v = b->prev->pair->vertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert( v != u && "1: floating point precision error");
|
assert(v != u && "1: floating point precision error");
|
||||||
if( v != lv && v != rv && in_circle(lv, rv, u, v) == ON_CIRCLE )
|
if (v != lv && v != rv && in_circle(lv, rv, u, v) == ON_CIRCLE)
|
||||||
{
|
{
|
||||||
du = du->next;
|
du = du->next;
|
||||||
del_remove_edge(b);
|
del_remove_edge(b);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
du = dd;
|
du = dd;
|
||||||
|
|
||||||
assert(du->pair);
|
assert(du->pair);
|
||||||
return du;
|
return du;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* validate a link
|
* validate a link
|
||||||
*/
|
*/
|
||||||
static auto del_valid_link(halfedge_t *b) -> halfedge_t *
|
static auto del_valid_link(halfedge_t *b) -> halfedge_t *
|
||||||
{
|
{
|
||||||
point2d_t *g, *g_p, *d, *d_p;
|
point2d_t *g, *g_p, *d, *d_p;
|
||||||
|
@ -787,13 +782,13 @@ static auto del_valid_link(halfedge_t *b) -> halfedge_t *
|
||||||
d_p = dd->vertex;
|
d_p = dd->vertex;
|
||||||
assert(b->pair);
|
assert(b->pair);
|
||||||
|
|
||||||
if( g != g_p && d != d_p )
|
if (g != g_p && d != d_p)
|
||||||
{
|
{
|
||||||
int a = in_circle(g, d, g_p, d_p);
|
int a = in_circle(g, d, g_p, d_p);
|
||||||
|
|
||||||
if( a != ON_CIRCLE )
|
if (a != ON_CIRCLE)
|
||||||
{
|
{
|
||||||
if( a == INSIDE )
|
if (a == INSIDE)
|
||||||
{
|
{
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
g_p = g;
|
g_p = g;
|
||||||
|
@ -832,8 +827,8 @@ static auto del_valid_link(halfedge_t *b) -> halfedge_t *
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* find the lower tangent between the two delaunay, going from left to right (returns the left half edge)
|
* find the lower tangent between the two delaunay, going from left to right (returns the left half edge)
|
||||||
*/
|
*/
|
||||||
static auto del_get_lower_tangent(delaunay_t *left, delaunay_t *right) -> halfedge_t *
|
static auto del_get_lower_tangent(delaunay_t *left, delaunay_t *right) -> halfedge_t *
|
||||||
{
|
{
|
||||||
halfedge_t *right_d, *left_d, *new_ld, *new_rd;
|
halfedge_t *right_d, *left_d, *new_ld, *new_rd;
|
||||||
|
@ -842,19 +837,22 @@ static auto del_get_lower_tangent(delaunay_t *left, delaunay_t *right) -> halfed
|
||||||
left_d = left->rightmost_he;
|
left_d = left->rightmost_he;
|
||||||
right_d = right->leftmost_he;
|
right_d = right->leftmost_he;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
point2d_t *pl = left_d->prev->pair->vertex;
|
point2d_t *pl = left_d->prev->pair->vertex;
|
||||||
point2d_t *pr = right_d->pair->vertex;
|
point2d_t *pr = right_d->pair->vertex;
|
||||||
|
|
||||||
if( (sl = classify_point_seg(left_d->vertex, right_d->vertex, pl)) == ON_RIGHT ) {
|
if ((sl = classify_point_seg(left_d->vertex, right_d->vertex, pl)) == ON_RIGHT)
|
||||||
|
{
|
||||||
left_d = left_d->prev->pair;
|
left_d = left_d->prev->pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (sr = classify_point_seg(left_d->vertex, right_d->vertex, pr)) == ON_RIGHT ) {
|
if ((sr = classify_point_seg(left_d->vertex, right_d->vertex, pr)) == ON_RIGHT)
|
||||||
|
{
|
||||||
right_d = right_d->pair->next;
|
right_d = right_d->pair->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while( sl == ON_RIGHT || sr == ON_RIGHT );
|
} while (sl == ON_RIGHT || sr == ON_RIGHT);
|
||||||
|
|
||||||
/* create the 2 halfedges */
|
/* create the 2 halfedges */
|
||||||
new_ld = halfedge_alloc();
|
new_ld = halfedge_alloc();
|
||||||
|
@ -879,14 +877,14 @@ static auto del_get_lower_tangent(delaunay_t *left, delaunay_t *right) -> halfed
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* link the 2 delaunay together
|
* link the 2 delaunay together
|
||||||
*/
|
*/
|
||||||
static void del_link( delaunay_t *result, delaunay_t *left, delaunay_t *right )
|
static void del_link(delaunay_t *result, delaunay_t *left, delaunay_t *right)
|
||||||
{
|
{
|
||||||
point2d_t *u, *v, *ml, *mr;
|
point2d_t *u, *v, *ml, *mr;
|
||||||
halfedge_t *base;
|
halfedge_t *base;
|
||||||
|
|
||||||
assert( left->points == right->points );
|
assert(left->points == right->points);
|
||||||
|
|
||||||
/* save the most right point and the most left point */
|
/* save the most right point and the most left point */
|
||||||
ml = left->leftmost_he->vertex;
|
ml = left->leftmost_he->vertex;
|
||||||
|
@ -897,8 +895,7 @@ static void del_link( delaunay_t *result, delaunay_t *left, delaunay_t *right )
|
||||||
u = base->next->pair->vertex;
|
u = base->next->pair->vertex;
|
||||||
v = base->pair->prev->pair->vertex;
|
v = base->pair->prev->pair->vertex;
|
||||||
|
|
||||||
while( del_classify_point(base, u) == ON_LEFT ||
|
while (del_classify_point(base, u) == ON_LEFT || del_classify_point(base, v) == ON_LEFT)
|
||||||
del_classify_point(base, v) == ON_LEFT )
|
|
||||||
{
|
{
|
||||||
base = del_valid_link(base);
|
base = del_valid_link(base);
|
||||||
u = base->next->pair->vertex;
|
u = base->next->pair->vertex;
|
||||||
|
@ -909,10 +906,10 @@ static void del_link( delaunay_t *result, delaunay_t *left, delaunay_t *right )
|
||||||
left->leftmost_he = ml->he;
|
left->leftmost_he = ml->he;
|
||||||
|
|
||||||
/* TODO: this part is not needed, and can be optimized */
|
/* TODO: this part is not needed, and can be optimized */
|
||||||
while( del_classify_point( right->rightmost_he, right->rightmost_he->prev->pair->vertex ) == ON_RIGHT )
|
while (del_classify_point(right->rightmost_he, right->rightmost_he->prev->pair->vertex) == ON_RIGHT)
|
||||||
right->rightmost_he = right->rightmost_he->prev;
|
right->rightmost_he = right->rightmost_he->prev;
|
||||||
|
|
||||||
while( del_classify_point( left->leftmost_he, left->leftmost_he->prev->pair->vertex ) == ON_RIGHT )
|
while (del_classify_point(left->leftmost_he, left->leftmost_he->prev->pair->vertex) == ON_RIGHT)
|
||||||
left->leftmost_he = left->leftmost_he->prev;
|
left->leftmost_he = left->leftmost_he->prev;
|
||||||
|
|
||||||
result->leftmost_he = left->leftmost_he;
|
result->leftmost_he = left->leftmost_he;
|
||||||
|
@ -923,54 +920,54 @@ static void del_link( delaunay_t *result, delaunay_t *left, delaunay_t *right )
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* divide and conquer delaunay
|
* divide and conquer delaunay
|
||||||
*/
|
*/
|
||||||
void del_divide_and_conquer( delaunay_t *del, int start, int end );
|
void del_divide_and_conquer(delaunay_t *del, int start, int end);
|
||||||
void del_divide_and_conquer( delaunay_t *del, int start, int end )
|
void del_divide_and_conquer(delaunay_t *del, int start, int end)
|
||||||
{
|
{
|
||||||
delaunay_t left, right;
|
delaunay_t left, right;
|
||||||
|
|
||||||
int n = (end - start + 1);
|
int n = (end - start + 1);
|
||||||
|
|
||||||
if( n > 3 )
|
if (n > 3)
|
||||||
{
|
{
|
||||||
int i = (n / 2) + (n & 1);
|
int i = (n / 2) + (n & 1);
|
||||||
left.points = del->points;
|
left.points = del->points;
|
||||||
right.points = del->points;
|
right.points = del->points;
|
||||||
del_divide_and_conquer( &left, start, start + i - 1 );
|
del_divide_and_conquer(&left, start, start + i - 1);
|
||||||
del_divide_and_conquer( &right, start + i, end );
|
del_divide_and_conquer(&right, start + i, end);
|
||||||
del_link( del, &left, &right );
|
del_link(del, &left, &right);
|
||||||
} else
|
}
|
||||||
if( n == 3 )
|
else if (n == 3)
|
||||||
del_init_tri( del, start );
|
del_init_tri(del, start);
|
||||||
else
|
else if (n == 2)
|
||||||
if( n == 2 )
|
del_init_seg(del, start);
|
||||||
del_init_seg( del, start );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void build_halfedge_face( delaunay_t *del, halfedge_t *d )
|
static void build_halfedge_face(delaunay_t *del, halfedge_t *d)
|
||||||
{
|
{
|
||||||
halfedge_t *curr;
|
halfedge_t *curr;
|
||||||
|
|
||||||
/* test if the halfedge has already a pointing face */
|
/* test if the halfedge has already a pointing face */
|
||||||
if( d->face != nullptr )
|
if (d->face != nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
del->faces = (face_t*)realloc(del->faces, (del->num_faces + 1) * sizeof(face_t));
|
del->faces = (face_t *)realloc(del->faces, (del->num_faces + 1) * sizeof(face_t));
|
||||||
|
|
||||||
face_t *f = &(del->faces[del->num_faces]);
|
face_t *f = &(del->faces[del->num_faces]);
|
||||||
curr = d;
|
curr = d;
|
||||||
f->he = d;
|
f->he = d;
|
||||||
f->num_verts = 0;
|
f->num_verts = 0;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
curr->face = f;
|
curr->face = f;
|
||||||
(f->num_verts)++;
|
(f->num_verts)++;
|
||||||
curr = curr->pair->prev;
|
curr = curr->pair->prev;
|
||||||
} while( curr != d );
|
} while (curr != d);
|
||||||
|
|
||||||
(del->num_faces)++;
|
(del->num_faces)++;
|
||||||
|
|
||||||
/* if( d->face.radius < 0.0 )
|
/* if( d->face.radius < 0.0 )
|
||||||
{
|
{
|
||||||
d->face.p[0] = d->vertex;
|
d->face.p[0] = d->vertex;
|
||||||
d->face.p[1] = d->pair->vertex;
|
d->face.p[1] = d->pair->vertex;
|
||||||
|
@ -978,17 +975,18 @@ static void build_halfedge_face( delaunay_t *del, halfedge_t *d )
|
||||||
|
|
||||||
if( classify_point_seg( d->face.p[0], d->face.p[1], d->face.p[2] ) == ON_LEFT )
|
if( classify_point_seg( d->face.p[0], d->face.p[1], d->face.p[2] ) == ON_LEFT )
|
||||||
{
|
{
|
||||||
compute_circle(d->face.p[0], d->face.p[1], d->face.p[2], &(d->face.cx), &(d->face.cy), &(d->face.radius));
|
compute_circle(d->face.p[0], d->face.p[1], d->face.p[2], &(d->face.cx), &(d->face.cy),
|
||||||
|
&(d->face.radius));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* build the faces for all the halfedge
|
* build the faces for all the halfedge
|
||||||
*/
|
*/
|
||||||
void del_build_faces( delaunay_t *del );
|
void del_build_faces(delaunay_t *del);
|
||||||
void del_build_faces( delaunay_t *del )
|
void del_build_faces(delaunay_t *del)
|
||||||
{
|
{
|
||||||
quint32 i;
|
quint32 i;
|
||||||
halfedge_t *curr;
|
halfedge_t *curr;
|
||||||
|
@ -999,39 +997,40 @@ void del_build_faces( delaunay_t *del )
|
||||||
/* build external face first */
|
/* build external face first */
|
||||||
build_halfedge_face(del, del->rightmost_he->pair);
|
build_halfedge_face(del, del->rightmost_he->pair);
|
||||||
|
|
||||||
for( i = del->start_point; i <= del->end_point; i++ )
|
for (i = del->start_point; i <= del->end_point; i++)
|
||||||
{
|
{
|
||||||
curr = del->points[i]->he;
|
curr = del->points[i]->he;
|
||||||
|
|
||||||
do {
|
do
|
||||||
build_halfedge_face( del, curr );
|
{
|
||||||
|
build_halfedge_face(del, curr);
|
||||||
curr = curr->next;
|
curr = curr->next;
|
||||||
} while( curr != del->points[i]->he );
|
} while (curr != del->points[i]->he);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
auto delaunay2d_from(del_point2d_t *points, quint32 num_points) -> delaunay2d_t *
|
auto delaunay2d_from(del_point2d_t *points, quint32 num_points) -> delaunay2d_t *
|
||||||
{
|
{
|
||||||
delaunay2d_t* res = nullptr;
|
delaunay2d_t *res = nullptr;
|
||||||
delaunay_t del;
|
delaunay_t del;
|
||||||
quint32 i;
|
quint32 i;
|
||||||
quint32* faces = nullptr;
|
quint32 *faces = nullptr;
|
||||||
|
|
||||||
del.num_faces = 0; //Warning using uninitialized value
|
del.num_faces = 0; // Warning using uninitialized value
|
||||||
|
|
||||||
#if PREDICATE == EXACT_PREDICATE
|
#if PREDICATE == EXACT_PREDICATE
|
||||||
exactinit();
|
exactinit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* allocate the points */
|
/* allocate the points */
|
||||||
del.points = (point2d_t**)malloc(num_points * sizeof(point2d_t*));
|
del.points = (point2d_t **)malloc(num_points * sizeof(point2d_t *));
|
||||||
assert( del.points != nullptr );
|
assert(del.points != nullptr);
|
||||||
memset(del.points, 0, num_points * sizeof(point2d_t*));
|
memset(del.points, 0, num_points * sizeof(point2d_t *));
|
||||||
|
|
||||||
/* copy the points */
|
/* copy the points */
|
||||||
for( i = 0; i < num_points; i++ )
|
for (i = 0; i < num_points; i++)
|
||||||
{
|
{
|
||||||
del.points[i] = point_alloc();
|
del.points[i] = point_alloc();
|
||||||
del.points[i]->idx = i;
|
del.points[i]->idx = i;
|
||||||
|
@ -1039,21 +1038,22 @@ auto delaunay2d_from(del_point2d_t *points, quint32 num_points) -> delaunay2d_t
|
||||||
del.points[i]->y = points[i].y;
|
del.points[i]->y = points[i].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort(del.points, num_points, sizeof(point2d_t*), cmp_points);
|
qsort(del.points, num_points, sizeof(point2d_t *), cmp_points);
|
||||||
|
|
||||||
if( num_points >= 3 ) {
|
if (num_points >= 3)
|
||||||
|
{
|
||||||
quint32 fbuff_size = 0;
|
quint32 fbuff_size = 0;
|
||||||
quint32 j = 0;
|
quint32 j = 0;
|
||||||
|
|
||||||
del_divide_and_conquer( &del, 0, static_cast<int>(num_points - 1) );
|
del_divide_and_conquer(&del, 0, static_cast<int>(num_points - 1));
|
||||||
del_build_faces( &del );
|
del_build_faces(&del);
|
||||||
|
|
||||||
for( i = 0; i < del.num_faces; i++ )
|
for (i = 0; i < del.num_faces; i++)
|
||||||
fbuff_size += del.faces[i].num_verts + 1;
|
fbuff_size += del.faces[i].num_verts + 1;
|
||||||
|
|
||||||
faces = (quint32*)malloc(sizeof(quint32) * fbuff_size);
|
faces = (quint32 *)malloc(sizeof(quint32) * fbuff_size);
|
||||||
|
|
||||||
for( i = 0; i < del.num_faces; i++ )
|
for (i = 0; i < del.num_faces; i++)
|
||||||
{
|
{
|
||||||
halfedge_t *curr;
|
halfedge_t *curr;
|
||||||
|
|
||||||
|
@ -1061,25 +1061,26 @@ auto delaunay2d_from(del_point2d_t *points, quint32 num_points) -> delaunay2d_t
|
||||||
j++;
|
j++;
|
||||||
|
|
||||||
curr = del.faces[i].he;
|
curr = del.faces[i].he;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
faces[j] = curr->vertex->idx;
|
faces[j] = curr->vertex->idx;
|
||||||
j++;
|
j++;
|
||||||
curr = curr->pair->prev;
|
curr = curr->pair->prev;
|
||||||
} while( curr != del.faces[i].he );
|
} while (curr != del.faces[i].he);
|
||||||
}
|
}
|
||||||
|
|
||||||
del_free_halfedges( &del );
|
del_free_halfedges(&del);
|
||||||
|
|
||||||
free(del.faces);
|
free(del.faces);
|
||||||
for( i = 0; i < num_points; i++ )
|
for (i = 0; i < num_points; i++)
|
||||||
point_free(del.points[i]);
|
point_free(del.points[i]);
|
||||||
|
|
||||||
free(del.points);
|
free(del.points);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = (delaunay2d_t*)malloc(sizeof(delaunay2d_t));
|
res = (delaunay2d_t *)malloc(sizeof(delaunay2d_t));
|
||||||
res->num_points = num_points;
|
res->num_points = num_points;
|
||||||
res->points = (del_point2d_t*)malloc(sizeof(del_point2d_t) * num_points);
|
res->points = (del_point2d_t *)malloc(sizeof(del_point2d_t) * num_points);
|
||||||
memcpy(res->points, points, sizeof(del_point2d_t) * num_points);
|
memcpy(res->points, points, sizeof(del_point2d_t) * num_points);
|
||||||
res->num_faces = del.num_faces;
|
res->num_faces = del.num_faces;
|
||||||
res->faces = faces;
|
res->faces = faces;
|
||||||
|
@ -1087,7 +1088,8 @@ auto delaunay2d_from(del_point2d_t *points, quint32 num_points) -> delaunay2d_t
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void delaunay2d_release(delaunay2d_t *del) {
|
void delaunay2d_release(delaunay2d_t *del)
|
||||||
|
{
|
||||||
free(del->faces);
|
free(del->faces);
|
||||||
free(del->points);
|
free(del->points);
|
||||||
free(del);
|
free(del);
|
||||||
|
|
|
@ -107,10 +107,6 @@
|
||||||
|
|
||||||
#include <QtGlobal>
|
#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_PUSH
|
||||||
QT_WARNING_DISABLE_MSVC(4701)
|
QT_WARNING_DISABLE_MSVC(4701)
|
||||||
// cppcheck-suppress unknownMacro
|
// cppcheck-suppress unknownMacro
|
||||||
|
@ -153,7 +149,6 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
|
||||||
#define Absolute(a) ((a) >= 0.0 ? (a) : -(a))
|
#define Absolute(a) ((a) >= 0.0 ? (a) : -(a))
|
||||||
/* #define Absolute(a) fabs(a) */
|
/* #define Absolute(a) fabs(a) */
|
||||||
|
|
||||||
|
|
||||||
/* Many of the operations are broken up into two pieces, a main part that */
|
/* Many of the operations are broken up into two pieces, a main part that */
|
||||||
/* performs an approximate operation, and a "tail" that computes the */
|
/* performs an approximate operation, and a "tail" that computes the */
|
||||||
/* roundoff error of that operation. */
|
/* roundoff error of that operation. */
|
||||||
|
@ -172,34 +167,34 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
|
||||||
y = b - bvirt
|
y = b - bvirt
|
||||||
|
|
||||||
#define Fast_Two_Sum(a, b, x, y) \
|
#define Fast_Two_Sum(a, b, x, y) \
|
||||||
x = (qreal) (a + b); \
|
x = (qreal)(a + b); \
|
||||||
Fast_Two_Sum_Tail(a, b, x, y)
|
Fast_Two_Sum_Tail(a, b, x, y)
|
||||||
|
|
||||||
#define Two_Sum_Tail(a, b, x, y) \
|
#define Two_Sum_Tail(a, b, x, y) \
|
||||||
bvirt = (qreal) (x - a); \
|
bvirt = (qreal)(x - a); \
|
||||||
avirt = x - bvirt; \
|
avirt = x - bvirt; \
|
||||||
bround = b - bvirt; \
|
bround = b - bvirt; \
|
||||||
around = a - avirt; \
|
around = a - avirt; \
|
||||||
y = around + bround
|
y = around + bround
|
||||||
|
|
||||||
#define Two_Sum(a, b, x, y) \
|
#define Two_Sum(a, b, x, y) \
|
||||||
x = (qreal) (a + b); \
|
x = (qreal)(a + b); \
|
||||||
Two_Sum_Tail(a, b, x, y)
|
Two_Sum_Tail(a, b, x, y)
|
||||||
|
|
||||||
#define Two_Diff_Tail(a, b, x, y) \
|
#define Two_Diff_Tail(a, b, x, y) \
|
||||||
bvirt = (qreal) (a - x); \
|
bvirt = (qreal)(a - x); \
|
||||||
avirt = x + bvirt; \
|
avirt = x + bvirt; \
|
||||||
bround = bvirt - b; \
|
bround = bvirt - b; \
|
||||||
around = a - avirt; \
|
around = a - avirt; \
|
||||||
y = around + bround
|
y = around + bround
|
||||||
|
|
||||||
#define Two_Diff(a, b, x, y) \
|
#define Two_Diff(a, b, x, y) \
|
||||||
x = (qreal) (a - b); \
|
x = (qreal)(a - b); \
|
||||||
Two_Diff_Tail(a, b, x, y)
|
Two_Diff_Tail(a, b, x, y)
|
||||||
|
|
||||||
#define Split(a, ahi, alo) \
|
#define Split(a, ahi, alo) \
|
||||||
c = (qreal) (splitter * a); \
|
c = (qreal)(splitter * a); \
|
||||||
abig = (qreal) (c - a); \
|
abig = (qreal)(c - a); \
|
||||||
ahi = c - abig; \
|
ahi = c - abig; \
|
||||||
alo = a - ahi
|
alo = a - ahi
|
||||||
|
|
||||||
|
@ -212,14 +207,14 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
|
||||||
y = (alo * blo) - err3
|
y = (alo * blo) - err3
|
||||||
|
|
||||||
#define Two_Product(a, b, x, y) \
|
#define Two_Product(a, b, x, y) \
|
||||||
x = (qreal) (a * b); \
|
x = (qreal)(a * b); \
|
||||||
Two_Product_Tail(a, b, x, y)
|
Two_Product_Tail(a, b, x, y)
|
||||||
|
|
||||||
/* Two_Product_Presplit() is Two_Product() where one of the inputs has */
|
/* Two_Product_Presplit() is Two_Product() where one of the inputs has */
|
||||||
/* already been split. Avoids redundant splitting. */
|
/* already been split. Avoids redundant splitting. */
|
||||||
|
|
||||||
#define Two_Product_Presplit(a, b, bhi, blo, x, y) \
|
#define Two_Product_Presplit(a, b, bhi, blo, x, y) \
|
||||||
x = (qreal) (a * b); \
|
x = (qreal)(a * b); \
|
||||||
Split(a, ahi, alo); \
|
Split(a, ahi, alo); \
|
||||||
err1 = x - (ahi * bhi); \
|
err1 = x - (ahi * bhi); \
|
||||||
err2 = err1 - (alo * bhi); \
|
err2 = err1 - (alo * bhi); \
|
||||||
|
@ -235,19 +230,19 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
|
||||||
y = (alo * alo) - err3
|
y = (alo * alo) - err3
|
||||||
|
|
||||||
#define Square(a, x, y) \
|
#define Square(a, x, y) \
|
||||||
x = (qreal) (a * a); \
|
x = (qreal)(a * a); \
|
||||||
Square_Tail(a, x, y)
|
Square_Tail(a, x, y)
|
||||||
|
|
||||||
/* Macros for summing expansions of various fixed lengths. These are all */
|
/* Macros for summing expansions of various fixed lengths. These are all */
|
||||||
/* unrolled versions of Expansion_Sum(). */
|
/* unrolled versions of Expansion_Sum(). */
|
||||||
|
|
||||||
#define Two_One_Sum(a1, a0, b, x2, x1, x0) \
|
#define Two_One_Sum(a1, a0, b, x2, x1, x0) \
|
||||||
Two_Sum(a0, b , _i, x0); \
|
Two_Sum(a0, b, _i, x0); \
|
||||||
Two_Sum(a1, _i, x2, x1)
|
Two_Sum(a1, _i, x2, x1)
|
||||||
|
|
||||||
#define Two_One_Diff(a1, a0, b, x2, x1, x0) \
|
#define Two_One_Diff(a1, a0, b, x2, x1, x0) \
|
||||||
Two_Diff(a0, b , _i, x0); \
|
Two_Diff(a0, b, _i, x0); \
|
||||||
Two_Sum( a1, _i, x2, x1)
|
Two_Sum(a1, _i, x2, x1)
|
||||||
|
|
||||||
#define Two_Two_Sum(a1, a0, b1, b0, x3, x2, x1, x0) \
|
#define Two_Two_Sum(a1, a0, b1, b0, x3, x2, x1, x0) \
|
||||||
Two_One_Sum(a1, a0, b0, _j, _0, x0); \
|
Two_One_Sum(a1, a0, b0, _j, _0, x0); \
|
||||||
|
@ -463,7 +458,8 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
|
||||||
Split(b, bhi, blo);
|
Split(b, bhi, blo);
|
||||||
Two_Product_Presplit(e[0], b, bhi, blo, Q, hh);
|
Two_Product_Presplit(e[0], b, bhi, blo, Q, hh);
|
||||||
hindex = 0;
|
hindex = 0;
|
||||||
if (hh != 0) {
|
if (hh != 0)
|
||||||
|
{
|
||||||
h[hindex++] = hh;
|
h[hindex++] = hh;
|
||||||
}
|
}
|
||||||
for (eindex = 1; eindex < elen; eindex++)
|
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;
|
INEXACT qreal _i, _j;
|
||||||
qreal _0;
|
qreal _0;
|
||||||
|
|
||||||
adx = (qreal) (pa[0] - pd[0]);
|
adx = (qreal)(pa[0] - pd[0]);
|
||||||
bdx = (qreal) (pb[0] - pd[0]);
|
bdx = (qreal)(pb[0] - pd[0]);
|
||||||
cdx = (qreal) (pc[0] - pd[0]);
|
cdx = (qreal)(pc[0] - pd[0]);
|
||||||
ady = (qreal) (pa[1] - pd[1]);
|
ady = (qreal)(pa[1] - pd[1]);
|
||||||
bdy = (qreal) (pb[1] - pd[1]);
|
bdy = (qreal)(pb[1] - pd[1]);
|
||||||
cdy = (qreal) (pc[1] - pd[1]);
|
cdy = (qreal)(pc[1] - pd[1]);
|
||||||
|
|
||||||
Two_Product(bdx, cdy, bdxcdy1, bdxcdy0);
|
Two_Product(bdx, cdy, bdxcdy1, bdxcdy0);
|
||||||
Two_Product(cdx, bdy, cdxbdy1, cdxbdy0);
|
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(pb[1], pd[1], bdy, bdytail);
|
||||||
Two_Diff_Tail(pc[0], pd[0], cdx, cdxtail);
|
Two_Diff_Tail(pc[0], pd[0], cdx, cdxtail);
|
||||||
Two_Diff_Tail(pc[1], pd[1], cdy, cdytail);
|
Two_Diff_Tail(pc[1], pd[1], cdy, cdytail);
|
||||||
if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0)
|
if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0) && (adytail == 0.0) && (bdytail == 0.0) &&
|
||||||
&& (adytail == 0.0) && (bdytail == 0.0) && (cdytail == 0.0))
|
(cdytail == 0.0))
|
||||||
{
|
{
|
||||||
return det;
|
return det;
|
||||||
}
|
}
|
||||||
|
|
||||||
errbound = iccerrboundC * permanent + resulterrbound * Absolute(det);
|
errbound = iccerrboundC * permanent + resulterrbound * Absolute(det);
|
||||||
det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail) - (bdy * cdxtail + cdx * bdytail))
|
det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail) - (bdy * cdxtail + cdx * bdytail)) +
|
||||||
+ 2.0 * (adx * adxtail + ady * adytail) * (bdx * cdy - bdy * cdx))
|
2.0 * (adx * adxtail + ady * adytail) * (bdx * cdy - bdy * cdx)) +
|
||||||
+ ((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail) - (cdy * adxtail + adx * cdytail))
|
((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail) - (cdy * adxtail + adx * cdytail)) +
|
||||||
+ 2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx))
|
2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx)) +
|
||||||
+ ((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - (ady * bdxtail + bdx * adytail))
|
((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - (ady * bdxtail + bdx * adytail)) +
|
||||||
+ 2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx));
|
2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx));
|
||||||
if ((det >= errbound) || (-det >= errbound))
|
if ((det >= errbound) || (-det >= errbound))
|
||||||
{
|
{
|
||||||
return det;
|
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);
|
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
||||||
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
|
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)
|
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);
|
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
||||||
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
|
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)
|
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);
|
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
||||||
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
|
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)
|
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);
|
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
||||||
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
|
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)
|
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);
|
cxtaalen = scale_expansion_zeroelim(4, aa, cdxtail, cxtaa);
|
||||||
temp16clen = scale_expansion_zeroelim(cxtaalen, cxtaa, -bdy, temp16c);
|
temp16clen = scale_expansion_zeroelim(cxtaalen, cxtaa, -bdy, temp16c);
|
||||||
|
|
||||||
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a,
|
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
||||||
temp16blen, temp16b, temp32a);
|
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
||||||
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c,
|
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
|
||||||
temp32alen, temp32a, temp48);
|
finswap = finnow;
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len,
|
finnow = finother;
|
||||||
temp48, finother);
|
finother = finswap;
|
||||||
finswap = finnow; finnow = finother; finother = finswap;
|
|
||||||
}
|
}
|
||||||
if (cdytail != 0.0)
|
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);
|
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
||||||
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
|
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))
|
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);
|
temp32alen = scale_expansion_zeroelim(axtbctlen, axtbct, 2.0 * adx, temp32a);
|
||||||
temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
|
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)
|
if (bdytail != 0.0)
|
||||||
{
|
{
|
||||||
temp8len = scale_expansion_zeroelim(4, cc, adxtail, temp8);
|
temp8len = scale_expansion_zeroelim(4, cc, adxtail, temp8);
|
||||||
temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a);
|
temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother);
|
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)
|
if (cdytail != 0.0)
|
||||||
{
|
{
|
||||||
temp8len = scale_expansion_zeroelim(4, bb, -adxtail, temp8);
|
temp8len = scale_expansion_zeroelim(4, bb, -adxtail, temp8);
|
||||||
temp16alen = scale_expansion_zeroelim(temp8len, temp8, cdytail, temp16a);
|
temp16alen = scale_expansion_zeroelim(temp8len, temp8, cdytail, temp16a);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother);
|
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);
|
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);
|
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
||||||
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
|
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)
|
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);
|
temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, 2.0 * ady, temp32a);
|
||||||
temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
|
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);
|
temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, adytail, temp32a);
|
||||||
aytbcttlen = scale_expansion_zeroelim(bcttlen, bctt, adytail, aytbctt);
|
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);
|
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
||||||
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
|
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))
|
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);
|
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
||||||
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
|
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)
|
if (bdytail != 0.0)
|
||||||
{
|
{
|
||||||
|
@ -936,7 +954,6 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
|
||||||
finnow = finother;
|
finnow = finother;
|
||||||
finother = finswap;
|
finother = finswap;
|
||||||
|
|
||||||
|
|
||||||
temp32alen = scale_expansion_zeroelim(bytcatlen, bytcat, bdytail, temp32a);
|
temp32alen = scale_expansion_zeroelim(bytcatlen, bytcat, bdytail, temp32a);
|
||||||
bytcattlen = scale_expansion_zeroelim(cattlen, catt, bdytail, bytcatt);
|
bytcattlen = scale_expansion_zeroelim(cattlen, catt, bdytail, bytcatt);
|
||||||
temp16alen = scale_expansion_zeroelim(bytcattlen, bytcatt, 2.0 * bdy, temp16a);
|
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);
|
temp8len = scale_expansion_zeroelim(4, aa, -cdxtail, temp8);
|
||||||
temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a);
|
temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother);
|
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);
|
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;
|
finnow = finother;
|
||||||
finother = finswap;
|
finother = finswap;
|
||||||
|
|
||||||
|
|
||||||
temp32alen = scale_expansion_zeroelim(cytabtlen, cytabt, cdytail, temp32a);
|
temp32alen = scale_expansion_zeroelim(cytabtlen, cytabt, cdytail, temp32a);
|
||||||
cytabttlen = scale_expansion_zeroelim(abttlen, abtt, cdytail, cytabtt);
|
cytabttlen = scale_expansion_zeroelim(abttlen, abtt, cdytail, cytabtt);
|
||||||
temp16alen = scale_expansion_zeroelim(cytabttlen, cytabtt, 2.0 * cdy, temp16a);
|
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);
|
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
||||||
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
||||||
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
|
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;
|
bdxady = bdx * ady;
|
||||||
clift = cdx * cdx + cdy * cdy;
|
clift = cdx * cdx + cdy * cdy;
|
||||||
|
|
||||||
det = alift * (bdxcdy - cdxbdy)
|
det = alift * (bdxcdy - cdxbdy) + blift * (cdxady - adxcdy) + clift * (adxbdy - bdxady);
|
||||||
+ blift * (cdxady - adxcdy)
|
|
||||||
+ clift * (adxbdy - bdxady);
|
|
||||||
|
|
||||||
permanent = (Absolute(bdxcdy) + Absolute(cdxbdy)) * alift
|
permanent = (Absolute(bdxcdy) + Absolute(cdxbdy)) * alift + (Absolute(cdxady) + Absolute(adxcdy)) * blift +
|
||||||
+ (Absolute(cdxady) + Absolute(adxcdy)) * blift
|
(Absolute(adxbdy) + Absolute(bdxady)) * clift;
|
||||||
+ (Absolute(adxbdy) + Absolute(bdxady)) * clift;
|
|
||||||
errbound = iccerrboundA * permanent;
|
errbound = iccerrboundA * permanent;
|
||||||
if ((det > errbound) || (-det > errbound))
|
if ((det > errbound) || (-det > errbound))
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,7 +37,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VObjPaintDevice::VObjPaintDevice()
|
VObjPaintDevice::VObjPaintDevice()
|
||||||
:QPaintDevice(), engine(new VObjEngine()), fileName(), owns_iodevice(1)
|
: QPaintDevice(),
|
||||||
|
engine(new VObjEngine()),
|
||||||
|
fileName(),
|
||||||
|
owns_iodevice(1)
|
||||||
{
|
{
|
||||||
owns_iodevice = static_cast<int>(false);
|
owns_iodevice = static_cast<int>(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ auto GetSeamPassmarkSAPoint(const VPiecePassmarkData &passmarkData, const QVecto
|
||||||
if (needRollback && not seamAllowance.isEmpty())
|
if (needRollback && not seamAllowance.isEmpty())
|
||||||
{
|
{
|
||||||
ekvPoints.clear();
|
ekvPoints.clear();
|
||||||
ekvPoints += VRawSAPoint(seamAllowance.at(seamAllowance.size()-1));
|
ekvPoints += VRawSAPoint(seamAllowance.at(seamAllowance.size() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ekvPoints.isEmpty())
|
if (ekvPoints.isEmpty())
|
||||||
|
@ -80,9 +80,9 @@ auto PointsToSegments(const QVector<QPointF> &points) -> QVector<QLineF>
|
||||||
if (points.size() >= 2)
|
if (points.size() >= 2)
|
||||||
{
|
{
|
||||||
lines.reserve(points.size() - 1);
|
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)
|
if (segment.length() > 0)
|
||||||
{
|
{
|
||||||
lines.append(segment);
|
lines.append(segment);
|
||||||
|
@ -608,11 +608,10 @@ VPassmark::VPassmark(const VPiecePassmarkData &data)
|
||||||
m_null(false)
|
m_null(false)
|
||||||
{
|
{
|
||||||
// Correct distorsion
|
// Correct distorsion
|
||||||
if (VGObject::IsPointOnLineSegment(m_data.passmarkSAPoint, m_data.previousSAPoint,
|
if (VGObject::IsPointOnLineSegment(m_data.passmarkSAPoint, m_data.previousSAPoint, m_data.nextSAPoint))
|
||||||
m_data.nextSAPoint))
|
|
||||||
{
|
{
|
||||||
const QPointF p = VGObject::CorrectDistortion(m_data.passmarkSAPoint, m_data.previousSAPoint,
|
const QPointF p =
|
||||||
m_data.nextSAPoint);
|
VGObject::CorrectDistortion(m_data.passmarkSAPoint, m_data.previousSAPoint, m_data.nextSAPoint);
|
||||||
m_data.passmarkSAPoint.setX(p.x());
|
m_data.passmarkSAPoint.setX(p.x());
|
||||||
m_data.passmarkSAPoint.setY(p.y());
|
m_data.passmarkSAPoint.setY(p.y());
|
||||||
}
|
}
|
||||||
|
@ -630,16 +629,14 @@ auto VPassmark::FullPassmark(const VPiece &piece, const VContainer *data) const
|
||||||
{
|
{
|
||||||
QVector<QLineF> lines;
|
QVector<QLineF> lines;
|
||||||
lines += SAPassmark(piece, data, PassmarkSide::All);
|
lines += SAPassmark(piece, data, PassmarkSide::All);
|
||||||
if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark()
|
if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark() &&
|
||||||
&& (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath())
|
(VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath()) &&
|
||||||
&& m_data.isMainPathNode
|
m_data.isMainPathNode && m_data.passmarkAngleType != PassmarkAngleType::Intersection &&
|
||||||
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection
|
m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft &&
|
||||||
&& m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft
|
m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyRight &&
|
||||||
&& m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyRight
|
m_data.passmarkAngleType != PassmarkAngleType::Intersection2 &&
|
||||||
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection2
|
m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyLeft &&
|
||||||
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyLeft
|
m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight && m_data.isShowSecondPassmark)
|
||||||
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight
|
|
||||||
&& m_data.isShowSecondPassmark)
|
|
||||||
{
|
{
|
||||||
lines += BuiltInSAPassmark(piece, data);
|
lines += BuiltInSAPassmark(piece, data);
|
||||||
}
|
}
|
||||||
|
@ -713,7 +710,7 @@ auto VPassmark::Data() const -> VPiecePassmarkData
|
||||||
auto VPassmark::FindIntersection(const QLineF &line, const QVector<QPointF> &seamAllowance) -> QLineF
|
auto VPassmark::FindIntersection(const QLineF &line, const QVector<QPointF> &seamAllowance) -> QLineF
|
||||||
{
|
{
|
||||||
QLineF testLine = line;
|
QLineF testLine = line;
|
||||||
testLine.setLength(testLine.length()*10);
|
testLine.setLength(testLine.length() * 10);
|
||||||
QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(seamAllowance, testLine);
|
QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(seamAllowance, testLine);
|
||||||
if (not intersections.isEmpty())
|
if (not intersections.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -952,7 +949,7 @@ auto VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const -> QVector<
|
||||||
QLineF edge1 = QLineF(m_data.passmarkSAPoint, m_data.previousSAPoint);
|
QLineF edge1 = QLineF(m_data.passmarkSAPoint, m_data.previousSAPoint);
|
||||||
QLineF edge2 = QLineF(m_data.passmarkSAPoint, m_data.nextSAPoint);
|
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);
|
edge1.setLength(length);
|
||||||
|
|
||||||
return {edge1};
|
return {edge1};
|
||||||
|
@ -994,9 +991,11 @@ auto VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowance, const
|
||||||
if (rotatedSeamAllowance.size() < 2)
|
if (rotatedSeamAllowance.size() < 2)
|
||||||
{
|
{
|
||||||
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Seam allowance is "
|
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);
|
"empty.")
|
||||||
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
|
.arg(m_data.nodeName, m_data.pieceName);
|
||||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
VAbstractApplication::VApp()->IsPedantic()
|
||||||
|
? throw VExceptionInvalidNotch(errorMsg)
|
||||||
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||||
return {}; // Something wrong
|
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 "
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find "
|
||||||
"position for a notch.")
|
"position for a notch.")
|
||||||
.arg(m_data.nodeName, m_data.pieceName);
|
.arg(m_data.nodeName, m_data.pieceName);
|
||||||
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
|
VAbstractApplication::VApp()->IsPedantic()
|
||||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
? throw VExceptionInvalidNotch(errorMsg)
|
||||||
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||||
return {}; // Something wrong
|
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)
|
m_data.passmarkAngleType == PassmarkAngleType::Bisector)
|
||||||
? rotatedSeamAllowance
|
? rotatedSeamAllowance
|
||||||
: seamAllowance;
|
: 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 "
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Unable to fix a "
|
||||||
"notch position.")
|
"notch position.")
|
||||||
.arg(m_data.nodeName, m_data.pieceName);
|
.arg(m_data.nodeName, m_data.pieceName);
|
||||||
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
|
VAbstractApplication::VApp()->IsPedantic()
|
||||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
? throw VExceptionInvalidNotch(errorMsg)
|
||||||
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward)
|
if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward)
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#ifndef VFILEPROPERTYEDITOR_H
|
#ifndef VFILEPROPERTYEDITOR_H
|
||||||
#define VFILEPROPERTYEDITOR_H
|
#define VFILEPROPERTYEDITOR_H
|
||||||
|
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
@ -49,10 +48,9 @@ class VPROPERTYEXPLORERSHARED_EXPORT VFileEditWidget : public QWidget
|
||||||
Q_OBJECT // NOLINT
|
Q_OBJECT // NOLINT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VFileEditWidget(QWidget* parent, bool is_directory = false);
|
explicit VFileEditWidget(QWidget *parent, bool is_directory = false);
|
||||||
virtual ~VFileEditWidget() override;
|
virtual ~VFileEditWidget() override;
|
||||||
|
|
||||||
|
|
||||||
//! This function returns the file currently set to this editor
|
//! This function returns the file currently set to this editor
|
||||||
auto getFile() const -> QString;
|
auto getFile() const -> QString;
|
||||||
|
|
||||||
|
@ -67,12 +65,11 @@ signals:
|
||||||
//! This signal is emitted when the user changed the curret file.
|
//! This signal is emitted when the user changed the curret file.
|
||||||
//! Actions triggering this signal are either using the file dialog
|
//! Actions triggering this signal are either using the file dialog
|
||||||
//! to select a new file or changing the file path in the line edit.
|
//! 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
|
//! This signal is emitted whenever dataChangedByUser() gets emmitted
|
||||||
//! and is connected to the delegate's commitData() signal
|
//! and is connected to the delegate's commitData() signal
|
||||||
void commitData(QWidget* editor);
|
void commitData(QWidget *editor);
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Sets the current file, does not check if it is valid
|
//! Sets the current file, does not check if it is valid
|
||||||
|
@ -84,7 +81,7 @@ public slots:
|
||||||
//! Sets a filter for the file field
|
//! Sets a filter for the file field
|
||||||
//! \param dialog_filter The filter used for the File Dialog
|
//! \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
|
//! \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
|
//! Sets whether the property stores a directory or a file
|
||||||
void setDirectory(bool dir);
|
void setDirectory(bool dir);
|
||||||
|
@ -94,10 +91,10 @@ private slots:
|
||||||
void onToolButtonClicked();
|
void onToolButtonClicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void dragEnterEvent(QDragEnterEvent* event) override;
|
virtual void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
virtual void dragMoveEvent(QDragMoveEvent* event) override;
|
virtual void dragMoveEvent(QDragMoveEvent *event) override;
|
||||||
virtual void dragLeaveEvent(QDragLeaveEvent* event) override;
|
virtual void dragLeaveEvent(QDragLeaveEvent *event) override;
|
||||||
virtual void dropEvent(QDropEvent* event) override;
|
virtual void dropEvent(QDropEvent *event) override;
|
||||||
|
|
||||||
//! This function checks the mime data, if it is compatible with the filters
|
//! This function checks the mime data, if it is compatible with the filters
|
||||||
virtual auto checkMimeData(const QMimeData *data, QString &file) const -> bool;
|
virtual auto checkMimeData(const QMimeData *data, QString &file) const -> bool;
|
||||||
|
@ -106,8 +103,8 @@ protected:
|
||||||
virtual auto checkFileFilter(const QString &file) const -> bool;
|
virtual auto checkFileFilter(const QString &file) const -> bool;
|
||||||
|
|
||||||
QString CurrentFilePath;
|
QString CurrentFilePath;
|
||||||
QToolButton* ToolButton;
|
QToolButton *ToolButton;
|
||||||
QLineEdit* FileLineEdit;
|
QLineEdit *FileLineEdit;
|
||||||
QString FileDialogFilter;
|
QString FileDialogFilter;
|
||||||
QStringList FilterList;
|
QStringList FilterList;
|
||||||
|
|
||||||
|
@ -120,6 +117,6 @@ private:
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
}
|
} // namespace VPE
|
||||||
|
|
||||||
#endif // VFILEPROPERTYEDITOR_H
|
#endif // VFILEPROPERTYEDITOR_H
|
||||||
|
|
|
@ -50,6 +50,6 @@ public:
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
}
|
} // namespace VPE
|
||||||
|
|
||||||
#endif // VABSTRACTPROPERTYFACTORY_H
|
#endif // VABSTRACTPROPERTYFACTORY_H
|
||||||
|
|
|
@ -38,10 +38,10 @@ class VPropertyFormViewPrivate : public VPropertyFormWidgetPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! The current property model
|
//! The current property model
|
||||||
VPropertyModel* Model;
|
VPropertyModel *Model;
|
||||||
|
|
||||||
//! The currently used property set
|
//! The currently used property set
|
||||||
VPropertySet* PropertySet;
|
VPropertySet *PropertySet;
|
||||||
|
|
||||||
//! Determines whether the widget needs to be rebuild
|
//! Determines whether the widget needs to be rebuild
|
||||||
bool NeedsRebuild;
|
bool NeedsRebuild;
|
||||||
|
@ -50,19 +50,31 @@ public:
|
||||||
bool IgnoreDataChangedSignal;
|
bool IgnoreDataChangedSignal;
|
||||||
|
|
||||||
VPropertyFormViewPrivate()
|
VPropertyFormViewPrivate()
|
||||||
: VPropertyFormWidgetPrivate(), Model(nullptr), PropertySet(nullptr), NeedsRebuild(false),
|
: VPropertyFormWidgetPrivate(),
|
||||||
|
Model(nullptr),
|
||||||
|
PropertySet(nullptr),
|
||||||
|
NeedsRebuild(false),
|
||||||
IgnoreDataChangedSignal(false)
|
IgnoreDataChangedSignal(false)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
explicit VPropertyFormViewPrivate(VPropertyModel* prop_model)
|
explicit VPropertyFormViewPrivate(VPropertyModel *prop_model)
|
||||||
: VPropertyFormWidgetPrivate(), Model(prop_model), PropertySet(nullptr), NeedsRebuild(false),
|
: VPropertyFormWidgetPrivate(),
|
||||||
|
Model(prop_model),
|
||||||
|
PropertySet(nullptr),
|
||||||
|
NeedsRebuild(false),
|
||||||
IgnoreDataChangedSignal(false)
|
IgnoreDataChangedSignal(false)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
explicit VPropertyFormViewPrivate(VPropertySet* prop_set)
|
explicit VPropertyFormViewPrivate(VPropertySet *prop_set)
|
||||||
: VPropertyFormWidgetPrivate(), Model(nullptr), PropertySet(prop_set), NeedsRebuild(false),
|
: VPropertyFormWidgetPrivate(),
|
||||||
|
Model(nullptr),
|
||||||
|
PropertySet(prop_set),
|
||||||
|
NeedsRebuild(false),
|
||||||
IgnoreDataChangedSignal(false)
|
IgnoreDataChangedSignal(false)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~VPropertyFormViewPrivate() override {}
|
virtual ~VPropertyFormViewPrivate() override {}
|
||||||
|
|
||||||
|
@ -72,6 +84,6 @@ private:
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
}
|
} // namespace VPE
|
||||||
|
|
||||||
#endif // VPROPERTYFORMVIEW_P_H
|
#endif // VPROPERTYFORMVIEW_P_H
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
|
|
||||||
// ONLY INCLUDE THIS IN .CPP FILES
|
// ONLY INCLUDE THIS IN .CPP FILES
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
#include "vproperty.h"
|
#include "vproperty.h"
|
||||||
|
#include <QList>
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#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)
|
//! Stores either another VPropertyFormWidget (then Editor is null) or an editor widget (then FormWidget is null)
|
||||||
struct SEditorWidget
|
struct SEditorWidget
|
||||||
{
|
{
|
||||||
SEditorWidget() : FormWidget(nullptr), Editor(nullptr) {}
|
SEditorWidget()
|
||||||
explicit SEditorWidget(VPropertyFormWidget* form_widget) : FormWidget(form_widget), Editor(nullptr) {}
|
: FormWidget(nullptr),
|
||||||
explicit SEditorWidget(QWidget* editor_widget) : FormWidget(nullptr), Editor(editor_widget) {}
|
Editor(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit SEditorWidget(VPropertyFormWidget *form_widget)
|
||||||
|
: FormWidget(form_widget),
|
||||||
|
Editor(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit SEditorWidget(QWidget *editor_widget)
|
||||||
|
: FormWidget(nullptr),
|
||||||
|
Editor(editor_widget)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
VPropertyFormWidget* FormWidget;
|
VPropertyFormWidget *FormWidget;
|
||||||
QWidget* Editor;
|
QWidget *Editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! The root property to use
|
//! The root property to use
|
||||||
QList<VProperty*> Properties;
|
QList<VProperty *> Properties;
|
||||||
|
|
||||||
//! Binds the properties to their editors
|
//! Binds the properties to their editors
|
||||||
QList<SEditorWidget> EditorWidgets;
|
QList<SEditorWidget> EditorWidgets;
|
||||||
|
@ -61,19 +73,25 @@ public:
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
VPropertyFormWidgetPrivate()
|
VPropertyFormWidgetPrivate()
|
||||||
: Properties(QList<VProperty*>()), EditorWidgets(QList<SEditorWidget>()), UpdateEditors(true)
|
: Properties(QList<VProperty *>()),
|
||||||
{}
|
EditorWidgets(QList<SEditorWidget>()),
|
||||||
|
UpdateEditors(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit VPropertyFormWidgetPrivate(const QList<VProperty*>& properties)
|
explicit VPropertyFormWidgetPrivate(const QList<VProperty *> &properties)
|
||||||
: Properties(properties), EditorWidgets(QList<SEditorWidget>()), UpdateEditors(true)
|
: Properties(properties),
|
||||||
{}
|
EditorWidgets(QList<SEditorWidget>()),
|
||||||
|
UpdateEditors(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~VPropertyFormWidgetPrivate() {}
|
virtual ~VPropertyFormWidgetPrivate() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
}
|
} // namespace VPE
|
||||||
|
|
||||||
#endif // VPROPERTYFORMWIDGET_P_H
|
#endif // VPROPERTYFORMWIDGET_P_H
|
||||||
|
|
|
@ -44,18 +44,24 @@ public:
|
||||||
QPointer<QWidget> Widget;
|
QPointer<QWidget> Widget;
|
||||||
|
|
||||||
//! Constructor passing name and type
|
//! Constructor passing name and type
|
||||||
VWidgetPropertyPrivate(const QString& name,
|
VWidgetPropertyPrivate(const QString &name,
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
QMetaType::Type type,
|
QMetaType::Type type,
|
||||||
#else
|
#else
|
||||||
QVariant::Type type,
|
QVariant::Type type,
|
||||||
#endif
|
#endif
|
||||||
QWidget* widget = nullptr)
|
QWidget *widget = nullptr)
|
||||||
: VPropertyPrivate(name, type), Widget(widget) {}
|
: VPropertyPrivate(name, type),
|
||||||
|
Widget(widget)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
VWidgetPropertyPrivate()
|
VWidgetPropertyPrivate()
|
||||||
: VPropertyPrivate(), Widget(nullptr) {}
|
: VPropertyPrivate(),
|
||||||
|
Widget(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~VWidgetPropertyPrivate() override
|
virtual ~VWidgetPropertyPrivate() override
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
#include "vtoolflippingbyaxis.h"
|
#include "vtoolflippingbyaxis.h"
|
||||||
|
|
||||||
#include <climits>
|
|
||||||
#include <qiterator.h>
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QDomNode>
|
#include <QDomNode>
|
||||||
#include <QDomNodeList>
|
#include <QDomNodeList>
|
||||||
|
@ -37,28 +35,27 @@
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
#include <climits>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <qiterator.h>
|
||||||
|
|
||||||
#include "../../../../dialogs/tools/dialogtool.h"
|
|
||||||
#include "../../../../dialogs/tools/dialogflippingbyaxis.h"
|
#include "../../../../dialogs/tools/dialogflippingbyaxis.h"
|
||||||
|
#include "../../../../dialogs/tools/dialogtool.h"
|
||||||
#include "../../../../visualization/line/operation/vistoolflippingbyaxis.h"
|
#include "../../../../visualization/line/operation/vistoolflippingbyaxis.h"
|
||||||
#include "../../../../visualization/visualization.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 "../../../vabstracttool.h"
|
||||||
#include "../../../vdatatool.h"
|
#include "../../../vdatatool.h"
|
||||||
#include "../../vdrawtool.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;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
@ -102,7 +99,7 @@ auto VToolFlippingByAxis::Create(const QPointer<DialogTool> &dialog, VMainGraphi
|
||||||
initData.typeCreation = Source::FromGui;
|
initData.typeCreation = Source::FromGui;
|
||||||
initData.notes = dialogTool->GetNotes();
|
initData.notes = dialogTool->GetNotes();
|
||||||
|
|
||||||
VToolFlippingByAxis* operation = Create(initData);
|
VToolFlippingByAxis *operation = Create(initData);
|
||||||
if (operation != nullptr)
|
if (operation != nullptr)
|
||||||
{
|
{
|
||||||
operation->m_dialog = dialog;
|
operation->m_dialog = dialog;
|
||||||
|
@ -191,10 +188,10 @@ void VToolFlippingByAxis::ShowContextMenu(QGraphicsSceneContextMenuEvent *event,
|
||||||
{
|
{
|
||||||
ContextMenu<DialogFlippingByAxis>(event, id);
|
ContextMenu<DialogFlippingByAxis>(event, id);
|
||||||
}
|
}
|
||||||
catch(const VExceptionToolWasDeleted &e)
|
catch (const VExceptionToolWasDeleted &e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(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, AttrAxisType, QString().setNum(static_cast<int>(dialogTool->GetAxisType())));
|
||||||
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
|
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
|
||||||
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
|
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
|
||||||
[](const QString ¬es) noexcept {return notes.isEmpty();});
|
[](const QString ¬es) noexcept { return notes.isEmpty(); });
|
||||||
|
|
||||||
source = dialogTool->GetSourceObjects();
|
source = dialogTool->GetSourceObjects();
|
||||||
SaveSourceDestination(domElement);
|
SaveSourceDestination(domElement);
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
#include "vtoolflippingbyline.h"
|
#include "vtoolflippingbyline.h"
|
||||||
|
|
||||||
#include <climits>
|
|
||||||
#include <qiterator.h>
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QDomNode>
|
#include <QDomNode>
|
||||||
#include <QDomNodeList>
|
#include <QDomNodeList>
|
||||||
|
@ -37,14 +35,20 @@
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
#include <climits>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <qiterator.h>
|
||||||
|
|
||||||
#include "../../../../dialogs/tools/dialogtool.h"
|
|
||||||
#include "../../../../dialogs/tools/dialogflippingbyline.h"
|
#include "../../../../dialogs/tools/dialogflippingbyline.h"
|
||||||
|
#include "../../../../dialogs/tools/dialogtool.h"
|
||||||
#include "../../../../visualization/line/operation/vistoolflippingbyline.h"
|
#include "../../../../visualization/line/operation/vistoolflippingbyline.h"
|
||||||
#include "../../../../visualization/visualization.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 "../vgeometry/vpointf.h"
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
@ -52,13 +56,9 @@
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vpatterndb/vformula.h"
|
#include "../vpatterndb/vformula.h"
|
||||||
#include "../ifc/ifcdef.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
#include "../ifc/exception/vexception.h"
|
|
||||||
#include "../vwidgets/vabstractsimple.h"
|
#include "../vwidgets/vabstractsimple.h"
|
||||||
#include "../vwidgets/vmaingraphicsscene.h"
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
#include "../../../vabstracttool.h"
|
|
||||||
#include "../../../vdatatool.h"
|
|
||||||
#include "../../vdrawtool.h"
|
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ auto VToolFlippingByLine::Create(const QPointer<DialogTool> &dialog, VMainGraphi
|
||||||
initData.typeCreation = Source::FromGui;
|
initData.typeCreation = Source::FromGui;
|
||||||
initData.notes = dialogTool->GetNotes();
|
initData.notes = dialogTool->GetNotes();
|
||||||
|
|
||||||
VToolFlippingByLine* operation = Create(initData);
|
VToolFlippingByLine *operation = Create(initData);
|
||||||
if (operation != nullptr)
|
if (operation != nullptr)
|
||||||
{
|
{
|
||||||
operation->m_dialog = dialog;
|
operation->m_dialog = dialog;
|
||||||
|
@ -176,10 +176,10 @@ void VToolFlippingByLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event,
|
||||||
{
|
{
|
||||||
ContextMenu<DialogFlippingByLine>(event, id);
|
ContextMenu<DialogFlippingByLine>(event, id);
|
||||||
}
|
}
|
||||||
catch(const VExceptionToolWasDeleted &e)
|
catch (const VExceptionToolWasDeleted &e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(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, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId()));
|
||||||
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
|
doc->SetAttribute(domElement, AttrSuffix, dialogTool->GetSuffix());
|
||||||
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
|
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
|
||||||
[](const QString ¬es) noexcept {return notes.isEmpty();});
|
[](const QString ¬es) noexcept { return notes.isEmpty(); });
|
||||||
|
|
||||||
source = dialogTool->GetSourceObjects();
|
source = dialogTool->GetSourceObjects();
|
||||||
SaveSourceDestination(domElement);
|
SaveSourceDestination(domElement);
|
||||||
|
@ -250,8 +250,7 @@ auto VToolFlippingByLine::MakeToolTip() const -> QString
|
||||||
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>"
|
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||||
"<tr> <td><b>%3:</b> %4</td> </tr>"
|
"<tr> <td><b>%3:</b> %4</td> </tr>"
|
||||||
"%5")
|
"%5")
|
||||||
.arg(tr("First line point"), FirstLinePointName(),
|
.arg(tr("First line point"), FirstLinePointName(), tr("Second line point"), SecondLinePointName()) // 1, 2, 3, 4
|
||||||
tr("Second line point"), SecondLinePointName()) // 1, 2, 3, 4
|
|
||||||
.arg(VisibilityGroupToolTip()); // 5
|
.arg(VisibilityGroupToolTip()); // 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
#include "vtoolmove.h"
|
#include "vtoolmove.h"
|
||||||
|
|
||||||
#include <climits>
|
|
||||||
#include <qiterator.h>
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QDomNode>
|
#include <QDomNode>
|
||||||
#include <QDomNodeList>
|
#include <QDomNodeList>
|
||||||
|
@ -37,37 +35,39 @@
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
#include <climits>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <qiterator.h>
|
||||||
|
|
||||||
#include "../../../dialogs/tools/dialogtool.h"
|
|
||||||
#include "../../../dialogs/tools/dialogmove.h"
|
#include "../../../dialogs/tools/dialogmove.h"
|
||||||
|
#include "../../../dialogs/tools/dialogtool.h"
|
||||||
#include "../../../visualization/line/operation/vistoolmove.h"
|
#include "../../../visualization/line/operation/vistoolmove.h"
|
||||||
#include "../../../visualization/visualization.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/vabstractcurve.h"
|
||||||
#include "../vgeometry/varc.h"
|
#include "../vgeometry/varc.h"
|
||||||
#include "../vgeometry/vellipticalarc.h"
|
|
||||||
#include "../vgeometry/vcubicbezier.h"
|
#include "../vgeometry/vcubicbezier.h"
|
||||||
#include "../vgeometry/vcubicbezierpath.h"
|
#include "../vgeometry/vcubicbezierpath.h"
|
||||||
|
#include "../vgeometry/vellipticalarc.h"
|
||||||
#include "../vgeometry/vgobject.h"
|
#include "../vgeometry/vgobject.h"
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
#include "../vgeometry/vspline.h"
|
#include "../vgeometry/vspline.h"
|
||||||
#include "../vgeometry/vsplinepath.h"
|
#include "../vgeometry/vsplinepath.h"
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vmisc/compatibility.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/compatibility.h"
|
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vpatterndb/vformula.h"
|
#include "../vpatterndb/vformula.h"
|
||||||
#include "../ifc/ifcdef.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
#include "../ifc/exception/vexception.h"
|
|
||||||
#include "../vwidgets/vabstractsimple.h"
|
#include "../vwidgets/vabstractsimple.h"
|
||||||
#include "../vwidgets/vmaingraphicsscene.h"
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
#include "../../vabstracttool.h"
|
|
||||||
#include "../../vdatatool.h"
|
|
||||||
#include "../vdrawtool.h"
|
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
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
|
// 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.");
|
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:
|
case GOType::Point:
|
||||||
originObjects.append(data->GeometricObject<VPointF>(object.id)->toQPointF());
|
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();
|
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);
|
move.setAngle(calcAngle);
|
||||||
return move.p2();
|
return move.p2();
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolMove::SetDialog()
|
void VToolMove::SetDialog()
|
||||||
|
@ -159,7 +159,7 @@ auto VToolMove::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *s
|
||||||
initData.typeCreation = Source::FromGui;
|
initData.typeCreation = Source::FromGui;
|
||||||
initData.notes = dialogTool->GetNotes();
|
initData.notes = dialogTool->GetNotes();
|
||||||
|
|
||||||
VToolMove* operation = Create(initData);
|
VToolMove *operation = Create(initData);
|
||||||
if (operation != nullptr)
|
if (operation != nullptr)
|
||||||
{
|
{
|
||||||
operation->m_dialog = dialog;
|
operation->m_dialog = dialog;
|
||||||
|
@ -176,8 +176,8 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove *
|
||||||
|
|
||||||
calcAngle = CheckFormula(initData.id, initData.formulaAngle, initData.data);
|
calcAngle = CheckFormula(initData.id, initData.formulaAngle, initData.data);
|
||||||
calcRotationAngle = CheckFormula(initData.id, initData.formulaRotationAngle, initData.data);
|
calcRotationAngle = CheckFormula(initData.id, initData.formulaRotationAngle, initData.data);
|
||||||
calcLength = VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formulaLength,
|
calcLength =
|
||||||
initData.data));
|
VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data));
|
||||||
|
|
||||||
QPointF rotationOrigin;
|
QPointF rotationOrigin;
|
||||||
QSharedPointer<VPointF> originPoint;
|
QSharedPointer<VPointF> originPoint;
|
||||||
|
@ -194,9 +194,9 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove *
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromGui)
|
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))
|
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
|
// 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.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch (static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
initData.destination.append(CreatePoint(initData.id, object, calcAngle, calcLength,
|
initData.destination.append(CreatePoint(initData.id, object, calcAngle, calcLength,
|
||||||
|
@ -230,9 +230,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle,
|
initData.destination.append(CreateCurveWithSegments<VSplinePath>(
|
||||||
calcLength, calcRotationAngle,
|
initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix,
|
||||||
rotationOrigin, initData.suffix,
|
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
|
@ -241,11 +240,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
initData.suffix, initData.data));
|
initData.suffix, initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object,
|
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(
|
||||||
calcAngle, calcLength,
|
initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix,
|
||||||
calcRotationAngle,
|
|
||||||
rotationOrigin,
|
|
||||||
initData.suffix,
|
|
||||||
initData.data));
|
initData.data));
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
|
@ -253,7 +249,7 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -266,9 +262,9 @@ QT_WARNING_POP
|
||||||
// This check helps to find missed objects in the switch
|
// 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.");
|
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
switch(static_cast<GOType>(obj->getType()))
|
switch (static_cast<GOType>(obj->getType()))
|
||||||
{
|
{
|
||||||
case GOType::Point:
|
case GOType::Point:
|
||||||
UpdatePoint(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
|
UpdatePoint(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
|
||||||
|
@ -284,31 +280,30 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::Spline:
|
case GOType::Spline:
|
||||||
UpdateCurve<VSpline>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
|
UpdateCurve<VSpline>(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
|
||||||
rotationOrigin, initData.suffix, initData.data, initData.destination.at(i).id);
|
initData.suffix, initData.data, initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::SplinePath:
|
case GOType::SplinePath:
|
||||||
UpdateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle, calcLength,
|
UpdateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
|
||||||
calcRotationAngle, rotationOrigin,initData.suffix,
|
rotationOrigin, initData.suffix, initData.data,
|
||||||
initData.data, initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezier:
|
case GOType::CubicBezier:
|
||||||
UpdateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
|
UpdateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
|
||||||
rotationOrigin,initData.suffix, initData.data,
|
rotationOrigin, initData.suffix, initData.data,
|
||||||
initData.destination.at(i).id);
|
initData.destination.at(i).id);
|
||||||
break;
|
break;
|
||||||
case GOType::CubicBezierPath:
|
case GOType::CubicBezierPath:
|
||||||
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, object, calcAngle, calcLength,
|
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, object, calcAngle, calcLength,
|
||||||
calcRotationAngle, rotationOrigin,
|
calcRotationAngle, rotationOrigin, initData.suffix,
|
||||||
initData.suffix, initData.data,
|
initData.data, initData.destination.at(i).id);
|
||||||
initData.destination.at(i).id);
|
|
||||||
break;
|
break;
|
||||||
case GOType::Unknown:
|
case GOType::Unknown:
|
||||||
case GOType::PlaceLabel:
|
case GOType::PlaceLabel:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
}
|
}
|
||||||
if (initData.parse != Document::FullParse)
|
if (initData.parse != Document::FullParse)
|
||||||
{
|
{
|
||||||
|
@ -445,10 +440,10 @@ void VToolMove::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 i
|
||||||
{
|
{
|
||||||
ContextMenu<DialogMove>(event, id);
|
ContextMenu<DialogMove>(event, id);
|
||||||
}
|
}
|
||||||
catch(const VExceptionToolWasDeleted &e)
|
catch (const VExceptionToolWasDeleted &e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(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, AttrCenter, QString().setNum(dialogTool->GetRotationOrigPointId()));
|
||||||
doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle());
|
doc->SetAttribute(domElement, AttrRotationAngle, dialogTool->GetRotationAngle());
|
||||||
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
|
doc->SetAttributeOrRemoveIf<QString>(domElement, AttrNotes, dialogTool->GetNotes(),
|
||||||
[](const QString ¬es) noexcept {return notes.isEmpty();});
|
[](const QString ¬es) noexcept { return notes.isEmpty(); });
|
||||||
|
|
||||||
source = dialogTool->GetSourceObjects();
|
source = dialogTool->GetSourceObjects();
|
||||||
SaveSourceDestination(domElement);
|
SaveSourceDestination(domElement);
|
||||||
|
@ -579,8 +574,8 @@ template <class Item>
|
||||||
auto VToolMove::CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
auto VToolMove::CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data) -> DestinationItem
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data) -> DestinationItem
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
|
const DestinationItem item =
|
||||||
data);
|
CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data);
|
||||||
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
|
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -648,8 +643,8 @@ template <class Item>
|
||||||
auto VToolMove::CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
auto VToolMove::CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
|
||||||
const QPointF &rotationOrigin, const QString &suffix, VContainer *data) -> DestinationItem
|
const QPointF &rotationOrigin, const QString &suffix, VContainer *data) -> DestinationItem
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
|
const DestinationItem item =
|
||||||
data);
|
CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data);
|
||||||
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
|
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -660,8 +655,8 @@ auto VToolMove::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem,
|
||||||
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
|
||||||
VContainer *data) -> DestinationItem
|
VContainer *data) -> DestinationItem
|
||||||
{
|
{
|
||||||
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
|
const DestinationItem item =
|
||||||
data);
|
CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data);
|
||||||
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
|
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,11 @@
|
||||||
#include "../../../dialogs/tools/dialogtool.h"
|
#include "../../../dialogs/tools/dialogtool.h"
|
||||||
#include "../../../visualization/line/operation/vistoolrotation.h"
|
#include "../../../visualization/line/operation/vistoolrotation.h"
|
||||||
#include "../../../visualization/visualization.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/varc.h"
|
||||||
#include "../vgeometry/vcubicbezier.h"
|
#include "../vgeometry/vcubicbezier.h"
|
||||||
#include "../vgeometry/vcubicbezierpath.h"
|
#include "../vgeometry/vcubicbezierpath.h"
|
||||||
|
@ -52,17 +57,12 @@
|
||||||
#include "../vgeometry/vsplinepath.h"
|
#include "../vgeometry/vsplinepath.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
#include "../vpatterndb/vformula.h"
|
||||||
#include "../vpatterndb/vtranslatevars.h"
|
#include "../vpatterndb/vtranslatevars.h"
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
#include "../vmisc/diagnostic.h"
|
#include "../vmisc/diagnostic.h"
|
||||||
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
#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"
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
|
|
||||||
class QDomElement;
|
class QDomElement;
|
||||||
|
|
|
@ -27,23 +27,23 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vabstractmainwindow.h"
|
#include "vabstractmainwindow.h"
|
||||||
#include "../vpropertyexplorer/checkablemessagebox.h"
|
|
||||||
#include "../vmisc/vabstractapplication.h"
|
|
||||||
#include "../vmisc/compatibility.h"
|
#include "../vmisc/compatibility.h"
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vsysexits.h"
|
#include "../vmisc/vsysexits.h"
|
||||||
|
#include "../vpropertyexplorer/checkablemessagebox.h"
|
||||||
#include "dialogs/dialogexporttocsv.h"
|
#include "dialogs/dialogexporttocsv.h"
|
||||||
|
|
||||||
#include <QStyle>
|
|
||||||
#include <QToolBar>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QFileDialog>
|
||||||
#include <QLockFile>
|
#include <QLockFile>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QToolBar>
|
||||||
|
|
||||||
//#ifdef Q_OS_WIN
|
// #ifdef Q_OS_WIN
|
||||||
//extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
// extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
|
||||||
//#endif /*Q_OS_WIN*/
|
// #endif /*Q_OS_WIN*/
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
@ -75,7 +75,7 @@ auto RecentFiles(const QStringList &paths) -> QStringList
|
||||||
QVector<QStringList> table;
|
QVector<QStringList> table;
|
||||||
table.reserve(paths.size());
|
table.reserve(paths.size());
|
||||||
|
|
||||||
for(const auto &path : paths)
|
for (const auto &path : paths)
|
||||||
{
|
{
|
||||||
table.append(SplitFilePaths(path));
|
table.append(SplitFilePaths(path));
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ auto RecentFiles(const QStringList &paths) -> QStringList
|
||||||
auto CreateOptimized = [table](int tableRow)
|
auto CreateOptimized = [table](int tableRow)
|
||||||
{
|
{
|
||||||
QStringList optimized;
|
QStringList optimized;
|
||||||
const QStringList& path = table.at(tableRow);
|
const QStringList &path = table.at(tableRow);
|
||||||
for (int count = 1; count <= path.size(); ++count)
|
for (int count = 1; count <= path.size(); ++count)
|
||||||
{
|
{
|
||||||
bool isUnique = true;
|
bool isUnique = true;
|
||||||
|
@ -130,14 +130,14 @@ auto RecentFiles(const QStringList &paths) -> QStringList
|
||||||
QStringList recentFiles;
|
QStringList recentFiles;
|
||||||
recentFiles.reserve(paths.size());
|
recentFiles.reserve(paths.size());
|
||||||
|
|
||||||
for(auto &path : optimizedPaths)
|
for (auto &path : optimizedPaths)
|
||||||
{
|
{
|
||||||
recentFiles.append(path.join(QDir::separator()));
|
recentFiles.append(path.join(QDir::separator()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return recentFiles;
|
return recentFiles;
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractMainWindow::VAbstractMainWindow(QWidget *parent)
|
VAbstractMainWindow::VAbstractMainWindow(QWidget *parent)
|
||||||
|
@ -169,7 +169,8 @@ auto VAbstractMainWindow::ContinueFormatRewrite(const QString ¤tFormatVers
|
||||||
msgBox.setText(tr("This file is using previous format version v%1. The current is v%2. "
|
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 "
|
"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. "
|
"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.setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
|
||||||
msgBox.setDefaultButton(QDialogButtonBox::No);
|
msgBox.setDefaultButton(QDialogButtonBox::No);
|
||||||
msgBox.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32));
|
msgBox.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32));
|
||||||
|
@ -212,7 +213,7 @@ auto VAbstractMainWindow::CSVFilePath() -> QString
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFileInfo f( fileName );
|
QFileInfo f(fileName);
|
||||||
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
||||||
{
|
{
|
||||||
fileName += QChar('.') + 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);
|
QFileInfo info(path);
|
||||||
|
|
||||||
//#ifdef Q_OS_WIN32
|
// #ifdef Q_OS_WIN32
|
||||||
// qt_ntfs_permission_lookup++; // turn checking on
|
// qt_ntfs_permission_lookup++; // turn checking on
|
||||||
//#endif /*Q_OS_WIN32*/
|
// #endif /*Q_OS_WIN32*/
|
||||||
|
|
||||||
if (not info.exists())
|
if (not info.exists())
|
||||||
{
|
{
|
||||||
|
@ -269,9 +270,9 @@ auto VAbstractMainWindow::CheckFilePermissions(const QString &path, QWidget *mes
|
||||||
|
|
||||||
const bool isFileWritable = info.isWritable();
|
const bool isFileWritable = info.isWritable();
|
||||||
|
|
||||||
//#ifdef Q_OS_WIN32
|
// #ifdef Q_OS_WIN32
|
||||||
// qt_ntfs_permission_lookup--; // turn it off again
|
// qt_ntfs_permission_lookup--; // turn it off again
|
||||||
//#endif /*Q_OS_WIN32*/
|
// #endif /*Q_OS_WIN32*/
|
||||||
|
|
||||||
if (not isFileWritable)
|
if (not isFileWritable)
|
||||||
{
|
{
|
||||||
|
@ -284,13 +285,13 @@ auto VAbstractMainWindow::CheckFilePermissions(const QString &path, QWidget *mes
|
||||||
|
|
||||||
if (messageBox.exec() == QMessageBox::Yes)
|
if (messageBox.exec() == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
//#ifdef Q_OS_WIN32
|
// #ifdef Q_OS_WIN32
|
||||||
// qt_ntfs_permission_lookup++; // turn checking on
|
// qt_ntfs_permission_lookup++; // turn checking on
|
||||||
//#endif /*Q_OS_WIN32*/
|
// #endif /*Q_OS_WIN32*/
|
||||||
bool changed = QFile::setPermissions(path, QFileInfo(path).permissions() | QFileDevice::WriteUser);
|
bool changed = QFile::setPermissions(path, QFileInfo(path).permissions() | QFileDevice::WriteUser);
|
||||||
//#ifdef Q_OS_WIN32
|
// #ifdef Q_OS_WIN32
|
||||||
// qt_ntfs_permission_lookup--; // turn it off again
|
// qt_ntfs_permission_lookup--; // turn it off again
|
||||||
//#endif /*Q_OS_WIN32*/
|
// #endif /*Q_OS_WIN32*/
|
||||||
|
|
||||||
if (not changed)
|
if (not changed)
|
||||||
{
|
{
|
||||||
|
@ -317,27 +318,27 @@ auto VAbstractMainWindow::IgnoreLocking(int error, const QString &path, bool gui
|
||||||
QMessageBox::StandardButton answer = QMessageBox::Abort;
|
QMessageBox::StandardButton answer = QMessageBox::Abort;
|
||||||
if (guiMode)
|
if (guiMode)
|
||||||
{
|
{
|
||||||
switch(error)
|
switch (error)
|
||||||
{
|
{
|
||||||
case QLockFile::LockFailedError:
|
case QLockFile::LockFailedError:
|
||||||
answer = QMessageBox::warning(this, tr("Locking file"),
|
answer = QMessageBox::warning(this, tr("Locking file"),
|
||||||
tr("This file already opened in another window. Ignore if you want "
|
tr("This file already opened in another window. Ignore if you want "
|
||||||
"to continue (not recommended, can cause a data corruption)."),
|
"to continue (not recommended, can cause a data corruption)."),
|
||||||
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
|
QMessageBox::Abort | QMessageBox::Ignore, QMessageBox::Abort);
|
||||||
break;
|
break;
|
||||||
case QLockFile::PermissionError:
|
case QLockFile::PermissionError:
|
||||||
answer = QMessageBox::question(this, tr("Locking file"),
|
answer = QMessageBox::question(this, tr("Locking file"),
|
||||||
tr("The lock file could not be created, for lack of permissions. "
|
tr("The lock file could not be created, for lack of permissions. "
|
||||||
"Ignore if you want to continue (not recommended, can cause "
|
"Ignore if you want to continue (not recommended, can cause "
|
||||||
"a data corruption)."),
|
"a data corruption)."),
|
||||||
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
|
QMessageBox::Abort | QMessageBox::Ignore, QMessageBox::Abort);
|
||||||
break;
|
break;
|
||||||
case QLockFile::UnknownError:
|
case QLockFile::UnknownError:
|
||||||
answer = QMessageBox::question(this, tr("Locking file"),
|
answer = QMessageBox::question(this, tr("Locking file"),
|
||||||
tr("Unknown error happened, for instance a full partition "
|
tr("Unknown error happened, for instance a full partition "
|
||||||
"prevented writing out the lock file. Ignore if you want to "
|
"prevented writing out the lock file. Ignore if you want to "
|
||||||
"continue (not recommended, can cause a data corruption)."),
|
"continue (not recommended, can cause a data corruption)."),
|
||||||
QMessageBox::Abort|QMessageBox::Ignore, QMessageBox::Abort);
|
QMessageBox::Abort | QMessageBox::Ignore, QMessageBox::Abort);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
answer = QMessageBox::Abort;
|
answer = QMessageBox::Abort;
|
||||||
|
@ -351,7 +352,7 @@ auto VAbstractMainWindow::IgnoreLocking(int error, const QString &path, bool gui
|
||||||
qCDebug(abstactMainWindow, "Error type: %d", error);
|
qCDebug(abstactMainWindow, "Error type: %d", error);
|
||||||
if (not guiMode)
|
if (not guiMode)
|
||||||
{
|
{
|
||||||
switch(error)
|
switch (error)
|
||||||
{
|
{
|
||||||
case QLockFile::LockFailedError:
|
case QLockFile::LockFailedError:
|
||||||
qCCritical(abstactMainWindow, "%s",
|
qCCritical(abstactMainWindow, "%s",
|
||||||
|
|
|
@ -27,10 +27,10 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "tst_vabstractpiece.h"
|
#include "tst_vabstractpiece.h"
|
||||||
#include "../vlayout/vabstractpiece.h"
|
|
||||||
#include "../vlayout/vrawsapoint.h"
|
|
||||||
#include "../vgeometry/varc.h"
|
#include "../vgeometry/varc.h"
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
|
#include "../vlayout/vabstractpiece.h"
|
||||||
|
#include "../vlayout/vrawsapoint.h"
|
||||||
|
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
@ -40,7 +40,8 @@
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
TST_VAbstractPiece::TST_VAbstractPiece(QObject *parent)
|
TST_VAbstractPiece::TST_VAbstractPiece(QObject *parent)
|
||||||
: AbstractTest(parent)
|
: AbstractTest(parent)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TST_VAbstractPiece::EquidistantRemoveLoop_data()
|
void TST_VAbstractPiece::EquidistantRemoveLoop_data()
|
||||||
|
@ -57,20 +58,17 @@ void TST_VAbstractPiece::EquidistantRemoveLoop_data()
|
||||||
};
|
};
|
||||||
|
|
||||||
// See file src/app/share/collection/test/seamtest1.val
|
// See file src/app/share/collection/test/seamtest1.val
|
||||||
ASSERT_TEST_CASE("Seam test 1. Piece. By angle.",
|
ASSERT_TEST_CASE("Seam test 1. Piece. By angle.", QStringLiteral("://seamtest1_by_angle/input.json"),
|
||||||
QStringLiteral("://seamtest1_by_angle/input.json"),
|
|
||||||
QStringLiteral("://seamtest1_by_angle/output.json"),
|
QStringLiteral("://seamtest1_by_angle/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/test/seamtest1.val
|
// See file src/app/share/collection/test/seamtest1.val
|
||||||
ASSERT_TEST_CASE("Seam test 1. Piece. By angle 2.",
|
ASSERT_TEST_CASE("Seam test 1. Piece. By angle 2.", QStringLiteral("://seamtest1_by_angle_2/input.json"),
|
||||||
QStringLiteral("://seamtest1_by_angle_2/input.json"),
|
|
||||||
QStringLiteral("://seamtest1_by_angle_2/output.json"),
|
QStringLiteral("://seamtest1_by_angle_2/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/test/seamtest1.val
|
// See file src/app/share/collection/test/seamtest1.val
|
||||||
ASSERT_TEST_CASE("Seam test 1. Piece. By intersection.",
|
ASSERT_TEST_CASE("Seam test 1. Piece. By intersection.", QStringLiteral("://seamtest1_by_intersection/input.json"),
|
||||||
QStringLiteral("://seamtest1_by_intersection/input.json"),
|
|
||||||
QStringLiteral("://seamtest1_by_intersection/output.json"),
|
QStringLiteral("://seamtest1_by_intersection/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
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)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/test/seamtest2.val
|
// See file src/app/share/collection/test/seamtest2.val
|
||||||
ASSERT_TEST_CASE("Seam test 2",
|
ASSERT_TEST_CASE("Seam test 2", QStringLiteral("://seamtest2/input.json"),
|
||||||
QStringLiteral("://seamtest2/input.json"),
|
QStringLiteral("://seamtest2/output.json"), 37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
QStringLiteral("://seamtest2/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
|
||||||
|
|
||||||
// See file src/app/share/collection/test/seamtest3.val
|
// See file src/app/share/collection/test/seamtest3.val
|
||||||
ASSERT_TEST_CASE("Seam test 3",
|
ASSERT_TEST_CASE("Seam test 3", QStringLiteral("://seamtest3/input.json"),
|
||||||
QStringLiteral("://seamtest3/input.json"),
|
QStringLiteral("://seamtest3/output.json"), 37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
QStringLiteral("://seamtest3/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
|
||||||
|
|
||||||
// These are two real cases where equdistant has loop.
|
// These are two real cases where equdistant has loop.
|
||||||
// See issue #298. Segmented Curve isn't selected in Seam Allowance tool.
|
// 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
|
// https://bitbucket.org/dismine/valentina/issue/298/segmented-curve-isnt-selected-in-seam
|
||||||
// See file src/app/share/collection/TestPuzzle.val
|
// See file src/app/share/collection/TestPuzzle.val
|
||||||
// Code should clean loops in path.
|
// Code should clean loops in path.
|
||||||
ASSERT_TEST_CASE("Issue 298. Case1",
|
ASSERT_TEST_CASE("Issue 298. Case1", QStringLiteral("://Issue_298_case1/input.json"),
|
||||||
QStringLiteral("://Issue_298_case1/input.json"),
|
QStringLiteral("://Issue_298_case1/output.json"), 75.59055118110237 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_298_case1/output.json"),
|
|
||||||
75.59055118110237 /*seam allowance width*/);
|
|
||||||
|
|
||||||
ASSERT_TEST_CASE("Issue 298. Case2",
|
ASSERT_TEST_CASE("Issue 298. Case2", QStringLiteral("://Issue_298_case2/input.json"),
|
||||||
QStringLiteral("://Issue_298_case2/input.json"),
|
QStringLiteral("://Issue_298_case2/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_298_case2/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See issue #548. Bug Detail tool. Case when seam allowance is wrong.
|
// 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
|
// https://bitbucket.org/dismine/valentina/issues/548/bug-detail-tool-case-when-seam-allowance
|
||||||
// Files: Steampunk_trousers.val and marie.vit
|
// Files: Steampunk_trousers.val and marie.vit
|
||||||
// Actually buggy detail see in file src/app/share/collection/bugs/Steampunk_trousers_issue_#548.val
|
// Actually buggy detail see in file src/app/share/collection/bugs/Steampunk_trousers_issue_#548.val
|
||||||
// Code should clean loops in path.
|
// Code should clean loops in path.
|
||||||
ASSERT_TEST_CASE("Issue 548. Case1",
|
ASSERT_TEST_CASE("Issue 548. Case1", QStringLiteral("://Issue_548_case1/input.json"),
|
||||||
QStringLiteral("://Issue_548_case1/input.json"),
|
|
||||||
QStringLiteral("://Issue_548_case1/output.json"),
|
QStringLiteral("://Issue_548_case1/output.json"),
|
||||||
11.338582677165354 /*seam allowance width (0.3 cm)*/);
|
11.338582677165354 /*seam allowance width (0.3 cm)*/);
|
||||||
|
|
||||||
ASSERT_TEST_CASE("Issue 548. Case2",
|
ASSERT_TEST_CASE("Issue 548. Case2", QStringLiteral("://Issue_548_case2/input.json"),
|
||||||
QStringLiteral("://Issue_548_case2/input.json"),
|
|
||||||
QStringLiteral("://Issue_548_case2/output.json"),
|
QStringLiteral("://Issue_548_case2/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
ASSERT_TEST_CASE("Issue 548. Case3",
|
ASSERT_TEST_CASE("Issue 548. Case3", QStringLiteral("://Issue_548_case3/input.json"),
|
||||||
QStringLiteral("://Issue_548_case3/input.json"),
|
|
||||||
QStringLiteral("://Issue_548_case3/output.json"),
|
QStringLiteral("://Issue_548_case3/output.json"),
|
||||||
75.59055118110237 /*seam allowance width (2.0 cm)*/);
|
75.59055118110237 /*seam allowance width (2.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#646.val
|
// See file src/app/share/collection/bugs/Issue_#646.val
|
||||||
ASSERT_TEST_CASE("Issue 646.",
|
ASSERT_TEST_CASE("Issue 646.", QStringLiteral("://Issue_646/input.json"),
|
||||||
QStringLiteral("://Issue_646/input.json"),
|
QStringLiteral("://Issue_646/output.json"), 37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
QStringLiteral("://Issue_646/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 1",
|
ASSERT_TEST_CASE("Issue 923. Test 1", QStringLiteral("://Issue_923_test1/input.json"),
|
||||||
QStringLiteral("://Issue_923_test1/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test1/output.json"),
|
QStringLiteral("://Issue_923_test1/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 2",
|
ASSERT_TEST_CASE("Issue 923. Test 2", QStringLiteral("://Issue_923_test2/input.json"),
|
||||||
QStringLiteral("://Issue_923_test2/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test2/output.json"),
|
QStringLiteral("://Issue_923_test2/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 3",
|
ASSERT_TEST_CASE("Issue 923. Test 3", QStringLiteral("://Issue_923_test3/input.json"),
|
||||||
QStringLiteral("://Issue_923_test3/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test3/output.json"),
|
QStringLiteral("://Issue_923_test3/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 4",
|
ASSERT_TEST_CASE("Issue 923. Test 4", QStringLiteral("://Issue_923_test4/input.json"),
|
||||||
QStringLiteral("://Issue_923_test4/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test4/output.json"),
|
QStringLiteral("://Issue_923_test4/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 5",
|
ASSERT_TEST_CASE("Issue 923. Test 5", QStringLiteral("://Issue_923_test5/input.json"),
|
||||||
QStringLiteral("://Issue_923_test5/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test5/output.json"),
|
QStringLiteral("://Issue_923_test5/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 6",
|
ASSERT_TEST_CASE("Issue 923. Test 6", QStringLiteral("://Issue_923_test6/input.json"),
|
||||||
QStringLiteral("://Issue_923_test6/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test6/output.json"),
|
QStringLiteral("://Issue_923_test6/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 1.1",
|
ASSERT_TEST_CASE("Issue 923. Test 1.1", QStringLiteral("://Issue_923_test1_1/input.json"),
|
||||||
QStringLiteral("://Issue_923_test1_1/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test1_1/output.json"),
|
QStringLiteral("://Issue_923_test1_1/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 2.2",
|
ASSERT_TEST_CASE("Issue 923. Test 2.2", QStringLiteral("://Issue_923_test2_2/input.json"),
|
||||||
QStringLiteral("://Issue_923_test2_2/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test2_2/output.json"),
|
QStringLiteral("://Issue_923_test2_2/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 3.3",
|
ASSERT_TEST_CASE("Issue 923. Test 3.3", QStringLiteral("://Issue_923_test3_3/input.json"),
|
||||||
QStringLiteral("://Issue_923_test3_3/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test3_3/output.json"),
|
QStringLiteral("://Issue_923_test3_3/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 4.4",
|
ASSERT_TEST_CASE("Issue 923. Test 4.4", QStringLiteral("://Issue_923_test4_4/input.json"),
|
||||||
QStringLiteral("://Issue_923_test4_4/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test4_4/output.json"),
|
QStringLiteral("://Issue_923_test4_4/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 5.5",
|
ASSERT_TEST_CASE("Issue 923. Test 5.5", QStringLiteral("://Issue_923_test5_5/input.json"),
|
||||||
QStringLiteral("://Issue_923_test5_5/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test5_5/output.json"),
|
QStringLiteral("://Issue_923_test5_5/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923.val
|
// See file src/app/share/collection/bugs/Issue_#923.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 6.6",
|
ASSERT_TEST_CASE("Issue 923. Test 6.6", QStringLiteral("://Issue_923_test6_6/input.json"),
|
||||||
QStringLiteral("://Issue_923_test6_6/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test6_6/output.json"),
|
QStringLiteral("://Issue_923_test6_6/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923_test7.val
|
// See file src/app/share/collection/bugs/Issue_#923_test7.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 7.1",
|
ASSERT_TEST_CASE("Issue 923. Test 7.1", QStringLiteral("://Issue_923_test7_1/input.json"),
|
||||||
QStringLiteral("://Issue_923_test7_1/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test7_1/output.json"),
|
QStringLiteral("://Issue_923_test7_1/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923_test7.val
|
// See file src/app/share/collection/bugs/Issue_#923_test7.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 7.2",
|
ASSERT_TEST_CASE("Issue 923. Test 7.2", QStringLiteral("://Issue_923_test7_2/input.json"),
|
||||||
QStringLiteral("://Issue_923_test7_2/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test7_2/output.json"),
|
QStringLiteral("://Issue_923_test7_2/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#923_test7.val
|
// See file src/app/share/collection/bugs/Issue_#923_test7.val
|
||||||
ASSERT_TEST_CASE("Issue 923. Test 7.3",
|
ASSERT_TEST_CASE("Issue 923. Test 7.3", QStringLiteral("://Issue_923_test7_3/input.json"),
|
||||||
QStringLiteral("://Issue_923_test7_3/input.json"),
|
|
||||||
QStringLiteral("://Issue_923_test7_3/output.json"),
|
QStringLiteral("://Issue_923_test7_3/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/loop_by_intersection.val
|
// See file src/app/share/collection/bugs/loop_by_intersection.val
|
||||||
ASSERT_TEST_CASE("Loop for angle by intersection",
|
ASSERT_TEST_CASE("Loop for angle by intersection", QStringLiteral("://loop_by_intersection/input.json"),
|
||||||
QStringLiteral("://loop_by_intersection/input.json"),
|
|
||||||
QStringLiteral("://loop_by_intersection/output.json"),
|
QStringLiteral("://loop_by_intersection/output.json"),
|
||||||
39.685039370078741 /*seam allowance width (1.05 cm)*/);
|
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
|
// See file valentina_private_collection/bugs/loop_start_point_on_line/loop_start_point_on_line.val
|
||||||
// (private collection)
|
// (private collection)
|
||||||
ASSERT_TEST_CASE("Loop for start point on line",
|
ASSERT_TEST_CASE("Loop for start point on line", QStringLiteral("://loop_start_point_on_line/input.json"),
|
||||||
QStringLiteral("://loop_start_point_on_line/input.json"),
|
|
||||||
QStringLiteral("://loop_start_point_on_line/output.json"),
|
QStringLiteral("://loop_start_point_on_line/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
||||||
ASSERT_TEST_CASE("By length",
|
ASSERT_TEST_CASE("By length", QStringLiteral("://DP_6_hem_by_length/input.json"),
|
||||||
QStringLiteral("://DP_6_hem_by_length/input.json"),
|
|
||||||
QStringLiteral("://DP_6_hem_by_length/output.json"),
|
QStringLiteral("://DP_6_hem_by_length/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
||||||
ASSERT_TEST_CASE("By intersection",
|
ASSERT_TEST_CASE("By intersection", QStringLiteral("://DP_6_hem_by_intersection/input.json"),
|
||||||
QStringLiteral("://DP_6_hem_by_intersection/input.json"),
|
|
||||||
QStringLiteral("://DP_6_hem_by_intersection/output.json"),
|
QStringLiteral("://DP_6_hem_by_intersection/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
||||||
ASSERT_TEST_CASE("By first edge symmetry",
|
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/input.json"),
|
|
||||||
QStringLiteral("://DP_6_hem_by_first_edge_symmetry/output.json"),
|
QStringLiteral("://DP_6_hem_by_first_edge_symmetry/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
||||||
ASSERT_TEST_CASE("By second edge symmetry",
|
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/input.json"),
|
|
||||||
QStringLiteral("://DP_6_hem_by_second_edge_symmetry/output.json"),
|
QStringLiteral("://DP_6_hem_by_second_edge_symmetry/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
||||||
ASSERT_TEST_CASE("By first edge right angle",
|
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/input.json"),
|
|
||||||
QStringLiteral("://DP_6_hem_by_first_edge_right_angle/output.json"),
|
QStringLiteral("://DP_6_hem_by_first_edge_right_angle/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
// See file valentina_private_collection/bugs/DP_6_hem/DP_6_hem.val
|
||||||
ASSERT_TEST_CASE("By second edge right angle",
|
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/input.json"),
|
|
||||||
QStringLiteral("://DP_6_hem_by_second_edge_right_angle/output.json"),
|
QStringLiteral("://DP_6_hem_by_second_edge_right_angle/output.json"),
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/DP_6/DP_6.val
|
// See file valentina_private_collection/bugs/DP_6/DP_6.val
|
||||||
ASSERT_TEST_CASE("Hem by seam allowance",
|
ASSERT_TEST_CASE("Hem by seam allowance", QStringLiteral("://DP_6/input.json"),
|
||||||
QStringLiteral("://DP_6/input.json"),
|
QStringLiteral("://DP_6/output.json"), 37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
||||||
QStringLiteral("://DP_6/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width (1.0 cm)*/);
|
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/smart_pattern_#36.val
|
// See file src/app/share/collection/bugs/smart_pattern_#36.val
|
||||||
ASSERT_TEST_CASE("Incorrect position of a notch",
|
ASSERT_TEST_CASE("Incorrect position of a notch", QStringLiteral("://smart_pattern_#36/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#36/input.json"),
|
|
||||||
QStringLiteral("://smart_pattern_#36/output.json"),
|
QStringLiteral("://smart_pattern_#36/output.json"),
|
||||||
30.236220472440944 /*seam allowance width (0.8 cm)*/);
|
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
|
// See file valentina_private_collection/bugs/smart_pattern_#58/smart_pattern_#58.val
|
||||||
ASSERT_TEST_CASE("Loop in layout allowance",
|
ASSERT_TEST_CASE("Loop in layout allowance", QStringLiteral("://smart_pattern_#58/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#58/input.json"),
|
|
||||||
QStringLiteral("://smart_pattern_#58/output.json"),
|
QStringLiteral("://smart_pattern_#58/output.json"),
|
||||||
18.897637795275593 /*seam allowance width (0.5 cm)*/);
|
18.897637795275593 /*seam allowance width (0.5 cm)*/);
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/smart_pattern_#99.val
|
// See file src/app/share/collection/bugs/smart_pattern_#99.val
|
||||||
ASSERT_TEST_CASE("Incorrect fix of distortion",
|
ASSERT_TEST_CASE("Incorrect fix of distortion", QStringLiteral("://smart_pattern_#99/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#99/input.json"),
|
QStringLiteral("://smart_pattern_#99/output.json"), 28.346456692913389 /*seam allowance width*/);
|
||||||
QStringLiteral("://smart_pattern_#99/output.json"),
|
|
||||||
28.346456692913389 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file valentina_private_collection/test/smart_pattern_#120/smart_pattern_#120.val
|
// See file valentina_private_collection/test/smart_pattern_#120/smart_pattern_#120.val
|
||||||
ASSERT_TEST_CASE("Piece 1",
|
ASSERT_TEST_CASE("Piece 1", QStringLiteral("://smart_pattern_#120_piece_1/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#120_piece_1/input.json"),
|
QStringLiteral("://smart_pattern_#120_piece_1/output.json"), 37.795275590551185);
|
||||||
QStringLiteral("://smart_pattern_#120_piece_1/output.json"),
|
|
||||||
37.795275590551185);
|
|
||||||
|
|
||||||
// See file valentina_private_collection/test/smart_pattern_#120/smart_pattern_#120.val
|
// See file valentina_private_collection/test/smart_pattern_#120/smart_pattern_#120.val
|
||||||
ASSERT_TEST_CASE("Piece 2",
|
ASSERT_TEST_CASE("Piece 2", QStringLiteral("://smart_pattern_#120_piece_2/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#120_piece_2/input.json"),
|
QStringLiteral("://smart_pattern_#120_piece_2/output.json"), 37.795275590551185);
|
||||||
QStringLiteral("://smart_pattern_#120_piece_2/output.json"),
|
|
||||||
37.795275590551185);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -388,14 +340,7 @@ void TST_VAbstractPiece::TestAreaCalculation_data()
|
||||||
QTest::addColumn<qreal>("excpectedArea");
|
QTest::addColumn<qreal>("excpectedArea");
|
||||||
|
|
||||||
{
|
{
|
||||||
QVector<QPointF> rect
|
QVector<QPointF> rect{QPointF(), QPointF(100, 0), QPointF(100, 50), QPointF(0, 50), QPointF()};
|
||||||
{
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -428,7 +373,7 @@ void TST_VAbstractPiece::TestAreaCalculation() const
|
||||||
QFETCH(QVector<QPointF>, path);
|
QFETCH(QVector<QPointF>, path);
|
||||||
QFETCH(qreal, excpectedArea);
|
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));
|
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)
|
// See file src/app/share/collection/bugs/smart_pattern_#112.val (private collection)
|
||||||
ASSERT_TEST_CASE("Loop intersection",
|
ASSERT_TEST_CASE("Loop intersection", QStringLiteral("://smart_pattern_#112/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#112/input.json"),
|
|
||||||
QStringLiteral("://smart_pattern_#112/output.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)
|
// See the file "collection/bugs/Issue_#604.val" (since 0.5.0)
|
||||||
ASSERT_TEST_CASE("Issue #604.",
|
ASSERT_TEST_CASE("Issue #604.", QStringLiteral("://Issue_604/input.json"),
|
||||||
QStringLiteral("://Issue_604/input.json"),
|
QStringLiteral("://Issue_604/output.json"), 11.338582677165354 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_604/output.json"),
|
|
||||||
11.338582677165354 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See the file "collection/bugs/Issue_#627.val"
|
// See the file "collection/bugs/Issue_#627.val"
|
||||||
ASSERT_TEST_CASE("Issue #627.",
|
ASSERT_TEST_CASE("Issue #627.", QStringLiteral("://Issue_627/input.json"),
|
||||||
QStringLiteral("://Issue_627/input.json"),
|
QStringLiteral("://Issue_627/output.json"), 56.692913385826778 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_627/output.json"),
|
|
||||||
56.692913385826778 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See the file "collection/bugs/Issue_#687.val"
|
// See the file "collection/bugs/Issue_#687.val"
|
||||||
ASSERT_TEST_CASE("Issue #687.",
|
ASSERT_TEST_CASE("Issue #687.", QStringLiteral("://Issue_687/input.json"),
|
||||||
QStringLiteral("://Issue_687/input.json"),
|
QStringLiteral("://Issue_687/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_687/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See private test cases in file jacket_issue_#767.val, piece "Fabric_TopCollar"
|
// See private test cases in file jacket_issue_#767.val, piece "Fabric_TopCollar"
|
||||||
// Curve approximation scale 0.5
|
// Curve approximation scale 0.5
|
||||||
ASSERT_TEST_CASE("Issue #767. Fabric_TopCollar.",
|
ASSERT_TEST_CASE("Issue #767. Fabric_TopCollar.", QStringLiteral("://Issue_767_Fabric_TopCollar/input.json"),
|
||||||
QStringLiteral("://Issue_767_Fabric_TopCollar/input.json"),
|
|
||||||
QStringLiteral("://Issue_767_Fabric_TopCollar/output.json"),
|
QStringLiteral("://Issue_767_Fabric_TopCollar/output.json"),
|
||||||
37.795275590551185 /*seam allowance width*/);
|
37.795275590551185 /*seam allowance width*/);
|
||||||
|
|
||||||
|
@ -968,63 +905,47 @@ void TST_VAbstractPiece::BrokenDetailEquidistant_data()
|
||||||
37.795275590551185 /*seam allowance width*/);
|
37.795275590551185 /*seam allowance width*/);
|
||||||
|
|
||||||
// See private test cases in file collection/bugs/Issue_#883_case1.val, piece "ledge"
|
// See private test cases in file collection/bugs/Issue_#883_case1.val, piece "ledge"
|
||||||
ASSERT_TEST_CASE("Issue #883. Piece 'ledge'",
|
ASSERT_TEST_CASE("Issue #883. Piece 'ledge'", QStringLiteral("://Issue_883_ledge/input.json"),
|
||||||
QStringLiteral("://Issue_883_ledge/input.json"),
|
QStringLiteral("://Issue_883_ledge/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
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"
|
// See private test cases in file collection/bugs/Issue_#883_case1.val, piece "prong"
|
||||||
ASSERT_TEST_CASE("Issue #883. Piece 'prong'",
|
ASSERT_TEST_CASE("Issue #883. Piece 'prong'", QStringLiteral("://Issue_883_prong/input.json"),
|
||||||
QStringLiteral("://Issue_883_prong/input.json"),
|
QStringLiteral("://Issue_883_prong/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_883_prong/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See the file "collection/bugs/smart_pattern_#145.val"
|
// See the file "collection/bugs/smart_pattern_#145.val"
|
||||||
ASSERT_TEST_CASE("Issue #145",
|
ASSERT_TEST_CASE("Issue #145", QStringLiteral("://smart_pattern_#145/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#145/input.json"),
|
QStringLiteral("://smart_pattern_#145/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
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
|
// See private test cases in file valentina_private_collection/bugs/women_jacket/women_jacket.val
|
||||||
// Point A38, size 32
|
// Point A38, size 32
|
||||||
ASSERT_TEST_CASE("women_jacket_A38",
|
ASSERT_TEST_CASE("women_jacket_A38", QStringLiteral("://women_jacket/input.json"),
|
||||||
QStringLiteral("://women_jacket/input.json"),
|
QStringLiteral("://women_jacket/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
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
|
// See private test cases in file valentina_private_collection/bugs/hood_1/hood_1.val
|
||||||
ASSERT_TEST_CASE("hood_1",
|
ASSERT_TEST_CASE("hood_1", QStringLiteral("://hood_1/input.json"), QStringLiteral("://hood_1/output.json"),
|
||||||
QStringLiteral("://hood_1/input.json"),
|
|
||||||
QStringLiteral("://hood_1/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
37.795275590551185 /*seam allowance width*/);
|
||||||
|
|
||||||
// See private test cases in file valentina_private_collection/bugs/hood_2/hood_2.val
|
// See private test cases in file valentina_private_collection/bugs/hood_2/hood_2.val
|
||||||
ASSERT_TEST_CASE("hood_2",
|
ASSERT_TEST_CASE("hood_2", QStringLiteral("://hood_2/input.json"), QStringLiteral("://hood_2/output.json"),
|
||||||
QStringLiteral("://hood_2/input.json"),
|
|
||||||
QStringLiteral("://hood_2/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
37.795275590551185 /*seam allowance width*/);
|
||||||
|
|
||||||
// See the file "collection/bugs/smart_pattern_#184_case1.val"
|
// See the file "collection/bugs/smart_pattern_#184_case1.val"
|
||||||
ASSERT_TEST_CASE("Issue #184 case 1",
|
ASSERT_TEST_CASE("Issue #184 case 1", QStringLiteral("://smart_pattern_#184_case1/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#184_case1/input.json"),
|
|
||||||
QStringLiteral("://smart_pattern_#184_case1/output.json"),
|
QStringLiteral("://smart_pattern_#184_case1/output.json"),
|
||||||
0.88157480314960635 /*seam allowance width*/);
|
0.88157480314960635 /*seam allowance width*/);
|
||||||
|
|
||||||
// See the file "collection/bugs/smart_pattern_#184_case2.val"
|
// See the file "collection/bugs/smart_pattern_#184_case2.val"
|
||||||
ASSERT_TEST_CASE("Issue #184 case 2",
|
ASSERT_TEST_CASE("Issue #184 case 2", QStringLiteral("://smart_pattern_#184_case2/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#184_case2/input.json"),
|
|
||||||
QStringLiteral("://smart_pattern_#184_case2/output.json"),
|
QStringLiteral("://smart_pattern_#184_case2/output.json"),
|
||||||
37.795275590551185 /*seam allowance width*/);
|
37.795275590551185 /*seam allowance width*/);
|
||||||
|
|
||||||
// See the file "valentina_private_collection/bugs/custom_seam_allwance_exclude/custom_seam_allwance_exclude.val"
|
// See the file "valentina_private_collection/bugs/custom_seam_allwance_exclude/custom_seam_allwance_exclude.val"
|
||||||
ASSERT_TEST_CASE("Piece 1. CSA Exclude",
|
ASSERT_TEST_CASE("Piece 1. CSA Exclude", QStringLiteral("://custom_seam_allwance_exclude_p1/input.json"),
|
||||||
QStringLiteral("://custom_seam_allwance_exclude_p1/input.json"),
|
|
||||||
QStringLiteral("://custom_seam_allwance_exclude_p1/output.json"),
|
QStringLiteral("://custom_seam_allwance_exclude_p1/output.json"),
|
||||||
37.795275590551185 /*seam allowance width 1 cm*/);
|
37.795275590551185 /*seam allowance width 1 cm*/);
|
||||||
|
|
||||||
// See the file "valentina_private_collection/bugs/custom_seam_allwance_exclude/custom_seam_allwance_exclude.val"
|
// See the file "valentina_private_collection/bugs/custom_seam_allwance_exclude/custom_seam_allwance_exclude.val"
|
||||||
ASSERT_TEST_CASE("Piece 2. CSA Exclude",
|
ASSERT_TEST_CASE("Piece 2. CSA Exclude", QStringLiteral("://custom_seam_allwance_exclude_p2/input.json"),
|
||||||
QStringLiteral("://custom_seam_allwance_exclude_p2/input.json"),
|
|
||||||
QStringLiteral("://custom_seam_allwance_exclude_p2/output.json"),
|
QStringLiteral("://custom_seam_allwance_exclude_p2/output.json"),
|
||||||
37.795275590551185 /*seam allowance width 1 cm*/);
|
37.795275590551185 /*seam allowance width 1 cm*/);
|
||||||
}
|
}
|
||||||
|
@ -1037,7 +958,7 @@ void TST_VAbstractPiece::BrokenDetailEquidistant() const
|
||||||
QFETCH(QVector<QPointF>, ekvOrig);
|
QFETCH(QVector<QPointF>, ekvOrig);
|
||||||
|
|
||||||
QVector<QPointF> ekv;
|
QVector<QPointF> ekv;
|
||||||
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv);// Take result
|
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv); // Take result
|
||||||
|
|
||||||
// Begin comparison
|
// Begin comparison
|
||||||
ComparePaths(ekv, ekvOrig);
|
ComparePaths(ekv, ekvOrig);
|
||||||
|
@ -1058,93 +979,63 @@ void TST_VAbstractPiece::EquidistantAngleType_data()
|
||||||
};
|
};
|
||||||
|
|
||||||
// See the file "collection/bugs/Issue_#880.val"
|
// See the file "collection/bugs/Issue_#880.val"
|
||||||
ASSERT_TEST_CASE("Issue #880. Piece: Detail.",
|
ASSERT_TEST_CASE("Issue #880. Piece: Detail.", QStringLiteral("://Issue_880_Detail/input.json"),
|
||||||
QStringLiteral("://Issue_880_Detail/input.json"),
|
QStringLiteral("://Issue_880_Detail/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_880_Detail/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See the file "collection/bugs/Issue_#880.val"
|
// See the file "collection/bugs/Issue_#880.val"
|
||||||
ASSERT_TEST_CASE("Issue #880. Piece: Detail_1.",
|
ASSERT_TEST_CASE("Issue #880. Piece: Detail_1.", QStringLiteral("://Issue_880_Detail_1/input.json"),
|
||||||
QStringLiteral("://Issue_880_Detail_1/input.json"),
|
QStringLiteral("://Issue_880_Detail_1/output.json"), 75.59055118110237 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_880_Detail_1/output.json"),
|
|
||||||
75.59055118110237 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#937.val
|
// See file src/app/share/collection/bugs/Issue_#937.val
|
||||||
ASSERT_TEST_CASE("Issue 937. Case1",
|
ASSERT_TEST_CASE("Issue 937. Case1", QStringLiteral("://Issue_937_case_1/input.json"),
|
||||||
QStringLiteral("://Issue_937_case_1/input.json"),
|
QStringLiteral("://Issue_937_case_1/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_937_case_1/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#937a.val
|
// See file src/app/share/collection/bugs/Issue_#937a.val
|
||||||
ASSERT_TEST_CASE("Issue 937. Case1a",
|
ASSERT_TEST_CASE("Issue 937. Case1a", QStringLiteral("://Issue_937_case_1a/input.json"),
|
||||||
QStringLiteral("://Issue_937_case_1a/input.json"),
|
QStringLiteral("://Issue_937_case_1a/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_937_case_1a/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#937.val
|
// See file src/app/share/collection/bugs/Issue_#937.val
|
||||||
ASSERT_TEST_CASE("Issue 937. Case2",
|
ASSERT_TEST_CASE("Issue 937. Case2", QStringLiteral("://Issue_937_case_2/input.json"),
|
||||||
QStringLiteral("://Issue_937_case_2/input.json"),
|
QStringLiteral("://Issue_937_case_2/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_937_case_2/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#937.val
|
// See file src/app/share/collection/bugs/Issue_#937.val
|
||||||
ASSERT_TEST_CASE("Issue 937. Case3",
|
ASSERT_TEST_CASE("Issue 937. Case3", QStringLiteral("://Issue_937_case_3/input.json"),
|
||||||
QStringLiteral("://Issue_937_case_3/input.json"),
|
QStringLiteral("://Issue_937_case_3/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_937_case_3/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#937.val
|
// See file src/app/share/collection/bugs/Issue_#937.val
|
||||||
ASSERT_TEST_CASE("Issue 937. Case4",
|
ASSERT_TEST_CASE("Issue 937. Case4", QStringLiteral("://Issue_937_case_4/input.json"),
|
||||||
QStringLiteral("://Issue_937_case_4/input.json"),
|
QStringLiteral("://Issue_937_case_4/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_937_case_4/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Issue_#937_case5.val
|
// See file src/app/share/collection/bugs/Issue_#937_case5.val
|
||||||
ASSERT_TEST_CASE("Issue 937. Case5",
|
ASSERT_TEST_CASE("Issue 937. Case5", QStringLiteral("://Issue_937_case_5/input.json"),
|
||||||
QStringLiteral("://Issue_937_case_5/input.json"),
|
QStringLiteral("://Issue_937_case_5/output.json"), 37.795275590551185 /*seam allowance width*/);
|
||||||
QStringLiteral("://Issue_937_case_5/output.json"),
|
|
||||||
37.795275590551185 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/busty/busty.val
|
// See file valentina_private_collection/bugs/busty/busty.val
|
||||||
ASSERT_TEST_CASE("Busty",
|
ASSERT_TEST_CASE("Busty", QStringLiteral("://busty/input.json"), QStringLiteral("://busty/output.json"),
|
||||||
QStringLiteral("://busty/input.json"),
|
|
||||||
QStringLiteral("://busty/output.json"),
|
|
||||||
0 /*seam allowance width*/);
|
0 /*seam allowance width*/);
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/panties/panties.val
|
// See file valentina_private_collection/bugs/panties/panties.val
|
||||||
ASSERT_TEST_CASE("Panties. Piece Case 1",
|
ASSERT_TEST_CASE("Panties. Piece Case 1", QStringLiteral("://panties_case1/input.json"),
|
||||||
QStringLiteral("://panties_case1/input.json"),
|
QStringLiteral("://panties_case1/output.json"), 26.45669291338583 /*seam allowance width*/);
|
||||||
QStringLiteral("://panties_case1/output.json"),
|
|
||||||
26.45669291338583 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/panties/panties.val
|
// See file valentina_private_collection/bugs/panties/panties.val
|
||||||
ASSERT_TEST_CASE("Panties. Piece Case 2",
|
ASSERT_TEST_CASE("Panties. Piece Case 2", QStringLiteral("://panties_case2/input.json"),
|
||||||
QStringLiteral("://panties_case2/input.json"),
|
QStringLiteral("://panties_case2/output.json"), 26.45669291338583 /*seam allowance width*/);
|
||||||
QStringLiteral("://panties_case2/output.json"),
|
|
||||||
26.45669291338583 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/smart_pattern_#113/smart_pattern_#113.val
|
// See file valentina_private_collection/bugs/smart_pattern_#113/smart_pattern_#113.val
|
||||||
ASSERT_TEST_CASE("Эдит 6",
|
ASSERT_TEST_CASE("Эдит 6", QStringLiteral("://smart_pattern_#113/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#113/input.json"),
|
QStringLiteral("://smart_pattern_#113/output.json"), 0.56692913385826771 /*seam allowance width*/);
|
||||||
QStringLiteral("://smart_pattern_#113/output.json"),
|
|
||||||
0.56692913385826771 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/smart_pattern_#118/smart_pattern_#118.val
|
// See file valentina_private_collection/bugs/smart_pattern_#118/smart_pattern_#118.val
|
||||||
ASSERT_TEST_CASE("Ретро стринги 3",
|
ASSERT_TEST_CASE("Ретро стринги 3", QStringLiteral("://smart_pattern_#118/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#118/input.json"),
|
QStringLiteral("://smart_pattern_#118/output.json"), 26.45669291338583 /*seam allowance width*/);
|
||||||
QStringLiteral("://smart_pattern_#118/output.json"),
|
|
||||||
26.45669291338583 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/smart_pattern_#133/smart_pattern_#133.val
|
// See file valentina_private_collection/bugs/smart_pattern_#133/smart_pattern_#133.val
|
||||||
ASSERT_TEST_CASE("Эдит 1",
|
ASSERT_TEST_CASE("Эдит 1", QStringLiteral("://smart_pattern_#133/input.json"),
|
||||||
QStringLiteral("://smart_pattern_#133/input.json"),
|
QStringLiteral("://smart_pattern_#133/output.json"), 26.45669291338583 /*seam allowance width*/);
|
||||||
QStringLiteral("://smart_pattern_#133/output.json"),
|
|
||||||
26.45669291338583 /*seam allowance width*/);
|
|
||||||
|
|
||||||
// See file valentina_private_collection/bugs/hat/hat.val
|
// See file valentina_private_collection/bugs/hat/hat.val
|
||||||
ASSERT_TEST_CASE("hat",
|
ASSERT_TEST_CASE("hat", QStringLiteral("://hat/input.json"), QStringLiteral("://hat/output.json"),
|
||||||
QStringLiteral("://hat/input.json"),
|
|
||||||
QStringLiteral("://hat/output.json"),
|
|
||||||
26.45669291338583 /*seam allowance width*/);
|
26.45669291338583 /*seam allowance width*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,7 +1047,7 @@ void TST_VAbstractPiece::EquidistantAngleType() const
|
||||||
QFETCH(QVector<QPointF>, ekvOrig);
|
QFETCH(QVector<QPointF>, ekvOrig);
|
||||||
|
|
||||||
QVector<QPointF> ekv;
|
QVector<QPointF> ekv;
|
||||||
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv);// Take result
|
CastTo(VAbstractPiece::Equidistant(points, width, QString()), ekv); // Take result
|
||||||
|
|
||||||
// Begin comparison
|
// Begin comparison
|
||||||
ComparePaths(ekv, ekvOrig);
|
ComparePaths(ekv, ekvOrig);
|
||||||
|
@ -1213,13 +1104,11 @@ void TST_VAbstractPiece::TestCorrectEquidistantPoints_data()
|
||||||
};
|
};
|
||||||
|
|
||||||
// See file src/app/share/collection/bugs/Steampunk_trousers_issue_#548.val
|
// See file src/app/share/collection/bugs/Steampunk_trousers_issue_#548.val
|
||||||
ASSERT_TEST_CASE("Test case issue #548",
|
ASSERT_TEST_CASE("Test case issue #548", QStringLiteral("://Issue_548/input.json"),
|
||||||
QStringLiteral("://Issue_548/input.json"),
|
|
||||||
QStringLiteral("://Issue_548/output.json"));
|
QStringLiteral("://Issue_548/output.json"));
|
||||||
|
|
||||||
// See the file "collection/bugs/Issue_#642.val"
|
// See the file "collection/bugs/Issue_#642.val"
|
||||||
ASSERT_TEST_CASE("Test case issue #642",
|
ASSERT_TEST_CASE("Test case issue #642", QStringLiteral("://Issue_642/input.json"),
|
||||||
QStringLiteral("://Issue_642/input.json"),
|
|
||||||
QStringLiteral("://Issue_642/output.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> basePoints = AbstractTest::VectorFromJson<QPointF>(base);
|
||||||
QVector<QPointF> allowancePoints = AbstractTest::VectorFromJson<QPointF>(allowance);
|
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)
|
// See file src/app/share/collection/valid_allowance/case3.val (private collection)
|
||||||
ASSERT_TEST_CASE("Valid seam allowance. Case 3",
|
ASSERT_TEST_CASE("Valid seam allowance. Case 3", QStringLiteral("://valid_allowance_case3/base.json"),
|
||||||
QStringLiteral("://valid_allowance_case3/base.json"),
|
QStringLiteral("://valid_allowance_case3/allowance.json"), true);
|
||||||
QStringLiteral("://valid_allowance_case3/allowance.json"),
|
|
||||||
true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -38,17 +38,21 @@ void PrepareTestCase(const QPointF ¢er, qreal startAngle, qreal endAngle)
|
||||||
{
|
{
|
||||||
qreal radius = UnitConvertor(1, Unit::Cm, Unit::Px);
|
qreal radius = UnitConvertor(1, Unit::Cm, Unit::Px);
|
||||||
const qreal threshold = UnitConvertor(2000, 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);
|
VArc arc(VPointF(center), radius, startAngle, endAngle);
|
||||||
const QVector<QPointF> points = arc.GetPoints();
|
const QVector<QPointF> points = arc.GetPoints();
|
||||||
|
|
||||||
const QString testStartAngle = QString("Test start angel. Arc radius %1, start angle %2, end angle %3")
|
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;
|
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")
|
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;
|
QTest::newRow(qUtf8Printable(testEndAngle)) << center << endAngle << points << ConstLast(points) << true;
|
||||||
|
|
||||||
radius += UnitConvertor(5, Unit::Cm, Unit::Px);
|
radius += UnitConvertor(5, Unit::Cm, Unit::Px);
|
||||||
|
@ -58,8 +62,9 @@ void PrepareTestCase(const QPointF ¢er, qreal startAngle, qreal endAngle)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
TST_VArc::TST_VArc(QObject *parent)
|
TST_VArc::TST_VArc(QObject *parent)
|
||||||
:AbstractTest(parent)
|
: AbstractTest(parent)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
|
@ -69,7 +74,7 @@ void TST_VArc::CompareTwoWays()
|
||||||
const qreal radius = 100;
|
const qreal radius = 100;
|
||||||
const qreal f1 = 1;
|
const qreal f1 = 1;
|
||||||
const qreal f2 = 46;
|
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 arc1(center, radius, f1, f2);
|
||||||
VArc arc2(length, center, radius, f1);
|
VArc arc2(length, center, radius, f1);
|
||||||
|
@ -92,7 +97,7 @@ void TST_VArc::NegativeArc()
|
||||||
const qreal radius = 100;
|
const qreal radius = 100;
|
||||||
const qreal f1 = 1;
|
const qreal f1 = 1;
|
||||||
const qreal f2 = 316;
|
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);
|
VArc arc(-length, center, radius, f1);
|
||||||
|
|
||||||
QCOMPARE(arc.GetLength(), -length);
|
QCOMPARE(arc.GetLength(), -length);
|
||||||
|
@ -209,26 +214,27 @@ void TST_VArc::TestGetPoints()
|
||||||
const qreal value = qAbs(rLine.length() - radius);
|
const qreal value = qAbs(rLine.length() - radius);
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
const QString errorMsg = QString("Broken the first rule. All points should be on the same distance from "
|
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));
|
QVERIFY2(value <= epsRadius, qUtf8Printable(errorMsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
qreal gSquare = 0.0;// geometry square
|
qreal gSquare = 0.0; // geometry square
|
||||||
|
|
||||||
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
|
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
|
||||||
{// circle square
|
{ // circle square
|
||||||
gSquare = M_PI * radius * radius;
|
gSquare = M_PI * radius * radius;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{// sector square
|
{ // sector square
|
||||||
gSquare = (M_PI * radius * radius) / 360.0 * arc.AngleArc();
|
gSquare = (M_PI * radius * radius) / 360.0 * arc.AngleArc();
|
||||||
points.append(static_cast<QPointF>(center));
|
points.append(static_cast<QPointF>(center));
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculated square
|
// 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);
|
const qreal value = qAbs(gSquare - cSquare);
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
const QString errorMsg =
|
const QString errorMsg =
|
||||||
|
@ -311,7 +317,7 @@ void TST_VArc::TestFlip_data()
|
||||||
l.setAngle(225);
|
l.setAngle(225);
|
||||||
p1 = l.p2();
|
p1 = l.p2();
|
||||||
|
|
||||||
l.setAngle(45+90);
|
l.setAngle(45 + 90);
|
||||||
l.setLength(5);
|
l.setLength(5);
|
||||||
|
|
||||||
const QPointF p1Axis = l.p2();
|
const QPointF p1Axis = l.p2();
|
||||||
|
@ -341,7 +347,7 @@ void TST_VArc::TestFlip()
|
||||||
|
|
||||||
QVERIFY2(res.IsFlipped(), qUtf8Printable("The arc is not flipped"));
|
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.GetRadius(), res.GetRadius());
|
||||||
QCOMPARE(originArc.AngleArc(), res.AngleArc());
|
QCOMPARE(originArc.AngleArc(), res.AngleArc());
|
||||||
}
|
}
|
||||||
|
@ -356,7 +362,7 @@ void TST_VArc::TestCutArc_data()
|
||||||
QTest::addColumn<qreal>("cutLength");
|
QTest::addColumn<qreal>("cutLength");
|
||||||
QTest::addColumn<QPointF>("cutPoint");
|
QTest::addColumn<QPointF>("cutPoint");
|
||||||
|
|
||||||
QPointF center (189.13625196850393, 344.1267401574803);
|
QPointF center(189.13625196850393, 344.1267401574803);
|
||||||
qreal radius = ToPixel(10, Unit::Cm);
|
qreal radius = ToPixel(10, Unit::Cm);
|
||||||
qreal startAngle = 45.0;
|
qreal startAngle = 45.0;
|
||||||
qreal length = ToPixel(-10, Unit::Cm);
|
qreal length = ToPixel(-10, Unit::Cm);
|
||||||
|
@ -364,14 +370,14 @@ void TST_VArc::TestCutArc_data()
|
||||||
QPointF cutPoint(539.3657292513009, 202.04366960088566);
|
QPointF cutPoint(539.3657292513009, 202.04366960088566);
|
||||||
|
|
||||||
// See file <root>/src/app/share/collection/bugs/Issue_#957.val
|
// 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
|
QTest::newRow("Arc -10 cm length, cut length 6 cm")
|
||||||
<< cutPoint;
|
<< center << radius << startAngle << length << cutLength << cutPoint;
|
||||||
|
|
||||||
cutLength = ToPixel(-4, Unit::Cm);
|
cutLength = ToPixel(-4, Unit::Cm);
|
||||||
|
|
||||||
// Opposite case
|
// Opposite case
|
||||||
QTest::newRow("Arc -10 cm length, cut length -4 cm") << center << radius << startAngle << length << cutLength
|
QTest::newRow("Arc -10 cm length, cut length -4 cm")
|
||||||
<< cutPoint;
|
<< center << radius << startAngle << length << cutLength << cutPoint;
|
||||||
|
|
||||||
startAngle = 135;
|
startAngle = 135;
|
||||||
length = ToPixel(10, Unit::Cm);
|
length = ToPixel(10, Unit::Cm);
|
||||||
|
@ -379,13 +385,13 @@ void TST_VArc::TestCutArc_data()
|
||||||
cutPoint = QPointF(-145.1588983496871, 167.78888781060192);
|
cutPoint = QPointF(-145.1588983496871, 167.78888781060192);
|
||||||
|
|
||||||
// See file <root>/src/app/share/collection/bugs/Issue_#957.val
|
// 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
|
QTest::newRow("Arc 10 cm length, cut length -7 cm")
|
||||||
<< cutPoint;
|
<< center << radius << startAngle << length << cutLength << cutPoint;
|
||||||
|
|
||||||
// Opposite case
|
// Opposite case
|
||||||
cutLength = ToPixel(3, Unit::Cm);
|
cutLength = ToPixel(3, Unit::Cm);
|
||||||
QTest::newRow("Arc 10 cm length, cut length 3 cm") << center << radius << startAngle << length << cutLength
|
QTest::newRow("Arc 10 cm length, cut length 3 cm")
|
||||||
<< cutPoint;
|
<< center << radius << startAngle << length << cutLength << cutPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -398,7 +404,7 @@ void TST_VArc::TestCutArc()
|
||||||
QFETCH(qreal, cutLength);
|
QFETCH(qreal, cutLength);
|
||||||
QFETCH(QPointF, cutPoint);
|
QFETCH(QPointF, cutPoint);
|
||||||
|
|
||||||
VArc arc (length, VPointF(center), radius, startAngle);
|
VArc arc(length, VPointF(center), radius, startAngle);
|
||||||
arc.SetApproximationScale(0.5);
|
arc.SetApproximationScale(0.5);
|
||||||
|
|
||||||
VArc arc1;
|
VArc arc1;
|
||||||
|
|
|
@ -34,8 +34,10 @@
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
TST_VEllipticalArc::TST_VEllipticalArc(QObject *parent) : AbstractTest(parent)
|
TST_VEllipticalArc::TST_VEllipticalArc(QObject *parent)
|
||||||
{}
|
: AbstractTest(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TST_VEllipticalArc::CompareTwoWays_data()
|
void TST_VEllipticalArc::CompareTwoWays_data()
|
||||||
|
@ -99,7 +101,7 @@ void TST_VEllipticalArc::CompareTwoWays()
|
||||||
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
|
// compare angles
|
||||||
const qreal diff = qAbs(arc1.GetEndAngle() - arc2.GetEndAngle());
|
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())));
|
qUtf8Printable(errorAngleMsg.arg(angleEps).arg(arc1.GetEndAngle()).arg(arc2.GetEndAngle())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,8 +117,8 @@ void TST_VEllipticalArc::NegativeArc()
|
||||||
const qreal rotationAngle = 0;
|
const qreal rotationAngle = 0;
|
||||||
|
|
||||||
// Full ellipse
|
// Full ellipse
|
||||||
const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2));
|
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 length = M_PI * (radius1 + radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h))) / 2;
|
||||||
VEllipticalArc arc(-length, center, radius1, radius2, f1, rotationAngle);
|
VEllipticalArc arc(-length, center, radius1, radius2, f1, rotationAngle);
|
||||||
|
|
||||||
const qreal eps = ToPixel(0.45, Unit::Mm); // computing error
|
const qreal eps = ToPixel(0.45, Unit::Mm); // computing error
|
||||||
|
@ -124,12 +126,10 @@ void TST_VEllipticalArc::NegativeArc()
|
||||||
const QString errorMsg =
|
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,
|
QVERIFY2(qAbs(arc.GetLength() + length) <= eps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length)));
|
||||||
qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length)));
|
|
||||||
|
|
||||||
const qreal angleEps = 0.4;
|
const qreal angleEps = 0.4;
|
||||||
QVERIFY2(arc.GetEndAngle() - f2 <= angleEps,
|
QVERIFY2(arc.GetEndAngle() - f2 <= angleEps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2)));
|
||||||
qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
|
@ -171,17 +171,17 @@ 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 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; 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 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
|
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 0")
|
||||||
<< 90.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 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; 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 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; 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
|
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90")
|
||||||
<< 50.0;
|
<< 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
|
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 90")
|
||||||
<< 90.0;
|
<< 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 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 150, 50, rotation 180") << 150.0 << 50.0 << 0.0 << 10.5 << 180.0;
|
||||||
|
@ -273,7 +273,7 @@ void TST_VEllipticalArc::TestData()
|
||||||
// cppcheck-suppress unusedFunction
|
// cppcheck-suppress unusedFunction
|
||||||
void TST_VEllipticalArc::TestGetPoints1()
|
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, radius1);
|
||||||
QFETCH(qreal, radius2);
|
QFETCH(qreal, radius2);
|
||||||
QFETCH(qreal, startAngle);
|
QFETCH(qreal, startAngle);
|
||||||
|
@ -291,12 +291,14 @@ void TST_VEllipticalArc::TestGetPoints1()
|
||||||
|
|
||||||
for (auto p : points)
|
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);
|
const qreal diff = qAbs(equationRes - 1);
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
const QString errorMsg = QString("Broken the first rule. Any point must satisfy the equation of ellipse."
|
const QString errorMsg = QString("Broken the first rule. Any point must satisfy the equation of ellipse."
|
||||||
"diff = '%1' > eps = '%2'").number(diff).number(eps);
|
"diff = '%1' > eps = '%2'")
|
||||||
QVERIFY2( diff <= eps, qUtf8Printable(errorMsg));
|
.number(diff)
|
||||||
|
.number(eps);
|
||||||
|
QVERIFY2(diff <= eps, qUtf8Printable(errorMsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,7 +319,7 @@ void TST_VEllipticalArc::TestGetPoints2()
|
||||||
arc.SetApproximationScale(maxCurveApproximationScale);
|
arc.SetApproximationScale(maxCurveApproximationScale);
|
||||||
QVector<QPointF> points = arc.GetPoints();
|
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
|
// distance from the center to the focus
|
||||||
|
|
||||||
QPointF focus1 = static_cast<QPointF>(center);
|
QPointF focus1 = static_cast<QPointF>(center);
|
||||||
|
@ -358,19 +360,23 @@ void TST_VEllipticalArc::TestGetPoints2()
|
||||||
|
|
||||||
const qreal distance = distance1.length() + distance2.length();
|
const qreal distance = distance1.length() + distance2.length();
|
||||||
const qreal eps = distance * 1.1 / 100; // computing error 1.1 % from origin distance
|
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 rLine1(focus1, points.at(i));
|
||||||
const QLineF rLine2(focus2, 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);
|
const qreal diff = qAbs(resultingDistance - distance);
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
const QString errorMsg = QString("Broken the first rule, part 2. Distance from the any point to the focus1"
|
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"
|
" plus distance from this point to the focus2 should be the same. Problem"
|
||||||
" with point '%1'. The disired distance is '%2', but resulting distance"
|
" with point '%1'. The disired distance is '%2', but resulting distance"
|
||||||
" is '%3'. Difference is '%4' and it biggest than eps '%5')").number(i)
|
" is '%3'. Difference is '%4' and it biggest than eps '%5')")
|
||||||
.number(distance).number(resultingDistance).number(diff).number(eps);
|
.number(i)
|
||||||
QVERIFY2( diff <= eps, qUtf8Printable(errorMsg));
|
.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();
|
QVector<QPointF> points = arc.GetPoints();
|
||||||
|
|
||||||
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
|
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
|
||||||
{// calculated full ellipse square
|
{ // calculated full ellipse square
|
||||||
const qreal ellipseSquare = M_PI * radius1 * radius2;
|
const qreal ellipseSquare = M_PI * radius1 * radius2;
|
||||||
const qreal epsSquare = ellipseSquare * 1.7 / 100; // computing error 1.7 % from origin square
|
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);
|
const qreal diffSquare = qAbs(ellipseSquare - arcSquare);
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
const QString errorMsg1 = QString("Broken the second rule. Interpolation has too big computing error. "
|
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));
|
QVERIFY2(diffSquare <= epsSquare, qUtf8Printable(errorMsg1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,15 +427,17 @@ void TST_VEllipticalArc::TestGetPoints4()
|
||||||
arc.SetApproximationScale(maxCurveApproximationScale);
|
arc.SetApproximationScale(maxCurveApproximationScale);
|
||||||
|
|
||||||
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
|
if (VFuzzyComparePossibleNulls(arc.AngleArc(), 360.0))
|
||||||
{// calculated full ellipse length
|
{ // calculated full ellipse length
|
||||||
const qreal h = ((radius1-radius2)*(radius1-radius2))/((radius1+radius2)*(radius1+radius2));
|
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 ellipseLength = M_PI * (radius1 + radius2) * (1 + 3 * h / (10 + qSqrt(4 - 3 * h)));
|
||||||
const qreal epsLength = ToPixel(1, Unit::Mm); // computing error
|
const qreal epsLength = ToPixel(1, Unit::Mm); // computing error
|
||||||
const qreal arcLength = VEllipticalArc(center, radius1, radius2, 0, 360, 0).GetLength();
|
const qreal arcLength = VEllipticalArc(center, radius1, radius2, 0, 360, 0).GetLength();
|
||||||
const qreal diffLength = qAbs(arcLength - ellipseLength);
|
const qreal diffLength = qAbs(arcLength - ellipseLength);
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
const QString errorMsg2 = QString("Difference between real and computing lengthes "
|
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));
|
QVERIFY2(diffLength <= epsLength, qUtf8Printable(errorMsg2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,8 +462,8 @@ void TST_VEllipticalArc::TestGetPoints5()
|
||||||
VEllipticalArc arc(center, radius1, radius2, startAngle, endAngle, rotationAngle);
|
VEllipticalArc arc(center, radius1, radius2, startAngle, endAngle, rotationAngle);
|
||||||
arc.SetApproximationScale(maxCurveApproximationScale);
|
arc.SetApproximationScale(maxCurveApproximationScale);
|
||||||
|
|
||||||
const qreal stAngle = VEllipticalArc::OptimizeAngle(arc.GetStartAngle()+arc.GetRotationAngle());
|
const qreal stAngle = VEllipticalArc::OptimizeAngle(arc.GetStartAngle() + arc.GetRotationAngle());
|
||||||
const qreal enAngle = VEllipticalArc::OptimizeAngle(arc.GetEndAngle()+arc.GetRotationAngle());
|
const qreal enAngle = VEllipticalArc::OptimizeAngle(arc.GetEndAngle() + arc.GetRotationAngle());
|
||||||
|
|
||||||
qreal f1 = QLineF(static_cast<QPointF>(center), arc.GetP1()).angle();
|
qreal f1 = QLineF(static_cast<QPointF>(center), arc.GetP1()).angle();
|
||||||
if ((qFuzzyIsNull(f1) && VFuzzyComparePossibleNulls(360, stAngle)) ||
|
if ((qFuzzyIsNull(f1) && VFuzzyComparePossibleNulls(360, stAngle)) ||
|
||||||
|
@ -503,17 +513,17 @@ void TST_VEllipticalArc::TestRotation_data()
|
||||||
QTest::addColumn<qreal>("degrees");
|
QTest::addColumn<qreal>("degrees");
|
||||||
QTest::addColumn<QString>("prefix");
|
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 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 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.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.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 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 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 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 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 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 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 9") << QPointF(10, 10) << 10. << 20.0 << 0. << 360. << 90. << QPointF() << 90. << "_r";
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -539,9 +549,8 @@ void TST_VEllipticalArc::TestRotation()
|
||||||
QString errorLengthMsg =
|
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),
|
QVERIFY2(qAbs(arcOrigin.GetLength() - rotatedArc.GetLength()) <= ToPixel(1, Unit::Mm),
|
||||||
qUtf8Printable(errorLengthMsg.arg(ToPixel(1, Unit::Mm))
|
qUtf8Printable(
|
||||||
.arg(arcOrigin.GetLength())
|
errorLengthMsg.arg(ToPixel(1, Unit::Mm)).arg(arcOrigin.GetLength()).arg(rotatedArc.GetLength())));
|
||||||
.arg(rotatedArc.GetLength())));
|
|
||||||
|
|
||||||
QCOMPARE(arcOrigin.GetRadius1(), rotatedArc.GetRadius1());
|
QCOMPARE(arcOrigin.GetRadius1(), rotatedArc.GetRadius1());
|
||||||
QCOMPARE(arcOrigin.GetRadius2(), rotatedArc.GetRadius2());
|
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);
|
const QString errorMsg = QString("The name doesn't contain the prefix '%1'.").arg(prefix);
|
||||||
QVERIFY2(res.name().endsWith(prefix), qUtf8Printable(errorMsg));
|
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.GetRadius1(), res.GetRadius1());
|
||||||
QCOMPARE(elArc.GetRadius2(), res.GetRadius2());
|
QCOMPARE(elArc.GetRadius2(), res.GetRadius2());
|
||||||
}
|
}
|
||||||
|
@ -600,8 +609,8 @@ void TST_VEllipticalArc::EmptyArc_data()
|
||||||
QTest::addColumn<qreal>("length");
|
QTest::addColumn<qreal>("length");
|
||||||
|
|
||||||
QTest::newRow("Empty elArc") << 0. << 0. << 0.;
|
QTest::newRow("Empty elArc") << 0. << 0. << 0.;
|
||||||
QTest::newRow("Radius1 correct") << 50. << 0. << 50.*4;
|
QTest::newRow("Radius1 correct") << 50. << 0. << 50. * 4;
|
||||||
QTest::newRow("Radius2 correct") << 0. << 30. << 30.*4;
|
QTest::newRow("Radius2 correct") << 0. << 30. << 30. * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user