New layout option --nestQuantity.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-07-04 14:33:45 +03:00
parent 3212fc6136
commit e8804c90bb
22 changed files with 170 additions and 55 deletions

View File

@ -21,6 +21,7 @@
- Move Tool options and Group menu to Window section.
- Raise the minimum value for curve approximation to 0.2.
- Make piece labels transparent.
- New layout option --nestQuantity.
# Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path.

View File

@ -1,6 +1,6 @@
.\" Manpage for valentina.
.\" Contact dismine@gmail.com to correct errors.
.TH valentina 1 "30 March, 2019" "valentina man page"
.TH valentina 1 "4 July, 2019" "valentina man page"
.SH NAME
Valentina \- Pattern making program.
.SH SYNOPSIS
@ -188,6 +188,8 @@ The path to output destination folder. By default the directory at which the app
.RB "Page bottom margin in current units like 3.0 (" "export mode" "). If not set will be used value from default printer. Or 0 if none printers was found."
.IP "--followGrainline"
.RB "Order detail to follow grainline direction (" "export mode" ").
.IP "--nestQuantity"
.RB "Nest quantity copies of each piece (" "export mode" ").
.IP "-c, --crop"
.RB "Auto crop unused length (" "export mode" ")."
.IP "-u, --unite"

View File

@ -225,6 +225,7 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
diag.SetFields(margins);
diag.SetFollowGrainline(IsOptionSet(LONG_OPTION_FOLLOW_GRAINLINE));
diag.SetNestQuantity(IsOptionSet(LONG_OPTION_NEST_QUANTITY));
diag.SetNestingTime(OptNestingTime());
diag.SetEfficiencyCoefficient(OptEfficiencyCoefficient());
@ -655,6 +656,8 @@ void VCommandLine::InitCommandLineOptions()
//=================================================================================================================
{LONG_OPTION_FOLLOW_GRAINLINE,
translate("VCommandLine", "Order detail to follow grainline direction (export mode).")},
{LONG_OPTION_NEST_QUANTITY,
translate("VCommandLine", "Nest quantity copies of each piece (export mode).")},
{{SINGLE_OPTION_CROP, LONG_OPTION_CROP},
translate("VCommandLine", "Auto crop unused length (export mode).")},
{{SINGLE_OPTION_UNITE, LONG_OPTION_UNITE},

View File

@ -328,6 +328,18 @@ void DialogLayoutSettings::SetTextAsPaths(bool value)
ui->checkBoxTextAsPaths->setChecked(value);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::IsNestQuantity() const
{
return ui->checkBoxNestQuantity->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::SetNestQuantity(bool state)
{
ui->checkBoxNestQuantity->setChecked(state);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogLayoutSettings::SelectedPrinter() const
{
@ -566,6 +578,7 @@ void DialogLayoutSettings::DialogAccepted()
generator->SetStripOptimization(IsStripOptimization());
generator->SetMultiplier(GetMultiplier());
generator->SetTextAsPaths(IsTextAsPaths());
generator->SetNestQuantity(IsNestQuantity());
if (IsIgnoreAllFields())
{
@ -654,6 +667,7 @@ void DialogLayoutSettings::RestoreDefaults()
SetMultiplier(VSettings::GetDefMultiplier());
SetNestingTime(VSettings::GetDefNestingTime());
SetEfficiencyCoefficient(VSettings::GetDefEfficiencyCoefficient());
SetNestQuantity(VSettings::GetDefLayoutNestQuantity());
CorrectMaxFileds();
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
@ -982,6 +996,7 @@ void DialogLayoutSettings::ReadSettings()
SetStripOptimization(settings->GetStripOptimization());
SetMultiplier(settings->GetMultiplier());
SetTextAsPaths(settings->GetTextAsPaths());
SetNestQuantity(settings->GetLayoutNestQuantity());
FindTemplate();
@ -1008,6 +1023,7 @@ void DialogLayoutSettings::WriteSettings() const
settings->SetTextAsPaths(IsTextAsPaths());
settings->SetNestingTime(GetNestingTime());
settings->SetEfficiencyCoefficient(GetEfficiencyCoefficient());
settings->SetLayoutNestQuantity(IsNestQuantity());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -95,6 +95,9 @@ public:
bool IsTextAsPaths() const;
void SetTextAsPaths(bool value);
bool IsNestQuantity() const;
void SetNestQuantity(bool state);
QString SelectedPrinter() const;
void EnableLandscapeOrientation();

View File

@ -518,6 +518,16 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxNestQuantity">
<property name="toolTip">
<string>Nest quantity of copies according to piece settings.</string>
</property>
<property name="text">
<string>Nest quantity</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">

View File

@ -1028,7 +1028,7 @@ VPieceLabelData VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiec
ppData.SetRotationWay(GetParametrEmptyString(domElement, AttrRotationWay));
ppData.SetTilt(GetParametrEmptyString(domElement, AttrTilt));
ppData.SetFoldPosition(GetParametrEmptyString(domElement, AttrFoldPosition));
ppData.SetQuantity(static_cast<int>(GetParametrUInt(domElement, AttrQuantity, QChar('1'))));
ppData.SetQuantity(static_cast<quint16>(GetParametrUInt(domElement, AttrQuantity, QChar('1'))));
ppData.SetOnFold(GetParametrBool(domElement, AttrOnFold, falseStr));
ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')),
GetParametrDouble(domElement, AttrMy, QChar('0'))));

View File

@ -50,6 +50,24 @@ QT_WARNING_POP
#undef small
#endif
namespace
{
QVector<VLayoutPiece> PrepareQuantity(const QVector<VLayoutPiece> &details)
{
QVector<VLayoutPiece> withQuantity;
withQuantity.reserve(details.size());
for(auto &piece : details)
{
for (int i = 0; i < piece.GetQuantity(); ++i)
{
withQuantity.append(piece);
}
}
return withQuantity;
}
}
//---------------------------------------------------------------------------------------------------------------------
VBank::VBank()
: details(),
@ -76,6 +94,18 @@ void VBank::SetLayoutWidth(qreal value)
Reset();
}
//---------------------------------------------------------------------------------------------------------------------
bool VBank::IsNestQuantity() const
{
return m_nestQuantity;
}
//---------------------------------------------------------------------------------------------------------------------
void VBank::SetNestQuantity(bool value)
{
m_nestQuantity = value;
}
//---------------------------------------------------------------------------------------------------------------------
void VBank::SetDetails(const QVector<VLayoutPiece> &details)
{
@ -213,6 +243,11 @@ bool VBank::PrepareDetails()
return prepare;
}
if (m_nestQuantity)
{
details = PrepareQuantity(details);
}
diagonal = 0;
for (int i=0; i < details.size(); ++i)

View File

@ -54,6 +54,8 @@ public:
qreal GetLayoutWidth() const;
void SetLayoutWidth(qreal value);
bool IsNestQuantity() const;
void SetNestQuantity(bool value);
void SetDetails(const QVector<VLayoutPiece> &details);
int GetNext();
@ -90,6 +92,7 @@ private:
Cases caseType;
bool prepare;
qreal diagonal;
bool m_nestQuantity{false};
void PrepareGroup();

View File

@ -728,6 +728,18 @@ void VLayoutGenerator::SetFollowGrainline(bool value)
followGrainline = value;
}
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutGenerator::IsNestQuantity() const
{
return bank->IsNestQuantity();
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::SetNestQuantity(bool value)
{
bank->SetNestQuantity(value);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VLayoutGenerator::GetPaperWidth() const
{

View File

@ -99,6 +99,9 @@ public:
bool GetFollowGrainline() const;
void SetFollowGrainline(bool value);
bool IsNestQuantity() const;
void SetNestQuantity(bool value);
int GetRotationNumber() const;
void SetRotationNumber(int value);

View File

@ -60,7 +60,7 @@
#include "vgraphicsfillitem.h"
const quint32 VLayoutPieceData::streamHeader = 0x80D7D009; // CRC-32Q string "VLayoutPieceData"
const quint16 VLayoutPieceData::classVersion = 1;
const quint16 VLayoutPieceData::classVersion = 2;
namespace
{
@ -443,13 +443,14 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, const VContainer *pattern
}
const VPieceLabelData& data = piece.GetPatternPieceData();
if (data.IsVisible() == true)
det.SetQuantity(data.GetQuantity());
if (data.IsVisible())
{
det.SetPieceText(piece.GetName(), data, qApp->Settings()->GetLabelFont(), pattern);
}
const VPatternLabelData& geom = piece.GetPatternInfo();
if (geom.IsVisible() == true)
if (geom.IsVisible())
{
VAbstractPattern* pDoc = qApp->getCurrentDocument();
det.SetPatternInfo(pDoc, geom, qApp->Settings()->GetLabelFont(), pattern);
@ -757,6 +758,18 @@ void VLayoutPiece::SetLayoutWidth(qreal value)
d->layoutWidth = value;
}
//---------------------------------------------------------------------------------------------------------------------
quint16 VLayoutPiece::GetQuantity() const
{
return d->m_quantity;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetQuantity(quint16 value)
{
d->m_quantity = qMax(static_cast<quint16>(1), value);
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::Translate(qreal dx, qreal dy)
{

View File

@ -116,6 +116,9 @@ public:
qreal GetLayoutWidth() const;
void SetLayoutWidth(qreal value);
quint16 GetQuantity() const;
void SetQuantity(quint16 value);
bool IsMirror() const;
void SetMirror(bool value);

View File

@ -52,23 +52,6 @@ class VLayoutPieceData : public QSharedData
{
public:
VLayoutPieceData()
: contour(),
seamAllowance(),
layoutAllowance(),
passmarks(),
m_internalPaths(),
matrix(),
layoutWidth(0),
mirror(false),
detailLabel(),
patternInfo(),
grainlinePoints(),
grainlineArrowType(ArrowType::atFront),
grainlineAngle(0),
grainlineEnabled(false),
m_tmDetail(),
m_tmPattern(),
m_placeLabels()
{}
VLayoutPieceData(const VLayoutPieceData &detail)
@ -90,7 +73,8 @@ public:
m_tmDetail(detail.m_tmDetail),
m_tmPattern(detail.m_tmPattern),
m_placeLabels(detail.m_placeLabels),
m_square(detail.m_square)
m_square(detail.m_square),
m_quantity(detail.m_quantity)
{}
~VLayoutPieceData() Q_DECL_EQ_DEFAULT;
@ -99,52 +83,54 @@ public:
friend QDataStream& operator>>(QDataStream& dataStream, VLayoutPieceData& piece);
/** @brief contour list of contour points. */
QVector<QPointF> contour;
QVector<QPointF> contour{};
/** @brief seamAllowance list of seam allowance points. */
QVector<QPointF> seamAllowance;
QVector<QPointF> seamAllowance{};
/** @brief layoutAllowance list of layout allowance points. */
QVector<QPointF> layoutAllowance;
QVector<QPointF> layoutAllowance{};
/** @brief passmarks list of passmakrs. */
QVector<VLayoutPassmark> passmarks;
QVector<VLayoutPassmark> passmarks{};
/** @brief m_internalPaths list of internal paths. */
QVector<VLayoutPiecePath> m_internalPaths;
QVector<VLayoutPiecePath> m_internalPaths{};
/** @brief matrix transformation matrix*/
QTransform matrix;
QTransform matrix{};
/** @brief layoutWidth value layout allowance width in pixels. */
qreal layoutWidth;
qreal layoutWidth{0};
bool mirror;
bool mirror{false};
/** @brief detailLabel detail label rectangle */
QVector<QPointF> detailLabel;
QVector<QPointF> detailLabel{};
/** @brief patternInfo pattern info rectangle */
QVector<QPointF> patternInfo;
QVector<QPointF> patternInfo{};
/** @brief grainlineInfo line */
QVector<QPointF> grainlinePoints;
QVector<QPointF> grainlinePoints{};
ArrowType grainlineArrowType;
qreal grainlineAngle;
bool grainlineEnabled;
ArrowType grainlineArrowType{ArrowType::atFront};
qreal grainlineAngle{0};
bool grainlineEnabled{false};
/** @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 */
VTextManager m_tmPattern;
VTextManager m_tmPattern{};
/** @brief m_placeLabels list of place labels. */
QVector<VLayoutPlaceLabel> m_placeLabels;
QVector<VLayoutPlaceLabel> m_placeLabels{};
qint64 m_square{0};
quint16 m_quantity{1};
private:
Q_DISABLE_ASSIGN(VLayoutPieceData)
@ -177,6 +163,7 @@ inline QDataStream &operator<<(QDataStream &dataStream, const VLayoutPieceData &
dataStream << piece.m_square;
// Added in classVersion = 2
dataStream << piece.m_quantity;
return dataStream;
}
@ -224,10 +211,10 @@ inline QDataStream &operator>>(QDataStream &dataStream, VLayoutPieceData &piece)
dataStream >> piece.m_placeLabels;
dataStream >> piece.m_square;
// if (actualClassVersion >= 2)
// {
// }
if (actualClassVersion >= 2)
{
dataStream >> piece.m_quantity;
}
return dataStream;
}

View File

@ -130,6 +130,8 @@ const QString LONG_OPTION_FOLLOW_GRAINLINE = QStringLiteral("followGrainline");
const QString LONG_OPTION_LANDSCAPE_ORIENTATION = QStringLiteral("landscapeOrientation");
const QString LONG_OPTION_NEST_QUANTITY = QStringLiteral("nestQuantity");
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AllKeys return list with all command line keys (short and long forms). Used for testing on conflicts.
@ -181,6 +183,7 @@ QStringList AllKeys()
LONG_OPTION_TILED_PDF_BOTTOM_MARGIN,
LONG_OPTION_TILED_PDF_LANDSCAPE,
LONG_OPTION_FOLLOW_GRAINLINE,
LONG_OPTION_LANDSCAPE_ORIENTATION
LONG_OPTION_LANDSCAPE_ORIENTATION,
LONG_OPTION_NEST_QUANTITY
};
}

View File

@ -124,6 +124,7 @@ extern const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_LANDSCAPE;
extern const QString LONG_OPTION_FOLLOW_GRAINLINE;
extern const QString LONG_OPTION_LANDSCAPE_ORIENTATION;
extern const QString LONG_OPTION_NEST_QUANTITY;
QStringList AllKeys();

View File

@ -83,6 +83,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSorting, (QLatin1String("l
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperHeight, (QLatin1String("layout/paperHeight")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPaperWidth, (QLatin1String("layout/paperWidth")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutNestQuantity, (QLatin1String("layout/nestQuantity")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCrop, (QLatin1String("layout/autoCrop")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages")))
@ -292,6 +293,24 @@ void VSettings::SetLayoutFollowGrainline(bool value)
setValue(*settingLayoutFollowGrainline, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutNestQuantity() const
{
return value(*settingLayoutNestQuantity, GetDefLayoutNestQuantity()).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutNestQuantity()
{
return false;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutNestQuantity(bool value)
{
setValue(*settingLayoutNestQuantity, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutAutoCrop() const
{

View File

@ -92,6 +92,10 @@ public:
static bool GetDefLayoutFollowGrainline();
void SetLayoutFollowGrainline(bool value);
bool GetLayoutNestQuantity() const;
static bool GetDefLayoutNestQuantity();
void SetLayoutNestQuantity(bool value);
bool GetLayoutAutoCrop() const;
static bool GetDefLayoutAutoCrop();
void SetLayoutAutoCrop(bool value);

View File

@ -138,18 +138,15 @@ void VPieceLabelData::SetFoldPosition(const QString &val)
}
//---------------------------------------------------------------------------------------------------------------------
int VPieceLabelData::GetQuantity() const
quint16 VPieceLabelData::GetQuantity() const
{
return d->m_quantity;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetQuantity(int val)
void VPieceLabelData::SetQuantity(quint16 val)
{
if (val >= 1)
{
d->m_quantity = val;
}
d->m_quantity = qMax(static_cast<quint16>(1), val);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -78,8 +78,8 @@ public:
QString GetFoldPosition() const;
void SetFoldPosition(const QString &val);
int GetQuantity() const;
void SetQuantity(int val);
quint16 GetQuantity() const;
void SetQuantity(quint16 val);
bool IsOnFold() const;
void SetOnFold(bool onFold);

View File

@ -81,7 +81,7 @@ public:
QString m_tilt;
QString m_foldPosition;
int m_quantity;
quint16 m_quantity;
bool m_onFold;
QVector<VLabelTemplateLine> m_lines;

View File

@ -2460,7 +2460,7 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.GetPatternPieceData().SetRotationWay(uiTabLabels->lineEditRotation->text());
piece.GetPatternPieceData().SetTilt(uiTabLabels->lineEditTilt->text());
piece.GetPatternPieceData().SetFoldPosition(uiTabLabels->lineEditFoldPosition->text());
piece.GetPatternPieceData().SetQuantity(uiTabLabels->spinBoxQuantity->value());
piece.GetPatternPieceData().SetQuantity(static_cast<quint16>(uiTabLabels->spinBoxQuantity->value()));
piece.GetPatternPieceData().SetOnFold(uiTabLabels->checkBoxFold->isChecked());
piece.GetPatternPieceData().SetLabelTemplate(m_templateLines);
piece.GetPatternPieceData().SetRotation(GetFormulaFromUser(uiTabLabels->lineEditDLAngleFormula));