QwtPlot(3) | Qwt User's Guide | QwtPlot(3) |
QwtPlot - A 2-D plotting widget.
#include <qwt_plot.h>
Inherits QFrame, and QwtPlotDict.
enum Axis { yLeft, yRight, xBottom,
xTop, axisCnt }
Axis index. enum LegendPosition { LeftLegend,
RightLegend, BottomLegend, TopLegend }
virtual void replot ()
Redraw the plot. void autoRefresh ()
Replots the plot if autoReplot() is true.
void itemAttached (QwtPlotItem *plotItem, bool on)
void legendDataChanged (const QVariant &itemInfo, const QList<
QwtLegendData > &data)
QwtPlot (QWidget *=NULL)
Constructor. QwtPlot (const QwtText &title, QWidget
*=NULL)
Constructor. virtual ~QwtPlot ()
Destructor. void applyProperties (const QString &)
QString grabProperties () const
void setAutoReplot (bool=true)
Set or reset the autoReplot option. bool autoReplot () const
void setPlotLayout (QwtPlotLayout *)
Assign a new plot layout. QwtPlotLayout * plotLayout ()
const QwtPlotLayout * plotLayout () const
void setTitle (const QString &)
void setTitle (const QwtText &)
QwtText title () const
QwtTextLabel * titleLabel ()
const QwtTextLabel * titleLabel () const
void setFooter (const QString &)
void setFooter (const QwtText &)
QwtText footer () const
QwtTextLabel * footerLabel ()
const QwtTextLabel * footerLabel () const
void setCanvas (QWidget *)
Set the drawing canvas of the plot widget. QWidget * canvas ()
const QWidget * canvas () const
void setCanvasBackground (const QBrush &)
Change the background of the plotting area. QBrush canvasBackground ()
const
virtual QwtScaleMap canvasMap (int axisId) const
double invTransform (int axisId, int pos) const
double transform (int axisId, double value) const
Transform a value into a coordinate in the plotting region.
QwtScaleEngine * axisScaleEngine (int axisId)
const QwtScaleEngine * axisScaleEngine (int axisId) const
void setAxisScaleEngine (int axisId, QwtScaleEngine *)
void setAxisAutoScale (int axisId, bool on=true)
Enable autoscaling for a specified axis. bool axisAutoScale (int
axisId) const
void enableAxis (int axisId, bool tf=true)
Enable or disable a specified axis. bool axisEnabled (int axisId) const
void setAxisFont (int axisId, const QFont &)
Change the font of an axis. QFont axisFont (int axisId) const
void setAxisScale (int axisId, double min, double max, double
stepSize=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. double axisStepSize (int axisId) const
Return the step size parameter that has been set in setAxisScale.
QwtInterval axisInterval (int axisId) const
Return the current interval of the specified axis. const QwtScaleDiv
& axisScaleDiv (int axisId) const
Return the scale division of a specified axis. const QwtScaleDraw *
axisScaleDraw (int axisId) const
Return the scale draw of a specified axis. QwtScaleDraw *
axisScaleDraw (int axisId)
Return the scale draw of a specified axis. const QwtScaleWidget *
axisWidget (int axisId) const
QwtScaleWidget * axisWidget (int axisId)
void setAxisLabelAlignment (int axisId, Qt::Alignment)
void setAxisLabelRotation (int axisId, double rotation)
void setAxisTitle (int axisId, const QString &)
Change the title of a specified axis. void setAxisTitle (int axisId,
const QwtText &)
Change the title of a specified axis. QwtText axisTitle (int
axisId) const
void setAxisMaxMinor (int axisId, int maxMinor)
int axisMaxMinor (int axisId) const
void setAxisMaxMajor (int axisId, int maxMajor)
int axisMaxMajor (int axisId) const
void insertLegend (QwtAbstractLegend *,
LegendPosition=QwtPlot::RightLegend, double ratio=-1.0)
Insert a legend. QwtAbstractLegend * legend ()
const QwtAbstractLegend * legend () const
void updateLegend ()
void updateLegend (const QwtPlotItem *)
virtual QSize sizeHint () const
virtual QSize minimumSizeHint () const
Return a minimum size hint. virtual void updateLayout ()
Adjust plot content to its current size. virtual void drawCanvas
(QPainter *)
void updateAxes ()
Rebuild the axes scales. void updateCanvasMargins ()
Update the canvas margins. virtual void getCanvasMarginsHint (const
QwtScaleMap maps[], const QRectF &canvasRect, double &left,
double &top, double &right, double &bottom) const
Calculate the canvas margins. virtual bool event (QEvent *)
Adds handling of layout requests. virtual bool eventFilter (QObject *,
QEvent *)
Event filter. virtual void drawItems (QPainter *, const QRectF &,
const QwtScaleMap maps[axisCnt]) const
virtual QVariant itemToInfo (QwtPlotItem *) const
Build an information, that can be used to identify a plot item on the legend.
virtual QwtPlotItem * infoToItem (const QVariant &) const
Identify the plot item according to an item info object, that has bee
generated from itemToInfo().
virtual void resizeEvent (QResizeEvent *e)
static bool axisValid (int axisId)
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
#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();
Axis index.
Enumerator
Position of the legend, relative to the canvas.
See also:
Enumerator
Constructor.
Parameters:
Constructor.
Parameters:
This method is intended for manipulating the plot widget from a specific editor in the Qwt designer plugin.
Warning:
Returns:
See also:
Returns:
Parameters:
Returns:
Parameters:
Returns:
Parameters:
Return the current interval of the specified axis. This is only a convenience function for axisScaleDiv( axisId )->interval();
Parameters:
Returns:
See also:
Returns:
Parameters:
See also:
Returns:
Parameters:
See also:
Return the scale division of a specified axis. axisScaleDiv(axisId).lowerBound(), axisScaleDiv(axisId).upperBound() are the current limits of the axis scale.
Parameters:
Returns:
See also:
Return the scale draw of a specified axis.
Parameters:
Returns:
Return the scale draw of a specified axis.
Parameters:
Returns:
Parameters:
Returns:
Parameters:
Returns:
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:
Returns:
See also:
Returns:
Parameters:
Returns:
Parameters:
Returns:
Parameters:
Returns:
Parameters:
Returns:
Returns:
Nothing else than: canvas()->palette().brush( QPalette::Normal, QPalette::Window);
Returns:
See also:
Parameters:
Returns:
See also:
Redraw the canvas.
Parameters:
Warning:
See also:
Redraw the canvas items.
Parameters:
Note:
Enable or disable a specified axis. When an axis is disabled, this only means that it is not visible on the screen. Curves, markers and can be attached to disabled axes, and transformation of screen coordinates into values works as normal.
Only xBottom and yLeft are enabled by default.
Parameters:
Adds handling of layout requests.
Parameters:
Returns:
Event filter. The plot handles the following events for the canvas:
Parameters:
Returns:
See also:
Returns:
Returns:
Returns:
Calculate the canvas margins.
Parameters:
Plot items might indicate, that they need some extra space at the borders of the canvas by the QwtPlotItem::Margins flag.
updateCanvasMargins(), QwtPlotItem::getCanvasMarginHint()
This method is intended for manipulating the plot widget from a specific editor in the Qwt designer plugin.
Returns:
Warning:
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:
Returns:
See also:
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:
See also:
Transform the x or y coordinate of a position in the drawing region into a value.
Parameters:
Returns:
Warning:
A signal indicating, that an item has been attached/detached
Parameters:
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.
QVariant itemInfo; qVariantSetValue( itemInfo, plotItem );
Parameters:
Returns:
See also:
Returns:
See also:
Returns:
See also:
A signal with the attributes how to update the legend entries for a plot item.
Parameters:
See also:
Returns:
Returns:
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:
Resize and update internal layout
Parameters:
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:
See also:
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:
See also:
Note:
Change the font of an axis.
Parameters:
Warning:
Change the alignment of the tick labels
Parameters:
See also:
Rotate all tick labels
Parameters:
See also:
Set the maximum number of major scale intervals for a specified axis
Parameters:
See also:
Set the maximum number of minor scale intervals for a specified axis
Parameters:
See also:
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:
See also:
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:
See also:
Set a scale draw.
Parameters:
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:
Warning:
Change the scale engine for an axis
Parameters:
See also:
Change the title of a specified axis.
Parameters:
Change the title of a specified axis.
Parameters:
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:
The default canvas is a QwtPlotCanvas
Parameters:
See also:
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:
See also:
Change the text the footer
Parameters:
Change the text the footer
Parameters:
Assign a new plot layout.
Parameters:
See also:
Change the plot's title
Parameters:
Change the plot's title
Parameters:
Returns:
See also:
Returns:
Returns:
Returns:
Transform a value into a coordinate in the plotting region.
Parameters:
Returns:
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:
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()
Adjust plot content to its current size.
See also:
Emit legendDataChanged() for all plot item
See also:
Emit legendDataChanged() for a plot item
Parameters:
See also:
Generated automatically by Doxygen for Qwt User's Guide from the source code.
Wed Jan 2 2019 | Version 6.1.4 |