valentina/src/geometry/varc.h

226 lines
6.9 KiB
C
Raw Normal View History

/************************************************************************
**
** @file varc.h
** @author Roman Telezhinsky <dismine@gmail.com>
** @date 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-05 10:37:56 +02:00
#ifndef VARC_H
#define VARC_H
2013-08-28 10:55:11 +02:00
#include "vspline.h"
#include <QCoreApplication>
#include "../options.h"
class QString;
class QLineF;
class QPainterPath;
class QPointF;
2013-08-05 10:37:56 +02:00
/**
* @brief VArc клас, що реалізує дугу. Дуга розраховується за годиниковою стрілкою.
*/
class VArc
{
Q_DECLARE_TR_FUNCTIONS(VArc)
2013-08-05 10:37:56 +02:00
public:
/**
* @brief VArc конструктор по замовчуванню.
*/
2013-10-27 11:22:44 +01:00
VArc ();
/**
* @brief VArc конструктор.
* @param center точка центру.
* @param radius радіус.
* @param f1 початковий кут в градусах.
* @param f2 кінцевий кут в градусах.
*/
2013-10-27 11:22:44 +01:00
VArc (const QHash<qint64, VPointF> *points, qint64 center, qreal radius, QString formulaRadius,
qreal f1, QString formulaF1, qreal f2, QString formulaF2, qint64 idObject = 0);
/**
* @brief VArc
* @param arc
*/
2013-10-27 11:22:44 +01:00
VArc(const VArc &arc);
/**
* @brief operator =
* @param arc
* @return
*/
2013-10-27 11:22:44 +01:00
VArc& operator= (const VArc &arc);
2013-08-05 10:37:56 +02:00
/**
* @brief GetF1 повертає початковий кут дуги.
* @return повертає кут в градусах.
*/
2013-10-26 22:42:54 +02:00
inline QString GetFormulaF1 () const {return formulaF1;}
/**
* @brief GetF1
* @return
*/
2013-10-26 22:42:54 +02:00
inline qreal GetF1 () const {return f1;}
2013-08-05 10:37:56 +02:00
/**
* @brief GetF2 повертає кінцевий кут дуги.
* @return повертає кут в градусах.
*/
2013-10-26 22:42:54 +02:00
inline QString GetFormulaF2 () const {return formulaF2;}
/**
* @brief GetF2
* @return
*/
2013-10-26 22:42:54 +02:00
inline qreal GetF2 () const {return f2;}
2013-08-05 10:37:56 +02:00
/**
* @brief GetLength повертає довжину дуги.
* @return повертає довжину дуги.
*/
2013-10-26 22:42:54 +02:00
inline qreal GetLength () const {return M_PI * radius/180 * (f2-f1);}
2013-08-05 10:37:56 +02:00
/**
* @brief GetRadius повертає радіус дуги.
* @return повертає радіус дуги.
*/
2013-10-26 22:42:54 +02:00
inline QString GetFormulaRadius () const {return formulaRadius;}
/**
* @brief GetRadius
* @return
*/
2013-10-26 22:42:54 +02:00
inline qreal GetRadius () const {return radius;}
2013-08-05 10:37:56 +02:00
/**
* @brief GetCenter повертає точку центра дуги.
* @return повертає точку центра дуги.
*/
2013-10-26 22:42:54 +02:00
inline qint64 GetCenter () const {return center;}
/**
* @brief GetCenterPoint
* @return
*/
2013-10-26 22:42:54 +02:00
QPointF GetCenterPoint() const;
/**
* @brief GetCenterVPoint
* @return
*/
VPointF GetCenterVPoint() const;
2013-08-05 10:37:56 +02:00
/**
* @brief GetP1 повертає першу точку з якої починається дуга.
* @return точку початку дуги.
*/
2013-10-26 22:42:54 +02:00
QPointF GetP1 () const;
2013-08-05 10:37:56 +02:00
/**
* @brief GetP2 повертає другу точку в якій закінчується дуга.
* @return точку кінця дуги.
*/
2013-10-26 22:42:54 +02:00
QPointF GetP2 () const;
/**
* @brief GetDataPoints
* @return
*/
const QHash<qint64, VPointF> GetDataPoints() const;
2013-08-05 10:37:56 +02:00
/**
* @brief GetPath будує шлях по даній дузі.
* @return повертає шлях.
*/
2013-10-26 22:42:54 +02:00
QPainterPath GetPath() const;
/**
* @brief AngleArc
* @return
*/
2013-10-26 22:42:54 +02:00
qreal AngleArc() const;
/**
* @brief NumberSplOfArc
* @return
*/
2013-10-26 22:42:54 +02:00
qint32 NumberSplOfArc () const;
/**
* @brief GetPoints
* @return
*/
2013-10-26 22:42:54 +02:00
QVector<QPointF> GetPoints () const;
/**
* @brief SplOfArc
* @param number
* @return
*/
2013-10-26 22:42:54 +02:00
QVector<QPointF> SplOfArc( qint32 number ) const;
/**
* @brief getIdObject
* @return
*/
2013-10-26 22:42:54 +02:00
inline qint64 getIdObject() const {return idObject;}
/**
* @brief setIdObject
* @param value
*/
2013-10-26 22:42:54 +02:00
inline void setIdObject(const qint64 &value) {idObject = value;}
/**
* @brief name
* @return
*/
QString name() const {return _name;}
/**
* @brief setName
* @param name
*/
void setName(const QString &name) {_name = name;}
2013-08-05 10:37:56 +02:00
private:
/**
* @brief f1 початковий кут в градусах
*/
qreal f1; // початковий кут нахилу дуги (градуси)
/**
* @brief formulaF1
*/
2013-10-27 11:22:44 +01:00
QString formulaF1;
2013-08-05 10:37:56 +02:00
/**
* @brief f2 кінцевий кут в градусах
*/
qreal f2; // кінцевий кут нахилу дуги (градуси)
/**
* @brief formulaF2
*/
2013-10-27 11:22:44 +01:00
QString formulaF2;
2013-08-05 10:37:56 +02:00
/**
* @brief radius радіус дуги.
*/
2013-10-27 11:22:44 +01:00
qreal radius;
/**
* @brief formulaRadius
*/
2013-10-27 11:22:44 +01:00
QString formulaRadius;
2013-08-05 10:37:56 +02:00
/**
* @brief center центральна точка дуги.
*/
2013-10-27 11:22:44 +01:00
qint64 center;
/**
* @brief points
*/
QHash<qint64, VPointF> points;
/**
* @brief idObject
*/
2013-10-27 11:22:44 +01:00
qint64 idObject;
/**
* @brief _name
*/
QString _name;
2013-08-05 10:37:56 +02:00
};
#endif // VARC_H