Refactoring.
Code style.
This commit is contained in:
parent
ff6689f247
commit
baf4f1a08b
|
@ -41,11 +41,13 @@ 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,10 +39,10 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
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)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -64,9 +64,9 @@ 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)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -119,22 +119,22 @@ auto DialogMDataBase::GetNewNames() const -> QStringList
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMDataBase::RetranslateGroups()
|
void DialogMDataBase::RetranslateGroups()
|
||||||
{
|
{
|
||||||
RetranslateGroup(m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA());
|
RetranslateGroup(m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA());
|
||||||
RetranslateGroup(m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB());
|
RetranslateGroup(m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB());
|
||||||
RetranslateGroup(m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC());
|
RetranslateGroup(m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC());
|
||||||
RetranslateGroup(m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD());
|
RetranslateGroup(m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD());
|
||||||
RetranslateGroup(m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE());
|
RetranslateGroup(m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE());
|
||||||
RetranslateGroup(m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF());
|
RetranslateGroup(m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF());
|
||||||
RetranslateGroup(m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG());
|
RetranslateGroup(m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG());
|
||||||
RetranslateGroup(m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH());
|
RetranslateGroup(m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH());
|
||||||
RetranslateGroup(m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI());
|
RetranslateGroup(m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI());
|
||||||
RetranslateGroup(m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ());
|
RetranslateGroup(m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ());
|
||||||
RetranslateGroup(m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK());
|
RetranslateGroup(m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK());
|
||||||
RetranslateGroup(m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL());
|
RetranslateGroup(m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL());
|
||||||
RetranslateGroup(m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM());
|
RetranslateGroup(m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM());
|
||||||
RetranslateGroup(m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN());
|
RetranslateGroup(m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN());
|
||||||
RetranslateGroup(m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO());
|
RetranslateGroup(m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO());
|
||||||
RetranslateGroup(m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP());
|
RetranslateGroup(m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP());
|
||||||
RetranslateGroup(m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ());
|
RetranslateGroup(m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ());
|
||||||
|
|
||||||
ShowDescription(ui->treeWidget->currentItem(), 0);
|
ShowDescription(ui->treeWidget->currentItem(), 0);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -379,22 +378,22 @@ void DialogMDataBase::FilterMeasurements(const QString &search)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogMDataBase::InitDataBase(const QStringList &list)
|
void DialogMDataBase::InitDataBase(const QStringList &list)
|
||||||
{
|
{
|
||||||
InitGroup(&m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list);
|
InitGroup(&m_groupA, "A. " + tr("Direct Height", "Measurement section"), ListGroupA(), list);
|
||||||
InitGroup(&m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list);
|
InitGroup(&m_groupB, "B. " + tr("Direct Width", "Measurement section"), ListGroupB(), list);
|
||||||
InitGroup(&m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list);
|
InitGroup(&m_groupC, "C. " + tr("Indentation", "Measurement section"), ListGroupC(), list);
|
||||||
InitGroup(&m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list);
|
InitGroup(&m_groupD, "D. " + tr("Hand", "Measurement section"), ListGroupD(), list);
|
||||||
InitGroup(&m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list);
|
InitGroup(&m_groupE, "E. " + tr("Foot", "Measurement section"), ListGroupE(), list);
|
||||||
InitGroup(&m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list);
|
InitGroup(&m_groupF, "F. " + tr("Head", "Measurement section"), ListGroupF(), list);
|
||||||
InitGroup(&m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list);
|
InitGroup(&m_groupG, "G. " + tr("Circumference and Arc", "Measurement section"), ListGroupG(), list);
|
||||||
InitGroup(&m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list);
|
InitGroup(&m_groupH, "H. " + tr("Vertical", "Measurement section"), ListGroupH(), list);
|
||||||
InitGroup(&m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list);
|
InitGroup(&m_groupI, "I. " + tr("Horizontal", "Measurement section"), ListGroupI(), list);
|
||||||
InitGroup(&m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list);
|
InitGroup(&m_groupJ, "J. " + tr("Bust", "Measurement section"), ListGroupJ(), list);
|
||||||
InitGroup(&m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list);
|
InitGroup(&m_groupK, "K. " + tr("Balance", "Measurement section"), ListGroupK(), list);
|
||||||
InitGroup(&m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list);
|
InitGroup(&m_groupL, "L. " + tr("Arm", "Measurement section"), ListGroupL(), list);
|
||||||
InitGroup(&m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list);
|
InitGroup(&m_groupM, "M. " + tr("Leg", "Measurement section"), ListGroupM(), list);
|
||||||
InitGroup(&m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list);
|
InitGroup(&m_groupN, "N. " + tr("Crotch and Rise", "Measurement section"), ListGroupN(), list);
|
||||||
InitGroup(&m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list);
|
InitGroup(&m_groupO, "O. " + tr("Men & Tailoring", "Measurement section"), ListGroupO(), list);
|
||||||
InitGroup(&m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list);
|
InitGroup(&m_groupP, "P. " + tr("Historical & Specialty", "Measurement section"), ListGroupP(), list);
|
||||||
InitGroup(&m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ(), list);
|
InitGroup(&m_groupQ, "Q. " + tr("Patternmaking measurements", "Measurement section"), ListGroupQ(), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,14 +414,14 @@ void DialogMDataBase::FilterGroup(QTreeWidgetItem *group, const QString &search)
|
||||||
SCASSERT(group != nullptr)
|
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)
|
||||||
|
@ -474,7 +473,7 @@ void DialogMDataBase::AddMeasurement(QTreeWidgetItem *group, const QString &name
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString text = VAbstractApplication::VApp()->TrVars()->MNumber(name) + ". " +
|
const QString text = VAbstractApplication::VApp()->TrVars()->MNumber(name) + ". " +
|
||||||
VAbstractApplication::VApp()->TrVars()->MToUser(name);
|
VAbstractApplication::VApp()->TrVars()->MToUser(name);
|
||||||
m->setText(0, text);
|
m->setText(0, text);
|
||||||
m->setToolTip(0, text);
|
m->setToolTip(0, text);
|
||||||
m->setData(0, Qt::UserRole, name);
|
m->setData(0, Qt::UserRole, name);
|
||||||
|
@ -518,8 +517,8 @@ auto DialogMDataBase::ItemFullDescription(QTreeWidgetItem *item, bool showImage)
|
||||||
"normal\"> %1 <br clear=\"left\"><b>%2</b>. <i>%3</i></p>"
|
"normal\"> %1 <br clear=\"left\"><b>%2</b>. <i>%3</i></p>"
|
||||||
"<p align=\"left\" style=\"font-variant: normal; font-style: normal; font-weight: "
|
"<p align=\"left\" style=\"font-variant: normal; font-style: normal; font-weight: "
|
||||||
"normal\">%4</p>")
|
"normal\">%4</p>")
|
||||||
.arg(imgTag, number, VAbstractApplication::VApp()->TrVars()->GuiText(name),
|
.arg(imgTag, number, VAbstractApplication::VApp()->TrVars()->GuiText(name),
|
||||||
VAbstractApplication::VApp()->TrVars()->Description(name));
|
VAbstractApplication::VApp()->TrVars()->Description(name));
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -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));
|
||||||
}
|
}
|
||||||
|
@ -540,7 +539,7 @@ void DialogMDataBase::RetranslateGroup(QTreeWidgetItem *group, const QString &gr
|
||||||
void DialogMDataBase::RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name)
|
void DialogMDataBase::RetranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name)
|
||||||
{
|
{
|
||||||
const QString text = VAbstractApplication::VApp()->TrVars()->MNumber(name) + ". " +
|
const QString text = VAbstractApplication::VApp()->TrVars()->MNumber(name) + ". " +
|
||||||
VAbstractApplication::VApp()->TrVars()->MToUser(name);
|
VAbstractApplication::VApp()->TrVars()->MToUser(name);
|
||||||
|
|
||||||
QTreeWidgetItem *m = group->child(index);
|
QTreeWidgetItem *m = group->child(index);
|
||||||
m->setText(0, text);
|
m->setText(0, text);
|
||||||
|
@ -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;
|
||||||
|
@ -120,7 +120,7 @@ public:
|
||||||
static auto GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue) -> qreal;
|
static auto GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue) -> qreal;
|
||||||
static auto GetParametrId(const QDomElement &domElement) -> quint32;
|
static auto GetParametrId(const QDomElement &domElement) -> quint32;
|
||||||
|
|
||||||
virtual void setXMLContent(const QString &fileName);
|
virtual void setXMLContent(const QString &fileName);
|
||||||
static auto UnitsHelpString() -> QString;
|
static auto UnitsHelpString() -> QString;
|
||||||
|
|
||||||
auto CreateElementWithText(const QString &tagName, const QString &text) -> QDomElement;
|
auto CreateElementWithText(const QString &tagName, const QString &text) -> QDomElement;
|
||||||
|
@ -131,7 +131,7 @@ public:
|
||||||
auto Patch() const -> QString;
|
auto Patch() const -> QString;
|
||||||
virtual auto GetFormatVersionStr() const -> QString;
|
virtual auto GetFormatVersionStr() const -> QString;
|
||||||
static auto GetFormatVersion(const QString &version) -> unsigned;
|
static auto GetFormatVersion(const QString &version) -> unsigned;
|
||||||
static void RemoveAllChildren(QDomElement &domElement);
|
static void RemoveAllChildren(QDomElement &domElement);
|
||||||
|
|
||||||
auto ParentNodeById(const quint32 &nodeId) -> QDomNode;
|
auto ParentNodeById(const quint32 &nodeId) -> QDomNode;
|
||||||
auto CloneNodeById(const quint32 &nodeId) -> QDomElement;
|
auto CloneNodeById(const quint32 &nodeId) -> QDomElement;
|
||||||
|
@ -140,9 +140,9 @@ public:
|
||||||
static auto SafeCopy(const QString &source, const QString &destination, QString &error) -> bool;
|
static auto SafeCopy(const QString &source, const QString &destination, QString &error) -> bool;
|
||||||
|
|
||||||
auto GetLabelTemplate(const QDomElement &element) const -> QVector<VLabelTemplateLine>;
|
auto GetLabelTemplate(const QDomElement &element) const -> QVector<VLabelTemplateLine>;
|
||||||
void SetLabelTemplate(QDomElement &element, const QVector<VLabelTemplateLine> &lines);
|
void SetLabelTemplate(QDomElement &element, const QVector<VLabelTemplateLine> &lines);
|
||||||
|
|
||||||
void TestUniqueId() const;
|
void TestUniqueId() const;
|
||||||
|
|
||||||
void RefreshElementIdCache();
|
void RefreshElementIdCache();
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ private:
|
||||||
// cppcheck-suppress unknownMacro
|
// cppcheck-suppress unknownMacro
|
||||||
Q_DISABLE_COPY_MOVE(VDomDocument) // NOLINT
|
Q_DISABLE_COPY_MOVE(VDomDocument) // NOLINT
|
||||||
/** @brief Map used for finding element by id. */
|
/** @brief Map used for finding element by id. */
|
||||||
QHash<quint32, QDomElement> m_elementIdCache;
|
QHash<quint32, QDomElement> m_elementIdCache;
|
||||||
QFutureWatcher<QHash<quint32, QDomElement>> *m_watcher;
|
QFutureWatcher<QHash<quint32, QDomElement>> *m_watcher;
|
||||||
|
|
||||||
static auto find(QHash<quint32, QDomElement> &cache, const QDomElement &node, quint32 id) -> bool;
|
static auto find(QHash<quint32, QDomElement> &cache, const QDomElement &node, quint32 id) -> bool;
|
||||||
|
@ -223,14 +223,14 @@ template <>
|
||||||
inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement, const QString &name,
|
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,22 +55,25 @@ 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_LOCALE_VARIABLES(m_locale);
|
INIT_LOCALE_VARIABLES(m_locale);
|
||||||
|
@ -153,7 +156,7 @@ void QmuFormulaBase::SetSepForTr(bool osSeparator, bool fromUser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSepForEval();//Same separators (internal) as for eval.
|
SetSepForEval(); // Same separators (internal) as for eval.
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -177,13 +180,13 @@ void QmuFormulaBase::SetSepForEval()
|
||||||
* @param map map with tokens
|
* @param 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,13 +43,13 @@ 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
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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,10 +227,10 @@ 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)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -636,32 +634,33 @@ inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound)
|
||||||
|
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
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(
|
||||||
i = j;
|
IntersectionPoint(crosPoint, points.at(i), points.at(i + 1), points.at(j), points.at(j + 1)));
|
||||||
loopFound = true;
|
i = j;
|
||||||
break;
|
loopFound = true;
|
||||||
case NoIntersection:
|
break;
|
||||||
/*We have not found loop.*/
|
case NoIntersection:
|
||||||
ekvPoints.append(points.at(i));
|
/*We have not found loop.*/
|
||||||
break;
|
ekvPoints.append(points.at(i));
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ekvPoints;
|
return ekvPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
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,42 +33,42 @@
|
||||||
#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)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
papers(),
|
papers(),
|
||||||
bank(new VBank()),
|
bank(new VBank()),
|
||||||
paperHeight(0),
|
paperHeight(0),
|
||||||
paperWidth(0),
|
paperWidth(0),
|
||||||
margins(),
|
margins(),
|
||||||
usePrinterFields(true),
|
usePrinterFields(true),
|
||||||
#ifdef Q_CC_MSVC
|
#ifdef Q_CC_MSVC
|
||||||
// See https://stackoverflow.com/questions/15750917/initializing-stdatomic-bool
|
// See https://stackoverflow.com/questions/15750917/initializing-stdatomic-bool
|
||||||
stopGeneration(ATOMIC_VAR_INIT(false)),
|
stopGeneration(ATOMIC_VAR_INIT(false)),
|
||||||
#else
|
#else
|
||||||
stopGeneration(false),
|
stopGeneration(false),
|
||||||
#endif
|
#endif
|
||||||
state(LayoutErrors::NoError),
|
state(LayoutErrors::NoError),
|
||||||
shift(0),
|
shift(0),
|
||||||
rotate(true),
|
rotate(true),
|
||||||
followGrainline(false),
|
followGrainline(false),
|
||||||
rotationNumber(2),
|
rotationNumber(2),
|
||||||
autoCropLength(false),
|
autoCropLength(false),
|
||||||
autoCropWidth(false),
|
autoCropWidth(false),
|
||||||
saveLength(false),
|
saveLength(false),
|
||||||
unitePages(false),
|
unitePages(false),
|
||||||
stripOptimizationEnabled(false),
|
stripOptimizationEnabled(false),
|
||||||
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"
|
||||||
|
@ -62,20 +62,19 @@ private:
|
||||||
bool m_curvePoint{false};
|
bool m_curvePoint{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(VLayoutPoint) // NOLINT
|
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();
|
||||||
|
@ -109,13 +108,15 @@ 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 {};
|
||||||
}
|
}
|
||||||
|
@ -136,12 +133,13 @@ auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSh
|
||||||
printer->setResolution(static_cast<int>(PrintDPI));
|
printer->setResolution(static_cast<int>(PrintDPI));
|
||||||
return printer;
|
return printer;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
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,12 +668,13 @@ 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);
|
{
|
||||||
SCASSERT(p != nullptr)
|
auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(paperItem);
|
||||||
return paper->rect() == p->rect();
|
SCASSERT(p != nullptr)
|
||||||
});
|
return paper->rect() == p->rect();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -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);
|
||||||
|
|
|
@ -64,27 +64,30 @@ private:
|
||||||
bool m_primary{false};
|
bool m_primary{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(VRawSAPoint) // NOLINT
|
Q_DECLARE_METATYPE(VRawSAPoint) // NOLINT
|
||||||
Q_DECLARE_TYPEINFO(VRawSAPoint, Q_MOVABLE_TYPE); // NOLINT
|
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)
|
||||||
: VLayoutPoint(p)
|
: VLayoutPoint(p)
|
||||||
{
|
{
|
||||||
SetCurvePoint(curvePoint);
|
SetCurvePoint(curvePoint);
|
||||||
SetTurnPoint(turnPoint);
|
SetTurnPoint(turnPoint);
|
||||||
|
@ -92,8 +95,8 @@ Q_DECL_RELAXED_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p, bool curvePo
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Q_DECL_RELAXED_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p, bool curvePoint, bool turnPoint, bool loopPoint)
|
Q_DECL_RELAXED_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p, bool curvePoint, bool turnPoint, bool loopPoint)
|
||||||
: VLayoutPoint(p),
|
: VLayoutPoint(p),
|
||||||
m_loopPoint(loopPoint)
|
m_loopPoint(loopPoint)
|
||||||
{
|
{
|
||||||
SetCurvePoint(curvePoint);
|
SetCurvePoint(curvePoint);
|
||||||
SetTurnPoint(turnPoint);
|
SetTurnPoint(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};
|
||||||
|
@ -114,23 +115,26 @@ private:
|
||||||
bool m_passmarkClockwiseOpening{false};
|
bool m_passmarkClockwiseOpening{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(VSAPoint) // NOLINT
|
Q_DECLARE_METATYPE(VSAPoint) // NOLINT
|
||||||
Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); // NOLINT
|
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
|
||||||
|
|
|
@ -43,13 +43,13 @@ 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
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -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,56 +124,53 @@ 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.
|
||||||
// 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.
|
||||||
auto value = static_cast<IntermediateType>(
|
auto value = static_cast<IntermediateType>(
|
||||||
static_cast<double>(static_cast<IntermediateType>(m_value) * y.m_value) / (FRACTION_MULT / 2));
|
static_cast<double>(static_cast<IntermediateType>(m_value) * y.m_value) / (FRACTION_MULT / 2));
|
||||||
m_value = static_cast<BaseType>((value / 2) + (value % 2));
|
m_value = static_cast<BaseType>((value / 2) + (value % 2));
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
@ -388,7 +382,7 @@ QT_WARNING_DISABLE_CLANG("-Wunneeded-internal-declaration")
|
||||||
static constexpr auto max_digits10(int bits) -> int
|
static constexpr auto max_digits10(int bits) -> int
|
||||||
{
|
{
|
||||||
// 8.24 fixed-point equivalent of (int)ceil(bits * std::log10(2));
|
// 8.24 fixed-point equivalent of (int)ceil(bits * std::log10(2));
|
||||||
using T = long long; // NOLINT(google-runtime-int)
|
using T = long long; // NOLINT(google-runtime-int)
|
||||||
return static_cast<int>((T{bits} * 5050445 + (T{1} << 24) - 1) >> 24); // NOLINT(hicpp-signed-bitwise)
|
return static_cast<int>((T{bits} * 5050445 + (T{1} << 24) - 1) >> 24); // NOLINT(hicpp-signed-bitwise)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,8 +390,8 @@ static constexpr auto max_digits10(int bits) -> int
|
||||||
static constexpr auto digits10(int bits) -> int
|
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,87 +453,77 @@ 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
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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,20 +50,19 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
//
|
//
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ constexpr inline auto islessgreater(fixed<B, I, F> x, fixed<B, I, F> y) noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F>
|
||||||
constexpr inline auto isunordered(fixed<B, I, F> /*x*/, fixed<B, I, F> /*y*/) noexcept -> bool
|
constexpr inline auto isunordered(fixed<B, I, F> /*x*/, fixed<B, I, F> /*y*/) noexcept -> bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -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,17 +224,15 @@ inline auto remquo(fixed<B, I, F> x, fixed<B, I, F> y, int* quo) noexcept -> fix
|
||||||
template <typename B, typename I, unsigned int F, typename C, typename J, unsigned int G>
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
template <typename B, typename I, unsigned int F>
|
||||||
|
@ -254,7 +242,7 @@ constexpr inline auto nexttoward(fixed<B, I, F> from, fixed<B, I, F> to) noexcep
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename B, typename I, unsigned int F>
|
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,28 +596,31 @@ auto atan_div(fixed<B, I, F> y, fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
// Make sure y and x are positive.
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 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>
|
||||||
|
@ -697,6 +681,6 @@ auto atan2(fixed<B, I, F> y, fixed<B, I, F> x) noexcept -> fixed<B, I, F>
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace fpm
|
} // namespace fpm
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,19 +38,18 @@ 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"}},
|
||||||
{QStringConverter::Utf16LE, {"UTF-16LE"}},
|
{QStringConverter::Utf16LE, {"UTF-16LE"}},
|
||||||
{QStringConverter::Utf32, {"UTF-32"}},
|
{QStringConverter::Utf32, {"UTF-32"}},
|
||||||
{QStringConverter::Utf32BE, {"UTF-32BE"}},
|
{QStringConverter::Utf32BE, {"UTF-32BE"}},
|
||||||
{QStringConverter::Utf32LE, {"UTF-32LE"}},
|
{QStringConverter::Utf32LE, {"UTF-32LE"}},
|
||||||
{QStringConverter::System, {"System"}},
|
{QStringConverter::System, {"System"}},
|
||||||
};
|
};
|
||||||
|
|
||||||
return codecs;
|
return codecs;
|
||||||
|
@ -59,27 +58,21 @@ 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;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
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 *
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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
|
||||||
|
@ -136,7 +132,7 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
|
||||||
/* To try this out, write "#define INEXACT volatile" below. Normally, */
|
/* To try this out, write "#define INEXACT volatile" below. Normally, */
|
||||||
/* however, INEXACT should be defined to be nothing. ("#define INEXACT".) */
|
/* however, INEXACT should be defined to be nothing. ("#define INEXACT".) */
|
||||||
|
|
||||||
#define INEXACT /* Nothing */
|
#define INEXACT /* Nothing */
|
||||||
/* #define INEXACT volatile */
|
/* #define INEXACT volatile */
|
||||||
|
|
||||||
#define REALPRINT doubleprint
|
#define REALPRINT doubleprint
|
||||||
|
@ -150,10 +146,9 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
|
||||||
/* which is disastrously slow. A faster way on IEEE machines might be to */
|
/* which is disastrously slow. A faster way on IEEE machines might be to */
|
||||||
/* mask the appropriate bit, but that's difficult to do in C. */
|
/* mask the appropriate bit, but that's difficult to do in C. */
|
||||||
|
|
||||||
#define Absolute(a) ((a) >= 0.0 ? (a) : -(a))
|
#define Absolute(a) ((a) >= 0.0 ? (a) : -(a))
|
||||||
/* #define Absolute(a) fabs(a) */
|
/* #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. */
|
||||||
|
@ -167,98 +162,98 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
|
||||||
/* The input parameter `x' (or the highest numbered `x_' parameter) must */
|
/* The input parameter `x' (or the highest numbered `x_' parameter) must */
|
||||||
/* also be declared `INEXACT'. */
|
/* also be declared `INEXACT'. */
|
||||||
|
|
||||||
#define Fast_Two_Sum_Tail(a, b, x, y) \
|
#define Fast_Two_Sum_Tail(a, b, x, y) \
|
||||||
bvirt = x - a; \
|
bvirt = x - a; \
|
||||||
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
|
||||||
|
|
||||||
#define Two_Product_Tail(a, b, x, y) \
|
#define Two_Product_Tail(a, b, x, y) \
|
||||||
Split(a, ahi, alo); \
|
Split(a, ahi, alo); \
|
||||||
Split(b, bhi, blo); \
|
Split(b, bhi, blo); \
|
||||||
err1 = x - (ahi * bhi); \
|
err1 = x - (ahi * bhi); \
|
||||||
err2 = err1 - (alo * bhi); \
|
err2 = err1 - (alo * bhi); \
|
||||||
err3 = err2 - (ahi * blo); \
|
err3 = err2 - (ahi * blo); \
|
||||||
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); \
|
||||||
err3 = err2 - (ahi * blo); \
|
err3 = err2 - (ahi * blo); \
|
||||||
y = (alo * blo) - err3
|
y = (alo * blo) - err3
|
||||||
|
|
||||||
/* Square() can be done more quickly than Two_Product(). */
|
/* Square() can be done more quickly than Two_Product(). */
|
||||||
|
|
||||||
#define Square_Tail(a, x, y) \
|
#define Square_Tail(a, x, y) \
|
||||||
Split(a, ahi, alo); \
|
Split(a, ahi, alo); \
|
||||||
err1 = x - (ahi * ahi); \
|
err1 = x - (ahi * ahi); \
|
||||||
err3 = err1 - ((ahi + ahi) * alo); \
|
err3 = err1 - ((ahi + ahi) * alo); \
|
||||||
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); \
|
||||||
Two_One_Sum(_j, _0, b1, x3, x2, x1)
|
Two_One_Sum(_j, _0, b1, x3, x2, x1)
|
||||||
|
|
||||||
#define Two_Two_Diff(a1, a0, b1, b0, x3, x2, x1, x0) \
|
#define Two_Two_Diff(a1, a0, b1, b0, x3, x2, x1, x0) \
|
||||||
Two_One_Diff(a1, a0, b0, _j, _0, x0); \
|
Two_One_Diff(a1, a0, b0, _j, _0, x0); \
|
||||||
Two_One_Diff(_j, _0, b1, x3, x2, x1)
|
Two_One_Diff(_j, _0, b1, x3, x2, x1)
|
||||||
|
|
||||||
qreal splitter; /* = 2^ceiling(p / 2) + 1. Used to split floats in half. */
|
qreal splitter; /* = 2^ceiling(p / 2) + 1. Used to split floats in half. */
|
||||||
qreal epsilon; /* = 2^(-p). Used to estimate roundoff errors. */
|
qreal epsilon; /* = 2^(-p). Used to estimate roundoff errors. */
|
||||||
/* A set of coefficients used to calculate maximum roundoff errors. */
|
/* A set of coefficients used to calculate maximum roundoff errors. */
|
||||||
qreal resulterrbound;
|
qreal resulterrbound;
|
||||||
qreal ccwerrboundA, ccwerrboundB, ccwerrboundC;
|
qreal ccwerrboundA, ccwerrboundB, ccwerrboundC;
|
||||||
|
@ -463,8 +458,9 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
|
||||||
Split(b, bhi, blo);
|
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,11 +61,11 @@ 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())
|
||||||
{ // Just in case
|
{ // Just in case
|
||||||
return PassmarkStatus::Error; // Something wrong
|
return PassmarkStatus::Error; // Something wrong
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -604,15 +604,14 @@ auto VPiecePassmarkData::toJson() const -> QJsonObject
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPassmark::VPassmark(const VPiecePassmarkData &data)
|
VPassmark::VPassmark(const VPiecePassmarkData &data)
|
||||||
: m_data(data),
|
: m_data(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())
|
||||||
{
|
{
|
||||||
|
@ -940,10 +937,10 @@ auto VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const -> QVector<
|
||||||
{
|
{
|
||||||
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2' with built "
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2' with built "
|
||||||
"in seam allowance. User must manually provide length.")
|
"in seam allowance. User must manually provide length.")
|
||||||
.arg(m_data.nodeName, m_data.pieceName);
|
.arg(m_data.nodeName, m_data.pieceName);
|
||||||
VAbstractApplication::VApp()->IsPedantic()
|
VAbstractApplication::VApp()->IsPedantic()
|
||||||
? throw VExceptionInvalidNotch(errorMsg)
|
? throw VExceptionInvalidNotch(errorMsg)
|
||||||
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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(),
|
||||||
IgnoreDataChangedSignal(false)
|
Model(nullptr),
|
||||||
{}
|
PropertySet(nullptr),
|
||||||
|
NeedsRebuild(false),
|
||||||
|
IgnoreDataChangedSignal(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
explicit VPropertyFormViewPrivate(VPropertyModel* prop_model)
|
explicit VPropertyFormViewPrivate(VPropertyModel *prop_model)
|
||||||
: VPropertyFormWidgetPrivate(), Model(prop_model), PropertySet(nullptr), NeedsRebuild(false),
|
: VPropertyFormWidgetPrivate(),
|
||||||
IgnoreDataChangedSignal(false)
|
Model(prop_model),
|
||||||
{}
|
PropertySet(nullptr),
|
||||||
|
NeedsRebuild(false),
|
||||||
|
IgnoreDataChangedSignal(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
explicit VPropertyFormViewPrivate(VPropertySet* prop_set)
|
explicit VPropertyFormViewPrivate(VPropertySet *prop_set)
|
||||||
: VPropertyFormWidgetPrivate(), Model(nullptr), PropertySet(prop_set), NeedsRebuild(false),
|
: VPropertyFormWidgetPrivate(),
|
||||||
IgnoreDataChangedSignal(false)
|
Model(nullptr),
|
||||||
{}
|
PropertySet(prop_set),
|
||||||
|
NeedsRebuild(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
|
||||||
|
@ -69,6 +75,6 @@ public:
|
||||||
|
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|
||||||
} // namespace VPE
|
} // namespace VPE
|
||||||
|
|
||||||
#endif // VWIDGETPROPERTY_P_H
|
#endif // VWIDGETPROPERTY_P_H
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -262,15 +259,15 @@ auto VToolFlippingByAxis::MakeToolTip() const -> QString
|
||||||
{
|
{
|
||||||
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>"
|
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>"
|
||||||
"%3")
|
"%3")
|
||||||
.arg(tr("Origin point"), OriginPointName()) // 1, 2
|
.arg(tr("Origin point"), OriginPointName()) // 1, 2
|
||||||
.arg(VisibilityGroupToolTip()); // 3
|
.arg(VisibilityGroupToolTip()); // 3
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent)
|
VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent)
|
||||||
: VAbstractFlipping(initData, parent),
|
: VAbstractFlipping(initData, parent),
|
||||||
m_originPointId(initData.originPointId),
|
m_originPointId(initData.originPointId),
|
||||||
m_axisType(initData.axisType)
|
m_axisType(initData.axisType)
|
||||||
{
|
{
|
||||||
InitOperatedObjects();
|
InitOperatedObjects();
|
||||||
ToolCreation(initData.typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
|
|
|
@ -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,16 +250,15 @@ 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolFlippingByLine::VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent)
|
VToolFlippingByLine::VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent)
|
||||||
: VAbstractFlipping(initData, parent),
|
: VAbstractFlipping(initData, parent),
|
||||||
m_firstLinePointId(initData.firstLinePointId),
|
m_firstLinePointId(initData.firstLinePointId),
|
||||||
m_secondLinePointId(initData.secondLinePointId)
|
m_secondLinePointId(initData.secondLinePointId)
|
||||||
{
|
{
|
||||||
InitOperatedObjects();
|
InitOperatedObjects();
|
||||||
ToolCreation(initData.typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
|
|
|
@ -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,10 +230,9 @@ 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:
|
||||||
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength,
|
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength,
|
||||||
|
@ -241,19 +240,16 @@ 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,
|
initData.data));
|
||||||
rotationOrigin,
|
|
||||||
initData.suffix,
|
|
||||||
initData.data));
|
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
@ -529,25 +524,25 @@ auto VToolMove::MakeToolTip() const -> QString
|
||||||
"<tr> <td><b>%6:</b> %7°</td> </tr>"
|
"<tr> <td><b>%6:</b> %7°</td> </tr>"
|
||||||
"<tr> <td><b>%8:</b> %9</td> </tr>"
|
"<tr> <td><b>%8:</b> %9</td> </tr>"
|
||||||
"%10")
|
"%10")
|
||||||
.arg(tr("Angle")) // 1
|
.arg(tr("Angle")) // 1
|
||||||
.arg(GetFormulaAngle().getDoubleValue()) // 2
|
.arg(GetFormulaAngle().getDoubleValue()) // 2
|
||||||
.arg(tr("Length")) // 3
|
.arg(tr("Length")) // 3
|
||||||
.arg(GetFormulaLength().getDoubleValue()) // 4
|
.arg(GetFormulaLength().getDoubleValue()) // 4
|
||||||
.arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), // 5
|
.arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), // 5
|
||||||
tr("Rotation angle")) // 6
|
tr("Rotation angle")) // 6
|
||||||
.arg(GetFormulaRotationAngle().getDoubleValue()) // 7
|
.arg(GetFormulaRotationAngle().getDoubleValue()) // 7
|
||||||
.arg(tr("Rotation origin point"), // 8
|
.arg(tr("Rotation origin point"), // 8
|
||||||
OriginPointName()) // 9
|
OriginPointName()) // 9
|
||||||
.arg(VisibilityGroupToolTip()); // 10
|
.arg(VisibilityGroupToolTip()); // 10
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
|
VToolMove::VToolMove(const VToolMoveInitData &initData, QGraphicsItem *parent)
|
||||||
: VAbstractOperation(initData, parent),
|
: VAbstractOperation(initData, parent),
|
||||||
formulaAngle(initData.formulaAngle),
|
formulaAngle(initData.formulaAngle),
|
||||||
formulaRotationAngle(initData.formulaRotationAngle),
|
formulaRotationAngle(initData.formulaRotationAngle),
|
||||||
formulaLength(initData.formulaLength),
|
formulaLength(initData.formulaLength),
|
||||||
origPointId(initData.rotationOrigin)
|
origPointId(initData.rotationOrigin)
|
||||||
{
|
{
|
||||||
InitOperatedObjects();
|
InitOperatedObjects();
|
||||||
ToolCreation(initData.typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
|
@ -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,20 +130,20 @@ 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)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
m_curFileFormatVersion(0x0),
|
m_curFileFormatVersion(0x0),
|
||||||
m_curFileFormatVersionStr(QLatin1String("0.0.0"))
|
m_curFileFormatVersionStr(QLatin1String("0.0.0"))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MaxRecentFiles; ++i)
|
for (int i = 0; i < MaxRecentFiles; ++i)
|
||||||
{
|
{
|
||||||
|
@ -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>
|
||||||
|
@ -39,8 +39,9 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
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,37 +340,30 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
VArc circle(VPointF(100, 100, QChar('C'), 0, 0), 100, 35, 35);
|
VArc circle(VPointF(100, 100, QChar('C'), 0, 0), 100, 35, 35);
|
||||||
circle.SetApproximationScale(maxCurveApproximationScale);
|
circle.SetApproximationScale(maxCurveApproximationScale);
|
||||||
QVector<QPointF> circlePath = circle.GetPoints();
|
QVector<QPointF> circlePath = circle.GetPoints();
|
||||||
if (not circlePath.isEmpty() && not VFuzzyComparePoints(ConstFirst(circlePath), ConstLast(circlePath)))
|
if (not circlePath.isEmpty() && not VFuzzyComparePoints(ConstFirst(circlePath), ConstLast(circlePath)))
|
||||||
{
|
{
|
||||||
circlePath.append(ConstFirst(circlePath));
|
circlePath.append(ConstFirst(circlePath));
|
||||||
}
|
}
|
||||||
QTest::newRow("Circle radis 100") << circlePath << M_PI * pow(100, 2);
|
QTest::newRow("Circle radis 100") << circlePath << M_PI * pow(100, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
VPointF sectorCenter(100, 100, QChar('C'), 0, 0);
|
VPointF sectorCenter(100, 100, QChar('C'), 0, 0);
|
||||||
VArc sector(sectorCenter, 100, 15, 45);
|
VArc sector(sectorCenter, 100, 15, 45);
|
||||||
sector.SetApproximationScale(maxCurveApproximationScale);
|
sector.SetApproximationScale(maxCurveApproximationScale);
|
||||||
QVector<QPointF> sectorPath = sector.GetPoints();
|
QVector<QPointF> sectorPath = sector.GetPoints();
|
||||||
sectorPath.append(sectorCenter.toQPointF());
|
sectorPath.append(sectorCenter.toQPointF());
|
||||||
sectorPath.append(ConstFirst(sectorPath));
|
sectorPath.append(ConstFirst(sectorPath));
|
||||||
QTest::newRow("Sector radius 100, 30 degree") << sectorPath << (M_PI * pow(100, 2) * 30.0) / 360.0;
|
QTest::newRow("Sector radius 100, 30 degree") << sectorPath << (M_PI * pow(100, 2) * 30.0) / 360.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,7 +373,7 @@ void TST_VAbstractPiece::TestAreaCalculation() const
|
||||||
QFETCH(QVector<QPointF>, path);
|
QFETCH(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,28 +38,33 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
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,30 +214,31 @@ 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 =
|
||||||
QString("Broken the second rule. Interpolation has too big computing error. Error ='%1'.").arg(value);
|
QString("Broken the second rule. Interpolation has too big computing error. Error ='%1'.").arg(value);
|
||||||
const qreal epsSquare = gSquare * 0.24 / 100; // computing error 0.24 % from origin square
|
const qreal epsSquare = gSquare * 0.24 / 100; // computing error 0.24 % from origin square
|
||||||
QVERIFY2(value <= epsSquare, qUtf8Printable(errorMsg));
|
QVERIFY2(value <= epsSquare, qUtf8Printable(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()
|
||||||
|
@ -87,7 +89,7 @@ void TST_VEllipticalArc::CompareTwoWays()
|
||||||
|
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
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(arc2.GetLength() - length) <= lengthEps,
|
QVERIFY2(qAbs(arc2.GetLength() - length) <= lengthEps,
|
||||||
qUtf8Printable(errorLengthMsg.arg(lengthEps).arg(arc2.GetLength()).arg(length)));
|
qUtf8Printable(errorLengthMsg.arg(lengthEps).arg(arc2.GetLength()).arg(length)));
|
||||||
QVERIFY2(qAbs(arc1.GetLength() - arc2.GetLength()) <= lengthEps,
|
QVERIFY2(qAbs(arc1.GetLength() - arc2.GetLength()) <= lengthEps,
|
||||||
|
@ -96,10 +98,10 @@ void TST_VEllipticalArc::CompareTwoWays()
|
||||||
const qreal angleEps = 0.4;
|
const qreal angleEps = 0.4;
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
const QString errorAngleMsg =
|
const QString errorAngleMsg =
|
||||||
QString("Difference between real and computing angles bigger than eps = %1. f1 = %2; f2 = %3");
|
QString("Difference between real and computing angles bigger than eps = %1. f1 = %2; f2 = %3");
|
||||||
// compare angles
|
// 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,21 +117,19 @@ 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
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
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,23 +171,23 @@ void TST_VEllipticalArc::TestData()
|
||||||
QTest::newRow("Full circle: radiuses 150, 200, rotation 30; start 0") << 150.0 << 200.0 << 0.0 << 360.0 << 30.0;
|
QTest::newRow("Full circle: radiuses 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;
|
||||||
QTest::newRow("Arc less than 45 degree, radiuses 1500, 800, rotation 90") << 1500.0 << 800.0 << 0.0 << 10.5 << 90.0;
|
QTest::newRow("Arc less than 45 degree, radiuses 1500, 800, rotation 90") << 1500.0 << 800.0 << 0.0 << 10.5 << 90.0;
|
||||||
QTest::newRow("Arc less than 45 degree, radiuses 15000, 10000, rotation 40")
|
QTest::newRow("Arc less than 45 degree, radiuses 15000, 10000, rotation 40")
|
||||||
<< 50000.0 << 10000.0 << 0.0 << 10.5 << 40.0;
|
<< 50000.0 << 10000.0 << 0.0 << 10.5 << 40.0;
|
||||||
QTest::newRow("Arc less than 45 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 10.5 << 0.0;
|
QTest::newRow("Arc less than 45 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 10.5 << 0.0;
|
||||||
|
|
||||||
QTest::newRow("Arc 45 degree, radiuses 100, 50, rotation 45") << 100.0 << 50.0 << 0.0 << 45.0 << 45.0;
|
QTest::newRow("Arc 45 degree, radiuses 100, 50, rotation 45") << 100.0 << 50.0 << 0.0 << 45.0 << 45.0;
|
||||||
|
@ -199,11 +199,11 @@ void TST_VEllipticalArc::TestData()
|
||||||
QTest::newRow("Arc less than 90 degree, radiuses 100, 400, rotation 50") << 100.0 << 400.0 << 0.0 << 75.0 << 50.0;
|
QTest::newRow("Arc less than 90 degree, radiuses 100, 400, rotation 50") << 100.0 << 400.0 << 0.0 << 75.0 << 50.0;
|
||||||
QTest::newRow("Arc less than 90 degree, radiuses 150, 400, rotation 90") << 150.0 << 400.0 << 0.0 << 75.0 << 90.0;
|
QTest::newRow("Arc less than 90 degree, radiuses 150, 400, rotation 90") << 150.0 << 400.0 << 0.0 << 75.0 << 90.0;
|
||||||
QTest::newRow("Arc less than 90 degree, radiuses 1500, 50000, rotation 180")
|
QTest::newRow("Arc less than 90 degree, radiuses 1500, 50000, rotation 180")
|
||||||
<< 1500.0 << 50000.0 << 0.0 << 75.0 << 180.0;
|
<< 1500.0 << 50000.0 << 0.0 << 75.0 << 180.0;
|
||||||
QTest::newRow("Arc less than 90 degree, radiuses 50000, 5000, rotation 30")
|
QTest::newRow("Arc less than 90 degree, radiuses 50000, 5000, rotation 30")
|
||||||
<< 50000.0 << 5000.0 << 0.0 << 75.0 << 30.0;
|
<< 50000.0 << 5000.0 << 0.0 << 75.0 << 30.0;
|
||||||
QTest::newRow("Arc less than 90 degree, radiuses 90000, 50000, rotation 30")
|
QTest::newRow("Arc less than 90 degree, radiuses 90000, 50000, rotation 30")
|
||||||
<< 90000.0 << 50000.0 << 0.0 << 75.0 << 30.0;
|
<< 90000.0 << 50000.0 << 0.0 << 75.0 << 30.0;
|
||||||
|
|
||||||
QTest::newRow("Arc 90 degree, radiuses 100, 50, rotation 30") << 100.0 << 50.0 << 0.0 << 90.0 << 30.0;
|
QTest::newRow("Arc 90 degree, radiuses 100, 50, rotation 30") << 100.0 << 50.0 << 0.0 << 90.0 << 30.0;
|
||||||
QTest::newRow("Arc 90 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 90.0 << 0.0;
|
QTest::newRow("Arc 90 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 90.0 << 0.0;
|
||||||
|
@ -213,11 +213,11 @@ void TST_VEllipticalArc::TestData()
|
||||||
|
|
||||||
QTest::newRow("Arc less than 135 degree, radiuses 100, 50, rotation 60") << 100.0 << 50.0 << 0.0 << 110.6 << 60.0;
|
QTest::newRow("Arc less than 135 degree, radiuses 100, 50, rotation 60") << 100.0 << 50.0 << 0.0 << 110.6 << 60.0;
|
||||||
QTest::newRow("Arc less than 135 degree, radiuses 150, 400, rotation 300")
|
QTest::newRow("Arc less than 135 degree, radiuses 150, 400, rotation 300")
|
||||||
<< 150.0 << 400.0 << 0.0 << 110.6 << 300.0;
|
<< 150.0 << 400.0 << 0.0 << 110.6 << 300.0;
|
||||||
QTest::newRow("Arc less than 135 degree, radiuses 1500, 800, rotation 360")
|
QTest::newRow("Arc less than 135 degree, radiuses 1500, 800, rotation 360")
|
||||||
<< 1500.0 << 800.0 << 0.0 << 110.6 << 360.0;
|
<< 1500.0 << 800.0 << 0.0 << 110.6 << 360.0;
|
||||||
QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500, rotation 290")
|
QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500, rotation 290")
|
||||||
<< 15000.0 << 1500.0 << 0.0 << 110.6 << 290.0;
|
<< 15000.0 << 1500.0 << 0.0 << 110.6 << 290.0;
|
||||||
QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500") << 15000.0 << 1500.0 << 0.0 << 110.6 << 0.0;
|
QTest::newRow("Arc less than 135 degree, radiuses 15000, 1500") << 15000.0 << 1500.0 << 0.0 << 110.6 << 0.0;
|
||||||
|
|
||||||
QTest::newRow("Arc 135 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 135.0 << 0.0;
|
QTest::newRow("Arc 135 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 135.0 << 0.0;
|
||||||
|
@ -230,7 +230,7 @@ void TST_VEllipticalArc::TestData()
|
||||||
QTest::newRow("Arc less than 180 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 160.7 << 0.0;
|
QTest::newRow("Arc less than 180 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 160.7 << 0.0;
|
||||||
QTest::newRow("Arc less than 180 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 160.7 << 0.0;
|
QTest::newRow("Arc less than 180 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 160.7 << 0.0;
|
||||||
QTest::newRow("Arc less than 180 degree, radiuses 15000, 1500, rotation 270")
|
QTest::newRow("Arc less than 180 degree, radiuses 15000, 1500, rotation 270")
|
||||||
<< 15000.0 << 1500.0 << 0.0 << 160.7 << 270.0;
|
<< 15000.0 << 1500.0 << 0.0 << 160.7 << 270.0;
|
||||||
QTest::newRow("Arc less than 180 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 160.7 << 0.0;
|
QTest::newRow("Arc less than 180 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 160.7 << 0.0;
|
||||||
|
|
||||||
QTest::newRow("Arc 180 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 180.0 << 0.0;
|
QTest::newRow("Arc 180 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 180.0 << 0.0;
|
||||||
|
@ -243,7 +243,7 @@ void TST_VEllipticalArc::TestData()
|
||||||
QTest::newRow("Arc less than 270 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 150.3 << 0.0;
|
QTest::newRow("Arc less than 270 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 150.3 << 0.0;
|
||||||
QTest::newRow("Arc less than 270 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 150.3 << 0.0;
|
QTest::newRow("Arc less than 270 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 150.3 << 0.0;
|
||||||
QTest::newRow("Arc less than 270 degree, radiuses 15000, 1500, rotation 20")
|
QTest::newRow("Arc less than 270 degree, radiuses 15000, 1500, rotation 20")
|
||||||
<< 15000.0 << 1500.0 << 0.0 << 150.3 << 20.0;
|
<< 15000.0 << 1500.0 << 0.0 << 150.3 << 20.0;
|
||||||
QTest::newRow("Arc less than 270 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 150.3 << 0.0;
|
QTest::newRow("Arc less than 270 degree, radiuses 15000, 10000") << 15000.0 << 10000.0 << 0.0 << 150.3 << 0.0;
|
||||||
|
|
||||||
QTest::newRow("Arc 270 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 270.0 << 0.0;
|
QTest::newRow("Arc 270 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 270.0 << 0.0;
|
||||||
|
@ -256,24 +256,24 @@ void TST_VEllipticalArc::TestData()
|
||||||
QTest::newRow("Arc less than 360 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 340.0 << 0.0;
|
QTest::newRow("Arc less than 360 degree, radiuses 150, 400") << 150.0 << 400.0 << 0.0 << 340.0 << 0.0;
|
||||||
QTest::newRow("Arc less than 360 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 340.0 << 0.0;
|
QTest::newRow("Arc less than 360 degree, radiuses 1500, 800") << 1500.0 << 800.0 << 0.0 << 340.0 << 0.0;
|
||||||
QTest::newRow("Arc less than 360 degree, radiuses 12000, 1200, rotation 30")
|
QTest::newRow("Arc less than 360 degree, radiuses 12000, 1200, rotation 30")
|
||||||
<< 12000.0 << 1200.0 << 0.0 << 340.0 << 30.0;
|
<< 12000.0 << 1200.0 << 0.0 << 340.0 << 30.0;
|
||||||
QTest::newRow("Arc less than 360 degree, radiuses 12000, 10000") << 15000.0 << 10000.0 << 0.0 << 340.0 << 0.0;
|
QTest::newRow("Arc less than 360 degree, radiuses 12000, 10000") << 15000.0 << 10000.0 << 0.0 << 340.0 << 0.0;
|
||||||
|
|
||||||
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 90.0 << 135.0 << 0.0;
|
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 90.0 << 135.0 << 0.0;
|
||||||
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 150, 400") << 150.0 << 400.0 << 90.0 << 135.0 << 0.0;
|
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 150, 400") << 150.0 << 400.0 << 90.0 << 135.0 << 0.0;
|
||||||
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 1500, 800")
|
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 1500, 800")
|
||||||
<< 1500.0 << 800.0 << 90.0 << 135.0 << 0.0;
|
<< 1500.0 << 800.0 << 90.0 << 135.0 << 0.0;
|
||||||
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 13000, 1000")
|
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 13000, 1000")
|
||||||
<< 15000.0 << 1000.0 << 90.0 << 135.0 << 0.0;
|
<< 15000.0 << 1000.0 << 90.0 << 135.0 << 0.0;
|
||||||
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 15000, 10000")
|
QTest::newRow("Arc start 90 degree, angle 45 degree, radiuses 15000, 10000")
|
||||||
<< 15000.0 << 10000.0 << 90.0 << 135.0 << 0.0;
|
<< 15000.0 << 10000.0 << 90.0 << 135.0 << 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
// cppcheck-suppress unusedFunction
|
// 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";
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -533,15 +543,14 @@ void TST_VEllipticalArc::TestRotation()
|
||||||
const VEllipticalArc rotatedArc = arcOrigin.Rotate(rotatePoint, degrees, prefix);
|
const VEllipticalArc rotatedArc = arcOrigin.Rotate(rotatePoint, degrees, prefix);
|
||||||
|
|
||||||
QVERIFY2(qAbs(arcOrigin.AngleArc() - rotatedArc.AngleArc()) <= 1.6,
|
QVERIFY2(qAbs(arcOrigin.AngleArc() - rotatedArc.AngleArc()) <= 1.6,
|
||||||
qUtf8Printable(QString("a1 = %1, a2 - %2").arg(arcOrigin.AngleArc()).arg(rotatedArc.AngleArc())));
|
qUtf8Printable(QString("a1 = %1, a2 - %2").arg(arcOrigin.AngleArc()).arg(rotatedArc.AngleArc())));
|
||||||
|
|
||||||
// cppcheck-suppress unreadVariable
|
// cppcheck-suppress unreadVariable
|
||||||
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