Added grainline to layout
--HG-- branch : feature
This commit is contained in:
parent
e1a4eeb4e4
commit
46eb6dfaa3
|
@ -39,6 +39,7 @@
|
||||||
#include "../vlayout/vposter.h"
|
#include "../vlayout/vposter.h"
|
||||||
#include "../vpatterndb/vpatternpiecedata.h"
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||||
|
#include "../vpatterndb/vgrainlinegeometry.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
@ -476,6 +477,11 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *de
|
||||||
}
|
}
|
||||||
det.SetPatternInfo(pDoc, geom, qApp->font(), pattern->size(), pattern->height());
|
det.SetPatternInfo(pDoc, geom, qApp->font(), pattern->size(), pattern->height());
|
||||||
}
|
}
|
||||||
|
const VGrainlineGeometry& grainlineGeom = d.GetGrainlineGeometry();
|
||||||
|
if (grainlineGeom.IsVisible() == true)
|
||||||
|
{
|
||||||
|
det.SetGrainline(grainlineGeom, *pattern);
|
||||||
|
}
|
||||||
det.setWidth(qApp->toPixel(d.getWidth()));
|
det.setWidth(qApp->toPixel(d.getWidth()));
|
||||||
det.CreateTextItems();
|
det.CreateTextItems();
|
||||||
det.setForbidFlipping(d.getForbidFlipping());
|
det.setForbidFlipping(d.getForbidFlipping());
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||||
#include "../vpatterndb/vpatternpiecedata.h"
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
#include "../vpatterndb/calculator.h"
|
||||||
#include "vlayoutdef.h"
|
#include "vlayoutdef.h"
|
||||||
#include "vlayoutdetail_p.h"
|
#include "vlayoutdetail_p.h"
|
||||||
#include "vtextmanager.h"
|
#include "vtextmanager.h"
|
||||||
|
@ -180,6 +182,41 @@ void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternI
|
||||||
d->m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight());
|
d->m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VLayoutDetail::SetGrainline(const VGrainlineGeometry& geom, const VContainer& rPattern)
|
||||||
|
{
|
||||||
|
d->grainlineGeom = geom;
|
||||||
|
qreal dAng;
|
||||||
|
qreal dLen;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QString qsFormula = geom.GetRotation().replace("\n", " ");
|
||||||
|
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
|
||||||
|
Calculator cal1;
|
||||||
|
dAng = cal1.EvalFormula(rPattern.PlainVariables(), qsFormula);
|
||||||
|
dAng = qDegreesToRadians(dAng);
|
||||||
|
|
||||||
|
qsFormula = geom.GetLength().replace("\n", " ");
|
||||||
|
qsFormula = qApp->TrVars()->FormulaFromUser(qsFormula, qApp->Settings()->GetOsSeparator());
|
||||||
|
Calculator cal2;
|
||||||
|
dLen = cal2.EvalFormula(rPattern.PlainVariables(), qsFormula);
|
||||||
|
dLen = ToPixel(dLen, *rPattern.GetPatternUnit());
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF pt1 = geom.GetPos();
|
||||||
|
QPointF pt2;
|
||||||
|
pt2.setX(pt1.x() + dLen * qCos(dAng));
|
||||||
|
pt2.setY(pt1.y() - dLen * qSin(dAng));
|
||||||
|
QVector<QPointF> v;
|
||||||
|
v << pt1 << pt2;
|
||||||
|
d->grainlinePoints = RoundPoints(v);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QTransform VLayoutDetail::GetMatrix() const
|
QTransform VLayoutDetail::GetMatrix() const
|
||||||
{
|
{
|
||||||
|
@ -673,6 +710,25 @@ QGraphicsItem *VLayoutDetail::GetItem() const
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QGraphicsItem* VLayoutDetail::GetGrainlineItem() const
|
||||||
|
{
|
||||||
|
if (d->grainlinePoints.count() < 2)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
QGraphicsPathItem* item = new QGraphicsPathItem();
|
||||||
|
QPainterPath path;
|
||||||
|
QVector<QPointF> v = Map(d->grainlinePoints);
|
||||||
|
path.moveTo(v.at(0));
|
||||||
|
for (int i = 1; i < v.count(); ++i)
|
||||||
|
{
|
||||||
|
path.lineTo(v.at(i));
|
||||||
|
}
|
||||||
|
item->setPath(path);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VLayoutDetail::IsMirror() const
|
bool VLayoutDetail::IsMirror() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||||
#include "../vpatterndb/vpatternpiecedata.h"
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "vabstractdetail.h"
|
#include "vabstractdetail.h"
|
||||||
|
|
||||||
class QFont;
|
class QFont;
|
||||||
|
@ -57,6 +58,7 @@ class VAbstractPattern;
|
||||||
class VLayoutDetailData;
|
class VLayoutDetailData;
|
||||||
class VPatternInfoGeometry;
|
class VPatternInfoGeometry;
|
||||||
class VPatternPieceData;
|
class VPatternPieceData;
|
||||||
|
class VGrainlineGeometry;
|
||||||
|
|
||||||
class VLayoutDetail :public VAbstractDetail
|
class VLayoutDetail :public VAbstractDetail
|
||||||
{
|
{
|
||||||
|
@ -80,6 +82,8 @@ public:
|
||||||
void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont& font,
|
void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont& font,
|
||||||
qreal dSize, qreal dHeight);
|
qreal dSize, qreal dHeight);
|
||||||
|
|
||||||
|
void SetGrainline(const VGrainlineGeometry& geom, const VContainer& rPattern);
|
||||||
|
|
||||||
QTransform GetMatrix() const;
|
QTransform GetMatrix() const;
|
||||||
void SetMatrix(const QTransform &matrix);
|
void SetMatrix(const QTransform &matrix);
|
||||||
|
|
||||||
|
@ -110,6 +114,7 @@ public:
|
||||||
QGraphicsItem* GetTextItem(int i) const Q_REQUIRED_RESULT;
|
QGraphicsItem* GetTextItem(int i) const Q_REQUIRED_RESULT;
|
||||||
QPainterPath LayoutAllowencePath() const;
|
QPainterPath LayoutAllowencePath() const;
|
||||||
QGraphicsItem *GetItem() const Q_REQUIRED_RESULT;
|
QGraphicsItem *GetItem() const Q_REQUIRED_RESULT;
|
||||||
|
QGraphicsItem* GetGrainlineItem() const Q_REQUIRED_RESULT;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VLayoutDetailData> d;
|
QSharedDataPointer<VLayoutDetailData> d;
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
#include "../vpatterndb/vpatternpiecedata.h"
|
#include "../vpatterndb/vpatternpiecedata.h"
|
||||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||||
|
#include "../vpatterndb/vgrainlinegeometry.h"
|
||||||
|
|
||||||
#include "vtextmanager.h"
|
#include "vtextmanager.h"
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
|
@ -47,16 +49,17 @@ 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(), m_tmDetail(),
|
patternInfo(QVector<QPointF>()), grainlinePoints(QVector<QPointF>()), detailData(), patternGeom(),
|
||||||
m_tmPattern(), m_liPP(QList<QPainterPath>())
|
grainlineGeom(), 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), grainlinePoints(detail.grainlinePoints), detailData(detail.detailData),
|
||||||
m_tmDetail(detail.m_tmDetail), m_tmPattern(detail.m_tmPattern), m_liPP(detail.m_liPP)
|
patternGeom(detail.patternGeom), grainlineGeom(detail.grainlineGeom), m_tmDetail(detail.m_tmDetail),
|
||||||
|
m_tmPattern(detail.m_tmPattern), m_liPP(detail.m_liPP)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~VLayoutDetailData() {}
|
~VLayoutDetailData() {}
|
||||||
|
@ -82,10 +85,14 @@ public:
|
||||||
QVector<QPointF> detailLabel;
|
QVector<QPointF> detailLabel;
|
||||||
/** @brief patternInfo pattern info rectangle */
|
/** @brief patternInfo pattern info rectangle */
|
||||||
QVector<QPointF> patternInfo;
|
QVector<QPointF> patternInfo;
|
||||||
|
/** @brief grainlineInfo line */
|
||||||
|
QVector<QPointF> grainlinePoints;
|
||||||
/** @brief detailData detail data */
|
/** @brief detailData detail data */
|
||||||
VPatternPieceData detailData;
|
VPatternPieceData detailData;
|
||||||
/** @brief patternGeom pattern geometry */
|
/** @brief patternGeom pattern geometry */
|
||||||
VPatternInfoGeometry patternGeom;
|
VPatternInfoGeometry patternGeom;
|
||||||
|
/** @brief grainlineGeom grainline geometry */
|
||||||
|
VGrainlineGeometry grainlineGeom;
|
||||||
/** @brief m_tmDetail text manager for laying out detail info */
|
/** @brief m_tmDetail text manager for laying out detail info */
|
||||||
VTextManager m_tmDetail;
|
VTextManager m_tmDetail;
|
||||||
/** @brief m_tmPattern text manager for laying out pattern info */
|
/** @brief m_tmPattern text manager for laying out pattern info */
|
||||||
|
|
|
@ -348,6 +348,12 @@ QList<QGraphicsItem *> VLayoutPaper::GetItemDetails() const
|
||||||
{
|
{
|
||||||
list.append(d->details.at(i).GetTextItem(iT));
|
list.append(d->details.at(i).GetTextItem(iT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QGraphicsItem* pItem = d->details.at(i).GetGrainlineItem();
|
||||||
|
if (pItem != 0)
|
||||||
|
{
|
||||||
|
list.append(pItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user