Merge with release.

This commit is contained in:
Roman Telezhynskyi 2015-05-15 20:24:41 +03:00
commit 03a7c5667e
17 changed files with 86 additions and 37 deletions

View File

@ -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.

View File

@ -1,4 +1,4 @@
valentina (0.3.1) trusty; urgency=low
valentina (0.3.2) trusty; urgency=low
* Auto build.

2
dist/rpm/_service vendored
View File

@ -1,7 +1,7 @@
<services>
<service name="tar_scm">
<param name="url">https://github.com/dismine/Valentina.git</param>
<param name="versionprefix">0.3.1</param>
<param name="versionprefix">0.3.2</param>
<param name="filename">valentina</param>
<param name="scm">git</param>
<param name="versionformat">%at</param>

View File

@ -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+

View File

@ -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);

View File

@ -76,7 +76,7 @@ QVector<QPointF> VAbstractCurve::FromBegin(const QVector<QPointF> &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);

View File

@ -352,30 +352,67 @@ void VGObject::LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c
}
//---------------------------------------------------------------------------------------------------------------------
bool VGObject::PointInSegment(const QPointF &t, const QPointF &p1, const QPointF &p2)
/**
* @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;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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<QPointF> GetReversePoints(const QVector<QPointF> &points);
static int GetLengthContour(const QVector<QPointF> &contour, const QVector<QPointF> &newPoints);
private:
QSharedDataPointer<VGObjectData> 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

View File

@ -31,7 +31,7 @@
#include <QStringList>
//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.

View File

@ -107,8 +107,8 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF &cente
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*/)
{

View File

@ -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));

View File

@ -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

View File

@ -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;
}

View File

@ -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());
}

View File

@ -274,7 +274,7 @@
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^0-9-*/^+=\s\(\)%:;!.,`'\&quot;]){1,1}([^-*/^+=\s\(\)%:;!.,`'\&quot;]){0,}$"/>
<xs:pattern value="^([^0-9*/^+\-=\s()?%:;!.,`'\&quot;]){1,1}([^*/^+\-=\s()?%:;!.,`'\&quot;]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">

View File

@ -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<QPointF> &contour, const VLayoutDetail &detai
++j;
}while (processedEdges < nD);
}
//---------------------------------------------------------------------------------------------------------------------
QLineF VContour::EmptySheetEdge() const
{
return QLineF(0, 0, d->paperWidth - 5, 0);
}

View File

@ -62,6 +62,7 @@ public:
QVector<QPointF> UniteWithContour(const VLayoutDetail &detail, int globalI, int detJ, BestFrom type) const;
QLineF EmptySheetEdge() const;
int EdgesCount() const;
QLineF GlobalEdge(int i) const;
QVector<QPointF> CutEdge(const QLineF &edge) const;