-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainWindow.cpp
102 lines (75 loc) · 2.09 KB
/
MainWindow.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
#include "MainWindow.hpp"
#include <string>
#include <cstdlib>
#include <fstream>
#include <QApplication>
#include <QFile>
#include <QSplitter>
#include "ColorMapEditor.hpp"
using namespace std;
int main( int argc, char* argv[] )
{
QApplication app( argc, argv );
if ( argc < 5 ) {
cerr << "usage: ctvr volume_file width height depth" << endl;
app.exit();
}
string filename = argv[1];
uint32_t ncols = atoi(argv[2]);
uint32_t nrows = atoi(argv[3]);
uint32_t nstacks = atoi(argv[4]);
uint32_t nvoxels = ncols*nrows*nstacks;
uint8_t *image = new uint8_t[nvoxels];
{
ifstream file( filename.c_str(), ios::in | ios::binary );
file.read( reinterpret_cast<char*>(image), nvoxels );
size_t nread = file.gcount();
if ( nread != nvoxels ) {
cerr << "file was shorter than expected" << endl;
app.exit();
}
}
cout << "building contour tree" << endl;
ContourTree *ct = new ContourTree(image,ncols,nrows,nstacks);
ct->build();
cout << "setting up volume renderer" << endl;
ContourTreeVolumeRenderer *ctvr =
new ContourTreeVolumeRenderer(*ct,image,ncols,nrows,nstacks);
QFile file(":/RayCaster.glsl");
file.open(QIODevice::ReadOnly | QIODevice::Text );
ctvr->fshader_src = string(file.readAll().data());
if ( argc > 5 ) {
ctvr->read_tracker_file(argv[5]);
ctvr->cluster_tf();
}
MainWindow *main_window = new MainWindow(ct,ctvr);
main_window->show();
main_window->resize(700,600);
app.exec();
}
MainWindow::MainWindow
(
ContourTree *ct_,
ContourTreeVolumeRenderer *ctvr_ ,
QWidget *parent
) :
QMainWindow(parent),
ct(ct_),
ctvr(ctvr_)
{
QSplitter *split = new QSplitter(this);
split->setOrientation(Qt::Vertical);
setCentralWidget(split);
vr = new VolumeRendererWidget(ctvr,split);
cme = new ColorMapEditor(split);
split->setStretchFactor(0,5);
split->setStretchFactor(1,3);
connect( cme, SIGNAL(edited(RGBA8*)), this, SLOT(tf_edited(RGBA8*)) );
}
void MainWindow::tf_edited( RGBA8 *colors )
{
vr->makeCurrent();
ctvr->set_global_tf( colors );
ctvr->update_global_tf_tex();
vr->update();
}