forked from toolchainX/Volume_Rendering_Using_GLSL
/
window.cpp
168 lines (131 loc) · 6.21 KB
/
window.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include "window.h"
#include "ui_window.h"
#include "myglwidget.h"
#include <fstream>
using namespace std;
Window::Window(QWidget *parent) :
QWidget(parent),
ui(new Ui::Window)
{
ui->setupUi(this);
connect(ui->topSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(cutBBTop(int)));
connect(ui->bottomSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(cutBBBottom(int)));
connect(ui->leftSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(cutBBLeft(int)));
connect(ui->rightSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(cutBBRight(int)));
connect(ui->frontSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(cutBBFront(int)));
connect(ui->backSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(cutBBBack(int)));
connect(ui->azimuthSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(azimuthUniform(int)));
connect(ui->elevationSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(elevationUniform(int)));
connect(ui->clipPlaneDepthSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(clipPlaneDepthUniform(int)));
connect(ui->clipCheckBox, SIGNAL(toggled(bool)), ui->myGLWidget, SLOT(clipEnableUniform(bool)));
// Intensity Control
connect(ui->intensityMaxSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(intensityMaxSliderUniform(int)));
connect(ui->intensityMinSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(intensityMinSliderUniform(int)));
// TFF
connect(ui->redWidthSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(redWidthUniform(int)));
connect(ui->redCenterSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(redCenterUniform(int)));
connect(ui->greenWidthSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(greenWidthUniform(int)));
connect(ui->greenCenterSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(greenCenterUniform(int)));
connect(ui->blueWidthSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(blueWidthUniform(int)));
connect(ui->blueCenterSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(blueCenterUniform(int)));
connect(ui->alphaWidthSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(alphaWidthUniform(int)));
connect(ui->alphaCenterSlider, SIGNAL(valueChanged(int)), ui->myGLWidget, SLOT(alphaCenterUniform(int)));
// ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
// QCP::iSelectLegend | QCP::iSelectPlottables);
// ui->histogramPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
// QCP::iSelectLegend | QCP::iSelectPlottables);
ui->histogramPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes |
QCP::iSelectPlottables);
// connect(ui->myGLWidget, SIGNAL(keyValue(QVector<double>)), this, SLOT(takeKeyValue(QVector<double>)));
// plot();
}
QVector<double> key;
QVector<double> nonEq;
QVector<double> eqHistValue;
QVector<double> luTableValue;
QString file1Name;
void Window::on_loadPushButton_clicked()
{
QString widthLineEdit;
QString heightLineEdit;
QString depthLineEdit;
bool ok;
widthLineEdit = ui->widthLineEdit->text();
heightLineEdit = ui->heightLineEdit->text();
depthLineEdit = ui->depthLineEdit->text();
ui->myGLWidget->initVol3DTex(file1Name.toStdString().c_str(),
widthLineEdit.toInt(&ok, 10),
heightLineEdit.toInt(&ok, 10),
depthLineEdit.toInt(&ok, 10));
}
void Window::on_loadRAWButton_clicked()
{
file1Name = QFileDialog::getOpenFileName(this, tr("Open RAW Data"), ".", tr("RAW File (*.raw)"));
//ui->File1Path->setText(file1Name);
// QFile myFile(file1Name);
// int fileSize = 0;
// fileSize = (myFile.size() / 16.0) * 8.0; //when file does open.
// myFile.close();
// qDebug() << "Size is: " << fileSize;
// ui->myGLWidget->initVol3DTex(file1Name.toStdString().c_str(), fileSize);
}
void Window::on_histPushButton_clicked()
{
eqHistogram();
nonEqHistogram();
plotHistogram(key, nonEq, eqHistValue, luTableValue);
}
void Window::eqHistogram()
{
luTableValue = ui->myGLWidget->lutEqualizedValue();
eqHistValue = ui->myGLWidget->equalizedValue();
}
void Window::nonEqHistogram()
{
key = ui->myGLWidget->keyValue();
nonEq = ui->myGLWidget->nonEqualizedValue();
}
void Window::plotHistogram(QVector<double> key, QVector<double> nonEq, QVector<double> eqValue, QVector<double> lutValue)
{
QCustomPlot *histogramPlot = ui->histogramPlot;
histogramPlot->clearGraphs();
// Non Equalized
QCPBars *nonEqHistBars = new QCPBars(histogramPlot->xAxis, histogramPlot->yAxis);
histogramPlot->addPlottable(nonEqHistBars);
nonEqHistBars->setWidth(1);
nonEqHistBars->setData(key, nonEq);
nonEqHistBars->setPen(Qt::NoPen);
nonEqHistBars->setBrush(QColor(10, 140, 70, 160));
// // Equalized
// QCPBars *eqHistBars = new QCPBars(histogramPlot->xAxis, histogramPlot->yAxis);
// histogramPlot->addPlottable(eqHistBars);
// eqHistBars->setWidth(1);
// eqHistBars->setData(key, eqValue);
// eqHistBars->setPen(Qt::NoPen);
// eqHistBars->setBrush(QColor(10, 100, 50, 70));
//// eqHistBars->moveAbove(eqHistBars);
// // LUT
// QCPGraph *lut = histogramPlot->addGraph();
// lut->setData(key, lutValue);
// lut->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone, QPen(Qt::black, 1.5), QBrush(Qt::white), 9));
// lut->setLineStyle(QCPGraph::lsStepCenter);
// lut->setPen(QPen(QColor(120, 120, 120), 2));
histogramPlot->replot();
histogramPlot->rescaleAxes();
}
void Window::keyPressEvent(QKeyEvent * e)
{
switch (e->key())
{
case Qt::Key_Escape: close(); break;
case Qt::Key_1: ui->myGLWidget->keyPressed(1); break;
case Qt::Key_2: ui->myGLWidget->keyPressed(2); break;
case Qt::Key_3: ui->myGLWidget->keyPressed(3); break;
case Qt::Key_4: ui->myGLWidget->keyPressed(4); break;
case Qt::Key_5: ui->myGLWidget->keyPressed(5); break;
}
}
Window::~Window()
{
delete ui;
}