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 )
70 : QGLWidget( format, plot )
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 ) );
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() )
194 QGLFramebufferObjectFormat
format;
195 format.setSamples( 4 );
196 format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
205 fboPainter.scale( pixelRatio, pixelRatio );
219 QGLFramebufferObject::blitFramebuffer( NULL,
220 rect.translated( 0, height() - rect.height() ),
m_data->
fbo, rect );
224 painter.begin(
this );
228 if ( hasFocusIndicator )
239 #include "moc_qwt_plot_glcanvas.cpp" Paint double buffered reusing the content of the pixmap buffer when possible.
QPainterPath canvasBorderPath(const QRect &rect) const
virtual void clearBackingStore() QWT_OVERRIDE
void draw(QPainter *)
Helper function for the derived plot canvas.
virtual ~QwtPlotGLCanvas()
Destructor.
virtual void resizeGL(int width, int height) QWT_OVERRIDE
No operation - reserved for some potential use in the future.
bool testPaintAttribute(PaintAttribute) const
virtual Q_INVOKABLE void invalidateBackingStore() QWT_OVERRIDE
Invalidate the internal backing store.
Base class of QwtPlotOpenGLCanvas and QwtPlotGLCanvas.
virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE
static qreal devicePixelRatio(const QPaintDevice *)
void setFrameShape(QFrame::Shape)
FocusIndicator focusIndicator() const
virtual void paintGL() QWT_OVERRIDE
Paint the plot.
QGLFramebufferObject * fbo
QwtPlot * plot()
Return parent plot widget.
virtual bool event(QEvent *) QWT_OVERRIDE
void setFrameShadow(QFrame::Shadow)
QwtPlotGLCanvas(QwtPlot *=NULL)
Constructor.
virtual void drawFocusIndicator(QPainter *)
Q_INVOKABLE QPainterPath borderPath(const QRect &) const
virtual void initializeGL() QWT_OVERRIDE
No operation - reserved for some potential use in the future.
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)