Fix issue. User should be able to control tiled pdf export through command line.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-10-13 17:48:20 +03:00
parent 0da31099f3
commit d15e507aeb
12 changed files with 512 additions and 199 deletions

View file

@ -1,6 +1,6 @@
.\" Manpage for valentina.
.\" Contact dismine@gmail.com to correct errors.
.TH valentina 1 "28 September, 2017" "valentina man page"
.TH valentina 1 "12 October, 2017" "valentina man page"
.SH NAME
Valentina \- Pattern making program.
.SH SYNOPSIS
@ -113,7 +113,7 @@ The path to output destination folder. By default the directory at which the app
.IP "-e, --gheight <The height value>"
.RB "Set height value a pattern file, that was opened with multisize measurements (" "export mode" "). Valid values: 92, 98, 104, 110, 116, 122, 128, 134, 140, 146, 152, 158, 164, 170, 176, 182, 188, 194, 200cm."
.IP "-p, --pageformat <Template number>"
.RB "Number corresponding to page template (default = 0, " "export mode" "):"
.RB "Number corresponding to layout page template (default = 0, " "export mode" "):"
.RS
.BR "*" " A0 = 0,"
.RE
@ -155,17 +155,17 @@ The path to output destination folder. By default the directory at which the app
.IP "-H, --pageh <The page height>"
.RB "Page height in current units like 12.0 (cannot be used with \*(lqpageformat\*(rq, " "export mode" ")."
.IP "-U, --pageunits <The measure unit>"
.RB "Page height/width measure units (cannot be used with \*(lqpageformat\*(rq, " "export mode" "). Valid values: mm, cm, inch, px."
.RB "Page measure units (" "export mode" "). Valid values: mm, cm, inch, px."
.IP "-i, --ignoremargins"
.RB "Ignore margins printing (" "export mode" "). Disable value keys: \*(lqlmargin", \*(lqrmargin\*(rq, \*(lqtmargin\*(rq, \*(lqbmargin\*(rq. Set all margins to 0."
.RB "Ignore margins printing (" "export mode" "). Use if need full paper space. In case of later printing you must account for the margins himself."
.IP "-L, --lmargin <The left margin>"
.RB "Page left 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. Value will be ignored if key \*(lqignoremargins\*(rq is used."
.RB "Page left 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 "-R, --rmargin <The right margin>"
.RB "Page right 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. Value will be ignored if key \*(lqignoremargins\*(rq is used."
.RB "Page right 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 "-T, --tmargin <The top margin>"
.RB "Page top 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. Value will be ignored if key \*(lqignoremargins\*(rq is used."
.RB "Page top 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 "-B, --bmargin <The bottom margin>"
.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. Value will be ignored if key \*(lqignoremargins\*(rq is used."
.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 "-r, --rotate <Angle>"
.RB "Rotation in degrees (one of predefined, " "export mode" "). Default value is " "180" ". 0 is no-rotate. Valid values: 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, 60, 72, 90, 180. Each value show how many times details will be rotated. For example 180 mean two times (360/180=2) by 180 degree."
.IP "-c, --crop"
@ -551,6 +551,39 @@ Run the program in a test mode. The program in this mode loads a single pattern
.RE
.IP "--csvExportFM <Path to csv file>"
.RB "Calling this command enable exporting final measurements. Specify path to csv file with final measurements. The path must contain path to directory and name of file. It can be absolute or relatetive. In case of relative path will be used current working directory to calc a destination path."
.IP "--tiledPageformat <Template number>"
.RB "Number corresponding to tiled pdf page template (default = 0, " "export mode with tiled pdf format" "):"
.RS
.BR "*" " A0 = 0,"
.RE
.RS
.BR "*" " A1 = 1,"
.RE
.RS
.BR "*" " A2 = 2,"
.RE
.RS
.BR "*" " A3 = 3,"
.RE
.RS
.BR "*" " A4 = 4,"
.RE
.RS
.BR "*" " Letter = 5,"
.RE
.RS
.BR "*" " Legal = 6."
.RE
.IP "--tiledlmargin <The left margin>"
.RB "Tiled page left margin in current units like 3.0 (" "export mode" "). If not set will be used default value 1 cm."
.IP "--tiledrmargin <The right margin>"
.RB "Tiled page right margin in current units like 3.0 (" "export mode" "). If not set will be used default value 1 cm."
.IP "--tiledtmargin <The top margin>"
.RB "Tiled page top margin in current units like 3.0 (" "export mode" "). If not set will be used value default value 1 cm."
.IP "--tiledbmargin <The bottom margin>"
.RB "Tiled page bottom margin in current units like 3.0 (" "export mode" "). If not set will be used value default value 1 cm."
.IP "--tiledLandscape"
.RB "Set tiled page orienatation to landscape (" "export mode" "). Default value if not set portrait."
.IP Arguments:
.I filename
\- a pattern file.

View file

@ -141,8 +141,8 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
//=================================================================================================================
optionsIndex.insert(LONG_OPTION_PAGETEMPLATE, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGETEMPLATE << LONG_OPTION_PAGETEMPLATE,
translate("VCommandLine", "Number corresponding to page template (default = "
"0, export mode):") +
translate("VCommandLine", "Number corresponding to layout page template "
"(default = 0, export mode):") +
DialogLayoutSettings::MakeHelpTemplateList(),
translate("VCommandLine", "Template number"), "0"));
@ -162,26 +162,24 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
optionsIndex.insert(LONG_OPTION_PAGEUNITS, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_PAGEUNITS << LONG_OPTION_PAGEUNITS,
translate("VCommandLine", "Page height/width measure units (cannot be used "
"with \"%1\", export mode). Valid values: %2.")
.arg(LONG_OPTION_PAGETEMPLATE).arg(VDomDocument::UnitsHelpString()),
translate("VCommandLine",
"Page measure units (export mode). Valid values: %2.")
.arg(VDomDocument::UnitsHelpString()),
translate("VCommandLine", "The measure unit")));
optionsIndex.insert(LONG_OPTION_IGNORE_MARGINS, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_IGNORE_MARGINS << LONG_OPTION_IGNORE_MARGINS,
translate("VCommandLine",
"Ignore margins printing (export mode). Disable value keys: "
"\"%1\", \"%2\", \"%3\", \"%4\". Set all margins to 0.")
.arg(LONG_OPTION_LEFT_MARGIN).arg(LONG_OPTION_RIGHT_MARGIN)
.arg(LONG_OPTION_TOP_MARGIN).arg(LONG_OPTION_BOTTOM_MARGIN)));
"Ignore printer margins (export mode). Use if need full paper "
"space. In case of later printing you must account for the "
"margins himself.")));
optionsIndex.insert(LONG_OPTION_LEFT_MARGIN, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_LEFT_MARGIN << LONG_OPTION_LEFT_MARGIN,
translate("VCommandLine",
"Page left 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. Value will be ignored if key \"%1\" is used.")
.arg(LONG_OPTION_IGNORE_MARGINS),
"printers was found."),
("The left margin")));
optionsIndex.insert(LONG_OPTION_RIGHT_MARGIN, index++);
@ -189,8 +187,7 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
translate("VCommandLine",
"Page right 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. Value will be ignored if key \"%1\" is used.")
.arg(LONG_OPTION_IGNORE_MARGINS),
"printers was found."),
("The right margin")));
optionsIndex.insert(LONG_OPTION_TOP_MARGIN, index++);
@ -198,8 +195,7 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
translate("VCommandLine",
"Page top 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. Value will be ignored if key \"%1\" is used.")
.arg(LONG_OPTION_IGNORE_MARGINS),
"printers was found."),
("The top margin")));
optionsIndex.insert(LONG_OPTION_BOTTOM_MARGIN, index++);
@ -207,8 +203,7 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
translate("VCommandLine",
"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. Value will be ignored if key \"%1\" is used.")
.arg(LONG_OPTION_IGNORE_MARGINS),
"printers was found."),
("The bottom margin")));
//=================================================================================================================
@ -320,9 +315,62 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
"relative path will be used current working "
"directory to calc a destination path."),
translate("VCommandLine", "Path to csv file")));
//=================================================================================================================
optionsIndex.insert(LONG_OPTION_TILED_PDF_PAGE_TEMPLATE, index++);
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_TILED_PDF_PAGE_TEMPLATE,
translate("VCommandLine", "Number corresponding to tiled pdf page template "
"(default = 0, export mode with tiled pdf "
"format):") +
DialogLayoutSettings::MakeHelpTiledPdfTemplateList(),
translate("VCommandLine", "Template number"), "0"));
optionsIndex.insert(LONG_OPTION_TILED_PDF_LEFT_MARGIN, index++);
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_TILED_PDF_LEFT_MARGIN,
translate("VCommandLine",
"Tiled page left margin in current units like 3.0 (export mode). "
"If not set will be used default value 1 cm."),
translate("VCommandLine", "The left margin")));
optionsIndex.insert(LONG_OPTION_TILED_PDF_RIGHT_MARGIN, index++);
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_TILED_PDF_RIGHT_MARGIN,
translate("VCommandLine",
"Tiled page right margin in current units like 3.0 (export mode). "
"If not set will be used default value 1 cm."),
translate("VCommandLine", "The right margin")));
optionsIndex.insert(LONG_OPTION_TILED_PDF_TOP_MARGIN, index++);
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_TILED_PDF_TOP_MARGIN,
translate("VCommandLine",
"Tiled page top margin in current units like 3.0 (export mode). If "
"not set will be used value default value 1 cm."),
translate("VCommandLine", "The top margin")));
optionsIndex.insert(LONG_OPTION_TILED_PDF_BOTTOM_MARGIN, index++);
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_TILED_PDF_BOTTOM_MARGIN,
translate("VCommandLine",
"Tiled page bottom margin in current units like 3.0 (export mode)."
" If not set will be used value default value 1 cm."),
translate("VCommandLine", "The bottom margin")));
optionsIndex.insert(LONG_OPTION_TILED_PDF_LANDSCAPE, index++);
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_TILED_PDF_LANDSCAPE,
translate("VCommandLine", "Set tiled page orienatation to landscape (export "
"mode). Default value if not set portrait.")));
}
//------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::FormatSize(const QString &key) const
{
int ppsize = 0;
if (parser.isSet(*optionsUsed.value(optionsIndex.value(key))))
{
ppsize = parser.value(*optionsUsed.value(optionsIndex.value(key))).toInt();
}
return static_cast<VAbstractLayoutDialog::PaperSizeTemplate>(ppsize);
}
//---------------------------------------------------------------------------------------------------------------------
VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
{
//this functions covers all options found into layout setup dialog, nothing to add here, unless dialog extended
@ -338,9 +386,9 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
bool b = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEW)));
bool c = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEUNITS)));
if ((a || b || c) && x)
if ((a || b) && x)
{
qCritical() << translate("VCommandLine", "Cannot use pageformat and page explicit size/units together.")
qCritical() << translate("VCommandLine", "Cannot use pageformat and page explicit size together.")
<< "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
@ -378,53 +426,33 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
}
}
auto CheckKey = [this](const QString &key, const QString &message)
{
//just anonymous namespace ...don' like to have a,b,c,d everywhere defined
bool a = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_LEFT_MARGIN)));
bool a = parser.isSet(*optionsUsed.value(optionsIndex.value(key)));
bool b = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEUNITS)));
if ((a || b) && !(a && b))
{
qCritical() << translate("VCommandLine", "Left margin must be used together with page units.") << "\n";
qCritical() << message << "\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 = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_RIGHT_MARGIN)));
bool b = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEUNITS)));
CheckKey(LONG_OPTION_LEFT_MARGIN, translate("VCommandLine", "Left margin must be used together with page units."));
CheckKey(LONG_OPTION_RIGHT_MARGIN,
translate("VCommandLine", "Right margin must be used together with page units."));
CheckKey(LONG_OPTION_TOP_MARGIN, translate("VCommandLine", "Top margin must be used together with page units."));
CheckKey(LONG_OPTION_BOTTOM_MARGIN,
translate("VCommandLine", "Bottom margin must be used together with page units."));
if ((a || b) && !(a && b))
{
qCritical() << translate("VCommandLine", "Right margin must be used together with page 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 = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_TOP_MARGIN)));
bool b = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEUNITS)));
if ((a || b) && !(a && b))
{
qCritical() << translate("VCommandLine", "Top margin must be used together with page 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 = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_BOTTOM_MARGIN)));
bool b = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGEUNITS)));
if ((a || b) && !(a && b))
{
qCritical() << translate("VCommandLine", "Bottom margin must be used together with page units.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
}
CheckKey(LONG_OPTION_TILED_PDF_LEFT_MARGIN,
translate("VCommandLine", "Tiled left margin must be used together with page units."));
CheckKey(LONG_OPTION_TILED_PDF_RIGHT_MARGIN,
translate("VCommandLine", "Tiled right margin must be used together with page units."));
CheckKey(LONG_OPTION_TILED_PDF_TOP_MARGIN,
translate("VCommandLine", "Tiled top margin must be used together with page units."));
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
@ -488,44 +516,42 @@ VLayoutGeneratorPtr VCommandLine::DefaultGenerator() const
{
diag.SetIgnoreAllFields(true);
}
else
QMarginsF margins = diag.GetFields();
{
QMarginsF margins = diag.GetFields();
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_LEFT_MARGIN));
if (parser.isSet(*option))
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_LEFT_MARGIN));
if (parser.isSet(*option))
{
margins.setLeft(Pg2Px(parser.value(*option), diag));
}
margins.setLeft(Pg2Px(parser.value(*option), diag));
}
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_RIGHT_MARGIN));
if (parser.isSet(*option))
{
margins.setRight(Pg2Px(parser.value(*option), diag));
}
}
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_TOP_MARGIN));
if (parser.isSet(*option))
{
margins.setTop(Pg2Px(parser.value(*option), diag));
}
}
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_BOTTOM_MARGIN));
if (parser.isSet(*option))
{
margins.setBottom(Pg2Px(parser.value(*option), diag));
}
}
diag.SetFields(margins);
}
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_RIGHT_MARGIN));
if (parser.isSet(*option))
{
margins.setRight(Pg2Px(parser.value(*option), diag));
}
}
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_TOP_MARGIN));
if (parser.isSet(*option))
{
margins.setTop(Pg2Px(parser.value(*option), diag));
}
}
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_BOTTOM_MARGIN));
if (parser.isSet(*option))
{
margins.setBottom(Pg2Px(parser.value(*option), diag));
}
}
diag.SetFields(margins);
diag.DialogAccepted(); // filling VLayoutGenerator
return res;
@ -604,14 +630,9 @@ bool VCommandLine::IsExportFMEnabled() const
}
//------------------------------------------------------------------------------------------------------
DialogLayoutSettings::PaperSizeTemplate VCommandLine::OptPaperSize() const
VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::OptPaperSize() const
{
int ppsize = 0;
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGETEMPLATE))))
{
ppsize = parser.value(*optionsUsed.value(optionsIndex.value(LONG_OPTION_PAGETEMPLATE))).toInt();
}
return static_cast<DialogLayoutSettings::PaperSizeTemplate>(ppsize);
return FormatSize(LONG_OPTION_PAGETEMPLATE);
}
//------------------------------------------------------------------------------------------------------
@ -809,4 +830,72 @@ QString VCommandLine::OptGradationHeight() const
}
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VCommandLine::TiledPageMargins() const
{
QMarginsF margins(10, 10, 10, 10); // mm
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_LEFT_MARGIN));
if (not parser.isSet(*option))
{
return margins;
}
const QString value = parser.value(*option);
const QStringList supportedUnits = QStringList() << unitMM << unitCM << unitINCH;
if (not supportedUnits.contains(value))
{
qCritical() << translate("VCommandLine", "Unsupported paper units.") << "\n";
const_cast<VCommandLine*>(this)->parser.showHelp(V_EX_USAGE);
}
const Unit unit = StrToUnits(value);
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_LEFT_MARGIN));
if (parser.isSet(*option))
{
margins.setLeft(UnitConvertor(parser.value(*option).toDouble(), unit, Unit::Mm));
}
}
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_RIGHT_MARGIN));
if (parser.isSet(*option))
{
margins.setRight(UnitConvertor(parser.value(*option).toDouble(), unit, Unit::Mm));
}
}
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_TOP_MARGIN));
if (parser.isSet(*option))
{
margins.setTop(UnitConvertor(parser.value(*option).toDouble(), unit, Unit::Mm));
}
}
{
const QCommandLineOption *option = optionsUsed.value(optionsIndex.value(LONG_OPTION_BOTTOM_MARGIN));
if (parser.isSet(*option))
{
margins.setBottom(UnitConvertor(parser.value(*option).toDouble(), unit, Unit::Mm));
}
}
return margins;
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractLayoutDialog::PaperSizeTemplate VCommandLine::OptTiledPaperSize() const
{
return FormatSize(LONG_OPTION_TILED_PDF_PAGE_TEMPLATE);
}
//---------------------------------------------------------------------------------------------------------------------
PageOrientation VCommandLine::OptTiledPageOrientation()
{
const QString key = LONG_OPTION_TILED_PDF_LANDSCAPE;
return static_cast<PageOrientation>(not parser.isSet(*optionsUsed.value(optionsIndex.value(key))));
}
#undef translate

View file

@ -110,13 +110,17 @@ public:
QString OptGradationSize() const;
QString OptGradationHeight() const;
QMarginsF TiledPageMargins() const;
VAbstractLayoutDialog::PaperSizeTemplate OptTiledPaperSize() const;
PageOrientation OptTiledPageOrientation();
protected:
VCommandLine();
//@brief returns DialogLayoutSettings::PaperSizeTemplate
DialogLayoutSettings::PaperSizeTemplate OptPaperSize() const;
//@brief returns VAbstractLayoutDialog::PaperSizeTemplate
VAbstractLayoutDialog::PaperSizeTemplate OptPaperSize() const;
//@brief returns rotation in degrees or 0 if not set
int OptRotation() const;
@ -141,6 +145,8 @@ private:
static qreal Pg2Px(const QString& src, const DialogLayoutSettings& converter);
static void InitOptions(VCommandLineOptions &options, QMap<QString, int> &optionsIndex);
VAbstractLayoutDialog::PaperSizeTemplate FormatSize(const QString &key) const;
};
#endif // VCMDEXPORT_H

View file

@ -810,6 +810,27 @@ QString DialogLayoutSettings::MakeHelpTemplateList()
return out;
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogLayoutSettings::MakeHelpTiledPdfTemplateList()
{
QString out = "\n";
for (int i = 0; i <= static_cast<int>(PaperSizeTemplate::Legal); ++i)
{
out += "\t* "+VAbstractLayoutDialog::pageFormatNames.at(i)+" = "+ QString::number(i);
if (i < static_cast<int>(PaperSizeTemplate::Legal))
{
out += ",\n";
}
else
{
out += ".\n";
}
}
return out;
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF DialogLayoutSettings::Template()
{

View file

@ -105,6 +105,7 @@ public:
//support functions for the command line parser which uses invisible dialog to properly build layout generator
bool SelectTemplate(const PaperSizeTemplate& id);
static QString MakeHelpTemplateList();
static QString MakeHelpTiledPdfTemplateList();
bool SelectPaperUnit(const QString& units);
bool SelectLayoutUnit(const QString& units);
qreal LayoutToPixels(qreal value) const;

View file

@ -52,7 +52,8 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
ui(new Ui::DialogSaveLAyout),
count(count),
isInitialized(false),
m_mode(mode)
m_mode(mode),
m_tiledExportMode(false)
{
ui->setupUi(this);
@ -621,6 +622,83 @@ void DialogSaveLayout::SetTextAsPaths(bool textAsPaths)
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::SetTiledExportMode(bool tiledExportMode)
{
m_tiledExportMode = tiledExportMode;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::SetTiledMargins(QMarginsF margins)
{
// read Margins top, right, bottom, left
margins = UnitConvertor(margins, Unit::Mm, qApp->patternUnit());
ui->doubleSpinBoxLeftField->setValue(margins.left());
ui->doubleSpinBoxTopField->setValue(margins.top());
ui->doubleSpinBoxRightField->setValue(margins.right());
ui->doubleSpinBoxBottomField->setValue(margins.bottom());
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF DialogSaveLayout::GetTiledMargins() const
{
QMarginsF margins = QMarginsF(
ui->doubleSpinBoxLeftField->value(),
ui->doubleSpinBoxTopField->value(),
ui->doubleSpinBoxRightField->value(),
ui->doubleSpinBoxBottomField->value()
);
return UnitConvertor(margins, qApp->patternUnit(), Unit::Mm);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::SetTiledPageFormat(PaperSizeTemplate format)
{
int index = ui->comboBoxTemplates->findData(static_cast<int>(format));
if (index != -1)
{
ui->comboBoxTemplates->setCurrentIndex(index);
}
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractLayoutDialog::PaperSizeTemplate DialogSaveLayout::GetTiledPageFormat() const
{
if (ui->comboBoxTemplates->currentIndex() != -1)
{
return static_cast<PaperSizeTemplate>(ui->comboBoxTemplates->currentData().toInt());
}
return PaperSizeTemplate::A0;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::SetTiledPageOrientation(PageOrientation orientation)
{
if(orientation == PageOrientation::Portrait)
{
ui->toolButtonPortrait->setChecked(true);
}
else
{
ui->toolButtonLandscape->setChecked(true);
}
}
//---------------------------------------------------------------------------------------------------------------------
PageOrientation DialogSaveLayout::GetTiledPageOrientation() const
{
if(ui->toolButtonPortrait->isChecked())
{
return PageOrientation::Portrait;
}
else
{
return PageOrientation::Landscape;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSaveLayout::showEvent(QShowEvent *event)
{
@ -785,7 +863,6 @@ void DialogSaveLayout::ReadSettings()
{
ui->toolButtonLandscape->setChecked(true);
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -795,6 +872,11 @@ void DialogSaveLayout::ReadSettings()
*/
void DialogSaveLayout::WriteSettings() const
{
if (m_tiledExportMode)
{
return;
}
VSettings *settings = qApp->ValentinaSettings();
const Unit unit = qApp->patternUnit();

View file

@ -111,6 +111,17 @@ public:
bool IsTextAsPaths() const;
void SetTextAsPaths(bool textAsPaths);
void SetTiledExportMode(bool tiledExportMode);
void SetTiledMargins(QMarginsF margins);
QMarginsF GetTiledMargins() const;
void SetTiledPageFormat(PaperSizeTemplate format);
PaperSizeTemplate GetTiledPageFormat() const;
void SetTiledPageOrientation(PageOrientation orientation);
PageOrientation GetTiledPageOrientation() const;
protected:
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
void InitTemplates(QComboBox *comboBoxTemplates);
@ -125,6 +136,7 @@ private:
int count;
bool isInitialized;
Draw m_mode;
bool m_tiledExportMode;
static bool havePdf;
static bool tested;

View file

@ -4553,18 +4553,22 @@ void MainWindow::ExportLayoutAs()
try
{
DialogSaveLayout dialog(scenes.size(), Draw::Layout, FileName(), this);
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(new DialogSaveLayout(scenes.size(), Draw::Layout,
FileName(), this));
if (dialog.exec() == QDialog::Rejected)
if (m_dialogSaveLayout->exec() == QDialog::Rejected)
{
m_dialogSaveLayout.clear();
ui->toolButtonLayoutExportAs->setChecked(false);
return;
}
ExportData(QVector<VLayoutPiece>(), dialog);
ExportData(QVector<VLayoutPiece>());
m_dialogSaveLayout.clear();
}
catch (const VException &e)
{
m_dialogSaveLayout.clear();
ui->toolButtonLayoutExportAs->setChecked(false);
qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
@ -4611,18 +4615,22 @@ void MainWindow::ExportDetailsAs()
try
{
DialogSaveLayout dialog(1, Draw::Modeling, FileName(), this);
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(new DialogSaveLayout(1, Draw::Modeling, FileName(),
this));
if (dialog.exec() == QDialog::Rejected)
if (m_dialogSaveLayout->exec() == QDialog::Rejected)
{
m_dialogSaveLayout.clear();
ui->toolButtonDetailExportAs->setChecked(false);
return;
}
ExportData(listDetails, dialog);
ExportData(listDetails);
m_dialogSaveLayout.clear();
}
catch (const VException &e)
{
m_dialogSaveLayout.clear();
ui->toolButtonDetailExportAs->setChecked(false);
qCritical("%s\n\n%s\n\n%s", qUtf8Printable(tr("Export error.")),
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
@ -4951,16 +4959,27 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams)
{
try
{
DialogSaveLayout dialog(1, Draw::Modeling, expParams->OptBaseName(), this);
dialog.SetDestinationPath(expParams->OptDestinationPath());
dialog.SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType()));
dialog.SetBinaryDXFFormat(expParams->IsBinaryDXF());
dialog.SetTextAsPaths(expParams->IsTextAsPaths());
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(new DialogSaveLayout(1, Draw::Modeling,
expParams->OptBaseName(), this));
m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath());
m_dialogSaveLayout->SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType()));
m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF());
m_dialogSaveLayout->SetTextAsPaths(expParams->IsTextAsPaths());
ExportData(listDetails, dialog);
if (static_cast<LayoutExportFormats>(expParams->OptExportType()) == LayoutExportFormats::PDFTiled)
{
m_dialogSaveLayout->SetTiledExportMode(true);
m_dialogSaveLayout->SetTiledMargins(expParams->TiledPageMargins());
m_dialogSaveLayout->SetTiledPageFormat(expParams->OptTiledPaperSize());
m_dialogSaveLayout->SetTiledPageOrientation(expParams->OptTiledPageOrientation());
}
ExportData(listDetails);
m_dialogSaveLayout.clear();
}
catch (const VException &e)
{
m_dialogSaveLayout.clear();
qCCritical(vMainWindow, "%s\n\n%s", qUtf8Printable(tr("Export error.")), qUtf8Printable(e.ErrorMessage()));
qApp->exit(V_EX_DATAERR);
return false;
@ -4975,15 +4994,27 @@ bool MainWindow::DoExport(const VCommandLinePtr &expParams)
{
try
{
DialogSaveLayout dialog(scenes.size(), Draw::Layout, expParams->OptBaseName(), this);
dialog.SetDestinationPath(expParams->OptDestinationPath());
dialog.SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType()));
dialog.SetBinaryDXFFormat(expParams->IsBinaryDXF());
m_dialogSaveLayout = QSharedPointer<DialogSaveLayout>(new DialogSaveLayout(scenes.size(), Draw::Layout,
expParams->OptBaseName(),
this));
m_dialogSaveLayout->SetDestinationPath(expParams->OptDestinationPath());
m_dialogSaveLayout->SelectFormat(static_cast<LayoutExportFormats>(expParams->OptExportType()));
m_dialogSaveLayout->SetBinaryDXFFormat(expParams->IsBinaryDXF());
ExportData(listDetails, dialog);
if (static_cast<LayoutExportFormats>(expParams->OptExportType()) == LayoutExportFormats::PDFTiled)
{
m_dialogSaveLayout->SetTiledExportMode(true);
m_dialogSaveLayout->SetTiledMargins(expParams->TiledPageMargins());
m_dialogSaveLayout->SetTiledPageFormat(expParams->OptTiledPaperSize());
m_dialogSaveLayout->SetTiledPageOrientation(expParams->OptTiledPageOrientation());
}
ExportData(listDetails);
m_dialogSaveLayout.clear();
}
catch (const VException &e)
{
m_dialogSaveLayout.clear();
qCCritical(vMainWindow, "%s\n\n%s", qUtf8Printable(tr("Export error.")),
qUtf8Printable(e.ErrorMessage()));
qApp->exit(V_EX_DATAERR);

View file

@ -110,11 +110,11 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
ignorePrinterFields(false),
margins(),
paperSize(),
m_dialogSaveLayout(),
isTiled(false),
isAutoCrop(false),
isUnitePages(false),
layoutPrinterName()
{
InitTempLayoutScene();
}
@ -254,9 +254,9 @@ void MainWindowsNoGUI::ExportFMeasurementsToCSV()
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails, const DialogSaveLayout &dialog)
void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails)
{
const LayoutExportFormats format = dialog.Format();
const LayoutExportFormats format = m_dialogSaveLayout->Format();
if (format == LayoutExportFormats::DXF_AC1006_AAMA ||
format == LayoutExportFormats::DXF_AC1009_AAMA ||
@ -268,44 +268,45 @@ void MainWindowsNoGUI::ExportData(const QVector<VLayoutPiece> &listDetails, cons
format == LayoutExportFormats::DXF_AC1024_AAMA ||
format == LayoutExportFormats::DXF_AC1027_AAMA)
{
if (dialog.Mode() == Draw::Layout)
if (m_dialogSaveLayout->Mode() == Draw::Layout)
{
for (int i = 0; i < detailsOnLayout.size(); ++i)
{
const QString name = dialog.Path() + QLatin1String("/") + dialog.FileName() + QString::number(i+1)
+ DialogSaveLayout::ExportFromatSuffix(dialog.Format());
const QString name = m_dialogSaveLayout->Path() + QLatin1String("/") + m_dialogSaveLayout->FileName() +
QString::number(i+1)
+ DialogSaveLayout::ExportFromatSuffix(m_dialogSaveLayout->Format());
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
SCASSERT(paper != nullptr)
ExportApparelLayout(dialog, detailsOnLayout.at(i), name, paper->rect().size().toSize());
ExportApparelLayout(detailsOnLayout.at(i), name, paper->rect().size().toSize());
}
}
else
{
ExportDetailsAsApparelLayout(dialog, listDetails);
ExportDetailsAsApparelLayout(listDetails);
}
}
else
{
if (dialog.Mode() == Draw::Layout)
if (m_dialogSaveLayout->Mode() == Draw::Layout)
{
ExportFlatLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins);
ExportFlatLayout(scenes, papers, shadows, details, ignorePrinterFields, margins);
}
else
{
ExportDetailsAsFlatLayout(dialog, listDetails);
ExportDetailsAsFlatLayout(listDetails);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportFlatLayout(const DialogSaveLayout &dialog, const QList<QGraphicsScene *> &scenes,
void MainWindowsNoGUI::ExportFlatLayout(const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers, const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details, bool ignorePrinterFields,
const QMarginsF &margins)
{
const QString path = dialog.Path();
const QString path = m_dialogSaveLayout->Path();
bool usedNotExistedDir = CreateLayoutPath(path);
if (not usedNotExistedDir)
{
@ -314,25 +315,24 @@ void MainWindowsNoGUI::ExportFlatLayout(const DialogSaveLayout &dialog, const QL
}
qApp->ValentinaSettings()->SetPathLayout(path);
const LayoutExportFormats format = dialog.Format();
const LayoutExportFormats format = m_dialogSaveLayout->Format();
if (format == LayoutExportFormats::PDFTiled && dialog.Mode() == Draw::Layout)
if (format == LayoutExportFormats::PDFTiled && m_dialogSaveLayout->Mode() == Draw::Layout)
{
const QString name = path + QLatin1String("/") + dialog.FileName() + QString::number(1)
+ DialogSaveLayout::ExportFromatSuffix(dialog.Format());
const QString name = path + QLatin1String("/") + m_dialogSaveLayout->FileName() + QString::number(1)
+ DialogSaveLayout::ExportFromatSuffix(m_dialogSaveLayout->Format());
PdfTiledFile(name);
}
else
{
ExportScene(dialog, scenes, papers, shadows, details, ignorePrinterFields, margins);
ExportScene(scenes, papers, shadows, details, ignorePrinterFields, margins);
}
RemoveLayoutPath(path, usedNotExistedDir);
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const DialogSaveLayout &dialog,
const QVector<VLayoutPiece> &listDetails)
void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const QVector<VLayoutPiece> &listDetails)
{
if (listDetails.isEmpty())
{
@ -344,7 +344,7 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const DialogSaveLayout &dialog,
QList<QGraphicsItem *> list;
for (int i=0; i < listDetails.count(); ++i)
{
QGraphicsItem *item = listDetails.at(i).GetItem(dialog.IsTextAsPaths());
QGraphicsItem *item = listDetails.at(i).GetItem(m_dialogSaveLayout->IsTextAsPaths());
item->setPos(listDetails.at(i).GetMx(), listDetails.at(i).GetMy());
list.append(item);
}
@ -383,17 +383,16 @@ void MainWindowsNoGUI::ExportDetailsAsFlatLayout(const DialogSaveLayout &dialog,
const bool ignorePrinterFields = false;
const qreal margin = ToPixel(1, Unit::Cm);
ExportFlatLayout(dialog, scenes, papers, shadows, details, ignorePrinterFields,
QMarginsF(margin, margin, margin, margin));
ExportFlatLayout(scenes, papers, shadows, details, ignorePrinterFields, QMarginsF(margin, margin, margin, margin));
qDeleteAll(scenes);//Scene will clear all other items
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportApparelLayout(const DialogSaveLayout &dialog, const QVector<VLayoutPiece> &details,
const QString &name, const QSize &size) const
void MainWindowsNoGUI::ExportApparelLayout(const QVector<VLayoutPiece> &details, const QString &name,
const QSize &size) const
{
const QString path = dialog.Path();
const QString path = m_dialogSaveLayout->Path();
bool usedNotExistedDir = CreateLayoutPath(path);
if (not usedNotExistedDir)
{
@ -402,7 +401,7 @@ void MainWindowsNoGUI::ExportApparelLayout(const DialogSaveLayout &dialog, const
}
qApp->ValentinaSettings()->SetPathLayout(path);
const LayoutExportFormats format = dialog.Format();
const LayoutExportFormats format = m_dialogSaveLayout->Format();
switch (format)
{
@ -418,31 +417,31 @@ void MainWindowsNoGUI::ExportApparelLayout(const DialogSaveLayout &dialog, const
Q_UNREACHABLE(); // For now not supported
break;
case LayoutExportFormats::DXF_AC1006_AAMA:
AAMADxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), size, details);
AAMADxfFile(name, DRW::AC1006, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1009_AAMA:
AAMADxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), size, details);
AAMADxfFile(name, DRW::AC1009, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1012_AAMA:
AAMADxfFile(name, DRW::AC1012, dialog.IsBinaryDXFFormat(), size, details);
AAMADxfFile(name, DRW::AC1012, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1014_AAMA:
AAMADxfFile(name, DRW::AC1014, dialog.IsBinaryDXFFormat(), size, details);
AAMADxfFile(name, DRW::AC1014, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1015_AAMA:
AAMADxfFile(name, DRW::AC1015, dialog.IsBinaryDXFFormat(), size, details);
AAMADxfFile(name, DRW::AC1015, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1018_AAMA:
AAMADxfFile(name, DRW::AC1018, dialog.IsBinaryDXFFormat(), size, details);
AAMADxfFile(name, DRW::AC1018, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1021_AAMA:
AAMADxfFile(name, DRW::AC1021, dialog.IsBinaryDXFFormat(), size, details);
AAMADxfFile(name, DRW::AC1021, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1024_AAMA:
AAMADxfFile(name, DRW::AC1024, dialog.IsBinaryDXFFormat(), size, details);
AAMADxfFile(name, DRW::AC1024, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details);
break;
case LayoutExportFormats::DXF_AC1027_AAMA:
AAMADxfFile(name, DRW::AC1027, dialog.IsBinaryDXFFormat(), size, details);
AAMADxfFile(name, DRW::AC1027, m_dialogSaveLayout->IsBinaryDXFFormat(), size, details);
break;
default:
qDebug() << "Can't recognize file type." << Q_FUNC_INFO;
@ -453,8 +452,7 @@ void MainWindowsNoGUI::ExportApparelLayout(const DialogSaveLayout &dialog, const
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportDetailsAsApparelLayout(const DialogSaveLayout &dialog,
QVector<VLayoutPiece> listDetails)
void MainWindowsNoGUI::ExportDetailsAsApparelLayout(QVector<VLayoutPiece> listDetails)
{
if (listDetails.isEmpty())
{
@ -466,7 +464,7 @@ void MainWindowsNoGUI::ExportDetailsAsApparelLayout(const DialogSaveLayout &dial
QList<QGraphicsItem *> list;
for (int i=0; i < listDetails.count(); ++i)
{
QGraphicsItem *item = listDetails.at(i).GetItem(dialog.IsTextAsPaths());
QGraphicsItem *item = listDetails.at(i).GetItem(m_dialogSaveLayout->IsTextAsPaths());
item->setPos(listDetails.at(i).GetMx(), listDetails.at(i).GetMy());
list.append(item);
}
@ -499,10 +497,10 @@ void MainWindowsNoGUI::ExportDetailsAsApparelLayout(const DialogSaveLayout &dial
listDetails[i].SetMatrix(moveMatrix);
}
const QString name = dialog.Path() + QLatin1String("/") + dialog.FileName() + QString::number(1)
+ DialogSaveLayout::ExportFromatSuffix(dialog.Format());
const QString name = m_dialogSaveLayout->Path() + QLatin1String("/") + m_dialogSaveLayout->FileName() +
QString::number(1) + DialogSaveLayout::ExportFromatSuffix(m_dialogSaveLayout->Format());
ExportApparelLayout(dialog, listDetails, name, rect.size());
ExportApparelLayout(listDetails, name, rect.size());
}
//---------------------------------------------------------------------------------------------------------------------
@ -534,10 +532,19 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer)
if (isTiled)
{
VSettings *settings = qApp->ValentinaSettings();
PageOrientation orientation;
if (not m_dialogSaveLayout.isNull())
{
orientation = m_dialogSaveLayout->GetTiledPageOrientation();
}
else
{
orientation = qApp->ValentinaSettings()->GetTiledPDFOrientation();
}
// when isTiled, the landscape tiles have to be rotated, because the pages
// stay portrait in the pdf
if(settings->GetTiledPDFOrientation() == PageOrientation::Landscape)
if(orientation == PageOrientation::Landscape)
{
painter.rotate(-90);
painter.translate(-ToPixel(printer->pageRect(QPrinter::Millimeter).height(), Unit::Mm), 0);
@ -551,7 +558,7 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer)
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
if (paper)
{
*poster += posterazor->Calc(paper->rect().toRect(), i, settings->GetTiledPDFOrientation());
*poster += posterazor->Calc(paper->rect().toRect(), i, orientation);
}
}
@ -952,7 +959,7 @@ void MainWindowsNoGUI::PdfTiledFile(const QString &name)
printer.setOutputFileName(name);
printer.setResolution(static_cast<int>(PrintDPI));
PrintPages( &printer );
PrintPages(&printer);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1288,9 +1295,21 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
}
else
{
VSettings *settings = qApp->ValentinaSettings();
QMarginsF pageMargin = QMarginsF(settings->GetTiledPDFMargins(Unit::Mm));
if(settings->GetTiledPDFOrientation() == PageOrientation::Landscape)
QMarginsF pageMargin;
PageOrientation orientation;
if (not m_dialogSaveLayout.isNull())
{
pageMargin = m_dialogSaveLayout->GetTiledMargins();
orientation = m_dialogSaveLayout->GetTiledPageOrientation();
}
else
{
VSettings *settings = qApp->ValentinaSettings();
pageMargin = QMarginsF(settings->GetTiledPDFMargins(Unit::Mm));
orientation = settings->GetTiledPDFOrientation();
}
if(orientation == PageOrientation::Landscape)
{
// because when painting we have a -90rotation in landscape modus,
// see function PrintPages.
@ -1467,7 +1486,7 @@ bool MainWindowsNoGUI::IsPagesFit(const QSizeF &printPaper) const
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindowsNoGUI::ExportScene(const DialogSaveLayout &dialog, const QList<QGraphicsScene *> &scenes,
void MainWindowsNoGUI::ExportScene(const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers, const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details, bool ignorePrinterFields,
const QMarginsF &margins) const
@ -1477,8 +1496,8 @@ void MainWindowsNoGUI::ExportScene(const DialogSaveLayout &dialog, const QList<Q
QGraphicsRectItem *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(i));
if (paper)
{
const QString name = dialog.Path() + QLatin1String("/") + dialog.FileName() + QString::number(i+1)
+ DialogSaveLayout::ExportFromatSuffix(dialog.Format());
const QString name = m_dialogSaveLayout->Path() + QLatin1String("/") + m_dialogSaveLayout->FileName() +
QString::number(i+1) + DialogSaveLayout::ExportFromatSuffix(m_dialogSaveLayout->Format());
QBrush *brush = new QBrush();
brush->setColor( QColor( Qt::white ) );
QGraphicsScene *scene = scenes.at(i);
@ -1486,7 +1505,7 @@ void MainWindowsNoGUI::ExportScene(const DialogSaveLayout &dialog, const QList<Q
shadows[i]->setVisible(false);
paper->setPen(QPen(QBrush(Qt::white, Qt::NoBrush), 0.1, Qt::NoPen));
switch (dialog.Format())
switch (m_dialogSaveLayout->Format())
{
case LayoutExportFormats::SVG:
paper->setVisible(false);
@ -1512,47 +1531,47 @@ void MainWindowsNoGUI::ExportScene(const DialogSaveLayout &dialog, const QList<Q
break;
case LayoutExportFormats::DXF_AC1006_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1006, dialog.IsBinaryDXFFormat(), paper, scene, details);
FlatDxfFile(name, DRW::AC1006, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1009_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1009, dialog.IsBinaryDXFFormat(), paper, scene, details);
FlatDxfFile(name, DRW::AC1009, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1012_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1012, dialog.IsBinaryDXFFormat(), paper, scene, details);
FlatDxfFile(name, DRW::AC1012, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1014_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1014, dialog.IsBinaryDXFFormat(), paper, scene, details);
FlatDxfFile(name, DRW::AC1014, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1015_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1015, dialog.IsBinaryDXFFormat(), paper, scene, details);
FlatDxfFile(name, DRW::AC1015, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1018_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1018, dialog.IsBinaryDXFFormat(), paper, scene, details);
FlatDxfFile(name, DRW::AC1018, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1021_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1021, dialog.IsBinaryDXFFormat(), paper, scene, details);
FlatDxfFile(name, DRW::AC1021, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1024_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1024, dialog.IsBinaryDXFFormat(), paper, scene, details);
FlatDxfFile(name, DRW::AC1024, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
case LayoutExportFormats::DXF_AC1027_Flat:
paper->setVisible(false);
FlatDxfFile(name, DRW::AC1027, dialog.IsBinaryDXFFormat(), paper, scene, details);
FlatDxfFile(name, DRW::AC1027, m_dialogSaveLayout->IsBinaryDXFFormat(), paper, scene, details);
paper->setVisible(true);
break;
default:

View file

@ -90,9 +90,11 @@ protected:
QMarginsF margins;
QSizeF paperSize;
QSharedPointer<DialogSaveLayout> m_dialogSaveLayout;
static QVector<VLayoutPiece> PrepareDetailsForLayout(const QHash<quint32, VPiece> &details);
void ExportData(const QVector<VLayoutPiece> &listDetails, const DialogSaveLayout &dialog);
void ExportData(const QVector<VLayoutPiece> &listDetails);
void InitTempLayoutScene();
virtual void CleanLayout()=0;
@ -156,26 +158,23 @@ private:
bool isPagesUniform() const;
bool IsPagesFit(const QSizeF &printPaper) const;
void ExportScene(const DialogSaveLayout &dialog,
const QList<QGraphicsScene *> &scenes,
void ExportScene(const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers,
const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details,
bool ignorePrinterFields, const QMarginsF &margins) const;
void ExportApparelLayout(const DialogSaveLayout &dialog, const QVector<VLayoutPiece> &details, const QString &name,
const QSize &size) const;
void ExportApparelLayout(const QVector<VLayoutPiece> &details, const QString &name, const QSize &size) const;
void ExportDetailsAsApparelLayout(const DialogSaveLayout &dialog, QVector<VLayoutPiece> listDetails);
void ExportDetailsAsApparelLayout(QVector<VLayoutPiece> listDetails);
void ExportFlatLayout(const DialogSaveLayout &dialog,
const QList<QGraphicsScene *> &scenes,
void ExportFlatLayout(const QList<QGraphicsScene *> &scenes,
const QList<QGraphicsItem *> &papers,
const QList<QGraphicsItem *> &shadows,
const QList<QList<QGraphicsItem *> > &details,
bool ignorePrinterFields, const QMarginsF &margins);
void ExportDetailsAsFlatLayout(const DialogSaveLayout &dialog, const QVector<VLayoutPiece> &listDetails);
void ExportDetailsAsFlatLayout(const QVector<VLayoutPiece> &listDetails);
};
#endif // MAINWINDOWSNOGUI_H

View file

@ -116,6 +116,13 @@ const QString LONG_OPTION_CSVCODEC = QStringLiteral("csvCodec");
const QString LONG_OPTION_CSVSEPARATOR = QStringLiteral("csvSeparator");
const QString LONG_OPTION_CSVEXPORTFM = QStringLiteral("csvExportFM");
const QString LONG_OPTION_TILED_PDF_PAGE_TEMPLATE = QStringLiteral("tiledPageformat");
const QString LONG_OPTION_TILED_PDF_LEFT_MARGIN = QStringLiteral("tiledlmargin");
const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN = QStringLiteral("tiledrmargin");
const QString LONG_OPTION_TILED_PDF_TOP_MARGIN = QStringLiteral("tiledtmargin");
const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN = QStringLiteral("tiledbmargin");
const QString LONG_OPTION_TILED_PDF_LANDSCAPE = QStringLiteral("tiledLandscape");
//---------------------------------------------------------------------------------------------------------------------
QStringList AllKeys()
{
@ -152,7 +159,13 @@ QStringList AllKeys()
<< LONG_OPTION_CSVWITHHEADER
<< LONG_OPTION_CSVCODEC
<< LONG_OPTION_CSVSEPARATOR
<< LONG_OPTION_CSVEXPORTFM;
<< LONG_OPTION_CSVEXPORTFM
<< LONG_OPTION_TILED_PDF_PAGE_TEMPLATE
<< LONG_OPTION_TILED_PDF_LEFT_MARGIN
<< LONG_OPTION_TILED_PDF_RIGHT_MARGIN
<< LONG_OPTION_TILED_PDF_TOP_MARGIN
<< LONG_OPTION_TILED_PDF_BOTTOM_MARGIN
<< LONG_OPTION_TILED_PDF_LANDSCAPE;
return list;
}

View file

@ -113,6 +113,13 @@ extern const QString LONG_OPTION_CSVCODEC;
extern const QString LONG_OPTION_CSVSEPARATOR;
extern const QString LONG_OPTION_CSVEXPORTFM;
extern const QString LONG_OPTION_TILED_PDF_PAGE_TEMPLATE;
extern const QString LONG_OPTION_TILED_PDF_LEFT_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_RIGHT_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_TOP_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_BOTTOM_MARGIN;
extern const QString LONG_OPTION_TILED_PDF_LANDSCAPE;
QStringList AllKeys();
#endif // COMMANDOPTIONS_H