CGraphFont Class Reference

#include <GraphFont.h>

List of all members.


Detailed Description

Graph font drawing class.

Maintains the fonts and handles drawing strings onto FXDC surfaces.

Definition at line 51 of file GraphFont.h.


Public Member Functions

 CGraphFont ()
 Constructor.
 ~CGraphFont ()
 Destructor.
void buildFont (FXApp *a, bool hqaa, float nummultiplier)
 Initialises the FXDC fonts and measures the metrics.
int getPrecision (double d)
 Calculates the number of digits after the decimal point.
int getStringDimensions (FXString txt)
 Calculates the string length in pixels.
FXColor * drawAAString (FXString txt, int &length)
 Draws an antialiased string.
float * drawAAStringf (FXString txt, int &length)
 Draw a antialiased string then convert the result to a float array.
int getStringDimensions (double d, int precision=0)
 Calculates string length of a number with specified precision in pixels and rounds close-to-zero numbers to zero.
FXColor * drawAAString (double d, int &length, int precision=0)
 Draws the number as an antialiased string with specified precision and rounds close-to-zero numbers to zero.
float * drawAAStringf (double d, int &length, int precision=0)
 Draws the number as an antialiased string with specified precision and rounds close-to-zero numbers to zero then converts to a float array.
void initCairoMeasurements (cairo_t *c)
 Measure font metrics for the Cairo canvas.
float getStringDimensions (cairo_t *c, FXString txt)
 Calculates the string length in units.
float getStringDimensions (cairo_t *c, double d, int precision=0)
 Calculates string length of a number with specified precision in units and rounds close-to-zero numbers to zero.
void drawString (cairo_t *c, float x, float y, FXString txt)
 Draws an antialiased string to the Cairo surface.
void drawString (cairo_t *c, float x, float y, double d, int precision=0)
 Draws the number as an antialiased string to the Cairo surface with specified precision and rounds close-to-zero numbers to zero.

Public Attributes

FXFontDesc textFontdesc
FXFontDesc symFontdesc
int fontheight
int numfontheight
float cairofontheight
float cairobaselineheight
float caironumfontheight

Private Member Functions

FXString doubleToString (double d)
 Convert double to string.
FXString preciseString (double d, int precision)
 Pads a string so it has the specified number of digits after the decimal.

Private Attributes

FXFont * textFont
 Text font.
FXFont * symFont
 Symbol font.
FXFont * textSFont
 Text sup/sub font.
FXFont * symSFont
 Symbol sup/sub font.
FXFont * numFont
 Number font (slightly different size).
int fontbaseline
int fontSupbaseline
int fontSubbaseline
int numfontbaseline
float fontkernel [3][3]
 Gaussian AA kernel.
bool aamethod
 Antialiasing method: true == HQ, false == LQ.
float numfactor
 Number font enlargement factor.
float cairofontraise
float cairofontlower
FXApp * app
 Application object pointer.

Constructor & Destructor Documentation

CGraphFont::CGraphFont (  ) 

Constructor.

Creates the low quality antialiasing kernel.

Definition at line 1124 of file GraphFont.cpp.

References fontkernel, numFont, symFont, symSFont, textFont, and textSFont.

CGraphFont::~CGraphFont (  ) 

Destructor.

Deletes the font objects.

Definition at line 1156 of file GraphFont.cpp.

References numFont, symFont, symSFont, textFont, and textSFont.


Member Function Documentation

FXString CGraphFont::doubleToString ( double  d  )  [private]

Convert double to string.

Also returns 0 if abs(d) < ZEROERR.

Parameters:
d Value to convert.
Returns:
Converted string.

Definition at line 49 of file GraphFont.cpp.

References ZEROERR.

Referenced by getPrecision(), and preciseString().

Here is the caller graph for this function:

FXString CGraphFont::preciseString ( double  d,
int  precision 
) [private]

Pads a string so it has the specified number of digits after the decimal.

Remarks:
Should also work for numbers in mantissa exponent format.
Parameters:
d Value to convert.
precision Number of digits after the decimal
Returns:
String representing the number at the required accuracy.

Definition at line 75 of file GraphFont.cpp.

References doubleToString(), and getPrecision().

Referenced by drawAAString(), drawString(), and getStringDimensions().

Here is the call graph for this function:

Here is the caller graph for this function:

void CGraphFont::buildFont ( FXApp *  a,
bool  hqaa,
float  nummultiplier 
)

Initialises the FXDC fonts and measures the metrics.

Parameters:
a The application object.
hqaa High quality antialiasing setting, see CGraphFont::aamethod.
nummultiplier Number font size ratio.

Definition at line 1053 of file GraphFont.cpp.

References aamethod, app, fontbaseline, fontheight, fontSubbaseline, fontSupbaseline, numfactor, numFont, numfontbaseline, numfontheight, symFont, symFontdesc, symSFont, textFont, textFontdesc, and textSFont.

Referenced by GreyLabWindow::cmdBuildFont(), GreyLabWindow::cmdGSHiresSave(), GreyLabWindow::cmdLSHiresSave(), GreyLabWindow::cmdSelectNumberFont(), GreyLabWindow::cmdSelectSymbolFont(), GreyLabWindow::cmdSelectTextFont(), and GreyLabWindow::readSettings().

Here is the caller graph for this function:

int CGraphFont::getPrecision ( double  d  ) 

Calculates the number of digits after the decimal point.

Parameters:
d Value to analyse.
Returns:
Number of digits after the decimal point.

Definition at line 62 of file GraphFont.cpp.

References doubleToString().

Referenced by GreyLabWindow::cmdGSRedraw(), GreyLabWindow::cmdGSVectorRedraw(), GreyLabWindow::cmdLSRedraw(), GreyLabWindow::cmdLSVectorRedraw(), and preciseString().

Here is the call graph for this function:

Here is the caller graph for this function:

int CGraphFont::getStringDimensions ( FXString  txt  ) 

Calculates the string length in pixels.

Parameters:
txt String to measure.
Returns:
Width in pixels.

Definition at line 122 of file GraphFont.cpp.

References aamethod, symFont, symSFont, textFont, and textSFont.

Referenced by GreyLabWindow::cmdGSRedraw(), GreyLabWindow::cmdGSVectorRedraw(), GreyLabWindow::cmdLSRedraw(), GreyLabWindow::cmdLSVectorRedraw(), getStringDimensions(), HeightWinDialog::onGLRefresh(), and GreyLabWindow::renderString().

Here is the caller graph for this function:

FXColor * CGraphFont::drawAAString ( FXString  txt,
int &  length 
)

Draws an antialiased string.

Parameters:
txt Text to render.
[out] length Length of resulting string.
Returns:
Array of FXColor values containing the drawing with width length and height CGraphFont::numfontheight.

Definition at line 318 of file GraphFont.cpp.

References aamethod, app, fontbaseline, fontheight, fontkernel, fontSubbaseline, fontSupbaseline, symFont, symSFont, textFont, and textSFont.

Referenced by GreyLabWindow::cmdGSRedraw(), GreyLabWindow::cmdLSRedraw(), drawAAStringf(), and GreyLabWindow::renderString().

Here is the caller graph for this function:

float * CGraphFont::drawAAStringf ( FXString  txt,
int &  length 
)

Draw a antialiased string then convert the result to a float array.

Remarks:
See CGraphFont::drawAAString.
Returns:
Array of float values containing the drawing with width length and height CGraphFont::numfontheight.

Definition at line 631 of file GraphFont.cpp.

References drawAAString(), and fontheight.

Referenced by HeightWinDialog::onGLRefresh().

Here is the call graph for this function:

Here is the caller graph for this function:

int CGraphFont::getStringDimensions ( double  d,
int  precision = 0 
)

Calculates string length of a number with specified precision in pixels and rounds close-to-zero numbers to zero.

Remarks:
Should also work for numbers in mantissa exponent format.
Parameters:
d Value to measure.
precision Number of digits after the decimal
Returns:
Width in pixels.

Definition at line 105 of file GraphFont.cpp.

References aamethod, numFont, and preciseString().

Here is the call graph for this function:

FXColor * CGraphFont::drawAAString ( double  d,
int &  length,
int  precision = 0 
)

Draws the number as an antialiased string with specified precision and rounds close-to-zero numbers to zero.

Parameters:
d Number to render.
[out] length Length of resulting string.
precision Required number precision.
Returns:
Array of FXColor values containing the drawing with width length and height CGraphFont::numfontheight.

Definition at line 216 of file GraphFont.cpp.

References aamethod, app, fontkernel, numFont, numfontbaseline, numfontheight, and preciseString().

Here is the call graph for this function:

float * CGraphFont::drawAAStringf ( double  d,
int &  length,
int  precision = 0 
)

Draws the number as an antialiased string with specified precision and rounds close-to-zero numbers to zero then converts to a float array.

Remarks:
See CGraphFont::drawAAString.
Returns:
Array of float values containing the drawing with width length and height CGraphFont::numfontheight.

Definition at line 608 of file GraphFont.cpp.

References drawAAString(), and numfontheight.

Here is the call graph for this function:

void CGraphFont::initCairoMeasurements ( cairo_t *  c  ) 

Measure font metrics for the Cairo canvas.

Parameters:
c The Cairo canvas object.
Remarks:
Fills in internal class values.

Definition at line 1006 of file GraphFont.cpp.

References cairobaselineheight, cairofontheight, cairofontlower, cairofontraise, caironumfontheight, numfactor, symFontdesc, and textFontdesc.

Referenced by GreyLabWindow::cmdGSVectorRedraw(), and GreyLabWindow::cmdLSVectorRedraw().

Here is the caller graph for this function:

float CGraphFont::getStringDimensions ( cairo_t *  c,
FXString  txt 
)

Calculates the string length in units.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
c The Cairo canvas object.
txt String to measure.
Returns:
Width in units.

Definition at line 673 of file GraphFont.cpp.

References symFontdesc, and textFontdesc.

float CGraphFont::getStringDimensions ( cairo_t *  c,
double  d,
int  precision = 0 
)

Calculates string length of a number with specified precision in units and rounds close-to-zero numbers to zero.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
c The Cairo canvas object.
d Value to measure.
precision Number of digits after the decimal
Returns:
Width in units.

Definition at line 660 of file GraphFont.cpp.

References getStringDimensions(), and preciseString().

Here is the call graph for this function:

void CGraphFont::drawString ( cairo_t *  c,
float  x,
float  y,
FXString  txt 
)

Draws an antialiased string to the Cairo surface.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
c The Cairo canvas object.
x X position on the canvas.
y Y position on the canvas.
txt Text to render.

Definition at line 844 of file GraphFont.cpp.

References cairofontlower, cairofontraise, symFontdesc, and textFontdesc.

Referenced by GreyLabWindow::cmdGSVectorRedraw(), GreyLabWindow::cmdLSVectorRedraw(), and GreyLabWindow::renderString().

Here is the caller graph for this function:

void CGraphFont::drawString ( cairo_t *  c,
float  x,
float  y,
double  d,
int  precision = 0 
)

Draws the number as an antialiased string to the Cairo surface with specified precision and rounds close-to-zero numbers to zero.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
c The Cairo canvas object.
x X position on the canvas.
y Y position on the canvas.
d Number to render.
precision Required number precision.

Definition at line 822 of file GraphFont.cpp.

References numfactor, preciseString(), and textFontdesc.

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Mon Mar 10 13:55:45 2008 for GreyLab by  doxygen 1.5.3