volmetrics
diff src/view3d.cc @ 36:1df14c5ffa71
conversion to Qt
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 06 Feb 2015 22:39:51 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/view3d.cc Fri Feb 06 22:39:51 2015 +0200 1.3 @@ -0,0 +1,68 @@ 1.4 +#include <algorithm> 1.5 +#include "opengl.h" 1.6 +#include "view3d.h" 1.7 +#include "volume.h" 1.8 + 1.9 +static int win_width, win_height; 1.10 + 1.11 +View3D::View3D() 1.12 +{ 1.13 + vol = 0; 1.14 + thres_low = 0.0; 1.15 + thres_high = 1.0; 1.16 +} 1.17 + 1.18 +View3D::~View3D() 1.19 +{ 1.20 + destroy(); 1.21 +} 1.22 + 1.23 +bool View3D::init(GLView *glview) 1.24 +{ 1.25 + this->glview = glview; 1.26 + return true; 1.27 +} 1.28 + 1.29 +void View3D::destroy() 1.30 +{ 1.31 +} 1.32 + 1.33 +void View3D::display() 1.34 +{ 1.35 + glClearColor(0, 0, 0, 1); 1.36 + glClear(GL_COLOR_BUFFER_BIT); 1.37 + 1.38 + glBegin(GL_QUADS); 1.39 + glColor3f(1, 0, 0); 1.40 + glVertex2f(thres_low * 2.0 - 1.0, 1); 1.41 + glVertex2f(thres_low * 2.0 - 1.0, -1); 1.42 + glColor3f(0, 0, 1); 1.43 + glVertex2f(thres_high * 2.0 - 1.0, -1); 1.44 + glVertex2f(thres_high * 2.0 - 1.0, 1); 1.45 + glEnd(); 1.46 +} 1.47 + 1.48 + 1.49 +void View3D::reshape(int x, int y) 1.50 +{ 1.51 + win_width = x; 1.52 + win_height = y; 1.53 +} 1.54 + 1.55 +void View3D::set_volume(Volume *vol) 1.56 +{ 1.57 + if(this->vol) { 1.58 + delete this->vol; 1.59 + } 1.60 + this->vol = vol; 1.61 + 1.62 + glview->update(); 1.63 +} 1.64 + 1.65 +void View3D::set_thresholds(float low, float high) 1.66 +{ 1.67 + thres_low = std::min(low, high); 1.68 + thres_high = std::max(low, high); 1.69 + 1.70 + glview->update(); 1.71 +}