volmetrics
view src/view3d.cc @ 37:1d935677d3ab
Created new branch non-qt-version
author | Eleni Maria Stea <elene.mst@gmail.com> |
---|---|
date | Mon, 17 Apr 2017 13:26:24 +0000 |
parents | |
children |
line source
1 #include <algorithm>
2 #include "opengl.h"
3 #include "view3d.h"
4 #include "volume.h"
6 static int win_width, win_height;
8 View3D::View3D()
9 {
10 vol = 0;
11 thres_low = 0.0;
12 thres_high = 1.0;
13 }
15 View3D::~View3D()
16 {
17 destroy();
18 }
20 bool View3D::init(GLView *glview)
21 {
22 this->glview = glview;
23 return true;
24 }
26 void View3D::destroy()
27 {
28 }
30 void View3D::display()
31 {
32 glClearColor(0, 0, 0, 1);
33 glClear(GL_COLOR_BUFFER_BIT);
35 glBegin(GL_QUADS);
36 glColor3f(1, 0, 0);
37 glVertex2f(thres_low * 2.0 - 1.0, 1);
38 glVertex2f(thres_low * 2.0 - 1.0, -1);
39 glColor3f(0, 0, 1);
40 glVertex2f(thres_high * 2.0 - 1.0, -1);
41 glVertex2f(thres_high * 2.0 - 1.0, 1);
42 glEnd();
43 }
46 void View3D::reshape(int x, int y)
47 {
48 win_width = x;
49 win_height = y;
50 }
52 void View3D::set_volume(Volume *vol)
53 {
54 if(this->vol) {
55 delete this->vol;
56 }
57 this->vol = vol;
59 glview->update();
60 }
62 void View3D::set_thresholds(float low, float high)
63 {
64 thres_low = std::min(low, high);
65 thres_high = std::max(low, high);
67 glview->update();
68 }