#include "ColorFilterMode.h"
#include "FittingCurveCoefficients.h"
#include "ImportImageExtensions.h"
#include "Logger.h"
#include "MainWindow.h"
#include <QApplication>
#include <QCoreApplication>
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QMessageBox>
#include <QObject>
#include <QProcessEnvironment>
#include <QStyleFactory>
#include "TranslatorContainer.h"
#include "ZoomFactor.h"
Go to the source code of this file.
|
| const QString | CMD_DEBUG ("debug") |
| |
| const QString | CMD_DROP_REGRESSION ("dropregression") |
| |
| const QString | CMD_ERROR_REPORT ("errorreport") |
| |
| const QString | CMD_EXPORT_ONLY ("exportonly") |
| |
| const QString | CMD_EXTRACT_IMAGE_ONLY ("extractimageonly") |
| |
| const QString | CMD_FILE_CMD_SCRIPT ("filecmdscript") |
| |
| const QString | CMD_GNUPLOT ("gnuplot") |
| |
| const QString | CMD_HELP ("help") |
| |
| const QString | CMD_REGRESSION ("regression") |
| |
| const QString | CMD_RESET ("reset") |
| |
| const QString | CMD_STYLE ("style") |
| |
| const QString | CMD_STYLES ("styles") |
| |
| const QString | CMD_UPGRADE ("upgrade") |
| |
| const QString | DASH ("-") |
| |
| const QString | DASH_DEBUG ("-"+CMD_DEBUG) |
| |
| const QString | DASH_DROP_REGRESSION ("-"+CMD_DROP_REGRESSION) |
| |
| const QString | DASH_ERROR_REPORT ("-"+CMD_ERROR_REPORT) |
| |
| const QString | DASH_EXTRACT_IMAGE_ONLY ("-"+CMD_EXTRACT_IMAGE_ONLY) |
| |
| const QString | DASH_EXPORT_ONLY ("-"+CMD_EXPORT_ONLY) |
| |
| const QString | DASH_FILE_CMD_SCRIPT ("-"+CMD_FILE_CMD_SCRIPT) |
| |
| const QString | DASH_GNUPLOT ("-"+CMD_GNUPLOT) |
| |
| const QString | DASH_HELP ("-"+CMD_HELP) |
| |
| const QString | DASH_REGRESSION ("-"+CMD_REGRESSION) |
| |
| const QString | DASH_RESET ("-"+CMD_RESET) |
| |
| const QString | DASH_STYLE ("-"+CMD_STYLE) |
| |
| const QString | DASH_STYLES ("-"+CMD_STYLES) |
| |
| const QString | DASH_UPGRADE ("-"+CMD_UPGRADE) |
| |
| const QString | ENGAUGE_LOG_FILE (".engauge.log") |
| |
| bool | checkFileExists (const QString &file) |
| |
| QString | engaugeLogFilename () |
| |
| bool | engaugeLogFilenameAttempt (const QString &path, QString &pathAndFile) |
| |
| 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 | sanityCheckLoadStartupFiles (bool isRepeatingFlag, const QString &dashForRepeatingFlag, const QString &errorReportFile, const QString &fileCmdScriptFile, const QStringList &loadStartupFiles) |
| |
| void | sanityCheckValue (bool requiredCondition, const QString &arg, const QString &msgUnadorned) |
| |
| void | showMessageAndQuit (const QString &msg) |
| |
| void | showStylesAndQuit () |
| |
| void | showUsageAndQuit () |
| |
| void | upgradeFiles (const QStringList &loadStartupFiles) |
| |
| int | main (int argc, char *argv[]) |
| |
◆ checkFileExists()
| bool checkFileExists |
( |
const QString & |
file | ) |
|
Definition at line 89 of file main.cpp.
91 QFileInfo check (file);
92 return check.exists() && check.isFile();
◆ CMD_DEBUG()
| const QString CMD_DEBUG |
( |
"debug" |
| ) |
|
◆ CMD_DROP_REGRESSION()
| const QString CMD_DROP_REGRESSION |
( |
"dropregression" |
| ) |
|
◆ CMD_ERROR_REPORT()
| const QString CMD_ERROR_REPORT |
( |
"errorreport" |
| ) |
|
◆ CMD_EXPORT_ONLY()
| const QString CMD_EXPORT_ONLY |
( |
"exportonly" |
| ) |
|
◆ CMD_EXTRACT_IMAGE_ONLY()
| const QString CMD_EXTRACT_IMAGE_ONLY |
( |
"extractimageonly" |
| ) |
|
◆ CMD_FILE_CMD_SCRIPT()
| const QString CMD_FILE_CMD_SCRIPT |
( |
"filecmdscript" |
| ) |
|
◆ CMD_GNUPLOT()
| const QString CMD_GNUPLOT |
( |
"gnuplot" |
| ) |
|
◆ CMD_HELP()
| const QString CMD_HELP |
( |
"help" |
| ) |
|
◆ CMD_REGRESSION()
| const QString CMD_REGRESSION |
( |
"regression" |
| ) |
|
◆ CMD_RESET()
| const QString CMD_RESET |
( |
"reset" |
| ) |
|
◆ CMD_STYLE()
| const QString CMD_STYLE |
( |
"style" |
| ) |
|
◆ CMD_STYLES()
| const QString CMD_STYLES |
( |
"styles" |
| ) |
|
◆ CMD_UPGRADE()
| const QString CMD_UPGRADE |
( |
"upgrade" |
| ) |
|
◆ DASH()
| const QString DASH |
( |
"-" |
| ) |
|
◆ DASH_DEBUG()
| const QString DASH_DEBUG |
( |
"-"+ |
CMD_DEBUG | ) |
|
◆ DASH_DROP_REGRESSION()
| const QString DASH_DROP_REGRESSION |
( |
"-"+ |
CMD_DROP_REGRESSION | ) |
|
◆ DASH_ERROR_REPORT()
| const QString DASH_ERROR_REPORT |
( |
"-"+ |
CMD_ERROR_REPORT | ) |
|
◆ DASH_EXPORT_ONLY()
| const QString DASH_EXPORT_ONLY |
( |
"-"+ |
CMD_EXPORT_ONLY | ) |
|
◆ DASH_EXTRACT_IMAGE_ONLY()
| const QString DASH_EXTRACT_IMAGE_ONLY |
( |
"-"+ |
CMD_EXTRACT_IMAGE_ONLY | ) |
|
◆ DASH_FILE_CMD_SCRIPT()
| const QString DASH_FILE_CMD_SCRIPT |
( |
"-"+ |
CMD_FILE_CMD_SCRIPT | ) |
|
◆ DASH_GNUPLOT()
| const QString DASH_GNUPLOT |
( |
"-"+ |
CMD_GNUPLOT | ) |
|
◆ DASH_HELP()
| const QString DASH_HELP |
( |
"-"+ |
CMD_HELP | ) |
|
◆ DASH_REGRESSION()
| const QString DASH_REGRESSION |
( |
"-"+ |
CMD_REGRESSION | ) |
|
◆ DASH_RESET()
| const QString DASH_RESET |
( |
"-"+ |
CMD_RESET | ) |
|
◆ DASH_STYLE()
| const QString DASH_STYLE |
( |
"-"+ |
CMD_STYLE | ) |
|
◆ DASH_STYLES()
| const QString DASH_STYLES |
( |
"-"+ |
CMD_STYLES | ) |
|
◆ DASH_UPGRADE()
| const QString DASH_UPGRADE |
( |
"-"+ |
CMD_UPGRADE | ) |
|
◆ ENGAUGE_LOG_FILE()
| const QString ENGAUGE_LOG_FILE |
( |
".engauge.log" |
| ) |
|
◆ engaugeLogFilename()
| QString engaugeLogFilename |
( |
| ) |
|
Definition at line 95 of file main.cpp.
99 #if !defined(OSX_RELEASE) && !defined(WIN_RELEASE) && !defined(APPIMAGE_RELEASE)
100 QProcessEnvironment env;
◆ engaugeLogFilenameAttempt()
| bool engaugeLogFilenameAttempt |
( |
const QString & |
path, |
|
|
QString & |
pathAndFile |
|
) |
| |
Definition at line 115 of file main.cpp.
118 bool success =
false;
121 pathAndFile = QString (
"%1%2%3")
123 .arg (QDir::separator())
125 QFile file (pathAndFile);
126 if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
◆ main()
| int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 136 of file main.cpp.
138 qRegisterMetaType<ColorFilterMode> (
"ColorFilterMode");
139 qRegisterMetaType<FittingCurveCoefficients> (
"FilterCurveCoefficients");
140 qRegisterMetaType<ZoomFactor> (
"ZoomFactor");
142 QApplication app(argc, argv);
148 bool isDebug, isDropRegression, isReset, isGnuplot, isErrorReportRegressionTest, isExportOnly, isExtractImageOnly, isUpgrade;
149 QString errorReportFile, extractImageOnlyExtension, fileCmdScriptFile;
150 QStringList loadStartupFiles, commandLineWithoutLoadStartupFiles;
158 isErrorReportRegressionTest,
162 extractImageOnlyExtension,
165 commandLineWithoutLoadStartupFiles);
171 LOG4CPP_INFO_S ((*
mainCat)) <<
"main args=" << QApplication::arguments().join (
" ").toLatin1().data();
182 isErrorReportRegressionTest,
187 extractImageOnlyExtension,
189 commandLineWithoutLoadStartupFiles);
◆ parseCmdLine()
| 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 |
|
) |
| |
Definition at line 199 of file main.cpp.
215 bool showUsage =
false;
220 bool nextIsErrorReportFile =
false;
221 bool nextIsExtractImageOnly =
false;
222 bool nextIsFileCmdScript =
false;
226 isDropRegression =
false;
228 errorReportFile =
"";
229 fileCmdScriptFile =
"";
230 isErrorReportRegressionTest =
false;
232 isExportOnly =
false;
233 isExtractImageOnly =
false;
234 extractImageOnlyExtension =
"";
237 for (
int i = 1; i < argc; i++) {
239 bool isLoadStartupFile =
false;
241 if (nextIsErrorReportFile) {
244 QObject::tr (
"is not a valid file name"));
245 errorReportFile = argv [i];
246 nextIsErrorReportFile =
false;
247 }
else if (nextIsExtractImageOnly) {
250 QObject::tr (
"is not a valid image file extension"));
251 extractImageOnlyExtension = argv [i];
252 nextIsExtractImageOnly =
false;
253 }
else if (nextIsFileCmdScript) {
256 QObject::tr (
"is not a valid file name"));
257 fileCmdScriptFile = argv [i];
258 nextIsFileCmdScript =
false;
259 }
else if (strcmp (argv [i],
DASH_DEBUG.toLatin1().data()) == 0) {
262 isDropRegression =
true;
264 nextIsErrorReportFile =
true;
268 isExtractImageOnly =
true;
269 nextIsExtractImageOnly =
true;
271 nextIsFileCmdScript =
true;
272 }
else if (strcmp (argv [i],
DASH_GNUPLOT.toLatin1().data()) == 0) {
274 }
else if (strcmp (argv [i],
DASH_HELP.toLatin1().data()) == 0) {
276 }
else if (strcmp (argv [i],
DASH_REGRESSION.toLatin1().data()) == 0) {
277 isErrorReportRegressionTest =
true;
278 }
else if (strcmp (argv [i],
DASH_RESET.toLatin1().data()) == 0) {
280 }
else if (strcmp (argv [i],
DASH_STYLE.toLatin1().data()) == 0) {
283 }
else if (strcmp (argv [i],
DASH_STYLES.toLatin1().data()) == 0) {
285 }
else if (strcmp (argv [i],
DASH_UPGRADE.toLatin1().data()) == 0) {
287 }
else if (strncmp (argv [i],
DASH.toLatin1().data(), 1) == 0) {
292 QString fileName = argv [i];
293 QFileInfo fInfo (fileName);
294 if (fInfo.isRelative() && !fileName.startsWith (
"http")) {
295 fileName = fInfo.absoluteFilePath();
298 isLoadStartupFile =
true;
299 loadStartupFiles << fileName;
303 if (!isLoadStartupFile) {
304 commandLineWithoutLoadStartupFiles << argv [i];
321 if (showUsage || nextIsErrorReportFile || nextIsExtractImageOnly || nextIsFileCmdScript) {
◆ sanityCheckLoadStartupFiles()
| void sanityCheckLoadStartupFiles |
( |
bool |
isRepeatingFlag, |
|
|
const QString & |
dashForRepeatingFlag, |
|
|
const QString & |
errorReportFile, |
|
|
const QString & |
fileCmdScriptFile, |
|
|
const QStringList & |
loadStartupFiles |
|
) |
| |
Definition at line 328 of file main.cpp.
334 if (isRepeatingFlag && (!errorReportFile.isEmpty() ||
335 !fileCmdScriptFile.isEmpty() ||
336 loadStartupFiles.size() == 0)) {
341 QTextStream str (&msg);
342 str << dashForRepeatingFlag.toLatin1().data() <<
" " << QObject::tr (
"is used only with one or more load files");
◆ sanityCheckValue()
| void sanityCheckValue |
( |
bool |
requiredCondition, |
|
|
const QString & |
arg, |
|
|
const QString & |
msgUnadorned |
|
) |
| |
Definition at line 347 of file main.cpp.
351 if (!requiredCondition) {
354 QString msg = QString (
"%1 %2")
◆ showMessageAndQuit()
| void showMessageAndQuit |
( |
const QString & |
msg | ) |
|
Definition at line 361 of file main.cpp.
364 QMessageBox::critical (
nullptr,
365 QObject::tr (
"Engauge Digitizer"),
◆ showStylesAndQuit()
| void showStylesAndQuit |
( |
| ) |
|
Definition at line 370 of file main.cpp.
373 QTextStream str (&msg);
374 str << QObject::tr (
"Available styles") <<
": " << QStyleFactory::keys ().join (
", ");
◆ showUsageAndQuit()
| void showUsageAndQuit |
( |
| ) |
|
Definition at line 378 of file main.cpp.
381 QTextStream str (&msg);
382 str <<
"<html>Usage: engauge "
383 <<
"[" <<
DASH_DEBUG.toLatin1().data() <<
"] "
390 <<
"[" <<
DASH_HELP.toLatin1().data() <<
"] "
392 <<
"[" <<
DASH_RESET.toLatin1().data () <<
"] "
393 <<
"[" <<
DASH_STYLE.toLatin1().data () <<
" <style>] "
395 <<
"[<load_file1>] [<load_file2>] ..." << endl
398 <<
"<td>" <<
DASH_DEBUG.toLatin1().data() <<
"</td>"
400 << QObject::tr (
"Enables extra debug information. Used for debugging").toLatin1().data()
406 << QObject::tr (
"Indicates files opened at startup are for testing drag and drop. Used for regression testing").toLatin1().data()
412 << QObject::tr (
"Specifies an error report file as input. Used for debugging and regression testing").toLatin1().data()
418 << QObject::tr (
"Export each loaded startup file, which must have all axis points defined, then stop").toLatin1().data()
424 << QObject::tr (
"Extract image in each loaded startup file to a file with the specified extension, then stop").toLatin1().data()
430 << QObject::tr (
"Specifies a file command script file as input. Used for debugging and testing").toLatin1().data()
436 << QObject::tr (
"Output diagnostic gnuplot input files. Used for debugging").toLatin1().data()
440 <<
"<td>" <<
DASH_HELP.toLatin1().data() <<
"</td>"
442 << QObject::tr (
"Show this help information").toLatin1().data()
448 << QObject::tr (
"Executes the error report file or file command script. Used for regression testing").toLatin1().data()
452 <<
"<td>" <<
DASH_RESET.toLatin1().data() <<
"</td>"
454 << QObject::tr (
"Removes all stored settings, including window positions. Used when windows start up offscreen").toLatin1().data()
458 <<
"<td>" <<
DASH_STYLE.toLatin1().data() <<
"</td>"
461 .arg (QObject::tr (
"Set the window style to one of the styles listed by the command line option"))
466 <<
"<td>" <<
DASH_STYLES.toLatin1().data() <<
"</td>"
469 .arg (QObject::tr (
"Show a list of available styles that can be used with the command line option"))
476 << QObject::tr (
"Upgrade files opened at startup to the most recent version").toLatin1().data()
480 <<
"<td>" << QString (
"<load file> ").toLatin1().data() <<
"</td>"
482 << QObject::tr (
"File(s) to be imported or opened at startup").toLatin1().data()
485 <<
"</table></html>";
◆ upgradeFiles()
| void upgradeFiles |
( |
const QStringList & |
loadStartupFiles | ) |
|
Definition at line 490 of file main.cpp.
492 QString FILE_SUFFIX (
".dig");
493 QString UPGRADE_TOKEN (
"_upgrade");
497 QStringList::const_iterator itr;
498 for (itr = loadStartupFiles.begin(); itr != loadStartupFiles.end(); itr++) {
500 QString filenameOld = *itr;
504 if (filenameOld.endsWith (FILE_SUFFIX,
505 Qt::CaseInsensitive)) {
506 QString withoutSuffix = filenameOld.left (filenameOld.size () - FILE_SUFFIX.size ());
507 filenameNew = QString (
"%1%2%3")
514 filenameNew = QString (
"%1%2")
516 .arg (UPGRADE_TOKEN);
523 QFile file (filenameNew);
524 if (!file.open (QFile::WriteOnly)) {
526 msg += QString (
"%1 %2")
527 .arg (QObject::tr (
"Could not write to"))
532 QXmlStreamWriter writer (&file);
533 writer.setAutoFormatting (
true);
534 writer.writeStartDocument();
535 writer.writeDTD (
"<!DOCTYPE engauge>");
536 document.saveXml (writer);
537 writer.writeEndDocument ();
539 msg += QString (
"%1 %2 %3 %4")
540 .arg (QObject::tr (
"Upgraded"))
542 .arg (QObject::tr (
"to"))
const QString DASH_DEBUG("-"+CMD_DEBUG)
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
Provides list of file extensions for import.
const QString DASH_FILE_CMD_SCRIPT("-"+CMD_FILE_CMD_SCRIPT)
void sanityCheckValue(bool requiredCondition, const QString &arg, const QString &msgUnadorned)
const QString DASH_UPGRADE("-"+CMD_UPGRADE)
const QString DASH_RESET("-"+CMD_RESET)
const QString DASH_DROP_REGRESSION("-"+CMD_DROP_REGRESSION)
const QString DASH_STYLES("-"+CMD_STYLES)
Storage of one imported image and the data attached to that image.
void showMessageAndQuit(const QString &msg)
const QString DASH_ERROR_REPORT("-"+CMD_ERROR_REPORT)
const QString DASH_EXPORT_ONLY("-"+CMD_EXPORT_ONLY)
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void upgradeFiles(const QStringList &loadStartupFiles)
const QString DASH_GNUPLOT("-"+CMD_GNUPLOT)
#define LOG4CPP_INFO_S(logger)
log4cpp::Category * mainCat
const QString DASH_HELP("-"+CMD_HELP)
const QString DASH_EXTRACT_IMAGE_ONLY("-"+CMD_EXTRACT_IMAGE_ONLY)
bool checkFileExists(const QString &file)
const QString ENGAUGE_LOG_FILE(".engauge.log")
Class that stores QTranslator objects for the duration of application execution.
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)
const QString DASH_STYLE("-"+CMD_STYLE)
void sanityCheckLoadStartupFiles(bool isRepeatingFlag, const QString &dashForRepeatingFlag, const QString &errorReportFile, const QString &fileCmdScriptFile, const QStringList &loadStartupFiles)
const QString DASH_REGRESSION("-"+CMD_REGRESSION)
QString engaugeLogFilename()
bool offers(const QString &fileExtension) const
Return true if specified file extension is supported.
bool engaugeLogFilenameAttempt(const QString &path, QString &pathAndFile)