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 "../vpatterndb/vpatternpiecedata.h"
|
||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||
#include "../vpatterndb/vgrainlinegeometry.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
|
@ -476,6 +477,11 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *de
|
|||
}
|
||||
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.CreateTextItems();
|
||||
det.setForbidFlipping(d.getForbidFlipping());
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||
#include "../vpatterndb/vpatternpiecedata.h"
|
||||
#include "../vmisc/vmath.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vpatterndb/calculator.h"
|
||||
#include "vlayoutdef.h"
|
||||
#include "vlayoutdetail_p.h"
|
||||
#include "vtextmanager.h"
|
||||
|
@ -180,6 +182,41 @@ void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternI
|
|||
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
|
||||
{
|
||||
|
@ -673,6 +710,25 @@ QGraphicsItem *VLayoutDetail::GetItem() const
|
|||
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
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||
#include "../vpatterndb/vpatternpiecedata.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "vabstractdetail.h"
|
||||
|
||||
class QFont;
|
||||
|
@ -57,6 +58,7 @@ class VAbstractPattern;
|
|||
class VLayoutDetailData;
|
||||
class VPatternInfoGeometry;
|
||||
class VPatternPieceData;
|
||||
class VGrainlineGeometry;
|
||||
|
||||
class VLayoutDetail :public VAbstractDetail
|
||||
{
|
||||
|
@ -80,6 +82,8 @@ public:
|
|||
void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont& font,
|
||||
qreal dSize, qreal dHeight);
|
||||
|
||||
void SetGrainline(const VGrainlineGeometry& geom, const VContainer& rPattern);
|
||||
|
||||
QTransform GetMatrix() const;
|
||||
void SetMatrix(const QTransform &matrix);
|
||||
|
||||
|
@ -110,6 +114,7 @@ public:
|
|||
QGraphicsItem* GetTextItem(int i) const Q_REQUIRED_RESULT;
|
||||
QPainterPath LayoutAllowencePath() const;
|
||||
QGraphicsItem *GetItem() const Q_REQUIRED_RESULT;
|
||||
QGraphicsItem* GetGrainlineItem() const Q_REQUIRED_RESULT;
|
||||
|
||||
private:
|
||||
QSharedDataPointer<VLayoutDetailData> d;
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#include "../vpatterndb/vpatternpiecedata.h"
|
||||
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||
#include "../vpatterndb/vgrainlinegeometry.h"
|
||||
|
||||
#include "vtextmanager.h"
|
||||
|
||||
QT_WARNING_PUSH
|
||||
|
@ -47,16 +49,17 @@ public:
|
|||
VLayoutDetailData()
|
||||
:contour(QVector<QPointF>()), seamAllowence(QVector<QPointF>()), layoutAllowence(QVector<QPointF>()),
|
||||
matrix(QMatrix()), layoutWidth(0), mirror(false), detailLabel(QVector<QPointF>()),
|
||||
patternInfo(QVector<QPointF>()), detailData(), patternGeom(), m_tmDetail(),
|
||||
m_tmPattern(), m_liPP(QList<QPainterPath>())
|
||||
patternInfo(QVector<QPointF>()), grainlinePoints(QVector<QPointF>()), detailData(), patternGeom(),
|
||||
grainlineGeom(), m_tmDetail(), m_tmPattern(), m_liPP(QList<QPainterPath>())
|
||||
{}
|
||||
|
||||
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),
|
||||
m_tmDetail(detail.m_tmDetail), m_tmPattern(detail.m_tmPattern), m_liPP(detail.m_liPP)
|
||||
patternInfo(detail.patternInfo), grainlinePoints(detail.grainlinePoints), detailData(detail.detailData),
|
||||
patternGeom(detail.patternGeom), grainlineGeom(detail.grainlineGeom), m_tmDetail(detail.m_tmDetail),
|
||||
m_tmPattern(detail.m_tmPattern), m_liPP(detail.m_liPP)
|
||||
{}
|
||||
|
||||
~VLayoutDetailData() {}
|
||||
|
@ -82,10 +85,14 @@ public:
|
|||
QVector<QPointF> detailLabel;
|
||||
/** @brief patternInfo pattern info rectangle */
|
||||
QVector<QPointF> patternInfo;
|
||||
/** @brief grainlineInfo line */
|
||||
QVector<QPointF> grainlinePoints;
|
||||
/** @brief detailData detail data */
|
||||
VPatternPieceData detailData;
|
||||
/** @brief patternGeom pattern geometry */
|
||||
VPatternInfoGeometry patternGeom;
|
||||
/** @brief grainlineGeom grainline geometry */
|
||||
VGrainlineGeometry grainlineGeom;
|
||||
/** @brief m_tmDetail text manager for laying out detail info */
|
||||
VTextManager m_tmDetail;
|
||||
/** @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));
|
||||
}
|
||||
|
||||
QGraphicsItem* pItem = d->details.at(i).GetGrainlineItem();
|
||||
if (pItem != 0)
|
||||
{
|
||||
list.append(pItem);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user