Moved m_tmDetail, m_tmPattern and m_liPP from VLayoutDetail into VLayoutDetailData class
--HG-- branch : feature
This commit is contained in:
parent
455befa493
commit
03482fb9a8
|
@ -45,13 +45,12 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VLayoutDetail::VLayoutDetail()
|
VLayoutDetail::VLayoutDetail()
|
||||||
:VAbstractDetail(), d(new VLayoutDetailData), m_tmDetail(), m_tmPattern(), m_liPP()
|
:VAbstractDetail(), d(new VLayoutDetailData)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VLayoutDetail::VLayoutDetail(const VLayoutDetail &detail)
|
VLayoutDetail::VLayoutDetail(const VLayoutDetail &detail)
|
||||||
:VAbstractDetail(detail), d(detail.d), m_tmDetail(detail.m_tmDetail), m_tmPattern(detail.m_tmPattern),
|
:VAbstractDetail(detail), d(detail.d)
|
||||||
m_liPP(detail.m_liPP)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -63,9 +62,6 @@ VLayoutDetail &VLayoutDetail::operator=(const VLayoutDetail &detail)
|
||||||
}
|
}
|
||||||
VAbstractDetail::operator=(detail);
|
VAbstractDetail::operator=(detail);
|
||||||
d = detail.d;
|
d = detail.d;
|
||||||
m_tmDetail = detail.m_tmDetail;
|
|
||||||
m_tmPattern = detail.m_tmPattern;
|
|
||||||
m_liPP = detail.m_liPP;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,12 +133,12 @@ void VLayoutDetail::SetDetail(const QString& qsName, const VPatternPieceData& da
|
||||||
d->detailLabel = RoundPoints(v);
|
d->detailLabel = RoundPoints(v);
|
||||||
|
|
||||||
// generate text
|
// generate text
|
||||||
m_tmDetail.SetFont(font);
|
d->m_tmDetail.SetFont(font);
|
||||||
m_tmDetail.SetFontSize(data.GetFontSize());
|
d->m_tmDetail.SetFontSize(data.GetFontSize());
|
||||||
m_tmDetail.Update(qsName, data);
|
d->m_tmDetail.Update(qsName, data);
|
||||||
// this will generate the lines of text
|
// this will generate the lines of text
|
||||||
m_tmDetail.SetFontSize(data.GetFontSize());
|
d->m_tmDetail.SetFontSize(data.GetFontSize());
|
||||||
m_tmDetail.FitFontSize(data.GetLabelWidth(), data.GetLabelHeight());
|
d->m_tmDetail.FitFontSize(data.GetLabelWidth(), data.GetLabelHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -163,13 +159,13 @@ void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternI
|
||||||
d->patternInfo = RoundPoints(v);
|
d->patternInfo = RoundPoints(v);
|
||||||
|
|
||||||
// Generate text
|
// Generate text
|
||||||
m_tmPattern.SetFont(font);
|
d->m_tmPattern.SetFont(font);
|
||||||
m_tmPattern.SetFontSize(geom.GetFontSize());
|
d->m_tmPattern.SetFontSize(geom.GetFontSize());
|
||||||
|
|
||||||
m_tmPattern.Update(pDoc);
|
d->m_tmPattern.Update(pDoc);
|
||||||
// generate lines of text
|
// generate lines of text
|
||||||
m_tmPattern.SetFontSize(geom.GetFontSize());
|
d->m_tmPattern.SetFontSize(geom.GetFontSize());
|
||||||
m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight());
|
d->m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -486,7 +482,7 @@ QPainterPath VLayoutDetail::ContourPath() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VLayoutDetail::ClearTextItems()
|
void VLayoutDetail::ClearTextItems()
|
||||||
{
|
{
|
||||||
m_liPP.clear();
|
d->m_liPP.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -502,11 +498,11 @@ void VLayoutDetail::CreateTextItems()
|
||||||
qreal dW = GetDistance(points.at(0), points.at(1));
|
qreal dW = GetDistance(points.at(0), points.at(1));
|
||||||
qreal dY = 0;
|
qreal dY = 0;
|
||||||
qreal dX;
|
qreal dX;
|
||||||
for (int i = 0; i < m_tmDetail.GetCount(); ++i)
|
for (int i = 0; i < d->m_tmDetail.GetCount(); ++i)
|
||||||
{
|
{
|
||||||
const TextLine& tl = m_tmDetail.GetLine(i);
|
const TextLine& tl = d->m_tmDetail.GetLine(i);
|
||||||
QFont fnt = m_tmDetail.GetFont();
|
QFont fnt = d->m_tmDetail.GetFont();
|
||||||
fnt.setPixelSize(m_tmDetail.GetFont().pixelSize() + tl.m_iFontSize);
|
fnt.setPixelSize(d->m_tmDetail.GetFont().pixelSize() + tl.m_iFontSize);
|
||||||
fnt.setWeight(tl.m_eFontWeight);
|
fnt.setWeight(tl.m_eFontWeight);
|
||||||
fnt.setStyle(tl.m_eStyle);
|
fnt.setStyle(tl.m_eStyle);
|
||||||
dY += tl.m_iHeight;
|
dY += tl.m_iHeight;
|
||||||
|
@ -529,8 +525,8 @@ void VLayoutDetail::CreateTextItems()
|
||||||
}
|
}
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addText(dX, dY - (fm.height() - fm.ascent())/2, fnt, tl.m_qsText);
|
path.addText(dX, dY - (fm.height() - fm.ascent())/2, fnt, tl.m_qsText);
|
||||||
m_liPP << mat.map(path);
|
d->m_liPP << mat.map(path);
|
||||||
dY += m_tmDetail.GetSpacing();
|
dY += d->m_tmDetail.GetSpacing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// and then add pattern texts
|
// and then add pattern texts
|
||||||
|
@ -542,11 +538,11 @@ void VLayoutDetail::CreateTextItems()
|
||||||
qreal dW = GetDistance(points.at(0), points.at(1));
|
qreal dW = GetDistance(points.at(0), points.at(1));
|
||||||
qreal dY = 0;
|
qreal dY = 0;
|
||||||
qreal dX;
|
qreal dX;
|
||||||
for (int i = 0; i < m_tmPattern.GetCount(); ++i)
|
for (int i = 0; i < d->m_tmPattern.GetCount(); ++i)
|
||||||
{
|
{
|
||||||
const TextLine& tl = m_tmPattern.GetLine(i);
|
const TextLine& tl = d->m_tmPattern.GetLine(i);
|
||||||
QFont fnt = m_tmPattern.GetFont();
|
QFont fnt = d->m_tmPattern.GetFont();
|
||||||
fnt.setPixelSize(m_tmPattern.GetFont().pixelSize() + tl.m_iFontSize);
|
fnt.setPixelSize(d->m_tmPattern.GetFont().pixelSize() + tl.m_iFontSize);
|
||||||
fnt.setWeight(tl.m_eFontWeight);
|
fnt.setWeight(tl.m_eFontWeight);
|
||||||
fnt.setStyle(tl.m_eStyle);
|
fnt.setStyle(tl.m_eStyle);
|
||||||
dY += tl.m_iHeight;
|
dY += tl.m_iHeight;
|
||||||
|
@ -569,8 +565,8 @@ void VLayoutDetail::CreateTextItems()
|
||||||
}
|
}
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addText(dX, dY - (fm.height() - fm.ascent())/2, fnt, tl.m_qsText);
|
path.addText(dX, dY - (fm.height() - fm.ascent())/2, fnt, tl.m_qsText);
|
||||||
m_liPP << mat.map(path);
|
d->m_liPP << mat.map(path);
|
||||||
dY += m_tmPattern.GetSpacing();
|
dY += d->m_tmPattern.GetSpacing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,7 +574,7 @@ void VLayoutDetail::CreateTextItems()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int VLayoutDetail::GetTextItemsCount() const
|
int VLayoutDetail::GetTextItemsCount() const
|
||||||
{
|
{
|
||||||
return m_liPP.count();
|
return d->m_liPP.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -587,12 +583,12 @@ QGraphicsItem* VLayoutDetail::GetTextItem(int i) const
|
||||||
QGraphicsPathItem* item = new QGraphicsPathItem();
|
QGraphicsPathItem* item = new QGraphicsPathItem();
|
||||||
QTransform transform = d->matrix;
|
QTransform transform = d->matrix;
|
||||||
|
|
||||||
QPainterPath path = transform.map(m_liPP[i]);
|
QPainterPath path = transform.map(d->m_liPP[i]);
|
||||||
|
|
||||||
if (d->mirror == true)
|
if (d->mirror == true)
|
||||||
{
|
{
|
||||||
QVector<QPointF> points;
|
QVector<QPointF> points;
|
||||||
if (i < m_tmDetail.GetCount())
|
if (i < d->m_tmDetail.GetCount())
|
||||||
{
|
{
|
||||||
points = Map(Mirror(d->detailLabel));
|
points = Map(Mirror(d->detailLabel));
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VLayoutDetailData> d;
|
QSharedDataPointer<VLayoutDetailData> d;
|
||||||
VTextManager m_tmDetail;
|
|
||||||
VTextManager m_tmPattern;
|
|
||||||
QList<QPainterPath> m_liPP;
|
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
#include "../vpatterndb/vpatternpiecedata.h"
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||||
|
#include "vtextmanager.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_CC_GNU
|
#ifdef Q_CC_GNU
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
|
@ -48,14 +50,16 @@ public:
|
||||||
VLayoutDetailData()
|
VLayoutDetailData()
|
||||||
:contour(QVector<QPointF>()), seamAllowence(QVector<QPointF>()), layoutAllowence(QVector<QPointF>()),
|
:contour(QVector<QPointF>()), seamAllowence(QVector<QPointF>()), layoutAllowence(QVector<QPointF>()),
|
||||||
matrix(QMatrix()), layoutWidth(0), mirror(false), detailLabel(QVector<QPointF>()),
|
matrix(QMatrix()), layoutWidth(0), mirror(false), detailLabel(QVector<QPointF>()),
|
||||||
patternInfo(QVector<QPointF>()), detailData(), patternGeom()
|
patternInfo(QVector<QPointF>()), detailData(), patternGeom(), m_tmDetail(),
|
||||||
|
m_tmPattern(), m_liPP(QList<QPainterPath>())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VLayoutDetailData(const VLayoutDetailData &detail)
|
VLayoutDetailData(const VLayoutDetailData &detail)
|
||||||
:QSharedData(detail), contour(detail.contour), seamAllowence(detail.seamAllowence),
|
:QSharedData(detail), contour(detail.contour), seamAllowence(detail.seamAllowence),
|
||||||
layoutAllowence(detail.layoutAllowence), matrix(detail.matrix),
|
layoutAllowence(detail.layoutAllowence), matrix(detail.matrix),
|
||||||
layoutWidth(detail.layoutWidth), mirror(detail.mirror), detailLabel(detail.detailLabel),
|
layoutWidth(detail.layoutWidth), mirror(detail.mirror), detailLabel(detail.detailLabel),
|
||||||
patternInfo(detail.patternInfo), detailData(detail.detailData), patternGeom(detail.patternGeom)
|
patternInfo(detail.patternInfo), detailData(detail.detailData), patternGeom(detail.patternGeom),
|
||||||
|
m_tmDetail(detail.m_tmDetail), m_tmPattern(detail.m_tmPattern), m_liPP(detail.m_liPP)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~VLayoutDetailData() {}
|
~VLayoutDetailData() {}
|
||||||
|
@ -85,6 +89,12 @@ public:
|
||||||
VPatternPieceData detailData;
|
VPatternPieceData detailData;
|
||||||
/** @brief patternGeom pattern geometry */
|
/** @brief patternGeom pattern geometry */
|
||||||
VPatternInfoGeometry patternGeom;
|
VPatternInfoGeometry patternGeom;
|
||||||
|
/** @brief m_tmDetail text manager for laying out detail info */
|
||||||
|
VTextManager m_tmDetail;
|
||||||
|
/** @brief m_tmPattern text manager for laying out pattern info */
|
||||||
|
VTextManager m_tmPattern;
|
||||||
|
/** @bried m_liPP list of generated text painter paths */
|
||||||
|
QList<QPainterPath> m_liPP;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VLayoutDetailData &operator=(const VLayoutDetailData &) Q_DECL_EQ_DELETE;
|
VLayoutDetailData &operator=(const VLayoutDetailData &) Q_DECL_EQ_DELETE;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user