2016-11-03 19:15:53 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 3 11, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2016 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VABSTRACTPIECE_H
|
|
|
|
#define VABSTRACTPIECE_H
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
2016-11-09 14:53:22 +01:00
|
|
|
#include <QSharedDataPointer>
|
2016-11-11 11:54:17 +01:00
|
|
|
#include <QPointF>
|
|
|
|
|
|
|
|
#include "../vmisc/diagnostic.h"
|
2016-11-03 19:15:53 +01:00
|
|
|
|
|
|
|
template <class T> class QVector;
|
2016-11-11 11:54:17 +01:00
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
class VAbstractPieceData;
|
2016-11-10 13:06:09 +01:00
|
|
|
class QLineF;
|
2016-11-03 19:15:53 +01:00
|
|
|
|
2016-11-11 11:54:17 +01:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The VSAPoint class seam allowance point
|
|
|
|
*/
|
|
|
|
class VSAPoint : public QPointF
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Q_DECL_CONSTEXPR VSAPoint();
|
|
|
|
Q_DECL_CONSTEXPR VSAPoint(const QPointF &p);
|
|
|
|
|
|
|
|
Q_DECL_CONSTEXPR qreal GetSABefore() const;
|
|
|
|
void SetSABefore(qreal value);
|
|
|
|
|
|
|
|
Q_DECL_CONSTEXPR qreal GetSAAfter() const;
|
|
|
|
void SetSAAfter(qreal value);
|
|
|
|
|
|
|
|
private:
|
|
|
|
qreal m_before;
|
|
|
|
qreal m_after;
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE);
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint()
|
|
|
|
: QPointF(),
|
|
|
|
m_before(-1),
|
|
|
|
m_after(-1)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(const QPointF &p)
|
|
|
|
: QPointF(p),
|
|
|
|
m_before(-1),
|
|
|
|
m_after(-1)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline qreal VSAPoint::GetSABefore() const
|
|
|
|
{
|
|
|
|
return m_before;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline void VSAPoint::SetSABefore(qreal value)
|
|
|
|
{
|
|
|
|
value < 0 ? m_before = -1 : m_before = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline qreal VSAPoint::GetSAAfter() const
|
|
|
|
{
|
|
|
|
return m_after;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline void VSAPoint::SetSAAfter(qreal value)
|
|
|
|
{
|
|
|
|
value < 0 ? m_after = -1 : m_after = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
QT_WARNING_POP
|
|
|
|
|
2016-11-03 19:15:53 +01:00
|
|
|
class VAbstractPiece
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VAbstractPiece();
|
|
|
|
VAbstractPiece(const VAbstractPiece &piece);
|
|
|
|
VAbstractPiece &operator=(const VAbstractPiece &piece);
|
|
|
|
virtual ~VAbstractPiece();
|
|
|
|
|
2016-11-09 14:53:22 +01:00
|
|
|
QString GetName() const;
|
|
|
|
void SetName(const QString &value);
|
|
|
|
|
2016-11-10 10:56:40 +01:00
|
|
|
bool IsForbidFlipping() const;
|
|
|
|
void SetForbidFlipping(bool value);
|
|
|
|
|
2016-11-10 11:53:02 +01:00
|
|
|
bool IsSeamAllowance() const;
|
|
|
|
void SetSeamAllowance(bool value);
|
|
|
|
|
|
|
|
qreal GetSAWidth() const;
|
|
|
|
void SetSAWidth(qreal value);
|
|
|
|
|
2016-11-10 13:06:09 +01:00
|
|
|
static QVector<QPointF> Equidistant(const QVector<QPointF> &points, qreal width);
|
2016-11-03 19:15:53 +01:00
|
|
|
static qreal SumTrapezoids(const QVector<QPointF> &points);
|
|
|
|
static QVector<QPointF> CheckLoops(const QVector<QPointF> &points);
|
|
|
|
static QVector<QPointF> CorrectEquidistantPoints(const QVector<QPointF> &points, bool removeFirstAndLast = true);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static QVector<QPointF> RemoveDublicates(const QVector<QPointF> &points, bool removeFirstAndLast = true);
|
2016-11-09 14:53:22 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
QSharedDataPointer<VAbstractPieceData> d;
|
2016-11-10 13:06:09 +01:00
|
|
|
|
2016-11-11 15:26:00 +01:00
|
|
|
static QVector<QPointF> EkvPoint(const QPointF &p1Line1, const QPointF &p2Line1,
|
|
|
|
const QPointF &p1Line2, const QPointF &p2Line2, qreal width);
|
|
|
|
static QLineF ParallelLine(const QPointF &p1, const QPointF &p2, qreal width);
|
|
|
|
static QPointF SingleParallelPoint(const QPointF &p1, const QPointF &p2, qreal angle, qreal width);
|
2016-11-10 13:06:09 +01:00
|
|
|
static int BisectorAngle(const QPointF &p1, const QPointF &p2, const QPointF &p3);
|
2016-11-03 19:15:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VABSTRACTPIECE_H
|