GClasses
GClasses::GPlotWindow Class Reference

Detailed Description

This class makes it easy to plot points and functions on 2D cartesian coordinates.

#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 More...
 
 ~GPlotWindow ()
 
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. More...
 
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. More...
 
void fatLine (double x1, double y1, double x2, double y2, float thickness, unsigned int col)
 Plots a fat line. More...
 
void function (MathFunc pFunc, unsigned int col, void *pThis)
 Plots a function. More...
 
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. More...
 
GImageimage ()
 Returns the image that was passed in to the constructor. More...
 
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.) More...
 
GImagelabelAxes (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. More...
 
void line (double x1, double y1, double x2, double y2, unsigned int col)
 Plots a line. More...
 
double pixelHeight () const
 Returns the height represented by each pixel. More...
 
double pixelWidth () const
 Returns the width represented by each pixel. More...
 
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.) More...
 
void viewToWindow (int x, int y, double *pX, double *pY)
 Convert from view (image) coordinates to window (Euclidean space) coordinates. More...
 
GDoubleRectwindow ()
 Returns the rect of the Euclidean space that this image represents. More...
 
void windowToView (double x, double y, float *pX, float *pY)
 Convert from window (Euclidean space) coordinates to view (image) coordinates. More...
 
void windowToView (double x, double y, int *pX, int *pY)
 Convert from window (Euclidean space) coordinates to view (image) coordinates. More...
 

Static Protected Member Functions

static void numericLabel (GImage *pImage, double value, int x, int y, int precision, float size, unsigned int color, double angle)
 
static void stringLabel (GImage *pImage, const char *szText, int x, int y, float size, unsigned int color, double angle)
 

Protected Attributes

int m_h
 
GImagem_pImage
 
int m_w
 
GDoubleRect m_window
 

Constructor & Destructor Documentation

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 ( )

Member Function Documentation

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 
)
staticprotected
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 
)
staticprotected
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,
float *  pX,
float *  pY 
)
inline

Convert from window (Euclidean space) coordinates to view (image) coordinates.

void GClasses::GPlotWindow::windowToView ( double  x,
double  y,
int *  pX,
int *  pY 
)
inline

Convert from window (Euclidean space) coordinates to view (image) coordinates.

Member Data Documentation

int GClasses::GPlotWindow::m_h
protected
GImage* GClasses::GPlotWindow::m_pImage
protected
int GClasses::GPlotWindow::m_w
protected
GDoubleRect GClasses::GPlotWindow::m_window
protected