Main Page   Namespace List   Alphabetical List   Compound List   File List   Compound Members   File Members  

Nviz3DCanvas Class Reference

#include <nviz3d.h>

List of all members.

Public Methods

 Nviz3DCanvas (wxWindow *parent, const wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name="TestGLCanvas")
 ~Nviz3DCanvas (void)
void OnPaint (wxPaintEvent &event)
void OnSize (wxSizeEvent &event)
void OnEraseBackground (wxEraseEvent &event)
void OnEnterWindow (wxMouseEvent &event)
void OnMouse (wxMouseEvent &event)
void DrawNeuron (GLfloat x, GLfloat y, GLfloat z,)
void Render (void)
void InitGL (void)

Private Attributes

bool m_init

Friends

class NVizFrame


Constructor & Destructor Documentation

Nviz3DCanvas::Nviz3DCanvas wxWindow *    parent,
const wxWindowID    id = -1,
const wxPoint &    pos = wxDefaultPosition,
const wxSize &    size = wxDefaultSize,
long    style = 0,
const wxString &    name = "TestGLCanvas"
 

Definition at line 55 of file nviz3d.cpp.

References m_init.

00057                                                             :
00058              wxGLCanvas(parent, (wxGLCanvas*) NULL, id, pos, size, style, name )
00059 {
00060     m_init = FALSE;
00061 }

Nviz3DCanvas::~Nviz3DCanvas void   
 

Definition at line 64 of file nviz3d.cpp.

00065 {
00066     // Nothing Here
00067 }


Member Function Documentation

void Nviz3DCanvas::DrawNeuron GLfloat    x,
GLfloat    y,
GLfloat    z
 

Definition at line 180 of file nviz3d.cpp.

00181 {
00182 }

void Nviz3DCanvas::InitGL void   
 

Definition at line 191 of file nviz3d.cpp.

Referenced by Render.

00192 {
00193     SetCurrent();
00194 
00195     // set viewing projection
00196     glMatrixMode(GL_PROJECTION);
00197     glFrustum(-1.0F, 1.0F, -1.0F, 1.0F, 1.0F, 100.0F);
00198 
00199     // position viewer
00200     glMatrixMode(GL_MODELVIEW);
00201     glLoadIdentity();
00202     glTranslated(0.0, 0.0, -4.0);
00203 
00204     glEnable(GL_DEPTH_TEST);
00205     glEnable(GL_LIGHTING);
00206     glEnable(GL_LIGHT0);
00207 }

void Nviz3DCanvas::OnEnterWindow wxMouseEvent &    event
 

Definition at line 108 of file nviz3d.cpp.

00109 {
00110     SetFocus();
00111 }

void Nviz3DCanvas::OnEraseBackground wxEraseEvent &    event
 

Definition at line 185 of file nviz3d.cpp.

00186 {
00187   // Do nothing, to avoid flashing.
00188 }

void Nviz3DCanvas::OnMouse wxMouseEvent &    event
 

Definition at line 138 of file nviz3d.cpp.

References last_x, last_y, xrot, yrot, and zoom.

00139 {
00140 // I think all this dragging stuff is a way to waste a cycle to get a last_x or
00141 // y before drawing. Still not working but good enough for now.
00142     static int dragging = 0;
00143 
00144     if (event.LeftIsDown())
00145     {
00146         if (!dragging)
00147         {
00148             dragging = 1;
00149         }
00150         else
00151         {
00152             yrot += (event.GetX() - last_x)*1.0;
00153             xrot += (event.GetY() - last_y)*1.0;
00154             Refresh(FALSE);
00155         }
00156         last_x = event.GetX();
00157         last_y = event.GetY();
00158     }
00159 
00160 
00161     if (event.RightIsDown())
00162     {
00163         if (!dragging)
00164         {
00165             dragging = 0;
00166         }
00167         else
00168         {
00169             xrot = 0.0;  // If this is not done it will rotate when zooming
00170             yrot = 0.0;
00171             zoom  += (event.GetY() - last_y)*0.25;
00172             Refresh(FALSE);
00173         }
00174         last_y = event.GetY();
00175     }
00176 //    else
00177 //        dragging = 0;
00178 }

void Nviz3DCanvas::OnPaint wxPaintEvent &    event
 

Definition at line 114 of file nviz3d.cpp.

References Render.

00115 {
00116     Render();
00117 }

void Nviz3DCanvas::OnSize wxSizeEvent &    event
 

Definition at line 120 of file nviz3d.cpp.

00121 {
00122     // this is also necessary to update the context on some platforms
00123     wxGLCanvas::OnSize(event);
00124 
00125     // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
00126     int w, h;
00127     GetClientSize(&w, &h);
00128 #ifndef __WXMOTIF__
00129     if (GetContext())
00130 #endif
00131     {
00132         SetCurrent();
00133         glViewport(0, 0, (GLint) w, (GLint) h);
00134     }
00135 }

void Nviz3DCanvas::Render void   
 

Definition at line 70 of file nviz3d.cpp.

References InitGL, m_init, xrot, yrot, and zoom.

Referenced by OnPaint.

00071 {
00072     // This is apperantly a dummy to avoid an endless succession of paint
00073     // messages. OnPaint handlers must always create a wxPaintDC.
00074     wxPaintDC dc(this);
00075 
00076 #ifndef __WXMOTIF__
00077     if (!GetContext()) return;
00078 #endif
00079 
00080     SetCurrent();
00081     // init OpenGL once, but after SetCurrent
00082     if (!m_init)
00083     {
00084         InitGL();
00085         m_init = TRUE;
00086     }
00087 
00088     // clear color and depth buffers
00089     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00090 
00091     glPushMatrix();
00092     glMatrixMode(GL_MODELVIEW);
00093     glRotatef(yrot, 0.0, 1.0, 0.0);
00094     glRotatef(xrot, 1.0, 0.0, 0.0);
00095     glMatrixMode(GL_PROJECTION);
00096     glTranslatef(0.0, 0.0, zoom);
00097 
00098     GLUquadricObj *gl_neuron = gluNewQuadric();
00099     gluSphere(gl_neuron, 1.0, 10, 10);
00100 
00101     glPopMatrix();
00102 
00103   glFlush();
00104   SwapBuffers();
00105 }


Friends And Related Function Documentation

friend class NVizFrame [friend]
 

Definition at line 49 of file nviz3d.h.


Member Data Documentation

bool Nviz3DCanvas::m_init [private]
 

Definition at line 69 of file nviz3d.h.

Referenced by Nviz3DCanvas, and Render.


The documentation for this class was generated from the following files:
Generated on Fri Jun 6 22:02:33 2003 for NeReK by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002