57 #include "../vmisc/def.h"
58 #include "../vmisc/vmath.h"
59 #include "../ifc/ifcdef.h"
82 #ifdef Q_COMPILER_RVALUE_REFS
84 { Swap(arc);
return *
this; }
90 VArc::VArc (
const VPointF ¢er, qreal radius,
const QString &formulaRadius, qreal f1,
const QString &formulaF1,
91 qreal f2,
const QString &formulaF2, quint32 idObject,
Draw mode)
93 d (new
VArcData(radius, formulaRadius))
108 const QString &formulaRadius, qreal f1,
const QString &formulaF1, quint32 idObject,
Draw mode)
110 d (new
VArcData(radius, formulaRadius))
159 const qreal f1 = QLineF(
static_cast<QPointF
>(center), p1).angle();
160 const qreal f2 = QLineF(
static_cast<QPointF
>(center), p2).angle();
179 const qreal f1 = QLineF(
static_cast<QPointF
>(center), p1).angle();
180 const qreal f2 = QLineF(
static_cast<QPointF
>(center), p2).angle();
199 const qreal f1 = QLineF(
static_cast<QPointF
>(center), p1).angle();
200 const qreal f2 = QLineF(
static_cast<QPointF
>(center), p2).angle();
222 qreal length =
d->radius * qDegreesToRadians(
AngleArc());
239 QLineF centerP1(
static_cast<QPointF
>(
GetCenter()), p1);
241 return centerP1.p2();
252 QLineF centerP2(
static_cast<QPointF
>(
GetCenter()), p2);
254 return centerP2.p2();
273 if (qFuzzyIsNull(angle))
275 points.append(pStart);
279 if (angle > 360 || angle < 0)
281 QLineF dummy(0,0, 100, 0);
282 dummy.setAngle(angle);
283 angle = dummy.angle();
286 const qreal angleInterpolation = 45;
287 const int sections = qFloor(angle / angleInterpolation);
288 for (
int i = 0; i < sections; ++i)
290 sectionAngle.append(angleInterpolation);
293 const qreal tail = angle - sections * angleInterpolation;
296 sectionAngle.append(tail);
300 for (
int i = 0; i < sectionAngle.size(); ++i)
302 const qreal lDistance =
GetRadius() * 4.0/3.0 * qTan(qDegreesToRadians(sectionAngle.at(i)) * 0.25);
304 const QPointF center =
static_cast<QPointF
>(
GetCenter());
306 QLineF lineP1P2(pStart, center);
307 lineP1P2.setAngle(lineP1P2.angle() - 90.0);
308 lineP1P2.setLength(lDistance);
310 QLineF lineP4P3(center, pStart);
311 lineP4P3.setAngle(lineP4P3.angle() + sectionAngle.at(i));
313 lineP4P3 = QLineF(lineP4P3.p2(), center);
314 lineP4P3.setAngle(lineP4P3.angle() + 90.0);
315 lineP4P3.setLength(lDistance);
319 if (not splPoints.isEmpty() && i != sectionAngle.size() - 1)
321 splPoints.removeLast();
325 pStart = lineP4P3.p1();
335 if (points.size() >= 2)
337 for (
int i=0; i < points.size()-1; ++i)
339 QLineF segment = QLineF(points.at(i), points.at(i+1));
340 if (segment.length() > 0)
342 lines.append(segment);
363 if (qAbs(fullLength) <= minLength)
376 length = fullLength + length;
380 line.setAngle(line.angle() + qRadiansToDegrees(length/
d->radius));
386 length = fullLength + length;
390 line.setAngle(line.angle() - qRadiansToDegrees(qAbs(length)/
d->radius));
410 return this->
CutArc(length, segment1, segment2);
441 qreal arcAngle = qAbs(qRadiansToDegrees(length/
d->radius));
445 arcAngle = arcAngle * -1;
448 QLineF startAngle(0, 0, 100, 0);
451 SetFormulaF2(QString().number(startAngle.angle()), startAngle.angle());
467 return d->formulaRadius;
473 d->formulaRadius = formula;
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)
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
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
VArc class for anticlockwise arc.
QPointF GetP2() const
GetP2 return point associated with end angle.
virtual void FindF2(qreal length) Q_DECL_OVERRIDE
VArc()
VArc default constructor.
virtual ~VArc() Q_DECL_OVERRIDE
QPointF CutArc(qreal length, VArc &segment1, VArc &segment2) const
CutArc cut arc into two segments.
virtual void CreateName() Q_DECL_OVERRIDE
VArc Move(qreal length, qreal angle, const QString &prefix=QString()) const
QVector< QLineF > getSegments() const
virtual qreal GetLength() const Q_DECL_OVERRIDE
GetLength return arc length.
VArc Flip(const QLineF &axis, const QString &prefix=QString()) const
QString GetFormulaRadius() const
GetRadius return arc radius.
VArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix=QString()) const
VArc & operator=(const VArc &arc)
operator = assignment operator
qreal GetRadius() const
GetRadius return formula for radius.
void Swap(VArc &arc) Q_DECL_NOTHROW
VArc constructor.
QPointF GetP1() const
GetP1 return point associated with start angle.
virtual QVector< QPointF > getPoints() const Q_DECL_OVERRIDE
GetPoints return list of points needed for drawing arc.
void SetFormulaRadius(const QString &formula, qreal value)
QSharedDataPointer< VArcData > d
virtual QString name() const
name return name graphical object.
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.
static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees)
static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle)
VPointF Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix=QString()) const
VPointF Flip(const QLineF &axis, const QString &prefix=QString()) const
VPointF Move(qreal length, qreal angle, const QString &prefix=QString()) const
static QPointF FlipPF(const QLineF &axis, const QPointF &point)
VSpline class that implements the spline.
virtual QVector< QPointF > getPoints() const Q_DECL_OVERRIDE
GetPoints return list with spline points.
double ToPixel(double val, const Unit &unit)