-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
71 lines (63 loc) · 2.07 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
#include <QApplication>
#include <QFileDialog>
#include <QFile>
#include <QDir>
#include <QDebug>
#include "SimpleView.h"
void Usage(const char *n)
{
fprintf(stderr,"Usage: %s [-show_example] [-f deviceFile]\n",n);
}
int main( int argc, char** argv )
{
// QT Stuff
QApplication app( argc, argv );
// set required fields to use QSettings API (these specify the location of the settings)
app.setApplicationName("Sketchbio");
app.setOrganizationName("UNC Computer Science");
app.setOrganizationDomain("sketchbio.org");
// fix current directory for Visual Studio/XCode and other IDES that put executables in
// folders based on build type. This makes the default location of the device config files
// correct.
QString path = app.applicationDirPath();
if (path.endsWith("/Release") || path.endsWith("/Debug") || path.endsWith("RelWithDebInfo")) {
QDir::setCurrent(path.mid(0,path.lastIndexOf("/")));
}
// Parse the non-Qt part of the command line.
// Start with default values.
bool do_example = false;
const char *deviceFile = "devices/razer_hydra.xml";
QVector<QString> object_names;
int i = 0;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-show_example")) {
do_example = true;
} else if (!strcmp(argv[i], "-f")) {
if (i+1 < argc) {
deviceFile = argv[i+1];
} else {
fprintf(stderr, "No device filename specified with -f\n");
Usage(argv[0]);
exit(1);
}
} else if (argv[i][0] == '-' || !strcmp(argv[i], "-h")) {
Usage(argv[0]);
exit(0);
} else {
}
}
if (object_names.size() > 0) {
// If we give it model names, we don't want the fibrin default.
do_example = false;
}
QString projDir = QFileDialog::getExistingDirectory((QWidget *)NULL,
QString("Select Project Folder"),QString("./"));
int retVal = 0;
if (projDir.length() != 0) {
SimpleView mySimpleView(projDir,do_example,deviceFile);
mySimpleView.setWindowTitle("SketchBio");
mySimpleView.show();
retVal = app.exec();
}
return retVal;
}