Changeset 9383 in ntrip for trunk/BNC/qwt/qwt_symbol.cpp
- Timestamp:
- Mar 19, 2021, 9:15:03 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_symbol.cpp
r8127 r9383 32 32 } 33 33 34 static QwtGraphic qwtPathGraphic( const QPainterPath &path, 34 static QwtGraphic qwtPathGraphic( const QPainterPath &path, 35 35 const QPen &pen, const QBrush& brush ) 36 36 { … … 47 47 } 48 48 49 static inline QRectF qwtScaledBoundingRect( 49 static inline QRectF qwtScaledBoundingRect( 50 50 const QwtGraphic &graphic, const QSizeF size ) 51 51 { … … 53 53 if ( scaledSize.isEmpty() ) 54 54 scaledSize = graphic.defaultSize(); 55 55 56 56 const QSizeF sz = graphic.controlPointRect().size(); 57 57 … … 59 59 if ( sz.width() > 0.0 ) 60 60 sx = scaledSize.width() / sz.width(); 61 61 62 62 double sy = 1.0; 63 63 if ( sz.height() > 0.0 ) … … 84 84 if ( pm.size() != size ) 85 85 pm = pm.scaled( size ); 86 86 87 87 QPointF pinPoint( 0.5 * size.width(), 0.5 * size.height() ); 88 88 if ( symbol.isPinPointEnabled() ) … … 95 95 const QPointF pos = transform.map( points[i] ) - pinPoint; 96 96 97 QwtPainter::drawPixmap( painter, 97 QwtPainter::drawPixmap( painter, 98 98 QRect( pos.toPoint(), pm.size() ), pm ); 99 99 } … … 102 102 #ifndef QWT_NO_SVG 103 103 104 static inline void qwtDrawSvgSymbols( QPainter *painter, 105 const QPointF *points, int numPoints, 104 static inline void qwtDrawSvgSymbols( QPainter *painter, 105 const QPointF *points, int numPoints, 106 106 QSvgRenderer *renderer, const QwtSymbol &symbol ) 107 107 { … … 132 132 const double y = points[i].y() - dy; 133 133 134 renderer->render( painter, 134 renderer->render( painter, 135 135 QRectF( x, y, sz.width(), sz.height() ) ); 136 136 } … … 139 139 #endif 140 140 141 static inline void qwtDrawGraphicSymbols( QPainter *painter, 141 static inline void qwtDrawGraphicSymbols( QPainter *painter, 142 142 const QPointF *points, int numPoints, const QwtGraphic &graphic, 143 143 const QwtSymbol &symbol ) … … 876 876 */ 877 877 878 QwtSymbol::QwtSymbol( const QPainterPath &path, 878 QwtSymbol::QwtSymbol( const QPainterPath &path, 879 879 const QBrush &brush, const QPen &pen ) 880 880 { … … 919 919 \brief Set a painter path as symbol 920 920 921 The symbol is represented by a painter path, where the 921 The symbol is represented by a painter path, where the 922 922 origin ( 0, 0 ) of the path coordinate system is mapped to 923 923 the position of the symbol. … … 927 927 the bounding rectangle of the path. 928 928 929 The following code defines a symbol drawing an arrow: 930 931 \verbatim 932 #include <qwt_symbol.h> 933 934 QwtSymbol *symbol = new QwtSymbol(); 935 936 QPen pen( Qt::black, 2 ); 937 pen.setJoinStyle( Qt::MiterJoin ); 938 939 symbol->setPen( pen ); 940 symbol->setBrush( Qt::red ); 941 942 QPainterPath path; 943 path.moveTo( 0, 8 ); 944 path.lineTo( 0, 5 ); 945 path.lineTo( -3, 5 ); 946 path.lineTo( 0, 0 ); 947 path.lineTo( 3, 5 ); 948 path.lineTo( 0, 5 ); 949 950 QTransform transform; 951 transform.rotate( -30.0 ); 952 path = transform.map( path ); 953 954 symbol->setPath( path ); 955 symbol->setPinPoint( QPointF( 0.0, 0.0 ) ); 956 957 setSize( 10, 14 ); 958 \endverbatim 929 \par Example 930 The following code defines a symbol drawing an arrow: 931 932 \code 933 #include <qwt_symbol.h> 934 935 QwtSymbol *symbol = new QwtSymbol(); 936 937 QPen pen( Qt::black, 2 ); 938 pen.setJoinStyle( Qt::MiterJoin ); 939 940 symbol->setPen( pen ); 941 symbol->setBrush( Qt::red ); 942 943 QPainterPath path; 944 path.moveTo( 0, 8 ); 945 path.lineTo( 0, 5 ); 946 path.lineTo( -3, 5 ); 947 path.lineTo( 0, 0 ); 948 path.lineTo( 3, 5 ); 949 path.lineTo( 0, 5 ); 950 951 QTransform transform; 952 transform.rotate( -30.0 ); 953 path = transform.map( path ); 954 955 symbol->setPath( path ); 956 symbol->setPinPoint( QPointF( 0.0, 0.0 ) ); 957 958 setSize( 10, 14 ); 959 \endcode 960 \endpar 959 961 960 962 \param path Painter path … … 1237 1239 The position of a complex symbol is not always aligned to its center 1238 1240 ( f.e an arrow, where the peak points to a position ). The pin point 1239 defines the position inside of a Pixmap, Graphic, SvgDocument 1241 defines the position inside of a Pixmap, Graphic, SvgDocument 1240 1242 or PainterPath symbol where the represented point has to 1241 1243 be aligned to. 1242 1244 1243 1245 \param pos Position 1244 1246 \param enable En/Disable the pin point alignment … … 1341 1343 { 1342 1344 if ( !d_data->size.isEmpty() && 1343 d_data->size != d_data->pixmap.pixmap.size() ) 1345 d_data->size != d_data->pixmap.pixmap.size() ) 1344 1346 { 1345 1347 useCache = true; 1346 1348 } 1347 1349 break; 1348 } 1350 } 1349 1351 default: 1350 1352 useCache = true; … … 1358 1360 const QRect br = boundingRect(); 1359 1361 1360 const QRect rect( 0, 0, br.width(), br.height() );1361 1362 1362 if ( d_data->cache.pixmap.isNull() ) 1363 1363 { … … 1402 1402 1403 1403 \param painter Painter 1404 \param rect Target rectangle for the symbol 1404 \param rect Target rectangle for the symbol 1405 1405 */ 1406 1406 void QwtSymbol::drawSymbol( QPainter *painter, const QRectF &rect ) const … … 1411 1411 if ( d_data->style == QwtSymbol::Graphic ) 1412 1412 { 1413 d_data->graphic.graphic.render( 1413 d_data->graphic.graphic.render( 1414 1414 painter, rect, Qt::KeepAspectRatio ); 1415 1415 } … … 1418 1418 if ( d_data->path.graphic.isNull() ) 1419 1419 { 1420 d_data->path.graphic = qwtPathGraphic( 1420 d_data->path.graphic = qwtPathGraphic( 1421 1421 d_data->path.path, d_data->pen, d_data->brush ); 1422 1422 } 1423 1423 1424 d_data->path.graphic.render( 1424 d_data->path.graphic.render( 1425 1425 painter, rect, Qt::KeepAspectRatio ); 1426 1426 return; … … 1445 1445 } 1446 1446 1447 d_data->svg.renderer->render( 1447 d_data->svg.renderer->render( 1448 1448 painter, scaledRect ); 1449 1449 } … … 1456 1456 // scale the symbol size to fit into rect. 1457 1457 1458 const double ratio = qMin( rect.width() / br.width(), 1458 const double ratio = qMin( rect.width() / br.width(), 1459 1459 rect.height() / br.height() ); 1460 1460 … … 1469 1469 const QPointF pos; 1470 1470 renderSymbols( painter, &pos, 1 ); 1471 1471 1472 1472 d_data->isPinPointEnabled = isPinPointEnabled; 1473 1473 … … 1570 1570 if ( d_data->path.graphic.isNull() ) 1571 1571 { 1572 d_data->path.graphic = qwtPathGraphic( d_data->path.path, 1572 d_data->path.graphic = qwtPathGraphic( d_data->path.path, 1573 1573 d_data->pen, d_data->brush ); 1574 1574 } 1575 1575 1576 qwtDrawGraphicSymbols( painter, points, numPoints, 1576 qwtDrawGraphicSymbols( painter, points, numPoints, 1577 1577 d_data->path.graphic, *this ); 1578 1578 break; … … 1585 1585 case QwtSymbol::Graphic: 1586 1586 { 1587 qwtDrawGraphicSymbols( painter, points, numPoints, 1587 qwtDrawGraphicSymbols( painter, points, numPoints, 1588 1588 d_data->graphic.graphic, *this ); 1589 1589 break; … … 1592 1592 { 1593 1593 #ifndef QWT_NO_SVG 1594 qwtDrawSvgSymbols( painter, points, numPoints, 1594 qwtDrawSvgSymbols( painter, points, numPoints, 1595 1595 d_data->svg.renderer, *this ); 1596 1596 #endif … … 1654 1654 } 1655 1655 1656 rect = qwtScaledBoundingRect( 1656 rect = qwtScaledBoundingRect( 1657 1657 d_data->path.graphic, d_data->size ); 1658 1658 pinPointTranslation = true; … … 1666 1666 else 1667 1667 rect.setSize( d_data->size ); 1668 1668 1669 1669 pinPointTranslation = true; 1670 1670 … … 1673 1673 case QwtSymbol::Graphic: 1674 1674 { 1675 rect = qwtScaledBoundingRect( 1675 rect = qwtScaledBoundingRect( 1676 1676 d_data->graphic.graphic, d_data->size ); 1677 1677 pinPointTranslation = true;
Note:
See TracChangeset
for help on using the changeset viewer.