Successful build.
--HG-- branch : feature
This commit is contained in:
parent
988da5fd19
commit
1ab541236d
|
@ -804,35 +804,25 @@ void VPattern::ParseDetailNodes(const QDomElement &domElement, VPiece &detail, q
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail) const
|
||||
{
|
||||
detail.GetPatternPieceData().SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
|
||||
VPieceLabelData &ppData = detail.GetPatternPieceData();
|
||||
ppData.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
|
||||
try
|
||||
{
|
||||
QString qsLetter = GetParametrString(domElement, AttrLetter, "");
|
||||
detail.GetPatternPieceData().SetLetter(qsLetter);
|
||||
ppData.SetLetter(qsLetter);
|
||||
}
|
||||
catch(const VExceptionEmptyParameter &e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
detail.GetPatternPieceData().SetLetter("");
|
||||
ppData.SetLetter("");
|
||||
}
|
||||
QPointF ptPos;
|
||||
ptPos.setX(GetParametrDouble(domElement, AttrMx, "0"));
|
||||
ptPos.setY(GetParametrDouble(domElement, AttrMy, "0"));
|
||||
detail.GetPatternPieceData().SetPos(ptPos);
|
||||
qreal dLW = GetParametrDouble(domElement, AttrWidth, "0");
|
||||
detail.GetPatternPieceData().SetLabelWidth(dLW);
|
||||
qreal dLH = GetParametrDouble(domElement, VToolSeamAllowance::AttrHeight, "0");
|
||||
detail.GetPatternPieceData().SetLabelHeight(dLH);
|
||||
int iFS = static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0"));
|
||||
detail.GetPatternPieceData().SetFontSize(iFS);
|
||||
qreal dRot = GetParametrDouble(domElement, AttrRotation, "0");
|
||||
detail.GetPatternPieceData().SetRotation(dRot);
|
||||
|
||||
const quint32 topLeftPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR);
|
||||
detail.GetPatternPieceData().SetTopLeftPin(topLeftPin);
|
||||
|
||||
const quint32 bottomRightPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR);
|
||||
detail.GetPatternPieceData().SetBottomRightPin(bottomRightPin);
|
||||
ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
|
||||
ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
|
||||
ppData.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1"));
|
||||
ppData.SetFontSize(static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0")));
|
||||
ppData.SetRotation(GetParametrString(domElement, AttrRotation, "0"));
|
||||
ppData.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
|
||||
ppData.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
|
||||
|
||||
QDomNodeList nodeListMCP = domElement.childNodes();
|
||||
for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP)
|
||||
|
@ -846,57 +836,36 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail)
|
|||
}
|
||||
mcp.m_iCutNumber = static_cast<int>(GetParametrUInt(domMCP, AttrCutNumber, 0));
|
||||
mcp.m_ePlacement = PlacementType(GetParametrUInt(domMCP, AttrPlacement, 0));
|
||||
detail.GetPatternPieceData().Append(mcp);
|
||||
ppData.Append(mcp);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::ParsePiecePatternInfo(const QDomElement &domElement, VPiece &detail) const
|
||||
{
|
||||
detail.GetPatternInfo().SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
|
||||
QPointF ptPos;
|
||||
ptPos.setX(GetParametrDouble(domElement, AttrMx, "0"));
|
||||
ptPos.setY(GetParametrDouble(domElement, AttrMy, "0"));
|
||||
detail.GetPatternInfo().SetPos(ptPos);
|
||||
qreal dLW = GetParametrDouble(domElement, AttrWidth, "0");
|
||||
detail.GetPatternInfo().SetLabelWidth(dLW);
|
||||
qreal dLH = GetParametrDouble(domElement, VToolSeamAllowance::AttrHeight, "0");
|
||||
detail.GetPatternInfo().SetLabelHeight(dLH);
|
||||
int iFS = static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0"));
|
||||
detail.GetPatternInfo().SetFontSize(iFS);
|
||||
qreal dRot = GetParametrDouble(domElement, AttrRotation, "0");
|
||||
detail.GetPatternInfo().SetRotation(dRot);
|
||||
|
||||
const quint32 topLeftPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR);
|
||||
detail.GetPatternInfo().SetTopLeftPin(topLeftPin);
|
||||
|
||||
const quint32 bottomRightPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR);
|
||||
detail.GetPatternInfo().SetBottomRightPin(bottomRightPin);
|
||||
VPatternLabelData &patternInfo = detail.GetPatternInfo();
|
||||
patternInfo.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
|
||||
patternInfo.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
|
||||
patternInfo.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
|
||||
patternInfo.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1"));
|
||||
patternInfo.SetFontSize(static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, "0")));
|
||||
patternInfo.SetRotation(GetParametrString(domElement, AttrRotation, "0"));
|
||||
patternInfo.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
|
||||
patternInfo.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPattern::ParsePieceGrainline(const QDomElement &domElement, VPiece &detail) const
|
||||
{
|
||||
detail.GetGrainlineGeometry().SetVisible(GetParametrBool(domElement, AttrVisible, falseStr));
|
||||
QPointF ptPos;
|
||||
ptPos.setX(GetParametrDouble(domElement, AttrMx, "0"));
|
||||
ptPos.setY(GetParametrDouble(domElement, AttrMy, "0"));
|
||||
detail.GetGrainlineGeometry().SetPos(ptPos);
|
||||
QString qsLength = GetParametrString(domElement, AttrLength, "0");
|
||||
detail.GetGrainlineGeometry().SetLength(qsLength);
|
||||
QString qsRot = GetParametrString(domElement, AttrRotation, "90");
|
||||
detail.GetGrainlineGeometry().SetRotation(qsRot);
|
||||
ArrowType eAT = static_cast<ArrowType>(GetParametrUInt(domElement, AttrArrows, "0"));
|
||||
detail.GetGrainlineGeometry().SetArrowType(eAT);
|
||||
|
||||
const quint32 centerPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR);
|
||||
detail.GetGrainlineGeometry().SetCenterPin(centerPin);
|
||||
|
||||
const quint32 topPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR);
|
||||
detail.GetGrainlineGeometry().SetTopPin(topPin);
|
||||
|
||||
const quint32 bottomPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomPin, NULL_ID_STR);
|
||||
detail.GetGrainlineGeometry().SetBottomPin(bottomPin);
|
||||
VGrainlineData &gGeometry = detail.GetGrainlineGeometry();
|
||||
gGeometry.SetVisible(GetParametrBool(domElement, AttrVisible, falseStr));
|
||||
gGeometry.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
|
||||
gGeometry.SetLength(GetParametrString(domElement, AttrLength, "1"));
|
||||
gGeometry.SetRotation(GetParametrString(domElement, AttrRotation, "90"));
|
||||
gGeometry.SetArrowType(static_cast<ArrowType>(GetParametrUInt(domElement, AttrArrows, "0")));
|
||||
gGeometry.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
||||
gGeometry.SetTopPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR));
|
||||
gGeometry.SetBottomPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomPin, NULL_ID_STR));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -492,9 +492,9 @@
|
|||
<xs:attribute name="fontSize" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="width" type="xs:double"/>
|
||||
<xs:attribute name="height" type="xs:double"/>
|
||||
<xs:attribute name="rotation" type="xs:double"/>
|
||||
<xs:attribute name="width" type="xs:string"/>
|
||||
<xs:attribute name="height" type="xs:string"/>
|
||||
<xs:attribute name="rotation" type="xs:string"/>
|
||||
<xs:attribute name="topLeftPin" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="bottomRightPin" type="xs:unsignedInt"/>
|
||||
</xs:complexType>
|
||||
|
@ -505,9 +505,9 @@
|
|||
<xs:attribute name="fontSize" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="mx" type="xs:double"/>
|
||||
<xs:attribute name="my" type="xs:double"/>
|
||||
<xs:attribute name="width" type="xs:double"/>
|
||||
<xs:attribute name="height" type="xs:double"/>
|
||||
<xs:attribute name="rotation" type="xs:double"/>
|
||||
<xs:attribute name="width" type="xs:string"/>
|
||||
<xs:attribute name="height" type="xs:string"/>
|
||||
<xs:attribute name="rotation" type="xs:string"/>
|
||||
<xs:attribute name="topLeftPin" type="xs:unsignedInt"/>
|
||||
<xs:attribute name="bottomRightPin" type="xs:unsignedInt"/>
|
||||
</xs:complexType>
|
||||
|
|
|
@ -75,11 +75,22 @@ QVector<VLayoutPiecePath> ConvertInternalPaths(const VPiece &piece, const VConta
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pattern, qreal &labelWidth,
|
||||
qreal &labelHeight, QPointF &pos)
|
||||
bool FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pattern, qreal &rotationAngle,
|
||||
qreal &labelWidth, qreal &labelHeight, QPointF &pos)
|
||||
{
|
||||
SCASSERT(pattern != nullptr)
|
||||
|
||||
try
|
||||
{
|
||||
Calculator cal1;
|
||||
rotationAngle = cal1.EvalFormula(pattern->PlainVariables(), labelData.GetRotation());
|
||||
}
|
||||
catch(qmu::QmuParserError &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
const quint32 topLeftPin = labelData.TopLeftPin();
|
||||
const quint32 bottomRightPin = labelData.BottomRightPin();
|
||||
|
||||
|
@ -96,7 +107,7 @@ void FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat
|
|||
|
||||
pos = labelRect.topLeft();
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
catch(const VExceptionBadId &)
|
||||
{
|
||||
|
@ -104,9 +115,43 @@ void FindLabelGeometry(const VPatternLabelData &labelData, const VContainer *pat
|
|||
}
|
||||
}
|
||||
|
||||
labelWidth = labelData.GetLabelWidth();
|
||||
labelHeight = labelData.GetLabelHeight();
|
||||
try
|
||||
{
|
||||
Calculator cal1;
|
||||
labelWidth = cal1.EvalFormula(pattern->PlainVariables(), labelData.GetLabelWidth());
|
||||
|
||||
Calculator cal2;
|
||||
labelHeight = cal2.EvalFormula(pattern->PlainVariables(), labelData.GetLabelHeight());
|
||||
}
|
||||
catch(qmu::QmuParserError &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
const quint32 centerPin = labelData.CenterPin();
|
||||
if (centerPin != NULL_ID)
|
||||
{
|
||||
try
|
||||
{
|
||||
const auto centerPinPoint = pattern->GeometricObject<VPointF>(centerPin);
|
||||
|
||||
const qreal lWidth = ToPixel(labelWidth, *pattern->GetPatternUnit());
|
||||
const qreal lHeight = ToPixel(labelHeight, *pattern->GetPatternUnit());
|
||||
|
||||
pos = *centerPinPoint - QRectF(0, 0, lWidth, lHeight).center();
|
||||
}
|
||||
catch(const VExceptionBadId &)
|
||||
{
|
||||
pos = labelData.GetPos();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = labelData.GetPos();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -401,7 +446,14 @@ void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data,
|
|||
QPointF ptPos;
|
||||
qreal labelWidth = 0;
|
||||
qreal labelHeight = 0;
|
||||
FindLabelGeometry(data, pattern, labelWidth, labelHeight, ptPos);
|
||||
qreal labelAngle = 0;
|
||||
if (not FindLabelGeometry(data, pattern, labelAngle, labelWidth, labelHeight, ptPos))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
labelWidth = ToPixel(labelWidth, *pattern->GetPatternUnit());
|
||||
labelHeight = ToPixel(labelHeight, *pattern->GetPatternUnit());
|
||||
|
||||
QVector<QPointF> v;
|
||||
v << ptPos
|
||||
|
@ -409,7 +461,7 @@ void VLayoutPiece::SetDetail(const QString& qsName, const VPieceLabelData& data,
|
|||
<< QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight)
|
||||
<< QPointF(ptPos.x(), ptPos.y() + labelHeight);
|
||||
|
||||
const qreal dAng = qDegreesToRadians(data.GetRotation());
|
||||
const qreal dAng = qDegreesToRadians(labelAngle);
|
||||
const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2);
|
||||
for (int i = 0; i < v.count(); ++i)
|
||||
{
|
||||
|
@ -435,7 +487,14 @@ void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLa
|
|||
QPointF ptPos;
|
||||
qreal labelWidth = 0;
|
||||
qreal labelHeight = 0;
|
||||
FindLabelGeometry(geom, pattern, labelWidth, labelHeight, ptPos);
|
||||
qreal labelAngle = 0;
|
||||
if (not FindLabelGeometry(geom, pattern, labelAngle, labelWidth, labelHeight, ptPos))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
labelWidth = ToPixel(labelWidth, *pattern->GetPatternUnit());
|
||||
labelHeight = ToPixel(labelHeight, *pattern->GetPatternUnit());
|
||||
|
||||
QVector<QPointF> v;
|
||||
v << ptPos
|
||||
|
@ -443,7 +502,7 @@ void VLayoutPiece::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternLa
|
|||
<< QPointF(ptPos.x() + labelWidth, ptPos.y() + labelHeight)
|
||||
<< QPointF(ptPos.x(), ptPos.y() + labelHeight);
|
||||
|
||||
const qreal dAng = qDegreesToRadians(geom.GetRotation());
|
||||
const qreal dAng = qDegreesToRadians(labelAngle);
|
||||
const QPointF ptCenter(ptPos.x() + labelWidth/2, ptPos.y() + labelHeight/2);
|
||||
for (int i = 0; i < v.count(); ++i)
|
||||
{
|
||||
|
|
|
@ -59,25 +59,25 @@ VPatternLabelData::~VPatternLabelData()
|
|||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VPatternLabelData::GetLabelWidth() const
|
||||
QString VPatternLabelData::GetLabelWidth() const
|
||||
{
|
||||
return d->m_dLabelWidth;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternLabelData::SetLabelWidth(qreal dLabelW)
|
||||
void VPatternLabelData::SetLabelWidth(const QString &dLabelW)
|
||||
{
|
||||
d->m_dLabelWidth = dLabelW;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VPatternLabelData::GetLabelHeight() const
|
||||
QString VPatternLabelData::GetLabelHeight() const
|
||||
{
|
||||
return d->m_dLabelHeight;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternLabelData::SetLabelHeight(qreal dLabelH)
|
||||
void VPatternLabelData::SetLabelHeight(const QString &dLabelH)
|
||||
{
|
||||
d->m_dLabelHeight = dLabelH;
|
||||
}
|
||||
|
@ -95,15 +95,15 @@ void VPatternLabelData::SetFontSize(int iSize)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VPatternLabelData::GetRotation() const
|
||||
QString VPatternLabelData::GetRotation() const
|
||||
{
|
||||
return d->m_dRotation;
|
||||
return d->m_dLabelAngle;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternLabelData::SetRotation(qreal dRot)
|
||||
void VPatternLabelData::SetRotation(const QString &dRot)
|
||||
{
|
||||
d->m_dRotation = dRot;
|
||||
d->m_dLabelAngle = dRot;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -47,17 +47,17 @@ public:
|
|||
virtual ~VPatternLabelData();
|
||||
|
||||
// methods, which set up label parameters
|
||||
qreal GetLabelWidth() const;
|
||||
void SetLabelWidth(qreal dLabelW);
|
||||
QString GetLabelWidth() const;
|
||||
void SetLabelWidth(const QString &dLabelW);
|
||||
|
||||
qreal GetLabelHeight() const;
|
||||
void SetLabelHeight(qreal dLabelH);
|
||||
QString GetLabelHeight() const;
|
||||
void SetLabelHeight(const QString &dLabelH);
|
||||
|
||||
int GetFontSize() const;
|
||||
void SetFontSize(int iSize);
|
||||
|
||||
qreal GetRotation() const;
|
||||
void SetRotation(qreal dRot);
|
||||
QString GetRotation() const;
|
||||
void SetRotation(const QString &dRot);
|
||||
|
||||
quint32 CenterPin() const;
|
||||
void SetCenterPin(const quint32 ¢erPin);
|
||||
|
|
|
@ -42,10 +42,10 @@ class VPatternLabelDataPrivate : public QSharedData
|
|||
{
|
||||
public:
|
||||
VPatternLabelDataPrivate()
|
||||
: m_dLabelWidth(0),
|
||||
m_dLabelHeight(0),
|
||||
: m_dLabelWidth(),
|
||||
m_dLabelHeight(),
|
||||
m_dLabelAngle(),
|
||||
m_iFontSize(0),
|
||||
m_dRotation(0),
|
||||
m_centerPin(NULL_ID),
|
||||
m_topLeftPin(NULL_ID),
|
||||
m_bottomRightPin(NULL_ID)
|
||||
|
@ -55,8 +55,8 @@ public:
|
|||
: QSharedData(data),
|
||||
m_dLabelWidth(data.m_dLabelWidth),
|
||||
m_dLabelHeight(data.m_dLabelHeight),
|
||||
m_dLabelAngle(data.m_dLabelAngle),
|
||||
m_iFontSize(data.m_iFontSize),
|
||||
m_dRotation(data.m_dRotation),
|
||||
m_centerPin(data.m_centerPin),
|
||||
m_topLeftPin(data.m_topLeftPin),
|
||||
m_bottomRightPin(data.m_bottomRightPin)
|
||||
|
@ -64,14 +64,14 @@ public:
|
|||
|
||||
~VPatternLabelDataPrivate();
|
||||
|
||||
/** @brief m_dLabelWidth label width */
|
||||
qreal m_dLabelWidth;
|
||||
/** @brief m_dLabelHeight label height */
|
||||
qreal m_dLabelHeight;
|
||||
/** @brief m_dLabelWidth formula to calculate the width of label */
|
||||
QString m_dLabelWidth;
|
||||
/** @brief m_dLabelHeight formula to calculate the height of label */
|
||||
QString m_dLabelHeight;
|
||||
/** @brief m_dLabelAngle formula to calculate the rotation angle of label */
|
||||
QString m_dLabelAngle;
|
||||
/** @brief m_iFontSize label text base font size */
|
||||
int m_iFontSize;
|
||||
/** @brief m_dRotation label rotation */
|
||||
qreal m_dRotation;
|
||||
/** @brief m_centerPin center pin id */
|
||||
quint32 m_centerPin;
|
||||
/** @brief m_topLeftPin top left corner pin id */
|
||||
|
|
|
@ -213,8 +213,6 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
|
|||
m_my = piece.GetMy();
|
||||
|
||||
ui->lineEditLetter->setText(piece.GetPatternPieceData().GetLetter());
|
||||
ui->groupBoxDetailLabel->setChecked(piece.GetPatternPieceData().IsVisible());
|
||||
ui->groupBoxPatternLabel->setChecked(piece.GetPatternInfo().IsVisible());
|
||||
|
||||
m_conMCP.clear();
|
||||
for (int i = 0; i < piece.GetPatternPieceData().GetMCPCount(); ++i)
|
||||
|
@ -224,25 +222,33 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
|
|||
|
||||
UpdateList();
|
||||
|
||||
ui->groupBoxGrainline->setChecked(piece.GetGrainlineGeometry().IsVisible());
|
||||
SetGrainlineAngle(piece.GetGrainlineGeometry().GetRotation());
|
||||
SetGrainlineLength(piece.GetGrainlineGeometry().GetLength());
|
||||
ui->comboBoxArrow->setCurrentIndex(int(piece.GetGrainlineGeometry().GetArrowType()));
|
||||
|
||||
m_oldData = piece.GetPatternPieceData();
|
||||
ui->groupBoxDetailLabel->setChecked(m_oldData.IsVisible());
|
||||
ChangeCurrentData(ui->comboBoxDLCenterPin, m_oldData.CenterPin());
|
||||
ChangeCurrentData(ui->comboBoxDLTopLeftPin, m_oldData.TopLeftPin());
|
||||
ChangeCurrentData(ui->comboBoxDLBottomRightPin, m_oldData.BottomRightPin());
|
||||
SetDLWidth(m_oldData.GetLabelWidth());
|
||||
SetDLHeight(m_oldData.GetLabelHeight());
|
||||
SetDLHeight(m_oldData.GetRotation());
|
||||
|
||||
m_oldGeom = piece.GetPatternInfo();
|
||||
ui->groupBoxPatternLabel->setChecked(m_oldGeom.IsVisible());
|
||||
ChangeCurrentData(ui->comboBoxPLCenterPin, m_oldGeom.CenterPin());
|
||||
ChangeCurrentData(ui->comboBoxPLTopLeftPin, m_oldGeom.TopLeftPin());
|
||||
ChangeCurrentData(ui->comboBoxPLBottomRightPin, m_oldGeom.BottomRightPin());
|
||||
SetPLWidth(m_oldGeom.GetLabelWidth());
|
||||
SetPLHeight(m_oldGeom.GetLabelHeight());
|
||||
SetPLHeight(m_oldGeom.GetRotation());
|
||||
|
||||
m_oldGrainline = piece.GetGrainlineGeometry();
|
||||
ui->groupBoxGrainline->setChecked(m_oldGrainline.IsVisible());
|
||||
ChangeCurrentData(ui->comboBoxGrainlineCenterPin, m_oldGrainline.CenterPin());
|
||||
ChangeCurrentData(ui->comboBoxGrainlineTopPin, m_oldGrainline.TopPin());
|
||||
ChangeCurrentData(ui->comboBoxGrainlineBottomPin, m_oldGrainline.BottomPin());
|
||||
SetGrainlineAngle(m_oldGrainline.GetRotation());
|
||||
SetGrainlineLength(m_oldGrainline.GetLength());
|
||||
|
||||
ValidObjects(MainPathIsValid());
|
||||
EnabledGrainline();
|
||||
|
@ -1794,10 +1800,10 @@ VPiece DialogSeamAllowance::CreatePiece() const
|
|||
}
|
||||
|
||||
piece.GetPatternPieceData().SetPos(m_oldData.GetPos());
|
||||
piece.GetPatternPieceData().SetLabelWidth(m_oldData.GetLabelWidth());
|
||||
piece.GetPatternPieceData().SetLabelHeight(m_oldData.GetLabelHeight());
|
||||
piece.GetPatternPieceData().SetLabelWidth(GetFormulaFromUser(ui->lineEditDLWidthFormula));
|
||||
piece.GetPatternPieceData().SetLabelHeight(GetFormulaFromUser(ui->lineEditDLHeightFormula));
|
||||
piece.GetPatternPieceData().SetFontSize(m_oldData.GetFontSize());
|
||||
piece.GetPatternPieceData().SetRotation(m_oldData.GetRotation());
|
||||
piece.GetPatternPieceData().SetRotation(GetFormulaFromUser(ui->lineEditDLAngleFormula));
|
||||
piece.GetPatternPieceData().SetVisible(ui->groupBoxDetailLabel->isChecked());
|
||||
piece.GetPatternPieceData().SetCenterPin(getCurrentObjectId(ui->comboBoxDLCenterPin));
|
||||
piece.GetPatternPieceData().SetTopLeftPin(getCurrentObjectId(ui->comboBoxDLTopLeftPin));
|
||||
|
@ -1808,6 +1814,9 @@ VPiece DialogSeamAllowance::CreatePiece() const
|
|||
piece.GetPatternInfo().SetCenterPin(getCurrentObjectId(ui->comboBoxPLCenterPin));
|
||||
piece.GetPatternInfo().SetTopLeftPin(getCurrentObjectId(ui->comboBoxPLTopLeftPin));
|
||||
piece.GetPatternInfo().SetBottomRightPin(getCurrentObjectId(ui->comboBoxPLBottomRightPin));
|
||||
piece.GetPatternInfo().SetLabelWidth(GetFormulaFromUser(ui->lineEditPLWidthFormula));
|
||||
piece.GetPatternInfo().SetLabelHeight(GetFormulaFromUser(ui->lineEditPLHeightFormula));
|
||||
piece.GetPatternInfo().SetRotation(GetFormulaFromUser(ui->lineEditPLAngleFormula));
|
||||
|
||||
piece.GetGrainlineGeometry() = m_oldGrainline;
|
||||
piece.GetGrainlineGeometry().SetVisible(ui->groupBoxGrainline->isChecked());
|
||||
|
|
|
@ -495,7 +495,14 @@ void VToolSeamAllowance::UpdateLabel()
|
|||
QPointF pos;
|
||||
qreal labelWidth = 0;
|
||||
qreal labelHeight = 0;
|
||||
const VTextGraphicsItem::MoveTypes type = FindLabelGeometry(labelData, labelWidth, labelHeight, pos);
|
||||
qreal labelAngle = 0;
|
||||
const VTextGraphicsItem::MoveTypes type = FindLabelGeometry(labelData, labelAngle, labelWidth, labelHeight,
|
||||
pos);
|
||||
if (type & VGrainlineItem::Error)
|
||||
{
|
||||
m_dataLabel->hide();
|
||||
return;
|
||||
}
|
||||
m_dataLabel->SetMoveType(type);
|
||||
|
||||
QFont fnt = qApp->font();
|
||||
|
@ -504,7 +511,8 @@ void VToolSeamAllowance::UpdateLabel()
|
|||
iFS < MIN_FONT_SIZE ? fnt.setPixelSize(MIN_FONT_SIZE) : fnt.setPixelSize(iFS);
|
||||
}
|
||||
m_dataLabel->SetFont(fnt);
|
||||
m_dataLabel->SetSize(labelWidth, labelHeight);
|
||||
m_dataLabel->SetSize(ToPixel(labelWidth, *VDataTool::data.GetPatternUnit()),
|
||||
ToPixel(labelHeight, *VDataTool::data.GetPatternUnit()));
|
||||
m_dataLabel->UpdateData(detail.GetName(), labelData);
|
||||
|
||||
QRectF rectBB;
|
||||
|
@ -513,14 +521,14 @@ void VToolSeamAllowance::UpdateLabel()
|
|||
rectBB.setHeight(m_dataLabel->boundingRect().height());
|
||||
qreal dX;
|
||||
qreal dY;
|
||||
if (m_dataLabel->IsContained(rectBB, labelData.GetRotation(), dX, dY) == false)
|
||||
if (m_dataLabel->IsContained(rectBB, labelAngle, dX, dY) == false)
|
||||
{
|
||||
pos.setX(pos.x() + dX);
|
||||
pos.setY(pos.y() + dY);
|
||||
}
|
||||
|
||||
m_dataLabel->setPos(pos);
|
||||
m_dataLabel->setRotation(labelData.GetRotation());
|
||||
m_dataLabel->setRotation(labelAngle);
|
||||
m_dataLabel->Update();
|
||||
m_dataLabel->show();
|
||||
}
|
||||
|
@ -544,7 +552,13 @@ void VToolSeamAllowance::UpdatePatternInfo()
|
|||
QPointF pos;
|
||||
qreal labelWidth = 0;
|
||||
qreal labelHeight = 0;
|
||||
const VTextGraphicsItem::MoveTypes type = FindLabelGeometry(geom, labelWidth, labelHeight, pos);
|
||||
qreal labelAngle = 0;
|
||||
const VTextGraphicsItem::MoveTypes type = FindLabelGeometry(geom, labelAngle, labelWidth, labelHeight, pos);
|
||||
if (type & VGrainlineItem::Error)
|
||||
{
|
||||
m_dataLabel->hide();
|
||||
return;
|
||||
}
|
||||
m_patternInfo->SetMoveType(type);
|
||||
|
||||
QFont fnt = qApp->font();
|
||||
|
@ -555,7 +569,8 @@ void VToolSeamAllowance::UpdatePatternInfo()
|
|||
}
|
||||
fnt.setPixelSize(iFS);
|
||||
m_patternInfo->SetFont(fnt);
|
||||
m_patternInfo->SetSize(labelWidth, labelHeight);
|
||||
m_patternInfo->SetSize(ToPixel(labelWidth, *VDataTool::data.GetPatternUnit()),
|
||||
ToPixel(labelHeight, *VDataTool::data.GetPatternUnit()));
|
||||
m_patternInfo->UpdateData(doc, getData()->size(), getData()->height());
|
||||
|
||||
QRectF rectBB;
|
||||
|
@ -564,14 +579,14 @@ void VToolSeamAllowance::UpdatePatternInfo()
|
|||
rectBB.setHeight(m_patternInfo->boundingRect().height());
|
||||
qreal dX;
|
||||
qreal dY;
|
||||
if (m_patternInfo->IsContained(rectBB, geom.GetRotation(), dX, dY) == false)
|
||||
if (m_patternInfo->IsContained(rectBB, labelAngle, dX, dY) == false)
|
||||
{
|
||||
pos.setX(pos.x() + dX);
|
||||
pos.setY(pos.y() + dY);
|
||||
}
|
||||
|
||||
m_patternInfo->setPos(pos);
|
||||
m_patternInfo->setRotation(geom.GetRotation());
|
||||
m_patternInfo->setRotation(labelAngle);
|
||||
m_patternInfo->Update();
|
||||
m_patternInfo->GetTextLines() > 0 ? m_patternInfo->show() : m_patternInfo->hide();
|
||||
}
|
||||
|
@ -623,10 +638,6 @@ void VToolSeamAllowance::SaveMoveDetail(const QPointF& ptPos)
|
|||
VPiece oldDet = VAbstractTool::data.GetPiece(id);
|
||||
VPiece newDet = oldDet;
|
||||
newDet.GetPatternPieceData().SetPos(ptPos);
|
||||
newDet.GetPatternPieceData().SetLabelWidth(m_dataLabel->boundingRect().width());
|
||||
newDet.GetPatternPieceData().SetLabelHeight(m_dataLabel->boundingRect().height());
|
||||
newDet.GetPatternPieceData().SetFontSize(m_dataLabel->GetFontSize());
|
||||
newDet.GetPatternPieceData().SetRotation(m_dataLabel->rotation());
|
||||
|
||||
SavePieceOptions* moveCommand = new SavePieceOptions(oldDet, newDet, doc, id);
|
||||
moveCommand->setText(tr("move pattern piece label"));
|
||||
|
@ -642,10 +653,13 @@ void VToolSeamAllowance::SaveResizeDetail(qreal dLabelW, int iFontSize)
|
|||
{
|
||||
VPiece oldDet = VAbstractTool::data.GetPiece(id);
|
||||
VPiece newDet = oldDet;
|
||||
newDet.GetPatternPieceData().SetLabelWidth(dLabelW);
|
||||
newDet.GetPatternPieceData().SetLabelHeight(m_dataLabel->boundingRect().height());
|
||||
|
||||
dLabelW = FromPixel(dLabelW, *VDataTool::data.GetPatternUnit());
|
||||
newDet.GetPatternPieceData().SetLabelWidth(QString().setNum(dLabelW));
|
||||
const qreal height = FromPixel(m_dataLabel->boundingRect().height(), *VDataTool::data.GetPatternUnit());
|
||||
newDet.GetPatternPieceData().SetLabelHeight(QString().setNum(height));
|
||||
newDet.GetPatternPieceData().SetFontSize(iFontSize);
|
||||
newDet.GetPatternPieceData().SetRotation(m_dataLabel->rotation());
|
||||
|
||||
SavePieceOptions* resizeCommand = new SavePieceOptions(oldDet, newDet, doc, id);
|
||||
resizeCommand->setText(tr("resize pattern piece label"));
|
||||
connect(resizeCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
|
@ -661,10 +675,8 @@ void VToolSeamAllowance::SaveRotationDetail(qreal dRot)
|
|||
VPiece oldDet = VAbstractTool::data.GetPiece(id);
|
||||
VPiece newDet = oldDet;
|
||||
newDet.GetPatternPieceData().SetPos(m_dataLabel->pos());
|
||||
newDet.GetPatternPieceData().SetLabelWidth(m_dataLabel->boundingRect().width());
|
||||
newDet.GetPatternPieceData().SetLabelHeight(m_dataLabel->boundingRect().height());
|
||||
newDet.GetPatternPieceData().SetFontSize(m_dataLabel->GetFontSize());
|
||||
newDet.GetPatternPieceData().SetRotation(dRot);
|
||||
newDet.GetPatternPieceData().SetRotation(QString().setNum(dRot));
|
||||
|
||||
SavePieceOptions* rotateCommand = new SavePieceOptions(oldDet, newDet, doc, id);
|
||||
rotateCommand->setText(tr("rotate pattern piece label"));
|
||||
|
@ -682,10 +694,6 @@ void VToolSeamAllowance::SaveMovePattern(const QPointF &ptPos)
|
|||
VPiece oldDet = VAbstractTool::data.GetPiece(id);
|
||||
VPiece newDet = oldDet;
|
||||
newDet.GetPatternInfo().SetPos(ptPos);
|
||||
newDet.GetPatternInfo().SetLabelWidth(m_patternInfo->boundingRect().width());
|
||||
newDet.GetPatternInfo().SetLabelHeight(m_patternInfo->boundingRect().height());
|
||||
newDet.GetPatternInfo().SetFontSize(m_patternInfo->GetFontSize());
|
||||
newDet.GetPatternInfo().SetRotation(m_patternInfo->rotation());
|
||||
|
||||
SavePieceOptions* moveCommand = new SavePieceOptions(oldDet, newDet, doc, id);
|
||||
moveCommand->setText(tr("move pattern info label"));
|
||||
|
@ -701,10 +709,13 @@ void VToolSeamAllowance::SaveResizePattern(qreal dLabelW, int iFontSize)
|
|||
{
|
||||
VPiece oldDet = VAbstractTool::data.GetPiece(id);
|
||||
VPiece newDet = oldDet;
|
||||
newDet.GetPatternInfo().SetLabelWidth(dLabelW);
|
||||
newDet.GetPatternInfo().SetLabelHeight(m_patternInfo->boundingRect().height());
|
||||
|
||||
dLabelW = FromPixel(dLabelW, *VDataTool::data.GetPatternUnit());
|
||||
newDet.GetPatternInfo().SetLabelWidth(QString().setNum(dLabelW));
|
||||
qreal height = FromPixel(m_patternInfo->boundingRect().height(), *VDataTool::data.GetPatternUnit());
|
||||
newDet.GetPatternInfo().SetLabelHeight(QString().setNum(height));
|
||||
newDet.GetPatternInfo().SetFontSize(iFontSize);
|
||||
newDet.GetPatternInfo().SetRotation(m_patternInfo->rotation());
|
||||
|
||||
SavePieceOptions* resizeCommand = new SavePieceOptions(oldDet, newDet, doc, id);
|
||||
resizeCommand->setText(tr("resize pattern info label"));
|
||||
connect(resizeCommand, &SavePieceOptions::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
|
@ -716,11 +727,10 @@ void VToolSeamAllowance::SaveRotationPattern(qreal dRot)
|
|||
{
|
||||
VPiece oldDet = VAbstractTool::data.GetPiece(id);
|
||||
VPiece newDet = oldDet;
|
||||
|
||||
newDet.GetPatternInfo().SetPos(m_patternInfo->pos());
|
||||
newDet.GetPatternInfo().SetLabelWidth(m_patternInfo->boundingRect().width());
|
||||
newDet.GetPatternInfo().SetLabelHeight(m_patternInfo->boundingRect().height());
|
||||
newDet.GetPatternInfo().SetFontSize(m_patternInfo->GetFontSize());
|
||||
newDet.GetPatternInfo().SetRotation(dRot);
|
||||
newDet.GetPatternInfo().SetRotation(QString().setNum(dRot));
|
||||
|
||||
SavePieceOptions* rotateCommand = new SavePieceOptions(oldDet, newDet, doc, id);
|
||||
rotateCommand->setText(tr("rotate pattern info label"));
|
||||
|
@ -763,8 +773,7 @@ void VToolSeamAllowance::SaveRotateGrainline(qreal dRot, const QPointF& ptPos)
|
|||
VPiece oldDet = VAbstractTool::data.GetPiece(id);
|
||||
VPiece newDet = oldDet;
|
||||
|
||||
dRot = qRadiansToDegrees(dRot);
|
||||
newDet.GetGrainlineGeometry().SetRotation(QString().setNum(dRot));
|
||||
newDet.GetGrainlineGeometry().SetRotation(QString().setNum(qRadiansToDegrees(dRot)));
|
||||
newDet.GetGrainlineGeometry().SetPos(ptPos);
|
||||
SavePieceOptions* rotateCommand = new SavePieceOptions(oldDet, newDet, doc, id);
|
||||
rotateCommand->setText(tr("rotate grainline"));
|
||||
|
@ -1167,9 +1176,27 @@ void VToolSeamAllowance::SaveDialogChange()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData& labelData, qreal &labelWidth,
|
||||
qreal &labelHeight, QPointF &pos)
|
||||
VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelData& labelData, qreal &rotationAngle,
|
||||
qreal &labelWidth, qreal &labelHeight, QPointF &pos)
|
||||
{
|
||||
|
||||
VPieceItem::MoveTypes restrictions = VPieceItem::AllModifications;
|
||||
try
|
||||
{
|
||||
if (not qmu::QmuTokenParser::IsSingle(labelData.GetRotation()))
|
||||
{
|
||||
restrictions &= ~ VPieceItem::IsRotatable;
|
||||
}
|
||||
|
||||
Calculator cal1;
|
||||
rotationAngle = cal1.EvalFormula(VAbstractTool::data.PlainVariables(), labelData.GetRotation());
|
||||
}
|
||||
catch(qmu::QmuParserError &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return VPieceItem::Error;
|
||||
}
|
||||
|
||||
const quint32 topLeftPin = labelData.TopLeftPin();
|
||||
const quint32 bottomRightPin = labelData.BottomRightPin();
|
||||
|
||||
|
@ -1186,7 +1213,10 @@ VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelD
|
|||
|
||||
pos = labelRect.topLeft();
|
||||
|
||||
return VTextGraphicsItem::IsRotatable;
|
||||
restrictions &= ~ VPieceItem::IsMovable;
|
||||
restrictions &= ~ VPieceItem::IsResizable;
|
||||
|
||||
return restrictions;
|
||||
}
|
||||
catch(const VExceptionBadId &)
|
||||
{
|
||||
|
@ -1194,10 +1224,53 @@ VPieceItem::MoveTypes VToolSeamAllowance::FindLabelGeometry(const VPatternLabelD
|
|||
}
|
||||
}
|
||||
|
||||
labelWidth = labelData.GetLabelWidth();
|
||||
labelHeight = labelData.GetLabelHeight();
|
||||
try
|
||||
{
|
||||
const bool widthIsSingle = qmu::QmuTokenParser::IsSingle(labelData.GetLabelWidth());
|
||||
|
||||
Calculator cal1;
|
||||
labelWidth = cal1.EvalFormula(VAbstractTool::data.PlainVariables(), labelData.GetLabelWidth());
|
||||
|
||||
const bool heightIsSingle = qmu::QmuTokenParser::IsSingle(labelData.GetLabelHeight());
|
||||
|
||||
Calculator cal2;
|
||||
labelHeight = cal2.EvalFormula(VAbstractTool::data.PlainVariables(), labelData.GetLabelHeight());
|
||||
|
||||
if (not widthIsSingle || not heightIsSingle)
|
||||
{
|
||||
restrictions &= ~ VPieceItem::IsResizable;
|
||||
}
|
||||
}
|
||||
catch(qmu::QmuParserError &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return VPieceItem::Error;
|
||||
}
|
||||
|
||||
const quint32 centerPin = labelData.CenterPin();
|
||||
if (centerPin != NULL_ID)
|
||||
{
|
||||
try
|
||||
{
|
||||
const auto centerPinPoint = VAbstractTool::data.GeometricObject<VPointF>(centerPin);
|
||||
|
||||
const qreal lWidth = ToPixel(labelWidth, *VDataTool::data.GetPatternUnit());
|
||||
const qreal lHeight = ToPixel(labelHeight, *VDataTool::data.GetPatternUnit());
|
||||
|
||||
pos = *centerPinPoint - QRectF(0, 0, lWidth, lHeight).center();
|
||||
restrictions &= ~ VPieceItem::IsMovable;
|
||||
}
|
||||
catch(const VExceptionBadId &)
|
||||
{
|
||||
pos = labelData.GetPos();
|
||||
return VTextGraphicsItem::AllModifications;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = labelData.GetPos();
|
||||
}
|
||||
|
||||
return restrictions;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -152,8 +152,8 @@ private:
|
|||
|
||||
void RefreshGeometry();
|
||||
void SaveDialogChange();
|
||||
VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &labelWidth, qreal &labelHeight,
|
||||
QPointF &pos);
|
||||
VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth,
|
||||
qreal &labelHeight, QPointF &pos);
|
||||
VPieceItem::MoveTypes FindGrainlineGeometry(const VGrainlineData &geom, qreal &length, qreal &rotationAngle,
|
||||
QPointF &pos);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user