#include <nviz3d.h>
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 | DrawNeuron (GLUquadricObj *obj, GLfloat x, GLfloat y, GLfloat z) |
void | InitGL (void) |
void | OnEnterWindow (wxMouseEvent &event) |
void | OnEraseBackground (wxEraseEvent &event) |
void | OnMouse (wxMouseEvent &event) |
void | OnPaint (wxPaintEvent &event) |
void | OnSize (wxSizeEvent &event) |
void | Render (void) |
Private Attributes | |
bool | m_init |
Friends | |
class | NVizFrame |
|
Definition at line 81 of file nviz3d.cpp. References m_init.
00083 : 00084 wxGLCanvas(parent, (wxGLCanvas*) NULL, id, pos, size, style, name ) 00085 { 00086 m_init = FALSE; 00087 } |
|
Definition at line 90 of file nviz3d.cpp.
00091 { 00092 // Nothing Here 00093 } |
|
Definition at line 96 of file nviz3d.cpp. References neuron_radius, neuron_slices, and neuron_stacks. Referenced by Render.
00097 { 00098 glPushMatrix(); 00099 glTranslatef(x, y, z); 00100 gluSphere(obj, neuron_radius, neuron_stacks, neuron_slices); 00101 glPopMatrix(); 00102 } |
|
Definition at line 105 of file nviz3d.cpp. Referenced by Render.
00106 { 00107 SetCurrent(); 00108 00109 // set viewing projection 00110 glMatrixMode(GL_PROJECTION); 00111 glFrustum(-1.0F, 1.0F, -1.0F, 1.0F, 1.0F, 100.0F); 00112 00113 // position viewer 00114 glMatrixMode(GL_MODELVIEW); 00115 glLoadIdentity(); 00116 glTranslated(0.0, 0.0, -4.0); 00117 00118 glEnable(GL_DEPTH_TEST); 00119 glEnable(GL_LIGHTING); 00120 glEnable(GL_LIGHT0); 00121 } |
|
Definition at line 124 of file nviz3d.cpp.
00125 { 00126 SetFocus(); 00127 } |
|
Definition at line 130 of file nviz3d.cpp.
00131 { 00132 // Do nothing, to avoid flashing. 00133 } |
|
Definition at line 136 of file nviz3d.cpp. References camera_rotate, camera_x, camera_y, camera_zoom, last_x, and last_y.
00137 { 00138 // I think all this dragging stuff is a way to waste a cycle to get a last_x or 00139 // y before drawing. Still not working but good enough for now. 00140 static int dragging = 0; 00141 00142 if (event.LeftIsDown()) 00143 { 00144 if (!dragging) 00145 { 00146 dragging = 1; 00147 } 00148 else 00149 { 00150 camera_x += (event.GetX() - last_x)*(drag_scale_x); 00151 camera_y -= (event.GetY() - last_y)*(drag_scale_y); 00152 Refresh(FALSE); 00153 } 00154 last_x = event.GetX(); 00155 last_y = event.GetY(); 00156 } 00157 else if (event.RightIsDown()) 00158 { 00159 if (!dragging) 00160 { 00161 dragging = 1; 00162 } 00163 else 00164 { 00165 camera_rotate += (event.GetX() - last_x)*(rotate_scale); 00166 camera_zoom += (event.GetY() - last_y)*(zoom_scale); 00167 Refresh(FALSE); 00168 } 00169 last_x = event.GetX(); 00170 last_y = event.GetY(); 00171 } 00172 else 00173 { 00174 dragging = 0; 00175 camera_rotate = 0; 00176 } 00177 } |
|
Definition at line 180 of file nviz3d.cpp. References Render.
00181 { 00182 Render(); 00183 } |
|
Definition at line 186 of file nviz3d.cpp.
00187 { 00188 // this is also necessary to update the context on some platforms 00189 wxGLCanvas::OnSize(event); 00190 00191 // set GL viewport (not called by wxGLCanvas::OnSize on all platforms...) 00192 int w, h; 00193 GetClientSize(&w, &h); 00194 #ifndef __WXMOTIF__ 00195 if (GetContext()) 00196 #endif 00197 { 00198 SetCurrent(); 00199 glViewport(0, 0, (GLint) w, (GLint) h); 00200 } 00201 } |
|
Definition at line 204 of file nviz3d.cpp. References camera_rotate, camera_x, camera_y, camera_zoom, DrawNeuron, gl_neuron_00, gl_neuron_01, gl_neuron_02, gl_neuron_03, gl_neuron_04, gl_neuron_05, InitGL, and m_init. Referenced by OnPaint.
00205 { 00206 // This is apperantly a dummy to avoid an endless succession of paint 00207 // messages. OnPaint handlers must always create a wxPaintDC. 00208 wxPaintDC dc(this); 00209 00210 #ifndef __WXMOTIF__ 00211 if (!GetContext()) return; 00212 #endif 00213 00214 SetCurrent(); 00215 // init OpenGL once, but after SetCurrent 00216 if (!m_init) 00217 { 00218 InitGL(); 00219 m_init = TRUE; 00220 } 00221 00222 // clear color and depth buffers 00223 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00224 00225 glPushMatrix(); 00226 glMatrixMode(GL_MODELVIEW); 00227 glTranslatef(camera_x, camera_y, camera_zoom); 00228 glMatrixMode(GL_PROJECTION); 00229 glRotatef(camera_rotate, 0.0, 1.0, 0.0); 00230 glMatrixMode(GL_MODELVIEW); 00231 00232 DrawNeuron(gl_neuron_00 , -2.0, -4.0, 0.0); 00233 DrawNeuron(gl_neuron_01 , 2.0, -4.0, 0.0); 00234 DrawNeuron(gl_neuron_02 , -2.0, 0.0, 0.0); 00235 DrawNeuron(gl_neuron_03 , 2.0, .0, 0.0); 00236 DrawNeuron(gl_neuron_04 , -2.0, 4.0, 0.0); 00237 DrawNeuron(gl_neuron_05 , 2.0, 4.0, 0.0); 00238 00239 glLineWidth(8); 00240 glBegin(GL_LINES); 00241 glVertex3f(-2.0, -4.0, 0.0); 00242 glVertex3f(-2.0, 0.0, 0.0); 00243 glEnd(); 00244 00245 glPopMatrix(); 00246 00247 glFlush(); 00248 SwapBuffers(); 00249 } |
|
|
|
Definition at line 57 of file nviz3d.h. Referenced by Nviz3DCanvas, and Render. |