Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_plot_directpainter.cpp
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_directpainter.cpp
r4271 r8127 18 18 #include <qpixmap.h> 19 19 20 static inline void renderItem(20 static inline void qwtRenderItem( 21 21 QPainter *painter, const QRect &canvasRect, 22 QwtPlot AbstractSeriesItem *seriesItem, int from, int to )22 QwtPlotSeriesItem *seriesItem, int from, int to ) 23 23 { 24 24 // A minor performance improvement is possible … … 32 32 seriesItem->testRenderHint( QwtPlotItem::RenderAntialiased ) ); 33 33 seriesItem->drawSeries( painter, xMap, yMap, canvasRect, from, to ); 34 } 35 36 static inline bool qwtHasBackingStore( const QwtPlotCanvas *canvas ) 37 { 38 return canvas->testPaintAttribute( QwtPlotCanvas::BackingStore ) 39 && canvas->backingStore() && !canvas->backingStore()->isNull(); 34 40 } 35 41 … … 40 46 attributes( 0 ), 41 47 hasClipping(false), 42 seriesItem( NULL ) 48 seriesItem( NULL ), 49 from( 0 ), 50 to( 0 ) 43 51 { 44 52 } … … 51 59 QPainter painter; 52 60 53 QwtPlot AbstractSeriesItem *seriesItem;61 QwtPlotSeriesItem *seriesItem; 54 62 int from; 55 63 int to; … … 92 100 93 101 /*! 94 Check if a attribute is set. 95 102 \return True, when attribute is enabled 96 103 \param attribute Attribute to be tested 97 104 \sa Attribute, setAttribute() … … 152 159 153 160 When observing an measurement while it is running, new points have to be 154 added to an existing seriesItem. drawSeries can be used to display them avoiding161 added to an existing seriesItem. drawSeries() can be used to display them avoiding 155 162 a complete redraw of the canvas. 156 163 … … 165 172 */ 166 173 void QwtPlotDirectPainter::drawSeries( 167 QwtPlot AbstractSeriesItem *seriesItem, int from, int to )174 QwtPlotSeriesItem *seriesItem, int from, int to ) 168 175 { 169 176 if ( seriesItem == NULL || seriesItem->plot() == NULL ) 170 177 return; 171 178 172 Q wtPlotCanvas*canvas = seriesItem->plot()->canvas();179 QWidget *canvas = seriesItem->plot()->canvas(); 173 180 const QRect canvasRect = canvas->contentsRect(); 174 181 175 const bool hasBackingStore = 176 canvas->testPaintAttribute( QwtPlotCanvas::BackingStore ) 177 && canvas->backingStore() && !canvas->backingStore()->isNull(); 178 179 if ( hasBackingStore ) 180 { 181 QPainter painter( const_cast<QPixmap *>( canvas->backingStore() ) ); 182 painter.translate( -canvasRect.x(), -canvasRect.y() ); 182 QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>( canvas ); 183 184 if ( plotCanvas && qwtHasBackingStore( plotCanvas ) ) 185 { 186 QPainter painter( const_cast<QPixmap *>( plotCanvas->backingStore() ) ); 183 187 184 188 if ( d_data->hasClipping ) 185 189 painter.setClipRegion( d_data->clipRegion ); 186 190 187 renderItem( &painter, canvasRect, seriesItem, from, to ); 191 qwtRenderItem( &painter, canvasRect, seriesItem, from, to ); 192 193 painter.end(); 188 194 189 195 if ( testAttribute( QwtPlotDirectPainter::FullRepaint ) ) 190 196 { 191 canvas->repaint();197 plotCanvas->repaint(); 192 198 return; 193 199 } … … 195 201 196 202 bool immediatePaint = true; 197 if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) && 198 !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) ) 199 { 200 immediatePaint = false; 203 if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) ) 204 { 205 #if QT_VERSION < 0x050000 206 if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) ) 207 #endif 208 immediatePaint = false; 201 209 } 202 210 203 211 if ( immediatePaint ) 204 212 { 205 QwtPlotCanvas *canvas = seriesItem->plot()->canvas();206 213 if ( !d_data->painter.isActive() ) 207 214 { … … 223 230 } 224 231 225 renderItem( &d_data->painter, canvasRect, seriesItem, from, to );232 qwtRenderItem( &d_data->painter, canvasRect, seriesItem, from, to ); 226 233 227 234 if ( d_data->attributes & QwtPlotDirectPainter::AtomicPainter ) … … 260 267 if ( d_data->painter.isActive() ) 261 268 { 262 QWidget *w = ( QWidget * )d_data->painter.device();269 QWidget *w = static_cast<QWidget *>( d_data->painter.device() ); 263 270 if ( w ) 264 271 w->removeEventFilter( this ); … … 279 286 const QPaintEvent *pe = static_cast< QPaintEvent *>( event ); 280 287 281 Q wtPlotCanvas*canvas = d_data->seriesItem->plot()->canvas();288 QWidget *canvas = d_data->seriesItem->plot()->canvas(); 282 289 283 290 QPainter painter( canvas ); 284 291 painter.setClipRegion( pe->region() ); 285 292 286 bool copyCache = testAttribute( CopyBackingStore ) 287 && canvas->testPaintAttribute( QwtPlotCanvas::BackingStore ); 288 289 if ( copyCache ) 293 bool doCopyCache = testAttribute( CopyBackingStore ); 294 295 if ( doCopyCache ) 290 296 { 291 // is something valid in the cache ? 292 copyCache = ( canvas->backingStore() != NULL ) 293 && !canvas->backingStore()->isNull(); 297 QwtPlotCanvas *plotCanvas = 298 qobject_cast<QwtPlotCanvas *>( canvas ); 299 if ( plotCanvas ) 300 { 301 doCopyCache = qwtHasBackingStore( plotCanvas ); 302 if ( doCopyCache ) 303 { 304 painter.drawPixmap( plotCanvas->rect().topLeft(), 305 *plotCanvas->backingStore() ); 306 } 307 } 294 308 } 295 309 296 if ( copyCache )310 if ( !doCopyCache ) 297 311 { 298 painter.drawPixmap( 299 canvas->contentsRect().topLeft(), 300 *canvas->backingStore() ); 301 } 302 else 303 { 304 renderItem( &painter, canvas->contentsRect(), 312 qwtRenderItem( &painter, canvas->contentsRect(), 305 313 d_data->seriesItem, d_data->from, d_data->to ); 306 314 }
Note:
See TracChangeset
for help on using the changeset viewer.