File: qwt_plot_canvas.h

package info (click to toggle)
libqwt 4.2.0-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,856 kB
  • ctags: 5,512
  • sloc: cpp: 22,973; ansic: 244; makefile: 59
file content (156 lines) | stat: -rw-r--r-- 3,730 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

// vim: expandtab

#ifndef QWT_PLOT_CANVAS_H
#define QWT_PLOT_CANVAS_H

#include <qframe.h>
#include <qpen.h>
#include "qwt_global.h"
#include "qwt.h"

class QwtPlot;
class QPixmap;

/*!
  \brief Canvas of a QwtPlot. 

  \sa  QwtPlot 
*/

class QWT_EXPORT QwtPlotCanvas : public QFrame
{
    Q_OBJECT
    friend class QwtPlot;

public:
    /*!
      \brief Focus indicator

      - NoFocusIndicator\n
        Dont paint a focus indicator
      - CanvasFocusIndicator\n
        The focus is related to the complete canvas.
        Paint the focus indicator using paintFocus()
      - ItemFocusIndicator\n
        The focus is related to an item (curve, point, ...) on
        the canvas. It is up to the application to display a
        focus indication using f.e. highlighting.

      \sa setFocusIndicator(), focusIndicator(), paintFocus()
    */

    enum FocusIndicator
    {
        NoFocusIndicator,
        CanvasFocusIndicator,
        ItemFocusIndicator
    };

    void setFocusIndicator(FocusIndicator);
    FocusIndicator focusIndicator() const;

    void setCacheMode(bool on);
    bool cacheMode() const;
    const QPixmap *cache() const;
    void invalidateCache();

protected:
    QwtPlotCanvas(QwtPlot *);
    virtual ~QwtPlotCanvas();

    QPixmap *cache();

    virtual void frameChanged();
    virtual void drawContents(QPainter *);
    virtual void drawFocusIndicator(QPainter *, const QRect &);

    void drawCanvas(QPainter *painter = NULL);

private:    
    FocusIndicator d_focusIndicator;
    bool d_cacheMode;
    QPixmap *d_cache;

#ifndef QWT_NO_COMPAT
public:
    void enableOutline(bool tf);
    bool outlineEnabled() const;

    void setOutlinePen(const QPen &p);
    const QPen& outlinePen() const;

    void setOutlineStyle(Qwt::Shape os);
    Qwt::Shape outlineStyle() const;
    
signals:
    /*!
      A signal which is emitted when the mouse is pressed in the canvas.

      \warning Outlining functionality is obsolete: use QwtPlotPicker or
      QwtPlotZoomer.
      
      \param e Mouse event object
    */
    void mousePressed(const QMouseEvent &e);
    /*!
      A signal which is emitted when a mouse button has been released in the
      canvas.

      \warning Outlining functionality is obsolete: use QwtPlotPicker or
      QwtPlotZoomer.

      \param e Mouse event object
    */
    void mouseReleased(const QMouseEvent &e);
    /*!
      A signal which is emitted when the mouse is moved in the canvas.

      \warning Outlining functionality is obsolete: use QwtPlotPicker or
      QwtPlotZoomer.

      \param e Mouse event object
    */
    void mouseMoved(const QMouseEvent &e);

protected:
    virtual void mousePressEvent(QMouseEvent *);
    virtual void mouseReleaseEvent(QMouseEvent *);
    virtual void mouseMoveEvent(QMouseEvent *);

private:    
    bool d_outlineEnabled;
    bool d_outlineActive;
    bool d_mousePressed;

    void drawOutline(QPainter &p);

    Qwt::Shape d_outline;
    QPen d_pen;
    QPoint d_entryPoint;
    QPoint d_lastPoint;
#else
private:
    // needed because of mocs #ifdef ignorance
    void mousePressed(const QMouseEvent &);
    void mouseReleased(const QMouseEvent &);
    void mouseMoved(const QMouseEvent &);
#endif // !QWT_NO_COMPAT

};

#endif

// Local Variables:
// mode: C++
// c-file-style: "stroustrup"
// indent-tabs-mode: nil
// End: