Classes | Public Types | Public Member Functions | Protected Member Functions

QwtPlotMarker Class Reference

A class for drawing markers. More...

#include <qwt_plot_marker.h>

Inheritance diagram for QwtPlotMarker:
Inheritance graph
[legend]
Collaboration diagram for QwtPlotMarker:
Collaboration graph
[legend]

List of all members.

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 QwtSymbolsymbol () 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

Detailed Description

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.


Member Enumeration Documentation

Line styles.

See also:
setLineStyle(), lineStyle()
Enumerator:
NoLine 
HLine 
VLine 
Cross 

Definition at line 53 of file qwt_plot_marker.h.


Constructor & Destructor Documentation

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]

Destructor.

Definition at line 65 of file qwt_plot_marker.cpp.

{
    delete d_data;
}

Member Function Documentation

QwtDoubleRect QwtPlotMarker::boundingRect (  ) const [virtual]
Returns:
An invalid bounding rect: QwtDoubleRect(1.0, 1.0, -2.0, -2.0)

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

Parameters:
painterPainter
xMapx Scale Map
yMapy Scale Map
canvasRectContents 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.

{
    const int x = xMap.transform(d_data->xValue);
    const int y = yMap.transform(d_data->yValue);

    drawAt(painter, canvasRect, QPoint(x, y));
}
void QwtPlotMarker::drawAt ( QPainter *  painter,
const QRect &  canvasRect,
const QPoint &  pos 
) const [protected]

Draw the marker at a specific position

Parameters:
painterPainter
canvasRectContents rect of the canvas in painter coordinates
posPosition 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
Returns:
the label
See also:
setLabel()

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
Returns:
the label alignment
See also:
setLabelAlignment(), setLabelOrientation()

Definition at line 410 of file qwt_plot_marker.cpp.

{ 
    return d_data->labelAlignment; 
}
Qt::Orientation QwtPlotMarker::labelOrientation (  ) const
Returns:
the label orientation
See also:
setLabelOrientation(), labelAlignment()

Definition at line 441 of file qwt_plot_marker.cpp.

References QwtPlotMarker::PrivateData::labelOrientation.

{
    return d_data->labelOrientation;
}
const QPen & QwtPlotMarker::linePen (  ) const
Returns:
the line pen
See also:
setLinePen()

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
Returns:
the line style
See also:
For a description of line styles, see QwtPlotMarker::setLineStyle()

Definition at line 327 of file qwt_plot_marker.cpp.

References QwtPlotMarker::PrivateData::style.

{ 
    return d_data->style; 
}
int QwtPlotMarker::rtti (  ) const [virtual]
Returns:
QwtPlotItem::Rtti_PlotMarker

Reimplemented from QwtPlotItem.

Definition at line 71 of file qwt_plot_marker.cpp.

References QwtPlotItem::Rtti_PlotMarker.

void QwtPlotMarker::setLabel ( const QwtText label )

Set the label.

Parameters:
labellabel text
See also:
label()

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.

Parameters:
alignAlignment. A combination of AlignTop, AlignBottom, AlignLeft, AlignRight, AlignCenter, AlgnHCenter, AlignVCenter.
See also:
labelAlignment(), labelOrientation()

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 ).

Parameters:
orientationOrientation of the label
See also:
labelOrientation(), setLabelAlignment()

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.

Parameters:
penNew pen
See also:
linePen(), QwtPainter::scaledPen()

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.

Parameters:
stLine style. Can be one of QwtPlotMarker::NoLine, HLine, VLine or Cross
See also:
lineStyle()

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.

Parameters:
spacingSpacing
See also:
spacing(), setLabelAlignment()

Definition at line 455 of file qwt_plot_marker.cpp.

References QwtPlotItem::itemChanged(), spacing(), and QwtPlotMarker::PrivateData::spacing.

{
    if ( spacing < 0 )
        spacing = 0;

    if ( spacing == d_data->spacing )
        return;

    d_data->spacing = spacing;
    itemChanged();
}
void QwtPlotMarker::setSymbol ( const QwtSymbol s )

Assign a symbol.

Parameters:
sNew symbol
See also:
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().

{
    setValue(pos.x(), pos.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().

{
    if ( x != d_data->xValue || y != d_data->yValue )
    {
        d_data->xValue = x; 
        d_data->yValue = y; 
        itemChanged(); 
    }
}
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().

{ 
    setValue(x, d_data->yValue);
}
void QwtPlotMarker::setYValue ( double  y )

Set Y Value.

Definition at line 118 of file qwt_plot_marker.cpp.

References setValue(), and QwtPlotMarker::PrivateData::xValue.

{ 
    setValue(d_data->xValue, y);
}
int QwtPlotMarker::spacing (  ) const
Returns:
the spacing
See also:
setSpacing()

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
Returns:
the symbol
See also:
setSymbol(), QwtSymbol

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; 
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines