14 #include <qcoreevent.h> 16 #include <qpainterpath.h> 17 #include <qglframebufferobject.h> 21 class QwtPlotGLCanvasFormat:
public QGLFormat
24 QwtPlotGLCanvasFormat():
25 QGLFormat( QGLFormat::defaultFormat() )
27 setSampleBuffers(
true );
47 QGLFramebufferObject*
fbo;
57 QGLWidget( QwtPlotGLCanvasFormat(), plot ),
62 setAttribute( Qt::WA_OpaquePaintEvent,
true );
67 QGLWidget( format, plot ),
72 setAttribute( Qt::WA_OpaquePaintEvent,
true );
90 QGLWidget::paintEvent( event );
100 const bool ok = QGLWidget::event( event );
102 if ( event->type() == QEvent::PolishRequest ||
103 event->type() == QEvent::StyleChange )
108 setAttribute( Qt::WA_StyledBackground,
109 testAttribute( Qt::WA_StyleSheet ) );
142 const bool hasFocusIndicator =
150 const QRect rect( 0, 0, width() * pixelRatio, height() * pixelRatio );
152 if ( hasFocusIndicator )
153 painter.begin(
this );
157 if (
d_data->
fbo->size() != rect.size() )
166 QGLFramebufferObjectFormat
format;
167 format.setSamples( 4 );
168 format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
177 fboPainter.scale( pixelRatio, pixelRatio );
191 QGLFramebufferObject::blitFramebuffer( NULL,
192 rect.translated( 0, height() - rect.height() ),
d_data->
fbo, rect );
196 painter.begin(
this );
200 if ( hasFocusIndicator )
210 #include "moc_qwt_plot_glcanvas.cpp" Paint double buffered reusing the content of the pixmap buffer when possible.
virtual void clearBackingStore() QWT_OVERRIDE
FMT_INLINE std::basic_string< Char > format(const S &format_str, Args &&...args)
virtual ~QwtPlotGLCanvas()
Destructor.
bool testPaintAttribute(PaintAttribute) const
FocusIndicator focusIndicator() const
virtual void resizeGL(int width, int height) QWT_OVERRIDE
virtual Q_INVOKABLE void invalidateBackingStore() QWT_OVERRIDE
virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE
static qreal devicePixelRatio(const QPaintDevice *)
Q_INVOKABLE QPainterPath borderPath(const QRect &) const
virtual void paintGL() QWT_OVERRIDE
QPainterPath borderPath2(const QRect &rect) const
QGLFramebufferObject * fbo
QwtPlot * plot()
Return parent plot widget.
virtual bool event(QEvent *) QWT_OVERRIDE
QwtPlotGLCanvas(QwtPlot *=NULL)
Constructor.
virtual void drawFocusIndicator(QPainter *)
virtual void initializeGL() QWT_OVERRIDE