Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
main.cpp
1 #include "ColorFilterMode.h"
2 #include <iostream>
3 #include "Logger.h"
4 #include "MainWindow.h"
5 #include <QApplication>
6 
7 using namespace std;
8 
9 const QString CMD_DEBUG ("debug");
10 const QString CMD_ERROR ("error");
11 const QString CMD_GNUPLOT ("gnuplot");
12 const QString CMD_HELP ("help");
13 const QString DASH_DEBUG ("-" + CMD_DEBUG);
14 const QString DASH_ERROR ("-" + CMD_ERROR);
15 const QString DASH_GNUPLOT ("-" + CMD_GNUPLOT);
16 const QString DASH_HELP ("-" + CMD_HELP);
17 
18 // Prototypes
19 void parseCmdLine (int argc, char **argv, bool &isDebug, QString &errorReportFile, bool &isGnuplot);
20 
21 // Functions
22 int main(int argc, char *argv[])
23 {
24  qRegisterMetaType<ColorFilterMode> ("ColorFilterMode");
25 
26  QApplication a(argc, argv);
27 
28  bool isDebug, isGnuplot;
29  QString errorReportFile;
30  parseCmdLine (argc,
31  argv,
32  isDebug,
33  errorReportFile,
34  isGnuplot);
35 
36  initializeLogging ("engauge",
37  "engauge.log",
38  isDebug);
39 
40  MainWindow w (errorReportFile,
41  isGnuplot);
42  w.show();
43 
44  return a.exec();
45 }
46 
47 void parseCmdLine (int argc,
48  char **argv,
49  bool &isDebug,
50  QString &errorReportFile,
51  bool &isGnuplot)
52 {
53  const int COLUMN_WIDTH = 20;
54  bool showUsage = false;
55 
56  // State
57  bool nextIsErrorReportFile = false;
58 
59  // Defaults
60  isDebug = false;
61  errorReportFile = "";
62  isGnuplot = false;
63 
64  for (int i = 1; i < argc; i++) {
65 
66  if (nextIsErrorReportFile) {
67  errorReportFile = argv [i];
68  nextIsErrorReportFile = false;
69  } else if (strcmp (argv [i], DASH_DEBUG.toLatin1().data()) == 0) {
70  isDebug = true;
71  } else if (strcmp (argv [i], DASH_ERROR.toLatin1().data()) == 0) {
72  nextIsErrorReportFile = true;
73  } else if (strcmp (argv [i], DASH_GNUPLOT.toLatin1().data()) == 0) {
74  isGnuplot = true;
75  } else {
76  showUsage = true;
77  }
78  }
79 
80  if (showUsage || nextIsErrorReportFile) {
81 
82  cerr << "Usage: engauge "
83  << "[" << DASH_DEBUG.toLatin1().data() << "] "
84  << "[" << DASH_ERROR.toLatin1().data() << " <file>] "
85  << "[" << DASH_GNUPLOT.toLatin1().data() << "]" << endl
86  << " " << DASH_DEBUG.leftJustified(COLUMN_WIDTH, ' ').toLatin1().data() << "Enables extra debug information" << endl
87  << " " << DASH_ERROR.leftJustified(COLUMN_WIDTH, ' ').toLatin1().data() << "Specifies an error report fie as input" << endl
88  << " " << DASH_GNUPLOT.leftJustified(COLUMN_WIDTH, ' ').toLatin1().data() << "Output diagnostic gnuplot input files for debugging" << endl;
89 
90  exit (0);
91  }
92 }
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:60