-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
executable file
·110 lines (101 loc) · 3.4 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/** @file
@brief Header
@date 2015
@author
Russell Taylor
<russ@reliasolve.com>
<http://sensics.com>
*/
// Copyright 2015 Sensics, Inc.
//
// (Licensed under the Apache License, Version 2.0)
#include <QApplication>
#include "mainwindow.h"
#include <iostream>
static void usage(std::string name)
{
std::cerr << "Usage: " << name << " [-fullscreen]"
<< " [-button vrpnDeviceName whichButton]"
<< " [-analog vrpnDeviceName whichAnalog threshold]"
<< " [-tracker vrpnDeviceName whichSensor translationThreshold rotationThreshold]"
<< " [-trackerRotate vrpnDeviceName whichSensor whichAxis[0,1,2]]"
<< " [-numquads num]"
<< std::endl;
exit(-1);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// Parse the command-line arguments
int real_params = 0;
bool doFullscreen = false;
std::string buttonName, analogName, trackerName;
int whichButton, whichAnalog, whichSensor;
double analogThreshold, transThreshold, rotThreshold;
bool doTrackerRotation = false;
int rotateAxis = -1;
int numQuads = -1; //-1 is invalid, so uses the default
for (int i = 1; i < argc; i++) {
if (std::string("-fullscreen") == argv[i]) {
doFullscreen = true;
}
else if (std::string("-button") == argv[i]) {
if (++i >= argc) { usage(argv[0]); }
buttonName = argv[i];
if (++i >= argc) { usage(argv[0]); }
whichButton = atoi(argv[i]);
}
else if (std::string("-analog") == argv[i]) {
if (++i >= argc) { usage(argv[0]); }
analogName = argv[i];
if (++i >= argc) { usage(argv[0]); }
whichAnalog = atoi(argv[i]);
if (++i >= argc) { usage(argv[0]); }
analogThreshold = atof(argv[i]);
}
else if (std::string("-tracker") == argv[i]) {
if (++i >= argc) { usage(argv[0]); }
trackerName = argv[i];
if (++i >= argc) { usage(argv[0]); }
whichSensor = atoi(argv[i]);
if (++i >= argc) { usage(argv[0]); }
transThreshold = atof(argv[i]);
if (++i >= argc) { usage(argv[0]); }
rotThreshold = atof(argv[i]);
}
else if (std::string("-trackerRotate") == argv[i]) {
if (++i >= argc) { usage(argv[0]); }
trackerName = argv[i];
if (++i >= argc) { usage(argv[0]); }
whichSensor = atoi(argv[i]);
if (++i >= argc) { usage(argv[0]); }
doTrackerRotation = true;
rotateAxis = atoi(argv[i]);
}
else if (std::string("-numquads") == argv[i]) {
if (++i >= argc) { usage(argv[0]); }
numQuads = atoi(argv[i]);
}
else if (argv[i][0] == '-') {
usage(argv[0]);
}
else switch (++real_params) {
case 1:
case 2:
default:
usage(argv[0]);
}
}
if (real_params != 0) {
usage(argv[0]);
}
MainWindow w(
doFullscreen
, numQuads
, buttonName.c_str(), whichButton
, analogName.c_str(), whichAnalog, analogThreshold
, trackerName.c_str(), whichSensor, transThreshold, rotThreshold
, doTrackerRotation, rotateAxis);
w.show();
return a.exec();
}