Logo Search packages:      
Sourcecode: pcp-gui version File versions

QwtPlot Class Reference

#include <qwt_plot.h>

Inheritance diagram for QwtPlot:

QwtPlotDict

List of all members.


Detailed Description

A 2-D plotting widget.

QwtPlot is a widget for plotting two-dimensional graphs. An unlimited number of plot items can be displayed on its canvas. Plot items might be curves (QwtPlotCurve), markers (QwtPlotMarker), the grid (QwtPlotGrid), or anything else derived from QwtPlotItem. A plot can have up to four axes, with each plot item attached to an x- and a y axis. The scales at the axes can be explicitely set (QwtScaleDiv), or are calculated from the plot items, using algorithms (QwtScaleEngine) which can be configured separately for each axis.

plot.png

Example
The following example shows (schematically) the most simple way to use QwtPlot. By default, only the left and bottom axes are visible and their scales are computed automatically.
#include <qwt_plot.h>
#include <qwt_plot_curve.h>

QwtPlot *myPlot;
double x[100], y1[100], y2[100];        // x and y values

myPlot = new QwtPlot("Two Curves", parent);

// add curves
QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2");

getSomeValues(x, y1, y2);

// copy the data into the curves
curve1->setData(x, y1, 100);
curve2->setData(x, y2, 100);

curve1->attach(myPlot);
curve2->attach(myPlot);

// finally, refresh the plot
myPlot->replot();

Definition at line 77 of file qwt_plot.h.


Public Types

enum  Axis {
  yLeft, yRight, xBottom, xTop,
  axisCnt
}
 Axis index.
enum  LegendPosition {
  LeftLegend, RightLegend, BottomLegend, TopLegend,
  ExternalLegend
}
 Position of the legend, relative to the canvas. More...

Public Slots

void autoRefresh ()
 Replots the plot if QwtPlot::autoReplot() is true.
void clear ()
 Remove all curves and markers.
virtual void replot ()
 Redraw the plot.

Signals

void legendChecked (QwtPlotItem *plotItem, bool on)
void legendClicked (QwtPlotItem *plotItem)

Public Member Functions

void applyProperties (const QString &)
bool autoDelete () const
bool autoReplot () const
bool axisAutoScale (int axisId) const
bool axisEnabled (int axisId) const
QFont axisFont (int axisId) const
int axisMaxMajor (int axisId) const
int axisMaxMinor (int axisId) const
QwtScaleDivaxisScaleDiv (int axisId)
 Return the scale division of a specified axis.
const QwtScaleDivaxisScaleDiv (int axisId) const
 Return the scale division of a specified axis.
QwtScaleDrawaxisScaleDraw (int axisId)
const QwtScaleDrawaxisScaleDraw (int axisId) const
const QwtScaleEngineaxisScaleEngine (int axisId) const
QwtScaleEngineaxisScaleEngine (int axisId)
QwtText axisTitle (int axisId) const
QwtScaleWidgetaxisWidget (int axisId)
const QwtScaleWidgetaxisWidget (int axisId) const
const QwtPlotCanvascanvas () const
QwtPlotCanvascanvas ()
const QColor & canvasBackground () const
int canvasLineWidth () const
virtual QwtScaleMap canvasMap (int axisId) const
void detachItems (int rtti=QwtPlotItem::Rtti_PlotItem, bool autoDelete=true)
void enableAxis (int axisId, bool tf=true)
 Enable or disable a specified axis.
virtual bool event (QEvent *)
 Adds handling of layout requests.
QString grabProperties () const
bool hideCanvas () const
void insertLegend (QwtLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0)
 Insert a legend.
double invTransform (int axisId, int pos) const
const QwtPlotItemList & itemList () const
const QwtLegendlegend () const
QwtLegendlegend ()
int margin () const
virtual QSize minimumSizeHint () const
 Return a minimum size hint.
const QwtPlotLayoutplotLayout () const
QwtPlotLayoutplotLayout ()
virtual void polish ()
virtual void print (QPainter *, const QRect &rect, const QwtPlotPrintFilter &=QwtPlotPrintFilter()) const
 Paint the plot into a given rectangle. Paint the contents of a QwtPlot instance into a given rectangle.
void print (QPaintDevice &p, const QwtPlotPrintFilter &=QwtPlotPrintFilter()) const
 Print the plot to a QPaintDevice (QPrinter) This function prints the contents of a QwtPlot instance to QPaintDevice object. The size is derived from its device metrics.
 QwtPlot (QWidget *, const char *name)
 Constructor.
 QwtPlot (const QwtText &title, QWidget *p=NULL)
 Constructor.
 QwtPlot (QWidget *=NULL)
 Constructor.
void setAutoDelete (bool)
void setAutoReplot (bool tf=true)
 Set or reset the autoReplot option If the autoReplot option is set, the plot will be updated implicitly by manipulating member functions. Since this may be time-consuming, it is recommended to leave this option switched off and call replot() explicitly if necessary.
void setAxisAutoScale (int axisId)
 Enable autoscaling for a specified axis.
void setAxisFont (int axisId, const QFont &f)
 Change the font of an axis.
void setAxisLabelAlignment (int axisId, int)
void setAxisLabelRotation (int axisId, double rotation)
void setAxisMaxMajor (int axisId, int maxMajor)
 Set the maximum number of major scale intervals for a specified axis.
void setAxisMaxMinor (int axisId, int maxMinor)
 Set the maximum number of minor scale intervals for a specified axis.
void setAxisScale (int axisId, double min, double max, double step=0)
 Disable autoscaling and specify a fixed scale for a selected axis.
void setAxisScaleDiv (int axisId, const QwtScaleDiv &)
 Disable autoscaling and specify a fixed scale for a selected axis.
void setAxisScaleDraw (int axisId, QwtScaleDraw *)
 Set a scale draw.
void setAxisScaleEngine (int axisId, QwtScaleEngine *)
void setAxisTitle (int axisId, const QwtText &)
 Change the title of a specified axis.
void setAxisTitle (int axisId, const QString &)
 Change the title of a specified axis.
void setCanvasBackground (const QColor &c)
 Change the background of the plotting area.
void setCanvasLineWidth (int w)
 Change the border width of the plotting area Nothing else than canvas()->setLineWidth(w), left for compatibility only.
void setHideCanvas (bool tf=true)
 Set or reset the hideCanvas option If the hideCanvas option is set, the plot will be rendered without a visible main canvas.
void setMargin (int margin)
void setTitle (const QwtText &t)
 Change the plot's title.
void setTitle (const QString &)
 Change the plot's title.
virtual QSize sizeHint () const
QwtText title () const
const QwtTextLabeltitleLabel () const
QwtTextLabeltitleLabel ()
int transform (int axisId, double value) const
 Transform a value into a coordinate in the plotting region.
virtual void updateLayout ()
 Adjust plot content to its current size.
virtual ~QwtPlot ()
 Destructor.

Protected Slots

virtual void legendItemChecked (bool)
virtual void legendItemClicked ()

Protected Member Functions

virtual void drawCanvas (QPainter *)
virtual void drawItems (QPainter *, const QRect &, const QwtScaleMap maps[axisCnt], const QwtPlotPrintFilter &) const
virtual void printCanvas (QPainter *, const QRect &, const QwtScaleMap maps[axisCnt], const QwtPlotPrintFilter &) const
virtual void printLegend (QPainter *, const QRect &) const
virtual void printLegendItem (QPainter *, const QWidget *, const QRect &) const
virtual void printScale (QPainter *, int axisId, int startDist, int endDist, int baseDist, const QRect &) const
 Paint a scale into a given rectangle. Paint the scale into a given rectangle.
virtual void printTitle (QPainter *, const QRect &) const
virtual void resizeEvent (QResizeEvent *e)
 Resize and update internal layout.
void updateAxes ()
 Rebuild the scales and maps.
virtual void updateTabOrder ()

Static Protected Member Functions

static bool axisValid (int axisId)

Properties

QString propertiesDocument

Private Member Functions

void deleteAxesData ()
void initAxesData ()
 Initialize axes.
void initPlot (const QwtText &title)
 Initializes a QwtPlot instance.
void updateScaleDiv ()

Private Attributes

AxisData * d_axisData [axisCnt]
PrivateData * d_data

Friends

class QwtPlotCanvas

Classes

class  AxisData
class  PrivateData

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

Generated by  Doxygen 1.6.0   Back to index