A 2-D plotting widget. More...
#include <qwt_plot.h>
Classes | |
class | AxisData |
class | PrivateData |
Public Types | |
enum | Axis { yLeft, yRight, xBottom, xTop, axisCnt } |
enum | LegendPosition { LeftLegend, RightLegend, BottomLegend, TopLegend, ExternalLegend } |
Public Slots | |
virtual void | clear () |
virtual void | replot () |
Redraw the plot. | |
void | autoRefresh () |
Replots the plot if QwtPlot::autoReplot() is true . | |
Signals | |
void | legendClicked (QwtPlotItem *plotItem) |
void | legendChecked (QwtPlotItem *plotItem, bool on) |
Public Member Functions | |
QwtPlot (QWidget *=NULL) | |
Constructor. | |
QwtPlot (const QwtText &title, QWidget *p=NULL) | |
Constructor. | |
QwtPlot (QWidget *, const char *name) | |
Constructor. | |
virtual | ~QwtPlot () |
Destructor. | |
void | applyProperties (const QString &) |
QString | grabProperties () const |
void | setAutoReplot (bool tf=true) |
Set or reset the autoReplot option. | |
bool | autoReplot () const |
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. | |
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. | |
QwtPlotLayout * | plotLayout () |
const QwtPlotLayout * | plotLayout () const |
void | setMargin (int margin) |
int | margin () const |
void | setTitle (const QString &) |
void | setTitle (const QwtText &t) |
QwtText | title () const |
QwtTextLabel * | titleLabel () |
const QwtTextLabel * | titleLabel () const |
QwtPlotCanvas * | canvas () |
const QwtPlotCanvas * | canvas () const |
void | setCanvasBackground (const QColor &c) |
Change the background of the plotting area. | |
const QColor & | canvasBackground () const |
void | setCanvasLineWidth (int w) |
Change the border width of the plotting area Nothing else than canvas()->setLineWidth(w), left for compatibility only. | |
int | canvasLineWidth () const |
virtual QwtScaleMap | canvasMap (int axisId) const |
double | invTransform (int axisId, int pos) const |
int | 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) |
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 &f) |
Change the font of an axis. | |
QFont | axisFont (int axisId) const |
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. | |
double | axisStepSize (int axisId) const |
const QwtScaleDiv * | axisScaleDiv (int axisId) const |
Return the scale division of a specified axis. | |
QwtScaleDiv * | axisScaleDiv (int axisId) |
Return the scale division of a specified axis. | |
const QwtScaleDraw * | axisScaleDraw (int axisId) const |
QwtScaleDraw * | axisScaleDraw (int axisId) |
const QwtScaleWidget * | axisWidget (int axisId) const |
QwtScaleWidget * | axisWidget (int axisId) |
void | setAxisLabelAlignment (int axisId, int) |
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 | axisMaxMajor (int axisId) const |
void | setAxisMaxMajor (int axisId, int maxMajor) |
int | axisMaxMinor (int axisId) const |
void | insertLegend (QwtLegend *, LegendPosition=QwtPlot::RightLegend, double ratio=-1.0) |
Insert a legend. | |
QwtLegend * | legend () |
const QwtLegend * | legend () const |
virtual void | polish () |
Polish. | |
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 scales. | |
virtual bool | event (QEvent *) |
Adds handling of layout requests. | |
Protected Slots | |
virtual void | legendItemClicked () |
virtual void | legendItemChecked (bool) |
Protected Member Functions | |
virtual void | drawItems (QPainter *, const QRect &, const QwtScaleMap maps[axisCnt], const QwtPlotPrintFilter &) const |
virtual void | updateTabOrder () |
virtual void | resizeEvent (QResizeEvent *e) |
virtual void | printLegendItem (QPainter *, const QWidget *, const QRect &) const |
virtual void | printTitle (QPainter *, 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 | printCanvas (QPainter *, const QRect &boundingRect, const QRect &canvasRect, const QwtScaleMap maps[axisCnt], const QwtPlotPrintFilter &) const |
virtual void | printLegend (QPainter *, const QRect &) const |
Static Protected Member Functions | |
static bool | axisValid (int axisId) |
Properties | |
QString | propertiesDocument |
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.
#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"); // copy the data into the curves curve1->setData(...); curve2->setData(...); curve1->attach(myPlot); curve2->attach(myPlot); // finally, refresh the plot myPlot->replot();
Definition at line 72 of file qwt_plot.h.
enum QwtPlot::Axis |
Position of the legend, relative to the canvas.
Definition at line 119 of file qwt_plot.h.
QwtPlot::QwtPlot | ( | QWidget * | parent = NULL ) |
[explicit] |
Constructor.
parent | Parent widget |
Definition at line 52 of file qwt_plot.cpp.
: QFrame(parent) { initPlot(QwtText()); }
QwtPlot::QwtPlot | ( | const QwtText & | title, |
QWidget * | parent = NULL |
||
) | [explicit] |
Constructor.
title | Title text |
parent | Parent widget |
Definition at line 63 of file qwt_plot.cpp.
: QFrame(parent) { initPlot(title); }
QwtPlot::QwtPlot | ( | QWidget * | parent, |
const char * | name | ||
) | [explicit] |
Constructor.
parent | Parent widget |
name | Object name |
Definition at line 75 of file qwt_plot.cpp.
: QFrame(parent, name) { initPlot(QwtText()); }
QwtPlot::~QwtPlot | ( | ) | [virtual] |
Destructor.
Definition at line 84 of file qwt_plot.cpp.
References QwtPlotDict::autoDelete(), QwtPlotDict::detachItems(), QwtPlot::PrivateData::layout, and QwtPlotItem::Rtti_PlotItem.
{ detachItems(QwtPlotItem::Rtti_PlotItem, autoDelete()); delete d_data->layout; deleteAxesData(); delete d_data; }
void QwtPlot::applyProperties | ( | const QString & | xmlDocument ) |
Definition at line 12 of file qwt_plot_xml.cpp.
References replot(), and setTitle().
void QwtPlot::autoRefresh | ( | ) | [slot] |
Replots the plot if QwtPlot::autoReplot() is true
.
Definition at line 163 of file qwt_plot.cpp.
References QwtPlot::PrivateData::autoReplot, and replot().
Referenced by QwtPlotItem::itemChanged(), setAxisAutoScale(), setAxisMaxMajor(), setAxisMaxMinor(), setAxisScale(), setAxisScaleDiv(), setAxisScaleDraw(), and setAxisScaleEngine().
{ if (d_data->autoReplot) replot(); }
bool QwtPlot::autoReplot | ( | ) | const |
Definition at line 190 of file qwt_plot.cpp.
References QwtPlot::PrivateData::autoReplot.
Referenced by QwtPlotPrintFilter::apply(), QwtPlotItem::attach(), QwtPlotCanvas::drawContents(), QwtPlotPanner::moveCanvas(), replot(), QwtPlotZoomer::rescale(), QwtPlotRescaler::rescale(), QwtPlotMagnifier::rescale(), QwtPlotPrintFilter::reset(), and QwtPlotRescaler::updateScales().
{ return d_data->autoReplot; }
bool QwtPlot::axisAutoScale | ( | int | axisId ) | const |
true
if autoscaling is enabled axisId | axis index |
Definition at line 170 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::doAutoScale.
Referenced by updateAxes().
{ if (axisValid(axisId)) return d_axisData[axisId]->doAutoScale; else return false; }
bool QwtPlot::axisEnabled | ( | int | axisId ) | const |
true
if a specified axis is enabled axisId | axis index |
Definition at line 183 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::isEnabled.
Referenced by canvasMap(), QwtPlotLayout::LayoutData::init(), QwtPlotLayout::minimumSizeHint(), print(), printScale(), QwtPlotPicker::QwtPlotPicker(), sizeHint(), and updateLayout().
QFont QwtPlot::axisFont | ( | int | axisId ) | const |
axisId | axis index |
Definition at line 195 of file qwt_plot_axis.cpp.
References axisValid(), and axisWidget().
{ if (axisValid(axisId)) return axisWidget(axisId)->font(); else return QFont(); }
int QwtPlot::axisMaxMajor | ( | int | axisId ) | const |
axisId | axis index sa setAxisMaxMajor() |
Definition at line 209 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::maxMajor.
int QwtPlot::axisMaxMinor | ( | int | axisId ) | const |
axisId | axis index sa setAxisMaxMinor() |
Definition at line 222 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::maxMinor.
const QwtScaleDiv * QwtPlot::axisScaleDiv | ( | int | axisId ) | const |
Return the scale division of a specified axis.
axisScaleDiv(axisId)->lowerBound(), axisScaleDiv(axisId)->upperBound() are the current limits of the axis scale.
axisId | axis index |
Definition at line 241 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::scaleDiv.
Referenced by canvasMap(), QwtPlotRescaler::interval(), QwtPlotPanner::moveCanvas(), print(), QwtPlotZoomer::rescale(), QwtPlotMagnifier::rescale(), QwtPlotPicker::scaleRect(), QwtPlotScaleItem::setScaleDivFromAxis(), QwtPlotScaleItem::setScaleDraw(), updateAxes(), and QwtPlotRescaler::updateScales().
QwtScaleDiv * QwtPlot::axisScaleDiv | ( | int | axisId ) |
Return the scale division of a specified axis.
axisScaleDiv(axisId)->lowerBound(), axisScaleDiv(axisId)->upperBound() are the current limits of the axis scale.
axisId | axis index |
Definition at line 260 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::scaleDiv.
const QwtScaleDraw * QwtPlot::axisScaleDraw | ( | int | axisId ) | const |
axisId | axis index |
Definition at line 274 of file qwt_plot_axis.cpp.
References axisValid(), axisWidget(), and QwtScaleWidget::scaleDraw().
{ if (!axisValid(axisId)) return NULL; return axisWidget(axisId)->scaleDraw(); }
QwtScaleDraw * QwtPlot::axisScaleDraw | ( | int | axisId ) |
axisId | axis index |
Definition at line 288 of file qwt_plot_axis.cpp.
References axisValid(), axisWidget(), and QwtScaleWidget::scaleDraw().
{ if (!axisValid(axisId)) return NULL; return axisWidget(axisId)->scaleDraw(); }
const QwtScaleEngine * QwtPlot::axisScaleEngine | ( | int | axisId ) | const |
axisId | axis index |
Definition at line 159 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::scaleEngine.
{ if (axisValid(axisId)) return d_axisData[axisId]->scaleEngine; else return NULL; }
QwtScaleEngine * QwtPlot::axisScaleEngine | ( | int | axisId ) |
axisId | axis index |
Definition at line 147 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::scaleEngine.
Referenced by canvasMap(), and print().
{ if (axisValid(axisId)) return d_axisData[axisId]->scaleEngine; else return NULL; }
double QwtPlot::axisStepSize | ( | int | 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.
axisId | axis index |
Definition at line 306 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::stepSize.
QwtText QwtPlot::axisTitle | ( | int | axisId ) | const |
axisId | axis index |
Definition at line 318 of file qwt_plot_axis.cpp.
References axisValid(), axisWidget(), and QwtScaleWidget::title().
{ if (axisValid(axisId)) return axisWidget(axisId)->title(); else return QwtText(); }
bool QwtPlot::axisValid | ( | int | axisId ) | [static, protected] |
true
if the specified axis exists, otherwise false
axisId | axis index |
Definition at line 733 of file qwt_plot.cpp.
References axisCnt, and yLeft.
Referenced by axisAutoScale(), axisEnabled(), axisFont(), axisMaxMajor(), axisMaxMinor(), axisScaleDiv(), axisScaleDraw(), axisScaleEngine(), axisStepSize(), axisTitle(), axisWidget(), enableAxis(), invTransform(), setAxisAutoScale(), setAxisFont(), setAxisLabelRotation(), setAxisMaxMajor(), setAxisMaxMinor(), setAxisScale(), setAxisScaleDiv(), setAxisScaleDraw(), setAxisScaleEngine(), setAxisTitle(), and transform().
{ return ((axisId >= QwtPlot::yLeft) && (axisId < QwtPlot::axisCnt)); }
const QwtScaleWidget * QwtPlot::axisWidget | ( | int | axisId ) | const |
axisId | axis index |
Definition at line 100 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::scaleWidget.
Referenced by QwtPlotPrintFilter::apply(), axisFont(), axisScaleDraw(), axisTitle(), canvasMap(), QwtPlotLayout::LayoutData::init(), QwtPlotLayout::minimumSizeHint(), print(), printScale(), QwtPlotPrintFilter::reset(), setAxisFont(), setAxisLabelRotation(), setAxisScaleDraw(), setAxisTitle(), sizeHint(), updateAxes(), and updateLayout().
{ if (axisValid(axisId)) return d_axisData[axisId]->scaleWidget; return NULL; }
QwtScaleWidget * QwtPlot::axisWidget | ( | int | axisId ) |
axisId | axis index |
Definition at line 112 of file qwt_plot_axis.cpp.
References axisValid(), and QwtPlot::AxisData::scaleWidget.
{ if (axisValid(axisId)) return d_axisData[axisId]->scaleWidget; return NULL; }
QwtPlotCanvas * QwtPlot::canvas | ( | ) |
Definition at line 275 of file qwt_plot.cpp.
References QwtPlot::PrivateData::canvas.
Referenced by canvasBackground(), canvasLineWidth(), QwtPlotCurve::draw(), QwtPlotLayout::LayoutData::init(), QmitkHistogramWidget::InitializeZoomer(), QwtPlotLayout::minimumSizeHint(), printCanvas(), QmitkHistogramWidget::QmitkHistogramWidget(), setCanvasBackground(), and setCanvasLineWidth().
{ return d_data->canvas; }
const QwtPlotCanvas * QwtPlot::canvas | ( | ) | const |
Definition at line 283 of file qwt_plot.cpp.
References QwtPlot::PrivateData::canvas.
{ return d_data->canvas; }
const QColor & QwtPlot::canvasBackground | ( | ) | const |
Nothing else than: canvas()->palette().color( QPalette::Normal, QColorGroup::Background);
Definition at line 696 of file qwt_plot.cpp.
References canvas().
Referenced by QwtPlotPrintFilter::apply().
int QwtPlot::canvasLineWidth | ( | ) | const |
Nothing else than: canvas()->lineWidth(), left for compatibility only.
Definition at line 724 of file qwt_plot.cpp.
References canvas().
{ return canvas()->lineWidth(); }
QwtScaleMap QwtPlot::canvasMap | ( | int | axisId ) | const [virtual] |
axisId | Axis |
Definition at line 592 of file qwt_plot.cpp.
References axisEnabled(), axisScaleDiv(), axisScaleEngine(), axisWidget(), QwtPlot::PrivateData::canvas, QwtPlotLayout::canvasMargin(), QwtScaleWidget::endBorderDist(), QwtScaleDiv::lowerBound(), margin(), plotLayout(), QwtScaleMap::setPaintInterval(), QwtScaleMap::setScaleInterval(), QwtScaleMap::setTransformation(), QwtScaleWidget::startBorderDist(), QwtScaleDiv::upperBound(), yLeft, and yRight.
Referenced by QwtPlotCurve::closestPoint(), QwtPlotCurve::draw(), drawCanvas(), QwtPlotPicker::invTransform(), invTransform(), QwtPlotPanner::moveCanvas(), QwtPlotPicker::transform(), and transform().
{ QwtScaleMap map; if ( !d_data->canvas ) return map; map.setTransformation(axisScaleEngine(axisId)->transformation()); const QwtScaleDiv *sd = axisScaleDiv(axisId); map.setScaleInterval(sd->lowerBound(), sd->upperBound()); if ( axisEnabled(axisId) ) { const QwtScaleWidget *s = axisWidget(axisId); if ( axisId == yLeft || axisId == yRight ) { int y = s->y() + s->startBorderDist() - d_data->canvas->y(); int h = s->height() - s->startBorderDist() - s->endBorderDist(); map.setPaintInterval(y + h, y); } else { int x = s->x() + s->startBorderDist() - d_data->canvas->x(); int w = s->width() - s->startBorderDist() - s->endBorderDist(); map.setPaintInterval(x, x + w); } } else { const int margin = plotLayout()->canvasMargin(axisId); const QRect &canvasRect = d_data->canvas->contentsRect(); if ( axisId == yLeft || axisId == yRight ) { map.setPaintInterval(canvasRect.bottom() - margin, canvasRect.top() + margin); } else { map.setPaintInterval(canvasRect.left() + margin, canvasRect.right() - margin); } } return map; }
void QwtPlot::clear | ( | ) | [virtual, slot] |
Remove all curves and markers
Definition at line 772 of file qwt_plot.cpp.
References QwtPlotDict::detachItems(), QwtPlotItem::Rtti_PlotCurve, and QwtPlotItem::Rtti_PlotMarker.
Referenced by QmitkPlotWidget::Clear(), and QmitkHistogramWidget::SetHistogram().
void QwtPlot::drawCanvas | ( | QPainter * | painter ) | [virtual] |
Redraw the canvas.
painter | Painter used for drawing |
Definition at line 534 of file qwt_plot.cpp.
References axisCnt, QwtPlot::PrivateData::canvas, canvasMap(), and drawItems().
{ QwtScaleMap maps[axisCnt]; for ( int axisId = 0; axisId < axisCnt; axisId++ ) maps[axisId] = canvasMap(axisId); drawItems(painter, d_data->canvas->contentsRect(), maps, QwtPlotPrintFilter()); }
void QwtPlot::drawItems | ( | QPainter * | painter, |
const QRect & | rect, | ||
const QwtScaleMap | map[axisCnt], | ||
const QwtPlotPrintFilter & | pfilter | ||
) | const [protected, virtual] |
Redraw the canvas items.
painter | Painter used for drawing |
rect | Bounding rectangle where to paint |
map | QwtPlot::axisCnt maps, mapping between plot and paint device coordinates |
pfilter | Plot print filter |
Definition at line 552 of file qwt_plot.cpp.
References QwtPlotItem::draw(), QwtPlotItem::isVisible(), QwtPlotDict::itemList(), QwtPlotPrintFilter::options(), QwtPlotPrintFilter::PrintGrid, QwtPlotItem::rtti(), QwtPlotItem::Rtti_PlotGrid, QwtPlotItem::xAxis(), and QwtPlotItem::yAxis().
Referenced by drawCanvas(), and printCanvas().
{ const QwtPlotItemList& itmList = itemList(); for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it ) { QwtPlotItem *item = *it; if ( item && item->isVisible() ) { if ( !(pfilter.options() & QwtPlotPrintFilter::PrintGrid) && item->rtti() == QwtPlotItem::Rtti_PlotGrid ) { continue; } painter->save(); #if QT_VERSION >= 0x040000 painter->setRenderHint(QPainter::Antialiasing, item->testRenderHint(QwtPlotItem::RenderAntialiased) ); #endif item->draw(painter, map[item->xAxis()], map[item->yAxis()], rect); painter->restore(); } } }
void QwtPlot::enableAxis | ( | int | axisId, |
bool | tf = true |
||
) |
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.
axisId | axis index |
tf | true (enabled) or false (disabled) |
Definition at line 338 of file qwt_plot_axis.cpp.
References axisValid(), QwtPlot::AxisData::isEnabled, and updateLayout().
{ if (axisValid(axisId) && tf != d_axisData[axisId]->isEnabled) { d_axisData[axisId]->isEnabled = tf; updateLayout(); } }
bool QwtPlot::event | ( | QEvent * | e ) | [virtual] |
Adds handling of layout requests.
Definition at line 140 of file qwt_plot.cpp.
References polish(), and updateLayout().
{ bool ok = QFrame::event(e); switch(e->type()) { #if QT_VERSION < 0x040000 case QEvent::LayoutHint: #else case QEvent::LayoutRequest: #endif updateLayout(); break; #if QT_VERSION >= 0x040000 case QEvent::PolishRequest: polish(); break; #endif default:; } return ok; }
QString QwtPlot::grabProperties | ( | ) | const |
Definition at line 21 of file qwt_plot_xml.cpp.
References QwtText::text(), and title().
void QwtPlot::insertLegend | ( | QwtLegend * | 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.
If pos != QwtPlot::ExternalLegend the plot widget will become parent of the legend. It will be deleted when the plot is deleted, or another legend is set with insertLegend().
legend | Legend |
pos | The legend's position. For top/left position the number of colums will be limited to 1, otherwise it will be set to unlimited. |
ratio | Ratio between legend and the bounding rect of title, canvas and axes. The legend will be shrinked 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. |
Definition at line 805 of file qwt_plot.cpp.
References BottomLegend, ExternalLegend, QwtPlotDict::itemList(), QwtPlot::PrivateData::layout, LeftLegend, QwtPlot::PrivateData::legend, QwtPlotLayout::legendPosition(), RightLegend, QwtPlotLayout::setLegendPosition(), QwtDynGridLayout::setMaxCols(), TopLegend, updateLayout(), and updateTabOrder().
{ d_data->layout->setLegendPosition(pos, ratio); if ( legend != d_data->legend ) { if ( d_data->legend && d_data->legend->parent() == this ) delete d_data->legend; d_data->legend = legend; if ( d_data->legend ) { if ( pos != ExternalLegend ) { if ( d_data->legend->parent() != this ) { #if QT_VERSION < 0x040000 d_data->legend->reparent(this, QPoint(0, 0)); #else d_data->legend->setParent(this); #endif } } const QwtPlotItemList& itmList = itemList(); for ( QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it ) { (*it)->updateLegend(d_data->legend); } QLayout *l = d_data->legend->contentsWidget()->layout(); if ( l && l->inherits("QwtDynGridLayout") ) { QwtDynGridLayout *tl = (QwtDynGridLayout *)l; switch(d_data->layout->legendPosition()) { case LeftLegend: case RightLegend: tl->setMaxCols(1); // 1 column: align vertical break; case TopLegend: case BottomLegend: tl->setMaxCols(0); // unlimited break; case ExternalLegend: break; } } } updateTabOrder(); } updateLayout(); }
double QwtPlot::invTransform | ( | int | axisId, |
int | pos | ||
) | const |
Transform the x or y coordinate of a position in the drawing region into a value.
axisId | axis index |
pos | position |
Definition at line 355 of file qwt_plot_axis.cpp.
References axisValid(), and canvasMap().
{ if (axisValid(axisId)) return(canvasMap(axisId).invTransform(pos)); else return 0.0; }
QwtLegend * QwtPlot::legend | ( | ) |
Definition at line 257 of file qwt_plot.cpp.
References QwtPlot::PrivateData::legend.
Referenced by QwtPlotLayout::activate(), QwtPlotPrintFilter::apply(), QwtPlotItem::attach(), QwtPlotLayout::LayoutData::init(), QwtPlotItem::itemChanged(), QwtPlotLayout::minimumSizeHint(), print(), printLegend(), and QwtPlotPrintFilter::reset().
{ return d_data->legend; }
const QwtLegend * QwtPlot::legend | ( | ) | const |
Definition at line 266 of file qwt_plot.cpp.
References QwtPlot::PrivateData::legend.
{ return d_data->legend; }
void QwtPlot::legendChecked | ( | QwtPlotItem * | plotItem, |
bool | on | ||
) | [signal] |
A signal which is emitted when the user has clicked on a legend item, which is in QwtLegend::CheckableItem mode
plotItem | Corresponding plot item of the selected legend item |
on | True when the legen item is checked |
Referenced by legendItemChecked().
void QwtPlot::legendClicked | ( | QwtPlotItem * | plotItem ) | [signal] |
A signal which is emitted when the user has clicked on a legend item, which is in QwtLegend::ClickableItem mode.
plotItem | Corresponding plot item of the selected legend item |
Referenced by legendItemClicked().
void QwtPlot::legendItemChecked | ( | bool | on ) | [protected, virtual, slot] |
Called internally when the legend has been checked Emits a legendClicked() signal.
Definition at line 757 of file qwt_plot.cpp.
References QwtPlot::PrivateData::legend, and legendChecked().
{ if ( d_data->legend && sender()->isWidgetType() ) { QwtPlotItem *plotItem = (QwtPlotItem*)d_data->legend->find((QWidget *)sender()); if ( plotItem ) emit legendChecked(plotItem, on); } }
void QwtPlot::legendItemClicked | ( | ) | [protected, virtual, slot] |
Called internally when the legend has been clicked on. Emits a legendClicked() signal.
Definition at line 742 of file qwt_plot.cpp.
References QwtPlot::PrivateData::legend, and legendClicked().
{ if ( d_data->legend && sender()->isWidgetType() ) { QwtPlotItem *plotItem = (QwtPlotItem*)d_data->legend->find((QWidget *)sender()); if ( plotItem ) emit legendClicked(plotItem); } }
int QwtPlot::margin | ( | ) | const |
Definition at line 661 of file qwt_plot.cpp.
References QwtPlot::PrivateData::layout, and QwtPlotLayout::margin().
Referenced by canvasMap(), and print().
QSize QwtPlot::minimumSizeHint | ( | ) | const [virtual] |
Return a minimum size hint.
Definition at line 338 of file qwt_plot.cpp.
References QwtPlot::PrivateData::layout, and QwtPlotLayout::minimumSizeHint().
Referenced by sizeHint().
{ QSize hint = d_data->layout->minimumSizeHint(this); hint += QSize(2 * frameWidth(), 2 * frameWidth()); return hint; }
const QwtPlotLayout * QwtPlot::plotLayout | ( | ) | const |
Definition at line 234 of file qwt_plot.cpp.
References QwtPlot::PrivateData::layout.
{ return d_data->layout; }
QwtPlotLayout * QwtPlot::plotLayout | ( | ) |
Definition at line 228 of file qwt_plot.cpp.
References QwtPlot::PrivateData::layout.
Referenced by canvasMap(), QwtPlotLayout::LayoutData::init(), and print().
{ return d_data->layout; }
void QwtPlot::polish | ( | ) | [virtual] |
Polish.
Definition at line 289 of file qwt_plot.cpp.
References replot().
Referenced by event().
{ replot(); #if QT_VERSION < 0x040000 QFrame::polish(); #endif }
void QwtPlot::print | ( | QPaintDevice & | paintDev, |
const QwtPlotPrintFilter & | pfilter = 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.
paintDev | device to paint on, often a printer |
pfilter | print filter |
Definition at line 43 of file qwt_plot_print.cpp.
{ #if QT_VERSION < 0x040000 QPaintDeviceMetrics mpr(&paintDev); int w = mpr.width(); int h = mpr.height(); #else int w = paintDev.width(); int h = paintDev.height(); #endif QRect rect(0, 0, w, h); double aspect = double(rect.width())/double(rect.height()); if ((aspect < 1.0)) rect.setHeight(int(aspect*rect.width())); QPainter p(&paintDev); print(&p, rect, pfilter); }
void QwtPlot::print | ( | QPainter * | painter, |
const QRect & | plotRect, | ||
const QwtPlotPrintFilter & | pfilter = QwtPlotPrintFilter() |
||
) | const [virtual] |
Paint the plot into a given rectangle. Paint the contents of a QwtPlot instance into a given rectangle.
painter | Painter |
plotRect | Bounding rectangle |
pfilter | Print filter |
Definition at line 74 of file qwt_plot_print.cpp.
References QwtPlotPrintFilter::apply(), axisCnt, axisEnabled(), axisScaleDiv(), axisScaleEngine(), axisWidget(), boundingRect(), QwtPlotLayout::canvasMargin(), QwtPlotLayout::canvasRect(), QwtScaleWidget::endBorderDist(), QwtScaleWidget::getBorderDistHint(), QwtPlotLayout::IgnoreFrames, QwtPlotLayout::IgnoreLegend, QwtPlotLayout::IgnoreMargin, QwtPlotLayout::IgnoreScrollbars, QwtLegend::isEmpty(), QwtText::isEmpty(), legend(), QwtScaleDiv::lowerBound(), margin(), QwtScaleWidget::margin(), QwtPainter::metricsMap(), QwtPlotPrintFilter::options(), plotLayout(), printCanvas(), QwtPlotPrintFilter::PrintFrameWithScales, printLegend(), QwtPlotPrintFilter::PrintLegend, QwtPlotPrintFilter::PrintMargin, printScale(), printTitle(), QwtPlotPrintFilter::PrintTitle, QwtPlotPrintFilter::reset(), QwtPainter::resetMetricsMap(), QwtPlotLayout::scaleRect(), QwtScaleWidget::setMargin(), QwtPainter::setMetricsMap(), QwtScaleMap::setPaintXInterval(), QwtScaleMap::setScaleInterval(), QwtScaleMap::setTransformation(), QwtDoubleRect::setWidth(), QwtScaleWidget::startBorderDist(), QwtTextLabel::text(), titleLabel(), QwtScaleDiv::upperBound(), xBottom, xTop, yLeft, and yRight.
{ int axisId; if ( painter == 0 || !painter->isActive() || !plotRect.isValid() || size().isNull() ) return; painter->save(); #if 1 /* PDF: In Qt4 ( <= 4.3.2 ) the scales are painted in gray instead of black. See http://trolltech.com/developer/task-tracker/index_html?id=184671&method=entry The dummy lines below work around the problem. */ const QPen pen = painter->pen(); painter->setPen(QPen(Qt::black, 1)); painter->setPen(pen); #endif // All paint operations need to be scaled according to // the paint device metrics. QwtPainter::setMetricsMap(this, painter->device()); const QwtMetricsMap &metricsMap = QwtPainter::metricsMap(); // It is almost impossible to integrate into the Qt layout // framework, when using different fonts for printing // and screen. To avoid writing different and Qt unconform // layout engines we change the widget attributes, print and // reset the widget attributes again. This way we produce a lot of // useless layout events ... pfilter.apply((QwtPlot *)this); int baseLineDists[QwtPlot::axisCnt]; if ( pfilter.options() & QwtPlotPrintFilter::PrintFrameWithScales ) { for (axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ) { QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId); if ( scaleWidget ) { baseLineDists[axisId] = scaleWidget->margin(); scaleWidget->setMargin(0); } } } // Calculate the layout for the print. int layoutOptions = QwtPlotLayout::IgnoreScrollbars | QwtPlotLayout::IgnoreFrames; if ( !(pfilter.options() & QwtPlotPrintFilter::PrintMargin) ) layoutOptions |= QwtPlotLayout::IgnoreMargin; if ( !(pfilter.options() & QwtPlotPrintFilter::PrintLegend) ) layoutOptions |= QwtPlotLayout::IgnoreLegend; ((QwtPlot *)this)->plotLayout()->activate(this, QwtPainter::metricsMap().deviceToLayout(plotRect), layoutOptions); if ((pfilter.options() & QwtPlotPrintFilter::PrintTitle) && (!titleLabel()->text().isEmpty())) { printTitle(painter, plotLayout()->titleRect()); } if ( (pfilter.options() & QwtPlotPrintFilter::PrintLegend) && legend() && !legend()->isEmpty() ) { printLegend(painter, plotLayout()->legendRect()); } for ( axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ) { QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId); if (scaleWidget) { int baseDist = scaleWidget->margin(); int startDist, endDist; scaleWidget->getBorderDistHint(startDist, endDist); printScale(painter, axisId, startDist, endDist, baseDist, plotLayout()->scaleRect(axisId)); } } QRect canvasRect = plotLayout()->canvasRect(); /* The border of the bounding rect needs to ba scaled to layout coordinates, so that it is aligned to the axes */ QRect boundingRect( canvasRect.left() - 1, canvasRect.top() - 1, canvasRect.width() + 2, canvasRect.height() + 2); boundingRect = metricsMap.layoutToDevice(boundingRect); boundingRect.setWidth(boundingRect.width() - 1); boundingRect.setHeight(boundingRect.height() - 1); canvasRect = metricsMap.layoutToDevice(canvasRect); // When using QwtPainter all sizes where computed in pixel // coordinates and scaled by QwtPainter later. This limits // the precision to screen resolution. A better solution // is to scale the maps and print in unlimited resolution. QwtScaleMap map[axisCnt]; for (axisId = 0; axisId < axisCnt; axisId++) { map[axisId].setTransformation(axisScaleEngine(axisId)->transformation()); const QwtScaleDiv &scaleDiv = *axisScaleDiv(axisId); map[axisId].setScaleInterval( scaleDiv.lowerBound(), scaleDiv.upperBound()); double from, to; if ( axisEnabled(axisId) ) { const int sDist = axisWidget(axisId)->startBorderDist(); const int eDist = axisWidget(axisId)->endBorderDist(); const QRect &scaleRect = plotLayout()->scaleRect(axisId); if ( axisId == xTop || axisId == xBottom ) { from = metricsMap.layoutToDeviceX(scaleRect.left() + sDist); to = metricsMap.layoutToDeviceX(scaleRect.right() + 1 - eDist); } else { from = metricsMap.layoutToDeviceY(scaleRect.bottom() + 1 - eDist ); to = metricsMap.layoutToDeviceY(scaleRect.top() + sDist); } } else { int margin = plotLayout()->canvasMargin(axisId); if ( axisId == yLeft || axisId == yRight ) { margin = metricsMap.layoutToDeviceY(margin); from = canvasRect.bottom() - margin; to = canvasRect.top() + margin; } else { margin = metricsMap.layoutToDeviceX(margin); from = canvasRect.left() + margin; to = canvasRect.right() - margin; } } map[axisId].setPaintXInterval(from, to); } // The canvas maps are already scaled. QwtPainter::setMetricsMap(painter->device(), painter->device()); printCanvas(painter, boundingRect, canvasRect, map, pfilter); QwtPainter::resetMetricsMap(); ((QwtPlot *)this)->plotLayout()->invalidate(); // reset all widgets with their original attributes. if ( pfilter.options() & QwtPlotPrintFilter::PrintFrameWithScales ) { // restore the previous base line dists for (axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ) { QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId); if ( scaleWidget ) scaleWidget->setMargin(baseLineDists[axisId]); } } pfilter.reset((QwtPlot *)this); painter->restore(); }
void QwtPlot::printCanvas | ( | QPainter * | painter, |
const QRect & | boundingRect, | ||
const QRect & | canvasRect, | ||
const QwtScaleMap | map[axisCnt], | ||
const QwtPlotPrintFilter & | pfilter | ||
) | const [protected, virtual] |
Print the canvas into a given rectangle.
painter | Painter |
map | Maps mapping between plot and paint device coordinates |
boundingRect | Bounding rectangle |
canvasRect | Canvas rectangle |
pfilter | Print filter |
Definition at line 471 of file qwt_plot_print.cpp.
References boundingRect(), canvas(), drawItems(), QwtPainter::drawRect(), QwtPainter::fillRect(), QwtPlotPrintFilter::options(), QwtPlotPrintFilter::PrintBackground, QwtPlotPrintFilter::PrintFrameWithScales, QwtPainter::setClipRect(), and QwtDoubleRect::setWidth().
Referenced by print().
{ if ( pfilter.options() & QwtPlotPrintFilter::PrintBackground ) { QBrush bgBrush; #if QT_VERSION >= 0x040000 bgBrush = canvas()->palette().brush(backgroundRole()); #else QColorGroup::ColorRole role = QPalette::backgroundRoleFromMode( backgroundMode() ); bgBrush = canvas()->colorGroup().brush( role ); #endif QRect r = boundingRect; if ( !(pfilter.options() & QwtPlotPrintFilter::PrintFrameWithScales) ) { r = canvasRect; #if QT_VERSION >= 0x040000 // Unfortunately the paint engines do no always the same const QPaintEngine *pe = painter->paintEngine(); if ( pe ) { switch(painter->paintEngine()->type() ) { case QPaintEngine::Raster: case QPaintEngine::X11: break; default: r.setWidth(r.width() - 1); r.setHeight(r.height() - 1); break; } } #else if ( painter->device()->isExtDev() ) { r.setWidth(r.width() - 1); r.setHeight(r.height() - 1); } #endif } QwtPainter::fillRect(painter, r, bgBrush); } if ( pfilter.options() & QwtPlotPrintFilter::PrintFrameWithScales ) { painter->save(); painter->setPen(QPen(Qt::black)); painter->setBrush(QBrush(Qt::NoBrush)); QwtPainter::drawRect(painter, boundingRect); painter->restore(); } painter->setClipping(true); QwtPainter::setClipRect(painter, canvasRect); drawItems(painter, canvasRect, map, pfilter); }
void QwtPlot::printLegend | ( | QPainter * | painter, |
const QRect & | rect | ||
) | const [protected, virtual] |
Print the legend into a given rectangle.
painter | Painter |
rect | Bounding rectangle |
Definition at line 284 of file qwt_plot_print.cpp.
References QwtDynGridLayout::columnsForWidth(), QwtLegend::contentsWidget(), QwtDynGridLayout::iterator(), QwtDynGridLayout::layoutItems(), legend(), printLegendItem(), and QwtPainter::setClipRect().
Referenced by print().
{ if ( !legend() || legend()->isEmpty() ) return; QLayout *l = legend()->contentsWidget()->layout(); if ( l == 0 || !l->inherits("QwtDynGridLayout") ) return; QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l; uint numCols = legendLayout->columnsForWidth(rect.width()); #if QT_VERSION < 0x040000 QValueList<QRect> itemRects = legendLayout->layoutItems(rect, numCols); #else QList<QRect> itemRects = legendLayout->layoutItems(rect, numCols); #endif int index = 0; #if QT_VERSION < 0x040000 QLayoutIterator layoutIterator = legendLayout->iterator(); for ( QLayoutItem *item = layoutIterator.current(); item != 0; item = ++layoutIterator) { #else for ( int i = 0; i < legendLayout->count(); i++ ) { QLayoutItem *item = legendLayout->itemAt(i); #endif QWidget *w = item->widget(); if ( w ) { painter->save(); painter->setClipping(true); QwtPainter::setClipRect(painter, itemRects[index]); printLegendItem(painter, w, itemRects[index]); index++; painter->restore(); } } }
void QwtPlot::printLegendItem | ( | QPainter * | painter, |
const QWidget * | w, | ||
const QRect & | rect | ||
) | const [protected, virtual] |
Print the legend item into a given rectangle.
painter | Painter |
w | Widget representing a legend item |
rect | Bounding rectangle |
Definition at line 339 of file qwt_plot_print.cpp.
References QwtLegendItem::drawItem().
Referenced by printLegend().
{ if ( w->inherits("QwtLegendItem") ) { QwtLegendItem *item = (QwtLegendItem *)w; painter->setFont(item->font()); item->drawItem(painter, rect); } }
void QwtPlot::printScale | ( | QPainter * | painter, |
int | axisId, | ||
int | startDist, | ||
int | endDist, | ||
int | baseDist, | ||
const QRect & | rect | ||
) | const [protected, virtual] |
Paint a scale into a given rectangle. Paint the scale into a given rectangle.
painter | Painter |
axisId | Axis |
startDist | Start border distance |
endDist | End border distance |
baseDist | Base distance |
rect | Bounding rectangle |
Definition at line 363 of file qwt_plot_print.cpp.
References axisEnabled(), axisWidget(), QwtScaleDraw::BottomScale, QwtScaleWidget::colorBarRect(), QwtScaleWidget::colorBarWidth(), QwtAbstractScaleDraw::draw(), QwtScaleWidget::drawColorBar(), QwtScaleWidget::drawTitle(), QwtScaleWidget::isColorBarEnabled(), QwtMetricsMap::layoutToScreen(), QwtScaleDraw::LeftScale, QwtScaleDraw::length(), QwtPainter::metricsMap(), QwtScaleDraw::move(), QwtScaleDraw::orientation(), QwtScaleWidget::penWidth(), QwtScaleDraw::pos(), QwtScaleDraw::RightScale, QwtScaleWidget::scaleDraw(), QwtMetricsMap::screenToLayoutX(), QwtMetricsMap::screenToLayoutY(), QwtScaleDraw::setLength(), QwtScaleWidget::spacing(), QwtScaleDraw::TopScale, xBottom, xTop, yLeft, and yRight.
Referenced by print().
{ if (!axisEnabled(axisId)) return; const QwtScaleWidget *scaleWidget = axisWidget(axisId); if ( scaleWidget->isColorBarEnabled() && scaleWidget->colorBarWidth() > 0) { const QwtMetricsMap map = QwtPainter::metricsMap(); QRect r = map.layoutToScreen(rect); r.setWidth(r.width() - 1); r.setHeight(r.height() - 1); scaleWidget->drawColorBar(painter, scaleWidget->colorBarRect(r)); const int off = scaleWidget->colorBarWidth() + scaleWidget->spacing(); if ( scaleWidget->scaleDraw()->orientation() == Qt::Horizontal ) baseDist += map.screenToLayoutY(off); else baseDist += map.screenToLayoutX(off); } QwtScaleDraw::Alignment align; int x, y, w; switch(axisId) { case yLeft: { x = rect.right() - baseDist; y = rect.y() + startDist; w = rect.height() - startDist - endDist; align = QwtScaleDraw::LeftScale; break; } case yRight: { x = rect.left() + baseDist; y = rect.y() + startDist; w = rect.height() - startDist - endDist; align = QwtScaleDraw::RightScale; break; } case xTop: { x = rect.left() + startDist; y = rect.bottom() - baseDist; w = rect.width() - startDist - endDist; align = QwtScaleDraw::TopScale; break; } case xBottom: { x = rect.left() + startDist; y = rect.top() + baseDist; w = rect.width() - startDist - endDist; align = QwtScaleDraw::BottomScale; break; } default: return; } scaleWidget->drawTitle(painter, align, rect); painter->save(); painter->setFont(scaleWidget->font()); QPen pen = painter->pen(); pen.setWidth(scaleWidget->penWidth()); painter->setPen(pen); QwtScaleDraw *sd = (QwtScaleDraw *)scaleWidget->scaleDraw(); const QPoint sdPos = sd->pos(); const int sdLength = sd->length(); sd->move(x, y); sd->setLength(w); #if QT_VERSION < 0x040000 sd->draw(painter, scaleWidget->palette().active()); #else QPalette palette = scaleWidget->palette(); palette.setCurrentColorGroup(QPalette::Active); sd->draw(painter, palette); #endif // reset previous values sd->move(sdPos); sd->setLength(sdLength); painter->restore(); }
void QwtPlot::printTitle | ( | QPainter * | painter, |
const QRect & | rect | ||
) | const [protected, virtual] |
Print the title into a given rectangle.
painter | Painter |
rect | Bounding rectangle |
Definition at line 260 of file qwt_plot_print.cpp.
References QwtText::draw(), QwtTextLabel::text(), and titleLabel().
Referenced by print().
{ painter->setFont(titleLabel()->font()); const QColor color = #if QT_VERSION < 0x040000 titleLabel()->palette().color( QPalette::Active, QColorGroup::Text); #else titleLabel()->palette().color( QPalette::Active, QPalette::Text); #endif painter->setPen(color); titleLabel()->text().draw(painter, rect); }
void QwtPlot::replot | ( | ) | [virtual, slot] |
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.
Definition at line 366 of file qwt_plot.cpp.
References autoReplot(), QwtPlot::PrivateData::canvas, setAutoReplot(), and updateAxes().
Referenced by applyProperties(), autoRefresh(), QwtPlotPanner::moveCanvas(), QmitkHistogramWidget::OnSelect(), polish(), QmitkPlotWidget::Replot(), QwtPlotZoomer::rescale(), QwtPlotMagnifier::rescale(), QmitkHistogramWidget::SetHistogram(), QwtPlotZoomer::setZoomBase(), and QwtPlotRescaler::updateScales().
{ bool doAutoReplot = autoReplot(); setAutoReplot(false); updateAxes(); /* Maybe the layout needs to be updated, because of changed axes labels. We need to process them here before painting to avoid that scales and canvas get out of sync. */ #if QT_VERSION >= 0x040000 QApplication::sendPostedEvents(this, QEvent::LayoutRequest); #else QApplication::sendPostedEvents(this, QEvent::LayoutHint); #endif d_data->canvas->replot(); setAutoReplot(doAutoReplot); }
void QwtPlot::resizeEvent | ( | QResizeEvent * | e ) | [protected, virtual] |
Resize and update internal layout
e | Resize event |
Definition at line 350 of file qwt_plot.cpp.
References updateLayout().
{ QFrame::resizeEvent(e); updateLayout(); }
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.
tf | true or false . Defaults to true . |
Definition at line 184 of file qwt_plot.cpp.
References QwtPlot::PrivateData::autoReplot.
Referenced by QwtPlotPrintFilter::apply(), QwtPlotCanvas::drawContents(), QwtPlotPanner::moveCanvas(), replot(), QwtPlotZoomer::rescale(), QwtPlotRescaler::rescale(), QwtPlotMagnifier::rescale(), QwtPlotPrintFilter::reset(), and QwtPlotRescaler::updateScales().
{ d_data->autoReplot = tf; }
void QwtPlot::setAxisAutoScale | ( | int | axisId ) |
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.
axisId | axis index |
Definition at line 402 of file qwt_plot_axis.cpp.
References autoRefresh(), axisValid(), and QwtPlot::AxisData::doAutoScale.
{ if (axisValid(axisId) && !d_axisData[axisId]->doAutoScale ) { d_axisData[axisId]->doAutoScale = true; autoRefresh(); } }
void QwtPlot::setAxisFont | ( | int | axisId, |
const QFont & | f | ||
) |
Change the font of an axis.
axisId | axis index |
f | font |
Definition at line 387 of file qwt_plot_axis.cpp.
References axisValid(), and axisWidget().
{ if (axisValid(axisId)) axisWidget(axisId)->setFont(f); }
void QwtPlot::setAxisLabelAlignment | ( | int | axisId, |
int | alignment | ||
) |
Change the alignment of the tick labels
axisId | axis index |
alignment | Or'd Qt::AlignmentFlags <see qnamespace.h> |
Definition at line 487 of file qwt_plot_axis.cpp.
{ if (axisValid(axisId)) axisWidget(axisId)->setLabelAlignment(alignment); }
void QwtPlot::setAxisLabelRotation | ( | int | axisId, |
double | rotation | ||
) |
Rotate all tick labels
axisId | axis index |
rotation | Angle in degrees. When changing the label rotation, the label alignment might be adjusted too. |
Definition at line 503 of file qwt_plot_axis.cpp.
References axisValid(), axisWidget(), and QwtScaleWidget::setLabelRotation().
{ if (axisValid(axisId)) axisWidget(axisId)->setLabelRotation(rotation); }
void QwtPlot::setAxisMaxMajor | ( | int | axisId, |
int | maxMajor | ||
) |
Set the maximum number of major scale intervals for a specified axis
axisId | axis index |
maxMajor | maximum number of major steps |
Definition at line 543 of file qwt_plot_axis.cpp.
References autoRefresh(), axisValid(), QwtScaleDiv::invalidate(), QwtPlot::AxisData::maxMajor, QwtPlot::AxisData::maxMinor, and QwtPlot::AxisData::scaleDiv.
{ if (axisValid(axisId)) { if ( maxMajor < 1 ) maxMajor = 1; if ( maxMajor > 1000 ) maxMajor = 10000; AxisData &d = *d_axisData[axisId]; if ( maxMajor != d.maxMinor ) { d.maxMajor = maxMajor; d.scaleDiv.invalidate(); autoRefresh(); } } }
void QwtPlot::setAxisMaxMinor | ( | int | axisId, |
int | maxMinor | ||
) |
Set the maximum number of minor scale intervals for a specified axis
axisId | axis index |
maxMinor | maximum number of minor steps |
Definition at line 516 of file qwt_plot_axis.cpp.
References autoRefresh(), axisValid(), QwtScaleDiv::invalidate(), QwtPlot::AxisData::maxMinor, and QwtPlot::AxisData::scaleDiv.
{ if (axisValid(axisId)) { if ( maxMinor < 0 ) maxMinor = 0; if ( maxMinor > 100 ) maxMinor = 100; AxisData &d = *d_axisData[axisId]; if ( maxMinor != d.maxMinor ) { d.maxMinor = maxMinor; d.scaleDiv.invalidate(); autoRefresh(); } } }
void QwtPlot::setAxisScale | ( | int | axisId, |
double | min, | ||
double | max, | ||
double | stepSize = 0 |
||
) |
Disable autoscaling and specify a fixed scale for a selected axis.
axisId | axis index |
min | |
max | minimum and maximum of the scale |
stepSize | Major step size. If step == 0 , the step size is calculated automatically using the maxMajor setting. |
Definition at line 420 of file qwt_plot_axis.cpp.
References autoRefresh(), axisValid(), QwtPlot::AxisData::doAutoScale, QwtScaleDiv::invalidate(), QuadProgPP::max(), QwtPlot::AxisData::maxValue, min, QwtPlot::AxisData::minValue, QwtPlot::AxisData::scaleDiv, and QwtPlot::AxisData::stepSize.
Referenced by QwtPlotPanner::moveCanvas(), QwtPlotZoomer::rescale(), QwtPlotRescaler::rescale(), QwtPlotMagnifier::rescale(), and QwtPlotRescaler::updateScales().
{ if (axisValid(axisId)) { AxisData &d = *d_axisData[axisId]; d.doAutoScale = false; d.scaleDiv.invalidate(); d.minValue = min; d.maxValue = max; d.stepSize = stepSize; autoRefresh(); } }
void QwtPlot::setAxisScaleDiv | ( | int | axisId, |
const QwtScaleDiv & | scaleDiv | ||
) |
Disable autoscaling and specify a fixed scale for a selected axis.
axisId | axis index |
scaleDiv | Scale division |
Definition at line 443 of file qwt_plot_axis.cpp.
References autoRefresh(), axisValid(), QwtPlot::AxisData::doAutoScale, and QwtPlot::AxisData::scaleDiv.
Referenced by QwtPlotRescaler::updateScales().
{ if (axisValid(axisId)) { AxisData &d = *d_axisData[axisId]; d.doAutoScale = false; d.scaleDiv = scaleDiv; autoRefresh(); } }
void QwtPlot::setAxisScaleDraw | ( | int | axisId, |
QwtScaleDraw * | scaleDraw | ||
) |
Set a scale draw.
axisId | axis index |
scaleDraw | object 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 ).
Definition at line 471 of file qwt_plot_axis.cpp.
References autoRefresh(), axisValid(), axisWidget(), and QwtScaleWidget::setScaleDraw().
{ if (axisValid(axisId)) { axisWidget(axisId)->setScaleDraw(scaleDraw); autoRefresh(); } }
void QwtPlot::setAxisScaleEngine | ( | int | axisId, |
QwtScaleEngine * | scaleEngine | ||
) |
Change the scale engine for an axis
axisId | axis index |
scaleEngine | Scale engine |
Definition at line 128 of file qwt_plot_axis.cpp.
References autoRefresh(), axisValid(), QwtScaleDiv::invalidate(), QwtPlot::AxisData::scaleDiv, and QwtPlot::AxisData::scaleEngine.
{ if (axisValid(axisId) && scaleEngine != NULL ) { AxisData &d = *d_axisData[axisId]; delete d.scaleEngine; d.scaleEngine = scaleEngine; d.scaleDiv.invalidate(); autoRefresh(); } }
void QwtPlot::setAxisTitle | ( | int | axisId, |
const QString & | title | ||
) |
Change the title of a specified axis.
axisId | axis index |
title | axis title |
Definition at line 567 of file qwt_plot_axis.cpp.
References axisValid(), axisWidget(), and QwtScaleWidget::setTitle().
Referenced by QmitkPlotWidget::SetAxisTitle().
{ if (axisValid(axisId)) axisWidget(axisId)->setTitle(title); }
void QwtPlot::setAxisTitle | ( | int | axisId, |
const QwtText & | title | ||
) |
Change the title of a specified axis.
axisId | axis index |
title | axis title |
Definition at line 578 of file qwt_plot_axis.cpp.
References axisValid(), axisWidget(), and QwtScaleWidget::setTitle().
{ if (axisValid(axisId)) axisWidget(axisId)->setTitle(title); }
void QwtPlot::setCanvasBackground | ( | const QColor & | c ) |
Change the background of the plotting area.
Sets c to QColorGroup::Background of all colorgroups of the palette of the canvas. Using canvas()->setPalette() is a more powerful way to set these colors.
c | new background color |
Definition at line 674 of file qwt_plot.cpp.
References canvas(), and QwtPlot::PrivateData::canvas.
Referenced by QwtPlotPrintFilter::apply(), QmitkHistogramWidget::QmitkHistogramWidget(), QmitkPlotWidget::QmitkPlotWidget(), and QwtPlotPrintFilter::reset().
void QwtPlot::setCanvasLineWidth | ( | int | w ) |
Change the border width of the plotting area Nothing else than canvas()->setLineWidth(w), left for compatibility only.
w | new border width |
Definition at line 713 of file qwt_plot.cpp.
References canvas(), and updateLayout().
{ canvas()->setLineWidth(w); updateLayout(); }
void QwtPlot::setMargin | ( | int | margin ) |
Change the margin of the plot. The margin is the space around all components.
margin | new margin |
Definition at line 645 of file qwt_plot.cpp.
References QwtPlot::PrivateData::layout, QwtPlotLayout::margin(), QwtPlotLayout::setMargin(), and updateLayout().
void QwtPlot::setTitle | ( | const QString & | title ) |
Change the plot's title
title | New title |
Definition at line 199 of file qwt_plot.cpp.
References QwtPlot::PrivateData::lblTitle, and updateLayout().
Referenced by applyProperties(), QmitkHistogramWidget::QmitkHistogramWidget(), QmitkPlotWidget::SetCurveTitle(), and QmitkPlotWidget::SetPlotTitle().
{ if ( title != d_data->lblTitle->text().text() ) { d_data->lblTitle->setText(title); updateLayout(); } }
void QwtPlot::setTitle | ( | const QwtText & | title ) |
Change the plot's title
title | New title |
Definition at line 212 of file qwt_plot.cpp.
References QwtPlot::PrivateData::lblTitle, and updateLayout().
{ if ( title != d_data->lblTitle->text() ) { d_data->lblTitle->setText(title); updateLayout(); } }
QSize QwtPlot::sizeHint | ( | ) | const [virtual] |
Return sizeHint
Definition at line 303 of file qwt_plot.cpp.
References axisCnt, axisEnabled(), axisWidget(), QwtScaleDiv::MajorTick, minimumSizeHint(), QwtScaleWidget::minimumSizeHint(), QwtAbstractScaleDraw::scaleDiv(), QwtScaleWidget::scaleDraw(), QwtScaleDiv::ticks(), yLeft, and yRight.
{ int dw = 0; int dh = 0; for ( int axisId = 0; axisId < axisCnt; axisId++ ) { if ( axisEnabled(axisId) ) { const int niceDist = 40; const QwtScaleWidget *scaleWidget = axisWidget(axisId); const QwtScaleDiv &scaleDiv = scaleWidget->scaleDraw()->scaleDiv(); const int majCnt = scaleDiv.ticks(QwtScaleDiv::MajorTick).count(); if ( axisId == yLeft || axisId == yRight ) { int hDiff = (majCnt - 1) * niceDist - scaleWidget->minimumSizeHint().height(); if ( hDiff > dh ) dh = hDiff; } else { int wDiff = (majCnt - 1) * niceDist - scaleWidget->minimumSizeHint().width(); if ( wDiff > dw ) dw = wDiff; } } } return minimumSizeHint() + QSize(dw, dh); }
QwtText QwtPlot::title | ( | ) | const |
Definition at line 222 of file qwt_plot.cpp.
References QwtPlot::PrivateData::lblTitle.
Referenced by grabProperties().
{ return d_data->lblTitle->text(); }
QwtTextLabel * QwtPlot::titleLabel | ( | ) |
Definition at line 240 of file qwt_plot.cpp.
References QwtPlot::PrivateData::lblTitle.
Referenced by QwtPlotPrintFilter::apply(), QwtPlotLayout::LayoutData::init(), QwtPlotLayout::minimumSizeHint(), print(), printTitle(), QmitkHistogramWidget::QmitkHistogramWidget(), and QwtPlotPrintFilter::reset().
{ return d_data->lblTitle; }
const QwtTextLabel * QwtPlot::titleLabel | ( | ) | const |
Definition at line 248 of file qwt_plot.cpp.
References QwtPlot::PrivateData::lblTitle.
{ return d_data->lblTitle; }
int QwtPlot::transform | ( | int | axisId, |
double | value | ||
) | const |
Transform a value into a coordinate in the plotting region.
axisId | axis index |
value | value |
Definition at line 371 of file qwt_plot_axis.cpp.
References axisValid(), and canvasMap().
void QwtPlot::updateAxes | ( | ) |
Rebuild the scales.
Definition at line 585 of file qwt_plot_axis.cpp.
References QwtScaleEngine::autoScale(), QwtPlotItem::AutoScale, axisAutoScale(), axisCnt, axisScaleDiv(), axisWidget(), QwtDoubleRect::bottom(), QwtPlotItem::boundingRect(), QwtScaleEngine::divideScale(), QwtPlot::AxisData::doAutoScale, QwtScaleWidget::getBorderDistHint(), QwtScaleDiv::invalidate(), QwtScaleDiv::isValid(), QwtDoubleInterval::isValid(), QwtPlotDict::itemList(), QwtDoubleRect::left(), QwtPlot::AxisData::maxMajor, QwtPlot::AxisData::maxMinor, QwtDoubleInterval::maxValue(), QwtPlot::AxisData::maxValue, QwtDoubleInterval::minValue(), QwtPlot::AxisData::minValue, QwtDoubleRect::right(), QwtPlot::AxisData::scaleDiv, QwtPlot::AxisData::scaleEngine, QwtScaleWidget::setBorderDist(), QwtScaleWidget::setScaleDiv(), QwtPlot::AxisData::stepSize, QwtPlotItem::testItemAttribute(), QwtDoubleRect::top(), QwtScaleEngine::transformation(), QwtPlotItem::updateScaleDiv(), QwtPlotItem::xAxis(), and QwtPlotItem::yAxis().
Referenced by replot(), and QwtPlotRescaler::rescale().
{ // Find bounding interval of the item data // for all axes, where autoscaling is enabled QwtDoubleInterval intv[axisCnt]; const QwtPlotItemList& itmList = itemList(); QwtPlotItemIterator it; for ( it = itmList.begin(); it != itmList.end(); ++it ) { const QwtPlotItem *item = *it; if ( !item->testItemAttribute(QwtPlotItem::AutoScale) ) continue; if ( axisAutoScale(item->xAxis()) || axisAutoScale(item->yAxis()) ) { const QwtDoubleRect rect = item->boundingRect(); intv[item->xAxis()] |= QwtDoubleInterval(rect.left(), rect.right()); intv[item->yAxis()] |= QwtDoubleInterval(rect.top(), rect.bottom()); } } // Adjust scales for (int axisId = 0; axisId < axisCnt; axisId++) { AxisData &d = *d_axisData[axisId]; double minValue = d.minValue; double maxValue = d.maxValue; double stepSize = d.stepSize; if ( d.doAutoScale && intv[axisId].isValid() ) { d.scaleDiv.invalidate(); minValue = intv[axisId].minValue(); maxValue = intv[axisId].maxValue(); d.scaleEngine->autoScale(d.maxMajor, minValue, maxValue, stepSize); } if ( !d.scaleDiv.isValid() ) { d.scaleDiv = d.scaleEngine->divideScale( minValue, maxValue, d.maxMajor, d.maxMinor, stepSize); } QwtScaleWidget *scaleWidget = axisWidget(axisId); scaleWidget->setScaleDiv( d.scaleEngine->transformation(), d.scaleDiv); int startDist, endDist; scaleWidget->getBorderDistHint(startDist, endDist); scaleWidget->setBorderDist(startDist, endDist); } for ( it = itmList.begin(); it != itmList.end(); ++it ) { QwtPlotItem *item = *it; item->updateScaleDiv( *axisScaleDiv(item->xAxis()), *axisScaleDiv(item->yAxis())); } }
void QwtPlot::updateLayout | ( | ) | [virtual] |
Adjust plot content to its current size.
Definition at line 393 of file qwt_plot.cpp.
References QwtPlotLayout::activate(), axisCnt, axisEnabled(), axisWidget(), QwtPlot::PrivateData::canvas, QwtPlotLayout::canvasRect(), ExternalLegend, QwtPlot::PrivateData::layout, QwtPlot::PrivateData::lblTitle, QwtPlot::PrivateData::legend, QwtPlotLayout::legendPosition(), QwtPlotLayout::legendRect(), QwtPlotLayout::scaleRect(), QwtPlotLayout::titleRect(), xBottom, xTop, yLeft, and yRight.
Referenced by enableAxis(), event(), insertLegend(), resizeEvent(), setCanvasLineWidth(), setMargin(), and setTitle().
{ d_data->layout->activate(this, contentsRect()); // // resize and show the visible widgets // if (!d_data->lblTitle->text().isEmpty()) { d_data->lblTitle->setGeometry(d_data->layout->titleRect()); if (!d_data->lblTitle->isVisible()) d_data->lblTitle->show(); } else d_data->lblTitle->hide(); for (int axisId = 0; axisId < axisCnt; axisId++ ) { if (axisEnabled(axisId) ) { axisWidget(axisId)->setGeometry(d_data->layout->scaleRect(axisId)); if ( axisId == xBottom || axisId == xTop ) { QRegion r(d_data->layout->scaleRect(axisId)); if ( axisEnabled(yLeft) ) r = r.subtract(QRegion(d_data->layout->scaleRect(yLeft))); if ( axisEnabled(yRight) ) r = r.subtract(QRegion(d_data->layout->scaleRect(yRight))); r.translate(-d_data->layout->scaleRect(axisId).x(), -d_data->layout->scaleRect(axisId).y()); axisWidget(axisId)->setMask(r); } if (!axisWidget(axisId)->isVisible()) axisWidget(axisId)->show(); } else axisWidget(axisId)->hide(); } if ( d_data->legend && d_data->layout->legendPosition() != ExternalLegend ) { if (d_data->legend->itemCount() > 0) { d_data->legend->setGeometry(d_data->layout->legendRect()); d_data->legend->show(); } else d_data->legend->hide(); } d_data->canvas->setGeometry(d_data->layout->canvasRect()); }
void QwtPlot::updateTabOrder | ( | ) | [protected, virtual] |
Update the focus tab order
The order is changed so that the canvas will be in front of the first legend item, or behind the last legend item - depending on the position of the legend.
Definition at line 457 of file qwt_plot.cpp.
References BottomLegend, ExternalLegend, and RightLegend.
Referenced by insertLegend().
{ #if QT_VERSION >= 0x040000 using namespace Qt; // QWidget::NoFocus/Qt::NoFocus #else if ( d_data->canvas->focusPolicy() == NoFocus ) return; #endif if ( d_data->legend.isNull() || d_data->layout->legendPosition() == ExternalLegend || d_data->legend->legendItems().count() == 0 ) { return; } // Depending on the position of the legend the // tab order will be changed that the canvas is // next to the last legend item, or before // the first one. const bool canvasFirst = d_data->layout->legendPosition() == QwtPlot::BottomLegend || d_data->layout->legendPosition() == QwtPlot::RightLegend; QWidget *previous = NULL; QWidget *w; #if QT_VERSION >= 0x040000 w = d_data->canvas; while ( ( w = w->nextInFocusChain() ) != d_data->canvas ) #else if ( focusData() == NULL ) return; while ( focusData()->next() != d_data->canvas ); while ( (w = focusData()->next()) != d_data->canvas ) #endif { bool isLegendItem = false; if ( w->focusPolicy() != NoFocus && w->parent() && w->parent() == d_data->legend->contentsWidget() ) { isLegendItem = true; } if ( canvasFirst ) { if ( isLegendItem ) break; previous = w; } else { if ( isLegendItem ) previous = w; else { if ( previous ) break; } } } if ( previous && previous != d_data->canvas) setTabOrder(previous, d_data->canvas); }
QString QwtPlot::propertiesDocument [read, write] |
Definition at line 76 of file qwt_plot.h.