nuclear@36: #include nuclear@36: #include "opengl.h" nuclear@36: #include "view3d.h" nuclear@36: #include "volume.h" nuclear@36: nuclear@36: static int win_width, win_height; nuclear@36: nuclear@36: View3D::View3D() nuclear@36: { nuclear@36: vol = 0; nuclear@36: thres_low = 0.0; nuclear@36: thres_high = 1.0; nuclear@36: } nuclear@36: nuclear@36: View3D::~View3D() nuclear@36: { nuclear@36: destroy(); nuclear@36: } nuclear@36: nuclear@36: bool View3D::init(GLView *glview) nuclear@36: { nuclear@36: this->glview = glview; nuclear@36: return true; nuclear@36: } nuclear@36: nuclear@36: void View3D::destroy() nuclear@36: { nuclear@36: } nuclear@36: nuclear@36: void View3D::display() nuclear@36: { nuclear@36: glClearColor(0, 0, 0, 1); nuclear@36: glClear(GL_COLOR_BUFFER_BIT); nuclear@36: nuclear@36: glBegin(GL_QUADS); nuclear@36: glColor3f(1, 0, 0); nuclear@36: glVertex2f(thres_low * 2.0 - 1.0, 1); nuclear@36: glVertex2f(thres_low * 2.0 - 1.0, -1); nuclear@36: glColor3f(0, 0, 1); nuclear@36: glVertex2f(thres_high * 2.0 - 1.0, -1); nuclear@36: glVertex2f(thres_high * 2.0 - 1.0, 1); nuclear@36: glEnd(); nuclear@36: } nuclear@36: nuclear@36: nuclear@36: void View3D::reshape(int x, int y) nuclear@36: { nuclear@36: win_width = x; nuclear@36: win_height = y; nuclear@36: } nuclear@36: nuclear@36: void View3D::set_volume(Volume *vol) nuclear@36: { nuclear@36: if(this->vol) { nuclear@36: delete this->vol; nuclear@36: } nuclear@36: this->vol = vol; nuclear@36: nuclear@36: glview->update(); nuclear@36: } nuclear@36: nuclear@36: void View3D::set_thresholds(float low, float high) nuclear@36: { nuclear@36: thres_low = std::min(low, high); nuclear@36: thres_high = std::max(low, high); nuclear@36: nuclear@36: glview->update(); nuclear@36: }