Refactoring VArc and VEllipticalArc classes.
--HG-- branch : feature
This commit is contained in:
parent
a7c4cc7aaf
commit
8713c628dc
208
src/libs/vgeometry/vabstractarc.cpp
Normal file
208
src/libs/vgeometry/vabstractarc.cpp
Normal 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 ¢er, 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 ¢er, 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 ¢er,
|
||||||
|
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 ¢er, 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;
|
||||||
|
}
|
80
src/libs/vgeometry/vabstractarc.h
Normal file
80
src/libs/vgeometry/vabstractarc.h
Normal 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 ¢er, qreal f1, const QString &formulaF1, qreal f2,
|
||||||
|
const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||||
|
VAbstractArc (const GOType &type, const VPointF ¢er, qreal f1, qreal f2, quint32 idObject = 0,
|
||||||
|
Draw mode = Draw::Calculation);
|
||||||
|
VAbstractArc (const GOType &type, const QString &formulaLength, const VPointF ¢er, qreal f1,
|
||||||
|
const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||||
|
VAbstractArc (const GOType &type, const VPointF ¢er, 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
|
148
src/libs/vgeometry/vabstractarc_p.h
Normal file
148
src/libs/vgeometry/vabstractarc_p.h
Normal 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 ¢er, qreal f1, const QString &formulaF1, qreal f2, const QString &formulaF2);
|
||||||
|
VAbstractArcData(const QString &formulaLength, VPointF center, qreal f1, QString formulaF1);
|
||||||
|
VAbstractArcData(const VPointF ¢er, qreal f1);
|
||||||
|
VAbstractArcData(const VPointF ¢er, 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 ¢er, 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 ¢er, qreal f1)
|
||||||
|
: f1(f1),
|
||||||
|
formulaF1(QString().number(f1)),
|
||||||
|
f2(0),
|
||||||
|
formulaF2("0"),
|
||||||
|
center(center),
|
||||||
|
isFlipped(false),
|
||||||
|
formulaLength()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VAbstractArcData::VAbstractArcData(const VPointF ¢er, 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
|
|
@ -42,7 +42,8 @@
|
||||||
* @brief VArc default constructor.
|
* @brief VArc default constructor.
|
||||||
*/
|
*/
|
||||||
VArc::VArc ()
|
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 f1 start angle (degree).
|
||||||
* @param f2 end angle (degree).
|
* @param f2 end angle (degree).
|
||||||
*/
|
*/
|
||||||
VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
|
VArc::VArc (const VPointF ¢er, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
|
||||||
QString formulaF2, quint32 idObject, Draw mode)
|
qreal f2, const QString &formulaF2, quint32 idObject, Draw mode)
|
||||||
: VAbstractCurve(GOType::Arc, idObject, mode),
|
: VAbstractArc(GOType::Arc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
|
||||||
d (new VArcData(center, radius, formulaRadius, f1, formulaF1, f2, formulaF2))
|
d (new VArcData(radius, formulaRadius))
|
||||||
{
|
{
|
||||||
CreateName();
|
CreateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VArc::VArc(VPointF center, qreal radius, qreal f1, qreal f2)
|
VArc::VArc(const VPointF ¢er, qreal radius, qreal f1, qreal f2)
|
||||||
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1, f2))
|
: VAbstractArc(GOType::Arc, center, f1, f2, NULL_ID, Draw::Calculation),
|
||||||
|
d (new VArcData(radius))
|
||||||
{
|
{
|
||||||
CreateName();
|
CreateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VArc::VArc(qreal length, QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1,
|
VArc::VArc(qreal length, const QString &formulaLength, const VPointF ¢er, qreal radius,
|
||||||
QString formulaF1, quint32 idObject, Draw mode)
|
const QString &formulaRadius, qreal f1, const QString &formulaF1, quint32 idObject, Draw mode)
|
||||||
: VAbstractCurve(GOType::Arc, idObject, mode),
|
: VAbstractArc(GOType::Arc, formulaLength, center, f1, formulaF1, idObject, mode),
|
||||||
d (new VArcData(formulaLength, center, radius, formulaRadius, f1, formulaF1))
|
d (new VArcData(radius, formulaRadius))
|
||||||
{
|
{
|
||||||
CreateName();
|
CreateName();
|
||||||
FindF2(length);
|
FindF2(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VArc::VArc(qreal length, VPointF center, qreal radius, qreal f1)
|
VArc::VArc(qreal length, const VPointF ¢er, qreal radius, qreal f1)
|
||||||
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1))
|
: VAbstractArc(GOType::Arc, center, f1, NULL_ID, Draw::Calculation),
|
||||||
|
d (new VArcData(radius))
|
||||||
{
|
{
|
||||||
CreateName();
|
CreateName();
|
||||||
FindF2(length);
|
FindF2(length);
|
||||||
|
@ -92,7 +95,7 @@ VArc::VArc(qreal length, VPointF center, qreal radius, qreal f1)
|
||||||
* @param arc arc
|
* @param arc arc
|
||||||
*/
|
*/
|
||||||
VArc::VArc(const VArc &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;
|
return *this;
|
||||||
}
|
}
|
||||||
VAbstractCurve::operator=(arc);
|
VAbstractArc::operator=(arc);
|
||||||
d = arc.d;
|
d = arc.d;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +140,7 @@ VArc::~VArc()
|
||||||
qreal VArc::GetLength() const
|
qreal VArc::GetLength() const
|
||||||
{
|
{
|
||||||
qreal length = (M_PI * d->radius)/180 * AngleArc();
|
qreal length = (M_PI * d->radius)/180 * AngleArc();
|
||||||
if (d->isFlipped)
|
if (IsFlipped())
|
||||||
{
|
{
|
||||||
length *= -1;
|
length *= -1;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +157,7 @@ QPointF VArc::GetP1() const
|
||||||
{
|
{
|
||||||
QPointF p1 ( GetCenter().x () + d->radius, GetCenter().y () );
|
QPointF p1 ( GetCenter().x () + d->radius, GetCenter().y () );
|
||||||
QLineF centerP1(GetCenter().toQPointF(), p1);
|
QLineF centerP1(GetCenter().toQPointF(), p1);
|
||||||
centerP1.setAngle(d->f1);
|
centerP1.setAngle(GetStartAngle());
|
||||||
return centerP1.p2();
|
return centerP1.p2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,39 +170,10 @@ QPointF VArc::GetP2 () const
|
||||||
{
|
{
|
||||||
QPointF p2 ( GetCenter().x () + d->radius, GetCenter().y () );
|
QPointF p2 ( GetCenter().x () + d->radius, GetCenter().y () );
|
||||||
QLineF centerP2(GetCenter().toQPointF(), p2);
|
QLineF centerP2(GetCenter().toQPointF(), p2);
|
||||||
centerP2.setAngle(d->f2);
|
centerP2.setAngle(GetEndAngle());
|
||||||
return centerP2.p2();
|
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.
|
* @brief GetPoints return list of points needed for drawing arc.
|
||||||
|
@ -211,7 +185,7 @@ QVector<QPointF> VArc::GetPoints() const
|
||||||
QVector<qreal> sectionAngle;
|
QVector<qreal> sectionAngle;
|
||||||
|
|
||||||
QPointF pStart;
|
QPointF pStart;
|
||||||
d->isFlipped ? pStart = GetP2() : pStart = GetP1();
|
IsFlipped() ? pStart = GetP2() : pStart = GetP1();
|
||||||
|
|
||||||
{
|
{
|
||||||
qreal angle = AngleArc();
|
qreal angle = AngleArc();
|
||||||
|
@ -314,11 +288,11 @@ QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const
|
||||||
QLineF line(GetCenter().toQPointF(), GetP1());
|
QLineF line(GetCenter().toQPointF(), GetP1());
|
||||||
line.setAngle(line.angle()+n);
|
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());
|
QString().setNum(line.angle()), getIdObject(), getMode());
|
||||||
|
|
||||||
arc2 = VArc (d->center, d->radius, d->formulaRadius, line.angle(), QString().setNum(line.angle()), d->f2,
|
arc2 = VArc (GetCenter(), d->radius, d->formulaRadius, line.angle(), QString().setNum(line.angle()), GetEndAngle(),
|
||||||
d->formulaF2, getIdObject(), getMode());
|
GetFormulaF2(), getIdObject(), getMode());
|
||||||
return line.p2();
|
return line.p2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,34 +305,6 @@ QPointF VArc::CutArc(const qreal &length) const
|
||||||
return this->CutArc(length, arc1, arc2);
|
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()
|
void VArc::CreateName()
|
||||||
{
|
{
|
||||||
|
@ -380,7 +326,7 @@ void VArc::CreateName()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VArc::FindF2(qreal length)
|
void VArc::FindF2(qreal length)
|
||||||
{
|
{
|
||||||
length < 0 ? d->isFlipped = true : d->isFlipped = false;
|
SetFlipped(length < 0);
|
||||||
|
|
||||||
if (length >= MaxLength())
|
if (length >= MaxLength())
|
||||||
{
|
{
|
||||||
|
@ -389,16 +335,15 @@ void VArc::FindF2(qreal length)
|
||||||
|
|
||||||
qreal arcAngle = (qAbs(length)*180)/(M_PI*d->radius);
|
qreal arcAngle = (qAbs(length)*180)/(M_PI*d->radius);
|
||||||
|
|
||||||
if (d->isFlipped)
|
if (IsFlipped())
|
||||||
{
|
{
|
||||||
arcAngle = arcAngle * -1;
|
arcAngle = arcAngle * -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLineF startAngle(0, 0, 100, 0);
|
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();
|
SetFormulaF2(QString().number(startAngle.angle()), startAngle.angle());
|
||||||
d->formulaF2 = QString().number(d->f2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -407,60 +352,6 @@ qreal VArc::MaxLength() const
|
||||||
return M_2PI*d->radius;
|
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.
|
* @brief GetRadius return arc radius.
|
||||||
|
@ -487,32 +378,3 @@ qreal VArc::GetRadius() const
|
||||||
{
|
{
|
||||||
return d->radius;
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#ifndef VARC_H
|
#ifndef VARC_H
|
||||||
#define VARC_H
|
#define VARC_H
|
||||||
|
|
||||||
#include "vabstractcurve.h"
|
#include "vabstractarc.h"
|
||||||
#include "vpointf.h"
|
#include "vpointf.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
@ -39,56 +39,41 @@ class VArcData;
|
||||||
/**
|
/**
|
||||||
* @brief VArc class for anticlockwise arc.
|
* @brief VArc class for anticlockwise arc.
|
||||||
*/
|
*/
|
||||||
class VArc: public VAbstractCurve
|
class VArc: public VAbstractArc
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(VArc)
|
Q_DECLARE_TR_FUNCTIONS(VArc)
|
||||||
public:
|
public:
|
||||||
VArc ();
|
VArc ();
|
||||||
VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2,
|
VArc (const VPointF ¢er, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
|
||||||
QString formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
qreal f2, const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||||
VArc (VPointF center, qreal radius, qreal f1, qreal f2);
|
VArc (const VPointF ¢er, qreal radius, qreal f1, qreal f2);
|
||||||
VArc (qreal length, QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1,
|
VArc (qreal length, const QString &formulaLength, const VPointF ¢er, qreal radius, const QString &formulaRadius,
|
||||||
QString formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
qreal f1, const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
||||||
VArc (qreal length, VPointF center, qreal radius, qreal f1);
|
VArc (qreal length, const VPointF ¢er, qreal radius, qreal f1);
|
||||||
VArc(const VArc &arc);
|
VArc(const VArc &arc);
|
||||||
VArc& operator= (const VArc &arc);
|
VArc& operator= (const VArc &arc);
|
||||||
VArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
|
VArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
|
||||||
virtual ~VArc() Q_DECL_OVERRIDE;
|
virtual ~VArc() 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 GetFormulaRadius () const;
|
QString GetFormulaRadius () const;
|
||||||
void SetFormulaRadius (const QString &formula, qreal value);
|
void SetFormulaRadius (const QString &formula, qreal value);
|
||||||
qreal GetRadius () const;
|
qreal GetRadius () const;
|
||||||
|
|
||||||
VPointF GetCenter () const;
|
|
||||||
void SetCenter (const VPointF &value);
|
|
||||||
|
|
||||||
QString GetFormulaLength () const;
|
|
||||||
void SetFormulaLength (const QString &formula, qreal value);
|
|
||||||
qreal GetLength () const;
|
qreal GetLength () const;
|
||||||
|
|
||||||
QPointF GetP1() const;
|
QPointF GetP1() const;
|
||||||
QPointF GetP2 () const;
|
QPointF GetP2 () const;
|
||||||
qreal AngleArc() const;
|
|
||||||
QVector<QPointF> GetPoints () const;
|
QVector<QPointF> GetPoints () const;
|
||||||
|
|
||||||
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
|
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
|
||||||
QPointF CutArc (const qreal &length) 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;
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CreateName() Q_DECL_OVERRIDE;
|
virtual void CreateName() Q_DECL_OVERRIDE;
|
||||||
|
virtual void FindF2(qreal length) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VArcData> d;
|
QSharedDataPointer<VArcData> d;
|
||||||
|
|
||||||
void FindF2(qreal length);
|
|
||||||
|
|
||||||
qreal MaxLength() const;
|
qreal MaxLength() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <QSharedData>
|
#include <QSharedData>
|
||||||
#include "vgeometrydef.h"
|
#include "vgeometrydef.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "vpointf.h"
|
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
@ -42,72 +41,48 @@
|
||||||
class VArcData : public QSharedData
|
class VArcData : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
VArcData();
|
||||||
VArcData ()
|
VArcData(qreal radius, QString formulaRadius);
|
||||||
: f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()),
|
VArcData(qreal radius);
|
||||||
center(VPointF()), isFlipped(false), formulaLength()
|
VArcData(const VArcData &arc);
|
||||||
{}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual ~VArcData();
|
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. */
|
/** @brief radius arc radius. */
|
||||||
qreal radius;
|
qreal radius;
|
||||||
|
|
||||||
/** @brief formulaRadius formula for arc radius. */
|
/** @brief formulaRadius formula for arc radius. */
|
||||||
QString formulaRadius;
|
QString formulaRadius;
|
||||||
|
|
||||||
/** @brief center center point of arc. */
|
|
||||||
VPointF center;
|
|
||||||
|
|
||||||
bool isFlipped;
|
|
||||||
|
|
||||||
QString formulaLength;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VArcData &operator=(const VArcData &) Q_DECL_EQ_DELETE;
|
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()
|
VArcData::~VArcData()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
* @brief VEllipticalArc default constructor.
|
* @brief VEllipticalArc default constructor.
|
||||||
*/
|
*/
|
||||||
VEllipticalArc::VEllipticalArc()
|
VEllipticalArc::VEllipticalArc()
|
||||||
: VAbstractCurve(GOType::EllipticalArc), d (new VEllipticalArcData)
|
: VAbstractArc(GOType::EllipticalArc), d (new VEllipticalArcData)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -54,9 +54,8 @@ VEllipticalArc::VEllipticalArc()
|
||||||
VEllipticalArc::VEllipticalArc (const VPointF ¢er, qreal radius1, qreal radius2, const QString &formulaRadius1,
|
VEllipticalArc::VEllipticalArc (const VPointF ¢er, qreal radius1, qreal radius2, const QString &formulaRadius1,
|
||||||
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
|
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
|
||||||
const QString &formulaF2, qreal rotationAngle, quint32 idObject, Draw mode)
|
const QString &formulaF2, qreal rotationAngle, quint32 idObject, Draw mode)
|
||||||
: VAbstractCurve(GOType::EllipticalArc, idObject, mode),
|
: VAbstractArc(GOType::EllipticalArc, center, f1, formulaF1, f2, formulaF2, idObject, mode),
|
||||||
d (new VEllipticalArcData(center, radius1, radius2, formulaRadius1, formulaRadius2, f1, formulaF1, f2, formulaF2,
|
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle))
|
||||||
rotationAngle))
|
|
||||||
{
|
{
|
||||||
CreateName();
|
CreateName();
|
||||||
}
|
}
|
||||||
|
@ -64,8 +63,8 @@ VEllipticalArc::VEllipticalArc (const VPointF ¢er, qreal radius1, qreal radi
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VEllipticalArc::VEllipticalArc(const VPointF ¢er, qreal radius1, qreal radius2, qreal f1, qreal f2,
|
VEllipticalArc::VEllipticalArc(const VPointF ¢er, qreal radius1, qreal radius2, qreal f1, qreal f2,
|
||||||
qreal rotationAngle)
|
qreal rotationAngle)
|
||||||
: VAbstractCurve(GOType::EllipticalArc, NULL_ID, Draw::Calculation),
|
: VAbstractArc(GOType::EllipticalArc, center, f1, f2, NULL_ID, Draw::Calculation),
|
||||||
d (new VEllipticalArcData(center, radius1, radius2, f1, f2, rotationAngle))
|
d (new VEllipticalArcData(radius1, radius2, rotationAngle))
|
||||||
{
|
{
|
||||||
CreateName();
|
CreateName();
|
||||||
}
|
}
|
||||||
|
@ -74,9 +73,8 @@ VEllipticalArc::VEllipticalArc(const VPointF ¢er, qreal radius1, qreal radiu
|
||||||
VEllipticalArc::VEllipticalArc(qreal length, const QString &formulaLength, const VPointF ¢er, qreal radius1,
|
VEllipticalArc::VEllipticalArc(qreal length, const QString &formulaLength, const VPointF ¢er, qreal radius1,
|
||||||
qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
|
qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
|
||||||
const QString &formulaF1, qreal rotationAngle, quint32 idObject, Draw mode)
|
const QString &formulaF1, qreal rotationAngle, quint32 idObject, Draw mode)
|
||||||
: VAbstractCurve(GOType::EllipticalArc, idObject, mode),
|
: VAbstractArc(GOType::EllipticalArc, formulaLength, center, f1, formulaF1, idObject, mode),
|
||||||
d (new VEllipticalArcData(formulaLength, center, radius1, radius2, formulaRadius1, formulaRadius2, f1, formulaF1,
|
d (new VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle))
|
||||||
rotationAngle))
|
|
||||||
{
|
{
|
||||||
CreateName();
|
CreateName();
|
||||||
FindF2(length);
|
FindF2(length);
|
||||||
|
@ -85,8 +83,8 @@ VEllipticalArc::VEllipticalArc(qreal length, const QString &formulaLength, const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VEllipticalArc::VEllipticalArc(qreal length, const VPointF ¢er, qreal radius1, qreal radius2, qreal f1,
|
VEllipticalArc::VEllipticalArc(qreal length, const VPointF ¢er, qreal radius1, qreal radius2, qreal f1,
|
||||||
qreal rotationAngle)
|
qreal rotationAngle)
|
||||||
: VAbstractCurve(GOType::EllipticalArc, NULL_ID, Draw::Calculation),
|
: VAbstractArc(GOType::EllipticalArc, center, f1, NULL_ID, Draw::Calculation),
|
||||||
d (new VEllipticalArcData(center, radius1, radius2, f1, rotationAngle))
|
d (new VEllipticalArcData(radius1, radius2, rotationAngle))
|
||||||
{
|
{
|
||||||
CreateName();
|
CreateName();
|
||||||
FindF2(length);
|
FindF2(length);
|
||||||
|
@ -98,7 +96,7 @@ VEllipticalArc::VEllipticalArc(qreal length, const VPointF ¢er, qreal radius
|
||||||
* @param arc arc
|
* @param arc arc
|
||||||
*/
|
*/
|
||||||
VEllipticalArc::VEllipticalArc(const VEllipticalArc &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;
|
return *this;
|
||||||
}
|
}
|
||||||
VAbstractCurve::operator=(arc);
|
VAbstractArc::operator=(arc);
|
||||||
d = arc.d;
|
d = arc.d;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +142,7 @@ qreal VEllipticalArc::GetLength() const
|
||||||
{
|
{
|
||||||
qreal length = PathLength(GetPoints());
|
qreal length = PathLength(GetPoints());
|
||||||
|
|
||||||
if (d->isFlipped)
|
if (IsFlipped())
|
||||||
{
|
{
|
||||||
length = length * -1;
|
length = length * -1;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +157,7 @@ qreal VEllipticalArc::GetLength() const
|
||||||
*/
|
*/
|
||||||
QPointF VEllipticalArc::GetP1() const
|
QPointF VEllipticalArc::GetP1() const
|
||||||
{
|
{
|
||||||
return GetPoint(d->f1);
|
return GetPoint(GetStartAngle());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -169,7 +167,7 @@ QPointF VEllipticalArc::GetP1() const
|
||||||
*/
|
*/
|
||||||
QPointF VEllipticalArc::GetP2 () const
|
QPointF VEllipticalArc::GetP2 () const
|
||||||
{
|
{
|
||||||
return GetPoint(d->f2);
|
return GetPoint(GetEndAngle());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -296,36 +294,6 @@ int VEllipticalArc::GetQuadransRad(qreal &rad)
|
||||||
return n;
|
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.
|
* @brief GetAngles return list of angles needed for drawing arc.
|
||||||
|
@ -338,7 +306,7 @@ QVector<qreal> VEllipticalArc::GetAngles() const
|
||||||
|
|
||||||
if (qFuzzyIsNull(angle))
|
if (qFuzzyIsNull(angle))
|
||||||
{// Return the array that includes one angle
|
{// Return the array that includes one angle
|
||||||
sectionAngle.append(d->f1);
|
sectionAngle.append(GetStartAngle());
|
||||||
return sectionAngle;
|
return sectionAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +343,7 @@ QVector<QPointF> VEllipticalArc::GetPoints() const
|
||||||
QVector<qreal> sectionAngle = GetAngles();
|
QVector<qreal> sectionAngle = GetAngles();
|
||||||
|
|
||||||
qreal currentAngle;
|
qreal currentAngle;
|
||||||
d->isFlipped ? currentAngle = GetEndAngle() : currentAngle = GetStartAngle();
|
IsFlipped() ? currentAngle = GetEndAngle() : currentAngle = GetStartAngle();
|
||||||
for (int i = 0; i < sectionAngle.size(); ++i)
|
for (int i = 0; i < sectionAngle.size(); ++i)
|
||||||
{
|
{
|
||||||
QPointF startPoint = GetPoint(currentAngle);
|
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
|
// 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,
|
arc1 = VEllipticalArc (len, QString().setNum(length), GetCenter(), d->radius1, d->radius2,
|
||||||
d->formulaRadius1, d->formulaRadius2, d->f1, d->formulaF1, d->rotationAngle,
|
d->formulaRadius1, d->formulaRadius2, GetStartAngle(), GetFormulaF1(), d->rotationAngle,
|
||||||
getIdObject(), getMode());
|
getIdObject(), getMode());
|
||||||
// the second arc has startAngle just like endAngle of the first arc
|
// the second arc has startAngle just like endAngle of the first arc
|
||||||
// and it has endAngle just like endAngle of the origin arc
|
// and it has endAngle just like endAngle of the origin arc
|
||||||
arc2 = VEllipticalArc (d->center, d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2,
|
arc2 = VEllipticalArc (GetCenter(), d->radius1, d->radius2, d->formulaRadius1, d->formulaRadius2,
|
||||||
arc1.GetEndAngle(), arc1.GetFormulaF2(), d->f2, d->formulaF2, d->rotationAngle,
|
arc1.GetEndAngle(), arc1.GetFormulaF2(), GetEndAngle(), GetFormulaF2(), d->rotationAngle,
|
||||||
getIdObject(), getMode());
|
getIdObject(), getMode());
|
||||||
return arc1.GetP1();
|
return arc1.GetP1();
|
||||||
}
|
}
|
||||||
|
@ -459,34 +427,6 @@ QPointF VEllipticalArc::CutArc(const qreal &length) const
|
||||||
return this->CutArc(length, arc1, arc2);
|
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()
|
void VEllipticalArc::CreateName()
|
||||||
{
|
{
|
||||||
|
@ -511,7 +451,7 @@ void VEllipticalArc::FindF2(qreal length)
|
||||||
qreal gap = 180;
|
qreal gap = 180;
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
{
|
{
|
||||||
d->isFlipped = true;
|
SetFlipped(true);
|
||||||
gap = -gap;
|
gap = -gap;
|
||||||
}
|
}
|
||||||
while (length > MaxLength())
|
while (length > MaxLength())
|
||||||
|
@ -523,7 +463,9 @@ void VEllipticalArc::FindF2(qreal length)
|
||||||
// first approximation of angle between start and end angles
|
// first approximation of angle between start and end angles
|
||||||
|
|
||||||
qreal endAngle = GetStartAngle() + gap;
|
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
|
qreal lenBez = GetLength(); // first approximation of length
|
||||||
|
|
||||||
|
@ -534,7 +476,6 @@ void VEllipticalArc::FindF2(qreal length)
|
||||||
gap = gap/2;
|
gap = gap/2;
|
||||||
if (gap < 0.0001)
|
if (gap < 0.0001)
|
||||||
{
|
{
|
||||||
d->f2 = endAngle;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (lenBez > length)
|
if (lenBez > length)
|
||||||
|
@ -546,11 +487,11 @@ void VEllipticalArc::FindF2(qreal length)
|
||||||
endAngle = endAngle + qAbs(gap);
|
endAngle = endAngle + qAbs(gap);
|
||||||
}
|
}
|
||||||
// we need to set d->f2, because we use it when we calculate GetLength
|
// we need to set d->f2, because we use it when we calculate GetLength
|
||||||
d->f2 = endAngle;
|
SetFormulaF2(QString::number(endAngle), endAngle);
|
||||||
lenBez = GetLength();
|
lenBez = GetLength();
|
||||||
}
|
}
|
||||||
d->formulaF2 = QString().number(d->f2);
|
SetFormulaF2(QString::number(endAngle), endAngle);
|
||||||
d->formulaLength = QString().number(qApp->fromPixel(lenBez));
|
SetFormulaLength(QString::number(qApp->fromPixel(lenBez)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -561,60 +502,6 @@ qreal VEllipticalArc::MaxLength() const
|
||||||
return ellipseLength;
|
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.
|
* @brief GetRadius return arc major radius.
|
||||||
|
@ -678,32 +565,3 @@ qreal VEllipticalArc::GetRadius2() const
|
||||||
{
|
{
|
||||||
return d->radius2;
|
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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -29,13 +29,13 @@
|
||||||
#ifndef VELLIPTICALARC_H
|
#ifndef VELLIPTICALARC_H
|
||||||
#define VELLIPTICALARC_H
|
#define VELLIPTICALARC_H
|
||||||
|
|
||||||
#include "vabstractcurve.h"
|
#include "vabstractarc.h"
|
||||||
#include "vpointf.h"
|
#include "vpointf.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
class VEllipticalArcData;
|
class VEllipticalArcData;
|
||||||
|
|
||||||
class VEllipticalArc : public VAbstractCurve
|
class VEllipticalArc : public VAbstractArc
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(VEllipticalArc)
|
Q_DECLARE_TR_FUNCTIONS(VEllipticalArc)
|
||||||
public:
|
public:
|
||||||
|
@ -56,14 +56,6 @@ public:
|
||||||
|
|
||||||
virtual ~VEllipticalArc() Q_DECL_OVERRIDE;
|
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;
|
|
||||||
|
|
||||||
qreal GetRotationAngle() const;
|
qreal GetRotationAngle() const;
|
||||||
|
|
||||||
QString GetFormulaRadius1 () const;
|
QString GetFormulaRadius1 () const;
|
||||||
|
@ -74,31 +66,25 @@ public:
|
||||||
void SetFormulaRadius2 (const QString &formula, qreal value);
|
void SetFormulaRadius2 (const QString &formula, qreal value);
|
||||||
qreal GetRadius2 () 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;
|
qreal GetLength () const;
|
||||||
|
|
||||||
QPointF GetP1() const;
|
QPointF GetP1() const;
|
||||||
QPointF GetP2() const;
|
QPointF GetP2() const;
|
||||||
|
|
||||||
qreal AngleArc() const;
|
|
||||||
QVector<qreal> GetAngles () const;
|
|
||||||
QVector<QPointF> GetPoints () const;
|
QVector<QPointF> GetPoints () const;
|
||||||
|
|
||||||
QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const;
|
QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const;
|
||||||
QPointF CutArc (const qreal &length) 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;
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CreateName() Q_DECL_OVERRIDE;
|
virtual void CreateName() Q_DECL_OVERRIDE;
|
||||||
|
virtual void FindF2(qreal length) Q_DECL_OVERRIDE;
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VEllipticalArcData> d;
|
QSharedDataPointer<VEllipticalArcData> d;
|
||||||
void FindF2(qreal length);
|
|
||||||
|
|
||||||
|
QVector<qreal> GetAngles () const;
|
||||||
qreal MaxLength() const;
|
qreal MaxLength() const;
|
||||||
QPointF GetPoint (qreal angle) const;
|
QPointF GetPoint (qreal angle) const;
|
||||||
|
|
||||||
static int GetQuadransRad(qreal &rad);
|
static int GetQuadransRad(qreal &rad);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,26 +14,13 @@ class VEllipticalArcData : public QSharedData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VEllipticalArcData ();
|
VEllipticalArcData ();
|
||||||
VEllipticalArcData (const VPointF ¢er, qreal radius1, qreal radius2, const QString &formulaRadius1,
|
VEllipticalArcData (qreal radius1, qreal radius2, const QString &formulaRadius1, const QString &formulaRadius2,
|
||||||
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
|
qreal rotationAngle);
|
||||||
const QString &formulaF2, qreal rotationAngle);
|
VEllipticalArcData(qreal radius1, qreal radius2, qreal rotationAngle);
|
||||||
VEllipticalArcData(const VPointF ¢er, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
|
|
||||||
VEllipticalArcData (const QString &formulaLength, const VPointF ¢er, qreal radius1, qreal radius2,
|
|
||||||
const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
|
|
||||||
const QString &formulaF1, qreal rotationAngle);
|
|
||||||
VEllipticalArcData(const VPointF ¢er, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
|
|
||||||
VEllipticalArcData(const VEllipticalArcData &arc);
|
VEllipticalArcData(const VEllipticalArcData &arc);
|
||||||
|
|
||||||
virtual ~VEllipticalArcData();
|
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. */
|
/** @brief radius1 elliptical arc major radius. */
|
||||||
qreal radius1;
|
qreal radius1;
|
||||||
/** @brief radius2 elliptical arc minor radius. */
|
/** @brief radius2 elliptical arc minor radius. */
|
||||||
|
@ -42,10 +29,6 @@ public:
|
||||||
QString formulaRadius1;
|
QString formulaRadius1;
|
||||||
/** @brief formulaRadius2 formula for elliptical arc minor radius. */
|
/** @brief formulaRadius2 formula for elliptical arc minor radius. */
|
||||||
QString formulaRadius2;
|
QString formulaRadius2;
|
||||||
/** @brief center center point of arc. */
|
|
||||||
VPointF center;
|
|
||||||
bool isFlipped;
|
|
||||||
QString formulaLength;
|
|
||||||
/** @brief rotationAngle in degree. */
|
/** @brief rotationAngle in degree. */
|
||||||
qreal rotationAngle;
|
qreal rotationAngle;
|
||||||
|
|
||||||
|
@ -55,105 +38,39 @@ private:
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VEllipticalArcData::VEllipticalArcData()
|
VEllipticalArcData::VEllipticalArcData()
|
||||||
: f1(0),
|
: radius1(0),
|
||||||
f2(0),
|
|
||||||
formulaF1(),
|
|
||||||
formulaF2(),
|
|
||||||
radius1(0),
|
|
||||||
radius2(0),
|
radius2(0),
|
||||||
formulaRadius1(),
|
formulaRadius1(),
|
||||||
formulaRadius2(),
|
formulaRadius2(),
|
||||||
center(),
|
|
||||||
isFlipped(false),
|
|
||||||
formulaLength(),
|
|
||||||
rotationAngle(0)
|
rotationAngle(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VEllipticalArcData::VEllipticalArcData(const VPointF ¢er, qreal radius1, qreal radius2,
|
VEllipticalArcData::VEllipticalArcData(qreal radius1, qreal radius2, const QString &formulaRadius1,
|
||||||
const QString &formulaRadius1, const QString &formulaRadius2, qreal f1,
|
const QString &formulaRadius2, qreal rotationAngle)
|
||||||
const QString &formulaF1, qreal f2, const QString &formulaF2,
|
: radius1(radius1),
|
||||||
qreal rotationAngle)
|
|
||||||
: f1(f1),
|
|
||||||
f2(f2),
|
|
||||||
formulaF1(formulaF1),
|
|
||||||
formulaF2(formulaF2),
|
|
||||||
radius1(radius1),
|
|
||||||
radius2(radius2),
|
radius2(radius2),
|
||||||
formulaRadius1(formulaRadius1),
|
formulaRadius1(formulaRadius1),
|
||||||
formulaRadius2(formulaRadius2),
|
formulaRadius2(formulaRadius2),
|
||||||
center(center),
|
|
||||||
isFlipped(false),
|
|
||||||
formulaLength(),
|
|
||||||
rotationAngle(rotationAngle)
|
rotationAngle(rotationAngle)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VEllipticalArcData::VEllipticalArcData(const VPointF ¢er, qreal radius1, qreal radius2, qreal f1, qreal f2,
|
VEllipticalArcData::VEllipticalArcData(qreal radius1, qreal radius2, qreal rotationAngle)
|
||||||
qreal rotationAngle)
|
: radius1(radius1),
|
||||||
: f1(f1),
|
|
||||||
f2(f2),
|
|
||||||
formulaF1(QString().number(f1)),
|
|
||||||
formulaF2(QString().number(f2)),
|
|
||||||
radius1(radius1),
|
|
||||||
radius2(radius2),
|
radius2(radius2),
|
||||||
formulaRadius1(QString().number(qApp->fromPixel(radius1))),
|
formulaRadius1(QString().number(qApp->fromPixel(radius1))),
|
||||||
formulaRadius2(QString().number(qApp->fromPixel(radius2))),
|
formulaRadius2(QString().number(qApp->fromPixel(radius2))),
|
||||||
center(center),
|
|
||||||
isFlipped(false),
|
|
||||||
formulaLength(),
|
|
||||||
rotationAngle(rotationAngle)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
VEllipticalArcData::VEllipticalArcData(const QString &formulaLength, const VPointF ¢er, 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 ¢er, 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)
|
rotationAngle(rotationAngle)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VEllipticalArcData::VEllipticalArcData(const VEllipticalArcData &arc)
|
VEllipticalArcData::VEllipticalArcData(const VEllipticalArcData &arc)
|
||||||
: QSharedData(arc),
|
: QSharedData(arc),
|
||||||
f1(arc.f1),
|
|
||||||
f2(arc.f2),
|
|
||||||
formulaF1(arc.formulaF1),
|
|
||||||
formulaF2(arc.formulaF2),
|
|
||||||
radius1(arc.radius1),
|
radius1(arc.radius1),
|
||||||
radius2(arc.radius2),
|
radius2(arc.radius2),
|
||||||
formulaRadius1(arc.formulaRadius1),
|
formulaRadius1(arc.formulaRadius1),
|
||||||
formulaRadius2(arc.formulaRadius2),
|
formulaRadius2(arc.formulaRadius2),
|
||||||
center(arc.center),
|
|
||||||
isFlipped(arc.isFlipped),
|
|
||||||
formulaLength(arc.formulaLength),
|
|
||||||
rotationAngle(arc.rotationAngle)
|
rotationAngle(arc.rotationAngle)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@ SOURCES += \
|
||||||
$$PWD/vcubicbezier.cpp \
|
$$PWD/vcubicbezier.cpp \
|
||||||
$$PWD/vabstractcubicbezier.cpp \
|
$$PWD/vabstractcubicbezier.cpp \
|
||||||
$$PWD/vabstractcubicbezierpath.cpp \
|
$$PWD/vabstractcubicbezierpath.cpp \
|
||||||
$$PWD/vcubicbezierpath.cpp
|
$$PWD/vcubicbezierpath.cpp \
|
||||||
|
$$PWD/vabstractarc.cpp
|
||||||
|
|
||||||
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
win32-msvc*:SOURCES += $$PWD/stable.cpp
|
||||||
|
|
||||||
|
@ -41,4 +42,6 @@ HEADERS += \
|
||||||
$$PWD/vabstractcubicbezier.h \
|
$$PWD/vabstractcubicbezier.h \
|
||||||
$$PWD/vabstractcubicbezierpath.h \
|
$$PWD/vabstractcubicbezierpath.h \
|
||||||
$$PWD/vcubicbezierpath.h \
|
$$PWD/vcubicbezierpath.h \
|
||||||
$$PWD/vcubicbezierpath_p.h
|
$$PWD/vcubicbezierpath_p.h \
|
||||||
|
$$PWD/vabstractarc.h \
|
||||||
|
$$PWD/vabstractarc_p.h
|
||||||
|
|
|
@ -63,27 +63,27 @@ int main(int argc, char** argv)
|
||||||
delete obj;
|
delete obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ASSERT_TEST(new TST_FindPoint());
|
ASSERT_TEST(new TST_FindPoint());
|
||||||
// ASSERT_TEST(new TST_VDetail());
|
ASSERT_TEST(new TST_VDetail());
|
||||||
// ASSERT_TEST(new TST_VPoster());
|
ASSERT_TEST(new TST_VPoster());
|
||||||
// ASSERT_TEST(new TST_VAbstractDetail());
|
ASSERT_TEST(new TST_VAbstractDetail());
|
||||||
// ASSERT_TEST(new TST_VSpline());
|
ASSERT_TEST(new TST_VSpline());
|
||||||
// ASSERT_TEST(new TST_NameRegExp());
|
ASSERT_TEST(new TST_NameRegExp());
|
||||||
// ASSERT_TEST(new TST_VLayoutDetail());
|
ASSERT_TEST(new TST_VLayoutDetail());
|
||||||
// ASSERT_TEST(new TST_VArc());
|
ASSERT_TEST(new TST_VArc());
|
||||||
ASSERT_TEST(new TST_VEllipticalArc());
|
ASSERT_TEST(new TST_VEllipticalArc());
|
||||||
// ASSERT_TEST(new TST_MeasurementRegExp());
|
ASSERT_TEST(new TST_MeasurementRegExp());
|
||||||
// ASSERT_TEST(new TST_TapeCommandLine());
|
ASSERT_TEST(new TST_TapeCommandLine());
|
||||||
// ASSERT_TEST(new TST_ValentinaCommandLine());
|
ASSERT_TEST(new TST_ValentinaCommandLine());
|
||||||
// ASSERT_TEST(new TST_QmuTokenParser());
|
ASSERT_TEST(new TST_QmuTokenParser());
|
||||||
// ASSERT_TEST(new TST_VMeasurements());
|
ASSERT_TEST(new TST_VMeasurements());
|
||||||
// ASSERT_TEST(new TST_QmuParserErrorMsg());
|
ASSERT_TEST(new TST_QmuParserErrorMsg());
|
||||||
// ASSERT_TEST(new TST_VLockGuard());
|
ASSERT_TEST(new TST_VLockGuard());
|
||||||
// ASSERT_TEST(new TST_Misc());
|
ASSERT_TEST(new TST_Misc());
|
||||||
// ASSERT_TEST(new TST_VCommandLine());
|
ASSERT_TEST(new TST_VCommandLine());
|
||||||
// ASSERT_TEST(new TST_TSTranslation());
|
ASSERT_TEST(new TST_TSTranslation());
|
||||||
// ASSERT_TEST(new TST_VAbstractCurve());
|
ASSERT_TEST(new TST_VAbstractCurve());
|
||||||
// ASSERT_TEST(new TST_VCubicBezierPath());
|
ASSERT_TEST(new TST_VCubicBezierPath());
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user