#include "TransferFunctionWidget.h"
Public Types | |
enum | PlotMode |
Defines the differant modes for working with points in a plot. | |
Public Member Functions | |
TransferFunctionPlot (wxWindow *parent) | |
Constructor. | |
~TransferFunctionPlot () | |
De-constructor. | |
void | SetPlotMode (PlotMode m) |
Sets the plot mode to use. | |
void | ResetPlot () |
Resets the plots to there defualt states. | |
void | DelayRealtimeUpdate (bool v) |
Enables/Disables realtime plot change updates. | |
void | DrawAll (bool b) |
Enable/Disable drawing all of the plots. | |
void | DrawHistogram (bool b) |
Enable/Disable drawing the histogram. | |
void | MakeRedActive () |
Makes the red plot responsive to user input. | |
void | MakeGreenActive () |
Makes the green plot responsive to user input. | |
void | MakeBlueActive () |
Makes the blue plot responsive to user input. | |
void | MakeAlphaActive () |
Makes the alpha plot responsive to user input. | |
void | OnPaint (wxPaintEvent &e) |
Called when the widget needs to be redrawn. | |
void | MouseMove (wxMouseEvent &m) |
Called when the mouse moves. | |
void | MouseLeftUp (wxMouseEvent &m) |
Called when the left mouse button is released. | |
void | MouseLeftDown (wxMouseEvent &m) |
Called when the left mouse button is pressed. | |
void | MouseWheel (wxMouseEvent &m) |
Called when the mouse wheel is moved. | |
void | MouseLeave (wxMouseEvent &m) |
Called when the mouse leaves the plot area. | |
void | SetListner (TransferPlotChangeListner *l) |
Sets object that listens for plot change events. | |
void | UpdateTexture (TransferTexture *tex) |
Updates the given texture to match the corrent plot. | |
void | Load (const char *file) |
Load a plot from a file. | |
void | Save (const char *file) |
Save the current plot data to a file. | |
void | RefreshListner () |
Updates the listner with new plot data. | |
void | SetHistogram (const unsigned int *h) |
Sets the histogram. | |
Protected Member Functions | |
void | DrawPlot (wxPaintDC &dc, const std::vector< PlotPoint > &plot, const Color4f &color) const |
Draws a vector of PlotPoints as a piecwise linear function. | |
void | DrawPlotPoints (wxPaintDC &dc, const std::vector< PlotPoint > &plot, const Color4f &color) const |
Draws PlotPoints as points. | |
void | PlotPointToScreen (const PlotPoint &p, int &x, int &y) const |
Converts a plot point to a point that can be used on the screen. | |
void | ScreenToPlotPoint (int x, int y, PlotPoint &p) const |
Converts a screen point to a plot poin. | |
int | PlotDataValueToXCoord (int dataValue) const |
Converts a plot point data value to a screen x coordinate. | |
int | PlotValueToYCoord (float value) const |
Converts a plot point value to a screen y coordinate. | |
bool | SelectPoint (wxCoord x, wxCoord y) |
Tests if the given point intersects a plot point in the active plot. | |
int | SelectPoint (wxCoord x, wxCoord y, const std::vector< PlotPoint > &plot) const |
Tests if the given point intersects a plot point in the given plot. | |
void | AddPoint (wxCoord x, wxCoord y) |
Adds a point at the given position. | |
void | RemovePoint (wxCoord x, wxCoord y) |
Removes a point at the given position (if one exists). | |
bool | LoadPlot (std::ifstream &file, std::vector< PlotPoint > &plot, int n) |
Reads plot points from a file and places them in a plot. | |
void | SavePlot (std::ofstream &file, const std::vector< PlotPoint > &plot) |
Saves plot points to a file. |
Definition at line 42 of file TransferFunctionWidget.h.
TransferFunctionPlot::TransferFunctionPlot | ( | wxWindow * | parent | ) |
Constructor.
[in] | parent | the parent window the widget should reside in. |
Definition at line 78 of file TransferFunctionWidget.cpp.
void TransferFunctionPlot::SetPlotMode | ( | PlotMode | m | ) |
Sets the plot mode to use.
[in] | m | the new plot mode. |
Definition at line 293 of file TransferFunctionWidget.cpp.
Referenced by TransferFunctionWidget::OnPlotModeSelection().
void TransferFunctionPlot::DelayRealtimeUpdate | ( | bool | v | ) | [inline] |
Enables/Disables realtime plot change updates.
[in] | v | set to true to delay realtime plot change updates, otherwise set to false. |
Definition at line 88 of file TransferFunctionWidget.h.
Referenced by TransferFunctionWidget::DelayRealtimeUpdate().
void TransferFunctionPlot::DrawAll | ( | bool | b | ) |
Enable/Disable drawing all of the plots.
[in] | b | set to true to draw the plots, set to false to not draw all the plots. |
Definition at line 299 of file TransferFunctionWidget.cpp.
Referenced by TransferFunctionWidget::OnDrawAllClick().
void TransferFunctionPlot::DrawHistogram | ( | bool | b | ) |
Enable/Disable drawing the histogram.
[in] | b | set to true to draw the histogram, set to false to not draw the histogram. |
Definition at line 306 of file TransferFunctionWidget.cpp.
Referenced by TransferFunctionWidget::OnDrawHistogramClick().
void TransferFunctionPlot::OnPaint | ( | wxPaintEvent & | e | ) |
Called when the widget needs to be redrawn.
[in,out] | e | the event. |
Definition at line 161 of file TransferFunctionWidget.cpp.
References DrawPlot(), and DrawPlotPoints().
void TransferFunctionPlot::MouseMove | ( | wxMouseEvent & | m | ) |
Called when the mouse moves.
[in,out] | m | the mouse event. |
Definition at line 198 of file TransferFunctionWidget.cpp.
References Clamp(), PlotPoint::dataValue, PlotDataValueToXCoord(), RefreshListner(), ScreenToPlotPoint(), and PlotPoint::value.
void TransferFunctionPlot::MouseLeftUp | ( | wxMouseEvent & | m | ) |
Called when the left mouse button is released.
[in,out] | m | the mouse event. |
Definition at line 271 of file TransferFunctionWidget.cpp.
void TransferFunctionPlot::MouseLeftDown | ( | wxMouseEvent & | m | ) |
Called when the left mouse button is pressed.
[in,out] | m | the mouse event. |
Definition at line 243 of file TransferFunctionWidget.cpp.
References AddPoint(), PlotPoint::dataValue, RemovePoint(), ScreenToPlotPoint(), SelectPoint(), and PlotPoint::value.
void TransferFunctionPlot::MouseWheel | ( | wxMouseEvent & | m | ) |
Called when the mouse wheel is moved.
[in,out] | m | the mouse event. |
Definition at line 278 of file TransferFunctionWidget.cpp.
void TransferFunctionPlot::MouseLeave | ( | wxMouseEvent & | m | ) |
Called when the mouse leaves the plot area.
[in,out] | m | the mouse event. |
Definition at line 283 of file TransferFunctionWidget.cpp.
References RefreshListner().
void TransferFunctionPlot::SetListner | ( | TransferPlotChangeListner * | l | ) |
Sets object that listens for plot change events.
[in] | l | pointer to the listner. |
Definition at line 349 of file TransferFunctionWidget.cpp.
References RefreshListner().
Referenced by TransferFunctionWidget::SetListner().
void TransferFunctionPlot::UpdateTexture | ( | TransferTexture * | tex | ) |
Updates the given texture to match the corrent plot.
[out] | tex | pointer to the texture. |
Definition at line 356 of file TransferFunctionWidget.cpp.
References TransferTexture::CreateFunction().
Referenced by RTVolumeRenderer::TransferPlotChanged().
void TransferFunctionPlot::Load | ( | const char * | file | ) |
Load a plot from a file.
[in] | file | the file to load. |
Definition at line 522 of file TransferFunctionWidget.cpp.
References ErrorMessage(), LoadPlot(), and RefreshListner().
Referenced by TransferFunctionWidget::OnLoadClick().
void TransferFunctionPlot::Save | ( | const char * | file | ) |
Save the current plot data to a file.
[in] | file | the name of the file. |
Definition at line 624 of file TransferFunctionWidget.cpp.
References ErrorMessage(), and SavePlot().
Referenced by TransferFunctionWidget::OnSaveClick().
void TransferFunctionPlot::SetHistogram | ( | const unsigned int * | h | ) |
Sets the histogram.
[in] | h | the histogram, assumed to have at least 256 elements. |
Definition at line 694 of file TransferFunctionWidget.cpp.
Referenced by TransferFunctionWidget::SetHistogram().
void TransferFunctionPlot::DrawPlot | ( | wxPaintDC & | dc, | |
const std::vector< PlotPoint > & | plot, | |||
const Color4f & | color | |||
) | const [protected] |
Draws a vector of PlotPoints as a piecwise linear function.
[in] | dc | the rendering context. |
[in] | plot | the plot points. |
[in] | color | the color to draw the plot. |
Definition at line 389 of file TransferFunctionWidget.cpp.
References Color4f::Get(), and PlotPointToScreen().
Referenced by OnPaint().
void TransferFunctionPlot::DrawPlotPoints | ( | wxPaintDC & | dc, | |
const std::vector< PlotPoint > & | plot, | |||
const Color4f & | color | |||
) | const [protected] |
Draws PlotPoints as points.
[in] | dc | the rendering context. |
[in] | plot | the plot points. |
[in] | color | the color to draw the points. |
Definition at line 410 of file TransferFunctionWidget.cpp.
References Color4f::Get(), and PlotPointToScreen().
Referenced by OnPaint().
void TransferFunctionPlot::PlotPointToScreen | ( | const PlotPoint & | p, | |
int & | x, | |||
int & | y | |||
) | const [protected] |
Converts a plot point to a point that can be used on the screen.
[in] | p | the plot point. |
[out] | x | the x value of the screen point. |
[out] | y | the y value of the screen point. |
Definition at line 363 of file TransferFunctionWidget.cpp.
References PlotPoint::dataValue, PlotDataValueToXCoord(), PlotValueToYCoord(), and PlotPoint::value.
Referenced by DrawPlot(), DrawPlotPoints(), and SelectPoint().
void TransferFunctionPlot::ScreenToPlotPoint | ( | int | x, | |
int | y, | |||
PlotPoint & | p | |||
) | const [protected] |
Converts a screen point to a plot poin.
[in] | x | the x value of the screen point. |
[in] | y | the y value of the screen point. |
[out] | p | the plot point. |
Definition at line 382 of file TransferFunctionWidget.cpp.
References PlotPoint::dataValue, and PlotPoint::value.
Referenced by AddPoint(), MouseLeftDown(), and MouseMove().
int TransferFunctionPlot::PlotDataValueToXCoord | ( | int | dataValue | ) | const [protected] |
Converts a plot point data value to a screen x coordinate.
[in] | dataValue | the plot point data value. |
Definition at line 370 of file TransferFunctionWidget.cpp.
Referenced by AddPoint(), MouseMove(), and PlotPointToScreen().
int TransferFunctionPlot::PlotValueToYCoord | ( | float | value | ) | const [protected] |
Converts a plot point value to a screen y coordinate.
[in] | value | the plot point value. |
Definition at line 376 of file TransferFunctionWidget.cpp.
Referenced by PlotPointToScreen().
bool TransferFunctionPlot::SelectPoint | ( | wxCoord | x, | |
wxCoord | y | |||
) | [protected] |
Tests if the given point intersects a plot point in the active plot.
[in] | x | the x position. |
[in] | y | the y position. |
Definition at line 438 of file TransferFunctionWidget.cpp.
Referenced by MouseLeftDown(), and RemovePoint().
int TransferFunctionPlot::SelectPoint | ( | wxCoord | x, | |
wxCoord | y, | |||
const std::vector< PlotPoint > & | plot | |||
) | const [protected] |
Tests if the given point intersects a plot point in the given plot.
[in] | x | the x position. |
[in] | y | the y position. |
[in] | plot | the plot. |
Definition at line 451 of file TransferFunctionWidget.cpp.
References Inside(), PlotPointToScreen(), ScreenRect::x1, ScreenRect::x2, ScreenRect::y1, and ScreenRect::y2.
void TransferFunctionPlot::AddPoint | ( | wxCoord | x, | |
wxCoord | y | |||
) | [protected] |
Adds a point at the given position.
[in] | x | the x position. |
[in] | y | the y position. |
Definition at line 473 of file TransferFunctionWidget.cpp.
References PlotDataValueToXCoord(), RefreshListner(), and ScreenToPlotPoint().
Referenced by MouseLeftDown().
void TransferFunctionPlot::RemovePoint | ( | wxCoord | x, | |
wxCoord | y | |||
) | [protected] |
Removes a point at the given position (if one exists).
[in] | x | the x position. |
[in] | y | the y position. |
Definition at line 505 of file TransferFunctionWidget.cpp.
References RefreshListner(), and SelectPoint().
Referenced by MouseLeftDown().
bool TransferFunctionPlot::LoadPlot | ( | std::ifstream & | file, | |
std::vector< PlotPoint > & | plot, | |||
int | n | |||
) | [protected] |
Reads plot points from a file and places them in a plot.
[in] | file | the file to read from. |
[out] | plot | the plot where read data will be stored. |
[in] | n | the number of plot points to read from the file. |
Definition at line 658 of file TransferFunctionWidget.cpp.
References PlotPoint::dataValue, and PlotPoint::value.
Referenced by Load().
void TransferFunctionPlot::SavePlot | ( | std::ofstream & | file, | |
const std::vector< PlotPoint > & | plot | |||
) | [protected] |
Saves plot points to a file.
[in] | file | the file to write to. |
[in] | plot | the plot to save. |
Definition at line 681 of file TransferFunctionWidget.cpp.
Referenced by Save().