Added VEllipticalArc
--HG-- branch : feature
This commit is contained in:
parent
1f15722417
commit
c587826a56
|
@ -146,6 +146,7 @@ extern const QString ColorYellow;
|
|||
// Hacks for avoiding the linker error "undefined reference to"
|
||||
#define SPL_ "Spl_"
|
||||
#define ARC_ "Arc_"
|
||||
#define EARC_ "EllipticalArc_"
|
||||
|
||||
extern const QString line_;
|
||||
extern const QString angleLine_;
|
||||
|
|
468
src/libs/vgeometry/vellipticalarc.cpp
Normal file
468
src/libs/vgeometry/vellipticalarc.cpp
Normal file
|
@ -0,0 +1,468 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vellipticalarc.cpp
|
||||
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
|
||||
** @date February 1, 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) 2013-2015 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/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vellipticalarc.h"
|
||||
#include "vellipticalarc_p.h"
|
||||
#include "vspline.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include <QtCore/qmath.h>
|
||||
#include <QLineF>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VEllipticalArc default constructor.
|
||||
*/
|
||||
VEllipticalArc::VEllipticalArc()
|
||||
:VAbstractCurve(GOType::EllipticalArc), d (new VEllipticalArcData)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VEllipticalArc constructor.
|
||||
* @param center center point.
|
||||
* @param radius1 arc major radius.
|
||||
* @param radius2 arc minor radius.
|
||||
* @param f1 start angle (degree).
|
||||
* @param f2 end angle (degree).
|
||||
*/
|
||||
VEllipticalArc::VEllipticalArc (VPointF center, qreal radius1, qreal radius2,
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1, qreal f2,
|
||||
QString formulaF2, qreal rotationAngle, quint32 idObject, Draw mode)
|
||||
: VAbstractCurve(GOType::EllipticalArc, idObject, mode),
|
||||
d (new VEllipticalArcData(center, radius1, radius2, formulaRadius1, formulaRadius2,
|
||||
f1, formulaF1, f2, formulaF2, rotationAngle))
|
||||
{
|
||||
EllipticalArcName();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VEllipticalArc::VEllipticalArc(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle)
|
||||
: VAbstractCurve(GOType::EllipticalArc, NULL_ID, Draw::Calculation),
|
||||
d (new VEllipticalArcData(center, radius1, radius2, f1, f2, rotationAngle))
|
||||
{
|
||||
EllipticalArcName();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VEllipticalArc::VEllipticalArc(qreal length, QString formulaLength, VPointF center, qreal radius1, qreal radius2,
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1, quint32 idObject, Draw mode)
|
||||
: VAbstractCurve(GOType::EllipticalArc, idObject, mode),
|
||||
d (new VEllipticalArcData(formulaLength, center, radius1, radius2, formulaRadius1, formulaRadius2, f1, formulaF1))
|
||||
{
|
||||
EllipticalArcName();
|
||||
FindF2(length);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VEllipticalArc::VEllipticalArc(qreal length, VPointF center, qreal radius1, qreal radius2, qreal f1)
|
||||
: VAbstractCurve(GOType::EllipticalArc, NULL_ID, Draw::Calculation),
|
||||
d (new VEllipticalArcData(center, radius1, radius2, f1))
|
||||
{
|
||||
EllipticalArcName();
|
||||
FindF2(length);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VEllipticalArc copy constructor
|
||||
* @param arc arc
|
||||
*/
|
||||
VEllipticalArc::VEllipticalArc(const VEllipticalArc &arc)
|
||||
: VAbstractCurve(arc), d (arc.d)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief operator = assignment operator
|
||||
* @param arc arc
|
||||
* @return arc
|
||||
*/
|
||||
VEllipticalArc &VEllipticalArc::operator =(const VEllipticalArc &arc)
|
||||
{
|
||||
if ( &arc == this )
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
VAbstractCurve::operator=(arc);
|
||||
d = arc.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VEllipticalArc::~VEllipticalArc()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetLength return arc length.
|
||||
* @return length.
|
||||
*/
|
||||
qreal VEllipticalArc::GetLength() const
|
||||
{
|
||||
QPointF firstPoint;
|
||||
QPointF point2;
|
||||
QPointF point3;
|
||||
QPointF lastPoint;
|
||||
|
||||
if (not d->isFlipped)
|
||||
{
|
||||
firstPoint = GetP1();
|
||||
point2 = GetPoint((2*GetStartAngle() + GetEndAngle())/3);
|
||||
point3 = GetPoint((GetStartAngle() + 2*GetEndAngle())/3);
|
||||
lastPoint = GetP2();
|
||||
}
|
||||
else
|
||||
{
|
||||
firstPoint = GetP2();
|
||||
point2 = GetPoint((2*GetEndAngle() + GetStartAngle())/3);
|
||||
point3 = GetPoint((GetEndAngle() + 2*GetStartAngle())/3);
|
||||
lastPoint = GetP1();
|
||||
}
|
||||
VSpline spl(VPointF(firstPoint), point2, point3, VPointF(lastPoint), 1.0);
|
||||
qreal length = spl.GetLength();
|
||||
|
||||
if (d->isFlipped)
|
||||
{
|
||||
length = length * -1;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetP1 return point associated with start angle.
|
||||
* @return point.
|
||||
*/
|
||||
QPointF VEllipticalArc::GetP1() const
|
||||
{
|
||||
// we ignore the rotation!
|
||||
QPointF p1 ( GetCenter().x () + qFloor((d->radius1 + d->radius2)*cos(d->f1*M_PI/180)),
|
||||
GetCenter().y () + qFloor((d->radius1 + d->radius2)*sin(d->f1*M_PI/180)));
|
||||
return p1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetP2 return point associated with end angle.
|
||||
* @return point.
|
||||
*/
|
||||
QPointF VEllipticalArc::GetP2 () const
|
||||
{
|
||||
// we ignore the rotation!
|
||||
QPointF p2 ( GetCenter().x () + qFloor((d->radius1 + d->radius2)*cos(d->f2*M_PI/180)),
|
||||
GetCenter().y () + qFloor((d->radius1 + d->radius2)*sin(d->f2*M_PI/180)));
|
||||
return p2;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetPoint return point associated with angle.
|
||||
* @return point.
|
||||
*/
|
||||
QPointF VEllipticalArc::GetPoint (qreal angle) const
|
||||
{
|
||||
// we ignore the rotation!
|
||||
QPointF p ( GetCenter().x () + qFloor((d->radius1 + d->radius2)*cos(angle*M_PI/180)),
|
||||
GetCenter().y () + qFloor((d->radius1 + d->radius2)*sin(angle*M_PI/180)));
|
||||
return p;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AngleArc calculate arc angle.
|
||||
* @return angle in degree.
|
||||
*/
|
||||
qreal VEllipticalArc::AngleArc() const
|
||||
{
|
||||
if ((qFuzzyCompare(d->f1+1, 0+1) && qFuzzyCompare(d->f2, 360)) ||
|
||||
(qFuzzyCompare(d->f1, 360) && qFuzzyCompare(d->f2+1, 0+1)))
|
||||
{
|
||||
return 360;
|
||||
}
|
||||
QLineF l1(0, 0, 100, 100);
|
||||
l1.setAngle(d->f1);
|
||||
QLineF l2(0, 0, 100, 100);
|
||||
l2.setAngle(d->f2);
|
||||
|
||||
qreal ang = l1.angleTo(l2);
|
||||
|
||||
if (d->isFlipped)
|
||||
{
|
||||
ang = 360 - ang;
|
||||
}
|
||||
|
||||
return ang;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetPoints return list of points needed for drawing arc.
|
||||
* @return list of points
|
||||
*/
|
||||
QVector<QPointF> VEllipticalArc::GetPoints() const
|
||||
{
|
||||
QVector<QPointF> points;
|
||||
QVector<qreal> sectionAngle;
|
||||
|
||||
QPointF pStart;
|
||||
d->isFlipped ? pStart = GetP2() : pStart = GetP1();
|
||||
|
||||
{
|
||||
qreal angle = AngleArc();
|
||||
|
||||
if (qFuzzyIsNull(angle))
|
||||
{
|
||||
points.append(pStart);
|
||||
return points;
|
||||
}
|
||||
|
||||
if (angle > 360 || angle < 0)
|
||||
{// Filter incorect value of angle
|
||||
QLineF dummy(0,0, 100, 0);
|
||||
dummy.setAngle(angle);
|
||||
angle = dummy.angle();
|
||||
}
|
||||
|
||||
const qreal angleInterpolation = 45; //degree
|
||||
const int sections = qFloor(angle / angleInterpolation);
|
||||
for (int i = 0; i < sections; ++i)
|
||||
{
|
||||
sectionAngle.append(angleInterpolation);
|
||||
}
|
||||
|
||||
const qreal tail = angle - sections * angleInterpolation;
|
||||
if (tail > 0)
|
||||
{
|
||||
sectionAngle.append(tail);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < sectionAngle.size(); ++i)
|
||||
{
|
||||
QPointF firstPoint = GetPoint(sectionAngle.at(i));
|
||||
QPointF point2 = GetPoint((2*sectionAngle.at(i) + sectionAngle.at(i+1))/3);
|
||||
QPointF point3 = GetPoint((sectionAngle.at(i) + 2*sectionAngle.at(i+1))/3);
|
||||
QPointF lastPoint = GetPoint(sectionAngle.at(i+1));
|
||||
|
||||
VSpline spl(VPointF(firstPoint), point2, point3, VPointF(lastPoint), 1.0);
|
||||
|
||||
QVector<QPointF> splPoints = spl.GetPoints();
|
||||
|
||||
if (not splPoints.isEmpty() && i != sectionAngle.size() - 1)
|
||||
{
|
||||
splPoints.removeLast();
|
||||
}
|
||||
points << splPoints;
|
||||
}
|
||||
// we ignore the rotation of ellipse.
|
||||
return points;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief CutArc cut arc into two arcs.
|
||||
* @param length length first arc.
|
||||
* @param arc1 first arc.
|
||||
* @param arc2 second arc.
|
||||
* @return point cutting
|
||||
*/
|
||||
QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VEllipticalArc::CutArc(const qreal &length) const
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setId keep id arc in data.
|
||||
* @param id id arc in data.
|
||||
*/
|
||||
void VEllipticalArc::setId(const quint32 &id)
|
||||
{
|
||||
VAbstractCurve::setId(id);
|
||||
setName(EARC_ + QString("%1_%2").arg(d->center.name()).arg(id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VEllipticalArc::EllipticalArcName()
|
||||
{
|
||||
setName(EARC_ + QString("%1").arg(this->GetCenter().name()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VEllipticalArc::FindF2(qreal length)
|
||||
{
|
||||
// We need to calculate the second angle,
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VEllipticalArc::MaxLength() const
|
||||
{
|
||||
return M_PI*(d->radius1+d->radius2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetF1 return start angle.
|
||||
* @return angle in degree.
|
||||
*/
|
||||
QString VEllipticalArc::GetFormulaF1() const
|
||||
{
|
||||
return d->formulaF1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VEllipticalArc::SetFormulaF1(const QString &formula, qreal value)
|
||||
{
|
||||
d->formulaF1 = formula;
|
||||
d->f1 = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetF1 return formula for start angle.
|
||||
* @return string with formula.
|
||||
*/
|
||||
qreal VEllipticalArc::GetStartAngle() const
|
||||
{
|
||||
return d->f1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetF2 return end angle.
|
||||
* @return angle in degree.
|
||||
*/
|
||||
QString VEllipticalArc::GetFormulaF2() const
|
||||
{
|
||||
return d->formulaF2;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VEllipticalArc::SetFormulaF2(const QString &formula, qreal value)
|
||||
{
|
||||
d->formulaF2 = formula;
|
||||
d->f2 = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetF2 return formula for end angle.
|
||||
* @return string with formula.
|
||||
*/
|
||||
qreal VEllipticalArc::GetEndAngle() const
|
||||
{
|
||||
return d->f2;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetRadius return arc major radius.
|
||||
* @return radius.
|
||||
*/
|
||||
QString VEllipticalArc::GetFormulaRadius1() const
|
||||
{
|
||||
return d->formulaRadius1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetRadius return arc minor radius.
|
||||
* @return radius.
|
||||
*/
|
||||
QString VEllipticalArc::GetFormulaRadius2() const
|
||||
{
|
||||
return d->formulaRadius2;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VEllipticalArc::SetFormulaRadius1(const QString &formula, qreal value)
|
||||
{
|
||||
d->formulaRadius1 = formula;
|
||||
d->radius1 = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VEllipticalArc::SetFormulaRadius2(const QString &formula, qreal value)
|
||||
{
|
||||
d->formulaRadius2 = formula;
|
||||
d->radius2 = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetRadius return formula for major radius.
|
||||
* @return string with formula.
|
||||
*/
|
||||
qreal VEllipticalArc::GetRadius1() const
|
||||
{
|
||||
return d->radius1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetRadius return formula for minor radius.
|
||||
* @return string with formula.
|
||||
*/
|
||||
qreal VEllipticalArc::GetRadius2() const
|
||||
{
|
||||
return d->radius2;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetCenter return center point.
|
||||
* @return center point.
|
||||
*/
|
||||
VPointF VEllipticalArc::GetCenter() const
|
||||
{
|
||||
return d->center;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VEllipticalArc::SetCenter(const VPointF &value)
|
||||
{
|
||||
d->center = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VEllipticalArc::GetFormulaLength() const
|
||||
{
|
||||
return d->formulaLength;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VEllipticalArc::SetFormulaLength(const QString &formula, qreal value)
|
||||
{
|
||||
d->formulaLength = formula;
|
||||
FindF2(value);
|
||||
}
|
101
src/libs/vgeometry/vellipticalarc.h
Normal file
101
src/libs/vgeometry/vellipticalarc.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vellipticalarc.h
|
||||
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
|
||||
** @date February 1, 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) 2013-2015 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 VELLIPTICALARC_H
|
||||
#define VELLIPTICALARC_H
|
||||
|
||||
#include "vabstractcurve.h"
|
||||
#include "vpointf.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
class VEllipticalArcData;
|
||||
|
||||
class VEllipticalArc : public VAbstractCurve
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VEllipticalArc)
|
||||
public:
|
||||
VEllipticalArc();
|
||||
VEllipticalArc (VPointF center, qreal radius1, qreal radius2, QString formulaRadius1, QString formulaRadius2, qreal f1,
|
||||
QString formulaF1, qreal f2, QString formulaF2, qreal rotationAngle, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||
|
||||
VEllipticalArc (VPointF center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
|
||||
|
||||
VEllipticalArc (qreal length, QString formulaLength, VPointF center, qreal radius1, qreal radius2,
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1,
|
||||
QString formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||
|
||||
VEllipticalArc (qreal length, VPointF center, qreal radius1, qreal radius2, qreal f1);
|
||||
|
||||
VEllipticalArc(const VEllipticalArc &arc);
|
||||
|
||||
VEllipticalArc& operator= (const VEllipticalArc &arc);
|
||||
|
||||
virtual ~VEllipticalArc() Q_DECL_OVERRIDE;
|
||||
|
||||
QString GetFormulaF1 () const;
|
||||
void SetFormulaF1 (const QString &formula, qreal value);
|
||||
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
|
||||
|
||||
QString GetFormulaF2 () const;
|
||||
void SetFormulaF2 (const QString &formula, qreal value);
|
||||
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
|
||||
|
||||
QString GetFormulaRadius1 () const;
|
||||
QString GetFormulaRadius2 () const;
|
||||
void SetFormulaRadius1 (const QString &formula, qreal value);
|
||||
void SetFormulaRadius2 (const QString &formula, qreal value);
|
||||
qreal GetRadius1 () const;
|
||||
qreal GetRadius2 () const;
|
||||
|
||||
VPointF GetCenter () const;
|
||||
void SetCenter (const VPointF &value);
|
||||
|
||||
QString GetFormulaLength () const;
|
||||
void SetFormulaLength (const QString &formula, qreal value);
|
||||
qreal GetLength () const;
|
||||
|
||||
QPointF GetP1() const;
|
||||
QPointF GetP2 () const;
|
||||
QPointF GetPoint (qreal angle) const;
|
||||
qreal AngleArc() const;
|
||||
QVector<QPointF> GetPoints () const;
|
||||
QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const;
|
||||
QPointF CutArc (const qreal &length) const;
|
||||
virtual void setId(const quint32 &id) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
QSharedDataPointer<VEllipticalArcData> d;
|
||||
|
||||
void EllipticalArcName();
|
||||
void FindF2(qreal length);
|
||||
|
||||
qreal MaxLength() const;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(VEllipticalArc, Q_MOVABLE_TYPE);
|
||||
|
||||
#endif // VELLIPTICALARC_H
|
85
src/libs/vgeometry/vellipticalarc_p.h
Normal file
85
src/libs/vgeometry/vellipticalarc_p.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
#ifndef VELLIPTICALARC_P
|
||||
#define VELLIPTICALARC_P
|
||||
|
||||
#include <QSharedData>
|
||||
#include "vpointf.h"
|
||||
|
||||
class VEllipticalArcData : public QSharedData
|
||||
{
|
||||
public:
|
||||
|
||||
VEllipticalArcData ()
|
||||
: f1(0), f2(0), formulaF1(QString()), formulaF2(QString()),
|
||||
radius1(0), radius2(0), formulaRadius1(QString()), formulaRadius2(QString()),
|
||||
center(VPointF()), isFlipped(false), formulaLength(), rotationAngle(0)
|
||||
{}
|
||||
|
||||
VEllipticalArcData (VPointF center, qreal radius1, qreal radius2, QString formulaRadius1, QString formulaRadius2,
|
||||
qreal f1, QString formulaF1, qreal f2, QString formulaF2, qreal rotationAngle)
|
||||
: f1(f1), f2(f2), formulaF1(formulaF1), formulaF2(formulaF2),
|
||||
radius1(radius1), radius2(radius2), formulaRadius1(formulaRadius1), formulaRadius2(formulaRadius2),
|
||||
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
|
||||
{}
|
||||
|
||||
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle)
|
||||
: f1(f1), f2(f2), formulaF1(QString("%1").arg(f1)), formulaF2(QString("%1").arg(f2)),
|
||||
radius1(radius1), radius2(radius2),
|
||||
formulaRadius1(QString("%1").arg(radius1)), formulaRadius2(QString("%1").arg(radius2)),
|
||||
center(center), isFlipped(false), formulaLength(), rotationAngle(rotationAngle)
|
||||
{}
|
||||
|
||||
VEllipticalArcData (QString formulaLength, VPointF center, qreal radius1, qreal radius2,
|
||||
QString formulaRadius1, QString formulaRadius2, qreal f1, QString formulaF1)
|
||||
: f1(f1), f2(0), formulaF1(formulaF1), formulaF2("0"), radius1(radius1),radius2(radius2),
|
||||
formulaRadius1(formulaRadius1), formulaRadius2(formulaRadius2),
|
||||
center(center), isFlipped(false), formulaLength(formulaLength), rotationAngle(0)
|
||||
{}
|
||||
|
||||
VEllipticalArcData(VPointF center, qreal radius1, qreal radius2, qreal f1)
|
||||
: f1(f1), f2(0), formulaF1(QString("%1").arg(f1)), formulaF2("0"),
|
||||
radius1(radius1), radius2(radius2),
|
||||
formulaRadius1(QString("%1").arg(radius1)), formulaRadius2(QString("%1").arg(radius2)),
|
||||
center(center), isFlipped(false), formulaLength(), rotationAngle(0)
|
||||
{}
|
||||
|
||||
VEllipticalArcData(const VEllipticalArcData &arc)
|
||||
: QSharedData(arc), f1(arc.f1), f2(arc.f2), formulaF1(arc.formulaF1), formulaF2(arc.formulaF2),
|
||||
radius1(arc.radius1), radius2(arc.radius2),
|
||||
formulaRadius1(arc.formulaRadius1), formulaRadius2(arc.formulaRadius2),
|
||||
center(arc.center), isFlipped(arc.isFlipped), formulaLength(arc.formulaLength), rotationAngle(arc.rotationAngle)
|
||||
{}
|
||||
|
||||
virtual ~VEllipticalArcData();
|
||||
|
||||
/** @brief f1 start angle in degree. */
|
||||
qreal f1;
|
||||
/** @brief f2 end angle in degree. */
|
||||
qreal f2;
|
||||
/** @brief formulaF1 formula for start angle. */
|
||||
QString formulaF1;
|
||||
/** @brief formulaF2 formula for end angle. */
|
||||
QString formulaF2;
|
||||
/** @brief radius1 elliptical arc major radius. */
|
||||
qreal radius1;
|
||||
/** @brief radius2 elliptical arc minor radius. */
|
||||
qreal radius2;
|
||||
/** @brief formulaRadius1 formula for elliptical arc major radius. */
|
||||
QString formulaRadius1;
|
||||
/** @brief formulaRadius2 formula for elliptical arc minor radius. */
|
||||
QString formulaRadius2;
|
||||
/** @brief center center point of arc. */
|
||||
VPointF center;
|
||||
bool isFlipped;
|
||||
QString formulaLength;
|
||||
/** @brief rotationAngle in degree. */
|
||||
qreal rotationAngle;
|
||||
|
||||
private:
|
||||
VEllipticalArcData &operator=(const VEllipticalArcData &) Q_DECL_EQ_DELETE;
|
||||
};
|
||||
|
||||
VEllipticalArcData::~VEllipticalArcData()
|
||||
{}
|
||||
|
||||
#endif // VELLIPTICALARC_P
|
||||
|
|
@ -8,7 +8,8 @@ SOURCES += \
|
|||
$$PWD/vpointf.cpp \
|
||||
$$PWD/vspline.cpp \
|
||||
$$PWD/vsplinepath.cpp \
|
||||
$$PWD/vsplinepoint.cpp
|
||||
$$PWD/vsplinepoint.cpp \
|
||||
$$PWD/vellipticalarc.cpp
|
||||
|
||||
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
||||
|
||||
|
@ -27,4 +28,6 @@ HEADERS += \
|
|||
$$PWD/vsplinepath_p.h \
|
||||
$$PWD/vsplinepoint.h \
|
||||
$$PWD/vsplinepoint_p.h \
|
||||
$$PWD/vgeometrydef.h
|
||||
$$PWD/vgeometrydef.h \
|
||||
$$PWD/vellipticalarc.h \
|
||||
$$PWD/vellipticalarc_p.h
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <QString>
|
||||
|
||||
enum class Draw : char { Calculation, Modeling, Layout };
|
||||
enum class GOType : char { Point, Arc, Spline, SplinePath, Unknown };
|
||||
enum class GOType : char { Point, Arc, EllipticalArc, Spline, SplinePath, Unknown };
|
||||
enum class SplinePointPosition : char { FirstPoint, LastPoint };
|
||||
|
||||
#endif // VGEOMETRYDEF_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user