Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_plot_scaleitem.cpp
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_scaleitem.cpp
r4271 r8127 10 10 #include "qwt_plot_scaleitem.h" 11 11 #include "qwt_plot.h" 12 #include "qwt_plot_canvas.h"13 12 #include "qwt_scale_map.h" 14 13 #include "qwt_interval.h" … … 32 31 } 33 32 34 void updateBorders( const QRectF &,35 const QwtScaleMap &, const QwtScaleMap & ) ;33 QwtInterval scaleInterval( const QRectF &, 34 const QwtScaleMap &, const QwtScaleMap & ) const; 36 35 37 36 QPalette palette; … … 41 40 bool scaleDivFromAxis; 42 41 QwtScaleDraw *scaleDraw; 43 QRectF canvasRectCache;44 42 }; 45 43 46 void QwtPlotScaleItem::PrivateData::updateBorders( const QRectF &canvasRect, 47 const QwtScaleMap &xMap, const QwtScaleMap &yMap ) 48 { 49 canvasRectCache = canvasRect; 50 44 QwtInterval QwtPlotScaleItem::PrivateData::scaleInterval( const QRectF &canvasRect, 45 const QwtScaleMap &xMap, const QwtScaleMap &yMap ) const 46 { 51 47 QwtInterval interval; 52 48 if ( scaleDraw->orientation() == Qt::Horizontal ) … … 61 57 } 62 58 63 QwtScaleDiv scaleDiv = scaleDraw->scaleDiv(); 64 scaleDiv.setInterval( interval ); 65 scaleDraw->setScaleDiv( scaleDiv ); 66 } 59 return interval; 60 } 61 67 62 /*! 68 63 \brief Constructor for scale item at the position pos. … … 84 79 d_data->scaleDraw->setAlignment( alignment ); 85 80 81 setItemInterest( QwtPlotItem::ScaleInterest, true ); 86 82 setZ( 11.0 ); 87 83 } … … 137 133 if ( plt ) 138 134 { 139 updateScaleDiv( *plt->axisScaleDiv( xAxis() ),140 *plt->axisScaleDiv( yAxis() ) );135 updateScaleDiv( plt->axisScaleDiv( xAxis() ), 136 plt->axisScaleDiv( yAxis() ) ); 141 137 itemChanged(); 142 138 } … … 164 160 { 165 161 d_data->palette = palette; 162 163 legendChanged(); 166 164 itemChanged(); 167 165 } … … 223 221 if ( plt ) 224 222 { 225 updateScaleDiv( *plt->axisScaleDiv( xAxis() ),226 *plt->axisScaleDiv( yAxis() ) );223 updateScaleDiv( plt->axisScaleDiv( xAxis() ), 224 plt->axisScaleDiv( yAxis() ) ); 227 225 } 228 226 … … 282 280 283 281 If distance is >= 0 the scale will be aligned to a 284 border of the contents rect of the canvas. If282 border of the contents rectangle of the canvas. If 285 283 alignment() is QwtScaleDraw::LeftScale, the scale will 286 284 be aligned to the right border, if it is QwtScaleDraw::TopScale … … 348 346 const QRectF &canvasRect ) const 349 347 { 348 QwtScaleDraw *sd = d_data->scaleDraw; 349 350 350 if ( d_data->scaleDivFromAxis ) 351 351 { 352 if ( canvasRect != d_data->canvasRectCache ) 353 d_data->updateBorders( canvasRect, xMap, yMap ); 352 const QwtInterval interval = 353 d_data->scaleInterval( canvasRect, xMap, yMap ); 354 355 if ( interval != sd->scaleDiv().interval() ) 356 { 357 QwtScaleDiv scaleDiv = sd->scaleDiv(); 358 scaleDiv.setInterval( interval ); 359 sd->setScaleDiv( scaleDiv ); 360 } 354 361 } 355 362 … … 358 365 painter->setPen( pen ); 359 366 360 QwtScaleDraw *sd = d_data->scaleDraw;361 367 if ( sd->orientation() == Qt::Horizontal ) 362 368 { … … 382 388 sd->move( canvasRect.left(), y ); 383 389 sd->setLength( canvasRect.width() - 1 ); 384 sd->setTransformation( xMap.transformation()->copy() ); 390 391 QwtTransform *transform = NULL; 392 if ( xMap.transformation() ) 393 transform = xMap.transformation()->copy(); 394 395 sd->setTransformation( transform ); 385 396 } 386 397 else // == Qt::Vertical … … 405 416 sd->move( x, canvasRect.top() ); 406 417 sd->setLength( canvasRect.height() - 1 ); 407 sd->setTransformation( yMap.transformation()->copy() ); 418 419 QwtTransform *transform = NULL; 420 if ( yMap.transformation() ) 421 transform = yMap.transformation()->copy(); 422 423 sd->setTransformation( transform ); 408 424 } 409 425 … … 428 444 const QwtScaleDiv& yScaleDiv ) 429 445 { 430 QwtScaleDraw *sd = d_data->scaleDraw; 431 if ( d_data->scaleDivFromAxis && sd ) 432 { 433 sd->setScaleDiv( 434 sd->orientation() == Qt::Horizontal ? xScaleDiv : yScaleDiv ); 446 QwtScaleDraw *scaleDraw = d_data->scaleDraw; 447 448 if ( d_data->scaleDivFromAxis && scaleDraw ) 449 { 450 const QwtScaleDiv &scaleDiv = 451 scaleDraw->orientation() == Qt::Horizontal ? xScaleDiv : yScaleDiv; 435 452 436 453 const QwtPlot *plt = plot(); 437 454 if ( plt != NULL ) 438 455 { 439 d_data->updateBorders( plt->canvas()->contentsRect(), 440 plt->canvasMap( xAxis() ), plt->canvasMap( yAxis() ) ); 441 } 442 } 443 } 456 const QRectF canvasRect = plt->canvas()->contentsRect(); 457 458 const QwtInterval interval = d_data->scaleInterval( 459 canvasRect, plt->canvasMap( xAxis() ), plt->canvasMap( yAxis() ) ); 460 461 QwtScaleDiv sd = scaleDiv; 462 sd.setInterval( interval ); 463 464 if ( sd != scaleDraw->scaleDiv() ) 465 { 466 // the internal label cache of QwtScaleDraw 467 // is cleared here, so better avoid pointless 468 // assignments. 469 470 scaleDraw->setScaleDiv( sd ); 471 } 472 } 473 else 474 { 475 scaleDraw->setScaleDiv( scaleDiv ); 476 } 477 } 478 }
Note:
See TracChangeset
for help on using the changeset viewer.