15 #include <qpainterpath.h> 16 #include <qcoreevent.h> 17 #include <qopenglframebufferobject.h> 18 #include <qopenglpaintdevice.h> 39 QOpenGLFramebufferObject*
fbo;
49 : QOpenGLWidget( plot )
52 QSurfaceFormat fmt =
format();
67 : QOpenGLWidget( plot )
81 setAttribute( Qt::WA_OpaquePaintEvent,
true );
104 QOpenGLWidget::paintEvent( event );
114 const bool ok = QOpenGLWidget::event( event );
116 if ( event->type() == QEvent::PolishRequest )
125 if ( event->type() == QEvent::PolishRequest ||
126 event->type() == QEvent::StyleChange )
131 setAttribute( Qt::WA_StyledBackground,
132 testAttribute( Qt::WA_StyleSheet ) );
181 const bool hasFocusIndicator =
187 QOpenGLFramebufferObject::hasOpenGLFramebufferBlit() )
190 const QSize fboSize =
size() * pixelRatio;
192 if ( hasFocusIndicator )
193 painter.begin(
this );
216 QOpenGLFramebufferObjectFormat fboFormat;
218 fboFormat.setAttachment( QOpenGLFramebufferObject::CombinedDepthStencil );
220 m_data->
fbo =
new QOpenGLFramebufferObject( fboSize, fboFormat );
228 QOpenGLPaintDevice pd( fboSize );
230 QPainter fboPainter( &pd );
231 fboPainter.scale( pixelRatio, pixelRatio );
238 QOpenGLFramebufferObject::blitFramebuffer( NULL,
m_data->
fbo );
242 painter.begin(
this );
246 if ( hasFocusIndicator )
257 #include "moc_qwt_plot_opengl_canvas.cpp" Paint double buffered reusing the content of the pixmap buffer when possible.
Q_INVOKABLE QPainterPath borderPath(const QRect &) const
void init(const QSurfaceFormat &)
QPainterPath canvasBorderPath(const QRect &rect) const
void draw(QPainter *)
Helper function for the derived plot canvas.
virtual void paintGL() QWT_OVERRIDE
Paint the plot.
virtual void paintEvent(QPaintEvent *) QWT_OVERRIDE
bool testPaintAttribute(PaintAttribute) const
Base class of QwtPlotOpenGLCanvas and QwtPlotGLCanvas.
virtual bool event(QEvent *) QWT_OVERRIDE
virtual ~QwtPlotOpenGLCanvas()
Destructor.
virtual void resizeGL(int width, int height) QWT_OVERRIDE
No operation - reserved for some potential use in the future.
virtual void clearBackingStore() QWT_OVERRIDE
static qreal devicePixelRatio(const QPaintDevice *)
virtual Q_INVOKABLE void invalidateBackingStore() QWT_OVERRIDE
Invalidate the internal backing store.
void setFrameShape(QFrame::Shape)
FocusIndicator focusIndicator() const
QwtPlot * plot()
Return parent plot widget.
QOpenGLFramebufferObject * fbo
void setFrameShadow(QFrame::Shadow)
span_constexpr std::size_t size(span< T, Extent > const &spn)
virtual void initializeGL() QWT_OVERRIDE
No operation - reserved for some potential use in the future.
virtual void drawFocusIndicator(QPainter *)
QwtPlotOpenGLCanvas(QwtPlot *=NULL)
Constructor.
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)