A class which draws a coordinate grid. More...
#include <qwt_plot_grid.h>
Classes | |
class | PrivateData |
Public Member Functions | |
QwtPlotGrid () | |
Enables major grid, disables minor grid. | |
virtual | ~QwtPlotGrid () |
Destructor. | |
virtual int | rtti () const |
void | enableX (bool tf) |
Enable or disable vertical gridlines. | |
bool | xEnabled () const |
void | enableY (bool tf) |
Enable or disable horizontal gridlines. | |
bool | yEnabled () const |
void | enableXMin (bool tf) |
Enable or disable minor vertical gridlines. | |
bool | xMinEnabled () const |
void | enableYMin (bool tf) |
Enable or disable minor horizontal gridlines. | |
bool | yMinEnabled () const |
void | setXDiv (const QwtScaleDiv &sx) |
const QwtScaleDiv & | xScaleDiv () const |
void | setYDiv (const QwtScaleDiv &sy) |
const QwtScaleDiv & | yScaleDiv () const |
void | setPen (const QPen &p) |
void | setMajPen (const QPen &p) |
const QPen & | majPen () const |
void | setMinPen (const QPen &p) |
const QPen & | minPen () const |
virtual void | draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &rect) const |
Draw the grid. | |
virtual void | updateScaleDiv (const QwtScaleDiv &xMap, const QwtScaleDiv &yMap) |
A class which draws a coordinate grid.
The QwtPlotGrid class can be used to draw a coordinate grid. A coordinate grid consists of major and minor vertical and horizontal gridlines. The locations of the gridlines are determined by the X and Y scale divisions which can be assigned with setXDiv() and setYDiv(). The draw() member draws the grid within a bounding rectangle.
Definition at line 34 of file qwt_plot_grid.h.
QwtPlotGrid::QwtPlotGrid | ( | ) | [explicit] |
Enables major grid, disables minor grid.
Definition at line 42 of file qwt_plot_grid.cpp.
References QwtPlotItem::setZ().
: QwtPlotItem(QwtText("Grid")) { d_data = new PrivateData; setZ(10.0); }
QwtPlotGrid::~QwtPlotGrid | ( | ) | [virtual] |
void QwtPlotGrid::draw | ( | QPainter * | painter, |
const QwtScaleMap & | xMap, | ||
const QwtScaleMap & | yMap, | ||
const QRect & | canvasRect | ||
) | const [virtual] |
Draw the grid.
The grid is drawn into the bounding rectangle such that gridlines begin and end at the rectangle's borders. The X and Y maps are used to map the scale divisions into the drawing region screen.
painter | Painter |
xMap | X axis map |
yMap | Y axis |
canvasRect | Contents rect of the plot canvas |
Implements QwtPlotItem.
Definition at line 214 of file qwt_plot_grid.cpp.
References QwtScaleDiv::MajorTick, QwtPlotGrid::PrivateData::majPen, QwtScaleDiv::MediumTick, QwtScaleDiv::MinorTick, QwtPlotGrid::PrivateData::minPen, QwtPainter::scaledPen(), QwtScaleDiv::ticks(), QwtPlotGrid::PrivateData::xEnabled, QwtPlotGrid::PrivateData::xMinEnabled, QwtPlotGrid::PrivateData::xScaleDiv, QwtPlotGrid::PrivateData::yEnabled, QwtPlotGrid::PrivateData::yMinEnabled, and QwtPlotGrid::PrivateData::yScaleDiv.
{ // draw minor gridlines painter->setPen(QwtPainter::scaledPen(d_data->minPen)); if (d_data->xEnabled && d_data->xMinEnabled) { drawLines(painter, canvasRect, Qt::Vertical, xMap, d_data->xScaleDiv.ticks(QwtScaleDiv::MinorTick)); drawLines(painter, canvasRect, Qt::Vertical, xMap, d_data->xScaleDiv.ticks(QwtScaleDiv::MediumTick)); } if (d_data->yEnabled && d_data->yMinEnabled) { drawLines(painter, canvasRect, Qt::Horizontal, yMap, d_data->yScaleDiv.ticks(QwtScaleDiv::MinorTick)); drawLines(painter, canvasRect, Qt::Horizontal, yMap, d_data->yScaleDiv.ticks(QwtScaleDiv::MediumTick)); } // draw major gridlines painter->setPen(QwtPainter::scaledPen(d_data->majPen)); if (d_data->xEnabled) { drawLines(painter, canvasRect, Qt::Vertical, xMap, d_data->xScaleDiv.ticks(QwtScaleDiv::MajorTick)); } if (d_data->yEnabled) { drawLines(painter, canvasRect, Qt::Horizontal, yMap, d_data->yScaleDiv.ticks(QwtScaleDiv::MajorTick)); } }
void QwtPlotGrid::enableX | ( | bool | tf ) |
Enable or disable vertical gridlines.
tf | Enable (true) or disable |
Definition at line 68 of file qwt_plot_grid.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotGrid::PrivateData::xEnabled.
{ if ( d_data->xEnabled != tf ) { d_data->xEnabled = tf; itemChanged(); } }
void QwtPlotGrid::enableXMin | ( | bool | tf ) |
Enable or disable minor vertical gridlines.
tf | Enable (true) or disable |
Definition at line 96 of file qwt_plot_grid.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotGrid::PrivateData::xMinEnabled.
Referenced by QmitkHistogramWidget::QmitkHistogramWidget().
{ if ( d_data->xMinEnabled != tf ) { d_data->xMinEnabled = tf; itemChanged(); } }
void QwtPlotGrid::enableY | ( | bool | tf ) |
Enable or disable horizontal gridlines.
tf | Enable (true) or disable |
Definition at line 82 of file qwt_plot_grid.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotGrid::PrivateData::yEnabled.
{ if ( d_data->yEnabled != tf ) { d_data->yEnabled = tf; itemChanged(); } }
void QwtPlotGrid::enableYMin | ( | bool | tf ) |
Enable or disable minor horizontal gridlines.
tf | Enable (true) or disable |
Definition at line 110 of file qwt_plot_grid.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotGrid::PrivateData::yMinEnabled.
Referenced by QmitkHistogramWidget::QmitkHistogramWidget().
{ if ( d_data->yMinEnabled != tf ) { d_data->yMinEnabled = tf; itemChanged(); } }
const QPen & QwtPlotGrid::majPen | ( | ) | const |
Definition at line 282 of file qwt_plot_grid.cpp.
References QwtPlotGrid::PrivateData::majPen.
Referenced by QwtPlotPrintFilter::apply(), and QwtPlotPrintFilter::reset().
{ return d_data->majPen; }
const QPen & QwtPlotGrid::minPen | ( | ) | const |
Definition at line 291 of file qwt_plot_grid.cpp.
References QwtPlotGrid::PrivateData::minPen.
Referenced by QwtPlotPrintFilter::apply(), and QwtPlotPrintFilter::reset().
{ return d_data->minPen; }
int QwtPlotGrid::rtti | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
Definition at line 56 of file qwt_plot_grid.cpp.
References QwtPlotItem::Rtti_PlotGrid.
{ return QwtPlotItem::Rtti_PlotGrid; }
void QwtPlotGrid::setMajPen | ( | const QPen & | pen ) |
Assign a pen for the major gridlines
The width of non cosmetic pens is scaled according to the resolution of the paint device.
pen | Pen |
Definition at line 175 of file qwt_plot_grid.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotGrid::PrivateData::majPen.
Referenced by QwtPlotPrintFilter::apply(), QmitkHistogramWidget::QmitkHistogramWidget(), and QwtPlotPrintFilter::reset().
{ if ( d_data->majPen != pen ) { d_data->majPen = pen; itemChanged(); } }
void QwtPlotGrid::setMinPen | ( | const QPen & | pen ) |
Assign a pen for the minor gridlines
The width of non cosmetic pens is scaled according to the resolution of the paint device.
pen | Pen |
Definition at line 193 of file qwt_plot_grid.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotGrid::PrivateData::minPen.
Referenced by QwtPlotPrintFilter::apply(), QmitkHistogramWidget::QmitkHistogramWidget(), and QwtPlotPrintFilter::reset().
{ if ( d_data->minPen != pen ) { d_data->minPen = pen; itemChanged(); } }
void QwtPlotGrid::setPen | ( | const QPen & | pen ) |
Assign a pen for both major and minor gridlines
The width of non cosmetic pens is scaled according to the resolution of the paint device.
pen | Pen |
Definition at line 156 of file qwt_plot_grid.cpp.
References QwtPlotItem::itemChanged(), QwtPlotGrid::PrivateData::majPen, and QwtPlotGrid::PrivateData::minPen.
{ if ( d_data->majPen != pen || d_data->minPen != pen ) { d_data->majPen = pen; d_data->minPen = pen; itemChanged(); } }
void QwtPlotGrid::setXDiv | ( | const QwtScaleDiv & | scaleDiv ) |
Assign an x axis scale division
scaleDiv | Scale division |
Definition at line 124 of file qwt_plot_grid.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotGrid::PrivateData::xScaleDiv.
Referenced by updateScaleDiv().
{ if ( d_data->xScaleDiv != scaleDiv ) { d_data->xScaleDiv = scaleDiv; itemChanged(); } }
void QwtPlotGrid::setYDiv | ( | const QwtScaleDiv & | scaleDiv ) |
Assign a y axis division
scaleDiv | Scale division |
Definition at line 138 of file qwt_plot_grid.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotGrid::PrivateData::yScaleDiv.
Referenced by updateScaleDiv().
{ if ( d_data->yScaleDiv != scaleDiv ) { d_data->yScaleDiv = scaleDiv; itemChanged(); } }
void QwtPlotGrid::updateScaleDiv | ( | const QwtScaleDiv & | xScaleDiv, |
const QwtScaleDiv & | yScaleDiv | ||
) | [virtual] |
Update the grid to changes of the axes scale division
xScaleDiv | Scale division of the x-axis |
yScaleDiv | Scale division of the y-axis |
Reimplemented from QwtPlotItem.
Definition at line 353 of file qwt_plot_grid.cpp.
bool QwtPlotGrid::xEnabled | ( | ) | const |
Definition at line 300 of file qwt_plot_grid.cpp.
References QwtPlotGrid::PrivateData::xEnabled.
{ return d_data->xEnabled; }
bool QwtPlotGrid::xMinEnabled | ( | ) | const |
Definition at line 309 of file qwt_plot_grid.cpp.
References QwtPlotGrid::PrivateData::xMinEnabled.
{ return d_data->xMinEnabled; }
const QwtScaleDiv & QwtPlotGrid::xScaleDiv | ( | ) | const |
Definition at line 334 of file qwt_plot_grid.cpp.
References QwtPlotGrid::PrivateData::xScaleDiv.
{ return d_data->xScaleDiv; }
bool QwtPlotGrid::yEnabled | ( | ) | const |
Definition at line 318 of file qwt_plot_grid.cpp.
References QwtPlotGrid::PrivateData::yEnabled.
{ return d_data->yEnabled; }
bool QwtPlotGrid::yMinEnabled | ( | ) | const |
Definition at line 327 of file qwt_plot_grid.cpp.
References QwtPlotGrid::PrivateData::yMinEnabled.
{ return d_data->yMinEnabled; }
const QwtScaleDiv & QwtPlotGrid::yScaleDiv | ( | ) | const |
Definition at line 340 of file qwt_plot_grid.cpp.
References QwtPlotGrid::PrivateData::yScaleDiv.
{ return d_data->yScaleDiv; }