33 #include <QPainterPath>
35 #include "../vmisc/def.h"
36 #include "../vmisc/vmath.h"
37 #include "../ifc/ifcdef.h"
38 #include "../vmisc/vabstractapplication.h"
43 #ifdef Q_COMPILER_RVALUE_REFS
68 const QString &formulaRadius2, qreal f1,
const QString &formulaF1, qreal f2,
69 const QString &formulaF2, qreal rotationAngle,
const QString &formulaRotationAngle,
70 quint32 idObject,
Draw mode)
72 d (new
VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
88 qreal radius2,
const QString &formulaRadius1,
const QString &formulaRadius2, qreal f1,
89 const QString &formulaF1, qreal rotationAngle,
const QString &formulaRotationAngle,
90 quint32 idObject,
Draw mode)
92 d (new
VEllipticalArcData(radius1, radius2, formulaRadius1, formulaRadius2, rotationAngle, formulaRotationAngle))
137 originPoint =
d->m_transform.inverted().map(originPoint);
139 QTransform t =
d->m_transform;
140 t.translate(originPoint.x(), originPoint.y());
141 t.rotate(
IsFlipped() ? degrees : -degrees);
142 t.translate(-originPoint.x(), -originPoint.y());
173 const VPointF center = oldCenter.
Move(length, angle);
175 const QPointF position =
d->m_transform.inverted().map(center.
toQPointF()) -
176 d->m_transform.inverted().map(oldCenter.
toQPointF());
178 QTransform t =
d->m_transform;
179 t.translate(position.x(), position.y());
207 length = length * -1;
236 return d->m_transform;
242 d->m_transform = combine ?
d->m_transform * matrix : matrix;
249 const QPointF p =
d->m_transform.map(center.
toQPointF());
268 QLineF line(0, 0, 100, 0);
269 line.setAngle(angle);
273 const qreal k = qSqrt(a*a + b*b);
280 QPointF p(line.p2().x() / k, line.p2().y() / k);
281 QLineF line2(QPointF(), p);
296 QRectF box(center.x() -
d->radius1, center.y() -
d->radius2,
d->radius1*2,
d->radius2*2);
298 QLineF startLine(center.x(), center.y(), center.x() +
d->radius1, center.y());
299 QLineF endLine = startLine;
303 qreal sweepAngle = startLine.angleTo(endLine);
305 if (qFuzzyIsNull(sweepAngle))
311 path.moveTo(
GetP1());
313 path.moveTo(
GetP2());
315 QTransform t =
d->m_transform;
316 t.translate(center.x(), center.y());
318 t.translate(-center.x(), -center.y());
324 if (not subpath.isEmpty())
326 polygon = path.toSubpathPolygons().first();
329 polygon.removeFirst();
363 if (fullLength <= minLength)
370 const qreal maxLength = fullLength - minLength;
372 if (length < minLength)
376 else if (length > maxLength)
403 return this->
CutArc(length, arc1, arc2);
443 radius1.setAngle(radius1.angle() + gap);
444 qreal endAngle = radius1.angle();
453 while (qAbs(bezLength - length) > eps)
460 if (bezLength > length)
462 radius1.setAngle(endAngle - qAbs(gap));
466 radius1.setAngle(endAngle + qAbs(gap));
468 endAngle = radius1.angle();
479 const qreal h = qPow(
d->radius1 -
d->radius2, 2) / qPow(
d->radius1 +
d->radius2, 2);
480 const qreal ellipseLength = M_PI * (
d->radius1 +
d->radius2) * (1+3*h/(10+qSqrt(4-3*h)));
481 return ellipseLength;
491 return d->formulaRadius1;
501 return d->formulaRadius2;
511 return d->formulaRotationAngle;
517 d->formulaRadius1 = formula;
524 d->formulaRadius2 = formula;
531 d->formulaRotationAngle = formula;
532 d->rotationAngle = value;
562 return d->rotationAngle;
570 if (qFuzzyIsNull(endAngle) ||
579 endAngle = qRadiansToDegrees(qAtan2(
d->radius1 * qSin(qDegreesToRadians(endAngle)),
580 d->radius2 * qCos(qDegreesToRadians(endAngle))));
void Swap(VAbstractArc &arc) Q_DECL_NOTHROW
virtual VPointF GetCenter() const
QString GetFormulaF1() const
VAbstractArc & operator=(const VAbstractArc &arc)
QString GetFormulaF2() const
void SetFormulaF2(const QString &formula, qreal value)
void SetFormulaLength(const QString &formula, qreal value)
virtual qreal GetEndAngle() const Q_DECL_OVERRIDE
virtual qreal GetStartAngle() const Q_DECL_OVERRIDE
void SetFlipped(bool value)
QString getLineWeight() const
getLineWeight return weight of the lines
static qreal PathLength(const QVector< QPointF > &path)
void SetPenStyle(const QString &penStyle)
void setLineColor(const QString &color)
void setLineWeight(const QString &lineWeight)
setLineWeight set weight of the lines
QString GetPenStyle() const
quint32 GetDuplicate() const
QString getLineColor() const
VEllipticalArc Flip(const QLineF &axis, const QString &prefix=QString()) const
qreal GetRadius2() const
GetRadius2 return elliptical arc minor radius.
QString GetFormulaRadius2() const
GetFormulaRadius2 return formula for minor radius.
VEllipticalArc Rotate(QPointF originPoint, qreal degrees, const QString &prefix=QString()) const
VEllipticalArc & operator=(const VEllipticalArc &arc)
operator = assignment operator
virtual qreal GetStartAngle() const Q_DECL_OVERRIDE
static qreal normalizeAngle(qreal angle)
QPointF GetP1() const
GetP1 return point associated with start angle.
VEllipticalArc Move(qreal length, qreal angle, const QString &prefix=QString()) const
QString GetFormulaRadius1() const
GetFormulaRadius1 return formula for major radius.
virtual VPointF GetCenter() const Q_DECL_OVERRIDE
void SetFormulaRadius1(const QString &formula, qreal value)
VEllipticalArc()
VEllipticalArc default constructor.
virtual ~VEllipticalArc() Q_DECL_OVERRIDE
QPointF CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const
CutArc cut arc into two arcs.
qreal GetRadius1() const
GetRadius1 return elliptical arc major radius.
QSharedDataPointer< VEllipticalArcData > d
virtual QVector< QPointF > getPoints() const Q_DECL_OVERRIDE
GetPoints return list of points needed for drawing arc.
virtual void FindF2(qreal length) Q_DECL_OVERRIDE
void setTransform(const QTransform &matrix, bool combine=false)
QString GetFormulaRotationAngle() const
GetFormulaRotationAngle return formula for rotation angle.
void SetFormulaRotationAngle(const QString &formula, qreal value)
virtual qreal GetEndAngle() const Q_DECL_OVERRIDE
QPointF getPoint(qreal angle) const
GetPoint return point associated with angle.
QPointF GetP2() const
GetP2 return point associated with end angle.
qreal GetRotationAngle() const
GetRotationAngle return rotation angle.
QTransform getTransform() const
virtual qreal GetLength() const Q_DECL_OVERRIDE
GetLength return arc length.
void SetFormulaRadius2(const QString &formula, qreal value)
qreal getRealEndAngle() const
void Swap(VEllipticalArc &arc) Q_DECL_NOTHROW
virtual void CreateName() Q_DECL_OVERRIDE
virtual QString name() const
name return name graphical object.
static QTransform flipTransform(const QLineF &axis)
quint32 getIdObject() const
getIdObject return parent id.
void setName(const QString &name)
setName set name graphical object.
Draw getMode() const
getMode return mode creation.
quint32 id() const
id return id object.
The VPointF class keep data of point.
void setX(const qreal &value)
setX set x coordinate
void setY(const qreal &value)
setY set y coordinate
QPointF toQPointF() const
VPointF Move(qreal length, qreal angle, const QString &prefix=QString()) const
double ToPixel(double val, const Unit &unit)
static Q_REQUIRED_RESULT bool VFuzzyComparePossibleNulls(double p1, double p2)
static Q_REQUIRED_RESULT bool VFuzzyComparePoints(const QPointF &p1, const QPointF &p2, qreal accuracy=accuracyPointOnLine)