Changes for dialog.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2019-03-29 11:31:17 +02:00
parent 0616dc5540
commit 47bcfd74ab
11 changed files with 229 additions and 436 deletions

View file

@ -110,19 +110,6 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
}
{
//just anonymous namespace ...don' like to have a,b,c,d everywhere defined
bool a = IsOptionSet(LONG_OPTION_SHIFTLENGTH);
bool b = IsOptionSet(LONG_OPTION_SHIFTUNITS);
if ((a || b) && !(a && b))
{
qCritical() << translate("VCommandLine", "Shift/Offset length must be used together with shift units.")
<< "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
{
//just anonymous namespace ...don' like to have a,b,c,d everywhere defined
bool a = IsOptionSet(LONG_OPTION_GAPWIDTH);
@ -163,19 +150,6 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
CheckKey(LONG_OPTION_TILED_PDF_BOTTOM_MARGIN,
translate("VCommandLine", "Tiled bottom margin must be used together with page units."));
const int rotateDegree = OptRotation();
diag.SetRotate(rotateDegree != 0 ); // 0 disable rotation
if (rotateDegree != VSettings::GetDefLayoutRotationIncrease())//Value by default
{
if (not diag.SetIncrease(rotateDegree))
{
qCritical() << translate("VCommandLine", "Invalid rotation value. That must be one of predefined values.")
<< "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
// if present units MUST be set before any other to keep conversions correct
if (!diag.SelectTemplate(OptPaperSize()))
{
@ -212,11 +186,6 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
}
}
if (IsOptionSet(LONG_OPTION_SHIFTLENGTH))
{
diag.SetShift(Lo2Px(OptionValue(LONG_OPTION_SHIFTLENGTH), diag));
}
if (IsOptionSet(LONG_OPTION_GAPWIDTH))
{
diag.SetLayoutWidth(Lo2Px(OptionValue(LONG_OPTION_GAPWIDTH), diag));
@ -256,6 +225,8 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
diag.SetFields(margins);
diag.SetFollowGrainline(IsOptionSet(LONG_OPTION_FOLLOW_GRAINLINE));
diag.SetNestingTime(OptNestingTime());
diag.SetEfficiencyCoefficient(OptEfficiencyCoefficient());
diag.DialogAccepted(); // filling VLayoutGenerator
@ -340,24 +311,6 @@ VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::OptPaperSize() const
return FormatSize(LONG_OPTION_PAGETEMPLATE);
}
//------------------------------------------------------------------------------------------------------
int VCommandLine::OptRotation() const
{
int rotate = VSettings::GetDefLayoutRotationIncrease();
if (IsOptionSet(LONG_OPTION_ROTATE))
{
bool ok = false;
rotate = OptionValue(LONG_OPTION_ROTATE).toInt(&ok);
if (not ok)
{
rotate = VSettings::GetDefLayoutRotationIncrease();
}
}
return rotate;
}
//------------------------------------------------------------------------------------------------------
Cases VCommandLine::OptGroup() const
{
@ -635,6 +588,24 @@ void VCommandLine::InitCommandLineOptions()
optionsUsed.insert(LONG_OPTION_MEASUREFILE, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_NESTING_TIME, LONG_OPTION_NESTING_TIME}),
translate("VCommandLine", "<Time> in minutes given for the algorithm to find best "
"layout. Time must be in range from 1 minute to 60 "
"minutes. Default value 1 minute."),
translate("VCommandLine", "Time"));
optionsUsed.insert(LONG_OPTION_NESTING_TIME, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_EFFICIENCY_COEFFICIENT, LONG_OPTION_EFFICIENCY_COEFFICIENT}),
translate("VCommandLine", "Set layout efficiency coefficient. Layout efficiency "
"coefficient is the ratio of the area occupied by the pieces "
"to the entire area of the sheet. If nesting reaches "
"required level the process stops. If value is 0 no check "
"will be made. Сoefficient must be in range from 0 to 100. "
"Default value 0."));
optionsUsed.insert(LONG_OPTION_EFFICIENCY_COEFFICIENT, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_EXP2FORMAT, LONG_OPTION_EXP2FORMAT}),
translate("VCommandLine", "Number corresponding to output format (default = 0, "
"export mode):") +
@ -773,18 +744,6 @@ void VCommandLine::InitCommandLineOptions()
parser.addOption(option);
//=================================================================================================================
option = VCommandLineOption(QStringList({SINGLE_OPTION_ROTATE, LONG_OPTION_ROTATE}),
translate("VCommandLine", "Rotation in degrees (one of predefined, export mode). "
"Default value is 180. 0 is no-rotate. Valid values: "
"%1. Each value show how many times details will be "
"rotated. For example 180 mean two times (360/180=2) "
"by 180 degree.")
.arg("0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, 60, 72, 90, "
"180"),
translate("VCommandLine", "Angle"));
optionsUsed.insert(LONG_OPTION_ROTATE, option);
parser.addOption(option);
option = VCommandLineOption(LONG_OPTION_FOLLOW_GRAINLINE,
translate("VCommandLine", "Order detail to follow grainline direction (export mode)."));
optionsUsed.insert(LONG_OPTION_FOLLOW_GRAINLINE, option);
@ -817,14 +776,6 @@ void VCommandLine::InitCommandLineOptions()
optionsUsed.insert(LONG_OPTION_SHIFTUNITS, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_SHIFTLENGTH, LONG_OPTION_SHIFTLENGTH}),
translate("VCommandLine", "Shift/Offset layout length measured in layout units "
"(export mode). The option show how many points along "
"edge will be used in creating a layout."),
translate("VCommandLine", "Shift/Offset length"));
optionsUsed.insert(LONG_OPTION_SHIFTLENGTH, option);
parser.addOption(option);
option = VCommandLineOption(QStringList({SINGLE_OPTION_GAPWIDTH, LONG_OPTION_GAPWIDTH}),
translate("VCommandLine", "The layout gap width x2, measured in layout units "
"(export mode). Set distance between details and a "
@ -973,4 +924,44 @@ QStringList VCommandLine::OptionValues(const QString &option) const
return parser.values(optionsUsed.value(option));
}
//---------------------------------------------------------------------------------------------------------------------
int VCommandLine::OptNestingTime() const
{
int time = VSettings::GetDefNestingTime();
if (IsOptionSet(LONG_OPTION_NESTING_TIME))
{
bool ok = false;
time = OptionValue(LONG_OPTION_NESTING_TIME).toInt(&ok);
if (not ok || time < 1 || time > 60)
{
qCritical() << translate("VCommandLine", "Time must be in range from 1 minute to 60 minutes.")
<< "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
return time;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCommandLine::OptEfficiencyCoefficient() const
{
qreal coefficient = VSettings::GetDefEfficiencyCoefficient();
if (IsOptionSet(LONG_OPTION_EFFICIENCY_COEFFICIENT))
{
bool ok = false;
coefficient = OptionValue(LONG_OPTION_EFFICIENCY_COEFFICIENT).toDouble(&ok);
if (not ok || coefficient < 0 || coefficient > 100)
{
qCritical() << translate("VCommandLine", "Сoefficient must be in range from 0 to 100.")
<< "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
return coefficient;
}
#undef translate

View file

@ -150,8 +150,6 @@ protected:
//@brief returns VAbstractLayoutDialog::PaperSizeTemplate
VAbstractLayoutDialog::PaperSizeTemplate OptPaperSize() const;
//@brief returns rotation in degrees or 0 if not set
int OptRotation() const;
Cases OptGroup() const;
@ -175,6 +173,9 @@ private:
bool IsOptionSet(const QString &option) const;
QString OptionValue(const QString &option) const;
QStringList OptionValues(const QString &option) const;
int OptNestingTime() const;
qreal OptEfficiencyCoefficient() const;
};
#endif // VCMDEXPORT_H

View file

@ -141,15 +141,27 @@ void DialogLayoutSettings::SetPaperWidth(qreal value)
}
//---------------------------------------------------------------------------------------------------------------------
qreal DialogLayoutSettings::GetShift() const
int DialogLayoutSettings::GetNestingTime() const
{
return UnitConvertor(ui->doubleSpinBoxShift->value(), oldLayoutUnit, Unit::Px);
return ui->spinBoxNestingTime->value();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::SetShift(qreal value)
void DialogLayoutSettings::SetNestingTime(int value)
{
ui->doubleSpinBoxShift->setValue(UnitConvertor(value, Unit::Px, LayoutUnit()));
ui->spinBoxNestingTime->setValue(value);
}
//---------------------------------------------------------------------------------------------------------------------
qreal DialogLayoutSettings::GetEfficiencyCoefficient() const
{
return ui->doubleSpinBoxEfficiency->value();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::SetEfficiencyCoefficient(qreal ration)
{
ui->doubleSpinBoxEfficiency->setValue(ration);
}
//---------------------------------------------------------------------------------------------------------------------
@ -220,18 +232,6 @@ void DialogLayoutSettings::SetGroup(const Cases &value)
}
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::GetRotate() const
{
return ui->groupBoxRotate->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::SetRotate(bool state)
{
ui->groupBoxRotate->setChecked(state);
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::GetFollowGrainline() const
{
@ -244,28 +244,6 @@ void DialogLayoutSettings::SetFollowGrainline(bool state)
ui->checkBoxFollowGrainline->setChecked(state);
}
//---------------------------------------------------------------------------------------------------------------------
int DialogLayoutSettings::GetIncrease() const
{
return ui->comboBoxIncrease->currentText().toInt();
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
bool DialogLayoutSettings::SetIncrease(int increase)
{
int index = ui->comboBoxIncrease->findText(QString::number(increase));
bool failed = (index == -1);
if (failed)
{
const QString def = QString::number(VSettings::GetDefLayoutRotationIncrease());// Value by default
index = ui->comboBoxIncrease->findText(def);
}
ui->comboBoxIncrease->setCurrentIndex(index);
return failed;
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::GetAutoCrop() const
{
@ -512,20 +490,16 @@ void DialogLayoutSettings::ConvertLayoutSize()
{
const Unit unit = LayoutUnit();
const qreal layoutWidth = ui->doubleSpinBoxLayoutWidth->value();
const qreal shift = ui->doubleSpinBoxShift->value();
ui->doubleSpinBoxLayoutWidth->setMaximum(FromPixel(QIMAGE_MAX, unit));
ui->doubleSpinBoxShift->setMaximum(FromPixel(QIMAGE_MAX, unit));
const qreal newLayoutWidth = UnitConvertor(layoutWidth, oldLayoutUnit, unit);
const qreal newShift = UnitConvertor(shift, oldLayoutUnit, unit);
oldLayoutUnit = unit;
CorrectLayoutDecimals();
MinimumLayoutSize();
ui->doubleSpinBoxLayoutWidth->setValue(newLayoutWidth);
ui->doubleSpinBoxShift->setValue(newShift);
}
//---------------------------------------------------------------------------------------------------------------------
@ -583,10 +557,9 @@ void DialogLayoutSettings::DialogAccepted()
generator->SetCaseType(GetGroup());
generator->SetPaperHeight(GetPaperHeight());
generator->SetPaperWidth(GetPaperWidth());
generator->SetShift(static_cast<quint32>(qFloor(GetShift())));
generator->SetRotate(GetRotate());
generator->SetNestingTime(GetNestingTime());
generator->SetEfficiencyCoefficient(GetEfficiencyCoefficient());
generator->SetFollowGrainline(GetFollowGrainline());
generator->SetRotationIncrease(GetIncrease());
generator->SetAutoCrop(GetAutoCrop());
generator->SetSaveLength(IsSaveLength());
generator->SetUnitePages(IsUnitePages());
@ -674,14 +647,13 @@ void DialogLayoutSettings::RestoreDefaults()
ui->comboBoxPrinter->blockSignals(false);
SetLayoutWidth(VSettings::GetDefLayoutWidth());
SetShift(VSettings::GetDefLayoutShift());
SetGroup(VSettings::GetDefLayoutGroup());
SetRotate(VSettings::GetDefLayoutRotate());
SetFollowGrainline(VSettings::GetDefLayoutFollowGrainline());
SetIncrease(VSettings::GetDefLayoutRotationIncrease());
SetFields(GetDefPrinterFields());
SetIgnoreAllFields(VSettings::GetDefIgnoreAllFields());
SetMultiplier(VSettings::GetDefMultiplier());
SetNestingTime(VSettings::GetDefNestingTime());
SetEfficiencyCoefficient(VSettings::GetDefEfficiencyCoefficient());
CorrectMaxFileds();
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
@ -990,11 +962,9 @@ void DialogLayoutSettings::CorrectLayoutDecimals()
case Unit::Mm:
case Unit::Px:
ui->doubleSpinBoxLayoutWidth->setDecimals(2);
ui->doubleSpinBoxShift->setDecimals(2);
break;
case Unit::Inch:
ui->doubleSpinBoxLayoutWidth->setDecimals(5);
ui->doubleSpinBoxShift->setDecimals(5);
break;
default:
break;
@ -1021,15 +991,14 @@ void DialogLayoutSettings::ReadSettings()
{
const VSettings *settings = qApp->ValentinaSettings();
SetLayoutWidth(settings->GetLayoutWidth());
SetShift(settings->GetLayoutShift());
SetNestingTime(settings->GetNestingTime());
SetEfficiencyCoefficient(settings->GetEfficiencyCoefficient());
const qreal width = UnitConvertor(settings->GetLayoutPaperWidth(), Unit::Px, LayoutUnit());
const qreal height = UnitConvertor(settings->GetLayoutPaperHeight(), Unit::Px, LayoutUnit());
SheetSize(QSizeF(width, height));
SetGroup(settings->GetLayoutGroup());
SetFollowGrainline(settings->GetLayoutFollowGrainline());
SetRotate(settings->GetLayoutRotate());
SetIncrease(settings->GetLayoutRotationIncrease());
SetAutoCrop(settings->GetLayoutAutoCrop());
SetSaveLength(settings->GetLayoutSaveLength());
SetUnitePages(settings->GetLayoutUnitePages());
@ -1053,10 +1022,7 @@ void DialogLayoutSettings::WriteSettings() const
settings->SetLayoutGroup(GetGroup());
settings->SetLayoutPaperHeight(GetPaperHeight());
settings->SetLayoutPaperWidth(GetPaperWidth());
settings->SetLayoutShift(GetShift());
settings->SetLayoutRotate(GetRotate());
settings->SetLayoutFollowGrainline(GetFollowGrainline());
settings->SetLayoutRotationIncrease(GetIncrease());
settings->SetLayoutAutoCrop(GetAutoCrop());
settings->SetLayoutSaveLength(IsSaveLength());
settings->SetLayoutUnitePages(IsUnitePages());
@ -1065,6 +1031,8 @@ void DialogLayoutSettings::WriteSettings() const
settings->SetStripOptimization(IsStripOptimization());
settings->SetMultiplier(GetMultiplier());
settings->SetTextAsPaths(IsTextAsPaths());
settings->SetNestingTime(GetNestingTime());
settings->SetEfficiencyCoefficient(GetEfficiencyCoefficient());
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -61,8 +61,11 @@ public:
qreal GetPaperWidth() const;
void SetPaperWidth(qreal value);
qreal GetShift() const;
void SetShift(qreal value);
int GetNestingTime() const;
void SetNestingTime(int value);
qreal GetEfficiencyCoefficient() const;
void SetEfficiencyCoefficient(qreal ration);
qreal GetLayoutWidth() const;
void SetLayoutWidth(qreal value);
@ -73,15 +76,9 @@ public:
Cases GetGroup() const;
void SetGroup(const Cases &value);
bool GetRotate() const;
void SetRotate(bool state);
bool GetFollowGrainline() const;
void SetFollowGrainline(bool state);
int GetIncrease() const;
bool SetIncrease(int increase);
bool GetAutoCrop() const;
void SetAutoCrop(bool autoCrop);

View file

@ -361,6 +361,39 @@
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Time:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QComboBox" name="comboBoxLayoutUnit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelLayoutWidth">
<property name="text">
<string>Gap width:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxNestingTime">
<property name="toolTip">
<string>Time given for the algorithm to find best layout.</string>
</property>
<property name="suffix">
<string> min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>60</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxLayoutWidth">
<property name="minimumSize">
@ -369,6 +402,9 @@
<height>0</height>
</size>
</property>
<property name="suffix">
<string notr="true"> ×2</string>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
@ -380,43 +416,26 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelLayoutWidth">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Gap width:</string>
<string>Efficiency:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelShiftLength">
<property name="text">
<string>Shift/Offset length:</string>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxEfficiency">
<property name="toolTip">
<string>Set layout efficiency coefficient. Layout efficiency coefficientt is the ratio of the area occupied by the pieces to the entire area of the sheet. If nesting reaches required level the process stops. If value is 0 no check will be made. </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxShift">
<property name="minimumSize">
<size>
<width>94</width>
<height>0</height>
</size>
<property name="suffix">
<string>%</string>
</property>
<property name="maximum">
<double>99999.990000000005239</double>
<property name="decimals">
<number>1</number>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="comboBoxLayoutUnit"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string notr="true">×2</string>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
@ -443,165 +462,6 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxRotate">
<property name="title">
<string>Rotate workpiece</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Rotate by</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxIncrease">
<property name="currentIndex">
<number>21</number>
</property>
<item>
<property name="text">
<string notr="true">1</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">2</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">3</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">4</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">5</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">6</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">8</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">9</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">10</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">12</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">15</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">18</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">20</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">24</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">30</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">36</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">40</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">45</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">60</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">72</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">90</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">180</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>degree</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
@ -782,7 +642,7 @@
</connection>
</connections>
<buttongroups>
<buttongroup name="buttonGroupPrinciple"/>
<buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroupPrinciple"/>
</buttongroups>
</ui>

View file

@ -643,6 +643,30 @@ void VLayoutGenerator::SetPaperWidth(qreal value)
paperWidth = value;
}
//---------------------------------------------------------------------------------------------------------------------
int VLayoutGenerator::GetNestingTime() const
{
return nestingTime;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::SetNestingTime(int value)
{
nestingTime = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VLayoutGenerator::GetEfficiencyRatio() const
{
return efficiencyCoefficient;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::SetEfficiencyCoefficient(qreal coefficient)
{
efficiencyCoefficient = coefficient;
}
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutGenerator::IsUsePrinterFields() const
{

View file

@ -71,6 +71,12 @@ public:
qreal GetPaperWidth() const;
void SetPaperWidth(qreal value);
int GetNestingTime() const;
void SetNestingTime(int value);
qreal GetEfficiencyRatio() const;
void SetEfficiencyCoefficient(qreal coefficient);
bool IsUsePrinterFields() const;
QMarginsF GetPrinterFields() const;
void SetPrinterFields(bool usePrinterFields, const QMarginsF &value);
@ -145,6 +151,8 @@ private:
quint8 multiplier;
bool stripOptimization;
bool textAsPaths;
int nestingTime{1};
qreal efficiencyCoefficient{0.0};
int PageHeight() const;
int PageWidth() const;

View file

@ -54,9 +54,6 @@ const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths");
const QString LONG_OPTION_EXPORTONLYDETAILS = QStringLiteral("exportOnlyDetails");
const QString LONG_OPTION_EXPORTSUCHDETAILS = QStringLiteral("exportSuchDetails");
const QString LONG_OPTION_ROTATE = QStringLiteral("rotate");
const QString SINGLE_OPTION_ROTATE = QStringLiteral("r");
const QString LONG_OPTION_CROP = QStringLiteral("crop");
const QString SINGLE_OPTION_CROP = QStringLiteral("c");
@ -75,9 +72,6 @@ const QString SINGLE_OPTION_PAGEUNITS = QStringLiteral("U");
const QString LONG_OPTION_SAVELENGTH = QStringLiteral("savelen");
const QString SINGLE_OPTION_SAVELENGTH = QStringLiteral("S");
const QString LONG_OPTION_SHIFTLENGTH = QStringLiteral("shiftlen");
const QString SINGLE_OPTION_SHIFTLENGTH = QStringLiteral("s");
const QString LONG_OPTION_SHIFTUNITS = QStringLiteral("layounits");
const QString SINGLE_OPTION_SHIFTUNITS = QStringLiteral("l");
@ -115,6 +109,12 @@ const QString SINGLE_OPTION_TOP_MARGIN = QStringLiteral("T");
const QString LONG_OPTION_BOTTOM_MARGIN = QStringLiteral("bmargin");
const QString SINGLE_OPTION_BOTTOM_MARGIN = QStringLiteral("B");
const QString LONG_OPTION_NESTING_TIME = QStringLiteral("time");
const QString SINGLE_OPTION_NESTING_TIME = QStringLiteral("n");
const QString LONG_OPTION_EFFICIENCY_COEFFICIENT = QStringLiteral("сoefficient");
const QString SINGLE_OPTION_EFFICIENCY_COEFFICIENT= QStringLiteral("e");
const QString LONG_OPTION_CSVWITHHEADER = QStringLiteral("csvWithHeader");
const QString LONG_OPTION_CSVCODEC = QStringLiteral("csvCodec");
const QString LONG_OPTION_CSVSEPARATOR = QStringLiteral("csvSeparator");
@ -148,14 +148,12 @@ QStringList AllKeys()
<< LONG_OPTION_TEXT2PATHS
<< LONG_OPTION_EXPORTONLYDETAILS
<< LONG_OPTION_EXPORTSUCHDETAILS
<< LONG_OPTION_ROTATE << SINGLE_OPTION_ROTATE
<< LONG_OPTION_CROP << SINGLE_OPTION_CROP
<< LONG_OPTION_UNITE << SINGLE_OPTION_UNITE
<< LONG_OPTION_PAGEW << SINGLE_OPTION_PAGEW
<< LONG_OPTION_PAGEH << SINGLE_OPTION_PAGEH
<< LONG_OPTION_PAGEUNITS << SINGLE_OPTION_PAGEUNITS
<< LONG_OPTION_SAVELENGTH << SINGLE_OPTION_SAVELENGTH
<< LONG_OPTION_SHIFTLENGTH << SINGLE_OPTION_SHIFTLENGTH
<< LONG_OPTION_SHIFTUNITS << SINGLE_OPTION_SHIFTUNITS
<< LONG_OPTION_GAPWIDTH << SINGLE_OPTION_GAPWIDTH
<< LONG_OPTION_GROUPPING << SINGLE_OPTION_GROUPPING
@ -169,6 +167,8 @@ QStringList AllKeys()
<< LONG_OPTION_RIGHT_MARGIN << SINGLE_OPTION_RIGHT_MARGIN
<< LONG_OPTION_TOP_MARGIN << SINGLE_OPTION_TOP_MARGIN
<< LONG_OPTION_BOTTOM_MARGIN << SINGLE_OPTION_BOTTOM_MARGIN
<< LONG_OPTION_NESTING_TIME << SINGLE_OPTION_NESTING_TIME
<< LONG_OPTION_EFFICIENCY_COEFFICIENT << SINGLE_OPTION_EFFICIENCY_COEFFICIENT
<< LONG_OPTION_NO_HDPI_SCALING
<< LONG_OPTION_CSVWITHHEADER
<< LONG_OPTION_CSVCODEC

View file

@ -51,9 +51,6 @@ extern const QString LONG_OPTION_TEXT2PATHS;
extern const QString LONG_OPTION_EXPORTONLYDETAILS;
extern const QString LONG_OPTION_EXPORTSUCHDETAILS;
extern const QString LONG_OPTION_ROTATE;
extern const QString SINGLE_OPTION_ROTATE;
extern const QString LONG_OPTION_CROP;
extern const QString SINGLE_OPTION_CROP;
@ -72,9 +69,6 @@ extern const QString SINGLE_OPTION_PAGEUNITS;
extern const QString LONG_OPTION_SAVELENGTH;
extern const QString SINGLE_OPTION_SAVELENGTH;
extern const QString LONG_OPTION_SHIFTLENGTH;
extern const QString SINGLE_OPTION_SHIFTLENGTH;
extern const QString LONG_OPTION_SHIFTUNITS;
extern const QString SINGLE_OPTION_SHIFTUNITS;
@ -112,6 +106,12 @@ extern const QString SINGLE_OPTION_TOP_MARGIN;
extern const QString LONG_OPTION_BOTTOM_MARGIN;
extern const QString SINGLE_OPTION_BOTTOM_MARGIN;
extern const QString LONG_OPTION_NESTING_TIME;
extern const QString SINGLE_OPTION_NESTING_TIME;
extern const QString LONG_OPTION_EFFICIENCY_COEFFICIENT;
extern const QString SINGLE_OPTION_EFFICIENCY_COEFFICIENT;
extern const QString LONG_OPTION_CSVWITHHEADER;
extern const QString LONG_OPTION_CSVCODEC;
extern const QString LONG_OPTION_CSVSEPARATOR;

View file

@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
**
** @file vsettings.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
@ -82,10 +82,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWidth, (QLatin1String("lay
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutSorting, (QLatin1String("layout/sorting")))
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, settingLayoutShift, (QLatin1String("layout/shift")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutRotate, (QLatin1String("layout/Rotate")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutRotationIncrease, (QLatin1String("layout/rotationIncrease")))
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")))
@ -94,6 +91,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingIgnoreFields, (QLatin1String("la
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingStripOptimization, (QLatin1String("layout/stripOptimization")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingMultiplier, (QLatin1String("layout/multiplier")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTextAsPaths, (QLatin1String("layout/textAsPaths")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingNestingTime, (QLatin1String("layout/time")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingEfficiencyCoefficient, (QLatin1String("layout/efficiencyCoefficient")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFMargins, (QLatin1String("tiledPDF/margins")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingTiledPDFPaperHeight, (QLatin1String("tiledPDF/paperHeight")))
@ -223,34 +222,6 @@ void VSettings::SetLayoutPaperWidth(qreal value)
setValue(*settingLayoutPaperWidth, value);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetLayoutShift() const
{
const qreal def = GetDefLayoutShift();
bool ok = false;
const qreal shift = value(*settingLayoutShift, def).toDouble(&ok);
if (ok)
{
return shift;
}
else
{
return def;
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetDefLayoutShift()
{
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutShift(qreal value)
{
setValue(*settingLayoutShift, value);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetLayoutWidth() const
{
@ -279,6 +250,36 @@ void VSettings::SetLayoutWidth(qreal value)
setValue(*settingLayoutWidth, value);
}
//---------------------------------------------------------------------------------------------------------------------
int VSettings::GetNestingTime() const
{
const int def = GetDefNestingTime();
bool ok = false;
const int time = value(*settingNestingTime, def).toInt(&ok);
return ok ? time : def;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetNestingTime(int value)
{
setValue(*settingNestingTime, value);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSettings::GetEfficiencyCoefficient() const
{
const qreal def = GetDefEfficiencyCoefficient();
bool ok = false;
const qreal coefficient = value(*settingEfficiencyCoefficient, def).toDouble(&ok);
return ok ? coefficient : def;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetEfficiencyCoefficient(qreal value)
{
setValue(*settingEfficiencyCoefficient, value);
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VSettings::GetFields(const QMarginsF &def) const
{
@ -331,24 +332,6 @@ void VSettings::SetLayoutGroup(const Cases &value)
setValue(*settingLayoutSorting, static_cast<int>(value));
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutRotate() const
{
return value(*settingLayoutRotate, GetDefLayoutRotate()).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefLayoutRotate()
{
return false;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutRotate(bool value)
{
setValue(*settingLayoutRotate, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutFollowGrainline() const
{
@ -367,41 +350,6 @@ void VSettings::SetLayoutFollowGrainline(bool value)
setValue(*settingLayoutFollowGrainline, value);
}
//---------------------------------------------------------------------------------------------------------------------
int VSettings::GetLayoutRotationIncrease() const
{
const int def = GetDefLayoutRotationIncrease();
bool ok = false;
const int r = value(*settingLayoutRotationIncrease, def).toInt(&ok);
if (ok)
{
if (not (r >= 1 && r <= 180 && 360 % r == 0))
{
return def;
}
else
{
return r;
}
}
else
{
return def;
}
}
//---------------------------------------------------------------------------------------------------------------------
int VSettings::GetDefLayoutRotationIncrease()
{
return 180;/*degree*/
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLayoutRotationIncrease(int value)
{
setValue(*settingLayoutRotationIncrease, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetLayoutAutoCrop() const
{

View file

@ -74,14 +74,18 @@ public:
qreal GetLayoutPaperWidth() const;
void SetLayoutPaperWidth(qreal value);
qreal GetLayoutShift() const;
static qreal GetDefLayoutShift();
void SetLayoutShift(qreal value);
qreal GetLayoutWidth() const;
static qreal GetDefLayoutWidth();
void SetLayoutWidth(qreal value);
int GetNestingTime() const;
static int GetDefNestingTime(){return 1;}
void SetNestingTime(int value);
qreal GetEfficiencyCoefficient() const;
static qreal GetDefEfficiencyCoefficient(){return 0.0;}
void SetEfficiencyCoefficient(qreal value);
QMarginsF GetFields(const QMarginsF &def = QMarginsF()) const;
void SetFields(const QMarginsF &value);
@ -89,18 +93,10 @@ public:
static Cases GetDefLayoutGroup();
void SetLayoutGroup(const Cases &value);
bool GetLayoutRotate() const;
static bool GetDefLayoutRotate();
void SetLayoutRotate(bool value);
bool GetLayoutFollowGrainline() const;
static bool GetDefLayoutFollowGrainline();
void SetLayoutFollowGrainline(bool value);
int GetLayoutRotationIncrease() const;
static int GetDefLayoutRotationIncrease();
void SetLayoutRotationIncrease(int value);
bool GetLayoutAutoCrop() const;
static bool GetDefLayoutAutoCrop();
void SetLayoutAutoCrop(bool value);