volmetrics
annotate 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 |
rev | line source |
---|---|
nuclear@36 | 1 #include <algorithm> |
nuclear@36 | 2 #include "opengl.h" |
nuclear@36 | 3 #include "view3d.h" |
nuclear@36 | 4 #include "volume.h" |
nuclear@36 | 5 |
nuclear@36 | 6 static int win_width, win_height; |
nuclear@36 | 7 |
nuclear@36 | 8 View3D::View3D() |
nuclear@36 | 9 { |
nuclear@36 | 10 vol = 0; |
nuclear@36 | 11 thres_low = 0.0; |
nuclear@36 | 12 thres_high = 1.0; |
nuclear@36 | 13 } |
nuclear@36 | 14 |
nuclear@36 | 15 View3D::~View3D() |
nuclear@36 | 16 { |
nuclear@36 | 17 destroy(); |
nuclear@36 | 18 } |
nuclear@36 | 19 |
nuclear@36 | 20 bool View3D::init(GLView *glview) |
nuclear@36 | 21 { |
nuclear@36 | 22 this->glview = glview; |
nuclear@36 | 23 return true; |
nuclear@36 | 24 } |
nuclear@36 | 25 |
nuclear@36 | 26 void View3D::destroy() |
nuclear@36 | 27 { |
nuclear@36 | 28 } |
nuclear@36 | 29 |
nuclear@36 | 30 void View3D::display() |
nuclear@36 | 31 { |
nuclear@36 | 32 glClearColor(0, 0, 0, 1); |
nuclear@36 | 33 glClear(GL_COLOR_BUFFER_BIT); |
nuclear@36 | 34 |
nuclear@36 | 35 glBegin(GL_QUADS); |
nuclear@36 | 36 glColor3f(1, 0, 0); |
nuclear@36 | 37 glVertex2f(thres_low * 2.0 - 1.0, 1); |
nuclear@36 | 38 glVertex2f(thres_low * 2.0 - 1.0, -1); |
nuclear@36 | 39 glColor3f(0, 0, 1); |
nuclear@36 | 40 glVertex2f(thres_high * 2.0 - 1.0, -1); |
nuclear@36 | 41 glVertex2f(thres_high * 2.0 - 1.0, 1); |
nuclear@36 | 42 glEnd(); |
nuclear@36 | 43 } |
nuclear@36 | 44 |
nuclear@36 | 45 |
nuclear@36 | 46 void View3D::reshape(int x, int y) |
nuclear@36 | 47 { |
nuclear@36 | 48 win_width = x; |
nuclear@36 | 49 win_height = y; |
nuclear@36 | 50 } |
nuclear@36 | 51 |
nuclear@36 | 52 void View3D::set_volume(Volume *vol) |
nuclear@36 | 53 { |
nuclear@36 | 54 if(this->vol) { |
nuclear@36 | 55 delete this->vol; |
nuclear@36 | 56 } |
nuclear@36 | 57 this->vol = vol; |
nuclear@36 | 58 |
nuclear@36 | 59 glview->update(); |
nuclear@36 | 60 } |
nuclear@36 | 61 |
nuclear@36 | 62 void View3D::set_thresholds(float low, float high) |
nuclear@36 | 63 { |
nuclear@36 | 64 thres_low = std::min(low, high); |
nuclear@36 | 65 thres_high = std::max(low, high); |
nuclear@36 | 66 |
nuclear@36 | 67 glview->update(); |
nuclear@36 | 68 } |