30 #include "../dialogs/dialoglayoutsettings.h"
31 #include "../vwidgets/export_format_combobox.h"
32 #include "../ifc/xml/vdomdocument.h"
33 #include "../vformat/vmeasurements.h"
34 #include "../vmisc/commandoptions.h"
35 #include "../vmisc/vsettings.h"
36 #include "../vlayout/vlayoutgenerator.h"
41 #define translate(context, source) QCoreApplication::translate((context), (source))
46 parser.setApplicationDescription(
translate(
"VCommandLine",
"Pattern making program."));
49 parser.addPositionalArgument(
"filename",
translate(
"VCommandLine",
"Pattern file."));
53 VCommandLineOptions::const_iterator i =
optionsUsed.constBegin();
81 translate(
"VCommandLine",
"The base filename of exported layout files. Use "
82 "it to enable console export mode."),
83 translate(
"VCommandLine",
"The base filename of layout files")));
87 translate(
"VCommandLine",
"The path to output destination folder. By "
88 "default the directory at which the application was started."),
89 translate(
"VCommandLine",
"The destination folder")));
93 translate(
"VCommandLine",
"Path to custom measure file (export mode)."),
94 translate(
"VCommandLine",
"The measure file")));
98 translate(
"VCommandLine",
"Number corresponding to output format (default = "
101 translate(
"VCommandLine",
"Format number"),
"0"));
105 translate(
"VCommandLine",
"Export dxf in binary form.")));
109 translate(
"VCommandLine",
"Export text as paths.")));
113 translate(
"VCommandLine",
"Export only details. Export details as they "
114 "positioned in the details mode. Any layout related"
115 " options will be ignored.")));
119 translate(
"VCommandLine",
"Set size value a pattern file, that was opened "
120 "with multisize measurements (export mode). Valid "
123 translate(
"VCommandLine",
"The size value")));
127 translate(
"VCommandLine",
"Set height value a pattern file, that was opened "
128 "with multisize measurements (export mode). Valid "
131 translate(
"VCommandLine",
"The height value")));
136 translate(
"VCommandLine",
"Number corresponding to page template (default = "
137 "0, export mode):") +
139 translate(
"VCommandLine",
"Template number"),
"0"));
143 translate(
"VCommandLine",
"Page width in current units like 12.0 (cannot be "
144 "used with \"%1\", export mode).")
146 translate(
"VCommandLine",
"The page width")));
150 translate(
"VCommandLine",
"Page height in current units like 12.0 (cannot "
151 "be used with \"%1\", export mode).")
153 (
"The page height")));
157 translate(
"VCommandLine",
"Page height/width measure units (cannot be used "
158 "with \"%1\", export mode). Valid values: %2.")
160 translate(
"VCommandLine",
"The measure unit")));
165 "Ignore margins printing (export mode). Disable value keys: "
166 "\"%1\", \"%2\", \"%3\", \"%4\". Set all margins to 0.")
173 "Page left margin in current units like 3.0 (export mode). If "
174 "not set will be used value from default printer. Or 0 if none "
175 "printers was found. Value will be ignored if key \"%1\" is used.")
177 (
"The left margin")));
182 "Page right margin in current units like 3.0 (export mode). If "
183 "not set will be used value from default printer. Or 0 if none "
184 "printers was found. Value will be ignored if key \"%1\" is used.")
186 (
"The right margin")));
191 "Page top margin in current units like 3.0 (export mode). If "
192 "not set will be used value from default printer. Or 0 if none "
193 "printers was found. Value will be ignored if key \"%1\" is used.")
195 (
"The top margin")));
200 "Page bottom margin in current units like 3.0 (export mode). If "
201 "not set will be used value from default printer. Or 0 if none "
202 "printers was found. Value will be ignored if key \"%1\" is used.")
204 (
"The bottom margin")));
209 translate(
"VCommandLine",
"Rotation in degrees (one of predefined, "
210 "export mode). Default value is 180. 0 is no-rotate. Valid values: "
211 "%1. Each value show how many times details will be rotated. For "
212 "example 180 mean two times (360/180=2) by 180 degree.")
213 .arg(
"0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, "
219 translate(
"VCommandLine",
"Auto crop unused length (export mode).")));
223 translate(
"VCommandLine",
"Unite pages if possible (export mode). Maximum "
224 "value limited by QImage that supports only a maximum of "
225 "32768x32768 px images.")));
231 "Save length of the sheet if set (export mode). The option tells "
232 "the program to use as much as possible width of sheet. Quality "
233 "of a layout can be worse when this option was used.")));
238 "Layout units (as paper's one except px, export mode)."),
243 translate(
"VCommandLine",
"Shift/Offset layout length measured in layout "
244 "units (export mode). The option show how many points along edge "
245 "will be used in creating a layout."),
246 translate(
"VCommandLine",
"Shift/Offset length")));
251 "The layout gap width x2, measured in layout units (export mode). "
252 "Set distance between details and a detail and a sheet."),
253 translate(
"VCommandLine",
"The gap width")));
257 translate(
"VCommandLine",
"Sets layout groupping cases (export mode): %1.")
259 translate(
"VCommandLine",
"Grouping type"),
"2"));
263 translate(
"VCommandLine",
"Run the program in a test mode. The program in "
264 "this mode loads a single pattern file and silently quit without "
265 "showing the main window. The key have priority before key '%1'.")
270 translate(
"VCommandLine",
"Disable high dpi scaling. Call this option if has "
271 "problem with scaling (by default scaling "
272 "enabled). Alternatively you can use the "
273 "%1 environment variable.")
274 .arg(
"QT_AUTO_SCREEN_SCALE_FACTOR=0")));
293 if ((a || b || c) && x)
295 qCritical() <<
translate(
"VCommandLine",
"Cannot use pageformat and page explicit size/units together.")
300 if ((a || b || c) && !(a && b && c))
302 qCritical() <<
translate(
"VCommandLine",
"Page height, width, units must be used all 3 at once.") <<
"\n";
313 if ((a || b) && !(a && b))
315 qCritical() <<
translate(
"VCommandLine",
"Shift/Offset length must be used together with shift units.")
326 if ((a || b) && !(a && b))
328 qCritical() <<
translate(
"VCommandLine",
"Gap width must be used together with shift units.") <<
"\n";
338 if ((a || b) && !(a && b))
340 qCritical() <<
translate(
"VCommandLine",
"Left margin must be used together with page units.") <<
"\n";
350 if ((a || b) && !(a && b))
352 qCritical() <<
translate(
"VCommandLine",
"Right margin must be used together with page units.") <<
"\n";
362 if ((a || b) && !(a && b))
364 qCritical() <<
translate(
"VCommandLine",
"Top margin must be used together with page units.") <<
"\n";
374 if ((a || b) && !(a && b))
376 qCritical() <<
translate(
"VCommandLine",
"Bottom margin must be used together with page units.") <<
"\n";
388 qCritical() <<
translate(
"VCommandLine",
"Invalid rotation value. That must be one of predefined values.")
397 qCritical() <<
translate(
"VCommandLine",
"Unknown page templated selected.") <<
"\n";
406 qCritical() <<
translate(
"VCommandLine",
"Unsupported paper units.") <<
"\n";
418 qCritical() <<
translate(
"VCommandLine",
"Unsupported layout units.") <<
"\n";
449 if (
parser.isSet(*option))
451 margins.setLeft(
Pg2Px(
parser.value(*option), diag));
457 if (
parser.isSet(*option))
459 margins.setRight(
Pg2Px(
parser.value(*option), diag));
465 if (
parser.isSet(*option))
467 margins.setTop(
Pg2Px(
parser.value(*option), diag));
473 if (
parser.isSet(*option))
475 margins.setBottom(
Pg2Px(
parser.value(*option), diag));
518 if (r &&
parser.positionalArguments().size() != 1)
520 qCritical() <<
translate(
"VCommandLine",
"Test option can be used with single input file only.") <<
"/n";
536 if (r &&
parser.positionalArguments().size() != 1)
538 qCritical() <<
translate(
"VCommandLine",
"Export options can be used with single input file only.") <<
"/n";
581 return static_cast<Cases>(r);
655 return parser.positionalArguments();
686 qCritical() <<
translate(
"VCommandLine",
"Invalid gradation size value.") <<
"\n";
701 qCritical() <<
translate(
"VCommandLine",
"Invalid gradation height value.") <<
"\n";
qreal PageToPixels(qreal value) const
bool SelectLayoutUnit(const QString &units)
void SetGroup(const Cases &value)
qreal LayoutToPixels(qreal value) const
void SetIgnoreAllFields(bool value)
void SetAutoCrop(bool autoCrop)
void SetUnitePages(bool save)
static QString MakeHelpTemplateList()
static QString MakeGroupsHelp()
QMarginsF GetFields() const
void SetLayoutWidth(qreal value)
bool SelectPaperUnit(const QString &units)
void SetShift(qreal value)
void SetSaveLength(bool save)
bool SetIncrease(int increase)
void SetRotate(bool state)
void SetPaperHeight(qreal value)
void SetFields(const QMarginsF &value)
bool SelectTemplate(const PaperSizeTemplate &id)
void SetPaperWidth(qreal value)
VCommandLineOptions optionsUsed
QString OptDestinationPath() const
bool IsTestModeEnabled() const
static void InitOptions(VCommandLineOptions &options, QMap< QString, int > &optionsIndex)
QString OptGradationHeight() const
QStringList OptInputFileNames() const
static VCommandLinePtr instance
QCommandLineParser parser
int exportOnlyPieces() const
QString OptBaseName() const
bool IsExportEnabled() const
DialogLayoutSettings::PaperSizeTemplate OptPaperSize() const
int isTextAsPaths() const
QString OptMeasurePath() const
bool IsNoScalingEnabled() const
static VCommandLinePtr Get(const QCoreApplication &app)
VLayoutGeneratorPtr DefaultGenerator() const
static qreal Lo2Px(const QString &src, const DialogLayoutSettings &converter)
bool IsSetGradationHeight() const
bool IsGuiEnabled() const
static qreal Pg2Px(const QString &src, const DialogLayoutSettings &converter)
QString OptGradationSize() const
bool IsSetGradationSize() const
QMap< QString, int > optionsIndex
int OptExportType() const
static QString UnitsHelpString()
static QStringList WholeListSizes(Unit patternUnit)
static QStringList WholeListHeights(Unit patternUnit)
static bool IsGradationSizeValid(const QString &size)
static bool IsGradationHeightValid(const QString &height)
static int GetDefLayoutRotationIncrease()
const QString SINGLE_OPTION_LEFT_MARGIN
const QString LONG_OPTION_PAGEH
const QString LONG_OPTION_EXP2FORMAT
const QString LONG_OPTION_LEFT_MARGIN
const QString LONG_OPTION_RIGHT_MARGIN
const QString SINGLE_OPTION_ROTATE
const QString SINGLE_OPTION_BASENAME
const QString SINGLE_OPTION_GAPWIDTH
const QString SINGLE_OPTION_RIGHT_MARGIN
const QString LONG_OPTION_GROUPPING
const QString SINGLE_OPTION_EXP2FORMAT
const QString LONG_OPTION_SAVELENGTH
const QString SINGLE_OPTION_CROP
const QString SINGLE_OPTION_SAVELENGTH
const QString LONG_OPTION_TEST
const QString SINGLE_OPTION_PAGEH
const QString SINGLE_OPTION_SHIFTUNITS
const QString LONG_OPTION_BINARYDXF
const QString LONG_OPTION_TOP_MARGIN
const QString SINGLE_OPTION_PAGEW
const QString SINGLE_OPTION_BOTTOM_MARGIN
const QString SINGLE_OPTION_PAGETEMPLATE
const QString LONG_OPTION_BOTTOM_MARGIN
const QString LONG_OPTION_EXPORTONLYDETAILS
const QString LONG_OPTION_BASENAME
const QString LONG_OPTION_PAGETEMPLATE
const QString SINGLE_OPTION_TOP_MARGIN
const QString LONG_OPTION_CROP
const QString LONG_OPTION_PAGEUNITS
const QString LONG_OPTION_ROTATE
const QString LONG_OPTION_SHIFTUNITS
const QString LONG_OPTION_GRADATIONSIZE
const QString LONG_OPTION_GAPWIDTH
const QString LONG_OPTION_SHIFTLENGTH
const QString SINGLE_OPTION_GROUPPING
const QString SINGLE_OPTION_UNITE
const QString LONG_OPTION_UNITE
const QString SINGLE_OPTION_IGNORE_MARGINS
const QString SINGLE_OPTION_TEST
const QString SINGLE_OPTION_PAGEUNITS
const QString LONG_OPTION_GRADATIONHEIGHT
const QString SINGLE_OPTION_GRADATIONHEIGHT
const QString LONG_OPTION_MEASUREFILE
const QString SINGLE_OPTION_DESTINATION
const QString LONG_OPTION_TEXT2PATHS
const QString LONG_OPTION_IGNORE_MARGINS
const QString SINGLE_OPTION_GRADATIONSIZE
const QString LONG_OPTION_DESTINATION
const QString SINGLE_OPTION_MEASUREFILE
const QString LONG_OPTION_PAGEW
const QString SINGLE_OPTION_SHIFTLENGTH
const QString LONG_OPTION_NO_HDPI_SCALING
#define translate(context, source)
std::shared_ptr< VLayoutGenerator > VLayoutGeneratorPtr
std::shared_ptr< VCommandLine > VCommandLinePtr
static const auto V_EX_USAGE