New layout generator option: Prefer one sheet solution.

This commit is contained in:
Roman Telezhynskyi 2020-03-22 16:22:03 +02:00
parent a476d47dab
commit 49828889e2
14 changed files with 94 additions and 10 deletions

View File

@ -45,6 +45,7 @@
- Export pattern to DXF-ASTM. - Export pattern to DXF-ASTM.
- [smart-pattern/valentina#18] Auto-created Visibility Group for group operation. - [smart-pattern/valentina#18] Auto-created Visibility Group for group operation.
- Setting scale factor for export and print. - Setting scale factor for export and print.
- New layout generator option: Prefer one sheet solution.
# Version 0.6.2 (unreleased) # Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path. - [#903] Bug in tool Cut Spline path.

View File

@ -1,6 +1,6 @@
.\" Manpage for valentina. .\" Manpage for valentina.
.\" Contact dismine@gmail.com to correct errors. .\" Contact dismine@gmail.com to correct errors.
.TH valentina 1 "21 March, 2020" "valentina man page" .TH valentina 1 "22 March, 2020" "valentina man page"
.SH NAME .SH NAME
Valentina \- Pattern making program. Valentina \- Pattern making program.
.SH SYNOPSIS .SH SYNOPSIS
@ -218,9 +218,9 @@ The path to output destination folder. By default the directory at which the app
.IP "--yscale <Vertical scale>" .IP "--yscale <Vertical scale>"
.RB "Set vertical scale factor from 0.01 to 3.0 (default = 1.0, " "export mode" ")." .RB "Set vertical scale factor from 0.01 to 3.0 (default = 1.0, " "export mode" ")."
.IP "--followGrainline" .IP "--followGrainline"
.RB "Order detail to follow grainline direction (" "export mode" "). .RB "Order detail to follow grainline direction (" "export mode" ")."
.IP "--manualPriority" .IP "--manualPriority"
.RB "Follow manual priority over priority by square (" "export mode" "). .RB "Follow manual priority over priority by square (" "export mode" ")."
.IP "--nestQuantity" .IP "--nestQuantity"
.RB "Nest quantity copies of each piece (" "export mode" "). .RB "Nest quantity copies of each piece (" "export mode" ").
.IP "-c, --crop" .IP "-c, --crop"
@ -229,6 +229,8 @@ The path to output destination folder. By default the directory at which the app
.RB "Auto crop unused width (" "export mode" ")." .RB "Auto crop unused width (" "export mode" ")."
.IP "-u, --unite" .IP "-u, --unite"
.RB "Unite pages if possible (" "export mode" "). Maximum value limited by QImage that supports only a maximum of " "32768x32768 px" " images." .RB "Unite pages if possible (" "export mode" "). Maximum value limited by QImage that supports only a maximum of " "32768x32768 px" " images."
.IP "--preferOneSheetSolution"
.RB "Prefer one sheet layout solution (" "export mode" ")."
.IP "-S, --savelen" .IP "-S, --savelen"
.RB "Save length of the sheet if set (" "export mode" "). The option tells the program to use as much as possible width of sheet. Quality of a layout can be worse when this option was used." .RB "Save length of the sheet if set (" "export mode" "). The option tells the program to use as much as possible width of sheet. Quality of a layout can be worse when this option was used."
.IP "-l, --layounits <The unit>" .IP "-l, --layounits <The unit>"

View File

@ -1,6 +1,6 @@
.\" Manpage for valentina. .\" Manpage for valentina.
.\" Contact dismine@gmail.com to correct errors. .\" Contact dismine@gmail.com to correct errors.
.TH valentina 1 "21 March, 2020" "valentina man page" .TH valentina 1 "22 March, 2020" "valentina man page"
.SH NAME .SH NAME
Valentina \- Pattern making program. Valentina \- Pattern making program.
.SH SYNOPSIS .SH SYNOPSIS
@ -218,9 +218,9 @@ The path to output destination folder. By default the directory at which the app
.IP "--yscale <Vertical scale>" .IP "--yscale <Vertical scale>"
.RB "Set vertical scale factor from 0.01 to 3.0 (default = 1.0, " "export mode" ")." .RB "Set vertical scale factor from 0.01 to 3.0 (default = 1.0, " "export mode" ")."
.IP "--followGrainline" .IP "--followGrainline"
.RB "Order detail to follow grainline direction (" "export mode" "). .RB "Order detail to follow grainline direction (" "export mode" ")."
.IP "--manualPriority" .IP "--manualPriority"
.RB "Follow manual priority over priority by square (" "export mode" "). .RB "Follow manual priority over priority by square (" "export mode" ")."
.IP "--nestQuantity" .IP "--nestQuantity"
.RB "Nest quantity copies of each piece (" "export mode" "). .RB "Nest quantity copies of each piece (" "export mode" ").
.IP "-c, --crop" .IP "-c, --crop"
@ -229,6 +229,8 @@ The path to output destination folder. By default the directory at which the app
.RB "Auto crop unused width (" "export mode" ")." .RB "Auto crop unused width (" "export mode" ")."
.IP "-u, --unite" .IP "-u, --unite"
.RB "Unite pages if possible (" "export mode" "). Maximum value limited by QImage that supports only a maximum of " "32768x32768 px" " images." .RB "Unite pages if possible (" "export mode" "). Maximum value limited by QImage that supports only a maximum of " "32768x32768 px" " images."
.IP "--preferOneSheetSolution"
.RB "Prefer one sheet layout solution (" "export mode" ")."
.IP "-S, --savelen" .IP "-S, --savelen"
.RB "Save length of the sheet if set (" "export mode" "). The option tells the program to use as much as possible width of sheet. Quality of a layout can be worse when this option was used." .RB "Save length of the sheet if set (" "export mode" "). The option tells the program to use as much as possible width of sheet. Quality of a layout can be worse when this option was used."
.IP "-l, --layounits <The unit>" .IP "-l, --layounits <The unit>"

View File

@ -204,6 +204,7 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
diag.SetAutoCropWidth(IsOptionSet(LONG_OPTION_CROP_WIDTH)); diag.SetAutoCropWidth(IsOptionSet(LONG_OPTION_CROP_WIDTH));
diag.SetUnitePages(IsOptionSet(LONG_OPTION_UNITE)); diag.SetUnitePages(IsOptionSet(LONG_OPTION_UNITE));
diag.SetSaveLength(IsOptionSet(LONG_OPTION_SAVELENGTH)); diag.SetSaveLength(IsOptionSet(LONG_OPTION_SAVELENGTH));
diag.SetPreferOneSheetSolution(IsOptionSet(LONG_OPTION_PREFER_ONE_SHEET_SOLUTION));
diag.SetGroup(OptGroup()); diag.SetGroup(OptGroup());
if (IsOptionSet(LONG_OPTION_IGNORE_MARGINS)) if (IsOptionSet(LONG_OPTION_IGNORE_MARGINS))
@ -706,6 +707,8 @@ void VCommandLine::InitCommandLineOptions()
{{SINGLE_OPTION_UNITE, LONG_OPTION_UNITE}, {{SINGLE_OPTION_UNITE, LONG_OPTION_UNITE},
translate("VCommandLine", "Unite pages if possible (export mode). Maximum value limited by QImage that " translate("VCommandLine", "Unite pages if possible (export mode). Maximum value limited by QImage that "
"supports only a maximum of 32768x32768 px images.")}, "supports only a maximum of 32768x32768 px images.")},
{LONG_OPTION_PREFER_ONE_SHEET_SOLUTION,
translate("VCommandLine", "Prefer one sheet layout solution (export mode).")},
//================================================================================================================= //=================================================================================================================
{{SINGLE_OPTION_SAVELENGTH, LONG_OPTION_SAVELENGTH}, {{SINGLE_OPTION_SAVELENGTH, LONG_OPTION_SAVELENGTH},
translate("VCommandLine", "Save length of the sheet if set (export mode). The option tells the program to use " translate("VCommandLine", "Save length of the sheet if set (export mode). The option tells the program to use "

View File

@ -292,6 +292,18 @@ void DialogLayoutSettings::SetSaveLength(bool save)
ui->checkBoxSaveLength->setChecked(save); ui->checkBoxSaveLength->setChecked(save);
} }
//---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::IsPreferOneSheetSolution() const
{
return ui->checkBoxOneSheetSolution->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::SetPreferOneSheetSolution(bool prefer)
{
ui->checkBoxOneSheetSolution->setChecked(prefer);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::IsUnitePages() const bool DialogLayoutSettings::IsUnitePages() const
{ {
@ -600,6 +612,7 @@ void DialogLayoutSettings::DialogAccepted()
generator->SetAutoCropLength(GetAutoCropLength()); generator->SetAutoCropLength(GetAutoCropLength());
generator->SetAutoCropWidth(GetAutoCropWidth()); generator->SetAutoCropWidth(GetAutoCropWidth());
generator->SetSaveLength(IsSaveLength()); generator->SetSaveLength(IsSaveLength());
generator->SetPreferOneSheetSolution(IsPreferOneSheetSolution());
generator->SetUnitePages(IsUnitePages()); generator->SetUnitePages(IsUnitePages());
generator->SetStripOptimization(IsStripOptimization()); generator->SetStripOptimization(IsStripOptimization());
generator->SetMultiplier(GetMultiplier()); generator->SetMultiplier(GetMultiplier());
@ -695,6 +708,7 @@ void DialogLayoutSettings::RestoreDefaults()
SetNestingTime(VSettings::GetDefNestingTime()); SetNestingTime(VSettings::GetDefNestingTime());
SetEfficiencyCoefficient(VSettings::GetDefEfficiencyCoefficient()); SetEfficiencyCoefficient(VSettings::GetDefEfficiencyCoefficient());
SetNestQuantity(VSettings::GetDefLayoutNestQuantity()); SetNestQuantity(VSettings::GetDefLayoutNestQuantity());
SetPreferOneSheetSolution(VSettings::GetDefLayoutPreferOneSheetSolution());
CorrectMaxFileds(); CorrectMaxFileds();
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked()); IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
@ -1019,6 +1033,7 @@ void DialogLayoutSettings::ReadSettings()
SetAutoCropLength(settings->GetLayoutAutoCropLength()); SetAutoCropLength(settings->GetLayoutAutoCropLength());
SetAutoCropWidth(settings->GetLayoutAutoCropWidth()); SetAutoCropWidth(settings->GetLayoutAutoCropWidth());
SetSaveLength(settings->GetLayoutSaveLength()); SetSaveLength(settings->GetLayoutSaveLength());
SetPreferOneSheetSolution(settings->GetLayoutPreferOneSheetSolution());
SetUnitePages(settings->GetLayoutUnitePages()); SetUnitePages(settings->GetLayoutUnitePages());
SetFields(settings->GetFields(GetDefPrinterFields())); SetFields(settings->GetFields(GetDefPrinterFields()));
SetIgnoreAllFields(settings->GetIgnoreAllFields()); SetIgnoreAllFields(settings->GetIgnoreAllFields());
@ -1046,6 +1061,7 @@ void DialogLayoutSettings::WriteSettings() const
settings->SetLayoutAutoCropLength(GetAutoCropLength()); settings->SetLayoutAutoCropLength(GetAutoCropLength());
settings->SetLayoutAutoCropWidth(GetAutoCropWidth()); settings->SetLayoutAutoCropWidth(GetAutoCropWidth());
settings->SetLayoutSaveLength(IsSaveLength()); settings->SetLayoutSaveLength(IsSaveLength());
settings->SetLayoutPreferOneSheetSolution(IsPreferOneSheetSolution());
settings->SetLayoutUnitePages(IsUnitePages()); settings->SetLayoutUnitePages(IsUnitePages());
settings->SetFields(GetFields()); settings->SetFields(GetFields());
settings->SetIgnoreAllFields(IsIgnoreAllFields()); settings->SetIgnoreAllFields(IsIgnoreAllFields());

View File

@ -85,6 +85,9 @@ public:
bool IsSaveLength() const; bool IsSaveLength() const;
void SetSaveLength(bool save); void SetSaveLength(bool save);
bool IsPreferOneSheetSolution() const;
void SetPreferOneSheetSolution(bool prefer);
bool IsUnitePages() const; bool IsUnitePages() const;
void SetUnitePages(bool save); void SetUnitePages(bool save);

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>601</width> <width>601</width>
<height>600</height> <height>645</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -448,6 +448,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBoxOneSheetSolution">
<property name="toolTip">
<string>Enable this option to prefer getting one sheet solutions. </string>
</property>
<property name="text">
<string>Prefer one sheet solution</string>
</property>
</widget>
</item>
<item> <item>
<widget class="Line" name="line_7"> <widget class="Line" name="line_7">
<property name="orientation"> <property name="orientation">

View File

@ -313,7 +313,7 @@ bool MainWindowsNoGUI::GenerateLayout(VLayoutGenerator& lGenerator)
if (lGenerator.PapersCount() <= papersCount) if (lGenerator.PapersCount() <= papersCount)
{ {
const qreal layoutEfficiency = lGenerator.LayoutEfficiency(); const qreal layoutEfficiency = lGenerator.LayoutEfficiency();
if (efficiency < layoutEfficiency) if (efficiency < layoutEfficiency || lGenerator.PapersCount() < papersCount)
{ {
efficiency = layoutEfficiency; efficiency = layoutEfficiency;
if (VApplication::IsGUIMode()) if (VApplication::IsGUIMode())
@ -404,7 +404,11 @@ bool MainWindowsNoGUI::GenerateLayout(VLayoutGenerator& lGenerator)
|| (nestingState == LayoutErrors::NoError && not qFuzzyIsNull(lGenerator.GetEfficiencyCoefficient()) || (nestingState == LayoutErrors::NoError && not qFuzzyIsNull(lGenerator.GetEfficiencyCoefficient())
&& efficiency >= lGenerator.GetEfficiencyCoefficient())) && efficiency >= lGenerator.GetEfficiencyCoefficient()))
{ {
break; if (not lGenerator.IsPreferOneSheetSolution()
|| (lGenerator.IsPreferOneSheetSolution() && lGenerator.PapersCount() == 1))
{
break;
}
} }
if (IsTimeout()) if (IsTimeout())

View File

@ -680,6 +680,18 @@ void VLayoutGenerator::SetSaveLength(bool value)
saveLength = value; saveLength = value;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutGenerator::IsPreferOneSheetSolution() const
{
return preferOneSheetSolution;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::SetPreferOneSheetSolution(bool value)
{
preferOneSheetSolution = value;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VLayoutGenerator::GetAutoCropLength() const bool VLayoutGenerator::GetAutoCropLength() const
{ {

View File

@ -117,6 +117,9 @@ public:
bool IsSaveLength() const; bool IsSaveLength() const;
void SetSaveLength(bool value); void SetSaveLength(bool value);
bool IsPreferOneSheetSolution() const;
void SetPreferOneSheetSolution(bool value);
bool IsUnitePages() const; bool IsUnitePages() const;
void SetUnitePages(bool value); void SetUnitePages(bool value);
@ -154,6 +157,7 @@ private:
bool autoCropLength; bool autoCropLength;
bool autoCropWidth; bool autoCropWidth;
bool saveLength; bool saveLength;
bool preferOneSheetSolution{false};
bool unitePages; bool unitePages;
bool stripOptimizationEnabled; bool stripOptimizationEnabled;
quint8 multiplier; quint8 multiplier;

View File

@ -136,6 +136,7 @@ const QString LONG_OPTION_MANUAL_PRIORITY = QStringLiteral("manualPriority");
const QString LONG_OPTION_LANDSCAPE_ORIENTATION = QStringLiteral("landscapeOrientation"); const QString LONG_OPTION_LANDSCAPE_ORIENTATION = QStringLiteral("landscapeOrientation");
const QString LONG_OPTION_NEST_QUANTITY = QStringLiteral("nestQuantity"); const QString LONG_OPTION_NEST_QUANTITY = QStringLiteral("nestQuantity");
const QString LONG_OPTION_PREFER_ONE_SHEET_SOLUTION = QStringLiteral("preferOneSheetSolution");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -193,6 +194,7 @@ QStringList AllKeys()
LONG_OPTION_FOLLOW_GRAINLINE, LONG_OPTION_FOLLOW_GRAINLINE,
LONG_OPTION_MANUAL_PRIORITY, LONG_OPTION_MANUAL_PRIORITY,
LONG_OPTION_LANDSCAPE_ORIENTATION, LONG_OPTION_LANDSCAPE_ORIENTATION,
LONG_OPTION_NEST_QUANTITY LONG_OPTION_NEST_QUANTITY,
LONG_OPTION_PREFER_ONE_SHEET_SOLUTION
}; };
} }

View File

@ -130,6 +130,7 @@ extern const QString LONG_OPTION_FOLLOW_GRAINLINE;
extern const QString LONG_OPTION_MANUAL_PRIORITY; extern const QString LONG_OPTION_MANUAL_PRIORITY;
extern const QString LONG_OPTION_LANDSCAPE_ORIENTATION; extern const QString LONG_OPTION_LANDSCAPE_ORIENTATION;
extern const QString LONG_OPTION_NEST_QUANTITY; extern const QString LONG_OPTION_NEST_QUANTITY;
extern const QString LONG_OPTION_PREFER_ONE_SHEET_SOLUTION;
QStringList AllKeys(); QStringList AllKeys();

View File

@ -91,6 +91,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutNestQuantity, (QLatin1Stri
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropLength, (QLatin1String("layout/autoCropLength"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropLength, (QLatin1String("layout/autoCropLength")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropWidth, (QLatin1String("layout/autoCropWidth"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutAutoCropWidth, (QLatin1String("layout/autoCropWidth")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSaveLength, (QLatin1String("layout/saveLength")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPreferOneSheetSolution,
(QLatin1String("layout/preferOneSheetSolution")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutUnitePages, (QLatin1String("layout/unitePages")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFields, (QLatin1String("layout/fields"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingFields, (QLatin1String("layout/fields")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, (QLatin1String("layout/ignoreFields"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, (QLatin1String("layout/ignoreFields")))
@ -426,6 +428,24 @@ void VSettings::SetLayoutSaveLength(bool value)
setValue(*settingLayoutSaveLength, value); setValue(*settingLayoutSaveLength, value);
} }
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutPreferOneSheetSolution() const
{
return value(*settingLayoutPreferOneSheetSolution, GetDefLayoutPreferOneSheetSolution()).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutPreferOneSheetSolution()
{
return false;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutPreferOneSheetSolution(bool value)
{
setValue(*settingLayoutPreferOneSheetSolution, value);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutUnitePages() const bool VSettings::GetLayoutUnitePages() const
{ {

View File

@ -110,6 +110,10 @@ public:
static bool GetDefLayoutSaveLength(); static bool GetDefLayoutSaveLength();
void SetLayoutSaveLength(bool value); void SetLayoutSaveLength(bool value);
bool GetLayoutPreferOneSheetSolution() const;
static bool GetDefLayoutPreferOneSheetSolution();
void SetLayoutPreferOneSheetSolution(bool value);
bool GetLayoutUnitePages() const; bool GetLayoutUnitePages() const;
static bool GetDefLayoutUnitePages(); static bool GetDefLayoutUnitePages();
void SetLayoutUnitePages(bool value); void SetLayoutUnitePages(bool value);