Refactoring VArc and VEllipticalArc classes.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-04-10 17:40:55 +03:00
parent a7c4cc7aaf
commit 8713c628dc
11 changed files with 599 additions and 577 deletions

View File

@ -0,0 +1,208 @@
/************************************************************************
**
** @file vabstractarc.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 4, 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/>.
**
*************************************************************************/
#include "vabstractarc.h"
#include "vabstractarc_p.h"
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const quint32 &idObject, const Draw &mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData())
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const VPointF &center, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, quint32 idObject, Draw mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData(center, f1, formulaF1, f2, formulaF2))
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const VPointF &center, qreal f1, qreal f2, quint32 idObject, Draw mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData(center, f1, f2))
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const QString &formulaLength, const VPointF &center,
qreal f1, const QString &formulaF1, quint32 idObject, Draw mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData(formulaLength, center, f1, formulaF1))
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const GOType &type, const VPointF &center, qreal f1, quint32 idObject, Draw mode)
: VAbstractCurve(type, idObject, mode), d (new VAbstractArcData(center, f1))
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::VAbstractArc(const VAbstractArc &arc)
: VAbstractCurve(arc), d (arc.d)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc &VAbstractArc::operator=(const VAbstractArc &arc)
{
if ( &arc == this )
{
return *this;
}
VAbstractCurve::operator=(arc);
d = arc.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArc::~VAbstractArc()
{}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::GetFormulaF1() const
{
return d->formulaF1;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFormulaF1(const QString &formula, qreal value)
{
d->formulaF1 = formula;
d->f1 = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractArc::GetStartAngle() const
{
return d->f1;
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::GetFormulaF2() const
{
return d->formulaF2;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFormulaF2(const QString &formula, qreal value)
{
d->formulaF2 = formula;
d->f2 = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractArc::GetEndAngle() const
{
return d->f2;
}
//---------------------------------------------------------------------------------------------------------------------
VPointF VAbstractArc::GetCenter() const
{
return d->center;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetCenter(const VPointF &point)
{
d->center = point;
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::GetFormulaLength() const
{
return d->formulaLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFormulaLength(const QString &formula, qreal value)
{
d->formulaLength = formula;
FindF2(value);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::setId(const quint32 &id)
{
VAbstractCurve::setId(id);
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractArc::NameForHistory(const QString &toolName) const
{
QString name = toolName + QString(" %1").arg(GetCenter().name());
if (VAbstractCurve::id() != NULL_ID)
{
name += QString("_%1").arg(VAbstractCurve::id());
}
if (GetDuplicate() > 0)
{
name += QString("_%1").arg(GetDuplicate());
}
return name;
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractArc::IsFlipped() const
{
return d->isFlipped;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractArc::AngleArc() const
{
{
const qreal angleDiff = qAbs(GetStartAngle() - GetEndAngle());
if (VFuzzyComparePossibleNulls(angleDiff, 0) || VFuzzyComparePossibleNulls(angleDiff, 360))
{
return 360;
}
}
QLineF l1(0, 0, 100, 0);
l1.setAngle(GetStartAngle());
QLineF l2(0, 0, 100, 0);
l2.setAngle(GetEndAngle());
qreal ang = l1.angleTo(l2);
if (IsFlipped())
{
ang = 360 - ang;
}
return ang;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFlipped(bool value)
{
d->isFlipped = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractArc::SetFormulaLength(const QString &formula)
{
d->formulaLength = formula;
}

View File

@ -0,0 +1,80 @@
/************************************************************************
**
** @file vabstractarc.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 4, 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 VABSTRACTARC_H
#define VABSTRACTARC_H
#include "vabstractcurve.h"
class VAbstractArcData;
class VPointF;
class VAbstractArc : public VAbstractCurve
{
public:
explicit VAbstractArc(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation);
VAbstractArc (const GOType &type, const VPointF &center, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
VAbstractArc (const GOType &type, const VPointF &center, qreal f1, qreal f2, quint32 idObject = 0,
Draw mode = Draw::Calculation);
VAbstractArc (const GOType &type, const QString &formulaLength, const VPointF &center, qreal f1,
const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
VAbstractArc (const GOType &type, const VPointF &center, qreal f1, quint32 idObject = 0,
Draw mode = Draw::Calculation);
explicit VAbstractArc(const VAbstractArc &arc);
VAbstractArc& operator= (const VAbstractArc &arc);
virtual ~VAbstractArc();
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;
VPointF GetCenter () const;
void SetCenter (const VPointF &point);
QString GetFormulaLength () const;
void SetFormulaLength (const QString &formula, qreal value);
virtual void setId(const quint32 &id) Q_DECL_OVERRIDE;
virtual QString NameForHistory(const QString &toolName) const Q_DECL_OVERRIDE;
bool IsFlipped() const;
qreal AngleArc() const;
protected:
void SetFlipped(bool value);
virtual void FindF2(qreal length)=0;
void SetFormulaLength(const QString &formula);
private:
QSharedDataPointer<VAbstractArcData> d;
};
#endif // VABSTRACTARC_H

View File

@ -0,0 +1,148 @@
/************************************************************************
**
** @file VAbstractArcData.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 10 4, 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 VABSTRACTARC_P_H
#define VABSTRACTARC_P_H
#include <QSharedData>
#include "vgeometrydef.h"
#include "../vmisc/vabstractapplication.h"
#include "vpointf.h"
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif
class VAbstractArcData : public QSharedData
{
public:
VAbstractArcData();
VAbstractArcData(const VPointF &center, qreal f1, const QString &formulaF1, qreal f2, const QString &formulaF2);
VAbstractArcData(const QString &formulaLength, VPointF center, qreal f1, QString formulaF1);
VAbstractArcData(const VPointF &center, qreal f1);
VAbstractArcData(const VPointF &center, qreal f1, qreal f2);
VAbstractArcData(const VAbstractArcData &arc);
virtual ~VAbstractArcData();
/** @brief f1 start angle in degree. */
qreal f1;
/** @brief formulaF1 formula for start angle. */
QString formulaF1;
/** @brief f2 end angle in degree. */
qreal f2;
/** @brief formulaF2 formula for end angle. */
QString formulaF2;
/** @brief center center point of arc. */
VPointF center;
bool isFlipped;
QString formulaLength;
private:
VAbstractArcData &operator=(const VAbstractArcData &) Q_DECL_EQ_DELETE;
};
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData()
: f1(0),
formulaF1(),
f2(0),
formulaF2(),
center(),
isFlipped(false),
formulaLength()
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const VPointF &center, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2)
: f1(f1),
formulaF1(formulaF1),
f2(f2),
formulaF2(formulaF2),
center(center),
isFlipped(false),
formulaLength()
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const QString &formulaLength, VPointF center, qreal f1, QString formulaF1)
: f1(f1),
formulaF1(formulaF1),
f2(0),
formulaF2("0"),
center(center),
isFlipped(false),
formulaLength(formulaLength)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const VPointF &center, qreal f1)
: f1(f1),
formulaF1(QString().number(f1)),
f2(0),
formulaF2("0"),
center(center),
isFlipped(false),
formulaLength()
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const VPointF &center, qreal f1, qreal f2)
: f1(f1),
formulaF1(QString().number(f1)),
f2(f2),
formulaF2(QString().number(f2)),
center(center),
isFlipped(false),
formulaLength()
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::VAbstractArcData(const VAbstractArcData &arc)
: QSharedData(arc),
f1(arc.f1),
formulaF1(arc.formulaF1),
f2(arc.f2),
formulaF2(arc.formulaF2),
center(arc.center),
isFlipped(arc.isFlipped),
formulaLength(arc.formulaLength)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractArcData::~VAbstractArcData()
{}
#endif // VABSTRACTARCDATA_H

View File

@ -42,7 +42,8 @@
* @brief VArc default constructor.
*/
VArc::VArc ()
:VAbstractCurve(GOType::Arc), d (new VArcData)
: VAbstractArc(GOType::Arc),
d (new VArcData)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -53,34 +54,36 @@ VArc::VArc ()
* @param f1 start angle (degree).
* @param f2 end angle (degree).
*/
VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
QString formulaF2, quint32 idObject, Draw mode)
: VAbstractCurve(GOType::Arc, idObject, mode),
d (new VArcData(center, radius, formulaRadius, f1, formulaF1, f2, formulaF2))
VArc::VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
qreal f2, const QString &formulaF2, quint32 idObject, Draw mode)
: VAbstractArc(GOType::Arc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d (new VArcData(radius, formulaRadius))
{
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
VArc::VArc(VPointF center, qreal radius, qreal f1, qreal f2)
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1, f2))
VArc::VArc(const VPointF &center, qreal radius, qreal f1, qreal f2)
: VAbstractArc(GOType::Arc, center, f1, f2, NULL_ID, Draw::Calculation),
d (new VArcData(radius))
{
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
VArc::VArc(qreal length, QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1,
QString formulaF1, quint32 idObject, Draw mode)
: VAbstractCurve(GOType::Arc, idObject, mode),
d (new VArcData(formulaLength, center, radius, formulaRadius, f1, formulaF1))
VArc::VArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius,
const QString &formulaRadius, qreal f1, const QString &formulaF1, quint32 idObject, Draw mode)
: VAbstractArc(GOType::Arc, formulaLength, center, f1, formulaF1, idObject, mode),
d (new VArcData(radius, formulaRadius))
{
CreateName();
FindF2(length);
}
//---------------------------------------------------------------------------------------------------------------------
VArc::VArc(qreal length, VPointF center, qreal radius, qreal f1)
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1))
VArc::VArc(qreal length, const VPointF &center, qreal radius, qreal f1)
: VAbstractArc(GOType::Arc, center, f1, NULL_ID, Draw::Calculation),
d (new VArcData(radius))
{
CreateName();
FindF2(length);
@ -92,7 +95,7 @@ VArc::VArc(qreal length, VPointF center, qreal radius, qreal f1)
* @param arc arc
*/
VArc::VArc(const VArc &arc)
: VAbstractCurve(arc), d (arc.d)
: VAbstractArc(arc), d (arc.d)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -107,7 +110,7 @@ VArc &VArc::operator =(const VArc &arc)
{
return *this;
}
VAbstractCurve::operator=(arc);
VAbstractArc::operator=(arc);
d = arc.d;
return *this;
}
@ -137,7 +140,7 @@ VArc::~VArc()
qreal VArc::GetLength() const
{
qreal length = (M_PI * d->radius)/180 * AngleArc();
if (d->isFlipped)
if (IsFlipped())
{
length *= -1;
}
@ -154,7 +157,7 @@ QPointF VArc::GetP1() const
{
QPointF p1 ( GetCenter().x () + d->radius, GetCenter().y () );
QLineF centerP1(GetCenter().toQPointF(), p1);
centerP1.setAngle(d->f1);
centerP1.setAngle(GetStartAngle());
return centerP1.p2();
}
@ -167,39 +170,10 @@ QPointF VArc::GetP2 () const
{
QPointF p2 ( GetCenter().x () + d->radius, GetCenter().y () );
QLineF centerP2(GetCenter().toQPointF(), p2);
centerP2.setAngle(d->f2);
centerP2.setAngle(GetEndAngle());
return centerP2.p2();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AngleArc calculate arc angle.
* @return angle in degree.
*/
qreal VArc::AngleArc() const
{
{
const qreal angleDiff = qAbs(d->f1 - d->f2);
if (VFuzzyComparePossibleNulls(angleDiff, 0) || VFuzzyComparePossibleNulls(angleDiff, 360))
{
return 360;
}
}
QLineF l1(0, 0, 100, 0);
l1.setAngle(d->f1);
QLineF l2(0, 0, 100, 0);
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.
@ -211,7 +185,7 @@ QVector<QPointF> VArc::GetPoints() const
QVector<qreal> sectionAngle;
QPointF pStart;
d->isFlipped ? pStart = GetP2() : pStart = GetP1();
IsFlipped() ? pStart = GetP2() : pStart = GetP1();
{
qreal angle = AngleArc();
@ -314,11 +288,11 @@ QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const
QLineF line(GetCenter().toQPointF(), GetP1());
line.setAngle(line.angle()+n);
arc1 = VArc (d->center, d->radius, d->formulaRadius, d->f1, d->formulaF1, line.angle(),
arc1 = VArc (GetCenter(), d->radius, d->formulaRadius, GetStartAngle(), GetFormulaF1(), line.angle(),
QString().setNum(line.angle()), getIdObject(), getMode());
arc2 = VArc (d->center, d->radius, d->formulaRadius, line.angle(), QString().setNum(line.angle()), d->f2,
d->formulaF2, getIdObject(), getMode());
arc2 = VArc (GetCenter(), d->radius, d->formulaRadius, line.angle(), QString().setNum(line.angle()), GetEndAngle(),
GetFormulaF2(), getIdObject(), getMode());
return line.p2();
}
@ -331,34 +305,6 @@ QPointF VArc::CutArc(const qreal &length) const
return this->CutArc(length, arc1, arc2);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setId keep id arc in data.
* @param id id arc in data.
*/
void VArc::setId(const quint32 &id)
{
VAbstractCurve::setId(id);
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
QString VArc::NameForHistory(const QString &toolName) const
{
QString name = toolName + QString(" %1").arg(this->GetCenter().name());
if (VAbstractCurve::id() != NULL_ID)
{
name += QString("_%1").arg(VAbstractCurve::id());
}
if (GetDuplicate() > 0)
{
name += QString("_%1").arg(GetDuplicate());
}
return name;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::CreateName()
{
@ -380,7 +326,7 @@ void VArc::CreateName()
//---------------------------------------------------------------------------------------------------------------------
void VArc::FindF2(qreal length)
{
length < 0 ? d->isFlipped = true : d->isFlipped = false;
SetFlipped(length < 0);
if (length >= MaxLength())
{
@ -389,16 +335,15 @@ void VArc::FindF2(qreal length)
qreal arcAngle = (qAbs(length)*180)/(M_PI*d->radius);
if (d->isFlipped)
if (IsFlipped())
{
arcAngle = arcAngle * -1;
}
QLineF startAngle(0, 0, 100, 0);
startAngle.setAngle(d->f1 + arcAngle);// We use QLineF just because it is easy way correct angle value
startAngle.setAngle(GetStartAngle() + arcAngle);// We use QLineF just because it is easy way correct angle value
d->f2 = startAngle.angle();
d->formulaF2 = QString().number(d->f2);
SetFormulaF2(QString().number(startAngle.angle()), startAngle.angle());
}
//---------------------------------------------------------------------------------------------------------------------
@ -407,60 +352,6 @@ qreal VArc::MaxLength() const
return M_2PI*d->radius;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF1 return start angle.
* @return angle in degree.
*/
QString VArc::GetFormulaF1() const
{
return d->formulaF1;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaF1(const QString &formula, qreal value)
{
d->formulaF1 = formula;
d->f1 = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF1 return formula for start angle.
* @return string with formula.
*/
qreal VArc::GetStartAngle() const
{
return d->f1;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF2 return end angle.
* @return angle in degree.
*/
QString VArc::GetFormulaF2() const
{
return d->formulaF2;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaF2(const QString &formula, qreal value)
{
d->formulaF2 = formula;
d->f2 = value;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetF2 return formula for end angle.
* @return string with formula.
*/
qreal VArc::GetEndAngle() const
{
return d->f2;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetRadius return arc radius.
@ -487,32 +378,3 @@ qreal VArc::GetRadius() const
{
return d->radius;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetCenter return center point.
* @return center point.
*/
VPointF VArc::GetCenter() const
{
return d->center;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetCenter(const VPointF &value)
{
d->center = value;
}
//---------------------------------------------------------------------------------------------------------------------
QString VArc::GetFormulaLength() const
{
return d->formulaLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaLength(const QString &formula, qreal value)
{
d->formulaLength = formula;
FindF2(value);
}

View File

@ -29,7 +29,7 @@
#ifndef VARC_H
#define VARC_H
#include "vabstractcurve.h"
#include "vabstractarc.h"
#include "vpointf.h"
#include <QCoreApplication>
@ -39,56 +39,41 @@ class VArcData;
/**
* @brief VArc class for anticlockwise arc.
*/
class VArc: public VAbstractCurve
class VArc: public VAbstractArc
{
Q_DECLARE_TR_FUNCTIONS(VArc)
public:
VArc ();
VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
QString formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (VPointF center, qreal radius, qreal f1, qreal f2);
VArc (qreal length, QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1,
QString formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (qreal length, VPointF center, qreal radius, qreal f1);
VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
qreal f2, const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (const VPointF &center, qreal radius, qreal f1, qreal f2);
VArc (qreal length, const QString &formulaLength, const VPointF &center, qreal radius, const QString &formulaRadius,
qreal f1, const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (qreal length, const VPointF &center, qreal radius, qreal f1);
VArc(const VArc &arc);
VArc& operator= (const VArc &arc);
VArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
virtual ~VArc() Q_DECL_OVERRIDE;
QString GetFormulaF1 () const;
void SetFormulaF1 (const QString &formula, qreal value);
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
QString GetFormulaRadius () const;
void SetFormulaRadius (const QString &formula, qreal value);
qreal GetRadius () const;
QString GetFormulaF2 () const;
void SetFormulaF2 (const QString &formula, qreal value);
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
qreal GetLength () const;
QString GetFormulaRadius () const;
void SetFormulaRadius (const QString &formula, qreal value);
qreal GetRadius () const;
QPointF GetP1() const;
QPointF GetP2 () const;
VPointF GetCenter () const;
void SetCenter (const VPointF &value);
QVector<QPointF> GetPoints () const;
QString GetFormulaLength () const;
void SetFormulaLength (const QString &formula, qreal value);
qreal GetLength () const;
QPointF GetP1() const;
QPointF GetP2 () const;
qreal AngleArc() const;
QVector<QPointF> GetPoints () const;
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
QPointF CutArc (const qreal &length) const;
virtual void setId(const quint32 &id) Q_DECL_OVERRIDE;
virtual QString NameForHistory(const QString &toolName) const Q_DECL_OVERRIDE;
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
QPointF CutArc (const qreal &length) const;
protected:
virtual void CreateName() Q_DECL_OVERRIDE;
virtual void FindF2(qreal length) Q_DECL_OVERRIDE;
private:
QSharedDataPointer<VArcData> d;
void FindF2(qreal length);
qreal MaxLength() const;
};

View File

@ -32,7 +32,6 @@
#include <QSharedData>
#include "vgeometrydef.h"
#include "../vmisc/vabstractapplication.h"
#include "vpointf.h"
#ifdef Q_CC_GNU
#pragma GCC diagnostic push
@ -42,72 +41,48 @@
class VArcData : public QSharedData
{
public:
VArcData ()
: f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
center(VPointF()), isFlipped(false), formulaLength()
{}
VArcData (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
QString formulaF2)
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
center(center), isFlipped(false), formulaLength()
{}
VArcData(VPointF center, qreal radius, qreal f1, qreal f2)
: f1(f1), formulaF1(QString().number(f1)),
f2(f2), formulaF2(QString().number(f2)),
radius(radius), formulaRadius(QString().number(qApp->fromPixel(radius))),
center(center), isFlipped(false), formulaLength()
{}
VArcData (QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1)
: f1(f1), formulaF1(formulaF1), f2(0), formulaF2("0"), radius(radius), formulaRadius(formulaRadius),
center(center), isFlipped(false), formulaLength(formulaLength)
{}
VArcData(VPointF center, qreal radius, qreal f1)
: f1(f1), formulaF1(QString().number(f1)), f2(0), formulaF2("0"), radius(radius),
formulaRadius(QString().number(qApp->fromPixel(radius))), center(center), isFlipped(false), formulaLength()
{}
VArcData(const VArcData &arc)
: QSharedData(arc), f1(arc.f1), formulaF1(arc.formulaF1), f2(arc.f2), formulaF2(arc.formulaF2),
radius(arc.radius), formulaRadius(arc.formulaRadius), center(arc.center), isFlipped(arc.isFlipped),
formulaLength(arc.formulaLength)
{}
VArcData();
VArcData(qreal radius, QString formulaRadius);
VArcData(qreal radius);
VArcData(const VArcData &arc);
virtual ~VArcData();
/** @brief f1 start angle in degree. */
qreal f1;
/** @brief formulaF1 formula for start angle. */
QString formulaF1;
/** @brief f2 end angle in degree. */
qreal f2;
/** @brief formulaF2 formula for end angle. */
QString formulaF2;
/** @brief radius arc radius. */
qreal radius;
/** @brief formulaRadius formula for arc radius. */
QString formulaRadius;
/** @brief center center point of arc. */
VPointF center;
bool isFlipped;
QString formulaLength;
private:
VArcData &operator=(const VArcData &) Q_DECL_EQ_DELETE;
};
//---------------------------------------------------------------------------------------------------------------------
VArcData::VArcData()
: radius(0),
formulaRadius(QString())
{}
//---------------------------------------------------------------------------------------------------------------------
VArcData::VArcData(qreal radius, QString formulaRadius)
: radius(radius),
formulaRadius(formulaRadius)
{}
//---------------------------------------------------------------------------------------------------------------------
VArcData::VArcData(qreal radius)
: radius(radius),
formulaRadius(QString().number(qApp->fromPixel(radius)))
{}
//---------------------------------------------------------------------------------------------------------------------
VArcData::VArcData(const VArcData &arc)
: QSharedData(arc),
radius(arc.radius),
formulaRadius(arc.formulaRadius)
{}
//---------------------------------------------------------------------------------------------------------------------
VArcData::~VArcData()
{}

View File

@ -39,7 +39,7 @@
* @brief VEllipticalArc default constructor.
*/
VEllipticalArc::VEllipticalArc()
: VAbstractCurve(GOType::EllipticalArc), d (new VEllipticalArcData)
: VAbstractArc(GOType::EllipticalArc), d (new VEllipticalArcData)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -54,9 +54,8 @@ VEllipticalArc::VEllipticalArc()
VEllipticalArc::VEllipticalArc (const VPointF &center, qreal radius1, qreal radius2, const QString &formulaRadius1,
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
const 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))
: VAbstractArc(GOType::EllipticalArc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle))
{
CreateName();
}
@ -64,8 +63,8 @@ VEllipticalArc::VEllipticalArc (const VPointF &center, qreal radius1, qreal radi
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(const 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))
: VAbstractArc(GOType::EllipticalArc, center, f1, f2, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(radius1, radius2, rotationAngle))
{
CreateName();
}
@ -74,9 +73,8 @@ VEllipticalArc::VEllipticalArc(const VPointF &center, qreal radius1, qreal radiu
VEllipticalArc::VEllipticalArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius1,
qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
const QString &formulaF1, qreal rotationAngle, quint32 idObject, Draw mode)
: VAbstractCurve(GOType::EllipticalArc, idObject, mode),
d (new VEllipticalArcData(formulaLength, center, radius1, radius2, formulaRadius1, formulaRadius2, f1, formulaF1,
rotationAngle))
: VAbstractArc(GOType::EllipticalArc, formulaLength, center, f1, formulaF1, idObject, mode),
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle))
{
CreateName();
FindF2(length);
@ -85,8 +83,8 @@ VEllipticalArc::VEllipticalArc(qreal length, const QString &formulaLength, const
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArc::VEllipticalArc(qreal length, const VPointF &center, qreal radius1, qreal radius2, qreal f1,
qreal rotationAngle)
: VAbstractCurve(GOType::EllipticalArc, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(center, radius1, radius2, f1, rotationAngle))
: VAbstractArc(GOType::EllipticalArc, center, f1, NULL_ID, Draw::Calculation),
d (new VEllipticalArcData(radius1, radius2, rotationAngle))
{
CreateName();
FindF2(length);
@ -98,7 +96,7 @@ VEllipticalArc::VEllipticalArc(qreal length, const VPointF &center, qreal radius
* @param arc arc
*/
VEllipticalArc::VEllipticalArc(const VEllipticalArc &arc)
: VAbstractCurve(arc), d (arc.d)
: VAbstractArc(arc), d (arc.d)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -113,7 +111,7 @@ VEllipticalArc &VEllipticalArc::operator =(const VEllipticalArc &arc)
{
return *this;
}
VAbstractCurve::operator=(arc);
VAbstractArc::operator=(arc);
d = arc.d;
return *this;
}
@ -144,7 +142,7 @@ qreal VEllipticalArc::GetLength() const
{
qreal length = PathLength(GetPoints());
if (d->isFlipped)
if (IsFlipped())
{
length = length * -1;
}
@ -159,7 +157,7 @@ qreal VEllipticalArc::GetLength() const
*/
QPointF VEllipticalArc::GetP1() const
{
return GetPoint(d->f1);
return GetPoint(GetStartAngle());
}
//---------------------------------------------------------------------------------------------------------------------
@ -169,7 +167,7 @@ QPointF VEllipticalArc::GetP1() const
*/
QPointF VEllipticalArc::GetP2 () const
{
return GetPoint(d->f2);
return GetPoint(GetEndAngle());
}
//---------------------------------------------------------------------------------------------------------------------
@ -296,36 +294,6 @@ int VEllipticalArc::GetQuadransRad(qreal &rad)
return n;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AngleArc calculate arc angle.
* @return angle in degree.
*/
qreal VEllipticalArc::AngleArc() const
{
{
const qreal angleDiff = qAbs(d->f1 - d->f2);
if (VFuzzyComparePossibleNulls(angleDiff, 0) || VFuzzyComparePossibleNulls(angleDiff, 360))
{
return 360;
}
}
QLineF l1(0, 0, 100, 0);
l1.setAngle(d->f1);
QLineF l2(0, 0, 100, 0);
l2.setAngle(d->f2);
qreal ang = l1.angleTo(l2);
if (d->isFlipped)
{
ang = 360 - ang;
}
return ang;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetAngles return list of angles needed for drawing arc.
@ -338,7 +306,7 @@ QVector<qreal> VEllipticalArc::GetAngles() const
if (qFuzzyIsNull(angle))
{// Return the array that includes one angle
sectionAngle.append(d->f1);
sectionAngle.append(GetStartAngle());
return sectionAngle;
}
@ -375,7 +343,7 @@ QVector<QPointF> VEllipticalArc::GetPoints() const
QVector<qreal> sectionAngle = GetAngles();
qreal currentAngle;
d->isFlipped ? currentAngle = GetEndAngle() : currentAngle = GetStartAngle();
IsFlipped() ? currentAngle = GetEndAngle() : currentAngle = GetStartAngle();
for (int i = 0; i < sectionAngle.size(); ++i)
{
QPointF startPoint = GetPoint(currentAngle);
@ -439,13 +407,13 @@ QPointF VEllipticalArc::CutArc(const qreal &length, VEllipticalArc &arc1, VEllip
}
// the first arc has given length and startAngle just like in the origin arc
arc1 = VEllipticalArc (len, QString().setNum(length), d->center, d->radius1, d->radius2,
d->formulaRadius1, d->formulaRadius2, d->f1, d->formulaF1, d->rotationAngle,
arc1 = VEllipticalArc (len, QString().setNum(length), GetCenter(), d->radius1, d->radius2,
d->formulaRadius1, d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle,
getIdObject(), getMode());
// the second arc has startAngle just like endAngle of the first arc
// and it has endAngle just like endAngle of the origin arc
arc2 = VEllipticalArc (d->center, d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2,
arc1.GetEndAngle(), arc1.GetFormulaF2(), d->f2, d->formulaF2, d->rotationAngle,
arc2 = VEllipticalArc (GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2,
arc1.GetEndAngle(), arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
getIdObject(), getMode());
return arc1.GetP1();
}
@ -459,34 +427,6 @@ QPointF VEllipticalArc::CutArc(const qreal &length) const
return this->CutArc(length, arc1, arc2);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setId keep id arc in data.
* @param id id arc in data.
*/
void VEllipticalArc::setId(const quint32 &id)
{
VAbstractCurve::setId(id);
CreateName();
}
//---------------------------------------------------------------------------------------------------------------------
QString VEllipticalArc::NameForHistory(const QString &toolName) const
{
QString name = toolName + QString(" %1").arg(this->GetCenter().name());
if (VAbstractCurve::id() != NULL_ID)
{
name += QString("_%1").arg(VAbstractCurve::id());
}
if (GetDuplicate() > 0)
{
name += QString("_%1").arg(GetDuplicate());
}
return name;
}
//---------------------------------------------------------------------------------------------------------------------
void VEllipticalArc::CreateName()
{
@ -511,7 +451,7 @@ void VEllipticalArc::FindF2(qreal length)
qreal gap = 180;
if (length < 0)
{
d->isFlipped = true;
SetFlipped(true);
gap = -gap;
}
while (length > MaxLength())
@ -523,7 +463,9 @@ void VEllipticalArc::FindF2(qreal length)
// first approximation of angle between start and end angles
qreal endAngle = GetStartAngle() + gap;
d->f2 = endAngle; // we need to set the end anngle, because we want to use GetLength()
// we need to set the end angle, because we want to use GetLength()
SetFormulaF2(QString::number(endAngle), endAngle);
qreal lenBez = GetLength(); // first approximation of length
@ -534,7 +476,6 @@ void VEllipticalArc::FindF2(qreal length)
gap = gap/2;
if (gap < 0.0001)
{
d->f2 = endAngle;
break;
}
if (lenBez > length)
@ -546,11 +487,11 @@ void VEllipticalArc::FindF2(qreal length)
endAngle = endAngle + qAbs(gap);
}
// we need to set d->f2, because we use it when we calculate GetLength
d->f2 = endAngle;
SetFormulaF2(QString::number(endAngle), endAngle);
lenBez = GetLength();
}
d->formulaF2 = QString().number(d->f2);
d->formulaLength = QString().number(qApp->fromPixel(lenBez));
SetFormulaF2(QString::number(endAngle), endAngle);
SetFormulaLength(QString::number(qApp->fromPixel(lenBez)));
}
//---------------------------------------------------------------------------------------------------------------------
@ -561,60 +502,6 @@ qreal VEllipticalArc::MaxLength() const
return ellipseLength;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @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.
@ -678,32 +565,3 @@ 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);
}

View File

@ -29,13 +29,13 @@
#ifndef VELLIPTICALARC_H
#define VELLIPTICALARC_H
#include "vabstractcurve.h"
#include "vabstractarc.h"
#include "vpointf.h"
#include <QCoreApplication>
class VEllipticalArcData;
class VEllipticalArc : public VAbstractCurve
class VEllipticalArc : public VAbstractArc
{
Q_DECLARE_TR_FUNCTIONS(VEllipticalArc)
public:
@ -56,49 +56,35 @@ public:
virtual ~VEllipticalArc() Q_DECL_OVERRIDE;
QString GetFormulaF1 () const;
void SetFormulaF1 (const QString &formula, qreal value);
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
qreal GetRotationAngle() const;
QString GetFormulaF2 () const;
void SetFormulaF2 (const QString &formula, qreal value);
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
QString GetFormulaRadius1 () const;
void SetFormulaRadius1 (const QString &formula, qreal value);
qreal GetRadius1 () const;
qreal GetRotationAngle() const;
QString GetFormulaRadius2 () const;
void SetFormulaRadius2 (const QString &formula, qreal value);
qreal GetRadius2 () const;
QString GetFormulaRadius1 () const;
void SetFormulaRadius1 (const QString &formula, qreal value);
qreal GetRadius1 () const;
qreal GetLength () const;
QString GetFormulaRadius2 () const;
void SetFormulaRadius2 (const QString &formula, qreal value);
qreal GetRadius2 () const;
QPointF GetP1() const;
QPointF GetP2() const;
VPointF GetCenter () const;
void SetCenter (const VPointF &value);
QVector<QPointF> GetPoints () const;
QString GetFormulaLength () const;
void SetFormulaLength (const QString &formula, qreal value);
qreal GetLength () const;
QPointF GetP1() const;
QPointF GetP2 () const;
qreal AngleArc() const;
QVector<qreal> GetAngles () 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;
virtual QString NameForHistory(const QString &toolName) const Q_DECL_OVERRIDE;
QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const;
QPointF CutArc (const qreal &length) const;
protected:
virtual void CreateName() Q_DECL_OVERRIDE;
virtual void FindF2(qreal length) Q_DECL_OVERRIDE;
private:
QSharedDataPointer<VEllipticalArcData> d;
void FindF2(qreal length);
qreal MaxLength() const;
QPointF GetPoint (qreal angle) const;
QVector<qreal> GetAngles () const;
qreal MaxLength() const;
QPointF GetPoint (qreal angle) const;
static int GetQuadransRad(qreal &rad);
};

View File

@ -14,40 +14,23 @@ class VEllipticalArcData : public QSharedData
{
public:
VEllipticalArcData ();
VEllipticalArcData (const VPointF &center, qreal radius1, qreal radius2, const QString &formulaRadius1,
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
const QString &formulaF2, qreal rotationAngle);
VEllipticalArcData(const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
VEllipticalArcData (const QString &formulaLength, const VPointF &center, qreal radius1, qreal radius2,
const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
const QString &formulaF1, qreal rotationAngle);
VEllipticalArcData(const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
VEllipticalArcData (qreal radius1, qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2,
qreal rotationAngle);
VEllipticalArcData(qreal radius1, qreal radius2, qreal rotationAngle);
VEllipticalArcData(const VEllipticalArcData &arc);
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;
qreal radius1;
/** @brief radius2 elliptical arc minor radius. */
qreal radius2;
qreal radius2;
/** @brief formulaRadius1 formula for elliptical arc major radius. */
QString formulaRadius1;
QString formulaRadius1;
/** @brief formulaRadius2 formula for elliptical arc minor radius. */
QString formulaRadius2;
/** @brief center center point of arc. */
VPointF center;
bool isFlipped;
QString formulaLength;
QString formulaRadius2;
/** @brief rotationAngle in degree. */
qreal rotationAngle;
qreal rotationAngle;
private:
VEllipticalArcData &operator=(const VEllipticalArcData &) Q_DECL_EQ_DELETE;
@ -55,105 +38,39 @@ private:
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::VEllipticalArcData()
: f1(0),
f2(0),
formulaF1(),
formulaF2(),
radius1(0),
: radius1(0),
radius2(0),
formulaRadius1(),
formulaRadius2(),
center(),
isFlipped(false),
formulaLength(),
rotationAngle(0)
{}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::VEllipticalArcData(const VPointF &center, qreal radius1, qreal radius2,
const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
const QString &formulaF1, qreal f2, const QString &formulaF2,
qreal rotationAngle)
: f1(f1),
f2(f2),
formulaF1(formulaF1),
formulaF2(formulaF2),
radius1(radius1),
VEllipticalArcData::VEllipticalArcData(qreal radius1, qreal radius2, const QString &formulaRadius1,
const QString &formulaRadius2, qreal rotationAngle)
: radius1(radius1),
radius2(radius2),
formulaRadius1(formulaRadius1),
formulaRadius2(formulaRadius2),
center(center),
isFlipped(false),
formulaLength(),
rotationAngle(rotationAngle)
{}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::VEllipticalArcData(const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2,
qreal rotationAngle)
: f1(f1),
f2(f2),
formulaF1(QString().number(f1)),
formulaF2(QString().number(f2)),
radius1(radius1),
VEllipticalArcData::VEllipticalArcData(qreal radius1, qreal radius2, qreal rotationAngle)
: radius1(radius1),
radius2(radius2),
formulaRadius1(QString().number(qApp->fromPixel(radius1))),
formulaRadius2(QString().number(qApp->fromPixel(radius2))),
center(center),
isFlipped(false),
formulaLength(),
rotationAngle(rotationAngle)
{}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::VEllipticalArcData(const QString &formulaLength, const VPointF &center, qreal radius1,
qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2,
qreal f1, const QString &formulaF1, qreal rotationAngle)
: f1(f1),
f2(0),
formulaF1(formulaF1),
formulaF2("0"),
radius1(radius1),
radius2(radius2),
formulaRadius1(formulaRadius1),
formulaRadius2(formulaRadius2),
center(center),
isFlipped(false),
formulaLength(formulaLength),
rotationAngle(rotationAngle)
{}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::VEllipticalArcData(const VPointF &center, qreal radius1, qreal radius2, qreal f1,
qreal rotationAngle)
: f1(f1),
f2(0),
formulaF1(QString().number(f1)),
formulaF2("0"),
radius1(radius1),
radius2(radius2),
formulaRadius1(QString().number(qApp->fromPixel(radius1))),
formulaRadius2(QString().number(qApp->fromPixel(radius2))),
center(center),
isFlipped(false),
formulaLength(),
rotationAngle(rotationAngle)
{}
//---------------------------------------------------------------------------------------------------------------------
VEllipticalArcData::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)
{}

View File

@ -13,7 +13,8 @@ SOURCES += \
$$PWD/vcubicbezier.cpp \
$$PWD/vabstractcubicbezier.cpp \
$$PWD/vabstractcubicbezierpath.cpp \
$$PWD/vcubicbezierpath.cpp
$$PWD/vcubicbezierpath.cpp \
$$PWD/vabstractarc.cpp
win32-msvc*:SOURCES += $$PWD/stable.cpp
@ -41,4 +42,6 @@ HEADERS += \
$$PWD/vabstractcubicbezier.h \
$$PWD/vabstractcubicbezierpath.h \
$$PWD/vcubicbezierpath.h \
$$PWD/vcubicbezierpath_p.h
$$PWD/vcubicbezierpath_p.h \
$$PWD/vabstractarc.h \
$$PWD/vabstractarc_p.h

View File

@ -63,27 +63,27 @@ int main(int argc, char** argv)
delete obj;
};
// ASSERT_TEST(new TST_FindPoint());
// ASSERT_TEST(new TST_VDetail());
// ASSERT_TEST(new TST_VPoster());
// ASSERT_TEST(new TST_VAbstractDetail());
// ASSERT_TEST(new TST_VSpline());
// ASSERT_TEST(new TST_NameRegExp());
// ASSERT_TEST(new TST_VLayoutDetail());
// ASSERT_TEST(new TST_VArc());
ASSERT_TEST(new TST_FindPoint());
ASSERT_TEST(new TST_VDetail());
ASSERT_TEST(new TST_VPoster());
ASSERT_TEST(new TST_VAbstractDetail());
ASSERT_TEST(new TST_VSpline());
ASSERT_TEST(new TST_NameRegExp());
ASSERT_TEST(new TST_VLayoutDetail());
ASSERT_TEST(new TST_VArc());
ASSERT_TEST(new TST_VEllipticalArc());
// ASSERT_TEST(new TST_MeasurementRegExp());
// ASSERT_TEST(new TST_TapeCommandLine());
// ASSERT_TEST(new TST_ValentinaCommandLine());
// ASSERT_TEST(new TST_QmuTokenParser());
// ASSERT_TEST(new TST_VMeasurements());
// ASSERT_TEST(new TST_QmuParserErrorMsg());
// ASSERT_TEST(new TST_VLockGuard());
// ASSERT_TEST(new TST_Misc());
// ASSERT_TEST(new TST_VCommandLine());
// ASSERT_TEST(new TST_TSTranslation());
// ASSERT_TEST(new TST_VAbstractCurve());
// ASSERT_TEST(new TST_VCubicBezierPath());
ASSERT_TEST(new TST_MeasurementRegExp());
ASSERT_TEST(new TST_TapeCommandLine());
ASSERT_TEST(new TST_ValentinaCommandLine());
ASSERT_TEST(new TST_QmuTokenParser());
ASSERT_TEST(new TST_VMeasurements());
ASSERT_TEST(new TST_QmuParserErrorMsg());
ASSERT_TEST(new TST_VLockGuard());
ASSERT_TEST(new TST_Misc());
ASSERT_TEST(new TST_VCommandLine());
ASSERT_TEST(new TST_TSTranslation());
ASSERT_TEST(new TST_VAbstractCurve());
ASSERT_TEST(new TST_VCubicBezierPath());
return status;
}