| 1 | /******************************************************************************
|
|---|
| 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_ABSTRACT_CANVAS_H
|
|---|
| 11 | #define QWT_PLOT_ABSTRACT_CANVAS_H
|
|---|
| 12 |
|
|---|
| 13 | #include "qwt_global.h"
|
|---|
| 14 | #include <qframe.h>
|
|---|
| 15 |
|
|---|
| 16 | class QwtPlot;
|
|---|
| 17 |
|
|---|
| 18 | /*!
|
|---|
| 19 | \brief Base class for all type of plot canvases
|
|---|
| 20 | */
|
|---|
| 21 | class QWT_EXPORT QwtPlotAbstractCanvas
|
|---|
| 22 | {
|
|---|
| 23 | public:
|
|---|
| 24 | /*!
|
|---|
| 25 | \brief Focus indicator
|
|---|
| 26 | The default setting is NoFocusIndicator
|
|---|
| 27 | \sa setFocusIndicator(), focusIndicator(), drawFocusIndicator()
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | enum FocusIndicator
|
|---|
| 31 | {
|
|---|
| 32 | //! Don't paint a focus indicator
|
|---|
| 33 | NoFocusIndicator,
|
|---|
| 34 |
|
|---|
| 35 | /*!
|
|---|
| 36 | The focus is related to the complete canvas.
|
|---|
| 37 | Paint the focus indicator using drawFocusIndicator()
|
|---|
| 38 | */
|
|---|
| 39 | CanvasFocusIndicator,
|
|---|
| 40 |
|
|---|
| 41 | /*!
|
|---|
| 42 | The focus is related to an item (curve, point, ...) on
|
|---|
| 43 | the canvas. It is up to the application to display a
|
|---|
| 44 | focus indication using f.e. highlighting.
|
|---|
| 45 | */
|
|---|
| 46 | ItemFocusIndicator
|
|---|
| 47 | };
|
|---|
| 48 |
|
|---|
| 49 | explicit QwtPlotAbstractCanvas( QWidget* canvasWidget );
|
|---|
| 50 | virtual ~QwtPlotAbstractCanvas();
|
|---|
| 51 |
|
|---|
| 52 | QwtPlot* plot();
|
|---|
| 53 | const QwtPlot* plot() const;
|
|---|
| 54 |
|
|---|
| 55 | void setFocusIndicator( FocusIndicator );
|
|---|
| 56 | FocusIndicator focusIndicator() const;
|
|---|
| 57 |
|
|---|
| 58 | void setBorderRadius( double );
|
|---|
| 59 | double borderRadius() const;
|
|---|
| 60 |
|
|---|
| 61 | protected:
|
|---|
| 62 | QWidget* canvasWidget();
|
|---|
| 63 | const QWidget* canvasWidget() const;
|
|---|
| 64 |
|
|---|
| 65 | virtual void drawFocusIndicator( QPainter* );
|
|---|
| 66 | virtual void drawBorder( QPainter* );
|
|---|
| 67 | virtual void drawBackground( QPainter* );
|
|---|
| 68 |
|
|---|
| 69 | void fillBackground( QPainter* );
|
|---|
| 70 | void drawCanvas( QPainter* );
|
|---|
| 71 | void drawStyled( QPainter*, bool );
|
|---|
| 72 | void drawUnstyled( QPainter* );
|
|---|
| 73 |
|
|---|
| 74 | QPainterPath canvasBorderPath( const QRect& rect ) const;
|
|---|
| 75 | void updateStyleSheetInfo();
|
|---|
| 76 |
|
|---|
| 77 | private:
|
|---|
| 78 | Q_DISABLE_COPY(QwtPlotAbstractCanvas)
|
|---|
| 79 |
|
|---|
| 80 | class PrivateData;
|
|---|
| 81 | PrivateData* m_data;
|
|---|
| 82 | };
|
|---|
| 83 |
|
|---|
| 84 | /*!
|
|---|
| 85 | \brief Base class of QwtPlotOpenGLCanvas and QwtPlotGLCanvas
|
|---|
| 86 | */
|
|---|
| 87 | class QWT_EXPORT QwtPlotAbstractGLCanvas : public QwtPlotAbstractCanvas
|
|---|
| 88 | {
|
|---|
| 89 | public:
|
|---|
| 90 | /*!
|
|---|
| 91 | \brief Paint attributes
|
|---|
| 92 |
|
|---|
| 93 | The default setting enables BackingStore and Opaque.
|
|---|
| 94 |
|
|---|
| 95 | \sa setPaintAttribute(), testPaintAttribute()
|
|---|
| 96 | */
|
|---|
| 97 | enum PaintAttribute
|
|---|
| 98 | {
|
|---|
| 99 | /*!
|
|---|
| 100 | \brief Paint double buffered reusing the content
|
|---|
| 101 | of the pixmap buffer when possible.
|
|---|
| 102 |
|
|---|
| 103 | Using a backing store might improve the performance
|
|---|
| 104 | significantly, when working with widget overlays ( like rubber bands ).
|
|---|
| 105 | Disabling the cache might improve the performance for
|
|---|
| 106 | incremental paints (using QwtPlotDirectPainter ).
|
|---|
| 107 |
|
|---|
| 108 | \sa backingStore(), invalidateBackingStore()
|
|---|
| 109 | */
|
|---|
| 110 | BackingStore = 1,
|
|---|
| 111 |
|
|---|
| 112 | /*!
|
|---|
| 113 | When ImmediatePaint is set replot() calls repaint()
|
|---|
| 114 | instead of update().
|
|---|
| 115 |
|
|---|
| 116 | \sa replot(), QWidget::repaint(), QWidget::update()
|
|---|
| 117 | */
|
|---|
| 118 | ImmediatePaint = 8,
|
|---|
| 119 | };
|
|---|
| 120 |
|
|---|
| 121 | //! Paint attributes
|
|---|
| 122 | Q_DECLARE_FLAGS( PaintAttributes, PaintAttribute )
|
|---|
| 123 |
|
|---|
| 124 | explicit QwtPlotAbstractGLCanvas( QWidget* canvasWidget );
|
|---|
| 125 | virtual ~QwtPlotAbstractGLCanvas();
|
|---|
| 126 |
|
|---|
| 127 | void setPaintAttribute( PaintAttribute, bool on = true );
|
|---|
| 128 | bool testPaintAttribute( PaintAttribute ) const;
|
|---|
| 129 |
|
|---|
| 130 | void setFrameStyle( int style );
|
|---|
| 131 | int frameStyle() const;
|
|---|
| 132 |
|
|---|
| 133 | void setFrameShadow( QFrame::Shadow );
|
|---|
| 134 | QFrame::Shadow frameShadow() const;
|
|---|
| 135 |
|
|---|
| 136 | void setFrameShape( QFrame::Shape );
|
|---|
| 137 | QFrame::Shape frameShape() const;
|
|---|
| 138 |
|
|---|
| 139 | void setLineWidth( int );
|
|---|
| 140 | int lineWidth() const;
|
|---|
| 141 |
|
|---|
| 142 | void setMidLineWidth( int );
|
|---|
| 143 | int midLineWidth() const;
|
|---|
| 144 |
|
|---|
| 145 | int frameWidth() const;
|
|---|
| 146 | QRect frameRect() const;
|
|---|
| 147 |
|
|---|
| 148 | //! Invalidate the internal backing store
|
|---|
| 149 | virtual void invalidateBackingStore() = 0;
|
|---|
| 150 |
|
|---|
| 151 | protected:
|
|---|
| 152 | void replot();
|
|---|
| 153 | void draw( QPainter* );
|
|---|
| 154 |
|
|---|
| 155 | private:
|
|---|
| 156 | virtual void clearBackingStore() = 0;
|
|---|
| 157 |
|
|---|
| 158 | class PrivateData;
|
|---|
| 159 | PrivateData* m_data;
|
|---|
| 160 | };
|
|---|
| 161 |
|
|---|
| 162 | Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotAbstractGLCanvas::PaintAttributes )
|
|---|
| 163 |
|
|---|
| 164 | #endif
|
|---|