Classes | Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | Private Slots | Private Member Functions | Private Attributes | Friends | List of all members
QwtPlot Class Reference

A 2-D plotting widget. More...

#include <qwt_plot.h>

Inheritance diagram for QwtPlot:
Inheritance graph
[legend]

Classes

class  PrivateData
 
class  ScaleData
 

Public Types

enum  Axis {
  yLeft = QwtAxis::YLeft, yRight = QwtAxis::YRight, xBottom = QwtAxis::XBottom, xTop = QwtAxis::XTop,
  axisCnt = QwtAxis::AxisPositions
}
 
enum  LegendPosition { LeftLegend, RightLegend, BottomLegend, TopLegend }
 

Public Slots

void autoRefresh ()
 Replots the plot if autoReplot() is true. More...
 
virtual void replot ()
 Redraw the plot. More...
 

Signals

void itemAttached (QwtPlotItem *plotItem, bool on)
 
void legendDataChanged (const QVariant &itemInfo, const QList< QwtLegendData > &data)
 

Public Member Functions

bool autoReplot () const
 
bool axisAutoScale (QwtAxisId) const
 
bool axisEnabled (int axisId) const
 
QFont axisFont (QwtAxisId) const
 
QwtInterval axisInterval (QwtAxisId) const
 Return the current interval of the specified axis. More...
 
int axisMaxMajor (QwtAxisId) const
 
int axisMaxMinor (QwtAxisId) const
 
const QwtScaleDivaxisScaleDiv (QwtAxisId) const
 Return the scale division of a specified axis. More...
 
QwtScaleDrawaxisScaleDraw (QwtAxisId)
 Return the scale draw of a specified axis. More...
 
const QwtScaleDrawaxisScaleDraw (QwtAxisId) const
 Return the scale draw of a specified axis. More...
 
QwtScaleEngineaxisScaleEngine (QwtAxisId)
 
const QwtScaleEngineaxisScaleEngine (QwtAxisId) const
 
double axisStepSize (QwtAxisId) const
 Return the step size parameter that has been set in setAxisScale. More...
 
QwtText axisTitle (QwtAxisId) const
 
QwtScaleWidgetaxisWidget (QwtAxisId)
 
const QwtScaleWidgetaxisWidget (QwtAxisId) const
 
QWidget * canvas ()
 
const QWidget * canvas () const
 
QBrush canvasBackground () const
 
virtual QwtScaleMap canvasMap (QwtAxisId) const
 
virtual void drawCanvas (QPainter *)
 
virtual void drawItems (QPainter *, const QRectF &, const QwtScaleMap maps[QwtAxis::AxisPositions]) const
 
void enableAxis (int axisId, bool on=true)
 
virtual bool event (QEvent *) QWT_OVERRIDE
 Adds handling of layout requests. More...
 
virtual bool eventFilter (QObject *, QEvent *) QWT_OVERRIDE
 Event filter. More...
 
QwtText footer () const
 
QwtTextLabelfooterLabel ()
 
const QwtTextLabelfooterLabel () const
 
virtual void getCanvasMarginsHint (const QwtScaleMap maps[], const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
 Calculate the canvas margins. More...
 
virtual QwtPlotIteminfoToItem (const QVariant &) const
 Identify the plot item according to an item info object, that has bee generated from itemToInfo(). More...
 
void insertLegend (QwtAbstractLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0)
 Insert a legend. More...
 
double invTransform (QwtAxisId, double pos) const
 
bool isAxisValid (QwtAxisId) const
 
bool isAxisVisible (QwtAxisId) const
 
virtual QVariant itemToInfo (QwtPlotItem *) const
 Build an information, that can be used to identify a plot item on the legend. More...
 
QwtAbstractLegendlegend ()
 
const QwtAbstractLegendlegend () const
 
virtual QSize minimumSizeHint () const QWT_OVERRIDE
 Return a minimum size hint. More...
 
QwtPlotLayoutplotLayout ()
 
const QwtPlotLayoutplotLayout () const
 
 QwtPlot (const QwtText &title, QWidget *=NULL)
 Constructor. More...
 
 QwtPlot (QWidget *=NULL)
 Constructor. More...
 
void setAutoReplot (bool=true)
 Set or reset the autoReplot option. More...
 
void setAxisAutoScale (QwtAxisId, bool on=true)
 Enable autoscaling for a specified axis. More...
 
void setAxisFont (QwtAxisId, const QFont &)
 Change the font of an axis. More...
 
void setAxisLabelAlignment (QwtAxisId, Qt::Alignment)
 
void setAxisLabelRotation (QwtAxisId, double rotation)
 
void setAxisMaxMajor (QwtAxisId, int maxMajor)
 
void setAxisMaxMinor (QwtAxisId, int maxMinor)
 
void setAxisScale (QwtAxisId, double min, double max, double stepSize=0)
 Disable autoscaling and specify a fixed scale for a selected axis. More...
 
void setAxisScaleDiv (QwtAxisId, const QwtScaleDiv &)
 Disable autoscaling and specify a fixed scale for a selected axis. More...
 
void setAxisScaleDraw (QwtAxisId, QwtScaleDraw *)
 Set a scale draw. More...
 
void setAxisScaleEngine (QwtAxisId, QwtScaleEngine *)
 
void setAxisTitle (QwtAxisId, const QString &)
 Change the title of a specified axis. More...
 
void setAxisTitle (QwtAxisId, const QwtText &)
 Change the title of a specified axis. More...
 
void setAxisVisible (QwtAxisId, bool on=true)
 Hide or show a specified axis. More...
 
void setCanvas (QWidget *)
 Set the drawing canvas of the plot widget. More...
 
void setCanvasBackground (const QBrush &)
 Change the background of the plotting area. More...
 
void setFooter (const QString &)
 
void setFooter (const QwtText &)
 
void setPlotLayout (QwtPlotLayout *)
 Assign a new plot layout. More...
 
void setTitle (const QString &)
 
void setTitle (const QwtText &)
 
virtual QSize sizeHint () const QWT_OVERRIDE
 
QwtText title () const
 
QwtTextLabeltitleLabel ()
 
const QwtTextLabeltitleLabel () const
 
double transform (QwtAxisId, double value) const
 Transform a value into a coordinate in the plotting region. More...
 
void updateAxes ()
 Rebuild the axes scales. More...
 
void updateCanvasMargins ()
 Update the canvas margins. More...
 
virtual void updateLayout ()
 Adjust plot content to its current size. More...
 
void updateLegend ()
 
void updateLegend (const QwtPlotItem *)
 
virtual ~QwtPlot ()
 Destructor. More...
 
- Public Member Functions inherited from QwtPlotDict
bool autoDelete () const
 
void detachItems (int rtti=QwtPlotItem::Rtti_PlotItem, bool autoDelete=true)
 
const QwtPlotItemListitemList () const
 A QwtPlotItemList of all attached plot items. More...
 
QwtPlotItemList itemList (int rtti) const
 
 QwtPlotDict ()
 
void setAutoDelete (bool)
 
virtual ~QwtPlotDict ()
 

Protected Member Functions

virtual void resizeEvent (QResizeEvent *) QWT_OVERRIDE
 
- Protected Member Functions inherited from QwtPlotDict
void insertItem (QwtPlotItem *)
 
void removeItem (QwtPlotItem *)
 

Properties

bool autoReplot
 
QBrush canvasBackground
 

Private Slots

void updateLegendItems (const QVariant &itemInfo, const QList< QwtLegendData > &legendData)
 Update all plot items interested in legend attributes. More...
 

Private Member Functions

void attachItem (QwtPlotItem *, bool)
 Attach/Detach a plot item. More...
 
void deleteAxesData ()
 
void initAxesData ()
 
void initPlot (const QwtText &title)
 Initializes a QwtPlot instance. More...
 
void updateScaleDiv ()
 

Private Attributes

PrivateDatam_data
 
ScaleDatam_scaleData
 

Friends

class QwtPlotItem
 

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 explicitly set (QwtScaleDiv), or are calculated from the plot items, using algorithms (QwtScaleEngine) which can be configured separately for each axis.

The simpleplot example is a good starting point to see how to set up a plot widget.

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 = new QwtPlot( "Two Curves", parent );
// add curves
QwtPlotCurve *curve1 = new QwtPlotCurve( "Curve 1" );
QwtPlotCurve *curve2 = new QwtPlotCurve( "Curve 2" );
// connect or copy the data to the curves
curve1->setData( ... );
curve2->setData( ... );
curve1->attach( myPlot );
curve2->attach( myPlot );
// finally, refresh the plot
myPlot->replot();

Definition at line 78 of file qwt_plot.h.

Member Enumeration Documentation

◆ Axis

Enumerator
yLeft 
yRight 
xBottom 
xTop 
axisCnt 

Definition at line 238 of file qwt_plot.h.

◆ LegendPosition

Position of the legend, relative to the canvas.

See also
insertLegend()
Enumerator
LeftLegend 

The legend will be left from the QwtAxis::YLeft axis.

RightLegend 

The legend will be right from the QwtAxis::YRight axis.

BottomLegend 

The legend will be below the footer.

TopLegend 

The legend will be above the title.

Definition at line 93 of file qwt_plot.h.

Constructor & Destructor Documentation

◆ QwtPlot() [1/2]

QwtPlot::QwtPlot ( QWidget *  parent = NULL)
explicit

Constructor.

Parameters
parentParent widget

Definition at line 103 of file qwt_plot.cpp.

◆ QwtPlot() [2/2]

QwtPlot::QwtPlot ( const QwtText title,
QWidget *  parent = NULL 
)
explicit

Constructor.

Parameters
titleTitle text
parentParent widget

Definition at line 114 of file qwt_plot.cpp.

◆ ~QwtPlot()

QwtPlot::~QwtPlot ( )
virtual

Destructor.

Definition at line 121 of file qwt_plot.cpp.

Member Function Documentation

◆ attachItem()

void QwtPlot::attachItem ( QwtPlotItem plotItem,
bool  on 
)
private

Attach/Detach a plot item.

Parameters
plotItemPlot item
onWhen true attach the item, otherwise detach it

Definition at line 1081 of file qwt_plot.cpp.

◆ autoRefresh

void QwtPlot::autoRefresh ( )
slot

Replots the plot if autoReplot() is true.

Definition at line 289 of file qwt_plot.cpp.

◆ autoReplot()

bool QwtPlot::autoReplot ( ) const

◆ axisAutoScale()

bool QwtPlot::axisAutoScale ( QwtAxisId  axisId) const
Returns
True, if autoscaling is enabled
Parameters
axisIdAxis

Definition at line 213 of file qwt_plot_axis.cpp.

◆ axisEnabled()

bool QwtPlot::axisEnabled ( int  axisId) const
inline

Definition at line 253 of file qwt_plot.h.

◆ axisFont()

QFont QwtPlot::axisFont ( QwtAxisId  axisId) const
Returns
The font of the scale labels for a specified axis
Parameters
axisIdAxis

Definition at line 237 of file qwt_plot_axis.cpp.

◆ axisInterval()

QwtInterval QwtPlot::axisInterval ( QwtAxisId  axisId) const

Return the current interval of the specified axis.

This is only a convenience function for axisScaleDiv( axisId )->interval();

Parameters
axisIdAxis
Returns
Scale interval
See also
QwtScaleDiv, axisScaleDiv()

Definition at line 348 of file qwt_plot_axis.cpp.

◆ axisMaxMajor()

int QwtPlot::axisMaxMajor ( QwtAxisId  axisId) const
Returns
The maximum number of major ticks for a specified axis
Parameters
axisIdAxis
See also
setAxisMaxMajor(), QwtScaleEngine::divideScale()

Definition at line 251 of file qwt_plot_axis.cpp.

◆ axisMaxMinor()

int QwtPlot::axisMaxMinor ( QwtAxisId  axisId) const
Returns
the maximum number of minor ticks for a specified axis
Parameters
axisIdAxis
See also
setAxisMaxMinor(), QwtScaleEngine::divideScale()

Definition at line 264 of file qwt_plot_axis.cpp.

◆ axisScaleDiv()

const QwtScaleDiv & QwtPlot::axisScaleDiv ( QwtAxisId  axisId) const

Return the scale division of a specified axis.

axisScaleDiv(axisId).lowerBound(), axisScaleDiv(axisId).upperBound() are the current limits of the axis scale.

Parameters
axisIdAxis
Returns
Scale division
See also
QwtScaleDiv, setAxisScaleDiv(), QwtScaleEngine::divideScale()

Definition at line 283 of file qwt_plot_axis.cpp.

◆ axisScaleDraw() [1/2]

QwtScaleDraw * QwtPlot::axisScaleDraw ( QwtAxisId  axisId)

Return the scale draw of a specified axis.

Parameters
axisIdAxis
Returns
Specified scaleDraw for axis, or NULL if axis is invalid.

Definition at line 312 of file qwt_plot_axis.cpp.

◆ axisScaleDraw() [2/2]

const QwtScaleDraw * QwtPlot::axisScaleDraw ( QwtAxisId  axisId) const

Return the scale draw of a specified axis.

Parameters
axisIdAxis
Returns
Specified scaleDraw for axis, or NULL if axis is invalid.

Definition at line 298 of file qwt_plot_axis.cpp.

◆ axisScaleEngine() [1/2]

QwtScaleEngine * QwtPlot::axisScaleEngine ( QwtAxisId  axisId)
Parameters
axisIdAxis
Returns
Scale engine for a specific axis

Definition at line 190 of file qwt_plot_axis.cpp.

◆ axisScaleEngine() [2/2]

const QwtScaleEngine * QwtPlot::axisScaleEngine ( QwtAxisId  axisId) const
Parameters
axisIdAxis
Returns
Scale engine for a specific axis

Definition at line 202 of file qwt_plot_axis.cpp.

◆ axisStepSize()

double QwtPlot::axisStepSize ( QwtAxisId  axisId) const

Return the step size parameter that has been set in setAxisScale.

This doesn't need to be the step size of the current scale.

Parameters
axisIdAxis
Returns
step size parameter value
See also
setAxisScale(), QwtScaleEngine::divideScale()

Definition at line 330 of file qwt_plot_axis.cpp.

◆ axisTitle()

QwtText QwtPlot::axisTitle ( QwtAxisId  axisId) const
Returns
Title of a specified axis
Parameters
axisIdAxis

Definition at line 360 of file qwt_plot_axis.cpp.

◆ axisWidget() [1/2]

QwtScaleWidget * QwtPlot::axisWidget ( QwtAxisId  axisId)
Returns
Scale widget of the specified axis, or NULL if axisId is invalid.
Parameters
axisIdAxis

Definition at line 153 of file qwt_plot_axis.cpp.

◆ axisWidget() [2/2]

const QwtScaleWidget * QwtPlot::axisWidget ( QwtAxisId  axisId) const
Returns
Scale widget of the specified axis, or NULL if axisId is invalid.
Parameters
axisIdAxis

Definition at line 141 of file qwt_plot_axis.cpp.

◆ canvas() [1/2]

const QWidget * QwtPlot::canvas ( )
Returns
the plot's canvas

Definition at line 463 of file qwt_plot.cpp.

◆ canvas() [2/2]

const QWidget* QwtPlot::canvas ( ) const

◆ canvasBackground()

QBrush QwtPlot::canvasBackground ( ) const

◆ canvasMap()

QwtScaleMap QwtPlot::canvasMap ( QwtAxisId  axisId) const
virtual
Parameters
axisIdAxis
Returns
Map for the axis on the canvas. With this map pixel coordinates can translated to plot coordinates and vice versa.
See also
QwtScaleMap, transform(), invTransform()

Definition at line 800 of file qwt_plot.cpp.

◆ deleteAxesData()

void QwtPlot::deleteAxesData ( )
private

Definition at line 115 of file qwt_plot_axis.cpp.

◆ drawCanvas()

void QwtPlot::drawCanvas ( QPainter *  painter)
virtual

Redraw the canvas.

Parameters
painterPainter used for drawing
Warning
drawCanvas calls drawItems what is also used for printing. Applications that like to add individual plot items better overload drawItems()
See also
drawItems()

Definition at line 742 of file qwt_plot.cpp.

◆ drawItems()

void QwtPlot::drawItems ( QPainter *  painter,
const QRectF &  canvasRect,
const QwtScaleMap  maps[QwtAxis::AxisPositions] 
) const
virtual

Redraw the canvas items.

Parameters
painterPainter used for drawing
canvasRectBounding rectangle where to paint
mapsQwtAxis::AxisCount maps, mapping between plot and paint device coordinates
Note
Usually canvasRect is contentsRect() of the plot canvas. Due to a bug in Qt this rectangle might be wrong for certain frame styles ( f.e QFrame::Box ) and it might be necessary to fix the margins manually using QWidget::setContentsMargins()

Definition at line 764 of file qwt_plot.cpp.

◆ enableAxis()

void QwtPlot::enableAxis ( int  axisId,
bool  on = true 
)
inline

Definition at line 248 of file qwt_plot.h.

◆ event()

bool QwtPlot::event ( QEvent *  event)
virtual

Adds handling of layout requests.

Parameters
eventEvent
Returns
See QFrame::event()

Definition at line 237 of file qwt_plot.cpp.

◆ eventFilter()

bool QwtPlot::eventFilter ( QObject *  object,
QEvent *  event 
)
virtual

Event filter.

The plot handles the following events for the canvas:

  • QEvent::Resize The canvas margins might depend on its size
  • QEvent::ContentsRectChange The layout needs to be recalculated
Parameters
objectObject to be filtered
eventEvent
Returns
See QFrame::eventFilter()
See also
updateCanvasMargins(), updateLayout()

Definition at line 271 of file qwt_plot.cpp.

◆ footer()

QwtText QwtPlot::footer ( ) const
Returns
Text of the footer

Definition at line 395 of file qwt_plot.cpp.

◆ footerLabel() [1/2]

const QwtTextLabel * QwtPlot::footerLabel ( )
Returns
Footer label widget.

Definition at line 401 of file qwt_plot.cpp.

◆ footerLabel() [2/2]

const QwtTextLabel* QwtPlot::footerLabel ( ) const

◆ getCanvasMarginsHint()

void QwtPlot::getCanvasMarginsHint ( const QwtScaleMap  maps[],
const QRectF &  canvasRect,
double &  left,
double &  top,
double &  right,
double &  bottom 
) const
virtual

Calculate the canvas margins.

Parameters
mapsQwtAxis::AxisCount maps, mapping between plot and paint device coordinates
canvasRectBounding rectangle where to paint
leftReturn parameter for the left margin
topReturn parameter for the top margin
rightReturn parameter for the right margin
bottomReturn parameter for the bottom margin

Plot items might indicate, that they need some extra space at the borders of the canvas by the QwtPlotItem::Margins flag.

updateCanvasMargins(), QwtPlotItem::getCanvasMarginHint()

Definition at line 670 of file qwt_plot.cpp.

◆ infoToItem()

QwtPlotItem * QwtPlot::infoToItem ( const QVariant &  itemInfo) const
virtual

Identify the plot item according to an item info object, that has bee generated from itemToInfo().

The default implementation simply tries to unwrap a QwtPlotItem pointer:

if ( itemInfo.canConvert<QwtPlotItem *>() )
return qvariant_cast<QwtPlotItem *>( itemInfo );
Parameters
itemInfoPlot item
Returns
A plot item, when successful, otherwise a NULL pointer.
See also
itemToInfo()

Definition at line 1159 of file qwt_plot.cpp.

◆ initAxesData()

void QwtPlot::initAxesData ( )
private

Definition at line 107 of file qwt_plot_axis.cpp.

◆ initPlot()

void QwtPlot::initPlot ( const QwtText title)
private

Initializes a QwtPlot instance.

Parameters
titleTitle text

Definition at line 135 of file qwt_plot.cpp.

◆ insertLegend()

void QwtPlot::insertLegend ( QwtAbstractLegend legend,
QwtPlot::LegendPosition  pos = QwtPlot::RightLegend,
double  ratio = -1.0 
)

Insert a legend.

If the position legend is QwtPlot::LeftLegend or QwtPlot::RightLegend the legend will be organized in one column from top to down. Otherwise the legend items will be placed in a table with a best fit number of columns from left to right.

insertLegend() will set the plot widget as parent for the legend. The legend will be deleted in the destructor of the plot or when another legend is inserted.

Legends, that are not inserted into the layout of the plot widget need to connect to the legendDataChanged() signal. Calling updateLegend() initiates this signal for an initial update. When the application code wants to implement its own layout this also needs to be done for rendering plots to a document ( see QwtPlotRenderer ).

Parameters
legendLegend
posThe legend's position. For top/left position the number of columns will be limited to 1, otherwise it will be set to unlimited.
ratioRatio between legend and the bounding rectangle of title, canvas and axes. The legend will be shrunk if it would need more space than the given ratio. The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0 it will be reset to the default ratio. The default vertical/horizontal ratio is 0.33/0.5.
See also
legend(), QwtPlotLayout::legendPosition(), QwtPlotLayout::setLegendPosition()

Definition at line 927 of file qwt_plot.cpp.

◆ invTransform()

double QwtPlot::invTransform ( QwtAxisId  axisId,
double  pos 
) const

Transform the x or y coordinate of a position in the drawing region into a value.

Parameters
axisIdAxis
posposition
Returns
Position as axis coordinate
Warning
The position can be an x or a y coordinate, depending on the specified axis.

Definition at line 401 of file qwt_plot_axis.cpp.

◆ isAxisValid()

bool QwtPlot::isAxisValid ( QwtAxisId  axisId) const

Checks if an axis is valid

Parameters
axisIdaxis
Returns
true if the specified axis exists, otherwise false
Note
This method is equivalent to QwtAxis::isValid( axisId ) and simply checks if axisId is one of the values of QwtAxis::Position. It is a placeholder for future releases, where it will be possible to have a customizable number of axes ( multiaxes branch ) at each side.

Definition at line 132 of file qwt_plot_axis.cpp.

◆ isAxisVisible()

bool QwtPlot::isAxisVisible ( QwtAxisId  axisId) const
Returns
True, if a specified axis is visible
Parameters
axisIdAxis

Definition at line 225 of file qwt_plot_axis.cpp.

◆ itemAttached

void QwtPlot::itemAttached ( QwtPlotItem plotItem,
bool  on 
)
signal

A signal indicating, that an item has been attached/detached

Parameters
plotItemPlot item
onAttached/Detached

◆ itemToInfo()

QVariant QwtPlot::itemToInfo ( QwtPlotItem plotItem) const
virtual

Build an information, that can be used to identify a plot item on the legend.

The default implementation simply wraps the plot item into a QVariant object. When overloading itemToInfo() usually infoToItem() needs to reimplemeted too.

Parameters
plotItemPlot item
Returns
Plot item embedded in a QVariant
See also
infoToItem()

Definition at line 1139 of file qwt_plot.cpp.

◆ legend() [1/2]

const QwtAbstractLegend * QwtPlot::legend ( )
Returns
the plot's legend
See also
insertLegend()

Definition at line 445 of file qwt_plot.cpp.

◆ legend() [2/2]

const QwtAbstractLegend* QwtPlot::legend ( ) const

◆ legendDataChanged

void QwtPlot::legendDataChanged ( const QVariant &  itemInfo,
const QList< QwtLegendData > &  data 
)
signal

A signal with the attributes how to update the legend entries for a plot item.

Parameters
itemInfoInfo about a plot item, build from itemToInfo()
dataAttributes of the entries ( usually <= 1 ) for the plot item.
See also
itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()

◆ minimumSizeHint()

QSize QwtPlot::minimumSizeHint ( ) const
virtual

Return a minimum size hint.

Definition at line 518 of file qwt_plot.cpp.

◆ plotLayout() [1/2]

const QwtPlotLayout * QwtPlot::plotLayout ( )
Returns
the plot's layout

Definition at line 430 of file qwt_plot.cpp.

◆ plotLayout() [2/2]

const QwtPlotLayout* QwtPlot::plotLayout ( ) const

◆ replot

void QwtPlot::replot ( )
virtualslot

Redraw the plot.

If the autoReplot option is not set (which is the default) or if any curves are attached to raw data, the plot has to be refreshed explicitly in order to make changes visible.

See also
updateAxes(), setAutoReplot()

Definition at line 545 of file qwt_plot.cpp.

◆ resizeEvent()

void QwtPlot::resizeEvent ( QResizeEvent *  e)
protectedvirtual

Resize and update internal layout

Parameters
eResize event

Reimplemented in PlotWidgetBase::QwtPlotPimpl.

Definition at line 530 of file qwt_plot.cpp.

◆ setAutoReplot()

void QwtPlot::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.

The autoReplot option is set to false by default, which means that the user has to call replot() in order to make changes visible.

Parameters
tftrue or false. Defaults to true.
See also
replot()

Definition at line 310 of file qwt_plot.cpp.

◆ setAxisAutoScale()

void QwtPlot::setAxisAutoScale ( QwtAxisId  axisId,
bool  on = true 
)

Enable autoscaling for a specified axis.

This member function is used to switch back to autoscaling mode after a fixed scale has been set. Autoscaling is enabled by default.

Parameters
axisIdAxis
onOn/Off
See also
setAxisScale(), setAxisScaleDiv(), updateAxes()
Note
The autoscaling flag has no effect until updateAxes() is executed ( called by replot() ).

Definition at line 453 of file qwt_plot_axis.cpp.

◆ setAxisFont()

void QwtPlot::setAxisFont ( QwtAxisId  axisId,
const QFont &  font 
)

Change the font of an axis.

Parameters
axisIdAxis
fontFont
Warning
This function changes the font of the tick labels, not of the axis title.

Definition at line 434 of file qwt_plot_axis.cpp.

◆ setAxisLabelAlignment()

void QwtPlot::setAxisLabelAlignment ( QwtAxisId  axisId,
Qt::Alignment  alignment 
)

Change the alignment of the tick labels

Parameters
axisIdAxis
alignmentOr'd Qt::AlignmentFlags see <qnamespace.h>
See also
QwtScaleDraw::setLabelAlignment()

Definition at line 553 of file qwt_plot_axis.cpp.

◆ setAxisLabelRotation()

void QwtPlot::setAxisLabelRotation ( QwtAxisId  axisId,
double  rotation 
)

Rotate all tick labels

Parameters
axisIdAxis
rotationAngle in degrees. When changing the label rotation, the label alignment might be adjusted too.
See also
QwtScaleDraw::setLabelRotation(), setAxisLabelAlignment()

Definition at line 568 of file qwt_plot_axis.cpp.

◆ setAxisMaxMajor()

void QwtPlot::setAxisMaxMajor ( QwtAxisId  axisId,
int  maxMajor 
)

Set the maximum number of major scale intervals for a specified axis

Parameters
axisIdAxis
maxMajorMaximum number of major steps
See also
axisMaxMajor()

Definition at line 606 of file qwt_plot_axis.cpp.

◆ setAxisMaxMinor()

void QwtPlot::setAxisMaxMinor ( QwtAxisId  axisId,
int  maxMinor 
)

Set the maximum number of minor scale intervals for a specified axis

Parameters
axisIdAxis
maxMinorMaximum number of minor steps
See also
axisMaxMinor()

Definition at line 582 of file qwt_plot_axis.cpp.

◆ setAxisScale()

void QwtPlot::setAxisScale ( QwtAxisId  axisId,
double  min,
double  max,
double  stepSize = 0 
)

Disable autoscaling and specify a fixed scale for a selected axis.

In updateAxes() the scale engine calculates a scale division from the specified parameters, that will be assigned to the scale widget. So updates of the scale widget usually happen delayed with the next replot.

Parameters
axisIdAxis
minMinimum of the scale
maxMaximum of the scale
stepSizeMajor step size. If step == 0, the step size is calculated automatically using the maxMajor setting.
See also
setAxisMaxMajor(), setAxisAutoScale(), axisStepSize(), QwtScaleEngine::divideScale()

Definition at line 477 of file qwt_plot_axis.cpp.

◆ setAxisScaleDiv()

void QwtPlot::setAxisScaleDiv ( QwtAxisId  axisId,
const QwtScaleDiv scaleDiv 
)

Disable autoscaling and specify a fixed scale for a selected axis.

The scale division will be stored locally only until the next call of updateAxes(). So updates of the scale widget usually happen delayed with the next replot.

Parameters
axisIdAxis
scaleDivScale division
See also
setAxisScale(), setAxisAutoScale()

Definition at line 506 of file qwt_plot_axis.cpp.

◆ setAxisScaleDraw()

void QwtPlot::setAxisScaleDraw ( QwtAxisId  axisId,
QwtScaleDraw scaleDraw 
)

Set a scale draw.

Parameters
axisIdAxis
scaleDrawObject responsible for drawing scales.

By passing scaleDraw it is possible to extend QwtScaleDraw functionality and let it take place in QwtPlot. Please note that scaleDraw has to be created with new and will be deleted by the corresponding QwtScale member ( like a child object ).

See also
QwtScaleDraw, QwtScaleWidget
Warning
The attributes of scaleDraw will be overwritten by those of the previous QwtScaleDraw.

Definition at line 536 of file qwt_plot_axis.cpp.

◆ setAxisScaleEngine()

void QwtPlot::setAxisScaleEngine ( QwtAxisId  axisId,
QwtScaleEngine scaleEngine 
)

Change the scale engine for an axis

Parameters
axisIdAxis
scaleEngineScale engine
See also
axisScaleEngine()

Definition at line 169 of file qwt_plot_axis.cpp.

◆ setAxisTitle() [1/2]

void QwtPlot::setAxisTitle ( QwtAxisId  axisId,
const QString &  title 
)

Change the title of a specified axis.

Parameters
axisIdAxis
titleaxis title

Definition at line 628 of file qwt_plot_axis.cpp.

◆ setAxisTitle() [2/2]

void QwtPlot::setAxisTitle ( QwtAxisId  axisId,
const QwtText title 
)

Change the title of a specified axis.

Parameters
axisIdAxis
titleAxis title

Definition at line 640 of file qwt_plot_axis.cpp.

◆ setAxisVisible()

void QwtPlot::setAxisVisible ( QwtAxisId  axisId,
bool  on = true 
)

Hide or show a specified axis.

Curves, markers and other items can be attached to hidden axes, and transformation of screen coordinates into values works as normal.

Only QwtAxis::XBottom and QwtAxis::YLeft are enabled by default.

Parameters
axisIdAxis
ontrue (visible) or false (hidden)

Definition at line 380 of file qwt_plot_axis.cpp.

◆ setCanvas()

void QwtPlot::setCanvas ( QWidget *  canvas)

Set the drawing canvas of the plot widget.

QwtPlot invokes methods of the canvas as meta methods ( see QMetaObject ). In opposite to using conventional C++ techniques like virtual methods they allow to use canvas implementations that are derived from QWidget or QGLWidget.

The following meta methods could be implemented:

  • replot() When the canvas doesn't offer a replot method, QwtPlot calls update() instead.
  • borderPath() The border path is necessary to clip the content of the canvas When the canvas doesn't have any special border ( f.e rounded corners ) it is o.k. not to implement this method.

The default canvas is a QwtPlotCanvas

Parameters
canvasCanvas Widget
See also
canvas()

Definition at line 213 of file qwt_plot.cpp.

◆ setCanvasBackground()

void QwtPlot::setCanvasBackground ( const QBrush &  brush)

Change the background of the plotting area.

Sets brush to QPalette::Window of all color groups of the palette of the canvas. Using canvas()->setPalette() is a more powerful way to set these colors.

Parameters
brushNew background brush
See also
canvasBackground()

Definition at line 873 of file qwt_plot.cpp.

◆ setFooter() [1/2]

void QwtPlot::setFooter ( const QString &  text)

Change the text the footer

Parameters
textNew text of the footer

Definition at line 372 of file qwt_plot.cpp.

◆ setFooter() [2/2]

void QwtPlot::setFooter ( const QwtText text)

Change the text the footer

Parameters
textNew text of the footer

Definition at line 385 of file qwt_plot.cpp.

◆ setPlotLayout()

void QwtPlot::setPlotLayout ( QwtPlotLayout layout)

Assign a new plot layout.

Parameters
layoutLayout()
See also
plotLayout()

Definition at line 418 of file qwt_plot.cpp.

◆ setTitle() [1/2]

void QwtPlot::setTitle ( const QString &  title)

Change the plot's title

Parameters
titleNew title

Definition at line 328 of file qwt_plot.cpp.

◆ setTitle() [2/2]

void QwtPlot::setTitle ( const QwtText title)

Change the plot's title

Parameters
titleNew title

Definition at line 341 of file qwt_plot.cpp.

◆ sizeHint()

QSize QwtPlot::sizeHint ( ) const
virtual
Returns
Size hint for the plot widget
See also
minimumSizeHint()

Definition at line 480 of file qwt_plot.cpp.

◆ title()

QwtText QwtPlot::title ( ) const
Returns
Title of the plot

Definition at line 351 of file qwt_plot.cpp.

◆ titleLabel() [1/2]

const QwtTextLabel * QwtPlot::titleLabel ( )
Returns
Title label widget.

Definition at line 357 of file qwt_plot.cpp.

◆ titleLabel() [2/2]

const QwtTextLabel* QwtPlot::titleLabel ( ) const

◆ transform()

double QwtPlot::transform ( QwtAxisId  axisId,
double  value 
) const

Transform a value into a coordinate in the plotting region.

Parameters
axisIdAxis
valuevalue
Returns
X or Y coordinate in the plotting region corresponding to the value.

Definition at line 418 of file qwt_plot_axis.cpp.

◆ updateAxes()

void QwtPlot::updateAxes ( )

Rebuild the axes scales.

In case of autoscaling the boundaries of a scale are calculated from the bounding rectangles of all plot items, having the QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ). Then a scale division is calculated ( QwtScaleEngine::didvideScale() ) and assigned to scale widget.

When the scale boundaries have been assigned with setAxisScale() a scale division is calculated ( QwtScaleEngine::didvideScale() ) for this interval and assigned to the scale widget.

When the scale has been set explicitly by setAxisScaleDiv() the locally stored scale division gets assigned to the scale widget.

The scale widget indicates modifications by emitting a QwtScaleWidget::scaleDivChanged() signal.

updateAxes() is usually called by replot().

See also
setAxisAutoScale(), setAxisScale(), setAxisScaleDiv(), replot() QwtPlotItem::boundingRect()

Definition at line 670 of file qwt_plot_axis.cpp.

◆ updateCanvasMargins()

void QwtPlot::updateCanvasMargins ( )

Update the canvas margins.

Plot items might indicate, that they need some extra space at the borders of the canvas by the QwtPlotItem::Margins flag.

getCanvasMarginsHint(), QwtPlotItem::getCanvasMarginHint()

Definition at line 706 of file qwt_plot.cpp.

◆ updateLayout()

void QwtPlot::updateLayout ( )
virtual

Adjust plot content to its current size.

See also
resizeEvent()

Definition at line 577 of file qwt_plot.cpp.

◆ updateLegend() [1/2]

void QwtPlot::updateLegend ( )

Emit legendDataChanged() for all plot item

See also
QwtPlotItem::legendData(), legendDataChanged()

Definition at line 1016 of file qwt_plot.cpp.

◆ updateLegend() [2/2]

void QwtPlot::updateLegend ( const QwtPlotItem plotItem)

Emit legendDataChanged() for a plot item

Parameters
plotItemPlot item
See also
QwtPlotItem::legendData(), legendDataChanged()

Definition at line 1032 of file qwt_plot.cpp.

◆ updateLegendItems

void QwtPlot::updateLegendItems ( const QVariant &  itemInfo,
const QList< QwtLegendData > &  legendData 
)
privateslot

Update all plot items interested in legend attributes.

Call QwtPlotItem::updateLegend(), when the QwtPlotItem::LegendInterest flag is set.

Parameters
itemInfoInfo about the plot item
legendDataEntries to be displayed for the plot item ( usually 1 )
See also
QwtPlotItem::LegendInterest, QwtPlotLegendItem, QwtPlotItem::updateLegend()

Definition at line 1058 of file qwt_plot.cpp.

◆ updateScaleDiv()

void QwtPlot::updateScaleDiv ( )
private

Friends And Related Function Documentation

◆ QwtPlotItem

friend class QwtPlotItem
friend

Definition at line 294 of file qwt_plot.h.

Member Data Documentation

◆ m_data

PrivateData* QwtPlot::m_data
private

Definition at line 306 of file qwt_plot.h.

◆ m_scaleData

ScaleData* QwtPlot::m_scaleData
private

Definition at line 303 of file qwt_plot.h.

Property Documentation

◆ autoReplot

bool QwtPlot::autoReplot
readwrite
Returns
true if the autoReplot option is set.
See also
setAutoReplot()

Definition at line 85 of file qwt_plot.h.

◆ canvasBackground

QBrush QwtPlot::canvasBackground
readwrite

Nothing else than: canvas()->palette().brush( QPalette::Normal, QPalette::Window);

Returns
Background brush of the plotting area.
See also
setCanvasBackground()

Definition at line 83 of file qwt_plot.h.


The documentation for this class was generated from the following files:
QwtPlot
A 2-D plotting widget.
Definition: qwt_plot.h:78
QwtSeriesStore::setData
void setData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:164
QwtPlotItem
Base class for items on the plot canvas.
Definition: qwt_plot_item.h:66
QwtPlot::QwtPlot
QwtPlot(QWidget *=NULL)
Constructor.
Definition: qwt_plot.cpp:103
QwtPlot::replot
virtual void replot()
Redraw the plot.
Definition: qwt_plot.cpp:545
qwt_plot_curve.h
QwtPlotItem::attach
void attach(QwtPlot *plot)
Attach the item to a plot.
Definition: qwt_plot_item.cpp:98
QwtPlotCurve
A plot item, that represents a series of points.
Definition: qwt_plot_curve.h:56
qwt_plot.h


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:29