2013-11-15 13:41:26 +01:00
|
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
|
** @file vsplinepath.h
|
2013-11-15 13:41:26 +01:00
|
|
|
|
** @author Roman Telezhinsky <dismine@gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
|
** @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.
|
2013-09-18 21:16:19 +02:00
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
|
** 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.
|
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
|
** 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-11-15 13:41:26 +01:00
|
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
|
2013-08-09 08:49:34 +02:00
|
|
|
|
#ifndef VSPLINEPATH_H
|
|
|
|
|
#define VSPLINEPATH_H
|
|
|
|
|
|
|
|
|
|
#include "vsplinepoint.h"
|
2013-11-06 16:49:07 +01:00
|
|
|
|
#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
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
namespace SplinePoint
|
|
|
|
|
{
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief The Position enum
|
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
|
enum Position { FirstPoint, LastPoint };
|
|
|
|
|
Q_DECLARE_FLAGS(Positions, Position)
|
2013-08-09 08:49:34 +02:00
|
|
|
|
}
|
2013-09-30 18:29:03 +02:00
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS( SplinePoint::Positions )
|
2013-08-09 08:49:34 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief The VSplinePath клас, що розраховує шлях сплайнів.
|
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
|
class VSplinePath
|
|
|
|
|
{
|
2013-09-30 18:29:03 +02:00
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(VSplinePath)
|
2013-08-09 08:49:34 +02:00
|
|
|
|
public:
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief VSplinePath конструктор по замовчуванню.
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
VSplinePath();
|
2013-11-19 21:56:49 +01: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);
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief VSplinePath
|
|
|
|
|
* @param splPath
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
VSplinePath(const VSplinePath& splPath);
|
2013-08-09 08:49:34 +02:00
|
|
|
|
/**
|
|
|
|
|
* @brief append додає точку сплайну до шляху.
|
|
|
|
|
* @param point точка.
|
|
|
|
|
*/
|
2013-11-07 15:40:39 +01:00
|
|
|
|
void append(const VSplinePoint &point);
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief Count
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
qint32 Count() const;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief CountPoint
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline qint32 CountPoint() const {return path.size();}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief GetSpline
|
|
|
|
|
* @param index
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
VSpline GetSpline(qint32 index) const;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief GetPath
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
QPainterPath GetPath() const;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief GetPathPoints
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
QVector<QPointF> GetPathPoints() const;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief GetSplinePath
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline QVector<VSplinePoint> GetSplinePath() const {return path;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief GetLength
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
qreal GetLength() const;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief GetDataPoints
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline QHash<qint64, VPointF> GetDataPoints() const {return points;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief UpdatePoint
|
|
|
|
|
* @param indexSpline
|
|
|
|
|
* @param pos
|
|
|
|
|
* @param point
|
|
|
|
|
*/
|
2013-11-07 15:40:39 +01:00
|
|
|
|
void UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const VSplinePoint &point);
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief GetSplinePoint
|
|
|
|
|
* @param indexSpline
|
|
|
|
|
* @param pos
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
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();}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief getKCurve
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline qreal getKCurve() const {return kCurve;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief setKCurve
|
|
|
|
|
* @param value
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline void setKCurve(const qreal &value) {kCurve = value;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief GetPoint
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline const QVector<VSplinePoint> *GetPoint() const {return &path;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief operator =
|
|
|
|
|
* @param path
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
VSplinePath &operator=(const VSplinePath &path);
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief operator []
|
|
|
|
|
* @param indx
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-11-06 20:27:43 +01:00
|
|
|
|
VSplinePoint &operator[](ptrdiff_t indx);
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief getMode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline Draw::Draws getMode() const {return mode;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief setMode
|
|
|
|
|
* @param value
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline void setMode(const Draw::Draws &value) {mode = value;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief getIdObject
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline qint64 getIdObject() const {return idObject;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief setIdObject
|
|
|
|
|
* @param value
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
inline void setIdObject(const qint64 &value) {idObject = value;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief name
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2013-11-12 13:48:45 +01:00
|
|
|
|
QString name() const {return _name;}
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief setName
|
|
|
|
|
* @param name
|
|
|
|
|
*/
|
2013-11-12 13:48:45 +01:00
|
|
|
|
void setName(const QString &name) {_name = name;}
|
2013-08-09 08:49:34 +02:00
|
|
|
|
protected:
|
|
|
|
|
/**
|
|
|
|
|
* @brief path вектор з точок сплайна.
|
|
|
|
|
*/
|
|
|
|
|
QVector<VSplinePoint> path;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief kCurve
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
qreal kCurve;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief mode
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
Draw::Draws mode;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief points
|
|
|
|
|
*/
|
2013-10-10 20:45:58 +02:00
|
|
|
|
QHash<qint64, VPointF> points;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief idObject
|
|
|
|
|
*/
|
2013-10-26 22:42:54 +02:00
|
|
|
|
qint64 idObject;
|
2013-11-19 21:56:49 +01:00
|
|
|
|
/**
|
|
|
|
|
* @brief _name
|
|
|
|
|
*/
|
2013-11-12 13:48:45 +01:00
|
|
|
|
QString _name;
|
2013-08-09 08:49:34 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // VSPLINEPATH_H
|