14#include <QApplication>
15#include <QCoreApplication>
21#include <QProcessEnvironment>
22#include <QStyleFactory>
61 QString &pathAndFile);
65 bool &isDropRegression,
67 QString &errorReportFile,
68 QString &fileCmdScriptFile,
69 bool &isErrorReportRegressionTest,
72 bool &isExtractImageOnly,
73 QString &extractImageOnlyExtension,
75 QStringList &loadStartupFiles,
76 QStringList &commandLineWithoutLoadStartupFiles);
78 const QString &dashForRepeatingFlag,
79 const QString &errorReportFile,
80 const QString &fileCmdScriptFile,
81 const QStringList &loadStartupFiles);
84 const QString &msgUnadorned);
93 QFileInfo check (file);
94 return check.exists() && check.isFile();
101#if !defined(OSX_RELEASE) && !defined(WIN_RELEASE) && !defined(APPIMAGE_RELEASE)
102 QProcessEnvironment env;
118 QString &pathAndFile)
120 bool success =
false;
123 pathAndFile = QString (
"%1%2%3")
125 .arg (QDir::separator())
127 QFile file (pathAndFile);
128 if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
138int main(
int argc,
char *argv[])
140 qRegisterMetaType<ColorFilterMode> (
"ColorFilterMode");
141 qRegisterMetaType<FittingCurveCoefficients> (
"FilterCurveCoefficients");
142 qRegisterMetaType<ZoomFactor> (
"ZoomFactor");
144 QApplication app(argc, argv);
150 bool isDebug, isDropRegression, isReset, isGnuplot, isErrorReportRegressionTest, isExportOnly, isExtractImageOnly, isUpgrade;
151 QString errorReportFile, extractImageOnlyExtension, fileCmdScriptFile;
152 QStringList loadStartupFiles, commandLineWithoutLoadStartupFiles;
160 isErrorReportRegressionTest,
164 extractImageOnlyExtension,
167 commandLineWithoutLoadStartupFiles);
173 LOG4CPP_INFO_S ((*
mainCat)) <<
"main args=" << QApplication::arguments().join (
" ").toLatin1().data();
184 isErrorReportRegressionTest,
189 extractImageOnlyExtension,
191 commandLineWithoutLoadStartupFiles);
204 bool &isDropRegression,
206 QString &errorReportFile,
207 QString &fileCmdScriptFile,
208 bool &isErrorReportRegressionTest,
211 bool &isExtractImageOnly,
212 QString &extractImageOnlyExtension,
214 QStringList &loadStartupFiles,
215 QStringList &commandLineWithoutLoadStartupFiles)
217 bool showUsage =
false;
222 bool nextIsErrorReportFile =
false;
223 bool nextIsExtractImageOnly =
false;
224 bool nextIsFileCmdScript =
false;
228 isDropRegression =
false;
230 errorReportFile =
"";
231 fileCmdScriptFile =
"";
232 isErrorReportRegressionTest =
false;
234 isExportOnly =
false;
235 isExtractImageOnly =
false;
236 extractImageOnlyExtension =
"";
239 for (
int i = 1; i < argc; i++) {
241 bool isLoadStartupFile =
false;
243 if (nextIsErrorReportFile) {
246 QObject::tr (
"is not a valid file name"));
247 errorReportFile = argv [i];
248 nextIsErrorReportFile =
false;
249 }
else if (nextIsExtractImageOnly) {
252 QObject::tr (
"is not a valid image file extension"));
253 extractImageOnlyExtension = argv [i];
254 nextIsExtractImageOnly =
false;
255 }
else if (nextIsFileCmdScript) {
258 QObject::tr (
"is not a valid file name"));
259 fileCmdScriptFile = argv [i];
260 nextIsFileCmdScript =
false;
261 }
else if (strcmp (argv [i],
DASH_DEBUG.toLatin1().data()) == 0) {
264 isDropRegression =
true;
266 nextIsErrorReportFile =
true;
270 isExtractImageOnly =
true;
271 nextIsExtractImageOnly =
true;
273 nextIsFileCmdScript =
true;
274 }
else if (strcmp (argv [i],
DASH_GNUPLOT.toLatin1().data()) == 0) {
276 }
else if (strcmp (argv [i],
DASH_HELP.toLatin1().data()) == 0) {
278 }
else if (strcmp (argv [i],
DASH_REGRESSION.toLatin1().data()) == 0) {
279 isErrorReportRegressionTest =
true;
280 }
else if (strcmp (argv [i],
DASH_RESET.toLatin1().data()) == 0) {
282 }
else if (strcmp (argv [i],
DASH_STYLE.toLatin1().data()) == 0) {
285 }
else if (strcmp (argv [i],
DASH_STYLES.toLatin1().data()) == 0) {
287 }
else if (strcmp (argv [i],
DASH_UPGRADE.toLatin1().data()) == 0) {
289 }
else if (strncmp (argv [i],
DASH.toLatin1().data(), 1) == 0) {
294 QString fileName = argv [i];
295 QFileInfo fInfo (fileName);
296 if (fInfo.isRelative() && !fileName.startsWith (
"http")) {
297 fileName = fInfo.absoluteFilePath();
300 isLoadStartupFile =
true;
301 loadStartupFiles << fileName;
305 if (!isLoadStartupFile) {
306 commandLineWithoutLoadStartupFiles << argv [i];
323 if (showUsage || nextIsErrorReportFile || nextIsExtractImageOnly || nextIsFileCmdScript) {
331 const QString &dashForRepeatingFlag,
332 const QString &errorReportFile,
333 const QString &fileCmdScriptFile,
334 const QStringList &loadStartupFiles)
336 if (isRepeatingFlag && (!errorReportFile.isEmpty() ||
337 !fileCmdScriptFile.isEmpty() ||
338 loadStartupFiles.size() == 0)) {
343 QTextStream str (&msg);
344 str << dashForRepeatingFlag.toLatin1().data() <<
" " << QObject::tr (
"is used only with one or more load files");
351 const QString &msgUnadorned)
353 if (!requiredCondition) {
356 QString msg = QString (
"%1 %2")
376 QTextStream str (&msg);
377 str << QObject::tr (
"Available styles") <<
": " << QStyleFactory::keys ().join (
", ");
384 QTextStream str (&msg);
385 str <<
"<html>Usage: engauge "
386 <<
"[" <<
DASH_DEBUG.toLatin1().data() <<
"] "
393 <<
"[" <<
DASH_HELP.toLatin1().data() <<
"] "
395 <<
"[" <<
DASH_RESET.toLatin1().data () <<
"] "
396 <<
"[" <<
DASH_STYLE.toLatin1().data () <<
" <style>] "
398 <<
"[<load_file1>] [<load_file2>] ..." <<
"\n"
401 <<
"<td>" << QObject::tr (
"where") <<
"</td>"
405 <<
"<td>" <<
DASH_DEBUG.toLatin1().data() <<
"</td>"
407 << QObject::tr (
"Enables extra debug information. Used for debugging").toLatin1().data()
413 << QObject::tr (
"Indicates files opened at startup are for testing drag and drop. Used for regression testing").toLatin1().data()
419 << QObject::tr (
"Specifies an error report file as input. Used for debugging and regression testing").toLatin1().data()
425 << QObject::tr (
"Export each loaded startup file, which must have all axis points defined, then stop").toLatin1().data()
431 << QObject::tr (
"Extract image in each loaded startup file to a file with the specified extension, then stop").toLatin1().data()
437 << QObject::tr (
"Specifies a file command script file as input. Used for debugging and testing").toLatin1().data()
443 << QObject::tr (
"Output diagnostic gnuplot input files. Used for debugging").toLatin1().data()
447 <<
"<td>" <<
DASH_HELP.toLatin1().data() <<
"</td>"
449 << QObject::tr (
"Show this help information").toLatin1().data()
455 << QObject::tr (
"Executes the error report file or file command script. Used for regression testing").toLatin1().data()
459 <<
"<td>" <<
DASH_RESET.toLatin1().data() <<
"</td>"
461 << QObject::tr (
"Removes all stored settings, including window positions. Used when windows start up offscreen").toLatin1().data()
465 <<
"<td>" <<
DASH_STYLE.toLatin1().data() <<
"</td>"
468 .arg (QObject::tr (
"Set the window style to one of the styles listed by the command line option"))
473 <<
"<td>" <<
DASH_STYLES.toLatin1().data() <<
"</td>"
476 .arg (QObject::tr (
"Show a list of available styles that can be used with the command line option"))
483 << QObject::tr (
"Upgrade files opened at startup to the most recent version").toLatin1().data()
487 <<
"<td>" << QString (
"<load file> ").toLatin1().data() <<
"</td>"
489 << QObject::tr (
"File(s) to be imported or opened at startup").toLatin1().data()
497 <<
"<td>" << QObject::tr (
"Useful environment variables:") <<
"</td>"
502 <<
"<td>" << QObject::tr (
"Set timezone to add or subtract hours in time values. Timezone values are listed as TZ Database Names in Wikipedia").toLatin1().data() <<
"</td>"
504 <<
"</table></html>";
511 QString FILE_SUFFIX (
".dig");
512 QString UPGRADE_TOKEN (
"_upgrade");
516 QStringList::const_iterator itr;
517 for (itr = loadStartupFiles.begin(); itr != loadStartupFiles.end(); itr++) {
519 QString filenameOld = *itr;
523 if (filenameOld.endsWith (FILE_SUFFIX,
524 Qt::CaseInsensitive)) {
525 QString withoutSuffix = filenameOld.left (filenameOld.size () - FILE_SUFFIX.size ());
526 filenameNew = QString (
"%1%2%3")
533 filenameNew = QString (
"%1%2")
535 .arg (UPGRADE_TOKEN);
542 QFile file (filenameNew);
543 if (!file.open (QFile::WriteOnly)) {
545 msg += QString (
"%1 %2")
546 .arg (QObject::tr (
"Could not write to"))
551 QXmlStreamWriter writer (&file);
552 writer.setAutoFormatting (
true);
553 writer.writeStartDocument();
554 writer.writeDTD (
"<!DOCTYPE engauge>");
556 writer.writeEndDocument ();
558 msg += QString (
"%1 %2 %3 %4")
559 .arg (QObject::tr (
"Upgraded"))
561 .arg (QObject::tr (
"to"))
log4cpp::Category * mainCat
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
Storage of one imported image and the data attached to that image.
void saveXml(QXmlStreamWriter &writer) const
Save document to xml.
Provides list of file extensions for import.
bool offers(const QString &fileExtension) const
Return true if specified file extension is supported.
Main window for momentary message dialog.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Class that stores QTranslator objects for the duration of application execution.
#define LOG4CPP_INFO_S(logger)
int main(int argc, char *argv[])
void sanityCheckLoadStartupFiles(bool isRepeatingFlag, const QString &dashForRepeatingFlag, const QString &errorReportFile, const QString &fileCmdScriptFile, const QStringList &loadStartupFiles)
const QString CMD_EXPORT_ONLY("exportonly")
const QString DASH_ERROR_REPORT("-"+CMD_ERROR_REPORT)
const QString CMD_STYLE("style")
const QString CMD_ERROR_REPORT("errorreport")
const QString CMD_RESET("reset")
bool engaugeLogFilenameAttempt(const QString &path, QString &pathAndFile)
const QString CMD_STYLES("styles")
const QString ENGAUGE_LOG_FILE(".engauge.log")
const QString CMD_DROP_REGRESSION("dropregression")
const QString CMD_REGRESSION("regression")
const QString DASH_GNUPLOT("-"+CMD_GNUPLOT)
const QString DASH_EXTRACT_IMAGE_ONLY("-"+CMD_EXTRACT_IMAGE_ONLY)
void parseCmdLine(int argc, char **argv, bool &isDebug, bool &isDropRegression, bool &isReset, QString &errorReportFile, QString &fileCmdScriptFile, bool &isErrorReportRegressionTest, bool &isGnuplot, bool &isExportOnly, bool &isExtractImageOnly, QString &extractImageOnlyExtension, bool &isUpgrade, QStringList &loadStartupFiles, QStringList &commandLineWithoutLoadStartupFiles)
void sanityCheckValue(bool requiredCondition, const QString &arg, const QString &msgUnadorned)
const QString CMD_GNUPLOT("gnuplot")
QString engaugeLogFilename()
const QString DASH_HELP("-"+CMD_HELP)
const QString DASH_UPGRADE("-"+CMD_UPGRADE)
const QString CMD_EXTRACT_IMAGE_ONLY("extractimageonly")
const QString DASH_RESET("-"+CMD_RESET)
const QString CMD_HELP("help")
const QString CMD_UPGRADE("upgrade")
void showMessageAndQuit(const QString &msg)
const QString DASH_STYLES("-"+CMD_STYLES)
const QString DASH_REGRESSION("-"+CMD_REGRESSION)
const QString CMD_FILE_CMD_SCRIPT("filecmdscript")
const QString DASH_EXPORT_ONLY("-"+CMD_EXPORT_ONLY)
const QString DASH_DROP_REGRESSION("-"+CMD_DROP_REGRESSION)
const QString DASH_DEBUG("-"+CMD_DEBUG)
const QString DASH_STYLE("-"+CMD_STYLE)
bool checkFileExists(const QString &file)
void upgradeFiles(const QStringList &loadStartupFiles)
const QString CMD_DEBUG("debug")
const QString DASH_FILE_CMD_SCRIPT("-"+CMD_FILE_CMD_SCRIPT)