tychoBCG3D  0.2
 All Data Structures Namespaces Files Functions Variables
Public Member Functions | Data Fields
GLWidget Class Reference

#include <glwidget.h>

Public Member Functions

 GLWidget (QWidget *parent, const char *name)
virtual void draw ()
 GLWidget::draw.
virtual void draw_border (float x_min, float x_max, float y_min, float y_max, float z_min, float z_max)
 GLWidget::draw_border.
virtual void init ()
 GLWidget::init.

Data Fields

float redAmbient
float greenAmbient
float blueAmbient
float redModel
float greenModel
float blueModel
int shininess
float x_min
float x_max
float y_min
float y_max
float z_min
float z_max
int drawer
QColor backroundColor
QVector< float > coordiantes [6]
QVector< float > stl_data [3]
QVector< float > sampled_data [3]
int point_size

Detailed Description

Definition at line 7 of file glwidget.h.


Constructor & Destructor Documentation

GLWidget::GLWidget ( QWidget *  parent,
const char *  name 
)

Definition at line 29 of file glwidget.cpp.

: QGLViewer(parent, name)
#else
GLWidget::GLWidget(QWidget *parent)
: QGLViewer(parent)
#endif
{
}

Member Function Documentation

void GLWidget::draw ( )
virtual

GLWidget::draw.

Draws the points, triangles and the smapled data

Definition at line 66 of file glwidget.cpp.

References blueAmbient, blueModel, coordiantes, draw_border(), drawer, greenAmbient, greenModel, point_size, redAmbient, redModel, sampled_data, shininess, stl_data, x_max, x_min, y_max, y_min, z_max, and z_min.

{
//to draw point data
if ((coordiantes[0].size() > 0)&&(drawer == 1)){
glPointSize((float)point_size);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER, 0.5);
glEnable(GL_DEPTH_TEST);
GLfloat white[] = {redAmbient, greenAmbient, blueAmbient, 1.0f};
glMaterialfv(GL_FRONT, GL_SPECULAR, white);
GLfloat shininess1[] = {shininess};
glMaterialfv(GL_FRONT, GL_SHININESS, shininess1);
glBegin(GL_POINTS);
for (int i = 0; i < coordiantes[0].size(); i++){
glNormal3f((GLfloat)coordiantes[3][i], (GLfloat)coordiantes[4][i],(GLfloat)coordiantes[5][i]);
glVertex3f((GLfloat)coordiantes[0][i], (GLfloat)coordiantes[1][i],(GLfloat)coordiantes[2][i]);
}
glEnd();
if (coordiantes[0].size() != 0) draw_border(x_min, x_max, y_min, y_max, z_min, z_max);
glDisable(GL_DEPTH_TEST);
}
//to draw stl data
if ((stl_data[0].size() > 0)&&(drawer == 1)){
glEnable(GL_DEPTH_TEST);
glPolygonMode(GL_FRONT_AND_BACK, GL_TRIANGLES );
GLfloat white[] = {redAmbient, greenAmbient, blueAmbient, 1.0f};
glMaterialfv(GL_FRONT, GL_SPECULAR, white);
GLfloat shininess1[] = {shininess};
glMaterialfv(GL_FRONT, GL_SHININESS, shininess1);
for (int i = 0; i < stl_data[0].size()-4; i = i+4){
glBegin(GL_TRIANGLES);
glNormal3f((GLfloat)stl_data[0][i], (GLfloat)stl_data[1][i], (GLfloat)stl_data[2][i]);
glVertex3f((GLfloat)stl_data[0][i+1], (GLfloat)stl_data[1][i+1], (GLfloat)stl_data[2][i+1]);
glVertex3f((GLfloat)stl_data[0][i+2], (GLfloat)stl_data[1][i+2], (GLfloat)stl_data[2][i+2]);
glVertex3f((GLfloat)stl_data[0][i+3], (GLfloat)stl_data[1][i+3], (GLfloat)stl_data[2][i+3]);
glEnd();
}
if (stl_data[0].size() != 0) draw_border(x_min, x_max, y_min, y_max, z_min, z_max);
glDisable(GL_DEPTH_TEST);
}
//to draw the sampled data
if ((sampled_data[0].size() > 0)&&(drawer == 2)){
glPointSize((float)point_size);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glAlphaFunc(GL_GREATER, 0.5);
glEnable(GL_DEPTH_TEST);
GLfloat white[] = {redAmbient, greenAmbient, blueAmbient, 1.0f};
glMaterialfv(GL_FRONT, GL_SPECULAR, white);
GLfloat shininess1[] = {shininess};
glMaterialfv(GL_FRONT, GL_SHININESS, shininess1);
glBegin(GL_POINTS);
for (int i = 0; i < sampled_data[0].size(); i++){
glVertex3f((GLfloat)sampled_data[0][i], (GLfloat)sampled_data[1][i],(GLfloat)sampled_data[2][i]);
}
glEnd();
glDisable(GL_DEPTH_TEST);
}
}
void GLWidget::draw_border ( float  x_min,
float  x_max,
float  y_min,
float  y_max,
float  z_min,
float  z_max 
)
virtual

GLWidget::draw_border.

Draws the bounding box, which represents the computational domain

Parameters:
x_min
x_max
y_min
y_max
z_min
z_max

Definition at line 169 of file glwidget.cpp.

References blueModel, greenModel, and redModel.

Referenced by draw().

{
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glLineWidth(1.0f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE );
glEnable(GL_DEPTH_TEST);
glBegin(GL_QUADS);
glVertex3f(x_max, y_max, z_max);
glVertex3f(x_min, y_max, z_max);
glVertex3f(x_min, y_min, z_max);
glVertex3f(x_max, y_min, z_max);
glVertex3f(x_max, y_max, z_min);
glVertex3f(x_min, y_max, z_min);
glVertex3f(x_min, y_min, z_min);
glVertex3f(x_max, y_min, z_min);
glVertex3f(x_max, y_max, z_max);
glVertex3f(x_max, y_min, z_max);
glVertex3f(x_max, y_min, z_min);
glVertex3f(x_max, y_max, z_min);
glVertex3f(x_min, y_max, z_max);
glVertex3f(x_min, y_min, z_max);
glVertex3f(x_min, y_min, z_min);
glVertex3f(x_min, y_max, z_min);
glVertex3f(x_max, y_max, z_max);
glVertex3f(x_min, y_max, z_max);
glVertex3f(x_min, y_max, z_min);
glVertex3f(x_max, y_max, z_min);
glVertex3f(x_max, y_min, z_max);
glVertex3f(x_min, y_min, z_max);
glVertex3f(x_min, y_min, z_min);
glVertex3f(x_max, y_min, z_min);
glEnd();
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glDisable(GL_LINE_SMOOTH);
glDisable(GL_DEPTH_TEST);
}
void GLWidget::init ( )
virtual

GLWidget::init.

Sets basic stuff for the GL viewer

Definition at line 44 of file glwidget.cpp.

References backroundColor, blueAmbient, greenAmbient, and redAmbient.

{
setSceneRadius(10.0);
setFPSIsDisplayed(true);
setBackgroundColor(backroundColor);
//Add ambient light
GLfloat ambientColor[] = {redAmbient, greenAmbient, blueAmbient}; //Color (0.2, 0.2, 0.2)
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);
// Light setup
glEnable(GL_LIGHTING); //Enable lighting
glEnable(GL_NORMALIZE); //Have OpenGL automatically normalize our normals
glShadeModel(GL_SMOOTH); //Enable smooth shading
}

Field Documentation

QColor GLWidget::backroundColor

Definition at line 30 of file glwidget.h.

Referenced by init().

float GLWidget::blueAmbient

Definition at line 18 of file glwidget.h.

Referenced by draw(), and init().

float GLWidget::blueModel

Definition at line 22 of file glwidget.h.

Referenced by draw(), and draw_border().

QVector<float> GLWidget::coordiantes[6]

Definition at line 33 of file glwidget.h.

Referenced by draw().

int GLWidget::drawer

Definition at line 28 of file glwidget.h.

Referenced by draw().

float GLWidget::greenAmbient

Definition at line 17 of file glwidget.h.

Referenced by draw(), and init().

float GLWidget::greenModel

Definition at line 21 of file glwidget.h.

Referenced by draw(), and draw_border().

int GLWidget::point_size

Definition at line 39 of file glwidget.h.

Referenced by draw().

float GLWidget::redAmbient

Definition at line 16 of file glwidget.h.

Referenced by draw(), and init().

float GLWidget::redModel

Definition at line 20 of file glwidget.h.

Referenced by draw(), and draw_border().

QVector<float> GLWidget::sampled_data[3]

Definition at line 37 of file glwidget.h.

Referenced by draw().

int GLWidget::shininess

Definition at line 24 of file glwidget.h.

Referenced by draw().

QVector<float> GLWidget::stl_data[3]

Definition at line 35 of file glwidget.h.

Referenced by draw().

float GLWidget::x_max

Definition at line 26 of file glwidget.h.

Referenced by draw().

float GLWidget::x_min

Definition at line 26 of file glwidget.h.

Referenced by draw().

float GLWidget::y_max

Definition at line 26 of file glwidget.h.

Referenced by draw().

float GLWidget::y_min

Definition at line 26 of file glwidget.h.

Referenced by draw().

float GLWidget::z_max

Definition at line 26 of file glwidget.h.

Referenced by draw().

float GLWidget::z_min

Definition at line 26 of file glwidget.h.

Referenced by draw().


The documentation for this class was generated from the following files: