-
Notifications
You must be signed in to change notification settings - Fork 0
/
histogram.cpp
73 lines (57 loc) · 1.98 KB
/
histogram.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
#include "histogram.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "inputdimension.h"
#include "inputbgcolour.h"
extern int colourmap;
extern CAMERA camera;
extern MainWindow *w;
extern VOLUME grid;
Histogram::Histogram(QWidget *parent) :
QGLWidget(parent)
{
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(0);
}
void Histogram::initializeGL() {
glEnable(GL_DEPTH_TEST);
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POINT_SMOOTH);
glDisable(GL_POLYGON_SMOOTH);
glDisable(GL_DITHER);
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glLineWidth(1.0);
glPointSize(1.0);
glClearColor(0.0,0.0,0.0,0.0);
glViewport(0, 0, 430, 400);
glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
}
void Histogram::paintGL() {
glDisable(GL_DEPTH_TEST);
DrawHistogram(colourmap);
glEnable(GL_DEPTH_TEST);
w->ui->HorizontalSlider->setMaximum(grid.themax);
w->ui->HorizontalSlider->setMinimum(grid.themin);
w->ui->HorizontalSlider->setValue(grid.isolevel);
QString label;
w->ui->isoLabel->setStyleSheet("QLabel { background-color : black; color : white; }");
w->ui->isoLabel->setText(label.setNum(grid.isolevel));
w->ui->minLabel->setStyleSheet("QLabel { background-color : black; color : yellow; }");
w->ui->minLabel->setText("Min: " + label.setNum(grid.themin));
w->ui->maxLabel->setStyleSheet("QLabel { background-color : black; color : red; }");
w->ui->maxLabel->setText("Max: " + label.setNum(grid.themax));
}
/*
Handle mouse events
Right button events are passed to menu handlers
*/
void Histogram::mousePressEvent(QMouseEvent *event) {
HistogramClick(event->pos().x()+15,event->pos().y());
}