1 #include "ColorFilterMode.h"
4 #include "MainWindow.h"
5 #include <QApplication>
10 const QString CMD_DEBUG (
"debug");
11 const QString CMD_ERROR (
"error");
12 const QString CMD_GNUPLOT (
"gnuplot");
13 const QString CMD_HELP (
"help");
14 const QString DASH (
"-");
15 const QString DASH_DEBUG (
"-" + CMD_DEBUG);
16 const QString DASH_ERROR (
"-" + CMD_ERROR);
17 const QString DASH_GNUPLOT (
"-" + CMD_GNUPLOT);
18 const QString DASH_HELP (
"-" + CMD_HELP);
21 bool checkFileExists (
const QString &file);
22 void parseCmdLine (
int argc,
25 QString &errorReportFile,
27 QStringList &loadStartupFiles);
30 bool checkFileExists (
const QString &file)
32 QFileInfo check (file);
33 return check.exists() && check.isFile();
36 int main(
int argc,
char *argv[])
38 qRegisterMetaType<ColorFilterMode> (
"ColorFilterMode");
40 QApplication a(argc, argv);
42 bool isDebug, isGnuplot;
43 QString errorReportFile;
44 QStringList loadStartupFiles;
52 initializeLogging (
"engauge",
55 LOG4CPP_INFO_S ((*mainCat)) <<
"main args=" << QApplication::arguments().join (
" ").toLatin1().data();
65 void parseCmdLine (
int argc,
68 QString &errorReportFile,
70 QStringList &loadStartupFiles)
72 const int COLUMN_WIDTH = 20;
73 bool showUsage =
false;
76 bool nextIsErrorReportFile =
false;
83 for (
int i = 1; i < argc; i++) {
85 if (nextIsErrorReportFile) {
86 errorReportFile = argv [i];
87 showUsage |= !checkFileExists (errorReportFile);
88 nextIsErrorReportFile =
false;
89 }
else if (strcmp (argv [i], DASH_DEBUG.toLatin1().data()) == 0) {
91 }
else if (strcmp (argv [i], DASH_ERROR.toLatin1().data()) == 0) {
92 nextIsErrorReportFile =
true;
93 }
else if (strcmp (argv [i], DASH_GNUPLOT.toLatin1().data()) == 0) {
95 }
else if (strcmp (argv [i], DASH_HELP.toLatin1().data()) == 0) {
97 }
else if (strncmp (argv [i], DASH.toLatin1().data(), 1) == 0) {
100 loadStartupFiles << argv [i];
104 if (showUsage || nextIsErrorReportFile) {
106 cerr <<
"Usage: engauge "
107 <<
"[" << DASH_DEBUG.toLatin1().data() <<
"] "
108 <<
"[" << DASH_ERROR.toLatin1().data() <<
" <file>] "
109 <<
"[" << DASH_GNUPLOT.toLatin1().data() <<
"] "
110 <<
"[" << DASH_HELP.toLatin1().data() <<
"] "
111 <<
"[<load_file1>] [<load_file2>] ..." << endl
112 <<
" " << DASH_DEBUG.leftJustified(COLUMN_WIDTH,
' ').toLatin1().data() <<
"Enables extra debug information" << endl
113 <<
" " << DASH_ERROR.leftJustified(COLUMN_WIDTH,
' ').toLatin1().data() <<
"Specifies an error report fie as input" << endl
114 <<
" " << DASH_GNUPLOT.leftJustified(COLUMN_WIDTH,
' ').toLatin1().data() <<
"Output diagnostic gnuplot input files for debugging" << endl
115 <<
" " << DASH_HELP.leftJustified(COLUMN_WIDTH,
' ').toLatin1().data() <<
"Show this help information" << endl
116 <<
" " << QString (
"<load file> ").leftJustified(COLUMN_WIDTH,
' ').toLatin1().data() <<
"File to be imported or opened at startup" << endl;
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...