Changeset 9383 in ntrip for trunk/BNC/qwt/qwt_plot_canvas.cpp
- Timestamp:
- Mar 19, 2021, 9:15:03 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_canvas.cpp
r8127 r9383 49 49 } 50 50 51 virtual void drawRects(const QRect *rects, int count ) 52 { 53 // to silence -Woverloaded-virtual 54 QwtNullPaintDevice::drawRects( rects, count ); 55 } 56 51 57 virtual void drawPath( const QPainterPath &path ) 52 58 { … … 73 79 for ( int i = 0; i < path.elementCount(); i++ ) 74 80 { 75 QPainterPath::Element el = path.elementAt(i); 81 QPainterPath::Element el = path.elementAt(i); 76 82 switch( el.type ) 77 83 { … … 98 104 { 99 105 QRectF r = clipRects.last(); 100 r.setCoords( 106 r.setCoords( 101 107 qMin( r.left(), el.x ), 102 108 qMin( r.top(), el.y ), … … 170 176 painter->setClipPath( borderClip, Qt::IntersectClip ); 171 177 172 const QBrush &brush = 178 const QBrush &brush = 173 179 canvas->palette().brush( canvas->backgroundRole() ); 174 180 … … 186 192 { 187 193 rects += canvas->rect(); 188 } 189 else 194 } 195 else 190 196 { 191 197 rects = painter->clipRegion().rects(); … … 197 203 if ( painter->paintEngine()->type() == QPaintEngine::X11 ) 198 204 { 199 // Qt 4.7.1: gradients on X11 are broken ( subrects + 205 // Qt 4.7.1: gradients on X11 are broken ( subrects + 200 206 // QGradient::StretchToDeviceMode ) and horrible slow. 201 207 // As workaround we have to use the raster paintengine. … … 223 229 } 224 230 } 225 231 226 232 QImage image( canvas->size(), format ); 227 233 … … 268 274 } 269 275 270 static QPainterPath qwtCombinePathList( const QRectF &rect, 276 static QPainterPath qwtCombinePathList( const QRectF &rect, 271 277 const QList<QPainterPath> &pathList ) 272 278 { … … 286 292 if ( br.center().y() < rect.center().y() ) 287 293 { 288 if ( qAbs( br.top() - rect.top() ) < 294 if ( qAbs( br.top() - rect.top() ) < 289 295 qAbs( br.left() - rect.left() ) ) 290 296 { … … 298 304 else 299 305 { 300 if ( qAbs( br.bottom() - rect.bottom() ) < 306 if ( qAbs( br.bottom() - rect.bottom() ) < 301 307 qAbs( br.left() - rect.left() ) ) 302 308 { … … 316 322 if ( br.center().y() < rect.center().y() ) 317 323 { 318 if ( qAbs( br.top() - rect.top() ) < 324 if ( qAbs( br.top() - rect.top() ) < 319 325 qAbs( br.right() - rect.right() ) ) 320 326 { … … 328 334 else 329 335 { 330 if ( qAbs( br.bottom() - rect.bottom() ) < 336 if ( qAbs( br.bottom() - rect.bottom() ) < 331 337 qAbs( br.right() - rect.right() ) ) 332 338 { … … 340 346 if ( subPath.currentPosition().y() < br.center().y() ) 341 347 qwtRevertPath( subPath ); 342 } 348 } 343 349 ordered[index] = subPath; 344 350 } … … 381 387 } 382 388 383 static inline void qwtDrawStyledBackground( 389 static inline void qwtDrawStyledBackground( 384 390 QWidget *w, QPainter *painter ) 385 391 { … … 418 424 } 419 425 420 static void qwtFillBackground( QPainter *painter, 426 static void qwtFillBackground( QPainter *painter, 421 427 QWidget *widget, const QVector<QRectF> &fillRects ) 422 428 { … … 521 527 }; 522 528 523 /*! 529 /*! 524 530 \brief Constructor 525 531 … … 595 601 *d_data->backingStore = grab( rect() ); 596 602 #else 597 *d_data->backingStore = 603 *d_data->backingStore = 598 604 QPixmap::grabWidget( this, rect() ); 599 605 #endif … … 695 701 bool QwtPlotCanvas::event( QEvent *event ) 696 702 { 697 if ( event->type() == QEvent::PolishRequest ) 703 if ( event->type() == QEvent::PolishRequest ) 698 704 { 699 705 if ( testPaintAttribute( QwtPlotCanvas::Opaque ) ) 700 706 { 701 // Setting a style sheet changes the 707 // Setting a style sheet changes the 702 708 // Qt::WA_OpaquePaintEvent attribute, but we insist 703 709 // on painting the background. 704 710 705 711 setAttribute( Qt::WA_OpaquePaintEvent, true ); 706 712 } 707 713 } 708 714 709 if ( event->type() == QEvent::PolishRequest || 715 if ( event->type() == QEvent::PolishRequest || 710 716 event->type() == QEvent::StyleChange ) 711 717 { … … 729 735 { 730 736 QPixmap &bs = *d_data->backingStore; 731 if ( bs.size() != size() ) 737 738 qreal pixelRatio = 1.0; 739 740 #if QT_VERSION >= 0x050000 741 pixelRatio = bs.devicePixelRatio(); 742 #endif 743 744 if ( bs.size() != size() * pixelRatio ) 732 745 { 733 746 bs = QwtPainter::backingStore( this, size() ); … … 806 819 drawCanvas( &painter, false ); 807 820 808 if ( frameWidth() > 0 ) 821 if ( frameWidth() > 0 ) 809 822 drawBorder( &painter ); 810 823 } … … 815 828 } 816 829 817 void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground ) 830 void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground ) 818 831 { 819 832 bool hackStyledBackground = false; 820 833 821 if ( withBackground && testAttribute( Qt::WA_StyledBackground ) 834 if ( withBackground && testAttribute( Qt::WA_StyledBackground ) 822 835 && testPaintAttribute( HackStyledBackground ) ) 823 836 { 824 837 // Antialiasing rounded borders is done by 825 // inserting pixels with colors between the 838 // inserting pixels with colors between the 826 839 // border color and the color on the canvas, 827 840 // When the border is painted before the plot items … … 853 866 854 867 painter->setPen( Qt::NoPen ); 855 painter->setBrush( d_data->styleSheet.background.brush ); 868 painter->setBrush( d_data->styleSheet.background.brush ); 856 869 painter->setBrushOrigin( d_data->styleSheet.background.origin ); 857 870 painter->setClipPath( d_data->styleSheet.borderPath ); … … 894 907 if ( !d_data->styleSheet.borderPath.isEmpty() ) 895 908 { 896 painter->setClipPath( 909 painter->setClipPath( 897 910 d_data->styleSheet.borderPath, Qt::IntersectClip ); 898 911 } … … 930 943 if ( frameWidth() > 0 ) 931 944 { 932 QwtPainter::drawRoundedFrame( painter, QRectF( frameRect() ), 945 QwtPainter::drawRoundedFrame( painter, QRectF( frameRect() ), 933 946 d_data->borderRadius, d_data->borderRadius, 934 947 palette(), frameWidth(), frameStyle() ); … … 953 966 #endif 954 967 955 switch (frameShape) 968 switch (frameShape) 956 969 { 957 970 case QFrame::Box: … … 963 976 opt.lineWidth = lineWidth(); 964 977 opt.midLineWidth = midLineWidth(); 965 break; 966 } 967 default: 978 break; 979 } 980 default: 968 981 { 969 982 opt.lineWidth = frameWidth(); … … 971 984 } 972 985 } 973 986 974 987 if ( frameShadow == Sunken ) 975 988 opt.state |= QStyle::State_Sunken; … … 1030 1043 1031 1044 QwtStyleSheetRecorder recorder( size() ); 1032 1045 1033 1046 QPainter painter( &recorder ); 1034 1047 1035 1048 QStyleOption opt; 1036 1049 opt.initFrom(this); 1037 1050 style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this); 1038 1051 1039 1052 painter.end(); 1040 1053 … … 1046 1059 if ( !recorder.border.rectList.isEmpty() ) 1047 1060 { 1048 d_data->styleSheet.borderPath = 1061 d_data->styleSheet.borderPath = 1049 1062 qwtCombinePathList( rect(), recorder.border.pathList ); 1050 1063 } … … 1097 1110 return path; 1098 1111 } 1099 1112 1100 1113 return QPainterPath(); 1101 1114 }
Note:
See TracChangeset
for help on using the changeset viewer.