GClasses
|
This class makes it easy to plot points and functions on 2D cartesian coordinates. More...
#include <GPlot.h>
Public Member Functions | |
GPlotWindow (GImage *pImage, double xmin, double ymin, double xmax, double ymax) | |
pImage is the image onto which you wish to plot | |
~GPlotWindow () | |
void | windowToView (double x, double y, float *pX, float *pY) |
Convert from window (Euclidean space) coordinates to view (image) coordinates. | |
void | windowToView (double x, double y, int *pX, int *pY) |
Convert from window (Euclidean space) coordinates to view (image) coordinates. | |
void | viewToWindow (int x, int y, double *pX, double *pY) |
Convert from view (image) coordinates to window (Euclidean space) coordinates. | |
double | pixelWidth () const |
Returns the width represented by each pixel. | |
double | pixelHeight () const |
Returns the height represented by each pixel. | |
GImage * | image () |
Returns the image that was passed in to the constructor. | |
GDoubleRect * | window () |
Returns the rect of the Euclidean space that this image represents. | |
void | point (double x, double y, unsigned int col) |
Plots a single pixel. (Note that for most applications, PlotDot is a better choice because it draws a larger dot centered at the sub-pixel location that you specify.) | |
void | dot (double x, double y, float radius, unsigned int colFore, unsigned int colBack) |
Plots a dot at the specified location. You must specify both the foreground and background color so that it can make the dot appear to be centered at the precise sub-pixel location specified. radius is specified in pixels. | |
void | line (double x1, double y1, double x2, double y2, unsigned int col) |
Plots a line. | |
void | fatLine (double x1, double y1, double x2, double y2, float thickness, unsigned int col) |
Plots a fat line. | |
void | function (MathFunc pFunc, unsigned int col, void *pThis) |
Plots a function. | |
void | label (double x, double y, const char *szLabel, float size, unsigned int col) |
Draws a label at the specified location. (A size of 1.0f will be small but legible.) | |
void | arrow (double x1, double y1, double x2, double y2, unsigned int col, int headSize) |
Draws an arrow from (x1, y1) to (x2, y2). headSize is specified in pixels. | |
void | gridLines (int maxHorizAxisLabels, int maxVertAxisLabels, unsigned int col) |
Draw grid lines If maxHorizAxisLabels is 0, no grid lines will be drawn for the horizontal axis. If maxHorizAxisLabels is -1, a logarithmic scale will be used for the horizontal axis. Same with maxVertAxisLabels. | |
GImage * | labelAxes (int maxHorizAxisLabels, int maxVertAxisLabels, int precision, float size, unsigned int color, double angle) |
Copy the image onto a larger image, and label the axes on the larger image. If maxHorizAxisLabels is 0, no labels will be drawn for the horizontal axis. If maxHorizAxisLabels is -1, a logarithmic scale will be used for the horizontal axis. Same with maxVertAxisLabels. | |
Static Protected Member Functions | |
static void | stringLabel (GImage *pImage, const char *szText, int x, int y, float size, unsigned int color, double angle) |
static void | numericLabel (GImage *pImage, double value, int x, int y, int precision, float size, unsigned int color, double angle) |
Protected Attributes | |
GImage * | m_pImage |
GDoubleRect | m_window |
int | m_w |
int | m_h |
This class makes it easy to plot points and functions on 2D cartesian coordinates.
GClasses::GPlotWindow::GPlotWindow | ( | GImage * | pImage, |
double | xmin, | ||
double | ymin, | ||
double | xmax, | ||
double | ymax | ||
) |
pImage is the image onto which you wish to plot
GClasses::GPlotWindow::~GPlotWindow | ( | ) |
void GClasses::GPlotWindow::arrow | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2, | ||
unsigned int | col, | ||
int | headSize | ||
) |
Draws an arrow from (x1, y1) to (x2, y2). headSize is specified in pixels.
void GClasses::GPlotWindow::dot | ( | double | x, |
double | y, | ||
float | radius, | ||
unsigned int | colFore, | ||
unsigned int | colBack | ||
) |
Plots a dot at the specified location. You must specify both the foreground and background color so that it can make the dot appear to be centered at the precise sub-pixel location specified. radius is specified in pixels.
void GClasses::GPlotWindow::fatLine | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2, | ||
float | thickness, | ||
unsigned int | col | ||
) |
Plots a fat line.
void GClasses::GPlotWindow::function | ( | MathFunc | pFunc, |
unsigned int | col, | ||
void * | pThis | ||
) |
Plots a function.
void GClasses::GPlotWindow::gridLines | ( | int | maxHorizAxisLabels, |
int | maxVertAxisLabels, | ||
unsigned int | col | ||
) |
Draw grid lines If maxHorizAxisLabels is 0, no grid lines will be drawn for the horizontal axis. If maxHorizAxisLabels is -1, a logarithmic scale will be used for the horizontal axis. Same with maxVertAxisLabels.
GImage* GClasses::GPlotWindow::image | ( | ) | [inline] |
Returns the image that was passed in to the constructor.
void GClasses::GPlotWindow::label | ( | double | x, |
double | y, | ||
const char * | szLabel, | ||
float | size, | ||
unsigned int | col | ||
) |
Draws a label at the specified location. (A size of 1.0f will be small but legible.)
GImage* GClasses::GPlotWindow::labelAxes | ( | int | maxHorizAxisLabels, |
int | maxVertAxisLabels, | ||
int | precision, | ||
float | size, | ||
unsigned int | color, | ||
double | angle | ||
) |
Copy the image onto a larger image, and label the axes on the larger image. If maxHorizAxisLabels is 0, no labels will be drawn for the horizontal axis. If maxHorizAxisLabels is -1, a logarithmic scale will be used for the horizontal axis. Same with maxVertAxisLabels.
void GClasses::GPlotWindow::line | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2, | ||
unsigned int | col | ||
) |
Plots a line.
static void GClasses::GPlotWindow::numericLabel | ( | GImage * | pImage, |
double | value, | ||
int | x, | ||
int | y, | ||
int | precision, | ||
float | size, | ||
unsigned int | color, | ||
double | angle | ||
) | [static, protected] |
double GClasses::GPlotWindow::pixelHeight | ( | ) | const [inline] |
Returns the height represented by each pixel.
double GClasses::GPlotWindow::pixelWidth | ( | ) | const [inline] |
Returns the width represented by each pixel.
void GClasses::GPlotWindow::point | ( | double | x, |
double | y, | ||
unsigned int | col | ||
) |
Plots a single pixel. (Note that for most applications, PlotDot is a better choice because it draws a larger dot centered at the sub-pixel location that you specify.)
static void GClasses::GPlotWindow::stringLabel | ( | GImage * | pImage, |
const char * | szText, | ||
int | x, | ||
int | y, | ||
float | size, | ||
unsigned int | color, | ||
double | angle | ||
) | [static, protected] |
void GClasses::GPlotWindow::viewToWindow | ( | int | x, |
int | y, | ||
double * | pX, | ||
double * | pY | ||
) | [inline] |
Convert from view (image) coordinates to window (Euclidean space) coordinates.
GDoubleRect* GClasses::GPlotWindow::window | ( | ) | [inline] |
Returns the rect of the Euclidean space that this image represents.
void GClasses::GPlotWindow::windowToView | ( | double | x, |
double | y, | ||
int * | pX, | ||
int * | pY | ||
) | [inline] |
Convert from window (Euclidean space) coordinates to view (image) coordinates.
void GClasses::GPlotWindow::windowToView | ( | double | x, |
double | y, | ||
float * | pX, | ||
float * | pY | ||
) | [inline] |
Convert from window (Euclidean space) coordinates to view (image) coordinates.
int GClasses::GPlotWindow::m_h [protected] |
GImage* GClasses::GPlotWindow::m_pImage [protected] |
int GClasses::GPlotWindow::m_w [protected] |
GDoubleRect GClasses::GPlotWindow::m_window [protected] |