1 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
---|
2 | * Qwt Widget Library
|
---|
3 | * Copyright (C) 1997 Josef Wilgen
|
---|
4 | * Copyright (C) 2002 Uwe Rathmann
|
---|
5 | *
|
---|
6 | * This library is free software; you can redistribute it and/or
|
---|
7 | * modify it under the terms of the Qwt License, Version 1.0
|
---|
8 | *****************************************************************************/
|
---|
9 |
|
---|
10 | #ifndef QWT_PLOT_GLCANVAS_H
|
---|
11 | #define QWT_PLOT_GLCANVAS_H
|
---|
12 |
|
---|
13 | #include "qwt_global.h"
|
---|
14 | #include <qframe.h>
|
---|
15 | #include <qgl.h>
|
---|
16 | #include <qpainterpath.h>
|
---|
17 |
|
---|
18 | class QwtPlot;
|
---|
19 |
|
---|
20 | /*!
|
---|
21 | \brief An alternative canvas for a QwtPlot derived from QGLWidget
|
---|
22 |
|
---|
23 | QwtPlotGLCanvas implements the very basics to act as canvas
|
---|
24 | inside of a QwtPlot widget. It might be extended to a full
|
---|
25 | featured alternative to QwtPlotCanvas in a future version of Qwt.
|
---|
26 |
|
---|
27 | Even if QwtPlotGLCanvas is not derived from QFrame it imitates
|
---|
28 | its API. When using style sheets it supports the box model - beside
|
---|
29 | backgrounds with rounded borders.
|
---|
30 |
|
---|
31 | \sa QwtPlot::setCanvas(), QwtPlotCanvas
|
---|
32 |
|
---|
33 | \note With Qt4 you might want to use the QPaintEngine::OpenGL paint engine
|
---|
34 | ( see QGL::setPreferredPaintEngine() ). On a Linux test system
|
---|
35 | QPaintEngine::OpenGL2 shows very basic problems like translated
|
---|
36 | geometries.
|
---|
37 | */
|
---|
38 | class QWT_EXPORT QwtPlotGLCanvas: public QGLWidget
|
---|
39 | {
|
---|
40 | Q_OBJECT
|
---|
41 |
|
---|
42 | Q_ENUMS( Shape Shadow )
|
---|
43 |
|
---|
44 | Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
|
---|
45 | Q_PROPERTY( Shape frameShape READ frameShape WRITE setFrameShape )
|
---|
46 | Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
|
---|
47 | Q_PROPERTY( int midLineWidth READ midLineWidth WRITE setMidLineWidth )
|
---|
48 | Q_PROPERTY( int frameWidth READ frameWidth )
|
---|
49 | Q_PROPERTY( QRect frameRect READ frameRect DESIGNABLE false )
|
---|
50 |
|
---|
51 | public:
|
---|
52 | /*!
|
---|
53 | \brief Frame shadow
|
---|
54 |
|
---|
55 | Unfortunately it is not possible to use QFrame::Shadow
|
---|
56 | as a property of a widget that is not derived from QFrame.
|
---|
57 | The following enum is made for the designer only. It is safe
|
---|
58 | to use QFrame::Shadow instead.
|
---|
59 | */
|
---|
60 | enum Shadow
|
---|
61 | {
|
---|
62 | //! QFrame::Plain
|
---|
63 | Plain = QFrame::Plain,
|
---|
64 |
|
---|
65 | //! QFrame::Raised
|
---|
66 | Raised = QFrame::Raised,
|
---|
67 |
|
---|
68 | //! QFrame::Sunken
|
---|
69 | Sunken = QFrame::Sunken
|
---|
70 | };
|
---|
71 |
|
---|
72 | /*!
|
---|
73 | \brief Frame shape
|
---|
74 |
|
---|
75 | Unfortunately it is not possible to use QFrame::Shape
|
---|
76 | as a property of a widget that is not derived from QFrame.
|
---|
77 | The following enum is made for the designer only. It is safe
|
---|
78 | to use QFrame::Shadow instead.
|
---|
79 |
|
---|
80 | \note QFrame::StyledPanel and QFrame::WinPanel are unsupported
|
---|
81 | and will be displayed as QFrame::Panel.
|
---|
82 | */
|
---|
83 | enum Shape
|
---|
84 | {
|
---|
85 | NoFrame = QFrame::NoFrame,
|
---|
86 |
|
---|
87 | Box = QFrame::Box,
|
---|
88 | Panel = QFrame::Panel
|
---|
89 | };
|
---|
90 |
|
---|
91 | explicit QwtPlotGLCanvas( QwtPlot * = NULL );
|
---|
92 | virtual ~QwtPlotGLCanvas();
|
---|
93 |
|
---|
94 | void setFrameStyle( int style );
|
---|
95 | int frameStyle() const;
|
---|
96 |
|
---|
97 | void setFrameShadow( Shadow );
|
---|
98 | Shadow frameShadow() const;
|
---|
99 |
|
---|
100 | void setFrameShape( Shape );
|
---|
101 | Shape frameShape() const;
|
---|
102 |
|
---|
103 | void setLineWidth( int );
|
---|
104 | int lineWidth() const;
|
---|
105 |
|
---|
106 | void setMidLineWidth( int );
|
---|
107 | int midLineWidth() const;
|
---|
108 |
|
---|
109 | int frameWidth() const;
|
---|
110 | QRect frameRect() const;
|
---|
111 |
|
---|
112 | Q_INVOKABLE QPainterPath borderPath( const QRect & ) const;
|
---|
113 |
|
---|
114 | virtual bool event( QEvent * );
|
---|
115 |
|
---|
116 | public Q_SLOTS:
|
---|
117 | void replot();
|
---|
118 |
|
---|
119 | protected:
|
---|
120 | virtual void paintEvent( QPaintEvent * );
|
---|
121 |
|
---|
122 | virtual void drawBackground( QPainter * );
|
---|
123 | virtual void drawBorder( QPainter * );
|
---|
124 | virtual void drawItems( QPainter * );
|
---|
125 |
|
---|
126 | private:
|
---|
127 | class PrivateData;
|
---|
128 | PrivateData *d_data;
|
---|
129 | };
|
---|
130 |
|
---|
131 | #endif
|
---|