A class for drawing markers. More...
#include <qwt_plot_marker.h>
Classes | |
class | PrivateData |
Public Types | |
enum | LineStyle { NoLine, HLine, VLine, Cross } |
Public Member Functions | |
QwtPlotMarker () | |
Sets alignment to Qt::AlignCenter, and style to NoLine. | |
virtual | ~QwtPlotMarker () |
Destructor. | |
virtual int | rtti () const |
double | xValue () const |
Return x Value. | |
double | yValue () const |
Return y Value. | |
QwtDoublePoint | value () const |
Return Value. | |
void | setXValue (double) |
Set X Value. | |
void | setYValue (double) |
Set Y Value. | |
void | setValue (double, double) |
Set Value. | |
void | setValue (const QwtDoublePoint &) |
Set Value. | |
void | setLineStyle (LineStyle st) |
Set the line style. | |
LineStyle | lineStyle () const |
void | setLinePen (const QPen &p) |
const QPen & | linePen () const |
void | setSymbol (const QwtSymbol &s) |
Assign a symbol. | |
const QwtSymbol & | symbol () const |
void | setLabel (const QwtText &) |
Set the label. | |
QwtText | label () const |
void | setLabelAlignment (int align) |
Set the alignment of the label. | |
int | labelAlignment () const |
void | setLabelOrientation (Qt::Orientation) |
Set the orientation of the label. | |
Qt::Orientation | labelOrientation () const |
void | setSpacing (int) |
Set the spacing. | |
int | spacing () const |
virtual void | draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &) const |
virtual QwtDoubleRect | boundingRect () const |
Protected Member Functions | |
void | drawAt (QPainter *, const QRect &, const QPoint &) const |
A class for drawing markers.
A marker can be a horizontal line, a vertical line, a symbol, a label or any combination of them, which can be drawn around a center point inside a bounding rectangle.
The QwtPlotMarker::setSymbol() member assigns a symbol to the marker. The symbol is drawn at the specified point.
With QwtPlotMarker::setLabel(), a label can be assigned to the marker. The QwtPlotMarker::setLabelAlignment() member specifies where the label is drawn. All the Align*-constants in Qt::AlignmentFlags (see Qt documentation) are valid. The interpretation of the alignment depends on the marker's line style. The alignment refers to the center point of the marker, which means, for example, that the label would be printed left above the center point if the alignment was set to AlignLeft|AlignTop.
Definition at line 45 of file qwt_plot_marker.h.
QwtPlotMarker::QwtPlotMarker | ( | ) | [explicit] |
Sets alignment to Qt::AlignCenter, and style to NoLine.
Definition at line 57 of file qwt_plot_marker.cpp.
References QwtPlotItem::setZ().
: QwtPlotItem(QwtText("Marker")) { d_data = new PrivateData; setZ(30.0); }
QwtPlotMarker::~QwtPlotMarker | ( | ) | [virtual] |
QwtDoubleRect QwtPlotMarker::boundingRect | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
Definition at line 503 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::xValue, and QwtPlotMarker::PrivateData::yValue.
{ return QwtDoubleRect(d_data->xValue, d_data->yValue, 0.0, 0.0); }
void QwtPlotMarker::draw | ( | QPainter * | painter, |
const QwtScaleMap & | xMap, | ||
const QwtScaleMap & | yMap, | ||
const QRect & | canvasRect | ||
) | const [virtual] |
Draw the marker
painter | Painter |
xMap | x Scale Map |
yMap | y Scale Map |
canvasRect | Contents rect of the canvas in painter coordinates |
Implements QwtPlotItem.
Definition at line 131 of file qwt_plot_marker.cpp.
References drawAt(), QwtScaleMap::transform(), QwtPlotMarker::PrivateData::xValue, and QwtPlotMarker::PrivateData::yValue.
void QwtPlotMarker::drawAt | ( | QPainter * | painter, |
const QRect & | canvasRect, | ||
const QPoint & | pos | ||
) | const [protected] |
Draw the marker at a specific position
painter | Painter |
canvasRect | Contents rect of the canvas in painter coordinates |
pos | Position of the marker in painter coordinates |
Definition at line 148 of file qwt_plot_marker.cpp.
References Cross, QwtSymbol::draw(), QwtPainter::drawLine(), HLine, NoLine, QwtSymbol::NoSymbol, QwtPlotMarker::PrivateData::pen, QwtPainter::scaledPen(), QwtSymbol::style(), QwtPlotMarker::PrivateData::style, QwtPlotMarker::PrivateData::symbol, and VLine.
Referenced by draw().
{ // draw lines if (d_data->style != NoLine) { painter->setPen(QwtPainter::scaledPen(d_data->pen)); if ( d_data->style == QwtPlotMarker::HLine || d_data->style == QwtPlotMarker::Cross ) { QwtPainter::drawLine(painter, canvasRect.left(), pos.y(), canvasRect.right(), pos.y() ); } if (d_data->style == QwtPlotMarker::VLine || d_data->style == QwtPlotMarker::Cross ) { QwtPainter::drawLine(painter, pos.x(), canvasRect.top(), pos.x(), canvasRect.bottom()); } } // draw symbol if (d_data->symbol->style() != QwtSymbol::NoSymbol) d_data->symbol->draw(painter, pos.x(), pos.y()); drawLabel(painter, canvasRect, pos); }
QwtText QwtPlotMarker::label | ( | ) | const |
Definition at line 371 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::label.
Referenced by QwtPlotPrintFilter::apply(), QwtPlotPrintFilter::reset(), and setLabel().
{ return d_data->label; }
int QwtPlotMarker::labelAlignment | ( | ) | const |
Definition at line 410 of file qwt_plot_marker.cpp.
{ return d_data->labelAlignment; }
Qt::Orientation QwtPlotMarker::labelOrientation | ( | ) | const |
Definition at line 441 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::labelOrientation.
{ return d_data->labelOrientation; }
const QPen & QwtPlotMarker::linePen | ( | ) | const |
Definition at line 498 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::pen.
Referenced by QwtPlotPrintFilter::apply(), and QwtPlotPrintFilter::reset().
{ return d_data->pen; }
QwtPlotMarker::LineStyle QwtPlotMarker::lineStyle | ( | ) | const |
Definition at line 327 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::style.
{ return d_data->style; }
int QwtPlotMarker::rtti | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
Definition at line 71 of file qwt_plot_marker.cpp.
References QwtPlotItem::Rtti_PlotMarker.
{ return QwtPlotItem::Rtti_PlotMarker; }
void QwtPlotMarker::setLabel | ( | const QwtText & | label ) |
Set the label.
label | label text |
Definition at line 358 of file qwt_plot_marker.cpp.
References QwtPlotItem::itemChanged(), label(), and QwtPlotMarker::PrivateData::label.
Referenced by QwtPlotPrintFilter::apply(), QmitkHistogramWidget::OnSelect(), and QwtPlotPrintFilter::reset().
{ if ( label != d_data->label ) { d_data->label = label; itemChanged(); } }
void QwtPlotMarker::setLabelAlignment | ( | int | align ) |
Set the alignment of the label.
In case of QwtPlotMarker::HLine the alignment is relative to the y position of the marker, but the horizontal flags correspond to the canvas rectangle. In case of QwtPlotMarker::VLine the alignment is relative to the x position of the marker, but the vertical flags correspond to the canvas rectangle.
In all other styles the alignment is relative to the marker's position.
align | Alignment. A combination of AlignTop, AlignBottom, AlignLeft, AlignRight, AlignCenter, AlgnHCenter, AlignVCenter. |
Definition at line 393 of file qwt_plot_marker.cpp.
Referenced by QmitkHistogramWidget::InitializeMarker().
{ if ( align != d_data->labelAlignment ) { d_data->labelAlignment = align; itemChanged(); } }
void QwtPlotMarker::setLabelOrientation | ( | Qt::Orientation | orientation ) |
Set the orientation of the label.
When orientation is Qt::Vertical the label is rotated by 90.0 degrees ( from bottom to top ).
orientation | Orientation of the label |
Definition at line 428 of file qwt_plot_marker.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotMarker::PrivateData::labelOrientation.
{ if ( orientation != d_data->labelOrientation ) { d_data->labelOrientation = orientation; itemChanged(); } }
void QwtPlotMarker::setLinePen | ( | const QPen & | pen ) |
Specify a pen for the line.
The width of non cosmetic pens is scaled according to the resolution of the paint device.
pen | New pen |
Definition at line 485 of file qwt_plot_marker.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotMarker::PrivateData::pen.
Referenced by QwtPlotPrintFilter::apply(), QmitkHistogramWidget::InitializeMarker(), and QwtPlotPrintFilter::reset().
{ if ( pen != d_data->pen ) { d_data->pen = pen; itemChanged(); } }
void QwtPlotMarker::setLineStyle | ( | QwtPlotMarker::LineStyle | st ) |
Set the line style.
st | Line style. Can be one of QwtPlotMarker::NoLine, HLine, VLine or Cross |
Definition at line 314 of file qwt_plot_marker.cpp.
References QwtPlotItem::itemChanged(), and QwtPlotMarker::PrivateData::style.
Referenced by QmitkHistogramWidget::InitializeMarker().
{ if ( st != d_data->style ) { d_data->style = st; itemChanged(); } }
void QwtPlotMarker::setSpacing | ( | int | spacing ) |
Set the spacing.
When the label is not centered on the marker position, the spacing is the distance between the position and the label.
spacing | Spacing |
Definition at line 455 of file qwt_plot_marker.cpp.
References QwtPlotItem::itemChanged(), spacing(), and QwtPlotMarker::PrivateData::spacing.
void QwtPlotMarker::setSymbol | ( | const QwtSymbol & | s ) |
Assign a symbol.
s | New symbol |
Definition at line 337 of file qwt_plot_marker.cpp.
References QwtSymbol::clone(), QwtPlotItem::itemChanged(), and QwtPlotMarker::PrivateData::symbol.
Referenced by QwtPlotPrintFilter::apply(), QmitkHistogramWidget::InitializeMarker(), and QwtPlotPrintFilter::reset().
{ delete d_data->symbol; d_data->symbol = s.clone(); itemChanged(); }
void QwtPlotMarker::setValue | ( | const QwtDoublePoint & | pos ) |
Set Value.
Definition at line 95 of file qwt_plot_marker.cpp.
References setValue(), QwtDoublePoint::x(), and QwtDoublePoint::y().
void QwtPlotMarker::setValue | ( | double | x, |
double | y | ||
) |
Set Value.
Definition at line 101 of file qwt_plot_marker.cpp.
References QwtPlotItem::itemChanged(), QwtPlotMarker::PrivateData::xValue, and QwtPlotMarker::PrivateData::yValue.
Referenced by setValue(), setXValue(), and setYValue().
void QwtPlotMarker::setXValue | ( | double | x ) |
Set X Value.
Definition at line 112 of file qwt_plot_marker.cpp.
References setValue(), and QwtPlotMarker::PrivateData::yValue.
Referenced by QmitkHistogramWidget::InitializeMarker(), and QmitkHistogramWidget::OnSelect().
void QwtPlotMarker::setYValue | ( | double | y ) |
Set Y Value.
Definition at line 118 of file qwt_plot_marker.cpp.
References setValue(), and QwtPlotMarker::PrivateData::xValue.
int QwtPlotMarker::spacing | ( | ) | const |
Definition at line 471 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::spacing.
Referenced by setSpacing().
{ return d_data->spacing; }
const QwtSymbol & QwtPlotMarker::symbol | ( | ) | const |
Definition at line 348 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::symbol.
Referenced by QwtPlotPrintFilter::apply(), and QwtPlotPrintFilter::reset().
{ return *d_data->symbol; }
QwtDoublePoint QwtPlotMarker::value | ( | ) | const |
Return Value.
Definition at line 77 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::xValue, and QwtPlotMarker::PrivateData::yValue.
{ return QwtDoublePoint(d_data->xValue, d_data->yValue); }
double QwtPlotMarker::xValue | ( | ) | const |
Return x Value.
Definition at line 83 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::xValue.
Referenced by QmitkHistogramWidget::GetMarkerPosition().
{ return d_data->xValue; }
double QwtPlotMarker::yValue | ( | ) | const |
Return y Value.
Definition at line 89 of file qwt_plot_marker.cpp.
References QwtPlotMarker::PrivateData::yValue.
{ return d_data->yValue; }