Return to Index

Graph

Parent class: Canvas

A 2-D plotting widget that draws plots. It provides zooming and auto-scaling capabilites, and can also automatically calculate appropriate grid line and tick mark spacings. It also provides two X-Y cursors. They can be locked to a specified plot.
Note: Modifying a plot's rendering properties, or other graphing widget properties may require calling the redraw() method to realize the changes on the screen.


Object Events:
CursorMovedAn event indicating the movement of a cursor.
RangeChangedAn event generated when the domain or codomain of the graph change.

Method Summary:
Graph::Graph();
PlotId Graph::plotData(PlotId id, PointF* points, int count);
PlotId Graph::plotData(PlotId id, double* xvals, double* yvals, int count);
PlotId Graph::plotData(PlotId id, const Vector& points, const Vector& points, int count);
PlotId Graph::plotData(PlotId id, const Vector& points, int count);
Color Graph::disable(PlotId id);
Color Graph::getPlotColor(PlotId id);
void Graph::setPlotColor(PlotId id, const Color& pColor);
int Graph::getThickness(PlotId id);
void Graph::setThickness(PlotId id, int pPixels);
void Graph::setStyle(PlotId id, PlotStyle pStyle);
PlotStyle Graph::getStyle(PlotId id);
bool Graph::isVisible(PlotId id);
void Graph::setVisible(PlotId id, bool pShow);
String Graph::getFileName(PlotId id);
bool Graph::save(PlotId id);
bool Graph::saveAs(PlotId id, const String& fn);
bool Graph::load(PlotId id, const String& fn);
void Graph::setX(PlotId id, int i, double x);
void Graph::setY(PlotId id, int i, double y);
PointF Graph::get(PlotId id, int i);
void Graph::set(PlotId id, int i, double x, double y);
void Graph::set(PlotId id, int i, const PointF& p);
int Graph::getCount(PlotId id);
void Graph::autoScale();
void Graph::autoScaleToPlot(PlotId id, ScalingType (=BOTH) scaling);
void Graph::zoomIn();
void Graph::zoomOut();
bool Graph::setXRange(double min, double max);
bool Graph::setYRange(double min, double max);
void Graph::setCursorVisible(CursorId cid, bool v);
bool Graph::isCursorVisible(int c);
PointF Graph::getCursorPos(int c);
void Graph::lockCursor(CursorId id, PlotId id, bool interpolate);
void Graph::unlockCursor(CursorId id);
double Graph::getXMin();
double Graph::getXMax();
double Graph::getYMin();
double Graph::getXMax();
void Graph::setXLabel(const String& s);
void Graph::setYLabel(const String& s);
void Graph::drawTicksAsDottedLines(bool b);
void Graph::setAutoCalculateGrid(bool b);
void Graph::setTicksPerDivX(int i);
void Graph::setTicksPerDivY(int i);
void Graph::setGridSpacingX(double i);
void Graph::setGridSpacingY(double i);



Graph::Graph
Graph::Graph();

Constructs a new graphing widget.

PlotId Graph::plotData
PlotId Graph::plotData(PlotId id, PointF* points, int count);

Plots the given data points using the specified styling, and returns the plot identifier.
Parameters:
PlotId idThe plot identifier. Can be NEW_PLOT to create a new plot the next available identifier.
PointF* pointsThe data points in x-y coordinates.
int countThe number of data points.

PlotId Graph::plotData
PlotId Graph::plotData(PlotId id, double* xvals, double* yvals, int count);

Plots the given data points using the specified styling, and returns the plot identifier.
Parameters:
PlotId idThe plot identifier. Can be NEW_PLOT to create a new plot the next available identifier.
double* xvalsAn array of X coordinates.
double* yvalsAn array of Y coordinates.
int countThe number of data points.

PlotId Graph::plotData
PlotId Graph::plotData(PlotId id, const Vector& points, const Vector& points, int count);

Plots the given data points using the specified styling, and returns the plot identifier.
Parameters:
PlotId idThe plot identifier. Can be NEW_PLOT to create a new plot the next available identifier.
const Vector& pointsThe vector of X coordinates.
const Vector& pointsThe vector of Y coordinates.
int countThe number of data points.

PlotId Graph::plotData
PlotId Graph::plotData(PlotId id, const Vector& points, int count);

Plots the given data points using the specified styling, and returns the plot identifier.
Parameters:
PlotId idThe plot identifier. Can be NEW_PLOT to create a new plot the next available identifier.
const Vector& pointsThe vector of X-Y coordinates.
int countThe number of data points.

Color Graph::disable
Color Graph::disable(PlotId id);

Disables the specified plot.
Parameters:
PlotId idThe plot identifier.

Color Graph::getPlotColor
Color Graph::getPlotColor(PlotId id);

Returns the rendering color of the plot.
Parameters:
PlotId idThe plot identifier.

void Graph::setPlotColor
void Graph::setPlotColor(PlotId id, const Color& pColor);

Sets the rendering color of the plot.
Parameters:
PlotId idThe plot identifier.
const Color& pColorThe color.

int Graph::getThickness
int Graph::getThickness(PlotId id);

Returns the current thickness with which the plot is rendered.
Parameters:
PlotId idThe plot identifier.

void Graph::setThickness
void Graph::setThickness(PlotId id, int pPixels);

Sets the line thickness of the plot.
Parameters:
PlotId idThe plot identifier.
int pPixelsThe thickness in pixels.

void Graph::setStyle
void Graph::setStyle(PlotId id, PlotStyle pStyle);

Changes the way the plot is rendered.
Parameters:
PlotId idThe plot identifier.
PlotStyle pStyleThe new rendering style.

PlotStyle Graph::getStyle
PlotStyle Graph::getStyle(PlotId id);

Returns the current plot rendering style.
Parameters:
PlotId idThe plot identifier.

bool Graph::isVisible
bool Graph::isVisible(PlotId id);

Returns whether the plot is visible or not.
Parameters:
PlotId idThe plot identifier.

void Graph::setVisible
void Graph::setVisible(PlotId id, bool pShow);

Changes whether the specified plot is drawn on the graph or not.
Parameters:
PlotId idThe plot identifier.
bool pShowWhether the show the plot or not.

String Graph::getFileName
String Graph::getFileName(PlotId id);

Returns the file name of the plot. Returns an empty string if the plot has not been saved.
Parameters:
PlotId idThe plot identifier.

bool Graph::save
bool Graph::save(PlotId id);

Saves the specified plot to the current file name. If the plot has not been saved yet, the saveAs() method must be called first to set the file name.
Parameters:
PlotId idThe plot identifier.

bool Graph::saveAs
bool Graph::saveAs(PlotId id, const String& fn);

Saves the specified plot to the specified file name, and updates the plot's file name.
Parameters:
PlotId idThe plot identifier.
const String& fnThe file name.

bool Graph::load
bool Graph::load(PlotId id, const String& fn);

Loads plot data from the given file into the specified plot. Upon success it updates the file name.
Parameters:
PlotId idThe plot identifier.
const String& fnThe file name.

void Graph::setX
void Graph::setX(PlotId id, int i, double x);

Set the X-coordinate of the i-th point in the specified plot.
Parameters:
PlotId idThe plot identifier.
int iThe index of the point.
double xThe X-coordinate.

void Graph::setY
void Graph::setY(PlotId id, int i, double y);

Set the Y-coordinate of the i-th point in the specified plot.
Parameters:
PlotId idThe plot identifier.
int iThe index of the point.
double yThe Y-coordinate.

PointF Graph::get
PointF Graph::get(PlotId id, int i);

Returns the i-th point of the specified plot.
Parameters:
PlotId idThe plot identifier.
int iThe index of the point.

void Graph::set
void Graph::set(PlotId id, int i, double x, double y);

Sets the X and Y coordinates of the i-th point on the specified plot.
Parameters:
PlotId idThe plot identifier.
int iThe index of the point.
double xThe X-coordinate value.
double yThe Y-coordinate value.

void Graph::set
void Graph::set(PlotId id, int i, const PointF& p);

Sets the X and Y coordinates of the i-th point on the specified plot.
Parameters:
PlotId idThe plot identifier.
int iThe index of the point.
const PointF& pThe new point.

int Graph::getCount
int Graph::getCount(PlotId id);

Returns the number of points in the specified plot.
Parameters:
PlotId idThe plot identifier.

void Graph::autoScale
void Graph::autoScale();

Automatically computes the X and Y ranges so that all the graphs are visible simultaneously. It may be necessary to call the redraw() method to ensure that the changes are reflected on the screen.

void Graph::autoScaleToPlot
void Graph::autoScaleToPlot(PlotId id, ScalingType (=BOTH) scaling);

Automatically scales the graph to the given plot. The scaling may be along only one axis or both, specified by XAXIS, YAXIS, or BOTH.
Parameters:
PlotId idThe plot to scale the graph to.
ScalingType (=BOTH) scalingSpecifies the scaling axis.

void Graph::zoomIn
void Graph::zoomIn();

Zooms in on the graph.

void Graph::zoomOut
void Graph::zoomOut();

Zooms out on the graph.

bool Graph::setXRange
bool Graph::setXRange(double min, double max);

Changes the X-axis range to the specifed minimal and maximal values. This method returns false if the range was invalid, but otherwise generates a RangeChanged event and returns true.
Parameters:
double minThe minimum X value.
double maxThe maximum X value.

bool Graph::setYRange
bool Graph::setYRange(double min, double max);

Changes the Y-axis range to the specifed minimal and maximal values. This method returns false if the range was invalid, but otherwise generates a RangeChanged event and returns true.
Parameters:
double minThe minimum Y value.
double maxThe maximum Y value.

void Graph::setCursorVisible
void Graph::setCursorVisible(CursorId cid, bool v);

Changes the visiblity of the specified cursor. If the visibility of the cursor changes, a CursorVisibility is generated with the cursor id available from the Event::getId() method. There are four possible cursor ids: X1, Y1, X2, Y2.
Parameters:
CursorId cidSpecifies which cursor. (i.e. Graph::X1, or Graph::Y2)
bool vWhether to show the cursor or not.

bool Graph::isCursorVisible
bool Graph::isCursorVisible(int c);

Returns the visibility state of a cursor.
Parameters:
int cThe cursor id.

PointF Graph::getCursorPos
PointF Graph::getCursorPos(int c);

Returns the current position of a cursor.
Parameters:
int cThe cursor id.

void Graph::lockCursor
void Graph::lockCursor(CursorId id, PlotId id, bool interpolate);

Locks the specified cursor to the given plot.
Parameters:
CursorId idThe cursor id.
PlotId idThe plot id.
bool interpolateWhether to interpolate between points.

void Graph::unlockCursor
void Graph::unlockCursor(CursorId id);

Unlocks the specified cursor from any plot that it may be locked to.
Parameters:
CursorId idThe cursor id.

double Graph::getXMin
double Graph::getXMin();

Returns the minimum X-value of the x-axis range.

double Graph::getXMax
double Graph::getXMax();

Returns the maximum X-value of the x-axis range.

double Graph::getYMin
double Graph::getYMin();

Returns the minimum Y-value of the y-axis range.

double Graph::getXMax
double Graph::getXMax();

Returns the maximum Y-value of the y-axis range.

void Graph::setXLabel
void Graph::setXLabel(const String& s);

Changes the X-axis text label.
Parameters:
const String& sThe new label.

void Graph::setYLabel
void Graph::setYLabel(const String& s);

Changes the Y-axis text label.
Parameters:
const String& sThe new label.

void Graph::drawTicksAsDottedLines
void Graph::drawTicksAsDottedLines(bool b);

Changes whether tick marks are draw as full dotted lines or simply ticks along the axes.
Parameters:
bool bWhether to draw ticks as dotted lines or not.

void Graph::setAutoCalculateGrid
void Graph::setAutoCalculateGrid(bool b);

Sets whether the grid and tick spacing is calculated automatically.
Parameters:
bool bTo enable grid auto-calculation or not.

void Graph::setTicksPerDivX
void Graph::setTicksPerDivX(int i);

Sets how many tick marks there are between each grid line in the X direction.
Parameters:
int iThe number of divisions.

void Graph::setTicksPerDivY
void Graph::setTicksPerDivY(int i);

Sets how many tick marks there are between each grid line in the Y direction.
Parameters:
int iThe number of divisions.

void Graph::setGridSpacingX
void Graph::setGridSpacingX(double i);

Sets the interval at which grid lines are drawn in the X direction.
Parameters:
double iThe grid spacing.

void Graph::setGridSpacingY
void Graph::setGridSpacingY(double i);

Sets the interval at which grid lines are drawn in the Y direction.
Parameters:
double iThe grid spacing.


Generated automatically by docgen 0.0.1
© 2003 Aron Dobos