Fl_PlotXY V1.0.13

Copyright 2004-2005 Michael Pearce
Document Started: 7 July 2004
Last Updated: 18 April 2005

class Fl_PlotXY



Class Hierarchy

Include Files

Description

This widget draws a box and then lets you add up to 10 seperate lines of X,Y plot data.

Features Include:
   Multiplule Lines (Max 10 Lines - set by a #define)
   Dot or solid line display
   Each line scale and colour selectable
   Load of CSV format file
   Save line as CSV format file
   Editing of stored data
   Auto scaling
   Manual scaling (used to zoom etc)

Methods

Fl_PlotXY::Fl_PlotXY(int x,int y,int w,int h,const char *label = 0);

The constructor creates the plotting area using the position, size, and label.

Fl_PlotXY::~Fl_PlotXY(void);

The destructor removes the plotting area.

int Fl_PlotXY::add(int line,double X, double Y)

Adds new X,Y data to end of selected line.

int Fl_PlotXY::axisfontface(void)
void Fl_PlotXY::axisfontface(int face)

The first method reads the current axis value font face. The second method sets the axis value font face.
FLTK values such as FL_HELVETICA, FL_COURIER can be used.

int Fl_PlotXY::axisfontsize(void)
void Fl_PlotXY::axisfontsize(int size)

The first form returns the font size in points. The second form sets the axis value font size.

int Fl_PlotXY::axistextspacex(void)
void Fl_PlotXY::axistextspacex(int space)

The first form reads the height in pixels used for the X axis value text. The second form sets the height in pixels to use for the X axis value text.

int Fl_PlotXY::axistextspacey(void)
void Fl_PlotXY::axistextspacey(int space)

The first form reads the width in pixels used for the Y axis value text. The second form sets the width in pixels to use for the Y axis value text.

int Fl_PlotXY::change(int line, unsigned long int point, double X, double Y);

Changes a point's values on the specified line.
Returns 1 on success, 0 on error

void Fl_PlotXY::clear(int line)

Clears the data set in line.

void Fl_PlotXY::clearall(void)

Clears data on ALL lines

unsigned long intFl_PlotXY::datasize(int line)

returns the current size of data in the selected line

int Fl_PlotXY::drawmode(int line, int Mode)

Sets the line drawing mode.
Valid modes are:
FL_PLOTXY_LINE - Draw using solid lines
FL_PLOTXY_DOT - Draw using single pixel points
Returns 1 on sucess, 0 on error.

int Fl_PlotXY::getrange(int,double* X1,double* Y2,double* X1,double* Y1)

Gets the current range of data displayed.
If FL_PLOTXY_AUTO mode used then is the values returned by the autoscaler.
If FL_PLOTXY_FIXED mode is used then returns the stored values.
Returns 1 on sucess, 0 in error and range values in X1,Y1,X2,Y2

Fl_Color linecolor(int line);
int Fl_PlotXY::linecolor(int line,Fl_Color C)

The first form returns the current colour for the selected line.
The second form sets the line colour to use.
Returns 1 on sucess, 0 on error.

int Fl_PlotXY:: linehide(int line)

Sets selected line so data is not displayed.
Returns 1 if done , 0 if error.

int Fl_PlotXY:: lineshow(int line)

Sets selected line to display data.
Returns 1 if done , 0 if error.

int Fl_PlotXY:: linetitle(int line, const char* title)
const char* Fl_PlotXY:: linetitle(int line)

The first form sets the title for seelcted line. Returns 1 if done , 0 if error.
The second form returns the pointer to the title, or NULL in error.

int Fl_PlotXY:: linevisible(int line)

Checks if line is currently displayed.
Returns 1 if visable, 0 if not, and -1 in error.

int Fl_PlotXY::load(const char *FileName)

Loads CSV formated data from FileName into a new line.
Not very smart at the moment - data needs to have no white spaces!
Any non numerical characters are treated as text and that line will be skipped.
Returns Line Descriptor on success, -1 on error

int Fl_PlotXY::loadxyyy(const char *FileName)

Loads CSV formated data from FileName to the graph.
First line in the file is comma seperated line titles. first column is not read.
Second line is Axis labels for Data. First column is X axis title, remaining columns are Y axis labels.
First Column is the X Data for all lines, the following columns are lines data.
Removes all lines on graph then reads csv file in form X,Y1,Y2....Yn
First line of csv file is treated as axis labels for the data.
Any non numerical characters are treated as text and that line will be skipped.
Returns 1 on success, 0 on error

int newline(void)
int Fl_PlotXY::newline(double X1, double Y1, double X2, double Y2,int mode, Fl_Color C, const char *label)

The first form creates a new line with default settings range=0,0,0,0 mode=FL_POTXY_AUTO Color=FL_BLACK label="".

The second form creates a new line with custom settings.
X1,Y1,X2,Y2 define the displayed data range.
mode selects Fixed or auto scaling of data using FL_PLOTXY_AUTO or FL_PLOTXY_FIXED.
C selects the colour to use for the data line
label selects the label to use for the line and CSV output (NOT IMPLIMENTED YET)

Both forms return the Line Descriptor to use or -1 if an error occurs.

int Fl_PlotXY::read (int line,unsigned long int point ,double* X,double* Y)

Reads X,Y from specified point on specified line.
Returns 1 on sucess, 0 on error and values in X and Y

void Fl_PlotXY::remove(int line)

Removes a line - frees it up for use.

void Fl_PlotXY::removeall(void)

Removes all lines - frees all lines for use.

int Fl_PlotXY::save(int line, const char *FileName)

Saves selected line data as CSV format to FileName
Returns 1 on success, 0 on error

int Fl_PlotXY::savexyyy(const char *FileName)

Saves all data as CSV format X,Y1,Y2...Yn to FileName
Returns 1 on success, 0 on error

int Fl_PlotXY::scalemode(int line, int mode)

Sets the scaling mode for selected line.
Valid modes are:
FL_PLOTXY_AUTO - Auto scales the data using Min and Max values in data set.
FL_PLOTXY_FIXED - Scales data according to range stored in line settings.
Returns 1 on success, 0 on error.

int Fl_PlotXY::setrange(int line ,double X1,double Y1,double X2,double Y2);

Set the range of data to display. Can be used to "Zoom" an area of the data.
Returns 1 on success, 0 on error.
Note: Not active unless scalemode(line,FL_PLOTXY_FIXED) is set.

int Fl_PlotXY::used(int line)

Indicates if line is in use.
Returns 1 if currently used, 0 if not in use

const char * Fl_PlotXY::version(void)

Returns pointer to widget version string in format "Vx.x.x"

void Fl_PlotXY::vlineenable(int e)
int Fl_PlotXY::vlineenable(void)

The first form enables (1) or disables (0) the vertical line.
The second form returns 0 if disabled and 1 if enabled.

void Fl_PlotXY::vlinesel(int l)
int Fl_PlotXY::vlinesel(void)

The first form selects the graph line to display data value on.
The second form returns the line that data is being displayed on.

void Fl_PlotXY::vlinepos(unsigned long int p)
unsigned long int Fl_PlotXY::vlinepos(void)

The first form sets the position in the data array to display data.
The second form returns the position that is being displayed.

int Fl_PlotXY::xmarklabel(int line, const char* label)
const char* Fl_PlotXY::xmarklabel(int line)

The first form sets the X Axis Label for line.
The second form returns the X Axis Label.

int Fl_PlotXY::xmarkon(int line)
int Fl_PlotXY::xmarkon(int line ,int mode)

The first form returns the state of the line markings.
The second form sets the state of the markings using the following mode values:
FL_PLOTXY_MARK_OFF - Turns Graduations etc OFF
FL_PLOTXY_MARK_ON - Show Y Graduations
FL_PLOTXY_MARK_LABEL - Show Axis Label
FL_PLOTXY_MARK_VAL - Show Axis Values
FL_PLOTXY_MARK_NAME - Show Lines NAME
Note: These can be OR'ed together.

int Fl_PlotXY::xmarkstep(int line, double step)

Sets the size between indicator marks.

int Fl_PlotXY::xvalformat(int line, int whole ,int points)

Sets the format of the X axis number values. Equivalent to "%0whole.0pointslf".
'whole' sets the number of whole numbers to display, including leading zeros.
'points' sets the number of decimal places to show, including following zeros.
'whole' and 'points' must be in the range 0 to 9.

int Fl_PlotXY::xvaltype(int line ,int mode)
int Fl_PlotXY::xvaltype(int line)

The first form sets the type of data to be displayed.
The second form returns the type of data displayed.
Options are:
FL_PLOTXY_VAL_NUMBER - Displays Number using %0.03lf format Number */
FL_PLOTXY_VAL_TIMES - Displays time in format SS
FL_PLOTXY_VAL_TIMEMS - Displays time in format MM:SS
FL_PLOTXY_VAL_TIMEHMS - Displays time in format HH:MM:SS
FL_PLOTXY_VAL_TIMEHM - Displays time in format HH:MM
FL_PLOTXY_VAL_TIMEh - Displays time in format hh
FL_PLOTXY_VAL_TIMESh - Displays time in format SS.hh
FL_PLOTXY_VAL_TIMEMSh - Displays time in format MM:SS.hh
FL_PLOTXY_VAL_TIMEHMSh - Displays time in format HH:MM:SS.hh
Note: Time formats require data to be in Seconds i.e. 1 minute = 60, 1 hour = 3600.

int Fl_PlotXY::ymarklabel(int line, const char* label)
const char * Fl_PlotXY::ymarklabel(int line)

The first form sets the Y Axis Label for line.
The second form returns the Y Axis Label - or NULL.

int Fl_PlotXY::ymarkon(int line)
int Fl_PlotXY::ymarkon(int line, int mode)

The first form returns the state of the line markings.
The second form sets the state of the markings using the following mode values:
FL_PLOTXY_MARK_OFF - Turns Graduations etc OFF
FL_PLOTXY_MARK_ON - Show Y Graduations
FL_PLOTXY_MARK_LABEL - Show Axis Label
FL_PLOTXY_MARK_VAL - Show Axis Values
FL_PLOTXY_MARK_NAME - Show Lines NAME
Note: These can be OR'ed together.

int Fl_PlotXY::ymarkstep(int line, double step)

Sets the size between indicator marks.

int Fl_PlotXY::yvalformat(int line, int whole ,int points)

Sets the format of the Y axis number values. Equivalent to "%0whole.0pointslf".
'whole' sets the number of whole numbers to display, including leading zeros.
'points' sets the number of decimal places to show, including following zeros.
'whole' and 'points' must be in the range 0 to 9.

int Fl_PlotXY::yvaltype(int line,int mode)
int Fl_PlotXY::yvaltype(int line)

The first form sets the type of data to be displayed.
The second form returns the type of data displayed.
Options are:
FL_PLOTXY_VAL_NUMBER - Displays Number using %0.03lf format Number */
FL_PLOTXY_VAL_TIMES - Displays time in format SS
FL_PLOTXY_VAL_TIMEMS - Displays time in format MM:SS
FL_PLOTXY_VAL_TIMEHMS - Displays time in format HH:MM:SS
FL_PLOTXY_VAL_TIMEHM - Displays time in format HH:MM
FL_PLOTXY_VAL_TIMEh - Displays time in format hh
FL_PLOTXY_VAL_TIMESh - Displays time in format SS.hh
FL_PLOTXY_VAL_TIMEMSh - Displays time in format MM:SS.hh
FL_PLOTXY_VAL_TIMEHMSh - Displays time in format HH:MM:SS.hh
Note: Time formats require data to be in Seconds.
e.g 2 Hours 4 minutes and 24 seconds = 2 x 3600 + 4 x 60 + 24 = 7464 seconds



Future plans

Following are possible future additions - ideas and comments welcome.
  • Add line labels.
  • Add axis grids / cross hairs.
  • Improve loading and saving to handle things such as date, time etc and to be less fussy.

    Known Problems

    Following are the known problems - please report any others you may find
  • File loading is very fussy - no white spaces allowed - will be working on this.
  • Crash can occur if try to display non existant data - need to add some more error traping.


    All content Copyright 2004 Michael Pearce All Rights Reserved.
    Email: mike AT kiwacan DOT co DOT nz
    Web: http://www.kiwacan.co.nz/fltk/fltk.html