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

vuTransferCanvas Class Reference

A viewer and editor for the vuTFDesign transfer function. More...

#include <vuTransferCanvas.h>

Inheritance diagram for vuTransferCanvas:

Inheritance graph
[legend]
Collaboration diagram for vuTransferCanvas:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 vuTransferCanvas (vuTFDesign &tf, wxWindow *parent, wxWindowID id=-1, bool edit=false)
 The constructor for the transfer function canvas.
 ~vuTransferCanvas ()
 The destructor.
vuTFDesigngetTransferFunc ()
 Returns the transfer function displayed by the canvas.
void setTransferFunc (const vuTFDesign &tf)
 Sets the transfer function to display on the canvas.
const vuTFDesign::OpacityNodegetActiveOpacity () const
 Returns the active control node, or 0 if there is none.
void setActiveOpacity (const vuTFDesign::OpacityNode *)
 Sets the active control node to the given value.
const vuTFDesign::ColourNodegetActiveColour () const
 Returns the active colour.
void setActiveColour (const vuTFDesign::ColourNode *)
 Sets the active colour node to the given value.
void setSmoothing (float opacity, float colour)
 Sets the smoothing of the transfer function.

Protected Member Functions

bool glInit ()
 Initializes openGL for the transfer function canvas.
void render ()
 Renders the transfer function.
void resize ()
 Sets up the coordinates for the canvas.
void OnMouse (wxMouseEvent &ev)
 Handles the mouse commands.
void postEvent (wxEventType ev)
 Helper function that posts the passed in event to the event handler.

Protected Attributes

vuTFDesignm_TFunc
 The transfer function being shown in the Canvas.
bool m_Edit
 Whether the transfer function is editeable or not.
float m_xScreenMin
 The coordinates of the screen.
float m_xScreenMax
 The coordinates of the screen.
float m_yScreenMin
 The coordinates of the screen.
float m_yScreenMax
 The coordinates of the screen.
float m_dx
 Grid widths and heights in graph coordinates.
float m_dy
 Grid widths and heights in graph coordinates.
dword m_Opacity
 The opacity node selected, if any (if none then value is -1).
dword m_Colour
 The colour node selected, if any (if none then value is -1).
const dword m_xMin
 These are the ranges for the graph, ie the scales on the axes.
const dword m_xMax
const float m_yMin
const float m_yMax
bool m_DoSpectral
 Indicates whether spectral colours are to be designed or RGBa.

Detailed Description

A viewer and editor for the vuTFDesign transfer function.

This class implements an Open GL viewer for the vuTFDesign transfer function. It can be run in both modes: as strictly a viewer, or as a viewer and editor. The class inherits from the wxWindows gl canvas, and is therefore a full- fledged wxWindows widget. It can be plugged into other windows and panels just like any other widget, or it can be made to fill the whole window.

As a viewer, the class displays the transfer function and has the option of going into editing mode. Displaying is done using a method similar to Riemann integrals: a rectangle is drawn for each intensity, where the height corresponds to the opacity at that intensity. The rectangle is assigned the same colour as the intensity. This method gives good results both for the continuity of the function and the continuity in colour gradients. The viewer can also be taken into editing mode. This is done when the user double clicks on it. This action pops up the vuTransferDialog for editing the function. As a viewer, this class could easily be used for any intensity transfer function, though right now it only accepts vuTFDesign transfer functions.

The class can also be run as an editor for the vuTFDesign transfer function. In this mode, it renders the opacity polyline which defines the transfer function. The control nodes defining the opacity polyline and also the colour regions are also drawn. The user can then click on these control regions to select them, can move them around, and can add and delete them. No user interface widgets are provided for this editing, for this kind of functionality look at vuTransferDialog. However, to help with such editing, the class also generates events corresponding to the user's interaction with the window. These events indicate when control nodes have been selected or opened up, and when the transfer function has been changed.

The editing functionality can only be provided for the vuTFDesign transfer function. This is because every transfer function is defined with different parameters, and the control nodes mean different things. However, this class can be used as a model for other transfer function editors.

Definition at line 47 of file vuTransferCanvas.h.


Constructor & Destructor Documentation

vuTransferCanvas::vuTransferCanvas vuTFDesign tf,
wxWindow *  parent,
wxWindowID  id = -1,
bool  edit = false
 

The constructor for the transfer function canvas.

The transfer canvas can be used in either edit or display mode (as set by the edit parameter). In edit mode, the control nodes are displayed and are moveable; in display mode, simply the transfer function is showed.

Parameters:
parent The parent window of the transfer canvas
id The wxWindows id to assign to the transfer canvas.
edit Sets the edit mode for the transfer canvas, true for edit mode.
number of components in colour model for transfer function
range Range of transfer function, which always begins with zero

Definition at line 17 of file vuTransferCanvas.cpp.

vuTransferCanvas::~vuTransferCanvas  ) 
 

The destructor.

Definition at line 35 of file vuTransferCanvas.cpp.


Member Function Documentation

const vuTFDesign::ColourNode * vuTransferCanvas::getActiveColour  )  const
 

Returns the active colour.

Definition at line 102 of file vuTransferCanvas.cpp.

References vuTFDesign::getColour(), m_Colour, and m_TFunc.

Referenced by vuTransferDialog::OnOpen(), and vuTransferDialog::OnSelect().

Here is the call graph for this function:

const vuTFDesign::OpacityNode * vuTransferCanvas::getActiveOpacity  )  const
 

Returns the active control node, or 0 if there is none.

Definition at line 74 of file vuTransferCanvas.cpp.

References vuTFDesign::getOpacity(), m_Opacity, and m_TFunc.

Referenced by vuTransferDialog::OnSelect(), and vuTFDialogSpec::OnSlideLight().

Here is the call graph for this function:

vuTFDesign & vuTransferCanvas::getTransferFunc  ) 
 

Returns the transfer function displayed by the canvas.

Definition at line 43 of file vuTransferCanvas.cpp.

Referenced by vuTFDialogSpec::buildCustomSizer(), vuTFDialogSpec::editSpecColour(), vuTransferDialog::getTransferFunc(), vuTFDialogSpec::OnEditPalette(), vuTransferDialog::OnLoadTF(), vuTransferDialog::OnOpen(), vuTransferDialog::OnSaveTF(), vuTFDialogSpec::OnSetupNodes(), vuTFDialogSpec::OnSlideLight(), and vuTFDialogSpec::updateSliders().

bool vuTransferCanvas::glInit  )  [protected, virtual]
 

Initializes openGL for the transfer function canvas.

Reimplemented from vuGLCanvas.

Definition at line 130 of file vuTransferCanvas.cpp.

References GL_MODELVIEW, GL_PROJECTION, glClearColor(), glLoadIdentity(), glMatrixMode(), m_xScreenMax, m_xScreenMin, m_yScreenMax, and m_yScreenMin.

Here is the call graph for this function:

void vuTransferCanvas::OnMouse wxMouseEvent &  ev  )  [protected]
 

Handles the mouse commands.

Definition at line 262 of file vuTransferCanvas.cpp.

References vuTFDesign::addColour(), vuTFDesign::addOpacity(), byte, vuTFDesign::ColourNode::col, dword, vuTFDesign::generateFunction(), vuTFDesign::getColour(), vuGLCanvas::getHeight(), vuTFDesign::getNumColours(), vuTFDesign::getNumOpacities(), vuTFDesign::getOpacity(), vuTransferDialog::getTransferFunc(), vuGLCanvas::getWidth(), vuTFDesign::ColourNode::intensity, vuTFDesign::OpacityNode::intensity, m_Colour, m_dy, m_Opacity, m_TFunc, m_xMax, m_xMin, m_xScreenMax, m_xScreenMin, m_yMin, m_yScreenMax, m_yScreenMin, vuTFDesign::OpacityNode::opacity, postEvent(), vuGLCanvas::redraw(), vuTFDesign::removeColour(), vuTFDesign::removeOpacity(), vuEVT_TRANSFER_CHANGE, vuEVT_TRANSFER_NODE_OPEN, and vuEVT_TRANSFER_NODE_SELECT.

Here is the call graph for this function:

void vuTransferCanvas::postEvent wxEventType  ev  )  [protected]
 

Helper function that posts the passed in event to the event handler.

Definition at line 441 of file vuTransferCanvas.cpp.

References m_TFunc.

Referenced by OnMouse().

void vuTransferCanvas::render  )  [protected, virtual]
 

Renders the transfer function.

Reimplemented from vuGLCanvas.

Definition at line 176 of file vuTransferCanvas.cpp.

References dword, vuTFDesign::getColour(), vuColour< S >::getData(), vuTFDesign::getNumColours(), vuTFDesign::getNumOpacities(), vuTFDesign::getOpacity(), vuTFIntensity::getOpacityAtPos(), vuTFIntensity::getRGBa(), GL_COLOR_BUFFER_BIT, GL_LINE_LOOP, GL_LINE_STRIP, GL_QUADS, glBegin(), glClear(), glColor3f(), glColor3fv(), glColor4f(), glEnd(), glVertex2f(), vuTFDesign::ColourNode::intensity, vuTFDesign::OpacityNode::intensity, m_dx, m_dy, m_TFunc, m_xMax, m_xMin, m_yMax, m_yMin, and vuTFDesign::OpacityNode::opacity.

Here is the call graph for this function:

void vuTransferCanvas::resize  )  [protected, virtual]
 

Sets up the coordinates for the canvas.

Reimplemented from vuGLCanvas.

Definition at line 148 of file vuTransferCanvas.cpp.

References vuGLCanvas::getHeight(), vuGLCanvas::getWidth(), GL_MODELVIEW, GL_PROJECTION, GLint, glLoadIdentity(), glMatrixMode(), glViewport(), m_dx, m_dy, m_xMax, m_xMin, m_xScreenMax, m_xScreenMin, m_yMax, m_yMin, m_yScreenMax, and m_yScreenMin.

Here is the call graph for this function:

void vuTransferCanvas::setActiveColour const vuTFDesign::ColourNode  ) 
 

Sets the active colour node to the given value.

Definition at line 114 of file vuTransferCanvas.cpp.

References vuTFDesign::addColour(), vuTFDesign::ColourNode::col, vuTFDesign::generateFunction(), vuTFDesign::ColourNode::intensity, m_Colour, m_TFunc, vuGLCanvas::redraw(), and vuTFDesign::removeColour().

Referenced by vuTransferDialog::OnOpen(), and vuTransferDialog::OnUpdate().

Here is the call graph for this function:

void vuTransferCanvas::setActiveOpacity const vuTFDesign::OpacityNode  ) 
 

Sets the active control node to the given value.

Definition at line 86 of file vuTransferCanvas.cpp.

References vuTFDesign::addOpacity(), vuTFDesign::generateFunction(), vuTFDesign::OpacityNode::intensity, m_Opacity, m_TFunc, vuTFDesign::OpacityNode::opacity, vuGLCanvas::redraw(), and vuTFDesign::removeOpacity().

Referenced by vuTransferDialog::OnUpdate().

Here is the call graph for this function:

void vuTransferCanvas::setSmoothing float  opacity,
float  colour
 

Sets the smoothing of the transfer function.

Definition at line 62 of file vuTransferCanvas.cpp.

References vuTFDesign::generateFunction(), m_TFunc, vuGLCanvas::redraw(), vuTFDesign::setColourSmoothing(), and vuTFDesign::setOpacitySmoothing().

Referenced by vuTransferDialog::OnUpdate().

Here is the call graph for this function:

void vuTransferCanvas::setTransferFunc const vuTFDesign tf  ) 
 

Sets the transfer function to display on the canvas.

Definition at line 52 of file vuTransferCanvas.cpp.

References m_TFunc, and vuGLCanvas::redraw().

Here is the call graph for this function:


Member Data Documentation

dword vuTransferCanvas::m_Colour [protected]
 

The colour node selected, if any (if none then value is -1).

Definition at line 111 of file vuTransferCanvas.h.

Referenced by getActiveColour(), OnMouse(), and setActiveColour().

bool vuTransferCanvas::m_DoSpectral [protected]
 

Indicates whether spectral colours are to be designed or RGBa.

Definition at line 121 of file vuTransferCanvas.h.

float vuTransferCanvas::m_dx [protected]
 

Grid widths and heights in graph coordinates.

Definition at line 106 of file vuTransferCanvas.h.

Referenced by render(), and resize().

float vuTransferCanvas::m_dy [protected]
 

Grid widths and heights in graph coordinates.

Definition at line 106 of file vuTransferCanvas.h.

Referenced by OnMouse(), render(), and resize().

bool vuTransferCanvas::m_Edit [protected]
 

Whether the transfer function is editeable or not.

Definition at line 101 of file vuTransferCanvas.h.

dword vuTransferCanvas::m_Opacity [protected]
 

The opacity node selected, if any (if none then value is -1).

Definition at line 109 of file vuTransferCanvas.h.

Referenced by getActiveOpacity(), OnMouse(), and setActiveOpacity().

vuTFDesign& vuTransferCanvas::m_TFunc [protected]
 

The transfer function being shown in the Canvas.

Definition at line 99 of file vuTransferCanvas.h.

Referenced by getActiveColour(), getActiveOpacity(), OnMouse(), postEvent(), render(), setActiveColour(), setActiveOpacity(), setSmoothing(), and setTransferFunc().

const dword vuTransferCanvas::m_xMax [protected]
 

Definition at line 116 of file vuTransferCanvas.h.

Referenced by OnMouse(), render(), and resize().

const dword vuTransferCanvas::m_xMin [protected]
 

These are the ranges for the graph, ie the scales on the axes.

Definition at line 115 of file vuTransferCanvas.h.

Referenced by OnMouse(), render(), and resize().

float vuTransferCanvas::m_xScreenMax [protected]
 

The coordinates of the screen.

Definition at line 104 of file vuTransferCanvas.h.

Referenced by glInit(), OnMouse(), and resize().

float vuTransferCanvas::m_xScreenMin [protected]
 

The coordinates of the screen.

Definition at line 104 of file vuTransferCanvas.h.

Referenced by glInit(), OnMouse(), and resize().

const float vuTransferCanvas::m_yMax [protected]
 

Definition at line 118 of file vuTransferCanvas.h.

Referenced by render(), and resize().

const float vuTransferCanvas::m_yMin [protected]
 

Definition at line 117 of file vuTransferCanvas.h.

Referenced by OnMouse(), render(), and resize().

float vuTransferCanvas::m_yScreenMax [protected]
 

The coordinates of the screen.

Definition at line 104 of file vuTransferCanvas.h.

Referenced by glInit(), OnMouse(), and resize().

float vuTransferCanvas::m_yScreenMin [protected]
 

The coordinates of the screen.

Definition at line 104 of file vuTransferCanvas.h.

Referenced by glInit(), OnMouse(), and resize().


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