--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-07-18 20:56:42 +02:00
commit fbe7d2ef65
2 changed files with 8 additions and 4 deletions

View File

@ -31,6 +31,7 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QPainterPath> #include <QPainterPath>
#include <QFont>
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
# include "../vmisc/vmath.h" # include "../vmisc/vmath.h"
@ -125,7 +126,7 @@ void VLayoutDetail::SetDetailLabelPoints(const QPointF& ptPos, qreal dWidth, qre
QPointF ptCenter(ptPos.x() + dWidth/2, ptPos.y() + dHeight/2); QPointF ptCenter(ptPos.x() + dWidth/2, ptPos.y() + dHeight/2);
QVector<QPointF> v; QVector<QPointF> v;
v << ptPos << QPointF(ptPos.x() + dWidth, ptPos.y()) << QPointF(ptPos.x() + dWidth, ptPos.y() + dHeight) v << ptPos << QPointF(ptPos.x() + dWidth, ptPos.y()) << QPointF(ptPos.x() + dWidth, ptPos.y() + dHeight)
<< QPointF(ptPos.x(), ptPos.y() + dHeight) << ptPos; << QPointF(ptPos.x(), ptPos.y() + dHeight);
for (int i = 0; i < v.count(); ++i) for (int i = 0; i < v.count(); ++i)
v[i] = RotatePoint(ptCenter, v[i], dAng); v[i] = RotatePoint(ptCenter, v[i], dAng);
d->detailLabel = RoundPoints(v); d->detailLabel = RoundPoints(v);
@ -144,7 +145,7 @@ void VLayoutDetail::SetPatternInfoPoints(const QPointF& ptPos, qreal dWidth, qre
QPointF ptCenter(ptPos.x() + dWidth/2, ptPos.y() + dHeight/2); QPointF ptCenter(ptPos.x() + dWidth/2, ptPos.y() + dHeight/2);
QVector<QPointF> v; QVector<QPointF> v;
v << ptPos << QPointF(ptPos.x() + dWidth, ptPos.y()) << QPointF(ptPos.x() + dWidth, ptPos.y() + dHeight) v << ptPos << QPointF(ptPos.x() + dWidth, ptPos.y()) << QPointF(ptPos.x() + dWidth, ptPos.y() + dHeight)
<< QPointF(ptPos.x(), ptPos.y() + dHeight) << ptPos; << QPointF(ptPos.x(), ptPos.y() + dHeight);
for (int i = 0; i < v.count(); ++i) for (int i = 0; i < v.count(); ++i)
v[i] = RotatePoint(ptCenter, v[i], dAng); v[i] = RotatePoint(ptCenter, v[i], dAng);
d->patternInfo = RoundPoints(v); d->patternInfo = RoundPoints(v);
@ -461,6 +462,7 @@ QPainterPath VLayoutDetail::ContourPath() const
if (d->detailLabel.count() > 0) if (d->detailLabel.count() > 0)
{ {
points = Map(d->detailLabel); points = Map(d->detailLabel);
points.push_back(points.at(0));
QPainterPath pathDet; QPainterPath pathDet;
pathDet.moveTo(points.at(0)); pathDet.moveTo(points.at(0));
@ -475,6 +477,7 @@ QPainterPath VLayoutDetail::ContourPath() const
if (d->patternInfo.count() > 0) if (d->patternInfo.count() > 0)
{ {
points = Map(d->patternInfo); points = Map(d->patternInfo);
points.push_back(points.at(0));
QPainterPath pathDet; QPainterPath pathDet;
pathDet.moveTo(points.at(0)); pathDet.moveTo(points.at(0));
@ -527,7 +530,7 @@ void VLayoutDetail::SetMirror(bool value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QPointF VLayoutDetail::RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng) QPointF VLayoutDetail::RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng) const
{ {
QPointF ptDest; QPointF ptDest;
QPointF ptRel = pt - ptCenter; QPointF ptRel = pt - ptCenter;
@ -536,3 +539,4 @@ QPointF VLayoutDetail::RotatePoint(const QPointF &ptCenter, const QPointF& pt, q
return ptDest + ptCenter; return ptDest + ptCenter;
} }

View File

@ -93,7 +93,7 @@ private:
QVector<QPointF> Map(const QVector<QPointF> &points) const; QVector<QPointF> Map(const QVector<QPointF> &points) const;
static QVector<QPointF> RoundPoints(const QVector<QPointF> &points); static QVector<QPointF> RoundPoints(const QVector<QPointF> &points);
QPointF RotatePoint(const QPointF& ptCenter, const QPointF& pt, qreal dAng); QPointF RotatePoint(const QPointF& ptCenter, const QPointF& pt, qreal dAng) const;
}; };
Q_DECLARE_TYPEINFO(VLayoutDetail, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(VLayoutDetail, Q_MOVABLE_TYPE);