-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
134 lines (114 loc) · 5.23 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "QDebug"
#include "glwidget.h"
#include "glypheditor.h"
#include "displayparameters.h"
#include "glglyphview.h"
#include "qmath.h"
#include "boost/program_options.hpp"
#include "iostream"
#include "fstream"
#include "qfiledialog.h"
namespace po = boost::program_options;
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
string surfsetl;
string surfsetr;
string scons;
string config;
string overlayl;
string overlayr;
string view;
string screenshotname;
// Declare the supported options.
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("surfsetl", po::value<string>(&surfsetl), "Set of surfaces for the left hemisphere")
("surfsetr", po::value<string>(&surfsetr), "Set of surfaces for the right hemisphere")
("overlayl", po::value<string>(&overlayl), "Set of surfaces for the left hemisphere")
("overlayr", po::value<string>(&overlayr), "Set of surfaces for the right hemisphere")
("scons", po::value<string>(&scons), "Connectivity (.bin) or indexed connections (.txt)")
("config", po::value<string>(&config), "Config file containing these here options")
("view", po::value<string>(&view), "Load file with view matrix")
("leftalpha", po::value<float>(), "alpha value for left hemisphere")
("rightalpha", po::value<float>(), "alpha value for right hemisphere")
("glyphs", po::value<float>(), "alpha value for glyphs")
("threshold", po::value<float>(), "threshold for edges to be displayed")
("clipthreshold", po::value<float>(), "threshold determining how many connections are included from a full (.bin) connectivity matrix")
("radius", po::value<float>(), "glyph radius")
("normalization", po::value<float>(), "normalization between 0 (no normalization) and 1 (completely normalized)")
("primsize", po::value<float>(), "size of display primitives (pointsize or linewidth, in pixels)")
("display", po::value<int>(), "number of surface in surface set that is displayed")
("color", po::value<int>(), "number of surface in surface set that determines the coloration of the glyphs")
("geometry", po::value<int>(), "number of surface in surface set that determines the geometric distribution of the glyph primitives")
("glyphstyle", po::value<int>(), "0 = geometry, 1 = projection, 2 = pie charts")
("primitives", po::value<int>(), "0 = points, 1 = vectors")
("minlength", po::value<float>(), "length threshold for removal of short edges")
("sresolution", po::value<float>(), "resolution multiplication factor for screenshots")
("minlsource", po::value<int>(), "number of surface in surface set used for the calculation of length for short edge removal")
("screenshot", po::value<string>(&screenshotname), "make screenshot and exit")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
//TODO: Any way around using std::cout?
std::cout << desc;
return 1;
}
//QString qconfig(config.c_str());
//string stdstr = qconfig.toStdString();
ifstream ifs(config.c_str());
if (!ifs) {
cout << "can not open config file: " << config << "\n";
} else {
store(parse_config_file(ifs, desc), vm);
notify(vm);
}
MainWindow w(NULL);
w.setWindowTitle("Glyph Viewer");
GLWidget* glw = w.centralWidget()->findChild<GLWidget*>("widget");
QString qsurfsetl(surfsetl.c_str());
QString qsurfsetr(surfsetr.c_str());
QString qscons(scons.c_str());
QString qoverlayl(overlayl.c_str());
QString qoverlayr(overlayr.c_str());
QString qview(view.c_str());
QString qscreenshotname(screenshotname.c_str());
qDebug() << "loading data: " << qsurfsetl << qsurfsetr << qscons << qoverlayl << qoverlayr;
float clipthr = 0.7;
if (vm.count("clipthreshold")) clipthr = vm["clipthreshold"].as<float>();
glw->loadData(qsurfsetl,qsurfsetr,qscons, qoverlayl, qoverlayr, clipthr);
qDebug() << "data loaded...";
DisplayParameters* dp = new DisplayParameters(NULL, Qt::Window);
dp->setWindowTitle("Display Options");
dp->setVM(vm, desc);
glw->setDisplayParameters(dp);
GlyphEditor* ge = new GlyphEditor(NULL,Qt::Window);
ge->setWindowTitle("Glyph Options");
ge->setData(glw->data,dp);
ge->initParams();
ge->setVM(vm, desc);
QObject::connect(ge,SIGNAL(changed()),glw,SLOT(updateParameters()));
QObject::connect(glw,SIGNAL(selected()),ge->findChild<GLGlyphView*>("widget"),SLOT(updateGL()));
ge->show();
dp->show();
w.show();
if (qview!="") {
qDebug() << "loading view: " << qview;
glw->loadView(qview);
}
if (vm.count("screenshot")){
if (vm.count("sresolution")){
glw->screenshot(qscreenshotname,vm["sresolution"].as<float>());
} else {
glw->screenshot(qscreenshotname);
}
return 0;
}
return a.exec();
}