Changeset 9383 in ntrip for trunk/BNC/qwt/qwt_painter.cpp
- Timestamp:
- Mar 19, 2021, 9:15:03 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_painter.cpp
r8127 r9383 20 20 #include <qpalette.h> 21 21 #include <qpaintdevice.h> 22 #include <qpainterpath.h> 22 23 #include <qpixmap.h> 23 24 #include <qstyle.h> … … 33 34 #endif 34 35 35 #if QT_VERSION < 0x050000 36 #if QT_VERSION < 0x050000 36 37 37 38 #ifdef Q_WS_X11 … … 44 45 bool QwtPainter::d_roundingAlignment = true; 45 46 46 static inline bool qwtIsClippingNeeded( 47 static inline bool qwtIsClippingNeeded( 47 48 const QPainter *painter, QRectF &clipRect ) 48 49 { … … 142 143 bool QwtPainter::isX11GraphicsSystem() 143 144 { 145 /* 146 The X11 paint engine has been removed with Qt 5.0, but 147 reintroduced with Qt 5.10. It can be enabled with 148 "export QT_XCB_NATIVE_PAINTING=1". 149 */ 150 144 151 static int onX11 = -1; 145 152 if ( onX11 < 0 ) … … 181 188 } 182 189 183 const QTransform tr = painter->transform();190 const QTransform &tr = painter->transform(); 184 191 if ( tr.isRotating() || tr.isScaling() ) 185 192 { … … 196 203 to a paint engine that floors to integer values. For other paint engines 197 204 ( PDF, SVG ) this flag has no effect. 198 QwtPainter stores this flag only, the rounding itself is done in 205 QwtPainter stores this flag only, the rounding itself is done in 199 206 the painting code ( f.e the plot items ). 200 207 201 The default setting is true. 208 The default setting is true. 202 209 203 210 \sa roundingAlignment(), isAligning() … … 214 221 much faster when they are split in smaller chunks: f.e all supported Qt versions 215 222 >= Qt 5.0 when drawing an antialiased polyline with a pen width >=2. 223 224 Also the raster paint engine has a nasty bug in many versions ( Qt 4.8 - ... ) 225 for short lines ( https://codereview.qt-project.org/#/c/99456 ), that is worked 226 around in this mode. 216 227 217 228 The default setting is true. … … 397 408 unscaledRect = transform.inverted().mapRect(rect); 398 409 } 399 } 410 } 400 411 401 412 txt->setDefaultFont( painter->font() ); … … 452 463 QPolygonF cpa = polygon; 453 464 if ( deviceClipping ) 454 cpa = QwtClipper::clipPolygonF( clipRect, polygon );465 cpa = QwtClipper::clipPolygonF( clipRect, polygon, true ); 455 466 456 467 painter->drawPolygon( cpa ); … … 501 512 QPolygon cpa = polygon; 502 513 if ( deviceClipping ) 503 cpa = QwtClipper::clipPolygon( clipRect, polygon );514 cpa = QwtClipper::clipPolygon( clipRect, polygon, true ); 504 515 505 516 painter->drawPolygon( cpa ); … … 537 548 } 538 549 else 550 { 539 551 qwtDrawPolyline<QPoint>( painter, points, pointCount, d_polylineSplitting ); 552 } 540 553 } 541 554 … … 565 578 const int maxY = qFloor( clipRect.bottom() ); 566 579 567 if ( pos.x() < minX || pos.x() > maxX 580 if ( pos.x() < minX || pos.x() > maxX 568 581 || pos.y() < minY || pos.y() > maxY ) 569 582 { … … 576 589 577 590 //! Wrapper for QPainter::drawPoints() 578 void QwtPainter::drawPoints( QPainter *painter, 591 void QwtPainter::drawPoints( QPainter *painter, 579 592 const QPoint *points, int pointCount ) 580 593 { … … 609 622 610 623 //! Wrapper for QPainter::drawPoints() 611 void QwtPainter::drawPoints( QPainter *painter, 624 void QwtPainter::drawPoints( QPainter *painter, 612 625 const QPointF *points, int pointCount ) 613 626 { … … 697 710 698 711 /*! 699 Draw a round frame 712 Draw a round frame 700 713 701 714 \param painter Painter … … 708 721 */ 709 722 void QwtPainter::drawRoundFrame( QPainter *painter, 710 const QRectF &rect, const QPalette &palette, 723 const QRectF &rect, const QPalette &palette, 711 724 int lineWidth, int frameStyle ) 712 725 { … … 787 800 { 788 801 const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); 789 const QRectF innerRect = outerRect.adjusted( 802 const QRectF innerRect = outerRect.adjusted( 790 803 frameWidth, frameWidth, -frameWidth, -frameWidth ); 791 804 … … 806 819 { 807 820 const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); 808 const QRectF midRect1 = outerRect.adjusted( 821 const QRectF midRect1 = outerRect.adjusted( 809 822 frameWidth, frameWidth, -frameWidth, -frameWidth ); 810 const QRectF midRect2 = midRect1.adjusted( 823 const QRectF midRect2 = midRect1.adjusted( 811 824 midLineWidth, midLineWidth, -midLineWidth, -midLineWidth ); 812 825 813 const QRectF innerRect = midRect2.adjusted( 826 const QRectF innerRect = midRect2.adjusted( 814 827 frameWidth, frameWidth, -frameWidth, -frameWidth ); 815 828 … … 887 900 { 888 901 const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 ); 889 const QRectF innerRect = outerRect.adjusted( 890 frameWidth - 1.0, frameWidth - 1.0, 902 const QRectF innerRect = outerRect.adjusted( 903 frameWidth - 1.0, frameWidth - 1.0, 891 904 -( frameWidth - 1.0 ), -( frameWidth - 1.0 ) ); 892 905 … … 942 955 */ 943 956 944 void QwtPainter::drawRoundedFrame( QPainter *painter, 945 const QRectF &rect, double xRadius, double yRadius, 957 void QwtPainter::drawRoundedFrame( QPainter *painter, 958 const QRectF &rect, double xRadius, double yRadius, 946 959 const QPalette &palette, int lineWidth, int frameStyle ) 947 960 { … … 951 964 952 965 double lw2 = lineWidth * 0.5; 953 QRectF r= rect.adjusted( lw2, lw2, -lw2, -lw2 );966 QRectF innerRect = rect.adjusted( lw2, lw2, -lw2, -lw2 ); 954 967 955 968 QPainterPath path; 956 path.addRoundedRect( r, xRadius, yRadius );969 path.addRoundedRect( innerRect, xRadius, yRadius ); 957 970 958 971 enum Style … … 973 986 // move + 4 * ( cubicTo + lineTo ) 974 987 QPainterPath pathList[8]; 975 988 976 989 for ( int i = 0; i < 4; i++ ) 977 990 { 978 991 const int j = i * 4 + 1; 979 992 980 993 pathList[ 2 * i ].moveTo( 981 994 path.elementAt(j - 1).x, path.elementAt( j - 1 ).y 982 ); 983 995 ); 996 984 997 pathList[ 2 * i ].cubicTo( 985 998 path.elementAt(j + 0).x, path.elementAt(j + 0).y, 986 999 path.elementAt(j + 1).x, path.elementAt(j + 1).y, 987 1000 path.elementAt(j + 2).x, path.elementAt(j + 2).y ); 988 1001 989 1002 pathList[ 2 * i + 1 ].moveTo( 990 1003 path.elementAt(j + 2).x, path.elementAt(j + 2).y 991 ); 1004 ); 992 1005 pathList[ 2 * i + 1 ].lineTo( 993 1006 path.elementAt(j + 3).x, path.elementAt(j + 3).y 994 ); 995 } 1007 ); 1008 } 996 1009 997 1010 QColor c1( palette.color( QPalette::Dark ) ); … … 1003 1016 for ( int i = 0; i < 4; i++ ) 1004 1017 { 1005 QRectF r = pathList[2 * i].controlPointRect();1018 const QRectF r = pathList[2 * i].controlPointRect(); 1006 1019 1007 1020 QPen arcPen; … … 1147 1160 } 1148 1161 1149 static inline void qwtFillRect( const QWidget *widget, QPainter *painter, 1162 static inline void qwtFillRect( const QWidget *widget, QPainter *painter, 1150 1163 const QRect &rect, const QBrush &brush) 1151 1164 { 1152 if ( brush.style() == Qt::TexturePattern ) 1165 if ( brush.style() == Qt::TexturePattern ) 1153 1166 { 1154 1167 painter->save(); … … 1158 1171 1159 1172 painter->restore(); 1160 } 1173 } 1161 1174 else if ( brush.gradient() ) 1162 1175 { … … 1164 1177 1165 1178 painter->setClipRect( rect ); 1166 painter->fillRect(0, 0, widget->width(), 1179 painter->fillRect(0, 0, widget->width(), 1167 1180 widget->height(), brush); 1168 1181 1169 1182 painter->restore(); 1170 } 1171 else 1183 } 1184 else 1172 1185 { 1173 1186 painter->fillRect(rect, brush); … … 1179 1192 1180 1193 In Qt >= 5.0 QPixmap::fill() is a nop, in Qt 4.x it is buggy 1181 for backgrounds with gradients. Thus fillPixmap() offers 1194 for backgrounds with gradients. Thus fillPixmap() offers 1182 1195 an alternative implementation. 1183 1196 1184 1197 \param widget Widget 1185 1198 \param pixmap Pixmap to be filled 1186 \param offset Offset 1199 \param offset Offset 1187 1200 1188 1201 \sa QPixmap::fill() 1189 1202 */ 1190 void QwtPainter::fillPixmap( const QWidget *widget, 1203 void QwtPainter::fillPixmap( const QWidget *widget, 1191 1204 QPixmap &pixmap, const QPoint &offset ) 1192 1205 { … … 1196 1209 painter.translate( -offset ); 1197 1210 1198 const QBrush autoFillBrush = 1211 const QBrush autoFillBrush = 1199 1212 widget->palette().brush( widget->backgroundRole() ); 1200 1213 1201 if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) ) 1214 if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) ) 1202 1215 { 1203 1216 const QBrush bg = widget->palette().brush( QPalette::Window ); … … 1208 1221 qwtFillRect( widget, &painter, rect, autoFillBrush); 1209 1222 1210 if ( widget->testAttribute(Qt::WA_StyledBackground) ) 1223 if ( widget->testAttribute(Qt::WA_StyledBackground) ) 1211 1224 { 1212 1225 painter.setClipRegion( rect ); … … 1214 1227 QStyleOption opt; 1215 1228 opt.initFrom( widget ); 1216 widget->style()->drawPrimitive( QStyle::PE_Widget, 1229 widget->style()->drawPrimitive( QStyle::PE_Widget, 1217 1230 &opt, &painter, widget ); 1218 1231 } … … 1285 1298 #endif 1286 1299 1287 #if QT_VERSION < 0x050000 1300 #if QT_VERSION < 0x050000 1288 1301 #ifdef Q_WS_X11 1289 1302 if ( widget && isX11GraphicsSystem() )
Note:
See TracChangeset
for help on using the changeset viewer.