qwt_plot_marker.h 3.35 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
5
 *
pixhawk's avatar
pixhawk committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

#ifndef QWT_PLOT_MARKER_H
#define QWT_PLOT_MARKER_H

#include <qpen.h>
#include <qfont.h>
#include <qstring.h>
#include <qbrush.h>
#include "qwt_global.h"
#include "qwt_plot_item.h"

Bryant's avatar
Bryant committed
20
class QRectF;
pixhawk's avatar
pixhawk committed
21 22 23 24 25 26 27 28 29 30
class QwtText;
class QwtSymbol;

/*!
  \brief 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.

Bryant's avatar
Bryant committed
31
  The setSymbol() member assigns a symbol to the marker.
pixhawk's avatar
pixhawk committed
32 33
  The symbol is drawn at the specified point.

Bryant's avatar
Bryant committed
34 35
  With setLabel(), a label can be assigned to the marker.
  The setLabelAlignment() member specifies where the label is
pixhawk's avatar
pixhawk committed
36 37 38 39
  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
Bryant's avatar
Bryant committed
40 41 42 43 44 45
  left above the center point if the alignment was set to 
  Qt::AlignLeft | Qt::AlignTop.

  \note QwtPlotTextLabel is intended to align a text label
        according to the geometry of canvas 
        ( unrelated to plot coordinates )
pixhawk's avatar
pixhawk committed
46 47 48 49 50 51 52 53
*/

class QWT_EXPORT QwtPlotMarker: public QwtPlotItem
{
public:

    /*!
        Line styles.
Bryant's avatar
Bryant committed
54
        \sa setLineStyle(), lineStyle()
pixhawk's avatar
pixhawk committed
55
    */
Bryant's avatar
Bryant committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    enum LineStyle
    {
        //! No line
        NoLine,

        //! A horizontal line
        HLine,

        //! A vertical line
        VLine,

        //! A crosshair
        Cross
    };

    explicit QwtPlotMarker( const QString &title = QString::null );
    explicit QwtPlotMarker( const QwtText &title );
73

pixhawk's avatar
pixhawk committed
74 75 76 77 78 79
    virtual ~QwtPlotMarker();

    virtual int rtti() const;

    double xValue() const;
    double yValue() const;
Bryant's avatar
Bryant committed
80
    QPointF value() const;
pixhawk's avatar
pixhawk committed
81

Bryant's avatar
Bryant committed
82 83 84 85
    void setXValue( double );
    void setYValue( double );
    void setValue( double, double );
    void setValue( const QPointF & );
pixhawk's avatar
pixhawk committed
86

Bryant's avatar
Bryant committed
87
    void setLineStyle( LineStyle st );
pixhawk's avatar
pixhawk committed
88 89
    LineStyle lineStyle() const;

Bryant's avatar
Bryant committed
90 91
    void setLinePen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
    void setLinePen( const QPen &p );
pixhawk's avatar
pixhawk committed
92 93
    const QPen &linePen() const;

Bryant's avatar
Bryant committed
94 95
    void setSymbol( const QwtSymbol * );
    const QwtSymbol *symbol() const;
pixhawk's avatar
pixhawk committed
96

Bryant's avatar
Bryant committed
97
    void setLabel( const QwtText& );
pixhawk's avatar
pixhawk committed
98 99
    QwtText label() const;

Bryant's avatar
Bryant committed
100
    void setLabelAlignment( Qt::Alignment );
pixhawk's avatar
pixhawk committed
101 102
    Qt::Alignment labelAlignment() const;

Bryant's avatar
Bryant committed
103 104
    void setLabelOrientation( Qt::Orientation );
    Qt::Orientation labelOrientation() const;
105

Bryant's avatar
Bryant committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
    void setSpacing( int );
    int spacing() const;

    virtual void draw( QPainter *p,
        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
        const QRectF & ) const;

    virtual QRectF boundingRect() const;

    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;

protected:
    virtual void drawLines( QPainter *, 
        const QRectF &, const QPointF & ) const;

    virtual void drawLabel( QPainter *, 
        const QRectF &, const QPointF & ) const;
pixhawk's avatar
pixhawk committed
123 124

private:
Bryant's avatar
Bryant committed
125

pixhawk's avatar
pixhawk committed
126 127 128 129 130
    class PrivateData;
    PrivateData *d_data;
};

#endif