Labels are now shown on the layout, however I still need to figure out how to paste text into the labels
--HG-- branch : feature
This commit is contained in:
parent
25a58421cc
commit
fed323fc25
|
@ -37,6 +37,8 @@
|
|||
#include "dialogs/dialoglayoutprogress.h"
|
||||
#include "dialogs/dialogsavelayout.h"
|
||||
#include "../vlayout/vposter.h"
|
||||
#include "../vpatterndb/vpatternpiecedata.h"
|
||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
|
@ -472,6 +474,16 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *de
|
|||
det.SetCountourPoints(d.ContourPoints(pattern));
|
||||
det.SetSeamAllowencePoints(d.SeamAllowancePoints(pattern), d.getSeamAllowance(), d.getClosed());
|
||||
det.setName(d.getName());
|
||||
const VPatternPieceData& data = d.GetPatternPieceData();
|
||||
if (data.IsVisible() == true)
|
||||
{
|
||||
det.SetDetailLabelPoints(data.GetPos(), data.GetLabelWidth(), data.GetLabelHeight(), data.GetRotation());
|
||||
}
|
||||
const VPatternInfoGeometry& geom = d.GetPatternInfo();
|
||||
if (geom.IsVisible() == true)
|
||||
{
|
||||
det.SetPatternInfoPoints(geom.GetPos(), geom.GetLabelWidth(), geom.GetLabelHeight(), geom.GetRotation());
|
||||
}
|
||||
det.setWidth(qApp->toPixel(d.getWidth()));
|
||||
|
||||
listDetails.append(det);
|
||||
|
|
|
@ -112,6 +112,44 @@ QVector<QPointF> VLayoutDetail::GetLayoutAllowencePoints() const
|
|||
return Map(d->layoutAllowence);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VLayoutDetail::GetDetailLabelPoints() const
|
||||
{
|
||||
return d->detailLabel;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLayoutDetail::SetDetailLabelPoints(const QPointF& ptPos, qreal dWidth, qreal dHeight, qreal dRot)
|
||||
{
|
||||
qreal dAng = qDegreesToRadians(dRot);
|
||||
QPointF ptCenter(ptPos.x() + dWidth/2, ptPos.y() + dHeight/2);
|
||||
QVector<QPointF> v;
|
||||
v << ptPos << QPointF(ptPos.x() + dWidth, ptPos.y()) << QPointF(ptPos.x() + dWidth, ptPos.y() + dHeight)
|
||||
<< QPointF(ptPos.x(), ptPos.y() + dHeight) << ptPos;
|
||||
for (int i = 0; i < v.count(); ++i)
|
||||
v[i] = RotatePoint(ptCenter, v[i], dAng);
|
||||
d->detailLabel = RoundPoints(v);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VLayoutDetail::GetPatternInfoPoints() const
|
||||
{
|
||||
return d->patternInfo;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VLayoutDetail::SetPatternInfoPoints(const QPointF& ptPos, qreal dWidth, qreal dHeight, qreal dRot)
|
||||
{
|
||||
qreal dAng = qDegreesToRadians(dRot);
|
||||
QPointF ptCenter(ptPos.x() + dWidth/2, ptPos.y() + dHeight/2);
|
||||
QVector<QPointF> v;
|
||||
v << ptPos << QPointF(ptPos.x() + dWidth, ptPos.y()) << QPointF(ptPos.x() + dWidth, ptPos.y() + dHeight)
|
||||
<< QPointF(ptPos.x(), ptPos.y() + dHeight) << ptPos;
|
||||
for (int i = 0; i < v.count(); ++i)
|
||||
v[i] = RotatePoint(ptCenter, v[i], dAng);
|
||||
d->patternInfo = RoundPoints(v);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QTransform VLayoutDetail::GetMatrix() const
|
||||
{
|
||||
|
@ -420,6 +458,34 @@ QPainterPath VLayoutDetail::ContourPath() const
|
|||
path.setFillRule(Qt::WindingFill);
|
||||
}
|
||||
|
||||
if (d->detailLabel.count() > 0)
|
||||
{
|
||||
points = Map(d->detailLabel);
|
||||
|
||||
QPainterPath pathDet;
|
||||
pathDet.moveTo(points.at(0));
|
||||
for (qint32 i = 1; i < points.count(); ++i)
|
||||
{
|
||||
pathDet.lineTo(points.at(i));
|
||||
}
|
||||
|
||||
path.addPath(pathDet);
|
||||
}
|
||||
|
||||
if (d->patternInfo.count() > 0)
|
||||
{
|
||||
points = Map(d->patternInfo);
|
||||
|
||||
QPainterPath pathDet;
|
||||
pathDet.moveTo(points.at(0));
|
||||
for (qint32 i = 1; i < points.count(); ++i)
|
||||
{
|
||||
pathDet.lineTo(points.at(i));
|
||||
}
|
||||
|
||||
path.addPath(pathDet);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -459,3 +525,14 @@ void VLayoutDetail::SetMirror(bool value)
|
|||
{
|
||||
d->mirror = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VLayoutDetail::RotatePoint(const QPointF &ptCenter, const QPointF& pt, qreal dAng)
|
||||
{
|
||||
QPointF ptDest;
|
||||
QPointF ptRel = pt - ptCenter;
|
||||
ptDest.setX(cos(dAng)*ptRel.x() - sin(dAng)*ptRel.y());
|
||||
ptDest.setY(sin(dAng)*ptRel.x() + cos(dAng)*ptRel.y());
|
||||
|
||||
return ptDest + ptCenter;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,12 @@ public:
|
|||
QVector<QPointF> GetLayoutAllowencePoints() const;
|
||||
void SetLayoutAllowencePoints();
|
||||
|
||||
QVector<QPointF> GetDetailLabelPoints() const;
|
||||
void SetDetailLabelPoints(const QPointF& ptPos, qreal dWidth, qreal dHeight, qreal dRot);
|
||||
|
||||
QVector<QPointF> GetPatternInfoPoints() const;
|
||||
void SetPatternInfoPoints(const QPointF& ptPos, qreal dWidth, qreal dHeight, qreal dRot);
|
||||
|
||||
QTransform GetMatrix() const;
|
||||
void SetMatrix(const QTransform &matrix);
|
||||
|
||||
|
@ -86,6 +92,8 @@ private:
|
|||
|
||||
QVector<QPointF> Map(const QVector<QPointF> &points) const;
|
||||
static QVector<QPointF> RoundPoints(const QVector<QPointF> &points);
|
||||
|
||||
QPointF RotatePoint(const QPointF& ptCenter, const QPointF& pt, qreal dAng);
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(VLayoutDetail, Q_MOVABLE_TYPE);
|
||||
|
|
|
@ -44,13 +44,14 @@ class VLayoutDetailData : public QSharedData
|
|||
public:
|
||||
VLayoutDetailData()
|
||||
:contour(QVector<QPointF>()), seamAllowence(QVector<QPointF>()), layoutAllowence(QVector<QPointF>()),
|
||||
matrix(QMatrix()), layoutWidth(0), mirror(false)
|
||||
matrix(QMatrix()), layoutWidth(0), mirror(false), detailLabel(QVector<QPointF>()),
|
||||
patternInfo(QVector<QPointF>())
|
||||
{}
|
||||
|
||||
VLayoutDetailData(const VLayoutDetailData &detail)
|
||||
:QSharedData(detail), contour(detail.contour), seamAllowence(detail.seamAllowence),
|
||||
layoutAllowence(detail.layoutAllowence), matrix(detail.matrix), layoutWidth(detail.layoutWidth),
|
||||
mirror(detail.mirror)
|
||||
mirror(detail.mirror), detailLabel(detail.detailLabel), patternInfo(detail.patternInfo)
|
||||
{}
|
||||
|
||||
~VLayoutDetailData() {}
|
||||
|
@ -72,6 +73,11 @@ public:
|
|||
|
||||
bool mirror;
|
||||
|
||||
/** @brief detail label rectangle */
|
||||
QVector<QPointF> detailLabel;
|
||||
/** @brief pattern info rectangle */
|
||||
QVector<QPointF> patternInfo;
|
||||
|
||||
private:
|
||||
VLayoutDetailData &operator=(const VLayoutDetailData &) Q_DECL_EQ_DELETE;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user