Changeset 9383 in ntrip for trunk/BNC/qwt/qwt_graphic.cpp
- Timestamp:
- Mar 19, 2021, 9:15:03 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_graphic.cpp
r8127 r9383 38 38 } 39 39 40 static QRectF qwtStrokedPathRect( 40 static QRectF qwtStrokedPathRect( 41 41 const QPainter *painter, const QPainterPath &path ) 42 42 { … … 64 64 } 65 65 66 static inline void qwtExecCommand( 67 QPainter *painter, const QwtPainterCommand &cmd, 66 static inline void qwtExecCommand( 67 QPainter *painter, const QwtPainterCommand &cmd, 68 68 QwtGraphic::RenderHints renderHints, 69 69 const QTransform &transform, … … 122 122 { 123 123 const QwtPainterCommand::ImageData *data = cmd.imageData(); 124 painter->drawImage( data->rect, data->image, 124 painter->drawImage( data->rect, data->image, 125 125 data->subRect, data->flags ); 126 126 break; … … 130 130 const QwtPainterCommand::StateData *data = cmd.stateData(); 131 131 132 if ( data->flags & QPaintEngine::DirtyPen ) 132 if ( data->flags & QPaintEngine::DirtyPen ) 133 133 painter->setPen( data->pen ); 134 134 135 if ( data->flags & QPaintEngine::DirtyBrush ) 135 if ( data->flags & QPaintEngine::DirtyBrush ) 136 136 painter->setBrush( data->brush ); 137 137 138 if ( data->flags & QPaintEngine::DirtyBrushOrigin ) 138 if ( data->flags & QPaintEngine::DirtyBrushOrigin ) 139 139 painter->setBrushOrigin( data->brushOrigin ); 140 140 141 if ( data->flags & QPaintEngine::DirtyFont ) 141 if ( data->flags & QPaintEngine::DirtyFont ) 142 142 painter->setFont( data->font ); 143 143 144 if ( data->flags & QPaintEngine::DirtyBackground ) 144 if ( data->flags & QPaintEngine::DirtyBackground ) 145 145 { 146 146 painter->setBackgroundMode( data->backgroundMode ); … … 148 148 } 149 149 150 if ( data->flags & QPaintEngine::DirtyTransform ) 150 if ( data->flags & QPaintEngine::DirtyTransform ) 151 151 { 152 152 painter->setTransform( data->transform * transform ); 153 153 } 154 154 155 if ( data->flags & QPaintEngine::DirtyClipEnabled ) 155 if ( data->flags & QPaintEngine::DirtyClipEnabled ) 156 156 painter->setClipping( data->isClipEnabled ); 157 157 158 if ( data->flags & QPaintEngine::DirtyClipRegion) 158 if ( data->flags & QPaintEngine::DirtyClipRegion) 159 159 { 160 painter->setClipRegion( data->clipRegion, 160 painter->setClipRegion( data->clipRegion, 161 161 data->clipOperation ); 162 162 } 163 163 164 if ( data->flags & QPaintEngine::DirtyClipPath ) 164 if ( data->flags & QPaintEngine::DirtyClipPath ) 165 165 { 166 166 painter->setClipPath( data->clipPath, data->clipOperation ); 167 167 } 168 168 169 if ( data->flags & QPaintEngine::DirtyHints) 169 if ( data->flags & QPaintEngine::DirtyHints) 170 170 { 171 171 const QPainter::RenderHints hints = data->renderHints; … … 187 187 } 188 188 189 if ( data->flags & QPaintEngine::DirtyCompositionMode) 189 if ( data->flags & QPaintEngine::DirtyCompositionMode) 190 190 painter->setCompositionMode( data->compositionMode ); 191 191 192 if ( data->flags & QPaintEngine::DirtyOpacity) 192 if ( data->flags & QPaintEngine::DirtyOpacity) 193 193 painter->setOpacity( data->opacity ); 194 194 … … 210 210 } 211 211 212 PathInfo( const QRectF &pointRect, 212 PathInfo( const QRectF &pointRect, 213 213 const QRectF &boundingRect, bool scalablePen ): 214 214 d_pointRect( pointRect ), … … 247 247 } 248 248 249 inline double scaleFactorX( const QRectF& pathRect, 249 inline double scaleFactorX( const QRectF& pathRect, 250 250 const QRectF &targetRect, bool scalePens ) const 251 251 { … … 258 258 const double r = qAbs( pathRect.right() - p0.x() ); 259 259 260 const double w = 2.0 * qMin( l, r ) 260 const double w = 2.0 * qMin( l, r ) 261 261 * targetRect.width() / pathRect.width(); 262 262 … … 268 268 else 269 269 { 270 const double pw = qMax( 270 const double pw = qMax( 271 271 qAbs( d_boundingRect.left() - d_pointRect.left() ), 272 272 qAbs( d_boundingRect.right() - d_pointRect.right() ) ); … … 278 278 } 279 279 280 inline double scaleFactorY( const QRectF& pathRect, 280 inline double scaleFactorY( const QRectF& pathRect, 281 281 const QRectF &targetRect, bool scalePens ) const 282 282 { … … 289 289 const double b = qAbs( pathRect.bottom() - p0.y() ); 290 290 291 const double h = 2.0 * qMin( t, b ) 291 const double h = 2.0 * qMin( t, b ) 292 292 * targetRect.height() / pathRect.height(); 293 293 … … 299 299 else 300 300 { 301 const double pw = 301 const double pw = 302 302 qMax( qAbs( d_boundingRect.top() - d_pointRect.top() ), 303 303 qAbs( d_boundingRect.bottom() - d_pointRect.bottom() ) ); … … 352 352 \brief Copy constructor 353 353 354 \param other Source 354 \param other Source 355 355 \sa operator=() 356 356 */ … … 371 371 \brief Assignment operator 372 372 373 \param other Source 373 \param other Source 374 374 \return A reference of this object 375 375 */ … … 383 383 384 384 /*! 385 \brief Clear all stored commands 385 \brief Clear all stored commands 386 386 \sa isNull() 387 387 */ 388 void QwtGraphic::reset() 388 void QwtGraphic::reset() 389 389 { 390 390 d_data->commands.clear(); … … 460 460 461 461 /*! 462 The control point rectangle is the bounding rectangle 462 The control point rectangle is the bounding rectangle 463 463 of all control points of the paths and the target 464 464 rectangles of the images/pixmaps. … … 478 478 \brief Calculate the target rectangle for scaling the graphic 479 479 480 \param sx Horizontal scaling factor 481 \param sy Vertical scaling factor 482 483 \note In case of paths that are painted with a cosmetic pen 480 \param sx Horizontal scaling factor 481 \param sy Vertical scaling factor 482 483 \note In case of paths that are painted with a cosmetic pen 484 484 ( see QPen::isCosmetic() ) the target rectangle is different to 485 485 multiplying the bounding rectangle. … … 500 500 for ( int i = 0; i < d_data->pathInfos.size(); i++ ) 501 501 { 502 rect |= d_data->pathInfos[i].scaledBoundingRect( sx, sy, 502 rect |= d_data->pathInfos[i].scaledBoundingRect( sx, sy, 503 503 !d_data->renderHints.testFlag( RenderPensUnscaled ) ); 504 504 } … … 519 519 The default size is used in all methods rendering the graphic, 520 520 where no size is explicitly specified. Assigning an empty size 521 means, that the default size will be calculated from the bounding 521 means, that the default size will be calculated from the bounding 522 522 rectangle. 523 523 524 524 The default setting is an empty size. 525 525 526 526 \param size Default size 527 527 … … 544 544 545 545 The default size is used in all methods rendering the graphic, 546 where no size is explicitly specified. 546 where no size is explicitly specified. 547 547 548 548 \return Default size … … 575 575 for ( int i = 0; i < numCommands; i++ ) 576 576 { 577 qwtExecCommand( painter, commands[i], 577 qwtExecCommand( painter, commands[i], 578 578 d_data->renderHints, transform, d_data->initialTransform ); 579 579 } … … 592 592 \param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode 593 593 */ 594 void QwtGraphic::render( QPainter *painter, const QSizeF &size, 594 void QwtGraphic::render( QPainter *painter, const QSizeF &size, 595 595 Qt::AspectRatioMode aspectRatioMode ) const 596 596 { … … 608 608 \param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode 609 609 */ 610 void QwtGraphic::render( QPainter *painter, const QRectF &rect, 610 void QwtGraphic::render( QPainter *painter, const QRectF &rect, 611 611 Qt::AspectRatioMode aspectRatioMode ) const 612 612 { … … 614 614 return; 615 615 616 double sx = 1.0; 616 double sx = 1.0; 617 617 double sy = 1.0; 618 618 … … 623 623 sy = rect.height() / d_data->pointRect.height(); 624 624 625 const bool scalePens = 625 const bool scalePens = 626 626 !d_data->renderHints.testFlag( RenderPensUnscaled ); 627 627 … … 630 630 const PathInfo info = d_data->pathInfos[i]; 631 631 632 const double ssx = info.scaleFactorX( 632 const double ssx = info.scaleFactorX( 633 633 d_data->pointRect, rect, scalePens ); 634 634 … … 636 636 sx = qMin( sx, ssx ); 637 637 638 const double ssy = info.scaleFactorY( 638 const double ssy = info.scaleFactorY( 639 639 d_data->pointRect, rect, scalePens ); 640 640 … … 666 666 { 667 667 // we don't want to scale pens according to sx/sy, 668 // but we want to apply the scaling from the 668 // but we want to apply the scaling from the 669 669 // painter transformation later 670 670 … … 690 690 \param painter Qt painter 691 691 \param pos Reference point, where to render 692 \param alignment Flags how to align the target rectangle 692 \param alignment Flags how to align the target rectangle 693 693 to pos. 694 694 */ 695 void QwtGraphic::render( QPainter *painter, 695 void QwtGraphic::render( QPainter *painter, 696 696 const QPointF &pos, Qt::Alignment alignment ) const 697 697 { … … 729 729 /*! 730 730 \brief Convert the graphic to a QPixmap 731 731 732 732 All pixels of the pixmap get initialized by Qt::transparent 733 733 before the graphic is scaled and rendered on it. 734 734 735 735 The size of the pixmap is the default size ( ceiled to integers ) 736 736 of the graphic. … … 738 738 \return The graphic as pixmap in default size 739 739 \sa defaultSize(), toImage(), render() 740 */ 740 */ 741 741 QPixmap QwtGraphic::toPixmap() const 742 742 { … … 819 819 /*! 820 820 \brief Convert the graphic to a QImage 821 821 822 822 All pixels of the image get initialized by 0 ( transparent ) 823 823 before the graphic is scaled and rendered on it. … … 827 827 The size of the image is the default size ( ceiled to integers ) 828 828 of the graphic. 829 829 830 830 \return The graphic as image in default size 831 831 \sa defaultSize(), toPixmap(), render() … … 874 874 QRectF boundingRect = pointRect; 875 875 876 if ( painter->pen().style() != Qt::NoPen 876 if ( painter->pen().style() != Qt::NoPen 877 877 && painter->pen().brush().style() != Qt::NoBrush ) 878 878 { … … 883 883 updateBoundingRect( boundingRect ); 884 884 885 d_data->pathInfos += PathInfo( pointRect, 885 d_data->pathInfos += PathInfo( pointRect, 886 886 boundingRect, qwtHasScalablePen( painter ) ); 887 887 } … … 897 897 \sa QPaintEngine::drawPixmap() 898 898 */ 899 void QwtGraphic::drawPixmap( const QRectF &rect, 899 void QwtGraphic::drawPixmap( const QRectF &rect, 900 900 const QPixmap &pixmap, const QRectF &subRect ) 901 901 { … … 997 997 return; 998 998 999 // to calculate a proper bounding rectangle we don't simply copy 1000 // the commands. 999 // to calculate a proper bounding rectangle we don't simply copy 1000 // the commands. 1001 1001 1002 1002 const QwtPainterCommand *cmds = commands.constData();
Note:
See TracChangeset
for help on using the changeset viewer.