本文整理汇总了C++中QwtPlotCanvas::backingStore方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotCanvas::backingStore方法的具体用法?C++ QwtPlotCanvas::backingStore怎么用?C++ QwtPlotCanvas::backingStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlotCanvas
的用法示例。
在下文中一共展示了QwtPlotCanvas::backingStore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
//! Event filter
bool QwtPlotDirectPainter::eventFilter( QObject *, QEvent *event )
{
if ( event->type() == QEvent::Paint )
{
reset();
if ( d_data->seriesItem )
{
const QPaintEvent *pe = static_cast< QPaintEvent *>( event );
QwtPlotCanvas *canvas = d_data->seriesItem->plot()->canvas();
QPainter painter( canvas );
painter.setClipRegion( pe->region() );
bool copyCache = testAttribute( CopyBackingStore )
&& canvas->testPaintAttribute( QwtPlotCanvas::BackingStore );
if ( copyCache )
{
// is something valid in the cache ?
copyCache = ( canvas->backingStore() != NULL )
&& !canvas->backingStore()->isNull();
}
if ( copyCache )
{
painter.drawPixmap(
canvas->contentsRect().topLeft(),
*canvas->backingStore() );
}
else
{
renderItem( &painter, canvas->contentsRect(),
d_data->seriesItem, d_data->from, d_data->to );
}
return true; // don't call QwtPlotCanvas::paintEvent()
}
}
return false;
}
示例2: eventFilter
//! Event filter
bool QwtPlotDirectPainter::eventFilter( QObject *, QEvent *event )
{
if ( event->type() == QEvent::Paint )
{
reset();
if ( d_data->seriesItem )
{
const QPaintEvent *pe = static_cast< QPaintEvent *>( event );
QWidget *canvas = d_data->seriesItem->plot()->canvas();
QPainter painter( canvas );
painter.setClipRegion( pe->region() );
bool doCopyCache = testAttribute( CopyBackingStore );
if ( doCopyCache )
{
QwtPlotCanvas *plotCanvas =
qobject_cast<QwtPlotCanvas *>( canvas );
if ( plotCanvas )
{
doCopyCache = qwtHasBackingStore( plotCanvas );
if ( doCopyCache )
{
painter.drawPixmap( plotCanvas->contentsRect().topLeft(),
*plotCanvas->backingStore() );
}
}
}
if ( !doCopyCache )
{
qwtRenderItem( &painter, canvas->contentsRect(),
d_data->seriesItem, d_data->from, d_data->to );
}
return true; // don't call QwtPlotCanvas::paintEvent()
}
}
return false;
}
示例3: plot
/*!
\brief Draw a set of points of a seriesItem.
When observing an measurement while it is running, new points have to be
added to an existing seriesItem. drawSeries can be used to display them avoiding
a complete redraw of the canvas.
Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
will result in faster painting, if the paint engine of the canvas widget
supports this feature.
\param seriesItem Item to be painted
\param from Index of the first point to be painted
\param to Index of the last point to be painted. If to < 0 the
series will be painted to its last point.
*/
void QwtPlotDirectPainter::drawSeries(
QwtPlotAbstractSeriesItem *seriesItem, int from, int to )
{
if ( seriesItem == NULL || seriesItem->plot() == NULL )
return;
QwtPlotCanvas *canvas = seriesItem->plot()->canvas();
const QRect canvasRect = canvas->contentsRect();
const bool hasBackingStore =
canvas->testPaintAttribute( QwtPlotCanvas::BackingStore )
&& canvas->backingStore() && !canvas->backingStore()->isNull();
if ( hasBackingStore )
{
QPainter painter( const_cast<QPixmap *>( canvas->backingStore() ) );
if ( d_data->hasClipping )
painter.setClipRegion( d_data->clipRegion );
renderItem( &painter, canvasRect, seriesItem, from, to );
if ( testAttribute( QwtPlotDirectPainter::FullRepaint ) )
{
canvas->repaint();
return;
}
}
bool immediatePaint = true;
if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) )
{
immediatePaint = false;
}
if ( immediatePaint )
{
if ( !d_data->painter.isActive() )
{
reset();
d_data->painter.begin( canvas );
canvas->installEventFilter( this );
}
if ( d_data->hasClipping )
{
d_data->painter.setClipRegion(
QRegion( canvasRect ) & d_data->clipRegion );
}
else
{
if ( !d_data->painter.hasClipping() )
d_data->painter.setClipRect( canvasRect );
}
renderItem( &d_data->painter, canvasRect, seriesItem, from, to );
if ( d_data->attributes & QwtPlotDirectPainter::AtomicPainter )
{
reset();
}
else
{
if ( d_data->hasClipping )
d_data->painter.setClipping( false );
}
}
else
{
reset();
d_data->seriesItem = seriesItem;
d_data->from = from;
d_data->to = to;
QRegion clipRegion = canvasRect;
if ( d_data->hasClipping )
clipRegion &= d_data->clipRegion;
canvas->installEventFilter( this );
canvas->repaint(clipRegion);
canvas->removeEventFilter( this );
//.........这里部分代码省略.........
示例4: plot
/*!
\brief Draw a set of points of a seriesItem.
When observing an measurement while it is running, new points have to be
added to an existing seriesItem. drawSeries() can be used to display them avoiding
a complete redraw of the canvas.
Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
will result in faster painting, if the paint engine of the canvas widget
supports this feature.
\param seriesItem Item to be painted
\param from Index of the first point to be painted
\param to Index of the last point to be painted. If to < 0 the
series will be painted to its last point.
*/
void QwtPlotDirectPainter::drawSeries(
QwtPlotSeriesItem *seriesItem, int from, int to )
{
if ( seriesItem == NULL || seriesItem->plot() == NULL )
return;
QWidget *canvas = seriesItem->plot()->canvas();
const QRect canvasRect = canvas->contentsRect();
QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>( canvas );
if ( plotCanvas && qwtHasBackingStore( plotCanvas ) )
{
QPainter painter( const_cast<QPixmap *>( plotCanvas->backingStore() ) );
if ( d_data->hasClipping )
painter.setClipRegion( d_data->clipRegion );
qwtRenderItem( &painter, canvasRect, seriesItem, from, to );
painter.end();
if ( testAttribute( QwtPlotDirectPainter::FullRepaint ) )
{
plotCanvas->repaint();
return;
}
}
bool immediatePaint = true;
if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) )
{
#if QT_VERSION < 0x050000
if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) )
#endif
immediatePaint = false;
}
if ( immediatePaint )
{
if ( !d_data->painter.isActive() )
{
reset();
d_data->painter.begin( canvas );
canvas->installEventFilter( this );
}
if ( d_data->hasClipping )
{
d_data->painter.setClipRegion(
QRegion( canvasRect ) & d_data->clipRegion );
}
else
{
if ( !d_data->painter.hasClipping() )
d_data->painter.setClipRect( canvasRect );
}
qwtRenderItem( &d_data->painter, canvasRect, seriesItem, from, to );
if ( d_data->attributes & QwtPlotDirectPainter::AtomicPainter )
{
reset();
}
else
{
if ( d_data->hasClipping )
d_data->painter.setClipping( false );
}
}
else
{
reset();
d_data->seriesItem = seriesItem;
d_data->from = from;
d_data->to = to;
QRegion clipRegion = canvasRect;
if ( d_data->hasClipping )
clipRegion &= d_data->clipRegion;
canvas->installEventFilter( this );
//.........这里部分代码省略.........