From 16232eba926f6865eae74a52ca04340407c7c17c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 7 May 2015 20:00:00 +0300 Subject: [PATCH 1/6] Preparation to new release. --HG-- branch : release --- dist/debian/changelog | 2 +- dist/rpm/_service | 2 +- dist/rpm/valentina.spec | 2 +- src/app/version.cpp | 2 +- src/app/version.h | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/debian/changelog b/dist/debian/changelog index e3dbed73c..56561753a 100644 --- a/dist/debian/changelog +++ b/dist/debian/changelog @@ -1,4 +1,4 @@ -valentina (0.3.1) trusty; urgency=low +valentina (0.3.2) trusty; urgency=low * Auto build. diff --git a/dist/rpm/_service b/dist/rpm/_service index 43ceb7a81..3bdb8cc88 100644 --- a/dist/rpm/_service +++ b/dist/rpm/_service @@ -1,7 +1,7 @@ https://github.com/dismine/Valentina.git - 0.3.1 + 0.3.2 valentina git %at diff --git a/dist/rpm/valentina.spec b/dist/rpm/valentina.spec index 2c87451de..f59c242eb 100644 --- a/dist/rpm/valentina.spec +++ b/dist/rpm/valentina.spec @@ -33,7 +33,7 @@ BuildRequires: update-desktop-files Requires: poppler-utils -Version: 0.3.1 +Version: 0.3.2 Release: 0 URL: https://bitbucket.org/dismine/valentina License: GPL-3.0+ diff --git a/src/app/version.cpp b/src/app/version.cpp index 3c583a7fd..b51b7ef5a 100644 --- a/src/app/version.cpp +++ b/src/app/version.cpp @@ -33,7 +33,7 @@ extern const int MAJOR_VERSION = 0; extern const int MINOR_VERSION = 3; -extern const int DEBUG_VERSION = 1; +extern const int DEBUG_VERSION = 2; extern const QString APP_VERSION(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION) .arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE)); diff --git a/src/app/version.h b/src/app/version.h index cd548108f..3ad509bad 100644 --- a/src/app/version.h +++ b/src/app/version.h @@ -39,8 +39,8 @@ extern const QString APP_VERSION; // Change version number in version.cpp too. -#define VER_FILEVERSION 0,3,1,0 -#define VER_FILEVERSION_STR "0.3.1.0\0" +#define VER_FILEVERSION 0,3,2,0 +#define VER_FILEVERSION_STR "0.3.2.0\0" #define VER_PRODUCTVERSION VER_FILEVERSION #define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR From 24ee7c1960b98a14654ee50612dc769dd2087a80 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 7 May 2015 11:49:56 +0300 Subject: [PATCH 2/6] Refactoring. Better name. --HG-- branch : release --- src/app/geometry/vabstractcurve.cpp | 2 +- src/app/geometry/vgobject.cpp | 2 +- src/app/tools/drawTools/vtoolpointofcontact.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/geometry/vabstractcurve.cpp b/src/app/geometry/vabstractcurve.cpp index 1fe4e149a..9d1df7b04 100644 --- a/src/app/geometry/vabstractcurve.cpp +++ b/src/app/geometry/vabstractcurve.cpp @@ -76,7 +76,7 @@ QVector VAbstractCurve::FromBegin(const QVector &points, const { if (theBegin == false) { - if (PointInSegment(begin, points.at(i), points.at(i+1))) + if (IsPointOnLineSegment(begin, points.at(i), points.at(i+1))) { theBegin = true; segment.append(begin); diff --git a/src/app/geometry/vgobject.cpp b/src/app/geometry/vgobject.cpp index 467d1be37..61ab1d3ed 100644 --- a/src/app/geometry/vgobject.cpp +++ b/src/app/geometry/vgobject.cpp @@ -352,7 +352,7 @@ void VGObject::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c } //--------------------------------------------------------------------------------------------------------------------- -bool VGObject::PointInSegment(const QPointF &t, const QPointF &p1, const QPointF &p2) +bool VGObject::IsPointOnLineSegment(const QPointF &t, const QPointF &p1, const QPointF &p2) { const qreal eps = 1e-8; diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index 598370a08..a9ab674b7 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -107,8 +107,8 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e break; case 2: { - const bool flagP1 = VGObject::PointInSegment (p1, firstPoint, secondPoint); - const bool flagP2 = VGObject::PointInSegment (p2, firstPoint, secondPoint); + const bool flagP1 = VGObject::IsPointOnLineSegment (p1, firstPoint, secondPoint); + const bool flagP2 = VGObject::IsPointOnLineSegment (p2, firstPoint, secondPoint); if ((flagP1 == true && flagP2 == true) || (flagP1 == false && flagP2 == false)/*In case we have something wrong*/) { From f1d7caaba5a1d29f4e69e82ac32e6aa642dbfc46 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 7 May 2015 12:39:08 +0300 Subject: [PATCH 3/6] Fixed issue #298. Segmented Curve isn't selected in Seam Allowance tool. --HG-- branch : release --- src/app/geometry/vgobject.cpp | 63 +++++++++++++++++++++++++++-------- src/app/geometry/vgobject.h | 7 ++-- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/src/app/geometry/vgobject.cpp b/src/app/geometry/vgobject.cpp index 61ab1d3ed..eb027ac4a 100644 --- a/src/app/geometry/vgobject.cpp +++ b/src/app/geometry/vgobject.cpp @@ -352,30 +352,67 @@ void VGObject::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief IsPointOnLineSegment Check if the point is on the line segment. + * + * Original idea http://www.sunshine2k.de/coding/java/PointOnLine/PointOnLine.html + */ bool VGObject::IsPointOnLineSegment(const QPointF &t, const QPointF &p1, const QPointF &p2) { - const qreal eps = 1e-8; - - qreal a = p2.y() - p1.y(); - qreal b = p1.x() - p2.x(); - qreal c = - a * p1.x() - b * p1.y(); - if (qAbs(a * t.x() + b * t.y() + c) > eps) + // The test point must lie inside the bounding box spanned by the two line points. + if (not ( (p1.x() <= t.x() && t.x() <= p2.x()) || (p2.x() <= t.x() && t.x() <= p1.x()) )) { + // test point not in x-range return false; } - return PointInBox (t, p1, p2); + if (not ( (p1.y() <= t.y() && t.y() <= p2.y()) || (p2.y() <= t.y() && t.y() <= p1.y()) )) + { + // test point not in y-range + return false; + } + + // Test via the perp dot product (PDP) + return IsPointOnLineviaPDP(t, p1, p2); } //--------------------------------------------------------------------------------------------------------------------- -bool VGObject::PointInBox(const QPointF &t, const QPointF &p1, const QPointF &p2) +/** + * @brief IsPointOnLineviaPDP use the perp dot product (PDP) way. + * + * The pdp is zero only if the t lies on the line e1 = vector from p1 to p2. + */ +bool VGObject::IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2) { - const qreal eps = 1e-8; + return ( qAbs(PerpDotProduct(p1, p2, t) < GetEpsilon(p1, p2)) ); +} - return (qAbs (t.x() - qMin(p1.x(), p2.x())) <= eps || qMin(p1.x(), p2.x()) <= t.x()) && - (qAbs (qMax(p1.x(), p2.x()) - t.x()) <= eps || qMax(p1.x(), p2.x()) >= t.x()) && - (qAbs (t.y() - qMin(p1.y(), p2.y())) <= eps || qMin(p1.y(), p2.y()) <= t.y()) && - (qAbs (qMax(p1.y(), p2.y()) - t.y()) <= eps || qMax(p1.y(), p2.y()) >= t.y()); +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PerpDotProduct Calculates the area of the parallelogram of the three points. + * This is actually the same as the area of the triangle defined by the three points, multiplied by 2. + * @return 2 * triangleArea(a,b,c) + */ +double VGObject::PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2) +{ + return (p1.x() - t.x()) * (p2.y() - t.y()) - (p1.y() - t.y()) * (p2.x() - t.x()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetEpsilon solve the floating-point accuraccy problem. + * + * There is the floating-point accuraccy problem, so instead of checking against zero, some epsilon value has to be + * used. Because the size of the pdp value depends on the length of the vectors, no static value can be used. One + * approach is to compare the pdp/area value to the fraction of another area which also depends on the length of the + * line e1=(p1, p2), e.g. the area of the square with side e1 which is computed below + */ +double VGObject::GetEpsilon(const QPointF &p1, const QPointF &p2) +{ + const int dx1 = p2.toPoint().x() - p1.toPoint().x(); + const int dy1 = p2.toPoint().y() - p1.toPoint().y(); + const double epsilon = 0.003 * (dx1 * dx1 + dy1 * dy1); + return epsilon; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/geometry/vgobject.h b/src/app/geometry/vgobject.h index eff533f3d..ba302d687 100644 --- a/src/app/geometry/vgobject.h +++ b/src/app/geometry/vgobject.h @@ -78,13 +78,16 @@ public: static QPointF ClosestPoint(const QLineF &line, const QPointF &point); static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k); static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c); - static bool PointInSegment (const QPointF &t, const QPointF &p1, const QPointF &p2); - static bool PointInBox (const QPointF &t, const QPointF &p1, const QPointF &p2); + static bool IsPointOnLineSegment (const QPointF &t, const QPointF &p1, const QPointF &p2); static QVector GetReversePoints(const QVector &points); static int GetLengthContour(const QVector &contour, const QVector &newPoints); private: QSharedDataPointer d; + + static bool IsPointOnLineviaPDP(const QPointF &t, const QPointF &p1, const QPointF &p2); + static double PerpDotProduct(const QPointF &t, const QPointF &p1, const QPointF &p2); + static double GetEpsilon(const QPointF &p1, const QPointF &p2); }; #endif // VGOBJECT_H From 1c1077a0e6a8c966c1c8a0c3fcfe170b9b2dc009 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 11 May 2015 16:12:39 +0300 Subject: [PATCH 4/6] Fixed issue #299. Error when opening .val file. --HG-- branch : release --- src/app/dialogs/tools/dialogtool.cpp | 6 ++---- src/app/options.cpp | 2 +- src/app/widgets/textdelegate.cpp | 2 +- src/app/widgets/vtooloptionspropertybrowser.cpp | 4 ++-- src/libs/ifc/schema/pattern/v0.1.3.xsd | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 99fc95b5a..4f4147094 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -712,11 +712,9 @@ void DialogTool::NamePointChanged() if (edit) { QString name = edit->text(); - name.replace(" ", ""); - QRegExpValidator v(QRegExp(nameRegExp), this); - int pos = 0; + QRegularExpression rx(nameRegExp); if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false) || - v.validate(name, pos) == QValidator::Invalid) + rx.match(name).hasMatch() == false) { flagName = false; ChangeColor(labelEditNamePoint, Qt::red); diff --git a/src/app/options.cpp b/src/app/options.cpp index d4703df93..16f666a5b 100644 --- a/src/app/options.cpp +++ b/src/app/options.cpp @@ -31,7 +31,7 @@ #include //Same regexp in pattern.xsd shema file. Don't forget synchronize. -const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,`'\"]){1,1}([^-*/^+=\\s\\(\\)%:;!.,`'\"]){0,}$"); +const QString nameRegExp = QStringLiteral("^([^0-9*/^+\\-=\\s()?%:;!.,`'\"]){1,1}([^*/^+\\-=\\s()?%:;!.,`'\"]){0,}$"); // From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This // furthermore blows up the binary sizes. diff --git a/src/app/widgets/textdelegate.cpp b/src/app/widgets/textdelegate.cpp index 860175bb6..e9589e0d9 100644 --- a/src/app/widgets/textdelegate.cpp +++ b/src/app/widgets/textdelegate.cpp @@ -60,7 +60,7 @@ QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem QLineEdit *editor = new QLineEdit(parent); editor->setLocale(parent->locale()); //Same regex pattern in xsd file - editor->setValidator( new QRegExpValidator(QRegExp(regex)) ); + editor->setValidator( new QRegularExpressionValidator(QRegularExpression(regex)) ); connect(editor, &QLineEdit::editingFinished, this, &TextDelegate::commitAndCloseEditor); return editor; } diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index 77e069795..89817d1bc 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -431,8 +431,8 @@ void VToolOptionsPropertyBrowser::SetPointName(const QString &name) return; } - QRegExp rx(nameRegExp); - if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.exactMatch(name) == false) + QRegularExpression rx(nameRegExp); + if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.match(name).hasMatch() == false) { idToProperty[VAbstractTool::AttrName]->setValue(i->name()); } diff --git a/src/libs/ifc/schema/pattern/v0.1.3.xsd b/src/libs/ifc/schema/pattern/v0.1.3.xsd index 093973f62..94319dc32 100644 --- a/src/libs/ifc/schema/pattern/v0.1.3.xsd +++ b/src/libs/ifc/schema/pattern/v0.1.3.xsd @@ -274,7 +274,7 @@ - + From 1b4e61925de30f81f79a65064e0c9c70753dc37e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 15 May 2015 18:15:14 +0300 Subject: [PATCH 5/6] Fixed issue #302. Error when creating layout. --HG-- branch : release --- src/libs/vlayout/vcontour.cpp | 11 ++++++++--- src/libs/vlayout/vcontour.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libs/vlayout/vcontour.cpp b/src/libs/vlayout/vcontour.cpp index 8f08a3c73..9de9add9c 100644 --- a/src/libs/vlayout/vcontour.cpp +++ b/src/libs/vlayout/vcontour.cpp @@ -203,8 +203,7 @@ int VContour::EdgesCount() const return 1; } - const QLineF axis = QLineF(0, 0, d->paperWidth, 0); - const int n = qFloor(axis.length()/d->shift); + const int n = qFloor(EmptySheetEdge().length()/d->shift); if (n <= 0) { return 1; @@ -226,7 +225,7 @@ QLineF VContour::GlobalEdge(int i) const if (d->globalContour.isEmpty()) { // Because sheet is blank we have one global edge for all cases - Ox axis. - const QLineF axis = QLineF(0, 0, d->paperWidth - 5, 0); + const QLineF axis = EmptySheetEdge(); if (d->shift == 0) { return axis; @@ -318,3 +317,9 @@ void VContour::AppendWhole(QVector &contour, const VLayoutDetail &detai ++j; }while (processedEdges < nD); } + +//--------------------------------------------------------------------------------------------------------------------- +QLineF VContour::EmptySheetEdge() const +{ + return QLineF(0, 0, d->paperWidth - 5, 0); +} diff --git a/src/libs/vlayout/vcontour.h b/src/libs/vlayout/vcontour.h index bef34f6d0..ed1d710fa 100644 --- a/src/libs/vlayout/vcontour.h +++ b/src/libs/vlayout/vcontour.h @@ -62,6 +62,7 @@ public: QVector UniteWithContour(const VLayoutDetail &detail, int globalI, int detJ, BestFrom type) const; + QLineF EmptySheetEdge() const; int EdgesCount() const; QLineF GlobalEdge(int i) const; QVector CutEdge(const QLineF &edge) const; From e73a61ce2330e14483169a6301893aeb8037d651 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 15 May 2015 20:23:11 +0300 Subject: [PATCH 6/6] Changes in version 0.3.2. --HG-- branch : release --- ChangeLog.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index f1db245af..3a79ed6d4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,8 @@ +# Version 0.3.2 Released May 15, 2015 +- [#298] Segmented Curve isn't selected in Seam Allowance tool. +- [#299] Error when opening .val file. +- [#302] Error when creating layout. + # Version 0.3.1 Released April 24, 2015 - [#263] Regression. Union tool doesn't work. - For tool Curve intersect axis fixed wrong calculation point in case with too small scene rect size.