diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index 419a0089d..bcd904037 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -45,13 +45,12 @@ //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail::VLayoutDetail() - :VAbstractDetail(), d(new VLayoutDetailData), m_tmDetail(), m_tmPattern(), m_liPP() + :VAbstractDetail(), d(new VLayoutDetailData) {} //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail::VLayoutDetail(const VLayoutDetail &detail) - :VAbstractDetail(detail), d(detail.d), m_tmDetail(detail.m_tmDetail), m_tmPattern(detail.m_tmPattern), - m_liPP(detail.m_liPP) + :VAbstractDetail(detail), d(detail.d) {} //--------------------------------------------------------------------------------------------------------------------- @@ -63,9 +62,6 @@ VLayoutDetail &VLayoutDetail::operator=(const VLayoutDetail &detail) } VAbstractDetail::operator=(detail); d = detail.d; - m_tmDetail = detail.m_tmDetail; - m_tmPattern = detail.m_tmPattern; - m_liPP = detail.m_liPP; return *this; } @@ -137,12 +133,12 @@ void VLayoutDetail::SetDetail(const QString& qsName, const VPatternPieceData& da d->detailLabel = RoundPoints(v); // generate text - m_tmDetail.SetFont(font); - m_tmDetail.SetFontSize(data.GetFontSize()); - m_tmDetail.Update(qsName, data); + d->m_tmDetail.SetFont(font); + d->m_tmDetail.SetFontSize(data.GetFontSize()); + d->m_tmDetail.Update(qsName, data); // this will generate the lines of text - m_tmDetail.SetFontSize(data.GetFontSize()); - m_tmDetail.FitFontSize(data.GetLabelWidth(), data.GetLabelHeight()); + d->m_tmDetail.SetFontSize(data.GetFontSize()); + d->m_tmDetail.FitFontSize(data.GetLabelWidth(), data.GetLabelHeight()); } //--------------------------------------------------------------------------------------------------------------------- @@ -163,13 +159,13 @@ void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternI d->patternInfo = RoundPoints(v); // Generate text - m_tmPattern.SetFont(font); - m_tmPattern.SetFontSize(geom.GetFontSize()); + d->m_tmPattern.SetFont(font); + d->m_tmPattern.SetFontSize(geom.GetFontSize()); - m_tmPattern.Update(pDoc); + d->m_tmPattern.Update(pDoc); // generate lines of text - m_tmPattern.SetFontSize(geom.GetFontSize()); - m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight()); + d->m_tmPattern.SetFontSize(geom.GetFontSize()); + d->m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight()); } //--------------------------------------------------------------------------------------------------------------------- @@ -486,7 +482,7 @@ QPainterPath VLayoutDetail::ContourPath() const //--------------------------------------------------------------------------------------------------------------------- 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 dY = 0; 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); - QFont fnt = m_tmDetail.GetFont(); - fnt.setPixelSize(m_tmDetail.GetFont().pixelSize() + tl.m_iFontSize); + const TextLine& tl = d->m_tmDetail.GetLine(i); + QFont fnt = d->m_tmDetail.GetFont(); + fnt.setPixelSize(d->m_tmDetail.GetFont().pixelSize() + tl.m_iFontSize); fnt.setWeight(tl.m_eFontWeight); fnt.setStyle(tl.m_eStyle); dY += tl.m_iHeight; @@ -529,8 +525,8 @@ void VLayoutDetail::CreateTextItems() } QPainterPath path; path.addText(dX, dY - (fm.height() - fm.ascent())/2, fnt, tl.m_qsText); - m_liPP << mat.map(path); - dY += m_tmDetail.GetSpacing(); + d->m_liPP << mat.map(path); + dY += d->m_tmDetail.GetSpacing(); } } // and then add pattern texts @@ -542,11 +538,11 @@ void VLayoutDetail::CreateTextItems() qreal dW = GetDistance(points.at(0), points.at(1)); qreal dY = 0; 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); - QFont fnt = m_tmPattern.GetFont(); - fnt.setPixelSize(m_tmPattern.GetFont().pixelSize() + tl.m_iFontSize); + const TextLine& tl = d->m_tmPattern.GetLine(i); + QFont fnt = d->m_tmPattern.GetFont(); + fnt.setPixelSize(d->m_tmPattern.GetFont().pixelSize() + tl.m_iFontSize); fnt.setWeight(tl.m_eFontWeight); fnt.setStyle(tl.m_eStyle); dY += tl.m_iHeight; @@ -569,8 +565,8 @@ void VLayoutDetail::CreateTextItems() } QPainterPath path; path.addText(dX, dY - (fm.height() - fm.ascent())/2, fnt, tl.m_qsText); - m_liPP << mat.map(path); - dY += m_tmPattern.GetSpacing(); + d->m_liPP << mat.map(path); + dY += d->m_tmPattern.GetSpacing(); } } } @@ -578,7 +574,7 @@ void VLayoutDetail::CreateTextItems() //--------------------------------------------------------------------------------------------------------------------- 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(); QTransform transform = d->matrix; - QPainterPath path = transform.map(m_liPP[i]); + QPainterPath path = transform.map(d->m_liPP[i]); if (d->mirror == true) { QVector points; - if (i < m_tmDetail.GetCount()) + if (i < d->m_tmDetail.GetCount()) { points = Map(Mirror(d->detailLabel)); } diff --git a/src/libs/vlayout/vlayoutdetail.h b/src/libs/vlayout/vlayoutdetail.h index 3672c8093..e90e1b0c4 100644 --- a/src/libs/vlayout/vlayoutdetail.h +++ b/src/libs/vlayout/vlayoutdetail.h @@ -95,9 +95,6 @@ public: private: QSharedDataPointer d; - VTextManager m_tmDetail; - VTextManager m_tmPattern; - QList m_liPP; QVector Map(const QVector &points) const; static QVector RoundPoints(const QVector &points); diff --git a/src/libs/vlayout/vlayoutdetail_p.h b/src/libs/vlayout/vlayoutdetail_p.h index 77afa5ca7..01995de98 100644 --- a/src/libs/vlayout/vlayoutdetail_p.h +++ b/src/libs/vlayout/vlayoutdetail_p.h @@ -36,6 +36,8 @@ #include "../vpatterndb/vpatternpiecedata.h" #include "../vpatterndb/vpatterninfogeometry.h" +#include "vtextmanager.h" + #ifdef Q_CC_GNU #pragma GCC diagnostic push @@ -48,14 +50,16 @@ public: VLayoutDetailData() :contour(QVector()), seamAllowence(QVector()), layoutAllowence(QVector()), matrix(QMatrix()), layoutWidth(0), mirror(false), detailLabel(QVector()), - patternInfo(QVector()), detailData(), patternGeom() + patternInfo(QVector()), detailData(), patternGeom(), m_tmDetail(), + m_tmPattern(), m_liPP(QList()) {} VLayoutDetailData(const VLayoutDetailData &detail) :QSharedData(detail), contour(detail.contour), seamAllowence(detail.seamAllowence), layoutAllowence(detail.layoutAllowence), matrix(detail.matrix), 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() {} @@ -85,6 +89,12 @@ public: VPatternPieceData detailData; /** @brief patternGeom pattern geometry */ 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 m_liPP; private: VLayoutDetailData &operator=(const VLayoutDetailData &) Q_DECL_EQ_DELETE;