Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_plot_histogram.cpp
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_histogram.cpp
r4271 r8127 10 10 #include "qwt_plot_histogram.h" 11 11 #include "qwt_plot.h" 12 #include "qwt_legend.h"13 #include "qwt_legend_item.h"14 12 #include "qwt_painter.h" 15 13 #include "qwt_column_symbol.h" … … 18 16 #include <qpainter.h> 19 17 20 static inline bool isCombinable( const QwtInterval &d1,18 static inline bool qwtIsCombinable( const QwtInterval &d1, 21 19 const QwtInterval &d2 ) 22 20 { … … 63 61 \param title Title of the histogram. 64 62 */ 65 66 63 QwtPlotHistogram::QwtPlotHistogram( const QwtText &title ): 67 QwtPlotSeriesItem <QwtIntervalSample>( title )64 QwtPlotSeriesItem( title ) 68 65 { 69 66 init(); … … 75 72 */ 76 73 QwtPlotHistogram::QwtPlotHistogram( const QString &title ): 77 QwtPlotSeriesItem <QwtIntervalSample>( title )74 QwtPlotSeriesItem( title ) 78 75 { 79 76 init(); … … 90 87 { 91 88 d_data = new PrivateData(); 92 d_series = new QwtIntervalSeriesData();89 setData( new QwtIntervalSeriesData() ); 93 90 94 91 setItemAttribute( QwtPlotItem::AutoScale, true ); … … 109 106 { 110 107 d_data->style = style; 108 109 legendChanged(); 111 110 itemChanged(); 112 111 } … … 114 113 115 114 /*! 116 Return the current style115 \return Style of the histogram 117 116 \sa HistogramStyle, setStyle() 118 117 */ … … 121 120 return d_data->style; 122 121 } 122 123 /*! 124 Build and assign a pen 125 126 In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it 127 non cosmetic ( see QPen::isCosmetic() ). This method has been introduced 128 to hide this incompatibility. 129 130 \param color Pen color 131 \param width Pen width 132 \param style Pen style 133 134 \sa pen(), brush() 135 */ 136 void QwtPlotHistogram::setPen( const QColor &color, qreal width, Qt::PenStyle style ) 137 { 138 setPen( QPen( color, width, style ) ); 139 } 123 140 124 141 /*! … … 133 150 { 134 151 d_data->pen = pen; 152 153 legendChanged(); 135 154 itemChanged(); 136 155 } … … 157 176 { 158 177 d_data->brush = brush; 178 179 legendChanged(); 159 180 itemChanged(); 160 181 } … … 181 202 182 203 \note In applications, where different intervals need to be displayed 183 in a different way ( f.e different colors or even using differ nt symbols)204 in a different way ( f.e different colors or even using different symbols) 184 205 it is recommended to overload drawColumn(). 185 206 */ … … 190 211 delete d_data->symbol; 191 212 d_data->symbol = symbol; 213 214 legendChanged(); 192 215 itemChanged(); 193 216 } … … 238 261 QRectF QwtPlotHistogram::boundingRect() const 239 262 { 240 QRectF rect = d _series->boundingRect();263 QRectF rect = data()->boundingRect(); 241 264 if ( !rect.isValid() ) 242 265 return rect; … … 276 299 const QVector<QwtIntervalSample> &samples ) 277 300 { 278 delete d_series; 279 d_series = new QwtIntervalSeriesData( samples ); 280 itemChanged(); 301 setData( new QwtIntervalSeriesData( samples ) ); 302 } 303 304 /*! 305 Assign a series of samples 306 307 setSamples() is just a wrapper for setData() without any additional 308 value - beside that it is easier to find for the developer. 309 310 \param data Data 311 \warning The item takes ownership of the data object, deleting 312 it when its not used anymore. 313 */ 314 void QwtPlotHistogram::setSamples( 315 QwtSeriesData<QwtIntervalSample> *data ) 316 { 317 setData( data ); 281 318 } 282 319 … … 287 324 \param xMap Maps x-values into pixel coordinates. 288 325 \param yMap Maps y-values into pixel coordinates. 289 \param canvasRect Contents rect of the canvas326 \param canvasRect Contents rectangle of the canvas 290 327 \param from Index of the first sample to be painted 291 328 \param to Index of the last sample to be painted. If to < 0 the … … 350 387 for ( int i = from; i <= to; i++ ) 351 388 { 352 const QwtIntervalSample sample = d_series->sample( i );389 const QwtIntervalSample sample = this->sample( i ); 353 390 354 391 if ( !sample.interval.isValid() ) … … 361 398 if ( previous.interval.isValid() ) 362 399 { 363 if ( ! isCombinable( previous.interval, sample.interval ) )400 if ( !qwtIsCombinable( previous.interval, sample.interval ) ) 364 401 flushPolygon( painter, v0, polygon ); 365 402 } … … 426 463 painter->setBrush( d_data->brush ); 427 464 465 const QwtSeriesData<QwtIntervalSample> *series = data(); 466 428 467 for ( int i = from; i <= to; i++ ) 429 468 { 430 const QwtIntervalSample sample = d_series->sample( i );469 const QwtIntervalSample sample = series->sample( i ); 431 470 if ( !sample.interval.isNull() ) 432 471 { … … 458 497 painter->setBrush( Qt::NoBrush ); 459 498 499 const QwtSeriesData<QwtIntervalSample> *series = data(); 500 460 501 for ( int i = from; i <= to; i++ ) 461 502 { 462 const QwtIntervalSample sample = d_series->sample( i );503 const QwtIntervalSample sample = series->sample( i ); 463 504 if ( !sample.interval.isNull() ) 464 505 { … … 532 573 polygon += QPointF( baseLine, polygon.first().y() ); 533 574 } 575 534 576 QwtPainter::drawPolygon( painter, polygon ); 535 polygon.resize( polygon.size() - 2 ); 577 578 polygon.pop_back(); 579 polygon.pop_back(); 536 580 } 537 581 if ( d_data->pen.style() != Qt::NoPen ) … … 601 645 602 646 \note In applications, where different intervals need to be displayed 603 in a different way ( f.e different colors or even using differ nt symbols)647 in a different way ( f.e different colors or even using different symbols) 604 648 it is recommended to overload drawColumn(). 605 649 */ … … 630 674 631 675 /*! 632 Draw a plain rectangle without pen using the brush() as identifier 633 634 \param painter Painter 635 \param rect Bounding rectangle for the identifier 636 */ 637 void QwtPlotHistogram::drawLegendIdentifier( 638 QPainter *painter, const QRectF &rect ) const 639 { 640 const double dim = qMin( rect.width(), rect.height() ); 641 642 QSizeF size( dim, dim ); 643 644 QRectF r( 0, 0, size.width(), size.height() ); 645 r.moveCenter( rect.center() ); 646 647 painter->fillRect( r, d_data->brush ); 648 } 676 A plain rectangle without pen using the brush() 677 678 \param index Index of the legend entry 679 ( ignored as there is only one ) 680 \param size Icon size 681 \return A graphic displaying the icon 682 683 \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() 684 */ 685 QwtGraphic QwtPlotHistogram::legendIcon( int index, 686 const QSizeF &size ) const 687 { 688 Q_UNUSED( index ); 689 return defaultIcon( d_data->brush, size ); 690 }
Note:
See TracChangeset
for help on using the changeset viewer.