10#include "qwt_plot_glcanvas.h" 
   12#include "qwt_painter.h" 
   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 );
 
   32class QwtPlotGLCanvas::PrivateData
 
   47    QGLFramebufferObject* fbo;
 
   57    : QGLWidget( QwtPlotGLCanvasFormat(), plot )
 
 
   70    : QGLWidget( format, plot )
 
 
   82void QwtPlotGLCanvas::init()
 
   84    m_data = 
new PrivateData;
 
   87    setAttribute( Qt::WA_OpaquePaintEvent, 
true );
 
  102    QGLWidget::paintEvent( 
event );
 
 
  112    const bool ok = QGLWidget::event( 
event );
 
  114    if ( 
event->type() == QEvent::PolishRequest ||
 
  115        event->type() == QEvent::StyleChange )
 
  120        setAttribute( Qt::WA_StyledBackground,
 
  121            testAttribute( Qt::WA_StyleSheet ) );
 
 
  139    m_data->fboDirty = 
true;
 
 
  142void QwtPlotGLCanvas::clearBackingStore()
 
  170    const bool hasFocusIndicator =
 
  178        const QRect rect( 0, 0, width() * pixelRatio, height() * pixelRatio );
 
  180        if ( hasFocusIndicator )
 
  181            painter.begin( 
this );
 
  185            if ( m_data->fbo->size() != rect.size() )
 
  192        if ( m_data->fbo == NULL )
 
  194            QGLFramebufferObjectFormat format;
 
  195            format.setSamples( 4 );
 
  196            format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
 
  198            m_data->fbo = 
new QGLFramebufferObject( rect.size(), format );
 
  199            m_data->fboDirty = 
true;
 
  202        if ( m_data->fboDirty )
 
  204            QPainter fboPainter( m_data->fbo );
 
  205            fboPainter.scale( pixelRatio, pixelRatio );
 
  209            m_data->fboDirty = 
false;
 
  219        QGLFramebufferObject::blitFramebuffer( NULL,
 
  220            rect.translated( 0, height() - rect.height() ), m_data->fbo, rect );
 
  224        painter.begin( 
this );
 
  228    if ( hasFocusIndicator )
 
 
  238#include "moc_qwt_plot_glcanvas.cpp" 
static qreal devicePixelRatio(const QPaintDevice *)
FocusIndicator focusIndicator() const
QPainterPath canvasBorderPath(const QRect &rect) const
virtual void drawFocusIndicator(QPainter *)
Base class of QwtPlotOpenGLCanvas and QwtPlotGLCanvas.
bool testPaintAttribute(PaintAttribute) const
@ BackingStore
Paint double buffered reusing the content of the pixmap buffer when possible.
void setFrameShape(QFrame::Shape)
void setFrameShadow(QFrame::Shadow)
void draw(QPainter *)
Helper function for the derived plot canvas.
virtual ~QwtPlotGLCanvas()
Destructor.
Q_INVOKABLE QPainterPath borderPath(const QRect &) const
virtual void initializeGL() override
No operation - reserved for some potential use in the future.
virtual Q_INVOKABLE void invalidateBackingStore() override
Invalidate the internal backing store.
virtual bool event(QEvent *) override
virtual void paintGL() override
Paint the plot.
virtual void paintEvent(QPaintEvent *) override
virtual void resizeGL(int width, int height) override
No operation - reserved for some potential use in the future.
QwtPlotGLCanvas(QwtPlot *=NULL)
Constructor.