valentina/geometry/vsplinepath.h

105 lines
4 KiB
C
Raw Normal View History

/************************************************************************
**
** @file vsplinepath.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date Friday November 15, 2013
**
** @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) 2013 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/>.
**
*************************************************************************/
2013-08-09 08:49:34 +02:00
#ifndef VSPLINEPATH_H
#define VSPLINEPATH_H
#include "vsplinepoint.h"
#include "../container/vpointf.h"
2013-08-09 08:49:34 +02:00
#include "vspline.h"
2013-10-26 22:42:54 +02:00
#include <QApplication>
2013-08-09 08:49:34 +02:00
namespace SplinePoint
{
enum Position { FirstPoint, LastPoint };
Q_DECLARE_FLAGS(Positions, Position)
2013-08-09 08:49:34 +02:00
}
Q_DECLARE_OPERATORS_FOR_FLAGS( SplinePoint::Positions )
2013-08-09 08:49:34 +02:00
/**
* @brief The VSplinePath клас, що розраховує шлях сплайнів.
*/
class VSplinePath
{
Q_DECLARE_TR_FUNCTIONS(VSplinePath)
2013-08-09 08:49:34 +02:00
public:
/**
* @brief VSplinePath конструктор по замовчуванню.
*/
2013-10-26 22:42:54 +02:00
VSplinePath();
2013-08-09 08:49:34 +02:00
/**
* @brief VSplinePath конструктор по замовчуванню.
*/
2013-10-26 22:42:54 +02:00
VSplinePath(const QHash<qint64, VPointF> *points, qreal kCurve = 1,
Draw::Draws mode = Draw::Calculation, qint64 idObject = 0);
VSplinePath(const VSplinePath& splPath);
2013-08-09 08:49:34 +02:00
/**
* @brief append додає точку сплайну до шляху.
* @param point точка.
*/
void append(const VSplinePoint &point);
2013-10-26 22:42:54 +02:00
qint32 Count() const;
inline qint32 CountPoint() const {return path.size();}
VSpline GetSpline(qint32 index) const;
QPainterPath GetPath() const;
QVector<QPointF> GetPathPoints() const;
inline QVector<VSplinePoint> GetSplinePath() const {return path;}
qreal GetLength() const;
inline QHash<qint64, VPointF> GetDataPoints() const {return points;}
void UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const VSplinePoint &point);
2013-10-26 22:42:54 +02:00
VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const;
2013-08-09 08:49:34 +02:00
/**
* @brief Clear очищає шлях сплайнів.
*/
2013-10-26 22:42:54 +02:00
inline void Clear() {path.clear();}
inline qreal getKCurve() const {return kCurve;}
inline void setKCurve(const qreal &value) {kCurve = value;}
inline const QVector<VSplinePoint> *GetPoint() const {return &path;}
VSplinePath &operator=(const VSplinePath &path);
VSplinePoint &operator[](ptrdiff_t indx);
2013-10-26 22:42:54 +02:00
inline Draw::Draws getMode() const {return mode;}
inline void setMode(const Draw::Draws &value) {mode = value;}
2013-08-28 10:55:11 +02:00
2013-10-26 22:42:54 +02:00
inline qint64 getIdObject() const {return idObject;}
inline void setIdObject(const qint64 &value) {idObject = value;}
QString name() const {return _name;}
void setName(const QString &name) {_name = name;}
2013-08-09 08:49:34 +02:00
protected:
/**
* @brief path вектор з точок сплайна.
*/
QVector<VSplinePoint> path;
2013-10-26 22:42:54 +02:00
qreal kCurve;
Draw::Draws mode;
QHash<qint64, VPointF> points;
2013-10-26 22:42:54 +02:00
qint64 idObject;
QString _name;
2013-08-09 08:49:34 +02:00
};
#endif // VSPLINEPATH_H