libkpl  5.0
A Library for Graphical Presentation of Data Sets and Functions
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
PSGraph Class Reference

PS graphics class. More...

#include <psgraph.h>

Public Member Functions

 PSGraph (QTextStream *stream, const QList< QGraphicsItem * > &list, const QSizeF &size, bool landscape=false, bool eps=true)
 Constructor. More...
 
 PSGraph (QTextStream *stream, const QSizeF &size, const QPointF &topRight=QPointF(), const QPointF &bottomLeft=QPointF(), bool landscape=false, bool eps=true)
 Constructor. More...
 
 ~PSGraph ()
 Destructor. More...
 
void drawArray (const double *x, const double *y, double fx, double fy, int n, KplItem::FillStyle fillStyle=KplItem::NoBrush, double xOff=0, double yOff=0, bool clip=true)
 Plots array item. More...
 
void drawItems (const QList< QGraphicsItem * > &list)
 Plots items. More...
 
void drawText (const QString &text, double x, double y, TextItem::Alignment alignment=TextItem::AlignLeft)
 Plots text. More...
 
void finish ()
 Finishes plot. More...
 
void setColorData (unsigned color)
 Sets color for data plotting. More...
 
void setDir (double dir)
 Sets rotation angle. More...
 
double setRelSize (double m_relSize)
 Sets relative size of item. More...
 

Static Public Attributes

static const double pts
 Points per cm. More...
 

Protected Member Functions

void cm2r (double xcm, double ycm, double fx, double fy, double *xu, double *yu) const
 Converts from centimeters to user units. More...
 
void draw3D (ThreeDItem *item)
 Plots 3D item. More...
 
void drawArc (ArcItem *item)
 Plots arc item. More...
 
void drawArray (ArrayItem *item)
 Plots array item. More...
 
void drawArray3D (Array3DItem *item)
 Plots 3D array item. More...
 
void drawArrow (ArrowItem *item)
 Plots arrow item. More...
 
void drawEllipse (EllipseItem *item)
 Plots ellipse item. More...
 
void drawErrorBars (const double *x, const double *y, const double *errors, double fx, double fy, int n, double xOff=0, double yOff=0, bool clip=true)
 Plots error bars for array item. More...
 
void drawFrame (FrameItem *item)
 Plots frame item. More...
 
void drawFunc (FunItem *item)
 Plots function item. More...
 
void drawFunc3D (Fun3DItem *item)
 Plots 3D function item. More...
 
void drawImage (ImageItem *item)
 Plots image item. More...
 
void drawLegend (LegendItem *item)
 Plots legend item. More...
 
void drawLine (LineItem *item)
 Plots line item. More...
 
void drawParFunc (ParFunItem *item)
 Plots parametric function item. More...
 
void drawRect (RectItem *item)
 Plots rectangle item. More...
 
void drawScaleBar (ScaleBarItem *item)
 Plots scale bar item. More...
 
void drawSpline (SplineItem *item)
 Plots spline item. More...
 
void drawText (TextItem *item)
 Plots text item. More...
 
void labelX (const QString &text, int exp, bool xTop)
 Plots x axis label. More...
 
void labelY (const QString &text, int exp, bool yRight)
 Plots y axis label. More...
 
void prolog (bool landscape, bool eps, const QPointF &topRight=QPointF(), const QPointF &bottomLeft=QPointF())
 Writes PostScript prolog. More...
 
void psStr (const QString &text)
 Converts to PostScript string. More...
 
void resetDashOffset ()
 Resets offset for dashed lines. More...
 
void scale (double xMin, double xMax, double yMin, double yMax, bool logX=false, bool logY=false)
 Scales data window to user units. More...
 
void setColorFrame (unsigned color)
 Sets color for frame. More...
 
void setColorGrid (unsigned color)
 Sets color for grid and tics. More...
 
void setProperties (ScaledItem *item)
 Sets color and symbol type for array and function items. More...
 
void setSymbol (KplItem::Symbol symbol)
 Sets symbol type. More...
 
void window (double x0, double width, double y0, double height)
 Sets position and size of the data window. More...
 

Protected Attributes

bool m_logX
 
bool m_logY
 
KplItem::Symbol m_symbol
 
double m_x0
 
double m_y0
 
double m_width
 
double m_height
 
double m_xMin
 
double m_yMin
 
double m_xMax
 
double m_yMax
 
double m_relSize
 
QTextStreamts
 
QSizeF m_size
 

Detailed Description

PS graphics class.

Provides methods to generate PS and EPS output.

Author
Werner Stille

Constructor & Destructor Documentation

PSGraph::PSGraph ( QTextStream stream,
const QList< QGraphicsItem * > &  list,
const QSizeF size,
bool  landscape = false,
bool  eps = true 
)

Constructor.

Creates PS or EPS output of plot items.

Parameters
streampointer to output stream.
listlist of plot items.
sizemedia size in cm.
landscapetrue for landscape orientation.
epstrue for EPS, false for PS output.
PSGraph::PSGraph ( QTextStream stream,
const QSizeF size,
const QPointF topRight = QPointF(),
const QPointF bottomLeft = QPointF(),
bool  landscape = false,
bool  eps = true 
)

Constructor.

Writes PS prolog.

Parameters
streampointer to output stream.
sizemedia size in cm.
topRighttop-right coordinates of graphics rectangle in cm.
bottomLeftbottom-left coordinates of graphics rectangle in cm.
landscapetrue for landscape orientation.
epstrue for EPS, false for PS output.
PSGraph::~PSGraph ( )

Destructor.

Member Function Documentation

void PSGraph::cm2r ( double  xcm,
double  ycm,
double  fx,
double  fy,
double *  xu,
double *  yu 
) const
protected

Converts from centimeters to user units.

Parameters
xcmx value in centimeters.
ycmy value in centimeters.
fxnormalization factor for x values.
fynormalization factor for y values.
xupointer to x value in user units (output).
yupointer to y value in user units (output).
void PSGraph::draw3D ( ThreeDItem item)
protected

Plots 3D item.

Parameters
itempointer to item.
void PSGraph::drawArc ( ArcItem item)
protected

Plots arc item.

Parameters
itempointer to item.
void PSGraph::drawArray ( const double *  x,
const double *  y,
double  fx,
double  fy,
int  n,
KplItem::FillStyle  fillStyle = KplItem::NoBrush,
double  xOff = 0,
double  yOff = 0,
bool  clip = true 
)

Plots array item.

Parameters
xarray with x values.
yarray with y values.
fxnormalization factor for x values.
fynormalization factor for y values.
nnumber of data points.
fillStylefill style.
xOffoffset for x values.
yOffoffset for x values.
cliptrue for clipping.
void PSGraph::drawArray ( ArrayItem item)
protected

Plots array item.

Parameters
itempointer to item.
void PSGraph::drawArray3D ( Array3DItem item)
protected

Plots 3D array item.

Parameters
itempointer to item.
void PSGraph::drawArrow ( ArrowItem item)
protected

Plots arrow item.

Parameters
itempointer to item.
void PSGraph::drawEllipse ( EllipseItem item)
protected

Plots ellipse item.

Parameters
itempointer to item.
void PSGraph::drawErrorBars ( const double *  x,
const double *  y,
const double *  errors,
double  fx,
double  fy,
int  n,
double  xOff = 0,
double  yOff = 0,
bool  clip = true 
)
protected

Plots error bars for array item.

Parameters
xarray with x values.
yarray with y values.
errorsarray with y error values.
fxnormalization factor for x values.
fynormalization factor for y values.
nnumber of data points.
xOffoffset for x values.
yOffoffset for x values.
cliptrue for clipping.
void PSGraph::drawFrame ( FrameItem item)
protected

Plots frame item.

Parameters
itempointer to item.
void PSGraph::drawFunc ( FunItem item)
protected

Plots function item.

Parameters
itempointer to item.
void PSGraph::drawFunc3D ( Fun3DItem item)
protected

Plots 3D function item.

Parameters
itempointer to item.
void PSGraph::drawImage ( ImageItem item)
protected

Plots image item.

Parameters
itempointer to item.
void PSGraph::drawItems ( const QList< QGraphicsItem * > &  list)

Plots items.

Parameters
listlist of items.
void PSGraph::drawLegend ( LegendItem item)
protected

Plots legend item.

Parameters
itempointer to item.
void PSGraph::drawLine ( LineItem item)
protected

Plots line item.

Parameters
itempointer to item.
void PSGraph::drawParFunc ( ParFunItem item)
protected

Plots parametric function item.

Parameters
itempointer to item.
void PSGraph::drawRect ( RectItem item)
protected

Plots rectangle item.

Parameters
itempointer to item.
void PSGraph::drawScaleBar ( ScaleBarItem item)
protected

Plots scale bar item.

Parameters
itempointer to item.
void PSGraph::drawSpline ( SplineItem item)
protected

Plots spline item.

Parameters
itempointer to item.
void PSGraph::drawText ( const QString text,
double  x,
double  y,
TextItem::Alignment  alignment = TextItem::AlignLeft 
)

Plots text.

Parameters
texttext.
xx value in points.
yy value in points.
alignmenthorizontal alignment.
void PSGraph::drawText ( TextItem item)
protected

Plots text item.

Parameters
itempointer to item.
void PSGraph::finish ( )

Finishes plot.

void PSGraph::labelX ( const QString text,
int  exp,
bool  xTop 
)
protected

Plots x axis label.

Parameters
textlabel text.
explogarithm of normalization factor for x axis.
xToptrue for top side, false for bottom side label.
void PSGraph::labelY ( const QString text,
int  exp,
bool  yRight 
)
protected

Plots y axis label.

Parameters
textlabel text.
explogarithm of normalization factor for y axis.
yRighttrue for right side, false for left side label.
void PSGraph::prolog ( bool  landscape,
bool  eps,
const QPointF topRight = QPointF(),
const QPointF bottomLeft = QPointF() 
)
protected

Writes PostScript prolog.

Parameters
landscapetrue for landscape orientation.
epstrue for EPS, false for PS output.
topRightcoordinates of top-right corner in cm.
bottomLeftcoordinates of bottom-left corner in cm.
void PSGraph::psStr ( const QString text)
protected

Converts to PostScript string.

Parameters
texttext.
void PSGraph::resetDashOffset ( )
protected

Resets offset for dashed lines.

void PSGraph::scale ( double  xMin,
double  xMax,
double  yMin,
double  yMax,
bool  logX = false,
bool  logY = false 
)
protected

Scales data window to user units.

Parameters
xMinx value of left data window margin in user units.
xMaxx value of right data window margin in user units.
yMiny value of bottom data window margin in user units.
yMaxy value of top window data margin in user units.
logXtrue for logarithmic x scale.
logYtrue for logarithmic y scale.
void PSGraph::setColorData ( unsigned  color)

Sets color for data plotting.

Parameters
colorcolor.
void PSGraph::setColorFrame ( unsigned  color)
protected

Sets color for frame.

Parameters
colorcolor.
void PSGraph::setColorGrid ( unsigned  color)
protected

Sets color for grid and tics.

Parameters
colorcolor.
void PSGraph::setDir ( double  dir)

Sets rotation angle.

Parameters
dirrotation angle in deg.
void PSGraph::setProperties ( ScaledItem item)
protected

Sets color and symbol type for array and function items.

Parameters
itempointer to item.
double PSGraph::setRelSize ( double  m_relSize)

Sets relative size of item.

Parameters
m_relSizerelative size.
Returns
old relative size.
void PSGraph::setSymbol ( KplItem::Symbol  symbol)
protected

Sets symbol type.

Parameters
symbolsymbol type.
void PSGraph::window ( double  x0,
double  width,
double  y0,
double  height 
)
protected

Sets position and size of the data window.

Parameters
x0left page margin in centimeters.
widthwidth in centimeters.
y0bottom page margin in centimeters.
heightheight in centimeters.

Member Data Documentation

const double PSGraph::pts
static

Points per cm.


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