Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

vuGLCanvas Class Reference

A specialization of the wxGLCanvas to our project. More...

#include <vuGLCanvas.h>

Inheritance diagram for vuGLCanvas:

Inheritance graph
[legend]
Collaboration diagram for vuGLCanvas:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 vuGLCanvas (wxWindow *parent, const wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name="vuGLCanvas", int *gl_attrib=NULL)
 Initializes the canvas with the same parameters as the wxGLCanvas parent.
void redraw ()
 Redraws the contents of the canvas.
int getWidth () const
 Returns the width of the OpenGL canvas.
int getHeight () const
 Returns the height of the OpenGL canvas.
void enableOpenGL ()
 activate OpenGL Support
void disableOpenGL ()
 deactivate OpenGL Support

Protected Member Functions

virtual bool glInit ()
 Initializes openGL for use in the canvas.
virtual void render ()
 Renders the scene to the canvas using OpenGL.
virtual void resize ()
 Alters the OpenGL state after a resize event.

Private Member Functions

void onPaint (wxPaintEvent &event)
 Implements the OnPaint event.
void onSize (wxSizeEvent &event)
 Implements the default OnSize event.
void onEraseBackground (wxEraseEvent &event)
 Implements the OnEraseBackground event.

Private Attributes

int m_Width
 The width of the canvas.
int m_Height
 The height of the canvas.
bool m_init
 Whether the canvas has been initialized or not.
bool m_useOGL
 Whether the OpenGL should be used or not.

Detailed Description

A specialization of the wxGLCanvas to our project.

Steven Bergner, 30May02: redraw() now just triggers PAINT event, not calling render() directly. This caused problems in windows.

Definition at line 28 of file vuGLCanvas.h.


Constructor & Destructor Documentation

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

Initializes the canvas with the same parameters as the wxGLCanvas parent.

The constructor acts in the same way as the wxGLCanvas constructor, with the same parameters. Any open gl initialization commands must be made by overriding the glInit() method.

Note:
Even though the glCanvas is constructed after this call, it is not necessarily the case that openGL has been fully initialized for the canvas. This is because under some windowing systems, the opengl classes are not fully created until after the canvas has been shown on the screen. To initialize openGl then, the glInit() method must be overridden. It will get called automatically as soon as open gl calls are possible. Any opengl calls before this can result in segmentation faults.

Definition at line 20 of file vuGLCanvas.cpp.

References size.


Member Function Documentation

void vuGLCanvas::disableOpenGL  ) 
 

deactivate OpenGL Support

This is useful to hold the drawing canvas free for other drawing functions than OpenGL, e.g. if you want to use the GUI blit function instead of glDrawPixels() (which is said to be rather slow on PCs) Alternatively you can use vuDrawTools then, which should provide more direct frame buffer access.

Definition at line 41 of file vuGLCanvas.cpp.

References m_useOGL.

Referenced by vuBasicUtility::useOpenGL().

void vuGLCanvas::enableOpenGL  ) 
 

activate OpenGL Support

OpenGL is active in a vuGLCanvas by default. This function is intended to reactivate the OpenGL context.

Definition at line 32 of file vuGLCanvas.cpp.

References m_useOGL.

Referenced by vuBasicUtility::useOpenGL().

int vuGLCanvas::getHeight  )  const
 

Returns the height of the OpenGL canvas.

Definition at line 68 of file vuGLCanvas.cpp.

Referenced by vuSimpleFVRCanvas::_clearCanvas(), vuSimpleFVRCanvas::_renderImage(), vuSimpleFBR< SIZE, TYPE >::_renderImage(), vuSimpleFVRCanvas::_renderImageOld(), vuSimpleFBR< SIZE, TYPE >::_updateViewFilter(), vuSphericRevolver< SIZE, TYPE >::glInit(), vuSimpleFBR< SIZE, TYPE >::glInit(), vuBasicSubWindow::glInit(), vuSpecFVR::glOnMouse(), vuSlicer::glOnMouse(), vuStandardFVR< SIZE >::glRender(), vuSpectral::glRender(), vuSpecFVR::glRender(), vuFVR::glRender(), vuBCCSheetSplatter::glRender(), vuStandardFVR< SIZE >::glResize(), vuSplat::glResize(), vuSphericRevolver< SIZE, TYPE >::glResize(), vuSphericIBR< SIZE, TYPE >::glResize(), vuSphericBrowser< SIZE, TYPE >::glResize(), vuSpectral::glResize(), vuSpecSplat::glResize(), vuSpecFVR::glResize(), vuSlicer::glResize(), vuSimpleFBR< SIZE, TYPE >::glResize(), vuShearWarp::glResize(), vuRaycast::glResize(), vuMarchingCubes::glResize(), vuFVR::glResize(), vuCellProjector::glResize(), vuBccSplat::glResize(), vuBCCSheetSplatter::glResize(), vuBCCShearWarp::glResize(), vuBCCRaycaster::glResize(), vuBCCMarchingTetrahedra::glResize(), vuBCCFirstHitRaycaster::glResize(), vuSphericBrowser< SIZE, TYPE >::init(), vuBasicSubViewer::makeCanvasSizeEqual(), vuSimpleFVRDialog::OnButtonLoadFile(), vuMarchingCubes::onDblClick(), vuTransferCanvas::OnMouse(), vuBasicSubWindow::render(), vuTransferCanvas::resize(), vuKeyFrameCanvas::resize(), vuFBRSubCanvas< SIZE, TYPE >::resize(), and vuBasicSubViewer::showControl().

int vuGLCanvas::getWidth  )  const
 

Returns the width of the OpenGL canvas.

Definition at line 59 of file vuGLCanvas.cpp.

Referenced by vuSimpleFVRCanvas::_clearCanvas(), vuSimpleFVRCanvas::_renderImage(), vuSimpleFBR< SIZE, TYPE >::_renderImage(), vuSimpleFVRCanvas::_renderImageOld(), vuSimpleFBR< SIZE, TYPE >::_updateViewFilter(), vuSphericRevolver< SIZE, TYPE >::glInit(), vuSimpleFBR< SIZE, TYPE >::glInit(), vuBasicSubWindow::glInit(), vuSpecFVR::glOnMouse(), vuStandardFVR< SIZE >::glRender(), vuSpectral::glRender(), vuSpecFVR::glRender(), vuFVR::glRender(), vuStandardFVR< SIZE >::glResize(), vuSplat::glResize(), vuSphericRevolver< SIZE, TYPE >::glResize(), vuSphericIBR< SIZE, TYPE >::glResize(), vuSphericBrowser< SIZE, TYPE >::glResize(), vuSpectral::glResize(), vuSpecSplat::glResize(), vuSpecFVR::glResize(), vuSlicer::glResize(), vuSimpleFBR< SIZE, TYPE >::glResize(), vuShearWarp::glResize(), vuRaycast::glResize(), vuMarchingCubes::glResize(), vuFVR::glResize(), vuCellProjector::glResize(), vuBccSplat::glResize(), vuBCCSheetSplatter::glResize(), vuBCCShearWarp::glResize(), vuBCCRaycaster::glResize(), vuBCCMarchingTetrahedra::glResize(), vuBCCFirstHitRaycaster::glResize(), vuSphericBrowser< SIZE, TYPE >::init(), vuBasicSubViewer::makeCanvasSizeEqual(), vuSimpleFVRDialog::OnButtonLoadFile(), vuTransferCanvas::OnMouse(), vuBasicSubWindow::render(), vuTransferCanvas::resize(), vuKeyFrameCanvas::resize(), vuFBRSubCanvas< SIZE, TYPE >::resize(), and vuBasicSubViewer::showControl().

virtual bool vuGLCanvas::glInit void   )  [inline, protected, virtual]
 

Initializes openGL for use in the canvas.

This method is called by vuGLCanvas as soon as the canvas' open gl classes are created, and openGL calls can be made. All initializiation should be done by overriding this method.

Returns:
True if successful, false if the canvas could not yet be initialized.

Reimplemented in vuPreviewWin, vuBasicSubWindow, vuFBRSubCanvas< SIZE, TYPE >, vuKeyFrameCanvas, vuSimpleFVRCanvas, vuSphericViewWin, vuTransferCanvas, vuBasicGLCanvas, and vuFBRSubCanvas< SIZE, byte >.

Definition at line 85 of file vuGLCanvas.h.

Referenced by onPaint().

void vuGLCanvas::onEraseBackground wxEraseEvent &  event  )  [private]
 

Implements the OnEraseBackground event.

This method actually eliminates the EraseBackground event from the event stack so that the windowing system doesn't erase the window itself. This causes flickering because the paint event is put right after the background is erased.

Definition at line 134 of file vuGLCanvas.cpp.

void vuGLCanvas::onPaint wxPaintEvent &  event  )  [private]
 

Implements the OnPaint event.

It prepares the window's onPaint() drawing context, as required for an onPaint() event. It creates a clientDC for the window, as required for drawing to it, calls the render() method, then flushes the GL buffers to the canvas.

Definition at line 77 of file vuGLCanvas.cpp.

References dc, glInit(), m_init, render(), and resize().

Here is the call graph for this function:

void vuGLCanvas::onSize wxSizeEvent &  event  )  [private]
 

Implements the default OnSize event.

It updates the internal vuGLCanvas variables and resizes the openGL viewport to the new canvas area. If different behaviour is desired, the derived class should implement it's own onSize event handler. The onPaint() event is called by wxWindows immediately afterwards, so the glCanvas does not need to be explicitly refreshed.

Definition at line 110 of file vuGLCanvas.cpp.

References m_Height, m_Width, redraw(), and resize().

Here is the call graph for this function:

void vuGLCanvas::redraw  ) 
 

Redraws the contents of the canvas.

This method is called when the contents of canvas should be redrawn. calls Refresh(), which creates a PAINT event, which triggers onPaint()

Definition at line 50 of file vuGLCanvas.cpp.

Referenced by vuSphericBrowser< SIZE, TYPE >::_updateIndexAndRefresh(), vuSphericRevolver< SIZE, TYPE >::_updateScaleAndRefresh(), vuSphericBrowser< SIZE, TYPE >::_updateScaleAndRefresh(), vuSplat::DrawAgain(), vuSpectral::DrawAgain(), vuSpecSplat::DrawAgain(), vuSpecFVR::DrawAgain(), vuRaycast::DrawAgain(), vuFVR::DrawAgain(), vuCellProjector::DrawAgain(), vuBCCRaycaster::DrawAgain(), vuBCCFirstHitRaycaster::DrawAgain(), vuSphericRevolver< SIZE, TYPE >::DrawFromImage(), vuSphericIBR< SIZE, TYPE >::DrawFromImage(), vuSpectral::DrawFromImage(), vuSpecFVR::DrawFromImage(), vuSimpleFBR< SIZE, TYPE >::DrawFromImage(), vuRaycast::DrawFromImage(), vuBCCRaycaster::DrawFromImage(), vuBCCFirstHitRaycaster::DrawFromImage(), vuTFDialogSpec::editSpecColour(), vuSplat::glOnMouse(), vuSpecSplat::glOnMouse(), vuSpecFVR::glOnMouse(), vuSlicer::glOnMouse(), vuShearWarp::glOnMouse(), vuPreviewWin::glOnMouse(), vuFVR::glOnMouse(), vuCellProjector::glOnMouse(), vuBccSplat::glOnMouse(), vuBCCSheetSplatter::glOnMouse(), vuBCCShearWarp::glOnMouse(), vuBCCMarchingTetrahedra::glOnMouse(), vuBasicSubViewer::glOnMouse(), vuSphericIBR< SIZE, TYPE >::glRender(), vuStandardFVR< SIZE >::glResize(), vuSphericBrowser< SIZE, TYPE >::glResize(), vuSlicer::glResize(), vuSplat::notifyDataChanged(), vuSpectral::notifyDataChanged(), vuSpecSplat::notifyDataChanged(), vuSpecFVR::notifyDataChanged(), vuFVR::notifyDataChanged(), vuCellProjector::notifyDataChanged(), vuSphericBrowser< SIZE, TYPE >::OnBrowseViews(), vuShearWarp::OnButtonApplyViewing(), vuBCCShearWarp::OnButtonApplyViewing(), vuSimpleFVRDialog::OnButtonCloseFile(), vuSimpleFBR< SIZE, TYPE >::OnButtonFill(), vuStandardFVR< SIZE >::OnButtonFitScale(), vuSimpleFBR< SIZE, TYPE >::OnButtonFitScale(), vuSimpleFVRDialog::OnButtonFitScaleAndBias(), vuSimpleFVRDialog::OnButtonLoadFile(), vuSimpleFBR< SIZE, TYPE >::OnButtonPreprocess(), vuSpectral::OnButtonRender(), vuSpecFVR::OnButtonRender(), vuRaycast::OnButtonRender(), vuBCCSheetSplatter::OnButtonRender(), vuBCCRaycaster::OnButtonRender(), vuBCCFirstHitRaycaster::OnButtonRender(), vuSimpleFBR< SIZE, TYPE >::OnButtonReset(), vuSimpleFBR< SIZE, TYPE >::OnButtonSave(), vuSimpleFBR< SIZE, TYPE >::OnButtonSnap2View(), vuShearWarp::OnButtonTransferFunction(), vuBCCShearWarp::OnButtonTransferFunction(), vuSpecFVR::OnButtonTransform(), vuMarchingCubes::OnChangeFrame(), vuSpecFVR::OnChar(), vuSlicer::OnChar(), vuBasicUtility::OnChar(), vuSimpleFVRDialog::OnCheckboxAutoScaleAndBias(), vuStandardFVR< SIZE >::OnCheckboxChannels(), vuSimpleFBR< SIZE, TYPE >::OnCheckboxChannels(), vuFVR::OnCheckBoxDepthCueing(), vuFVR::OnCheckBoxDiffuseShading(), vuSimpleFBR< SIZE, TYPE >::OnCheckboxInteractiveReconst(), vuStandardFVR< SIZE >::OnChoiceFilter(), vuSphericIBR< SIZE, TYPE >::OnChoiceFilter(), vuSimpleFBR< SIZE, TYPE >::OnChoiceFourierFilter(), vuSimpleFVRDialog::OnChoiceMethod(), vuSphericRevolver< SIZE, TYPE >::OnChoiceNumberOfViews(), vuStandardFVR< SIZE >::OnChoiceRenderMethod(), vuSimpleFBR< SIZE, TYPE >::OnChoiceRenderMethod(), vuSphericIBR< SIZE, TYPE >::OnChoiceSubFilter(), vuMarchingCubes::OnCubeChange(), vuMarchingCubes::OnCubeEnabledChecked(), vuMarchingCubes::OnCubeSizeChange(), vuMarchingCubes::OnCullLinesFrontBackChecked(), vuMarchingCubes::onDblClick(), vuMarchingCubes::OnDrawNormalsChecked(), vuMarchingCubes::OnFrameChecked(), vuFVR::onKeyboard(), vuBasicUtility::onKeyboardRotate(), vuBasicUtility::onKeyboardZoom(), vuMarchingCubes::OnLight1Checked(), vuTransferDialog::OnLoadTF(), vuTransferCanvas::OnMouse(), vuKeyFrameCanvas::OnMouse(), vuMarchingCubes::onMouseLeftMoving(), vuBasicUtility::onMouseLeftMoving(), vuMarchingCubes::onMouseRightMoving(), vuBasicUtility::onMouseRightMoving(), vuMarchingCubes::onMouseUp(), vuMarchingCubes::OnNormalLengthChange(), vuShearWarp::OnRadioBoxProjection(), vuBCCShearWarp::OnRadioBoxProjection(), vuMarchingCubes::OnRotateChecked(), vuSphericRevolver< SIZE, TYPE >::OnScaleImage(), vuSphericBrowser< SIZE, TYPE >::OnScaleImage(), vuSphericRevolver< SIZE, TYPE >::OnScaleImage2One(), vuSphericBrowser< SIZE, TYPE >::OnScaleImage2One(), vuShearWarp::OnScrollPerspective(), vuBCCShearWarp::OnScrollPerspective(), vuMarchingCubes::OnSelectType(), vuMarchingCubes::OnSetLineColor(), vuMarchingCubes::OnSetObjectColor(), vuTFDialogSpec::OnSetupNodes(), onSize(), vuTFDialogSpec::OnSlideLight(), vuSpectral::OnSlideLight(), vuSpecFVR::OnSlideLight(), vuStandardFVR< SIZE >::OnSliderImageScale(), vuSimpleFVRDialog::OnSliderImageScale(), vuSimpleFBR< SIZE, TYPE >::OnSliderImageScale(), vuSlicer::OnSlideSlice(), vuMarchingCubes::OnThresChange(), vuMarchingCubes::redraw(), vuBasicSubViewer::redraw(), vuMarchingCubes::resize(), vuTransferCanvas::setActiveColour(), vuTransferCanvas::setActiveOpacity(), vuMarchingCubes::setBackground(), vuTransferCanvas::setSmoothing(), vuKeyFrameCanvas::setSmoothing(), and vuTransferCanvas::setTransferFunc().

virtual void vuGLCanvas::render void   )  [inline, protected, virtual]
 

Renders the scene to the canvas using OpenGL.

This is an interior method for the canvas that encapsulates all the rendering calls. It is called both when the user wants a redraw, and when the operating system requests one. These two cases need different preparation, and so are implemented in the redraw() and onPaint() methods.

The method should be overriden and implement all the rendering calls to OpenGL. The two methods that call it set up the needed device contexts, activate the canvas' GL context, and flush the buffers, so no setting up is necessary. The method encapsulates just the openGL calls.

Reimplemented in vuPreviewWin, vuBasicSubWindow, vuFBRSubCanvas< SIZE, TYPE >, vuKeyFrameCanvas, vuSimpleFVRCanvas, vuSphericViewWin, vuTransferCanvas, vuBasicGLCanvas, and vuFBRSubCanvas< SIZE, byte >.

Definition at line 99 of file vuGLCanvas.h.

Referenced by onPaint().

virtual void vuGLCanvas::resize  )  [inline, protected, virtual]
 

Alters the OpenGL state after a resize event.

This method is called by the vuGLCanvas interior OnSize() method when it gets a canvas resize event. The OnSize() method handles the interior management related to the resize event, then passes control to this method so that any application specific calculation can be done. These are calls such as setting view matrices or updating necessary states.

Reimplemented in vuFBRSubCanvas< SIZE, TYPE >, vuKeyFrameCanvas, vuSimpleFVRCanvas, vuTransferCanvas, vuBasicGLCanvas, and vuFBRSubCanvas< SIZE, byte >.

Definition at line 109 of file vuGLCanvas.h.

Referenced by vuPreviewWin::glOnMouse(), onPaint(), and onSize().


Member Data Documentation

int vuGLCanvas::m_Height [private]
 

The height of the canvas.

Definition at line 141 of file vuGLCanvas.h.

Referenced by onSize().

bool vuGLCanvas::m_init [private]
 

Whether the canvas has been initialized or not.

Definition at line 143 of file vuGLCanvas.h.

Referenced by onPaint().

bool vuGLCanvas::m_useOGL [private]
 

Whether the OpenGL should be used or not.

Definition at line 145 of file vuGLCanvas.h.

Referenced by disableOpenGL(), and enableOpenGL().

int vuGLCanvas::m_Width [private]
 

The width of the canvas.

Definition at line 139 of file vuGLCanvas.h.

Referenced by onSize().


The documentation for this class was generated from the following files:
Generated on Wed Dec 15 21:21:16 2004 for vuVolume by  doxygen 1.3.9.1