Refactoring.

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

View file

@ -42,10 +42,12 @@ QT_WARNING_POP
//---------------------------------------------------------------------------------------------------------------------
VPUndoCommand::VPUndoCommand(QUndoCommand *parent)
: QUndoCommand(parent)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
VPUndoCommand::VPUndoCommand(bool allowMerge, QUndoCommand *parent)
: QUndoCommand(parent),
m_allowMerge(allowMerge)
{}
{
}

View file

@ -27,9 +27,9 @@
*************************************************************************/
#include "dialogmdatabase.h"
#include "ui_dialogmdatabase.h"
#include "../mapplication.h"
#include "../vpatterndb/measurements.h"
#include "ui_dialogmdatabase.h"
#include "../vmisc/compatibility.h"
#include <QKeyEvent>
@ -144,8 +144,8 @@ void DialogMDataBase::RetranslateGroups()
auto DialogMDataBase::ImgTag(const QString &number) -> QString
{
QString imgUrl(QStringLiteral("<img src=\"wrong.png\" align=\"center\"/>")); // In case of error
const QString filePath = QStringLiteral("://diagrams/%1.svg")
.arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number));
const QString filePath =
QStringLiteral("://diagrams/%1.svg").arg(MapDiagrams(VAbstractApplication::VApp()->TrVars(), number));
if (QFileInfo::exists(filePath))
{
// Load your SVG
@ -262,8 +262,7 @@ void DialogMDataBase::UpdateChecks(QTreeWidgetItem *item, int column)
}
for (int j = 0; j < parent->childCount(); ++j)
{
if (j != parent->indexOfChild(item)
&& item->checkState(0) != parent->child(j)->checkState(0))
if (j != parent->indexOfChild(item) && item->checkState(0) != parent->child(j)->checkState(0))
{
diff = true;
}
@ -418,11 +417,11 @@ void DialogMDataBase::FilterGroup(QTreeWidgetItem *group, const QString &search)
for (int i = 0; i < group->childCount(); ++i)
{
QTreeWidgetItem *childItem = group->child(i);
const QString description = QTextDocumentFragment::fromHtml(ItemFullDescription(childItem, false))
.toPlainText();
const QString description =
QTextDocumentFragment::fromHtml(ItemFullDescription(childItem, false)).toPlainText();
const bool hidden = not childItem->text(0).contains(search, Qt::CaseInsensitive)
&& not description.contains(search, Qt::CaseInsensitive);
const bool hidden = not childItem->text(0).contains(search, Qt::CaseInsensitive) &&
not description.contains(search, Qt::CaseInsensitive);
childItem->setHidden(hidden);
if (not hidden)
@ -577,43 +576,27 @@ auto DialogMDataBase::GlobalCheckState() const -> Qt::CheckState
if (m_selectMode)
{
if (m_groupA->checkState(0) == Qt::Unchecked &&
m_groupB->checkState(0) == Qt::Unchecked &&
m_groupC->checkState(0) == Qt::Unchecked &&
m_groupD->checkState(0) == Qt::Unchecked &&
m_groupE->checkState(0) == Qt::Unchecked &&
m_groupF->checkState(0) == Qt::Unchecked &&
m_groupG->checkState(0) == Qt::Unchecked &&
m_groupH->checkState(0) == Qt::Unchecked &&
m_groupI->checkState(0) == Qt::Unchecked &&
m_groupJ->checkState(0) == Qt::Unchecked &&
m_groupK->checkState(0) == Qt::Unchecked &&
m_groupL->checkState(0) == Qt::Unchecked &&
m_groupM->checkState(0) == Qt::Unchecked &&
m_groupN->checkState(0) == Qt::Unchecked &&
m_groupO->checkState(0) == Qt::Unchecked &&
m_groupP->checkState(0) == Qt::Unchecked &&
if (m_groupA->checkState(0) == Qt::Unchecked && m_groupB->checkState(0) == Qt::Unchecked &&
m_groupC->checkState(0) == Qt::Unchecked && m_groupD->checkState(0) == Qt::Unchecked &&
m_groupE->checkState(0) == Qt::Unchecked && m_groupF->checkState(0) == Qt::Unchecked &&
m_groupG->checkState(0) == Qt::Unchecked && m_groupH->checkState(0) == Qt::Unchecked &&
m_groupI->checkState(0) == Qt::Unchecked && m_groupJ->checkState(0) == Qt::Unchecked &&
m_groupK->checkState(0) == Qt::Unchecked && m_groupL->checkState(0) == Qt::Unchecked &&
m_groupM->checkState(0) == Qt::Unchecked && m_groupN->checkState(0) == Qt::Unchecked &&
m_groupO->checkState(0) == Qt::Unchecked && m_groupP->checkState(0) == Qt::Unchecked &&
m_groupQ->checkState(0) == Qt::Unchecked)
{
return Qt::Checked;
}
if (m_groupA->checkState(0) == Qt::Checked &&
m_groupB->checkState(0) == Qt::Checked &&
m_groupC->checkState(0) == Qt::Checked &&
m_groupD->checkState(0) == Qt::Checked &&
m_groupE->checkState(0) == Qt::Checked &&
m_groupF->checkState(0) == Qt::Checked &&
m_groupG->checkState(0) == Qt::Checked &&
m_groupH->checkState(0) == Qt::Checked &&
m_groupI->checkState(0) == Qt::Checked &&
m_groupJ->checkState(0) == Qt::Checked &&
m_groupK->checkState(0) == Qt::Checked &&
m_groupL->checkState(0) == Qt::Checked &&
m_groupM->checkState(0) == Qt::Checked &&
m_groupN->checkState(0) == Qt::Checked &&
m_groupO->checkState(0) == Qt::Checked &&
m_groupP->checkState(0) == Qt::Checked &&
if (m_groupA->checkState(0) == Qt::Checked && m_groupB->checkState(0) == Qt::Checked &&
m_groupC->checkState(0) == Qt::Checked && m_groupD->checkState(0) == Qt::Checked &&
m_groupE->checkState(0) == Qt::Checked && m_groupF->checkState(0) == Qt::Checked &&
m_groupG->checkState(0) == Qt::Checked && m_groupH->checkState(0) == Qt::Checked &&
m_groupI->checkState(0) == Qt::Checked && m_groupJ->checkState(0) == Qt::Checked &&
m_groupK->checkState(0) == Qt::Checked && m_groupL->checkState(0) == Qt::Checked &&
m_groupM->checkState(0) == Qt::Checked && m_groupN->checkState(0) == Qt::Checked &&
m_groupO->checkState(0) == Qt::Checked && m_groupP->checkState(0) == Qt::Checked &&
m_groupQ->checkState(0) == Qt::Checked)
{
return Qt::Unchecked;

View file

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

View file

@ -35,20 +35,20 @@
#include <QDomNode>
#include <QHash>
#include <QLatin1String>
#include <QString>
#include <QtGlobal>
#include <QLocale>
#include <QLoggingCategory>
#include <functional>
#include <QString>
#include <QtCore/qcontainerfwd.h>
#include <QtGlobal>
#include <functional>
#include "../ifcdef.h"
#include "../qmuparser/qmudef.h"
#include "../vmisc/def.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/literals.h"
#include "../qmuparser/qmudef.h"
class QDomElement;
class QDomNode;
@ -84,6 +84,7 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
class VDomDocument : public QObject, public QDomDocument
{
Q_OBJECT // NOLINT
public:
static const QString AttrId;
static const QString AttrText;
@ -100,8 +101,7 @@ public:
virtual ~VDomDocument();
auto elementById(quint32 id, const QString &tagName = QString(), bool updateCache = true) -> QDomElement;
template <typename T>
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
template <typename T> void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
template <typename T>
void SetAttributeOrRemoveIf(QDomElement &domElement, const QString &name, const T &value,
@ -223,8 +223,8 @@ template <>
inline void VDomDocument::SetAttribute<MeasurementsType>(QDomElement &domElement, const QString &name,
const MeasurementsType &value) const
{
domElement.setAttribute(name, value == MeasurementsType::Multisize ? QStringLiteral("multisize") :
QStringLiteral("individual"));
domElement.setAttribute(name, value == MeasurementsType::Multisize ? QStringLiteral("multisize")
: QStringLiteral("individual"));
}
//---------------------------------------------------------------------------------------------------------------------

View file

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

View file

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

View file

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

View file

@ -11,11 +11,11 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#include <cstdlib>
#include "drw_entities.h"
#include "intern/dxfreader.h"
#include "intern/drw_dbg.h"
#include "drw_reserve.h"
#include "intern/drw_dbg.h"
#include "intern/dxfreader.h"
#include <cstdlib>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
@ -26,16 +26,20 @@
* Calculate arbitrary axis for apply extrusions
* @author Rallaz
*/
void DRW_Entity::calculateAxis(DRW_Coord extPoint){
void DRW_Entity::calculateAxis(DRW_Coord extPoint)
{
// Follow the arbitrary DXF definitions for extrusion axes.
if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625) {
if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625)
{
// If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec.
// The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x
// Factoring in the fixed values for Wy gives N.z,0,-N.x
extAxisX.x = extPoint.z;
extAxisX.y = 0;
extAxisX.z = -extPoint.x;
} else {
}
else
{
// Otherwise, implement Ax = Wz x N where Wz is [0,0,1] per the DXF spec.
// The cross product works out to Wz.y*N.z-Wz.z*N.y, Wz.z*N.x-Wz.x*N.z, Wz.x*N.y-Wz.y*N.x
// Factoring in the fixed values for Wz gives -N.y,N.x,0.
@ -59,7 +63,8 @@ void DRW_Entity::calculateAxis(DRW_Coord extPoint){
* apply extrusion in a point using arbitrary axis (previous calculated)
* @author Rallaz
*/
void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const{
void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const
{
double px, py, pz;
px = (extAxisX.x * point->x) + (extAxisY.x * point->y) + (extPoint.x * point->z);
py = (extAxisX.y * point->x) + (extAxisY.y * point->y) + (extPoint.y * point->z);
@ -72,7 +77,8 @@ void DRW_Entity::extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const{
auto DRW_Entity::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 5:
handle = static_cast<quint32>(reader->getHandleString());
break;
@ -164,17 +170,21 @@ auto DRW_Entity::parseDxfGroups(int code, dxfReader *reader) -> bool
DRW_Variant c;
int nc;
std::string appName = reader->getString();
if (!appName.empty() && appName.at(0)== '{'){
if (!appName.empty() && appName.at(0) == '{')
{
c.addString(appName.substr(1, static_cast<size_t>(appName.size() - 1)));
c.code = code;
ls.push_back(c);
while (code !=102 && appName.at(0)== '}'){
while (code != 102 && appName.at(0) == '}')
{
reader->readRec(&nc);
c.code = code;
if (code == 330 || code == 360)
c.addInt(reader->getHandleString());
else {
switch (reader->type) {
else
{
switch (reader->type)
{
case dxfReader::STRING:
c.addString(reader->getString());
break;
@ -202,7 +212,8 @@ auto DRW_Entity::parseDxfGroups(int code, dxfReader *reader) -> bool
auto DRW_Point::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 10:
basePoint.x = reader->getDouble();
break;
@ -234,7 +245,8 @@ auto DRW_Point::parseCode(int code, dxfReader *reader) -> bool
auto DRW_ASTMNotch::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 50:
angle = reader->getDouble();
break;
@ -247,7 +259,8 @@ auto DRW_ASTMNotch::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Line::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 11:
secPoint.x = reader->getDouble();
break;
@ -264,8 +277,10 @@ auto DRW_Line::parseCode(int code, dxfReader *reader) -> bool
return true;
}
void DRW_Circle::applyExtrusion(){
if (haveExtrusion) {
void DRW_Circle::applyExtrusion()
{
if (haveExtrusion)
{
// NOTE: Commenting these out causes the the arcs being tested to be located
// on the other side of the y axis (all x dimensions are negated).
calculateAxis(extPoint);
@ -275,7 +290,8 @@ void DRW_Circle::applyExtrusion(){
auto DRW_Circle::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 40:
radious = reader->getDouble();
break;
@ -286,16 +302,19 @@ auto DRW_Circle::parseCode(int code, dxfReader *reader) -> bool
return true;
}
void DRW_Arc::applyExtrusion(){
void DRW_Arc::applyExtrusion()
{
DRW_Circle::applyExtrusion();
if(haveExtrusion){
if (haveExtrusion)
{
// If the extrusion vector has a z value less than 0, the angles for the arc
// have to be mirrored since DXF files use the right hand rule.
// Note that the following code only handles the special case where there is a 2D
// drawing with the z axis heading into the paper (or rather screen). An arbitrary
// extrusion axis (with x and y values greater than 1/64) may still have issues.
if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0) {
if (fabs(extPoint.x) < 0.015625 && fabs(extPoint.y) < 0.015625 && extPoint.z < 0.0)
{
staangle = M_PI - staangle;
endangle = M_PI - endangle;
@ -308,7 +327,8 @@ void DRW_Arc::applyExtrusion(){
auto DRW_Arc::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 50:
staangle = reader->getDouble() / ARAD;
break;
@ -324,7 +344,8 @@ auto DRW_Arc::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Ellipse::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 40:
ratio = reader->getDouble();
break;
@ -341,12 +362,15 @@ auto DRW_Ellipse::parseCode(int code, dxfReader *reader) -> bool
return true;
}
void DRW_Ellipse::applyExtrusion(){
if (haveExtrusion) {
void DRW_Ellipse::applyExtrusion()
{
if (haveExtrusion)
{
calculateAxis(extPoint);
extrudePoint(extPoint, &secPoint);
double intialparam = staparam;
if (extPoint.z < 0.){
if (extPoint.z < 0.)
{
staparam = M_PIx2 - endparam;
endparam = M_PIx2 - intialparam;
}
@ -354,21 +378,25 @@ void DRW_Ellipse::applyExtrusion(){
}
// if ratio > 1 minor axis are greather than major axis, correct it
void DRW_Ellipse::correctAxis(){
void DRW_Ellipse::correctAxis()
{
bool complete = false;
if (DRW_FuzzyComparePossibleNulls(staparam, endparam)) {
if (DRW_FuzzyComparePossibleNulls(staparam, endparam))
{
staparam = 0.0;
endparam = M_PIx2; // 2*M_PI;
complete = true;
}
if (ratio > 1){
if (ratio > 1)
{
if (fabs(endparam - staparam - M_PIx2) < 1.0e-10)
complete = true;
double incX = secPoint.x;
secPoint.x = -(secPoint.y * ratio);
secPoint.y = incX * ratio;
ratio = 1 / ratio;
if (!complete){
if (!complete)
{
if (staparam < M_PI_2)
staparam += M_PI * 2;
if (endparam < M_PI_2)
@ -380,7 +408,8 @@ void DRW_Ellipse::correctAxis(){
}
// parts are the number of vertex to split polyline, default 128
void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts)
{
double radMajor, radMinor, cosRot, sinRot, incAngle, curAngle;
radMajor = sqrt(secPoint.x * secPoint.x + secPoint.y * secPoint.y);
radMinor = radMajor * ratio;
@ -391,8 +420,10 @@ void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
incAngle = M_PIx2 / parts;
curAngle = staparam;
int i = static_cast<int>(curAngle / incAngle);
do {
if (curAngle > endparam) {
do
{
if (curAngle > endparam)
{
curAngle = endparam;
i = parts + 2;
}
@ -403,7 +434,8 @@ void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
pol->addVertex(DRW_Vertex(x, y, 0.0, 0.0));
curAngle = (++i) * incAngle;
} while (i < parts);
if ( fabs(endparam - staparam - M_PIx2) < 1.0e-10){
if (fabs(endparam - staparam - M_PIx2) < 1.0e-10)
{
pol->flags = 1;
}
pol->layer = this->layer;
@ -413,8 +445,10 @@ void DRW_Ellipse::toPolyline(DRW_Polyline *pol, int parts){
pol->extPoint = this->extPoint;
}
void DRW_Trace::applyExtrusion(){
if (haveExtrusion) {
void DRW_Trace::applyExtrusion()
{
if (haveExtrusion)
{
calculateAxis(extPoint);
extrudePoint(extPoint, &basePoint);
extrudePoint(extPoint, &secPoint);
@ -425,7 +459,8 @@ void DRW_Trace::applyExtrusion(){
auto DRW_Trace::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 12:
thirdPoint.x = reader->getDouble();
break;
@ -453,7 +488,8 @@ auto DRW_Trace::parseCode(int code, dxfReader *reader) -> bool
auto DRW_3Dface::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 70:
invisibleflag = reader->getInt32();
break;
@ -466,7 +502,8 @@ auto DRW_3Dface::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Block::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 2:
name = reader->getUtf8String();
break;
@ -482,7 +519,8 @@ auto DRW_Block::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Insert::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 2:
name = reader->getUtf8String();
break;
@ -518,10 +556,13 @@ auto DRW_Insert::parseCode(int code, dxfReader *reader) -> bool
return true;
}
void DRW_LWPolyline::applyExtrusion(){
if (haveExtrusion) {
void DRW_LWPolyline::applyExtrusion()
{
if (haveExtrusion)
{
calculateAxis(extPoint);
for (unsigned int i=0; i<vertlist.size(); i++) {
for (unsigned int i = 0; i < vertlist.size(); i++)
{
DRW_Vertex2D *vert = vertlist.at(i);
DRW_Coord v(vert->x, vert->y, elevation);
extrudePoint(extPoint, &v);
@ -533,12 +574,15 @@ void DRW_LWPolyline::applyExtrusion(){
auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
case 10: {
switch (code)
{
case 10:
{
vertex = new DRW_Vertex2D();
vertlist.push_back(vertex);
vertex->x = reader->getDouble();
break; }
break;
}
case 20:
if (vertex != NULL)
vertex->y = reader->getDouble();
@ -589,7 +633,8 @@ auto DRW_LWPolyline::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Text::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 40:
height = reader->getDouble();
break;
@ -626,7 +671,8 @@ auto DRW_Text::parseCode(int code, dxfReader *reader) -> bool
auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 1:
text += reader->getString();
text = reader->toUtf8String(text);
@ -640,14 +686,16 @@ auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
case 44:
interlin = reader->getDouble();
break;
case 71: {
case 71:
{
// Attachment point
Attach a = static_cast<Attach>(reader->getInt32());
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(a) {
switch (a)
{
case TopLeft:
alignV = VTop;
alignH = HLeft;
@ -687,7 +735,8 @@ auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
}
QT_WARNING_POP
} break;
}
break;
case 72:
// To prevent redirection to DRW_Text::parseCode.
// This code meaning is different for MTEXT.
@ -705,15 +754,18 @@ auto DRW_MText::parseCode(int code, dxfReader *reader) -> bool
return true;
}
void DRW_MText::updateAngle(){
if (hasXAxisVec) {
void DRW_MText::updateAngle()
{
if (hasXAxisVec)
{
angle = atan2(secPoint.y, secPoint.x) * 180 / M_PI;
}
}
auto DRW_Polyline::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 70:
flags = reader->getInt32();
break;
@ -747,7 +799,8 @@ auto DRW_Polyline::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Vertex::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 70:
flags = reader->getInt32();
break;
@ -787,7 +840,8 @@ auto DRW_Vertex::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 2:
name = reader->getUtf8String();
break;
@ -798,61 +852,87 @@ auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
associative = reader->getInt32();
break;
case 72: /*edge type*/
if (ispol){ //if is polyline is a as_bulge flag
if (ispol)
{ // if is polyline is a as_bulge flag
break;
} else if (reader->getInt32() == 1){ //line
}
else if (reader->getInt32() == 1)
{ // line
addLine();
} else if (reader->getInt32() == 2){ //arc
}
else if (reader->getInt32() == 2)
{ // arc
addArc();
} else if (reader->getInt32() == 3){ //elliptic arc
}
else if (reader->getInt32() == 3)
{ // elliptic arc
addEllipse();
} else if (reader->getInt32() == 4){ //spline
}
else if (reader->getInt32() == 4)
{ // spline
addSpline();
}
break;
case 10:
if (pt) pt->basePoint.x = reader->getDouble();
else if (pline) {
if (pt)
pt->basePoint.x = reader->getDouble();
else if (pline)
{
plvert = pline->addVertex();
plvert->x = reader->getDouble();
}
break;
case 20:
if (pt) pt->basePoint.y = reader->getDouble();
else if (plvert) plvert ->y = reader->getDouble();
if (pt)
pt->basePoint.y = reader->getDouble();
else if (plvert)
plvert->y = reader->getDouble();
break;
case 11:
if (line) line->secPoint.x = reader->getDouble();
else if (ellipse) ellipse->secPoint.x = reader->getDouble();
if (line)
line->secPoint.x = reader->getDouble();
else if (ellipse)
ellipse->secPoint.x = reader->getDouble();
break;
case 21:
if (line) line->secPoint.y = reader->getDouble();
else if (ellipse) ellipse->secPoint.y = reader->getDouble();
if (line)
line->secPoint.y = reader->getDouble();
else if (ellipse)
ellipse->secPoint.y = reader->getDouble();
break;
case 40:
if (arc) arc->radious = reader->getDouble();
else if (ellipse) ellipse->ratio = reader->getDouble();
if (arc)
arc->radious = reader->getDouble();
else if (ellipse)
ellipse->ratio = reader->getDouble();
break;
case 41:
scale = reader->getDouble();
break;
case 42:
if (plvert) plvert ->bulge = reader->getDouble();
if (plvert)
plvert->bulge = reader->getDouble();
break;
case 50:
if (arc) arc->staangle = reader->getDouble()/ARAD;
else if (ellipse) ellipse->staparam = reader->getDouble()/ARAD;
if (arc)
arc->staangle = reader->getDouble() / ARAD;
else if (ellipse)
ellipse->staparam = reader->getDouble() / ARAD;
break;
case 51:
if (arc) arc->endangle = reader->getDouble()/ARAD;
else if (ellipse) ellipse->endparam = reader->getDouble()/ARAD;
if (arc)
arc->endangle = reader->getDouble() / ARAD;
else if (ellipse)
ellipse->endparam = reader->getDouble() / ARAD;
break;
case 52:
angle = reader->getDouble();
break;
case 73:
if (arc) arc->isccw = reader->getInt32();
else if (pline) pline->flags = reader->getInt32();
if (arc)
arc->isccw = reader->getInt32();
else if (pline)
pline->flags = reader->getInt32();
break;
case 75:
hstyle = reader->getInt32();
@ -872,16 +952,21 @@ auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
case 92:
loop = new DRW_HatchLoop(reader->getInt32());
looplist.push_back(loop);
if (reader->getInt32() & 2) {
if (reader->getInt32() & 2)
{
ispol = true;
clearEntities();
pline = new DRW_LWPolyline;
loop->objlist.push_back(pline);
} else ispol = false;
}
else
ispol = false;
break;
case 93:
if (pline) pline->vertexnum = reader->getInt32();
else if (loop) loop->numedges = reader->getInt32();//aqui reserve
if (pline)
pline->vertexnum = reader->getInt32();
else if (loop)
loop->numedges = reader->getInt32(); // aqui reserve
break;
case 98: // seed points ??
clearEntities();
@ -895,7 +980,8 @@ auto DRW_Hatch::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 210:
normalVec.x = reader->getDouble();
break;
@ -947,11 +1033,13 @@ auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
case 44:
tolfit = reader->getDouble();
break;
case 10: {
case 10:
{
controlpoint = new DRW_Coord();
controllist.push_back(controlpoint);
controlpoint->x = reader->getDouble();
break; }
break;
}
case 20:
if (controlpoint != NULL)
controlpoint->y = reader->getDouble();
@ -960,11 +1048,13 @@ auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
if (controlpoint != NULL)
controlpoint->z = reader->getDouble();
break;
case 11: {
case 11:
{
fitpoint = new DRW_Coord();
fitlist.push_back(fitpoint);
fitpoint->x = reader->getDouble();
break; }
break;
}
case 21:
if (fitpoint != NULL)
fitpoint->y = reader->getDouble();
@ -988,7 +1078,8 @@ auto DRW_Spline::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Image::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 12:
vVector.x = reader->getDouble();
break;
@ -1028,7 +1119,8 @@ auto DRW_Image::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Dimension::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 1:
text = reader->getUtf8String();
break;
@ -1150,7 +1242,8 @@ auto DRW_Dimension::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 3:
style = reader->getUtf8String();
break;
@ -1181,11 +1274,13 @@ auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
case 41:
textwidth = reader->getDouble();
break;
case 10: {
case 10:
{
vertexpoint = new DRW_Coord();
vertexlist.push_back(vertexpoint);
vertexpoint->x = reader->getDouble();
break; }
break;
}
case 20:
if (vertexpoint != NULL)
vertexpoint->y = reader->getDouble();
@ -1242,7 +1337,8 @@ auto DRW_Leader::parseCode(int code, dxfReader *reader) -> bool
auto DRW_Viewport::parseCode(int code, dxfReader *reader) -> bool
{
switch (code) {
switch (code)
{
case 40:
pswidth = reader->getDouble();
break;
@ -1255,9 +1351,11 @@ auto DRW_Viewport::parseCode(int code, dxfReader *reader) -> bool
case 69:
vpID = reader->getInt32();
break;
case 12: {
case 12:
{
centerPX = reader->getDouble();
break; }
break;
}
case 22:
centerPY = reader->getDouble();
break;

View file

@ -16,8 +16,8 @@
#include <cstring>
#include "drw_entities.h"
#include "drw_objects.h"
#include "drw_header.h"
#include "drw_objects.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
@ -34,10 +34,10 @@ QT_WARNING_DISABLE_GCC("-Wsuggest-final-methods")
*
* @author Rallaz
*/
class DRW_Interface {
class DRW_Interface
{
public:
DRW_Interface() {
}
DRW_Interface() {}
virtual ~DRW_Interface() = default;
/** Called when header is parsed. */
@ -112,7 +112,6 @@ public:
/** Called for every solid start */
virtual void addSolid(const DRW_Solid &) {}
/** Called for every Multi Text entity. */
virtual void addMText(const DRW_MText &) {}

File diff suppressed because it is too large Load diff

View file

@ -29,17 +29,17 @@
#ifndef VABSTRACTPIECE_H
#define VABSTRACTPIECE_H
#include <QtGlobal>
#include <QSharedDataPointer>
#include <QPointF>
#include <QDebug>
#include <QCoreApplication>
#include <QDebug>
#include <QPainterPath>
#include <QPointF>
#include <QSharedDataPointer>
#include <QtGlobal>
#include "../vmisc/compatibility.h"
#include "../vgeometry/vgobject.h"
#include "vsapoint.h"
#include "../vmisc/compatibility.h"
#include "vrawsapoint.h"
#include "vsapoint.h"
class VAbstractPieceData;
class QPainterPath;
@ -53,6 +53,7 @@ using PlaceLabelImg = QVector<QVector<VLayoutPoint> >;
class VAbstractPiece
{
Q_DECLARE_TR_FUNCTIONS(VAbstractPiece) // NOLINT
public:
VAbstractPiece();
VAbstractPiece(const VAbstractPiece &piece);
@ -109,25 +110,24 @@ public:
static auto Equidistant(QVector<VSAPoint> points, qreal width, const QString &name) -> QVector<VLayoutPoint>;
static auto SumTrapezoids(const QVector<QPointF> &points) -> qreal;
template <class T>
static auto CheckLoops(QVector<T> points) -> QVector<T>;
template <class T> static auto CheckLoops(QVector<T> points) -> QVector<T>;
static auto EkvPoint(QVector<VRawSAPoint> points, const VSAPoint &p1Line1, const VSAPoint &p2Line1,
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width,
bool *needRollback = nullptr) -> QVector<VRawSAPoint>;
const VSAPoint &p1Line2, const VSAPoint &p2Line2, qreal width, bool *needRollback = nullptr)
-> QVector<VRawSAPoint>;
static auto ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width) -> QLineF;
static auto IsAllowanceValid(const QVector<QPointF> &base, const QVector<QPointF> &allowance) -> bool;
template <class T>
static auto IsInsidePolygon(const QVector<T> &path, const QVector<T> &polygon,
qreal accuracy = accuracyPointOnLine) -> bool;
static auto IsInsidePolygon(const QVector<T> &path, const QVector<T> &polygon, qreal accuracy = accuracyPointOnLine)
-> bool;
template <class T>
static auto CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast = true) -> QVector<T>;
static auto RollbackSeamAllowance(QVector<VRawSAPoint> points, const QLineF &cuttingEdge,
bool *success) -> QVector<VRawSAPoint>;
static auto RollbackSeamAllowance(QVector<VRawSAPoint> points, const QLineF &cuttingEdge, bool *success)
-> QVector<VRawSAPoint>;
static auto GrainlineMainLine(const VGrainlineData &geom, const VContainer *pattern,
const QRectF &boundingRect) -> QLineF;
static auto GrainlineMainLine(const VGrainlineData &geom, const VContainer *pattern, const QRectF &boundingRect)
-> QLineF;
friend auto operator<<(QDataStream &dataStream, const VAbstractPiece &piece) -> QDataStream &;
friend auto operator>>(QDataStream &dataStream, VAbstractPiece &piece) -> QDataStream &;
@ -144,19 +144,17 @@ protected:
template <class T>
static auto CheckPointOnLine(QVector<T> &points, const T &iPoint, const T &prevPoint, const T &nextPoint) -> bool;
static auto IsItemContained(const QRectF &parentBoundingRect, const QVector<QPointF> &shape, qreal &dX,
qreal &dY) -> bool;
static auto IsItemContained(const QRectF &parentBoundingRect, const QVector<QPointF> &shape, qreal &dX, qreal &dY)
-> bool;
static auto CorrectPosition(const QRectF &parentBoundingRect, QVector<QPointF> points) -> QVector<QPointF>;
static auto FindGrainlineGeometry(const VGrainlineData &geom, const VContainer *pattern, qreal &length,
qreal &rotationAngle, QPointF &pos) -> bool;
template <class T>
static auto ComparePoints(QVector<T> &points, const T &p1, const T &p2, qreal accuracy) -> bool;
template <class T>
static auto CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void;
template <class T>
static auto CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>;
template <class T> static auto ComparePoints(QVector<T> &points, const T &p1, const T &p2, qreal accuracy) -> bool;
template <class T> static auto CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void;
template <class T> static auto CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>;
template <class T>
static auto IntersectionPoint(QPointF crosPoint, const T &l1p1, const T &l1p2, const T &l2p1, const T &l2p2) -> T;
private:
QSharedDataPointer<VAbstractPieceData> d;
};
@ -403,8 +401,7 @@ inline auto VAbstractPiece::ComparePoints<QPointF>(QVector<QPointF> &points, con
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void
template <class T> inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal accuracy) -> void
{
if (points.isEmpty())
{
@ -437,8 +434,7 @@ inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<T> &points, qreal
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<VRawSAPoint> &points, qreal accuracy) -> void
template <> inline auto VAbstractPiece::CompareFirstAndLastPoints(QVector<VRawSAPoint> &points, qreal accuracy) -> void
{
if (points.isEmpty())
{
@ -529,13 +525,11 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVecto
QPointF crosPoint;
const auto type = Intersects(baseSegment, allowanceSegment, &crosPoint);
if (type == QLineF::BoundedIntersection
&& not VFuzzyComparePoints(baseSegment.p1(), crosPoint, accuracy)
&& not VFuzzyComparePoints(baseSegment.p2(), crosPoint, accuracy)
&& not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2(),
accuracy)
&& not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2(),
accuracy))
if (type == QLineF::BoundedIntersection && not VFuzzyComparePoints(baseSegment.p1(), crosPoint, accuracy) &&
not VFuzzyComparePoints(baseSegment.p2(), crosPoint, accuracy) &&
not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2(),
accuracy) &&
not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2(), accuracy))
{
return false;
}
@ -544,7 +538,8 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVecto
// Just instersection edges is not enough. The base must be inside of the allowance.
QPolygonF allowancePolygon(polygon);
return std::all_of(path.begin(), path.end(), [allowancePolygon](const T &point)
return std::all_of(path.begin(), path.end(),
[allowancePolygon](const T &point)
{ return allowancePolygon.containsPoint(point, Qt::WindingFill); });
}
@ -554,8 +549,7 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector<T> &path, const QVecto
* @param points vector of points of equidistant.
* @return vector of points of equidistant.
*/
template <class T>
inline auto VAbstractPiece::CheckLoops(QVector<T> points) -> QVector<T>
template <class T> inline auto VAbstractPiece::CheckLoops(QVector<T> points) -> QVector<T>
{
// DumpVector(points, QStringLiteral("input.json.XXXXXX")); // Uncomment for dumping test data
@ -583,8 +577,7 @@ inline auto VAbstractPiece::CheckLoops(QVector<T> points) -> QVector<T>
}
//---------------------------------------------------------------------------------------------------------------------
template<class T>
inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>
template <class T> inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound) -> QVector<T>
{
loopFound = false;
@ -604,7 +597,12 @@ inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound)
continue;
}
enum LoopIntersectType { NoIntersection, BoundedIntersection, ParallelIntersection };
enum LoopIntersectType
{
NoIntersection,
BoundedIntersection,
ParallelIntersection
};
QPointF crosPoint;
LoopIntersectType status = NoIntersection;
@ -645,7 +643,8 @@ inline auto VAbstractPiece::CheckLoop(const QVector<T> &points, bool &loopFound)
break;
case BoundedIntersection:
ekvPoints.append(points.at(i));
ekvPoints.append(IntersectionPoint(crosPoint, points.at(i), points.at(i+1), points.at(j), points.at(j+1)));
ekvPoints.append(
IntersectionPoint(crosPoint, points.at(i), points.at(i + 1), points.at(j), points.at(j + 1)));
i = j;
loopFound = true;
break;

View file

@ -33,12 +33,11 @@
#include <QRectF>
#include <QThreadPool>
#include "../vmisc/def.h"
#include "../vmisc/vmath.h"
#include "../vmisc/compatibility.h"
#include "vlayoutpiece.h"
#include "vlayoutpaper.h"
#include "../ifc/exception/vexceptionterminatedposition.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/def.h"
#include "vlayoutpaper.h"
#include "vlayoutpiece.h"
//---------------------------------------------------------------------------------------------------------------------
VLayoutGenerator::VLayoutGenerator(QObject *parent)
@ -68,7 +67,8 @@ VLayoutGenerator::VLayoutGenerator(QObject *parent)
multiplier(1),
stripOptimization(false),
textAsPaths(false)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
VLayoutGenerator::~VLayoutGenerator()

View file

@ -28,10 +28,10 @@
#ifndef VLAYOUTPOINT_H
#define VLAYOUTPOINT_H
#include <QtGlobal>
#include <QPointF>
#include <QMetaType>
#include <QPointF>
#include <QVector>
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
@ -66,8 +66,7 @@ Q_DECLARE_METATYPE(VLayoutPoint) // NOLINT
Q_DECLARE_TYPEINFO(VLayoutPoint, Q_MOVABLE_TYPE); // NOLINT
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline auto CastTo(const QVector<T> &points, QVector<T> &casted) -> void
template <class T> inline auto CastTo(const QVector<T> &points, QVector<T> &casted) -> void
{
Q_UNUSED(points)
Q_UNUSED(casted)
@ -110,12 +109,14 @@ auto operator>>(QDataStream &, VLayoutPoint &) -> QDataStream &;
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VLayoutPoint::VLayoutPoint(qreal xpos, qreal ypos)
: QPointF(xpos, ypos)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VLayoutPoint::VLayoutPoint(QPointF p)
: QPointF(p)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VLayoutPoint::TurnPoint() const -> bool

View file

@ -27,31 +27,30 @@
*************************************************************************/
#include "vprintlayout.h"
#include <QPrinterInfo>
#include <QMessageBox>
#include <QSpacerItem>
#include <QGridLayout>
#include <QPrintDialog>
#include <QGuiApplication>
#include <QDir>
#include <QDebug>
#include <QDir>
#include <QGraphicsRectItem>
#include <QGraphicsScene>
#include <QGridLayout>
#include <QGuiApplication>
#include <QMessageBox>
#include <QPageSize>
#include <QPainter>
#include <QPixmapCache>
#include <QGraphicsScene>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include <QPageSize>
#include <QPrinterInfo>
#include <QSpacerItem>
#include "dialogs/dialoglayoutscale.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/xml/vwatermarkconverter.h"
#include "../vformat/vwatermark.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "dialogs/dialoglayoutscale.h"
#include "dialogs/vabstractlayoutdialog.h"
#include "vposter.h"
#include "../vformat/vwatermark.h"
#include "../ifc/xml/vwatermarkconverter.h"
#include "../ifc/exception/vexception.h"
#include "../vmisc/vmath.h"
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "../vmisc/compatibility.h"
namespace
{
@ -59,9 +58,7 @@ namespace
auto FindPageSizeId(QSizeF size) -> QPageSize::PageSizeId
{
auto TestSize = [size](float width, float height)
{
return size == QSizeF(width, height) || size == QSizeF(height, width);
};
{ return size == QSizeF(width, height) || size == QSizeF(height, width); };
constexpr int A0Width = 841;
constexpr int A0Height = 1189;
@ -116,8 +113,8 @@ auto FindPageSizeId(QSizeF size) -> QPageSize::PageSizeId
}
//---------------------------------------------------------------------------------------------------------------------
Q_REQUIRED_RESULT auto PreparePrinter(
const QPrinterInfo &info, QPrinter::PrinterMode mode = QPrinter::ScreenResolution) -> QSharedPointer<QPrinter>;
Q_REQUIRED_RESULT auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode = QPrinter::ScreenResolution)
-> QSharedPointer<QPrinter>;
auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSharedPointer<QPrinter>
{
QPrinterInfo tmpInfo = info;
@ -141,7 +138,8 @@ auto PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode) -> QSh
//---------------------------------------------------------------------------------------------------------------------
VPrintLayout::VPrintLayout(QObject *parent)
: QObject(parent)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
VPrintLayout::~VPrintLayout()
@ -421,8 +419,8 @@ void VPrintLayout::PrintPages(QPrinter *printer)
if (m_isTiled)
{
// Draw tile
posterData = posterazor->Tile(paper, poster->at(index), m_layoutScenes.size(), data,
m_watermarkPath);
posterData =
posterazor->Tile(paper, poster->at(index), m_layoutScenes.size(), data, m_watermarkPath);
}
PreparePaper(paperIndex);
@ -431,8 +429,8 @@ void VPrintLayout::PrintPages(QPrinter *printer)
QRectF source;
m_isTiled ? source = poster->at(index).rect : source = paper->rect();
m_layoutScenes.at(paperIndex)->render(&painter, VPrintLayout::SceneTargetRect(printer, source), source,
Qt::IgnoreAspectRatio);
m_layoutScenes.at(paperIndex)
->render(&painter, VPrintLayout::SceneTargetRect(printer, source), source, Qt::IgnoreAspectRatio);
if (m_isTiled)
{
@ -479,8 +477,8 @@ void VPrintLayout::SetPrinterPrinterMargins(QPrinter *printer)
{
// because when painting we have a -90rotation in landscape mode,
// see function PrintPages.
printerMargins = QMarginsF(m_tiledMargins.bottom(), m_tiledMargins.left(), m_tiledMargins.top(),
m_tiledMargins.right());
printerMargins =
QMarginsF(m_tiledMargins.bottom(), m_tiledMargins.left(), m_tiledMargins.top(), m_tiledMargins.right());
}
else
{
@ -504,8 +502,8 @@ void VPrintLayout::SetPrinterOutputFileName(QPrinter *printer, PrintType printTy
{
case PrintType::PrintPDF:
{
const QString outputFileName = filePath.isEmpty() ? QDir::homePath() + QDir::separator() + DocName()
: filePath;
const QString outputFileName =
filePath.isEmpty() ? QDir::homePath() + QDir::separator() + DocName() : filePath;
printer->setOutputFileName(outputFileName + QStringLiteral(".pdf"));
#ifdef Q_OS_MAC
@ -542,13 +540,13 @@ void VPrintLayout::SetPrinterPageSize(QPrinter *printer)
{
if (m_isLayoutPortrait)
{
height = FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(),
Unit::Mm);
height =
FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(), Unit::Mm);
}
else
{
width = FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(),
Unit::Mm);
width =
FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(), Unit::Mm);
}
}
}
@ -560,13 +558,13 @@ void VPrintLayout::SetPrinterPageSize(QPrinter *printer)
{
if (m_isLayoutPortrait)
{
width = FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(),
Unit::Mm);
width =
FromPixel(paper->rect().width() + m_layoutMargins.left() + m_layoutMargins.right(), Unit::Mm);
}
else
{
height = FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(),
Unit::Mm);
height =
FromPixel(paper->rect().height() + m_layoutMargins.top() + m_layoutMargins.bottom(), Unit::Mm);
}
}
}
@ -670,7 +668,8 @@ auto VPrintLayout::IsPagesUniform() const -> bool
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(m_layoutPapers.at(0));
SCASSERT(paper != nullptr)
return std::all_of(m_layoutPapers.begin(), m_layoutPapers.end(), [paper](QGraphicsItem *paperItem)
return std::all_of(m_layoutPapers.begin(), m_layoutPapers.end(),
[paper](QGraphicsItem *paperItem)
{
auto *p = qgraphicsitem_cast<QGraphicsRectItem *>(paperItem);
SCASSERT(p != nullptr)
@ -711,8 +710,9 @@ auto VPrintLayout::WatermarkData() const -> VWatermarkData
catch (VException &e)
{
const QString errorMsg = tr("File error.\n\n%1\n\n%2").arg(e.ErrorMessage(), e.DetailedInformation());
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
}
@ -766,7 +766,8 @@ auto VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source) -> Q
}
else
{
x = 0; y = 0;
x = 0;
y = 0;
}
QPair<qreal, qreal> scaleDiff = PrinterScaleDiff(printer);

View file

@ -70,17 +70,20 @@ Q_DECLARE_TYPEINFO(VRawSAPoint, Q_MOVABLE_TYPE); // NOLINT
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(qreal xpos, qreal ypos)
: VLayoutPoint(xpos, ypos)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p)
: VLayoutPoint(p)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VRawSAPoint::VRawSAPoint(const VLayoutPoint &p)
: VLayoutPoint(p)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline VRawSAPoint::VRawSAPoint(QPointF p, bool curvePoint, bool turnPoint)

View file

@ -28,15 +28,16 @@
#ifndef VSAPOINT_H
#define VSAPOINT_H
#include <QtGlobal>
#include <QMetaType>
#include <QtGlobal>
#include "../vgeometry/vgeometrydef.h"
#include "../vmisc/def.h"
#include "vlayoutpoint.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/def.h"
#include "../vgeometry/vgeometrydef.h"
#include "vlayoutpoint.h"
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
@ -120,17 +121,20 @@ Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); // NOLINT
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
: VLayoutPoint(xpos, ypos)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(QPointF p)
: VLayoutPoint(p)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(const VLayoutPoint &p)
: VLayoutPoint(p)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VSAPoint::GetSABefore() const -> qreal

View file

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

View file

@ -1,17 +1,13 @@
#ifndef FPM_FIXED_HPP
#define FPM_FIXED_HPP
#include <QtGlobal>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <functional>
#include <limits>
#include <type_traits>
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
namespace fpm
{
@ -21,8 +17,7 @@ namespace fpm
//! unsigned type.
//! \tparam IntermediateType the integer type used to store intermediate results during calculations.
//! \tparam FractionBits the number of bits of the BaseType used to store the fraction
template <typename BaseType, typename IntermediateType, unsigned int FractionBits>
class fixed
template <typename BaseType, typename IntermediateType, unsigned int FractionBits> class fixed
{
static_assert(std::is_integral<BaseType>::value, "BaseType must be an integral type");
static_assert(FractionBits > 0, "FractionBits must be greater than zero");
@ -36,8 +31,13 @@ class fixed
// is incorrect (flips from positive to negative), so we must extend the size to IntermediateType.
static constexpr IntermediateType FRACTION_MULT = IntermediateType(1) << FractionBits;
struct raw_construct_tag {};
constexpr inline fixed(BaseType val, raw_construct_tag /*unused*/) noexcept : m_value(val) {}
struct raw_construct_tag
{
};
constexpr inline fixed(BaseType val, raw_construct_tag /*unused*/) noexcept
: m_value(val)
{
}
public:
inline fixed() noexcept = default;
@ -47,21 +47,24 @@ public:
template <typename T, typename std::enable_if<std::is_integral<T>::value>::type * = nullptr>
constexpr inline explicit fixed(T val) noexcept
: m_value(static_cast<BaseType>(val * FRACTION_MULT))
{}
{
}
// Converts an floating-point number to the fixed-point type.
// Like static_cast, this truncates bits that don't fit.
template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type * = nullptr>
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})))
{}
{
}
// Constructs from another fixed-point type with possibly different underlying representation.
// Like static_cast, this truncates bits that don't fit.
template <typename B, typename I, unsigned int F>
constexpr inline explicit fixed(fixed<B, I, F> val) noexcept
: m_value(from_fixed_point<F>(val.raw_value()).raw_value())
{}
{
}
// Explicit conversion to a floating-point type
template <typename T, typename std::enable_if<std::is_floating_point<T>::value>::type * = nullptr>
@ -79,10 +82,7 @@ public:
// Returns the raw underlying value of this type.
// Do not use this unless you know what you're doing.
constexpr inline auto raw_value() const noexcept -> BaseType
{
return m_value;
}
constexpr inline auto raw_value() const noexcept -> BaseType { return m_value; }
//! Constructs a fixed-point number from another fixed-point number.
//! \tparam NumFractionBits the number of bits used by the fraction in \a value.
@ -93,8 +93,7 @@ public:
{
// To correctly round the last bit in the result, we need one more bit of information.
// We do this by multiplying by two before dividing and adding the LSB to the real result.
return fixed(static_cast<BaseType>(
value / (T(1) << (NumFractionBits - FractionBits)) +
return fixed(static_cast<BaseType>(value / (T(1) << (NumFractionBits - FractionBits)) +
(value / (T(1) << (NumFractionBits - FractionBits - 1)) % 2)),
raw_construct_tag{});
}
@ -103,9 +102,7 @@ public:
typename std::enable_if<(NumFractionBits <= FractionBits)>::type * = nullptr>
static constexpr inline auto from_fixed_point(T value) noexcept -> fixed
{
return fixed(static_cast<BaseType>(
value * (T(1) << (FractionBits - NumFractionBits))),
raw_construct_tag{});
return fixed(static_cast<BaseType>(value * (T(1) << (FractionBits - NumFractionBits))), raw_construct_tag{});
}
// Constructs a fixed-point number from its raw underlying value.
@ -127,10 +124,7 @@ public:
// Arithmetic member operators
//
constexpr inline auto operator-() const noexcept -> fixed
{
return fixed::from_raw_value(-m_value);
}
constexpr inline auto operator-() const noexcept -> fixed { return fixed::from_raw_value(-m_value); }
inline auto operator+=(const fixed &y) noexcept -> fixed &
{
@ -409,8 +403,7 @@ QT_WARNING_POP
namespace std // NOLINT(cert-dcl58-cpp)
{
template <typename B, typename I, unsigned int F>
struct hash<fpm::fixed<B,I,F>>
template <typename B, typename I, unsigned int F> struct hash<fpm::fixed<B, I, F>>
{
using argument_type = fpm::fixed<B, I, F>;
using result_type = std::size_t;
@ -425,8 +418,7 @@ private:
std::hash<B> m_hash;
};
template <typename B, typename I, unsigned int F>
struct numeric_limits<fpm::fixed<B,I,F>>
template <typename B, typename I, unsigned int F> struct numeric_limits<fpm::fixed<B, I, F>>
{
static constexpr bool is_specialized = true;
static constexpr bool is_signed = std::numeric_limits<B>::is_signed;
@ -466,30 +458,18 @@ struct numeric_limits<fpm::fixed<B,I,F>>
return fpm::fixed<B, I, F>::from_raw_value(std::numeric_limits<B>::lowest());
}
static constexpr auto min() noexcept -> fpm::fixed<B,I,F>
{
return lowest();
}
static constexpr auto min() noexcept -> fpm::fixed<B, I, F> { return lowest(); }
static constexpr auto max() noexcept -> fpm::fixed<B, I, F>
{
return fpm::fixed<B, I, F>::from_raw_value(std::numeric_limits<B>::max());
}
static constexpr auto epsilon() noexcept -> fpm::fixed<B,I,F>
{
return fpm::fixed<B,I,F>::from_raw_value(1);
}
static constexpr auto epsilon() noexcept -> fpm::fixed<B, I, F> { return fpm::fixed<B, I, F>::from_raw_value(1); }
static constexpr auto round_error() noexcept -> fpm::fixed<B,I,F>
{
return fpm::fixed<B,I,F>(1) / 2;
}
static constexpr auto round_error() noexcept -> fpm::fixed<B, I, F> { return fpm::fixed<B, I, F>(1) / 2; }
static constexpr auto denorm_min() noexcept -> fpm::fixed<B,I,F>
{
return min();
}
static constexpr auto denorm_min() noexcept -> fpm::fixed<B, I, F> { return min(); }
};
// See https://stackoverflow.com/a/46719572/3045403
@ -509,11 +489,13 @@ constexpr bool numeric_limits<fpm::fixed<B,I,F>>::has_quiet_NaN; // NOLINT(reada
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::has_signaling_NaN; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr std::float_denorm_style numeric_limits<fpm::fixed<B,I,F>>::has_denorm; // NOLINT(readability-redundant-declaration)
constexpr std::float_denorm_style
numeric_limits<fpm::fixed<B, I, F>>::has_denorm; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::has_denorm_loss; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr std::float_round_style numeric_limits<fpm::fixed<B,I,F>>::round_style; // NOLINT(readability-redundant-declaration)
constexpr std::float_round_style
numeric_limits<fpm::fixed<B, I, F>>::round_style; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>
constexpr bool numeric_limits<fpm::fixed<B, I, F>>::is_iec_559; // NOLINT(readability-redundant-declaration)
template <typename B, typename I, unsigned int F>

View file

@ -37,9 +37,12 @@ inline auto find_highest_bit(unsigned long long value) noexcept -> long
#if defined(_WIN64)
_BitScanReverse64(&index, value);
#else
if (_BitScanReverse(&index, static_cast<unsigned long>(value >> 32)) != 0) {
if (_BitScanReverse(&index, static_cast<unsigned long>(value >> 32)) != 0)
{
index += 32;
} else {
}
else
{
_BitScanReverse(&index, static_cast<unsigned long>(value & 0xfffffffflu));
}
#endif
@ -59,8 +62,7 @@ QT_WARNING_POP
// Classification methods
//
template <typename B, typename I, unsigned int F>
constexpr inline auto fpclassify(fixed<B, I, F> x) noexcept -> int
template <typename B, typename I, unsigned int F> constexpr inline auto fpclassify(fixed<B, I, F> x) noexcept -> int
{
return (x.raw_value() == 0) ? FP_ZERO : FP_NORMAL;
}
@ -83,14 +85,12 @@ constexpr inline auto isnan(fixed<B, I, F> /*unused*/) noexcept -> bool
return false;
}
template <typename B, typename I, unsigned int F>
constexpr inline auto isnormal(fixed<B, I, F> x) noexcept -> bool
template <typename B, typename I, unsigned int F> constexpr inline auto isnormal(fixed<B, I, F> x) noexcept -> bool
{
return x.raw_value() != 0;
}
template <typename B, typename I, unsigned int F>
constexpr inline auto signbit(fixed<B, I, F> x) noexcept -> bool
template <typename B, typename I, unsigned int F> constexpr inline auto signbit(fixed<B, I, F> x) noexcept -> bool
{
return x.raw_value() < 0;
}
@ -134,8 +134,7 @@ constexpr inline auto isunordered(fixed<B, I, F> /*x*/, fixed<B, I, F> /*y*/)
//
// Nearest integer operations
//
template <typename B, typename I, unsigned int F>
inline auto ceil(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto ceil(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
constexpr auto FRAC = B(1) << F;
auto value = x.raw_value();
@ -146,8 +145,7 @@ inline auto ceil(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return fixed<B, I, F>::from_raw_value(value / FRAC * FRAC);
}
template <typename B, typename I, unsigned int F>
inline auto floor(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto floor(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
constexpr auto FRAC = B(1) << F;
auto value = x.raw_value();
@ -158,23 +156,20 @@ inline auto floor(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return fixed<B, I, F>::from_raw_value(value / FRAC * FRAC);
}
template <typename B, typename I, unsigned int F>
inline auto trunc(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto trunc(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
constexpr auto FRAC = B(1) << F;
return fixed<B, I, F>::from_raw_value(x.raw_value() / FRAC * FRAC);
}
template <typename B, typename I, unsigned int F>
inline auto round(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto round(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
constexpr auto FRAC = B(1) << F;
auto value = x.raw_value() / (FRAC / 2);
return fixed<B, I, F>::from_raw_value(((value / 2) + (value % 2)) * FRAC);
}
template <typename B, typename I, unsigned int F>
auto nearbyint(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto nearbyint(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
// Rounding mode is assumed to be FE_TONEAREST
constexpr auto FRAC = B(1) << F;
@ -196,8 +191,7 @@ constexpr inline auto rint(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
//
// Mathematical functions
//
template <typename B, typename I, unsigned int F>
constexpr inline auto abs(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> constexpr inline auto abs(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
return (x >= fixed<B, I, F>{0}) ? x : -x;
}
@ -205,17 +199,13 @@ constexpr inline auto abs(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F>
constexpr inline auto fmod(fixed<B, I, F> x, fixed<B, I, F> y) noexcept -> fixed<B, I, F>
{
return
assert(y.raw_value() != 0),
fixed<B, I, F>::from_raw_value(x.raw_value() % y.raw_value());
return assert(y.raw_value() != 0), fixed<B, I, F>::from_raw_value(x.raw_value() % y.raw_value());
}
template <typename B, typename I, unsigned int F>
constexpr inline auto remainder(fixed<B, I, F> x, fixed<B, I, F> y) noexcept -> fixed<B, I, F>
{
return
assert(y.raw_value() != 0),
x - nearbyint(x / y) * y;
return assert(y.raw_value() != 0), x - nearbyint(x / y) * y;
}
template <typename B, typename I, unsigned int F>
@ -234,16 +224,14 @@ inline auto remquo(fixed<B, I, F> x, fixed<B, I, F> y, int* quo) noexcept -> fix
template <typename B, typename I, unsigned int F, typename C, typename J, unsigned int G>
constexpr inline auto copysign(fixed<B, I, F> x, fixed<C, J, G> y) noexcept -> fixed<B, I, F>
{
return
x = abs(x),
(y >= fixed<C, J, G>{0}) ? x : -x;
return x = abs(x), (y >= fixed<C, J, G>{0}) ? x : -x;
}
template <typename B, typename I, unsigned int F>
constexpr inline auto nextafter(fixed<B, I, F> from, fixed<B, I, F> to) noexcept -> fixed<B, I, F>
{
return from == to ? to :
to > from ? fixed<B, I, F>::from_raw_value(from.raw_value() + 1)
return from == to ? to
: to > from ? fixed<B, I, F>::from_raw_value(from.raw_value() + 1)
: fixed<B, I, F>::from_raw_value(from.raw_value() - 1);
}
@ -262,7 +250,6 @@ inline auto modf(fixed<B, I, F> x, fixed<B, I, F>* iptr) noexcept -> fixed<B, I,
return fixed<B, I, F>::from_raw_value(raw % FRAC);
}
//
// Power functions
//
@ -273,7 +260,8 @@ auto pow(fixed<B, I, F> base, T exp) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (base == Fixed(0)) {
if (base == Fixed(0))
{
assert(exp > 0);
return Fixed(0);
}
@ -307,7 +295,8 @@ auto pow(fixed<B, I, F> base, fixed<B, I, F> exp) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (base == Fixed(0)) {
if (base == Fixed(0))
{
assert(exp > Fixed(0));
return Fixed(0);
}
@ -331,11 +320,11 @@ auto pow(fixed<B, I, F> base, fixed<B, I, F> exp) noexcept -> fixed<B, I, F>
return exp2(log2(base) * exp);
}
template <typename B, typename I, unsigned int F>
auto exp(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto exp(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (x < Fixed(0)) {
if (x < Fixed(0))
{
return 1 / exp(-x);
}
constexpr auto FRAC = B(1) << F;
@ -352,11 +341,11 @@ auto exp(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return pow(Fixed::e(), x_int) * (((((fA * x + fB) * x + fC) * x + fD) * x + fE) * x + fF);
}
template <typename B, typename I, unsigned int F>
auto exp2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto exp2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (x < Fixed(0)) {
if (x < Fixed(0))
{
return 1 / exp2(-x);
}
constexpr auto FRAC = B(1) << F;
@ -373,14 +362,12 @@ auto exp2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return Fixed(1 << x_int) * (((((fA * x + fB) * x + fC) * x + fD) * x + fE) * x + fF);
}
template <typename B, typename I, unsigned int F>
auto expm1(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto expm1(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
return exp(x) - 1; // cppcheck-suppress unpreciseMathCall
}
template <typename B, typename I, unsigned int F>
auto log2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto log2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
assert(x > Fixed(0));
@ -408,28 +395,24 @@ auto log2(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return Fixed(highest - F) + (((((fA * x + fB) * x + fC) * x + fD) * x + fE) * x + fF);
}
template <typename B, typename I, unsigned int F>
auto log(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto log(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
return log2(x) / log2(Fixed::e());
}
template <typename B, typename I, unsigned int F>
auto log10(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto log10(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
return log2(x) / log2(Fixed(10));
}
template <typename B, typename I, unsigned int F>
auto log1p(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto log1p(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
return log(1 + x); // cppcheck-suppress unpreciseMathCall
}
template <typename B, typename I, unsigned int F>
auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
@ -480,8 +463,7 @@ auto cbrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return Fixed::from_raw_value(static_cast<B>(res));
}
template <typename B, typename I, unsigned int F>
auto sqrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto sqrt(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
@ -530,8 +512,7 @@ auto hypot(fixed<B, I, F> x, fixed<B, I, F> y) noexcept -> fixed<B, I, F>
// Trigonometry functions
//
template <typename B, typename I, unsigned int F>
auto sin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto sin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
// This sine uses a fifth-order curve-fitting approximation originally
// described by Jasper Vijn on coranac.com which has a worst-case
@ -543,18 +524,21 @@ auto sin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
x = x / Fixed::half_pi();
// Take x modulo one rotation, so [-4..+4].
if (x < Fixed(0)) {
if (x < Fixed(0))
{
x += Fixed(4);
}
int sign = +1;
if (x > Fixed(2)) {
if (x > Fixed(2))
{
// Reduce domain to [0..2].
sign = -1;
x -= Fixed(2);
}
if (x > Fixed(1)) {
if (x > Fixed(1))
{
// Reduce domain to [0..1].
x = Fixed(2) - x;
}
@ -563,14 +547,12 @@ auto sin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return sign * x * (Fixed::pi() - x2 * (Fixed::two_pi() - 5 - x2 * (Fixed::pi() - 3))) / 2;
}
template <typename B, typename I, unsigned int F>
inline auto cos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto cos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
return sin(fixed<B, I, F>::half_pi() + x);
}
template <typename B, typename I, unsigned int F>
inline auto tan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> inline auto tan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
auto cx = cos(x);
@ -581,18 +563,19 @@ inline auto tan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return sin(x) / cx;
}
namespace detail {
namespace detail
{
// Calculates atan(x) assuming that x is in the range [0,1]
template <typename B, typename I, unsigned int F>
auto atan_sanitized(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto atan_sanitized(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
assert(x >= Fixed(0) && x <= Fixed(1));
constexpr auto fA = Fixed::template from_fixed_point<63>(716203666280654660LL); // 0.0776509570923569
constexpr auto fB = Fixed::template from_fixed_point<63>(-2651115102768076601LL); // -0.287434475393028
constexpr auto fC = Fixed::template from_fixed_point<63>( 9178930894564541004LL); // 0.995181681698119 (PI/4 - A - B)
constexpr auto fC =
Fixed::template from_fixed_point<63>(9178930894564541004LL); // 0.995181681698119 (PI/4 - A - B)
const auto xx = x * x;
return ((fA * xx + fB) * xx + fC) * x;
@ -613,19 +596,23 @@ auto atan_div(fixed<B, I, F> y, fixed<B, I, F> x) noexcept -> fixed<B, I, F>
// Make sure y and x are positive.
// If y / x is negative (when y or x, but not both, are negative), negate the result to
// keep the correct outcome.
if (y < Fixed(0)) {
if (x < Fixed(0)) {
if (y < Fixed(0))
{
if (x < Fixed(0))
{
return atan_div(-y, -x);
}
return -atan_div(-y, x);
}
if (x < Fixed(0)) {
if (x < Fixed(0))
{
return -atan_div(y, -x);
}
assert(y >= Fixed(0));
assert(x > Fixed(0));
if (y > x) {
if (y > x)
{
return Fixed::half_pi() - detail::atan_sanitized(x / y);
}
return detail::atan_sanitized(y / x);
@ -633,8 +620,7 @@ auto atan_div(fixed<B, I, F> y, fixed<B, I, F> x) noexcept -> fixed<B, I, F>
} // namespace detail
template <typename B, typename I, unsigned int F>
auto atan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto atan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
if (x < Fixed(0))
@ -650,8 +636,7 @@ auto atan(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return detail::atan_sanitized(x);
}
template <typename B, typename I, unsigned int F>
auto asin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto asin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
assert(x >= Fixed(-1) && x <= Fixed(+1));
@ -664,8 +649,7 @@ auto asin(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
return detail::atan_div(x, sqrt(yy));
}
template <typename B, typename I, unsigned int F>
auto acos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
template <typename B, typename I, unsigned int F> auto acos(fixed<B, I, F> x) noexcept -> fixed<B, I, F>
{
using Fixed = fixed<B, I, F>;
assert(x >= Fixed(-1) && x <= Fixed(+1));

View file

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

View file

@ -17,11 +17,11 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtGlobal>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
@ -54,7 +54,6 @@ struct face_s;
struct halfedge_s;
struct point2d_s;
#ifdef USE_DOUBLE
#define REAL_ZERO 0.0
#define REAL_ONE 1.0
@ -114,7 +113,6 @@ struct delaunay_s
quint32 end_point; /* end point index */
};
/*
* 3x3 matrix determinant
*/
@ -196,7 +194,8 @@ void del_free_halfedges( delaunay_t *del )
d = del->points[i]->he;
if (d != nullptr)
{
do {
do
{
sig = d->next;
halfedge_free(d);
d = sig;
@ -440,7 +439,6 @@ static auto in_circle(point2d_t *pt0, point2d_t *pt1, point2d_t *pt2, point2d_t
res = a * (p->x * p->x + p->y * p->y) - bx * p->x - by * p->y + c;
if (res < REAL_ZERO)
return INSIDE;
else if (res > REAL_ZERO)
@ -485,7 +483,6 @@ static auto del_init_seg(delaunay_t *del, int start) -> int
del->rightmost_he = d1;
del->leftmost_he = d0;
return 0;
}
@ -561,8 +558,8 @@ static auto del_init_tri(delaunay_t *del, int start) -> int
del->rightmost_he = d1;
del->leftmost_he = d0;
} else /* 2nd case */
}
else /* 2nd case */
{
/* set halfedges points */
d0->vertex = pt0;
@ -633,7 +630,6 @@ static void del_remove_edge( halfedge_t *d )
next->prev = prev;
prev->next = next;
/* check to see if we have already removed pair */
if (pair)
pair->pair = nullptr;
@ -657,7 +653,6 @@ static void del_remove_edge( halfedge_t *d )
next->prev = prev;
prev->next = next;
/* check to see if we have already removed pair */
if (pair)
pair->pair = nullptr;
@ -671,7 +666,6 @@ static void del_remove_edge( halfedge_t *d )
orig_pair->prev = nullptr;
orig_pair->pair = nullptr;
/* finally free the halfedges */
halfedge_free(d);
halfedge_free(orig_pair);
@ -717,7 +711,8 @@ static auto del_valid_left(halfedge_t *b) -> halfedge_t *
du = du->prev;
del_remove_edge(b);
}
} else /* treat the case where the 3 points are colinear */
}
else /* treat the case where the 3 points are colinear */
du = dg;
assert(du->pair);
@ -761,14 +756,14 @@ static auto del_valid_right(halfedge_t *b) -> halfedge_t *
du = du->next;
del_remove_edge(b);
}
} else
}
else
du = dd;
assert(du->pair);
return du;
}
/*
* validate a link
*/
@ -842,15 +837,18 @@ static auto del_get_lower_tangent(delaunay_t *left, delaunay_t *right) -> halfed
left_d = left->rightmost_he;
right_d = right->leftmost_he;
do {
do
{
point2d_t *pl = left_d->prev->pair->vertex;
point2d_t *pr = right_d->pair->vertex;
if( (sl = classify_point_seg(left_d->vertex, right_d->vertex, pl)) == ON_RIGHT ) {
if ((sl = classify_point_seg(left_d->vertex, right_d->vertex, pl)) == ON_RIGHT)
{
left_d = left_d->prev->pair;
}
if( (sr = classify_point_seg(left_d->vertex, right_d->vertex, pr)) == ON_RIGHT ) {
if ((sr = classify_point_seg(left_d->vertex, right_d->vertex, pr)) == ON_RIGHT)
{
right_d = right_d->pair->next;
}
@ -897,8 +895,7 @@ static void del_link( delaunay_t *result, delaunay_t *left, delaunay_t *right )
u = base->next->pair->vertex;
v = base->pair->prev->pair->vertex;
while( del_classify_point(base, u) == ON_LEFT ||
del_classify_point(base, v) == ON_LEFT )
while (del_classify_point(base, u) == ON_LEFT || del_classify_point(base, v) == ON_LEFT)
{
base = del_valid_link(base);
u = base->next->pair->vertex;
@ -940,11 +937,10 @@ void del_divide_and_conquer( delaunay_t *del, int start, int end )
del_divide_and_conquer(&left, start, start + i - 1);
del_divide_and_conquer(&right, start + i, end);
del_link(del, &left, &right);
} else
if( n == 3 )
}
else if (n == 3)
del_init_tri(del, start);
else
if( n == 2 )
else if (n == 2)
del_init_seg(del, start);
}
@ -962,7 +958,8 @@ static void build_halfedge_face( delaunay_t *del, halfedge_t *d )
curr = d;
f->he = d;
f->num_verts = 0;
do {
do
{
curr->face = f;
(f->num_verts)++;
curr = curr->pair->prev;
@ -978,7 +975,8 @@ static void build_halfedge_face( delaunay_t *del, halfedge_t *d )
if( classify_point_seg( d->face.p[0], d->face.p[1], d->face.p[2] ) == ON_LEFT )
{
compute_circle(d->face.p[0], d->face.p[1], d->face.p[2], &(d->face.cx), &(d->face.cy), &(d->face.radius));
compute_circle(d->face.p[0], d->face.p[1], d->face.p[2], &(d->face.cx), &(d->face.cy),
&(d->face.radius));
}
}
*/
@ -1003,7 +1001,8 @@ void del_build_faces( delaunay_t *del )
{
curr = del->points[i]->he;
do {
do
{
build_halfedge_face(del, curr);
curr = curr->next;
} while (curr != del->points[i]->he);
@ -1041,7 +1040,8 @@ auto delaunay2d_from(del_point2d_t *points, quint32 num_points) -> delaunay2d_t
qsort(del.points, num_points, sizeof(point2d_t *), cmp_points);
if( num_points >= 3 ) {
if (num_points >= 3)
{
quint32 fbuff_size = 0;
quint32 j = 0;
@ -1061,7 +1061,8 @@ auto delaunay2d_from(del_point2d_t *points, quint32 num_points) -> delaunay2d_t
j++;
curr = del.faces[i].he;
do {
do
{
faces[j] = curr->vertex->idx;
j++;
curr = curr->pair->prev;
@ -1087,7 +1088,8 @@ auto delaunay2d_from(del_point2d_t *points, quint32 num_points) -> delaunay2d_t
return res;
}
void delaunay2d_release(delaunay2d_t *del) {
void delaunay2d_release(delaunay2d_t *del)
{
free(del->faces);
free(del->points);
free(del);

View file

@ -107,10 +107,6 @@
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_MSVC(4701)
// cppcheck-suppress unknownMacro
@ -153,7 +149,6 @@ QT_WARNING_DISABLE_CLANG("-Wconditional-uninitialized")
#define Absolute(a) ((a) >= 0.0 ? (a) : -(a))
/* #define Absolute(a) fabs(a) */
/* Many of the operations are broken up into two pieces, a main part that */
/* performs an approximate operation, and a "tail" that computes the */
/* roundoff error of that operation. */
@ -463,7 +458,8 @@ auto scale_expansion_zeroelim(int elen, qreal *e, qreal b, qreal *h) -> int /* e
Split(b, bhi, blo);
Two_Product_Presplit(e[0], b, bhi, blo, Q, hh);
hindex = 0;
if (hh != 0) {
if (hh != 0)
{
h[hindex++] = hh;
}
for (eindex = 1; eindex < elen; eindex++)
@ -632,19 +628,19 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
Two_Diff_Tail(pb[1], pd[1], bdy, bdytail);
Two_Diff_Tail(pc[0], pd[0], cdx, cdxtail);
Two_Diff_Tail(pc[1], pd[1], cdy, cdytail);
if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0)
&& (adytail == 0.0) && (bdytail == 0.0) && (cdytail == 0.0))
if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0) && (adytail == 0.0) && (bdytail == 0.0) &&
(cdytail == 0.0))
{
return det;
}
errbound = iccerrboundC * permanent + resulterrbound * Absolute(det);
det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail) - (bdy * cdxtail + cdx * bdytail))
+ 2.0 * (adx * adxtail + ady * adytail) * (bdx * cdy - bdy * cdx))
+ ((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail) - (cdy * adxtail + adx * cdytail))
+ 2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx))
+ ((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - (ady * bdxtail + bdx * adytail))
+ 2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx));
det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail) - (bdy * cdxtail + cdx * bdytail)) +
2.0 * (adx * adxtail + ady * adytail) * (bdx * cdy - bdy * cdx)) +
((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail) - (cdy * adxtail + adx * cdytail)) +
2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx)) +
((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - (ady * bdxtail + bdx * adytail)) +
2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx));
if ((det >= errbound) || (-det >= errbound))
{
return det;
@ -689,7 +685,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (adytail != 0.0)
{
@ -705,7 +703,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (bdxtail != 0.0)
{
@ -721,7 +721,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (bdytail != 0.0)
{
@ -737,7 +739,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (cdxtail != 0.0)
{
@ -750,13 +754,12 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
cxtaalen = scale_expansion_zeroelim(4, aa, cdxtail, cxtaa);
temp16clen = scale_expansion_zeroelim(cxtaalen, cxtaa, -bdy, temp16c);
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a,
temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c,
temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len,
temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (cdytail != 0.0)
{
@ -772,7 +775,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16clen, temp16c, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if ((adxtail != 0.0) || (adytail != 0.0))
@ -812,20 +817,26 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = scale_expansion_zeroelim(axtbctlen, axtbct, 2.0 * adx, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
if (bdytail != 0.0)
{
temp8len = scale_expansion_zeroelim(4, cc, adxtail, temp8);
temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (cdytail != 0.0)
{
temp8len = scale_expansion_zeroelim(4, bb, -adxtail, temp8);
temp16alen = scale_expansion_zeroelim(temp8len, temp8, cdytail, temp16a);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
temp32alen = scale_expansion_zeroelim(axtbctlen, axtbct, adxtail, temp32a);
@ -835,7 +846,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (adytail != 0.0)
{
@ -844,8 +857,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, 2.0 * ady, temp32a);
temp48len = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp32alen, temp32a, temp48);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp48len, temp48, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
temp32alen = scale_expansion_zeroelim(aytbctlen, aytbct, adytail, temp32a);
aytbcttlen = scale_expansion_zeroelim(bcttlen, bctt, adytail, aytbctt);
@ -854,7 +868,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
}
if ((bdxtail != 0.0) || (bdytail != 0.0))
@ -923,7 +939,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
if (bdytail != 0.0)
{
@ -936,7 +954,6 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
finnow = finother;
finother = finswap;
temp32alen = scale_expansion_zeroelim(bytcatlen, bytcat, bdytail, temp32a);
bytcattlen = scale_expansion_zeroelim(cattlen, catt, bdytail, bytcatt);
temp16alen = scale_expansion_zeroelim(bytcattlen, bytcatt, 2.0 * bdy, temp16a);
@ -1003,7 +1020,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp8len = scale_expansion_zeroelim(4, aa, -cdxtail, temp8);
temp16alen = scale_expansion_zeroelim(temp8len, temp8, bdytail, temp16a);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp16alen, temp16a, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
temp32alen = scale_expansion_zeroelim(cxtabtlen, cxtabt, cdxtail, temp32a);
@ -1028,7 +1047,6 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
finnow = finother;
finother = finswap;
temp32alen = scale_expansion_zeroelim(cytabtlen, cytabt, cdytail, temp32a);
cytabttlen = scale_expansion_zeroelim(abttlen, abtt, cdytail, cytabtt);
temp16alen = scale_expansion_zeroelim(cytabttlen, cytabtt, 2.0 * cdy, temp16a);
@ -1036,7 +1054,9 @@ auto incircleadapt(qreal *pa, qreal *pb, qreal *pc, qreal *pd, qreal permanent)
temp32blen = fast_expansion_sum_zeroelim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
temp64len = fast_expansion_sum_zeroelim(temp32alen, temp32a, temp32blen, temp32b, temp64);
finlength = fast_expansion_sum_zeroelim(finlength, finnow, temp64len, temp64, finother);
finswap = finnow; finnow = finother; finother = finswap;
finswap = finnow;
finnow = finother;
finother = finswap;
}
}
@ -1070,13 +1090,10 @@ auto incircle(qreal *pa, qreal *pb, qreal *pc, qreal *pd) -> qreal
bdxady = bdx * ady;
clift = cdx * cdx + cdy * cdy;
det = alift * (bdxcdy - cdxbdy)
+ blift * (cdxady - adxcdy)
+ clift * (adxbdy - bdxady);
det = alift * (bdxcdy - cdxbdy) + blift * (cdxady - adxcdy) + clift * (adxbdy - bdxady);
permanent = (Absolute(bdxcdy) + Absolute(cdxbdy)) * alift
+ (Absolute(cdxady) + Absolute(adxcdy)) * blift
+ (Absolute(adxbdy) + Absolute(bdxady)) * clift;
permanent = (Absolute(bdxcdy) + Absolute(cdxbdy)) * alift + (Absolute(cdxady) + Absolute(adxcdy)) * blift +
(Absolute(adxbdy) + Absolute(bdxady)) * clift;
errbound = iccerrboundA * permanent;
if ((det > errbound) || (-det > errbound))
{

View file

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

View file

@ -608,11 +608,10 @@ VPassmark::VPassmark(const VPiecePassmarkData &data)
m_null(false)
{
// Correct distorsion
if (VGObject::IsPointOnLineSegment(m_data.passmarkSAPoint, m_data.previousSAPoint,
m_data.nextSAPoint))
if (VGObject::IsPointOnLineSegment(m_data.passmarkSAPoint, m_data.previousSAPoint, m_data.nextSAPoint))
{
const QPointF p = VGObject::CorrectDistortion(m_data.passmarkSAPoint, m_data.previousSAPoint,
m_data.nextSAPoint);
const QPointF p =
VGObject::CorrectDistortion(m_data.passmarkSAPoint, m_data.previousSAPoint, m_data.nextSAPoint);
m_data.passmarkSAPoint.setX(p.x());
m_data.passmarkSAPoint.setY(p.y());
}
@ -630,16 +629,14 @@ auto VPassmark::FullPassmark(const VPiece &piece, const VContainer *data) const
{
QVector<QLineF> lines;
lines += SAPassmark(piece, data, PassmarkSide::All);
if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark()
&& (VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath())
&& m_data.isMainPathNode
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection
&& m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft
&& m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyRight
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection2
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyLeft
&& m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight
&& m_data.isShowSecondPassmark)
if (VAbstractApplication::VApp()->Settings()->IsDoublePassmark() &&
(VAbstractApplication::VApp()->Settings()->IsPieceShowMainPath() || not piece.IsHideMainPath()) &&
m_data.isMainPathNode && m_data.passmarkAngleType != PassmarkAngleType::Intersection &&
m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyLeft &&
m_data.passmarkAngleType != PassmarkAngleType::IntersectionOnlyRight &&
m_data.passmarkAngleType != PassmarkAngleType::Intersection2 &&
m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyLeft &&
m_data.passmarkAngleType != PassmarkAngleType::Intersection2OnlyRight && m_data.isShowSecondPassmark)
{
lines += BuiltInSAPassmark(piece, data);
}
@ -994,9 +991,11 @@ auto VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowance, const
if (rotatedSeamAllowance.size() < 2)
{
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Seam allowance is "
"empty.").arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
"empty.")
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return {}; // Something wrong
}
@ -1007,8 +1006,9 @@ auto VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowance, const
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find "
"position for a notch.")
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return {}; // Something wrong
}
@ -1022,8 +1022,9 @@ auto VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowance, const
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Unable to fix a "
"notch position.")
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
VAbstractApplication::VApp()->IsPedantic()
? throw VExceptionInvalidNotch(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward)

View file

@ -21,7 +21,6 @@
#ifndef VFILEPROPERTYEDITOR_H
#define VFILEPROPERTYEDITOR_H
#include <QLineEdit>
#include <QMetaObject>
#include <QMimeData>
@ -52,7 +51,6 @@ public:
explicit VFileEditWidget(QWidget *parent, bool is_directory = false);
virtual ~VFileEditWidget() override;
//! This function returns the file currently set to this editor
auto getFile() const -> QString;
@ -73,7 +71,6 @@ signals:
//! and is connected to the delegate's commitData() signal
void commitData(QWidget *editor);
public slots:
//! Sets the current file, does not check if it is valid
//! \param value The new filepath the widget should show
@ -120,6 +117,6 @@ private:
QT_WARNING_POP
}
} // namespace VPE
#endif // VFILEPROPERTYEDITOR_H

View file

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

View file

@ -50,19 +50,31 @@ public:
bool IgnoreDataChangedSignal;
VPropertyFormViewPrivate()
: VPropertyFormWidgetPrivate(), Model(nullptr), PropertySet(nullptr), NeedsRebuild(false),
: VPropertyFormWidgetPrivate(),
Model(nullptr),
PropertySet(nullptr),
NeedsRebuild(false),
IgnoreDataChangedSignal(false)
{}
{
}
explicit VPropertyFormViewPrivate(VPropertyModel *prop_model)
: VPropertyFormWidgetPrivate(), Model(prop_model), PropertySet(nullptr), NeedsRebuild(false),
: VPropertyFormWidgetPrivate(),
Model(prop_model),
PropertySet(nullptr),
NeedsRebuild(false),
IgnoreDataChangedSignal(false)
{}
{
}
explicit VPropertyFormViewPrivate(VPropertySet *prop_set)
: VPropertyFormWidgetPrivate(), Model(nullptr), PropertySet(prop_set), NeedsRebuild(false),
: VPropertyFormWidgetPrivate(),
Model(nullptr),
PropertySet(prop_set),
NeedsRebuild(false),
IgnoreDataChangedSignal(false)
{}
{
}
virtual ~VPropertyFormViewPrivate() override {}
@ -72,6 +84,6 @@ private:
QT_WARNING_POP
}
} // namespace VPE
#endif // VPROPERTYFORMVIEW_P_H

View file

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

View file

@ -51,11 +51,17 @@ public:
QVariant::Type type,
#endif
QWidget *widget = nullptr)
: VPropertyPrivate(name, type), Widget(widget) {}
: VPropertyPrivate(name, type),
Widget(widget)
{
}
//! Constructor
VWidgetPropertyPrivate()
: VPropertyPrivate(), Widget(nullptr) {}
: VPropertyPrivate(),
Widget(nullptr)
{
}
//! Destructor
virtual ~VWidgetPropertyPrivate() override

View file

@ -28,8 +28,6 @@
#include "vtoolflippingbyaxis.h"
#include <climits>
#include <qiterator.h>
#include <QColor>
#include <QDomNode>
#include <QDomNodeList>
@ -37,28 +35,27 @@
#include <QPoint>
#include <QSharedPointer>
#include <QUndoStack>
#include <climits>
#include <new>
#include <qiterator.h>
#include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../dialogs/tools/dialogflippingbyaxis.h"
#include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../visualization/line/operation/vistoolflippingbyaxis.h"
#include "../../../../visualization/visualization.h"
#include "../vgeometry/vpointf.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../ifc/ifcdef.h"
#include "../ifc/exception/vexception.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../../../vabstracttool.h"
#include "../../../vdatatool.h"
#include "../../vdrawtool.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/ifcdef.h"
#include "../vgeometry/vpointf.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
template <class T> class QSharedPointer;

View file

@ -28,8 +28,6 @@
#include "vtoolflippingbyline.h"
#include <climits>
#include <qiterator.h>
#include <QColor>
#include <QDomNode>
#include <QDomNodeList>
@ -37,14 +35,20 @@
#include <QPoint>
#include <QSharedPointer>
#include <QUndoStack>
#include <climits>
#include <new>
#include <qiterator.h>
#include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../dialogs/tools/dialogflippingbyline.h"
#include "../../../../dialogs/tools/dialogtool.h"
#include "../../../../visualization/line/operation/vistoolflippingbyline.h"
#include "../../../../visualization/visualization.h"
#include "../../../vabstracttool.h"
#include "../../../vdatatool.h"
#include "../../vdrawtool.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/ifcdef.h"
#include "../vgeometry/vpointf.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
@ -52,13 +56,9 @@
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../ifc/ifcdef.h"
#include "../ifc/exception/vexception.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../../../vabstracttool.h"
#include "../../../vdatatool.h"
#include "../../vdrawtool.h"
template <class T> class QSharedPointer;
@ -250,8 +250,7 @@ auto VToolFlippingByLine::MakeToolTip() const -> QString
return QStringLiteral("<tr> <td><b>%1:</b> %2</td> </tr>"
"<tr> <td><b>%3:</b> %4</td> </tr>"
"%5")
.arg(tr("First line point"), FirstLinePointName(),
tr("Second line point"), SecondLinePointName()) // 1, 2, 3, 4
.arg(tr("First line point"), FirstLinePointName(), tr("Second line point"), SecondLinePointName()) // 1, 2, 3, 4
.arg(VisibilityGroupToolTip()); // 5
}

View file

@ -28,8 +28,6 @@
#include "vtoolmove.h"
#include <climits>
#include <qiterator.h>
#include <QColor>
#include <QDomNode>
#include <QDomNodeList>
@ -37,37 +35,39 @@
#include <QPoint>
#include <QSharedPointer>
#include <QUndoStack>
#include <climits>
#include <new>
#include <qiterator.h>
#include "../../../dialogs/tools/dialogtool.h"
#include "../../../dialogs/tools/dialogmove.h"
#include "../../../dialogs/tools/dialogtool.h"
#include "../../../visualization/line/operation/vistoolmove.h"
#include "../../../visualization/visualization.h"
#include "../../vabstracttool.h"
#include "../../vdatatool.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/ifcdef.h"
#include "../vdrawtool.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/varc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vcubicbezier.h"
#include "../vgeometry/vcubicbezierpath.h"
#include "../vgeometry/vellipticalarc.h"
#include "../vgeometry/vgobject.h"
#include "../vgeometry/vpointf.h"
#include "../vgeometry/vspline.h"
#include "../vgeometry/vsplinepath.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
#include "../vmisc/compatibility.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vformula.h"
#include "../ifc/ifcdef.h"
#include "../ifc/exception/vexception.h"
#include "../vpatterndb/vtranslatevars.h"
#include "../vwidgets/vabstractsimple.h"
#include "../vwidgets/vmaingraphicsscene.h"
#include "../../vabstracttool.h"
#include "../../vdatatool.h"
#include "../vdrawtool.h"
template <class T> class QSharedPointer;
@ -115,7 +115,7 @@ auto GetOriginPoint(const QVector<SourceItem> &objects, const VContainer *data,
return move.p2();
}
QT_WARNING_POP
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
void VToolMove::SetDialog()
@ -176,8 +176,8 @@ auto VToolMove::Create(VToolMoveInitData &initData) -> VToolMove *
calcAngle = CheckFormula(initData.id, initData.formulaAngle, initData.data);
calcRotationAngle = CheckFormula(initData.id, initData.formulaRotationAngle, initData.data);
calcLength = VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formulaLength,
initData.data));
calcLength =
VAbstractValApplication::VApp()->toPixel(CheckFormula(initData.id, initData.formulaLength, initData.data));
QPointF rotationOrigin;
QSharedPointer<VPointF> originPoint;
@ -230,9 +230,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
initData.data));
break;
case GOType::SplinePath:
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle,
calcLength, calcRotationAngle,
rotationOrigin, initData.suffix,
initData.destination.append(CreateCurveWithSegments<VSplinePath>(
initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix,
initData.data));
break;
case GOType::CubicBezier:
@ -241,11 +240,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
initData.suffix, initData.data));
break;
case GOType::CubicBezierPath:
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object,
calcAngle, calcLength,
calcRotationAngle,
rotationOrigin,
initData.suffix,
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(
initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin, initData.suffix,
initData.data));
break;
case GOType::Unknown:
@ -284,13 +280,13 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
initData.destination.at(i).id);
break;
case GOType::Spline:
UpdateCurve<VSpline>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
rotationOrigin, initData.suffix, initData.data, initData.destination.at(i).id);
UpdateCurve<VSpline>(initData.id, object, calcAngle, calcLength, calcRotationAngle, rotationOrigin,
initData.suffix, initData.data, initData.destination.at(i).id);
break;
case GOType::SplinePath:
UpdateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle, calcLength,
calcRotationAngle, rotationOrigin,initData.suffix,
initData.data, initData.destination.at(i).id);
UpdateCurveWithSegments<VSplinePath>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
rotationOrigin, initData.suffix, initData.data,
initData.destination.at(i).id);
break;
case GOType::CubicBezier:
UpdateCurve<VCubicBezier>(initData.id, object, calcAngle, calcLength, calcRotationAngle,
@ -299,9 +295,8 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
break;
case GOType::CubicBezierPath:
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, object, calcAngle, calcLength,
calcRotationAngle, rotationOrigin,
initData.suffix, initData.data,
initData.destination.at(i).id);
calcRotationAngle, rotationOrigin, initData.suffix,
initData.data, initData.destination.at(i).id);
break;
case GOType::Unknown:
case GOType::PlaceLabel:
@ -579,8 +574,8 @@ template <class Item>
auto VToolMove::CreateArc(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data) -> DestinationItem
{
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
data);
const DestinationItem item =
CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data);
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
return item;
}
@ -648,8 +643,8 @@ template <class Item>
auto VToolMove::CreateCurve(quint32 idTool, const SourceItem &sItem, qreal angle, qreal length, qreal rotationAngle,
const QPointF &rotationOrigin, const QString &suffix, VContainer *data) -> DestinationItem
{
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
data);
const DestinationItem item =
CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data);
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
return item;
}
@ -660,8 +655,8 @@ auto VToolMove::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem,
qreal rotationAngle, const QPointF &rotationOrigin, const QString &suffix,
VContainer *data) -> DestinationItem
{
const DestinationItem item = CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix,
data);
const DestinationItem item =
CreateItem<Item>(idTool, sItem, angle, length, rotationAngle, rotationOrigin, suffix, data);
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
return item;
}

View file

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

View file

@ -27,19 +27,19 @@
*************************************************************************/
#include "vabstractmainwindow.h"
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/def.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vsysexits.h"
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "dialogs/dialogexporttocsv.h"
#include <QStyle>
#include <QToolBar>
#include <QFileDialog>
#include <QAction>
#include <QFileDialog>
#include <QLockFile>
#include <QMessageBox>
#include <QStyle>
#include <QToolBar>
// #ifdef Q_OS_WIN
// extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
@ -137,7 +137,7 @@ auto RecentFiles(const QStringList &paths) -> QStringList
return recentFiles;
}
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
VAbstractMainWindow::VAbstractMainWindow(QWidget *parent)
@ -169,7 +169,8 @@ auto VAbstractMainWindow::ContinueFormatRewrite(const QString &currentFormatVers
msgBox.setText(tr("This file is using previous format version v%1. The current is v%2. "
"Saving the file with this app version will update the format version for this "
"file. This may prevent you from be able to open the file with older app versions. "
"Do you really want to continue?").arg(currentFormatVersion, maxFormatVersion));
"Do you really want to continue?")
.arg(currentFormatVersion, maxFormatVersion));
msgBox.setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
msgBox.setDefaultButton(QDialogButtonBox::No);
msgBox.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32));

View file

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

View file

@ -44,11 +44,15 @@ void PrepareTestCase(const QPointF &center, qreal startAngle, qreal endAngle)
const QVector<QPointF> points = arc.GetPoints();
const QString testStartAngle = QString("Test start angel. Arc radius %1, start angle %2, end angle %3")
.arg(radius).arg(startAngle).arg(endAngle);
.arg(radius)
.arg(startAngle)
.arg(endAngle);
QTest::newRow(qUtf8Printable(testStartAngle)) << center << startAngle << points << ConstFirst(points) << true;
const QString testEndAngle = QString("Test end angel. Arc radius %1, start angle %2, end angle %3")
.arg(radius).arg(startAngle).arg(endAngle);
.arg(radius)
.arg(startAngle)
.arg(endAngle);
QTest::newRow(qUtf8Printable(testEndAngle)) << center << endAngle << points << ConstLast(points) << true;
radius += UnitConvertor(5, Unit::Cm, Unit::Px);
@ -59,7 +63,8 @@ void PrepareTestCase(const QPointF &center, qreal startAngle, qreal endAngle)
//---------------------------------------------------------------------------------------------------------------------
TST_VArc::TST_VArc(QObject *parent)
: AbstractTest(parent)
{}
{
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
@ -209,7 +214,8 @@ void TST_VArc::TestGetPoints()
const qreal value = qAbs(rLine.length() - radius);
// cppcheck-suppress unreadVariable
const QString errorMsg = QString("Broken the first rule. All points should be on the same distance from "
"the center. Error ='%1'.").arg(value);
"the center. Error ='%1'.")
.arg(value);
QVERIFY2(value <= epsRadius, qUtf8Printable(errorMsg));
}
}
@ -364,14 +370,14 @@ void TST_VArc::TestCutArc_data()
QPointF cutPoint(539.3657292513009, 202.04366960088566);
// See file <root>/src/app/share/collection/bugs/Issue_#957.val
QTest::newRow("Arc -10 cm length, cut length 6 cm") << center << radius << startAngle << length << cutLength
<< cutPoint;
QTest::newRow("Arc -10 cm length, cut length 6 cm")
<< center << radius << startAngle << length << cutLength << cutPoint;
cutLength = ToPixel(-4, Unit::Cm);
// Opposite case
QTest::newRow("Arc -10 cm length, cut length -4 cm") << center << radius << startAngle << length << cutLength
<< cutPoint;
QTest::newRow("Arc -10 cm length, cut length -4 cm")
<< center << radius << startAngle << length << cutLength << cutPoint;
startAngle = 135;
length = ToPixel(10, Unit::Cm);
@ -379,13 +385,13 @@ void TST_VArc::TestCutArc_data()
cutPoint = QPointF(-145.1588983496871, 167.78888781060192);
// See file <root>/src/app/share/collection/bugs/Issue_#957.val
QTest::newRow("Arc 10 cm length, cut length -7 cm") << center << radius << startAngle << length << cutLength
<< cutPoint;
QTest::newRow("Arc 10 cm length, cut length -7 cm")
<< center << radius << startAngle << length << cutLength << cutPoint;
// Opposite case
cutLength = ToPixel(3, Unit::Cm);
QTest::newRow("Arc 10 cm length, cut length 3 cm") << center << radius << startAngle << length << cutLength
<< cutPoint;
QTest::newRow("Arc 10 cm length, cut length 3 cm")
<< center << radius << startAngle << length << cutLength << cutPoint;
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -34,8 +34,10 @@
#include <QtTest>
//---------------------------------------------------------------------------------------------------------------------
TST_VEllipticalArc::TST_VEllipticalArc(QObject *parent) : AbstractTest(parent)
{}
TST_VEllipticalArc::TST_VEllipticalArc(QObject *parent)
: AbstractTest(parent)
{
}
//---------------------------------------------------------------------------------------------------------------------
void TST_VEllipticalArc::CompareTwoWays_data()
@ -124,12 +126,10 @@ void TST_VEllipticalArc::NegativeArc()
const QString errorMsg =
QString("Difference between real and computing lengthes bigger than eps = %1. v1 = %2; v2 = %3");
QVERIFY2(qAbs(arc.GetLength() + length) <= eps,
qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length)));
QVERIFY2(qAbs(arc.GetLength() + length) <= eps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetLength()).arg(length)));
const qreal angleEps = 0.4;
QVERIFY2(arc.GetEndAngle() - f2 <= angleEps,
qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2)));
QVERIFY2(arc.GetEndAngle() - f2 <= angleEps, qUtf8Printable(errorMsg.arg(eps).arg(arc.GetEndAngle()).arg(f2)));
}
// cppcheck-suppress unusedFunction
@ -171,17 +171,17 @@ void TST_VEllipticalArc::TestData()
QTest::newRow("Full circle: radiuses 150, 200, rotation 30; start 0") << 150.0 << 200.0 << 0.0 << 360.0 << 30.0;
QTest::newRow("Full circle: radiuses 1500, 1000; start 0") << 1500.0 << 1000.0 << 0.0 << 360.0 << 0.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 0") << 1500.0 << 1000.0 << 0.0 << 360.0 << 50.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 0") << 15000.0 << 10000.0 << 0.0 << 360.0
<< 90.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 0")
<< 15000.0 << 10000.0 << 0.0 << 360.0 << 90.0;
QTest::newRow("Full circle: radiuses 10, 20; start 90") << 10.0 << 20.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, 200; start 90") << 150.0 << 200.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 150, 200, rotation 30; start 90") << 150.0 << 200.0 << 90.0 << 90.0 << 30.0;
QTest::newRow("Full circle: radiuses 1500, 1000; start 90") << 1500.0 << 1000.0 << 90.0 << 90.0 << 0.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90") << 1500.0 << 1000.0 << 90.0 << 90.0
<< 50.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 90") << 15000.0 << 10000.0 << 90.0 << 90.0
<< 90.0;
QTest::newRow("Full circle: radiuses 1500, 1000, rotation 50; start 90")
<< 1500.0 << 1000.0 << 90.0 << 90.0 << 50.0;
QTest::newRow("Full circle: radiuses 15000, 10000, rotation 90; start 90")
<< 15000.0 << 10000.0 << 90.0 << 90.0 << 90.0;
QTest::newRow("Arc less than 45 degree, radiuses 100, 50") << 100.0 << 50.0 << 0.0 << 10.5 << 0.0;
QTest::newRow("Arc less than 45 degree, radiuses 150, 50, rotation 180") << 150.0 << 50.0 << 0.0 << 10.5 << 180.0;
@ -295,7 +295,9 @@ void TST_VEllipticalArc::TestGetPoints1()
const qreal diff = qAbs(equationRes - 1);
// cppcheck-suppress unreadVariable
const QString errorMsg = QString("Broken the first rule. Any point must satisfy the equation of ellipse."
"diff = '%1' > eps = '%2'").number(diff).number(eps);
"diff = '%1' > eps = '%2'")
.number(diff)
.number(eps);
QVERIFY2(diff <= eps, qUtf8Printable(errorMsg));
}
}
@ -368,8 +370,12 @@ void TST_VEllipticalArc::TestGetPoints2()
const QString errorMsg = QString("Broken the first rule, part 2. Distance from the any point to the focus1"
" plus distance from this point to the focus2 should be the same. Problem"
" with point '%1'. The disired distance is '%2', but resulting distance"
" is '%3'. Difference is '%4' and it biggest than eps '%5')").number(i)
.number(distance).number(resultingDistance).number(diff).number(eps);
" is '%3'. Difference is '%4' and it biggest than eps '%5')")
.number(i)
.number(distance)
.number(resultingDistance)
.number(diff)
.number(eps);
QVERIFY2(diff <= eps, qUtf8Printable(errorMsg));
}
}
@ -398,7 +404,9 @@ void TST_VEllipticalArc::TestGetPoints3()
const qreal diffSquare = qAbs(ellipseSquare - arcSquare);
// cppcheck-suppress unreadVariable
const QString errorMsg1 = QString("Broken the second rule. Interpolation has too big computing error. "
"Difference ='%1' bigger than eps = '%2'.").arg(diffSquare).arg(epsSquare);
"Difference ='%1' bigger than eps = '%2'.")
.arg(diffSquare)
.arg(epsSquare);
QVERIFY2(diffSquare <= epsSquare, qUtf8Printable(errorMsg1));
}
}
@ -427,7 +435,9 @@ void TST_VEllipticalArc::TestGetPoints4()
const qreal diffLength = qAbs(arcLength - ellipseLength);
// cppcheck-suppress unreadVariable
const QString errorMsg2 = QString("Difference between real and computing lengthes "
"(diff = '%1') bigger than eps = '%2'.").arg(diffLength).arg(epsLength);
"(diff = '%1') bigger than eps = '%2'.")
.arg(diffLength)
.arg(epsLength);
QVERIFY2(diffLength <= epsLength, qUtf8Printable(errorMsg2));
}
}
@ -539,9 +549,8 @@ void TST_VEllipticalArc::TestRotation()
QString errorLengthMsg =
QString("Difference between real and computing lengthes bigger than eps = %1. l1 = %2; l2 = %3");
QVERIFY2(qAbs(arcOrigin.GetLength() - rotatedArc.GetLength()) <= ToPixel(1, Unit::Mm),
qUtf8Printable(errorLengthMsg.arg(ToPixel(1, Unit::Mm))
.arg(arcOrigin.GetLength())
.arg(rotatedArc.GetLength())));
qUtf8Printable(
errorLengthMsg.arg(ToPixel(1, Unit::Mm)).arg(arcOrigin.GetLength()).arg(rotatedArc.GetLength())));
QCOMPARE(arcOrigin.GetRadius1(), rotatedArc.GetRadius1());
QCOMPARE(arcOrigin.GetRadius2(), rotatedArc.GetRadius2());