qwt_symbol.h 1.95 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 20 21 22 23 24 25 26 27 28
 * 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_SYMBOL_H
#define QWT_SYMBOL_H

#include <qbrush.h>
#include <qpen.h>
#include <qsize.h>
#include "qwt_global.h"

class QPainter;
class QRect;

//! A class for drawing symbols
class QWT_EXPORT QwtSymbol
{
public:
    /*!
        Style
        \sa setStyle(), style()
     */
29 30
    enum Style {
        NoSymbol = -1,
pixhawk's avatar
pixhawk committed
31

32 33 34 35
        Ellipse,
        Rect,
        Diamond,
        Triangle,
pixhawk's avatar
pixhawk committed
36
        DTriangle,
37 38 39 40 41 42 43 44 45 46
        UTriangle,
        LTriangle,
        RTriangle,
        Cross,
        XCross,
        HLine,
        VLine,
        Star1,
        Star2,
        Hexagon,
pixhawk's avatar
pixhawk committed
47

48
        StyleCnt
pixhawk's avatar
pixhawk committed
49
    };
50

pixhawk's avatar
pixhawk committed
51 52 53 54
public:
    QwtSymbol();
    QwtSymbol(Style st, const QBrush &bd, const QPen &pn, const QSize &s);
    virtual ~QwtSymbol();
55

pixhawk's avatar
pixhawk committed
56 57 58 59 60 61 62 63 64 65 66 67
    bool operator!=(const QwtSymbol &) const;
    virtual bool operator==(const QwtSymbol &) const;

    virtual QwtSymbol *clone() const;

    void setSize(const QSize &s);
    void setSize(int a, int b = -1);
    void setBrush(const QBrush& b);
    void setPen(const QPen &p);
    void setStyle (Style s);

    //! Return Brush
68 69 70
    const QBrush& brush() const {
        return d_brush;
    }
pixhawk's avatar
pixhawk committed
71
    //! Return Pen
72 73 74
    const QPen& pen() const {
        return d_pen;
    }
pixhawk's avatar
pixhawk committed
75
    //! Return Size
76 77 78
    const QSize& size() const {
        return d_size;
    }
pixhawk's avatar
pixhawk committed
79
    //! Return Style
80 81 82 83 84
    Style style() const {
        return d_style;
    }

    void draw(QPainter *p, const QPoint &pt) const;
pixhawk's avatar
pixhawk committed
85 86 87 88 89 90 91 92 93 94 95
    void draw(QPainter *p, int x, int y) const;
    virtual void draw(QPainter *p, const QRect &r) const;

private:
    QBrush d_brush;
    QPen d_pen;
    QSize d_size;
    Style d_style;
};

#endif