Home

Download

Features

Screenshots

Handbook

Browse Source

Authors

SourceForge.net Logo
Hosted by SourceForge.net

OSI Certified


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Search  

MathFunction Class Reference

An abstract class which is used by a BasicGraph to execute math functions such as definite integral, arc length, etc. In order to create your own math function, you must create a subclass of this which reimplements calculate_and_draw(QPainter *, QString *), and as the name implies, calculates the result of the function and writes what you wish to display as the result in the given QString pointer. An example of this could be "Distance = 1.44" when calculating distance. Also, a pointer to a QPainter is given which allows you to draw a visual of the function calculated. This could shade the area underneath a curve for definite integral, for example. More...

#include <mathfunction.h>

Inheritance diagram for MathFunction:

Inheritance graph
[legend]
Collaboration diagram for MathFunction:

Collaboration graph
[legend]
List of all members.

Public Methods

 MathFunction (BasicGraph *=0, int expressions=0)
virtual ~MathFunction ()
virtual void calculate_and_draw (QPainter *)
 When creating a math function subclass, overwrite this function to calculate and then draw whatever visual you wish using the given QPainter.

virtual void draw_stored (QPainter *p)
 When creating a math function subclass, overwrite this function with a function to more quickly draw the result of the function.

int expressionsRequired ()
 Call this function to begin determining function.

void exec (FungParser *fp=0, FungParser *fp2=0)
void drawFunction (QPainter *)
bool active ()
void sendClick (QMouseEvent *e, double arg=0, double arg2=0)
void cancel ()

Protected Methods

void setResult (QString &s)
 Sets the string that will be displayed as the result of the function.

int toPixelXCoord (double x_coordinate)
int toPixelYCoord (double y_coordinate)
double toGraphXCoord (double x_coordinate)
double toGraphYCoord (double y_coordinate)
double animatorValue ()
void drawSelectedPoint (double x, double y, QPainter *painter)
 Draws a horizontal and vertical line going through the point (x,y) as well as a small box at this point.


Protected Attributes

QPoint lowerBounds
QPoint upperBounds
double arg1
double arg2
double beta
double arg1x
double arg2x
double arg1y
double arg2y
double beta2
int expression_count
FungParserexpression
 This variable is available to subclasses to use for calculating the value of a function with.

FungParserexpression2
BasicGraphbasicgraph
 This is provided in the case that you will need information from the BasicGraph such as its height/width or something else it provides.


Detailed Description

An abstract class which is used by a BasicGraph to execute math functions such as definite integral, arc length, etc. In order to create your own math function, you must create a subclass of this which reimplements calculate_and_draw(QPainter *, QString *), and as the name implies, calculates the result of the function and writes what you wish to display as the result in the given QString pointer. An example of this could be "Distance = 1.44" when calculating distance. Also, a pointer to a QPainter is given which allows you to draw a visual of the function calculated. This could shade the area underneath a curve for definite integral, for example.

Author:
Fungmeista

Definition at line 42 of file mathfunction.h.


Member Function Documentation

virtual void MathFunction::calculate_and_draw QPainter *    [inline, virtual]
 

When creating a math function subclass, overwrite this function to calculate and then draw whatever visual you wish using the given QPainter.

You should also call the function setResult() inside this function and pass to it a string that you wish to be displayed as the result of the function.

Reimplemented in DefiniteIntegralFunction, DistanceFunction, MaximumFunction, MeanValueFunction, and MinimumFunction.

Definition at line 53 of file mathfunction.h.

Referenced by draw_stored().

virtual void MathFunction::draw_stored QPainter *    p [inline, virtual]
 

When creating a math function subclass, overwrite this function with a function to more quickly draw the result of the function.

For example, if calculate_and_draw calculates many points, these can be saved and drawn in draw_stored instead of recalculating them.

Reimplemented in DefiniteIntegralFunction, DistanceFunction, MaximumFunction, MeanValueFunction, and MinimumFunction.

Definition at line 59 of file mathfunction.h.

References calculate_and_draw().

int MathFunction::expressionsRequired   [inline]
 

Call this function to begin determining function.

After calling this function you will be asked to enter a lower bounds, then an upper bounds, and then the result will be displayed which is determined by your calculate_and_draw() function. You may passed a pointer to a parsed expression which will be stored in the "expression" variable and can be used in determining the value of the function.

Definition at line 68 of file mathfunction.h.

Referenced by FunctionGraph::execMathFunction().

double MathFunction::toGraphXCoord double    x_coordinate [protected]
 

Parameters:
y_coordinate  A y-direction coordinate in the coordinate system of the underlying QWidget.
Returns :
A number that is in the coordinate system of the graph in the y direction.
Note:
When drawing onto the given QPainter it takes actual pixel coordinates where the bottom left is the x-y coordinate (0,0).

Definition at line 58 of file mathfunction.cpp.

References basicgraph, and BasicGraph::toGraphXCoord().

Referenced by MinimumFunction::calculate_and_draw(), MeanValueFunction::calculate_and_draw(), MaximumFunction::calculate_and_draw(), and DefiniteIntegralFunction::calculate_and_draw().

double MathFunction::toGraphYCoord double    y_coordinate [protected]
 

Parameters:
x_coordinate  A x-direction coordinate in the coordinate system of the underlying QWidget.
Returns :
A number that is in the coordinate system of the graph in the x direction.
Note:
When drawing onto the given QPainter it takes actual pixel coordinates where the bottom left is the x-y coordinate (0,0).

Definition at line 63 of file mathfunction.cpp.

References basicgraph, and BasicGraph::toGraphYCoord().

Referenced by MeanValueFunction::calculate_and_draw().

int MathFunction::toPixelXCoord double    x_coordinate [protected]
 

Parameters:
x_coordinate  A y-direction coordinate in the coordinate system of the graph
Returns :
A number that is in the coordinate system of the underlying QWidget in the x direction.
Note:
When drawing onto the given QPainter it takes actual pixel coordinates where the bottom left is the x-y coordinate (0,0).

Definition at line 48 of file mathfunction.cpp.

References basicgraph, and BasicGraph::toPixelXCoord().

Referenced by MeanValueFunction::calculate_and_draw(), and drawSelectedPoint().

int MathFunction::toPixelYCoord double    y_coordinate [protected]
 

Parameters:
y_coordinate  A x-direction coordinate in the coordinate system of the graph
Returns :
A number that is in the coordinate system of the underlying QWidget in the x direction.
Note:
When drawing onto the given QPainter it takes actual pixel coordinates where the bottom left is the x-y coordinate (0,0).

Definition at line 53 of file mathfunction.cpp.

References basicgraph, and BasicGraph::toPixelYCoord().

Referenced by MeanValueFunction::calculate_and_draw(), DefiniteIntegralFunction::calculate_and_draw(), and drawSelectedPoint().


Member Data Documentation

FungParser* MathFunction::expression [protected]
 

This variable is available to subclasses to use for calculating the value of a function with.

It is automatically stored in this variable for use in the functions draw_and_calculate() and draw_stored().

Definition at line 90 of file mathfunction.h.

Referenced by MinimumFunction::calculate_and_draw(), MeanValueFunction::calculate_and_draw(), MaximumFunction::calculate_and_draw(), and DefiniteIntegralFunction::calculate_and_draw().


The documentation for this class was generated from the following files: