Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_tradingcurve.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot_tradingcurve.cpp (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_tradingcurve.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 10 10 #include "qwt_plot_tradingcurve.h" 11 11 #include "qwt_scale_map.h" 12 #include "qwt_clipper.h"13 12 #include "qwt_painter.h" 13 #include "qwt_text.h" 14 #include "qwt_graphic.h" 15 #include "qwt_math.h" 16 14 17 #include <qpainter.h> 15 18 16 static inline bool qwtIsSampleInside( const QwtOHLCSample &sample,19 static inline bool qwtIsSampleInside( const QwtOHLCSample& sample, 17 20 double tMin, double tMax, double vMin, double vMax ) 18 21 { … … 28 31 class QwtPlotTradingCurve::PrivateData 29 32 { 30 public: 31 PrivateData() :32 symbolStyle( QwtPlotTradingCurve::CandleStick ) ,33 symbolExtent( 0.6 ) ,34 minSymbolWidth( 2.0 ) ,35 maxSymbolWidth( -1.0 ) ,36 paintAttributes( QwtPlotTradingCurve::ClipSymbols ) 33 public: 34 PrivateData() 35 : symbolStyle( QwtPlotTradingCurve::CandleStick ) 36 , symbolExtent( 0.6 ) 37 , minSymbolWidth( 2.0 ) 38 , maxSymbolWidth( -1.0 ) 39 , paintAttributes( QwtPlotTradingCurve::ClipSymbols ) 37 40 { 38 41 symbolBrush[0] = QBrush( Qt::white ); … … 52 55 53 56 /*! 54 Constructor 55 \param title Title of the curve 56 */ 57 QwtPlotTradingCurve::QwtPlotTradingCurve( const QwtText &title ):58 QwtPlotSeriesItem( title ) 57 Constructor 58 \param title Title of the curve 59 */ 60 QwtPlotTradingCurve::QwtPlotTradingCurve( const QwtText& title ) 61 : QwtPlotSeriesItem( title ) 59 62 { 60 63 init(); … … 62 65 63 66 /*! 64 Constructor 65 \param title Title of the curve 66 */ 67 QwtPlotTradingCurve::QwtPlotTradingCurve( const QString &title ):68 QwtPlotSeriesItem( QwtText( title ) ) 67 Constructor 68 \param title Title of the curve 69 */ 70 QwtPlotTradingCurve::QwtPlotTradingCurve( const QString& title ) 71 : QwtPlotSeriesItem( QwtText( title ) ) 69 72 { 70 73 init(); … … 74 77 QwtPlotTradingCurve::~QwtPlotTradingCurve() 75 78 { 76 delete d_data;79 delete m_data; 77 80 } 78 81 … … 83 86 setItemAttribute( QwtPlotItem::AutoScale, true ); 84 87 85 d_data = new PrivateData;88 m_data = new PrivateData; 86 89 setData( new QwtTradingChartData() ); 87 90 … … 96 99 97 100 /*! 98 Specify an attribute how to draw the curve 99 100 \param attribute Paint attribute 101 \param on On/Off 102 \sa testPaintAttribute() 103 */ 101 Specify an attribute how to draw the curve 102 103 \param attribute Paint attribute 104 \param on On/Off 105 \sa testPaintAttribute() 106 */ 104 107 void QwtPlotTradingCurve::setPaintAttribute( 105 108 PaintAttribute attribute, bool on ) 106 109 { 107 110 if ( on ) 108 d_data->paintAttributes |= attribute;111 m_data->paintAttributes |= attribute; 109 112 else 110 d_data->paintAttributes &= ~attribute;113 m_data->paintAttributes &= ~attribute; 111 114 } 112 115 … … 114 117 \return True, when attribute is enabled 115 118 \sa PaintAttribute, setPaintAttribute() 116 */ 119 */ 117 120 bool QwtPlotTradingCurve::testPaintAttribute( 118 121 PaintAttribute attribute ) const 119 122 { 120 return ( d_data->paintAttributes & attribute );121 } 122 123 /*! 124 Initialize data with an array of samples. 125 \param samples Vector of samples 126 127 \sa QwtPlotSeriesItem::setData() 128 */ 123 return ( m_data->paintAttributes & attribute ); 124 } 125 126 /*! 127 Initialize data with an array of samples. 128 \param samples Vector of samples 129 130 \sa QwtPlotSeriesItem::setData() 131 */ 129 132 void QwtPlotTradingCurve::setSamples( 130 const QVector<QwtOHLCSample > &samples )133 const QVector< QwtOHLCSample >& samples ) 131 134 { 132 135 setData( new QwtTradingChartData( samples ) ); … … 134 137 135 138 /*! 136 Assign a series of samples 137 138 setSamples() is just a wrapper for setData() without any additional 139 value - beside that it is easier to find for the developer. 140 141 \param data Data 142 \warning The item takes ownership of the data object, deleting 139 Assign a series of samples 140 141 setSamples() is just a wrapper for setData() without any additional 142 value - beside that it is easier to find for the developer. 143 144 \param data Data 145 \warning The item takes ownership of the data object, deleting 143 146 it when its not used anymore. 144 */ 147 */ 145 148 void QwtPlotTradingCurve::setSamples( 146 QwtSeriesData<QwtOHLCSample > *data )149 QwtSeriesData< QwtOHLCSample >* data ) 147 150 { 148 151 setData( data ); … … 150 153 151 154 /*! 152 Set the symbol style 153 154 \param style Symbol style 155 156 \sa symbolStyle(), setSymbolExtent(), 155 Set the symbol style 156 157 \param style Symbol style 158 159 \sa symbolStyle(), setSymbolExtent(), 157 160 setSymbolPen(), setSymbolBrush() 158 */ 161 */ 159 162 void QwtPlotTradingCurve::setSymbolStyle( SymbolStyle style ) 160 163 { 161 if ( style != d_data->symbolStyle )162 { 163 d_data->symbolStyle = style;164 if ( style != m_data->symbolStyle ) 165 { 166 m_data->symbolStyle = style; 164 167 165 168 legendChanged(); … … 169 172 170 173 /*! 171 \return Symbol style 172 \sa setSymbolStyle(), symbolExtent(), symbolPen(), symbolBrush() 173 */ 174 \return Symbol style 175 \sa setSymbolStyle(), symbolExtent(), symbolPen(), symbolBrush() 176 */ 174 177 QwtPlotTradingCurve::SymbolStyle QwtPlotTradingCurve::symbolStyle() const 175 178 { 176 return d_data->symbolStyle;177 } 178 179 /*! 180 Build and assign the symbol pen 181 182 In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it 183 non cosmetic ( see QPen::isCosmetic() ). This method has been introduced 184 to hide this incompatibility. 185 186 \param color Pen color 187 \param width Pen width 188 \param style Pen style 189 190 \sa pen(), brush() 179 return m_data->symbolStyle; 180 } 181 182 /*! 183 Build and assign the symbol pen 184 185 In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it 186 non cosmetic ( see QPen::isCosmetic() ). This method has been introduced 187 to hide this incompatibility. 188 189 \param color Pen color 190 \param width Pen width 191 \param style Pen style 192 193 \sa pen(), brush() 191 194 */ 192 195 void QwtPlotTradingCurve::setSymbolPen( 193 const QColor &color, qreal width, Qt::PenStyle style )196 const QColor& color, qreal width, Qt::PenStyle style ) 194 197 { 195 198 setSymbolPen( QPen( color, width, style ) ); … … 197 200 198 201 /*! 199 \brief Set the symbol pen 200 201 The symbol pen is used for rendering the lines of the 202 bar or candlestick symbols 203 204 \sa symbolPen(), setSymbolBrush() 205 */ 206 void QwtPlotTradingCurve::setSymbolPen( const QPen &pen )207 { 208 if ( pen != d_data->symbolPen )209 { 210 d_data->symbolPen = pen;202 \brief Set the symbol pen 203 204 The symbol pen is used for rendering the lines of the 205 bar or candlestick symbols 206 207 \sa symbolPen(), setSymbolBrush() 208 */ 209 void QwtPlotTradingCurve::setSymbolPen( const QPen& pen ) 210 { 211 if ( pen != m_data->symbolPen ) 212 { 213 m_data->symbolPen = pen; 211 214 212 215 legendChanged(); … … 216 219 217 220 /*! 218 \return Symbol pen 219 \sa setSymbolPen(), symbolBrush() 220 */ 221 \return Symbol pen 222 \sa setSymbolPen(), symbolBrush() 223 */ 221 224 QPen QwtPlotTradingCurve::symbolPen() const 222 225 { 223 return d_data->symbolPen;224 } 225 226 /*! 227 Set the symbol brush 228 229 \param direction Direction type 230 \param brush Brush used to fill the body of all candlestick 226 return m_data->symbolPen; 227 } 228 229 /*! 230 Set the symbol brush 231 232 \param direction Direction type 233 \param brush Brush used to fill the body of all candlestick 231 234 symbols with the direction 232 235 233 \sa symbolBrush(), setSymbolPen() 234 */ 236 \sa symbolBrush(), setSymbolPen() 237 */ 235 238 void QwtPlotTradingCurve::setSymbolBrush( 236 Direction direction, const QBrush &brush )239 Direction direction, const QBrush& brush ) 237 240 { 238 241 // silencing -Wtautological-constant-out-of-range-compare … … 241 244 return; 242 245 243 if ( brush != d_data->symbolBrush[ index ] )244 { 245 d_data->symbolBrush[ index ] = brush;246 if ( brush != m_data->symbolBrush[ index ] ) 247 { 248 m_data->symbolBrush[ index ] = brush; 246 249 247 250 legendChanged(); … … 251 254 252 255 /*! 253 \param direction 254 \return Brush used to fill the body of all candlestick 256 \param direction 257 \return Brush used to fill the body of all candlestick 255 258 symbols with the direction 256 259 257 \sa setSymbolPen(), symbolBrush() 258 */ 260 \sa setSymbolPen(), symbolBrush() 261 */ 259 262 QBrush QwtPlotTradingCurve::symbolBrush( Direction direction ) const 260 263 { … … 263 266 return QBrush(); 264 267 265 return d_data->symbolBrush[ index ];266 } 267 268 /*! 269 \brief Set the extent of the symbol 270 271 The width of the symbol is given in scale coordinates. When painting 272 a symbol the width is scaled into paint device coordinates 273 by scaledSymbolWidth(). The scaled width is bounded by 274 minSymbolWidth(), maxSymbolWidth() 275 276 \param extent Symbol width in scale coordinates 277 278 \sa symbolExtent(), scaledSymbolWidth(), 268 return m_data->symbolBrush[ index ]; 269 } 270 271 /*! 272 \brief Set the extent of the symbol 273 274 The width of the symbol is given in scale coordinates. When painting 275 a symbol the width is scaled into paint device coordinates 276 by scaledSymbolWidth(). The scaled width is bounded by 277 minSymbolWidth(), maxSymbolWidth() 278 279 \param extent Symbol width in scale coordinates 280 281 \sa symbolExtent(), scaledSymbolWidth(), 279 282 setMinSymbolWidth(), setMaxSymbolWidth() 280 */ 283 */ 281 284 void QwtPlotTradingCurve::setSymbolExtent( double extent ) 282 285 { 283 extent = q Max( 0.0, extent );284 if ( extent != d_data->symbolExtent )285 { 286 d_data->symbolExtent = extent;286 extent = qwtMaxF( 0.0, extent ); 287 if ( extent != m_data->symbolExtent ) 288 { 289 m_data->symbolExtent = extent; 287 290 288 291 legendChanged(); … … 292 295 293 296 /*! 294 \return Extent of a symbol in scale coordinates 295 \sa setSymbolExtent(), scaledSymbolWidth(), 297 \return Extent of a symbol in scale coordinates 298 \sa setSymbolExtent(), scaledSymbolWidth(), 296 299 minSymbolWidth(), maxSymbolWidth() 297 */ 300 */ 298 301 double QwtPlotTradingCurve::symbolExtent() const 299 302 { 300 return d_data->symbolExtent;301 } 302 303 /*! 304 Set a minimum for the symbol width 305 306 \param width Width in paint device coordinates 307 \sa minSymbolWidth(), setMaxSymbolWidth(), setSymbolExtent() 303 return m_data->symbolExtent; 304 } 305 306 /*! 307 Set a minimum for the symbol width 308 309 \param width Width in paint device coordinates 310 \sa minSymbolWidth(), setMaxSymbolWidth(), setSymbolExtent() 308 311 */ 309 312 void QwtPlotTradingCurve::setMinSymbolWidth( double width ) 310 313 { 311 width = q Max( width, 0.0 );312 if ( width != d_data->minSymbolWidth )313 { 314 d_data->minSymbolWidth = width;314 width = qwtMaxF( width, 0.0 ); 315 if ( width != m_data->minSymbolWidth ) 316 { 317 m_data->minSymbolWidth = width; 315 318 316 319 legendChanged(); … … 320 323 321 324 /*! 322 \return Minmum for the symbol width 323 \sa setMinSymbolWidth(), maxSymbolWidth(), symbolExtent() 325 \return Minmum for the symbol width 326 \sa setMinSymbolWidth(), maxSymbolWidth(), symbolExtent() 324 327 */ 325 328 double QwtPlotTradingCurve::minSymbolWidth() const 326 329 { 327 return d_data->minSymbolWidth;328 } 329 330 /*! 331 Set a maximum for the symbol width 332 333 A value <= 0.0 means an unlimited width 334 335 \param width Width in paint device coordinates 336 \sa maxSymbolWidth(), setMinSymbolWidth(), setSymbolExtent() 330 return m_data->minSymbolWidth; 331 } 332 333 /*! 334 Set a maximum for the symbol width 335 336 A value <= 0.0 means an unlimited width 337 338 \param width Width in paint device coordinates 339 \sa maxSymbolWidth(), setMinSymbolWidth(), setSymbolExtent() 337 340 */ 338 341 void QwtPlotTradingCurve::setMaxSymbolWidth( double width ) 339 342 { 340 if ( width != d_data->maxSymbolWidth )341 { 342 d_data->maxSymbolWidth = width;343 if ( width != m_data->maxSymbolWidth ) 344 { 345 m_data->maxSymbolWidth = width; 343 346 344 347 legendChanged(); … … 348 351 349 352 /*! 350 \return Maximum for the symbol width 351 \sa setMaxSymbolWidth(), minSymbolWidth(), symbolExtent() 353 \return Maximum for the symbol width 354 \sa setMaxSymbolWidth(), minSymbolWidth(), symbolExtent() 352 355 */ 353 356 double QwtPlotTradingCurve::maxSymbolWidth() const 354 357 { 355 return d_data->maxSymbolWidth;356 } 357 358 /*! 359 \return Bounding rectangle of all samples. 360 For an empty series the rectangle is invalid. 361 */ 358 return m_data->maxSymbolWidth; 359 } 360 361 /*! 362 \return Bounding rectangle of all samples. 363 For an empty series the rectangle is invalid. 364 */ 362 365 QRectF QwtPlotTradingCurve::boundingRect() const 363 366 { … … 370 373 371 374 /*! 372 Draw an interval of the curve 373 374 \param painter Painter 375 \param xMap Maps x-values into pixel coordinates. 376 \param yMap Maps y-values into pixel coordinates. 377 \param canvasRect Contents rectangle of the canvas 378 \param from Index of the first point to be painted 379 \param to Index of the last point to be painted. If to < 0 the 375 Draw an interval of the curve 376 377 \param painter Painter 378 \param xMap Maps x-values into pixel coordinates. 379 \param yMap Maps y-values into pixel coordinates. 380 \param canvasRect Contents rectangle of the canvas 381 \param from Index of the first point to be painted 382 \param to Index of the last point to be painted. If to < 0 the 380 383 curve will be painted to its last point. 381 384 382 \sa drawSymbols() 383 */ 384 void QwtPlotTradingCurve::drawSeries( QPainter *painter,385 const QwtScaleMap &xMap, const QwtScaleMap&yMap,386 const QRectF &canvasRect, int from, int to ) const385 \sa drawSymbols() 386 */ 387 void QwtPlotTradingCurve::drawSeries( QPainter* painter, 388 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 389 const QRectF& canvasRect, int from, int to ) const 387 390 { 388 391 if ( to < 0 ) … … 397 400 painter->save(); 398 401 399 if ( d_data->symbolStyle != QwtPlotTradingCurve::NoSymbol )402 if ( m_data->symbolStyle != QwtPlotTradingCurve::NoSymbol ) 400 403 drawSymbols( painter, xMap, yMap, canvasRect, from, to ); 401 404 … … 404 407 405 408 /*! 406 Draw symbols 407 408 \param painter Painter 409 \param xMap x map 410 \param yMap y map 411 \param canvasRect Contents rectangle of the canvas 412 \param from Index of the first point to be painted 413 \param to Index of the last point to be painted 414 415 \sa drawSeries() 416 */ 417 void QwtPlotTradingCurve::drawSymbols( QPainter *painter,418 const QwtScaleMap &xMap, const QwtScaleMap&yMap,419 const QRectF &canvasRect, int from, int to ) const409 Draw symbols 410 411 \param painter Painter 412 \param xMap x map 413 \param yMap y map 414 \param canvasRect Contents rectangle of the canvas 415 \param from Index of the first point to be painted 416 \param to Index of the last point to be painted 417 418 \sa drawSeries() 419 */ 420 void QwtPlotTradingCurve::drawSymbols( QPainter* painter, 421 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 422 const QRectF& canvasRect, int from, int to ) const 420 423 { 421 424 const QRectF tr = QwtScaleMap::invTransform( xMap, yMap, canvasRect ); 422 425 423 const QwtScaleMap *timeMap, *valueMap;426 const QwtScaleMap* timeMap, * valueMap; 424 427 double tMin, tMax, vMin, vMax; 425 428 … … 447 450 448 451 const bool inverted = timeMap->isInverting(); 449 const bool doClip = d_data->paintAttributes & ClipSymbols;452 const bool doClip = m_data->paintAttributes & ClipSymbols; 450 453 const bool doAlign = QwtPainter::roundingAlignment( painter ); 451 454 452 455 double symbolWidth = scaledSymbolWidth( xMap, yMap, canvasRect ); 453 456 if ( doAlign ) 454 symbolWidth = qFloor( 0.5 * symbolWidth ) * 2.0;455 456 QPen pen = d_data->symbolPen;457 symbolWidth = std::floor( 0.5 * symbolWidth ) * 2.0; 458 459 QPen pen = m_data->symbolPen; 457 460 pen.setCapStyle( Qt::FlatCap ); 458 461 … … 486 489 } 487 490 488 switch( d_data->symbolStyle )491 switch( m_data->symbolStyle ) 489 492 { 490 493 case Bar: … … 496 499 case CandleStick: 497 500 { 498 painter->setBrush( d_data->symbolBrush[ brushIndex ] );501 painter->setBrush( m_data->symbolBrush[ brushIndex ] ); 499 502 drawCandleStick( painter, translatedSample, 500 503 orient, symbolWidth ); … … 503 506 default: 504 507 { 505 if ( d_data->symbolStyle >= UserSymbol )508 if ( m_data->symbolStyle >= UserSymbol ) 506 509 { 507 painter->setBrush( d_data->symbolBrush[ brushIndex ] );508 drawUserSymbol( painter, d_data->symbolStyle,510 painter->setBrush( m_data->symbolBrush[ brushIndex ] ); 511 drawUserSymbol( painter, m_data->symbolStyle, 509 512 translatedSample, orient, inverted, symbolWidth ); 510 513 } … … 516 519 517 520 /*! 518 \brief Draw a symbol for a symbol style >= UserSymbol 519 520 The implementation does nothing and is intended to be overloaded 521 522 \param painter Qt painter, initialized with pen/brush 523 \param symbolStyle Symbol style 524 \param sample Samples already translated into paint device coordinates 525 \param orientation Vertical or horizontal 526 \param inverted True, when the opposite scale 521 \brief Draw a symbol for a symbol style >= UserSymbol 522 523 The implementation does nothing and is intended to be overloaded 524 525 \param painter Qt painter, initialized with pen/brush 526 \param symbolStyle Symbol style 527 \param sample Samples already translated into paint device coordinates 528 \param orientation Vertical or horizontal 529 \param inverted True, when the opposite scale 527 530 ( Qt::Vertical: x, Qt::Horizontal: y ) is increasing 528 531 in the opposite direction as QPainter coordinates. 529 \param symbolWidth Width of the symbol in paint device coordinates 530 */ 531 void QwtPlotTradingCurve::drawUserSymbol( QPainter *painter,532 SymbolStyle symbolStyle, const QwtOHLCSample &sample,532 \param symbolWidth Width of the symbol in paint device coordinates 533 */ 534 void QwtPlotTradingCurve::drawUserSymbol( QPainter* painter, 535 SymbolStyle symbolStyle, const QwtOHLCSample& sample, 533 536 Qt::Orientation orientation, bool inverted, double symbolWidth ) const 534 537 { … … 542 545 543 546 /*! 544 \brief Draw a bar 545 546 \param painter Qt painter, initialized with pen/brush 547 \param sample Sample, already translated into paint device coordinates 548 \param orientation Vertical or horizontal 549 \param inverted When inverted is false the open tick is painted 547 \brief Draw a bar 548 549 \param painter Qt painter, initialized with pen/brush 550 \param sample Sample, already translated into paint device coordinates 551 \param orientation Vertical or horizontal 552 \param inverted When inverted is false the open tick is painted 550 553 to the left/top, otherwise it is painted right/bottom. 551 554 The close tick is painted in the opposite direction … … 553 556 painted in the opposite d 554 557 opposite direction. 555 \param width Width or height of the candle, depending on the orientation 556 557 \sa Bar 558 */ 559 void QwtPlotTradingCurve::drawBar( QPainter *painter,560 const QwtOHLCSample &sample, Qt::Orientation orientation,558 \param width Width or height of the candle, depending on the orientation 559 560 \sa Bar 561 */ 562 void QwtPlotTradingCurve::drawBar( QPainter* painter, 563 const QwtOHLCSample& sample, Qt::Orientation orientation, 561 564 bool inverted, double width ) const 562 565 { … … 587 590 588 591 /*! 589 \brief Draw a candle stick 590 591 \param painter Qt painter, initialized with pen/brush 592 \param sample Samples already translated into paint device coordinates 593 \param orientation Vertical or horizontal 594 \param width Width or height of the candle, depending on the orientation 595 596 \sa CandleStick 597 */ 598 void QwtPlotTradingCurve::drawCandleStick( QPainter *painter,599 const QwtOHLCSample &sample, Qt::Orientation orientation,592 \brief Draw a candle stick 593 594 \param painter Qt painter, initialized with pen/brush 595 \param sample Samples already translated into paint device coordinates 596 \param orientation Vertical or horizontal 597 \param width Width or height of the candle, depending on the orientation 598 599 \sa CandleStick 600 */ 601 void QwtPlotTradingCurve::drawCandleStick( QPainter* painter, 602 const QwtOHLCSample& sample, Qt::Orientation orientation, 600 603 double width ) const 601 604 { 602 605 const double t = sample.time; 603 const double v1 = q Min( sample.low, sample.high );604 const double v2 = q Min( sample.open, sample.close );605 const double v3 = q Max( sample.low, sample.high );606 const double v4 = q Max( sample.open, sample.close );606 const double v1 = qwtMinF( sample.low, sample.high ); 607 const double v2 = qwtMinF( sample.open, sample.close ); 608 const double v3 = qwtMaxF( sample.low, sample.high ); 609 const double v4 = qwtMaxF( sample.open, sample.close ); 607 610 608 611 if ( orientation == Qt::Vertical ) … … 629 632 630 633 /*! 631 \return A rectangle filled with the color of the symbol pen 632 633 \param index Index of the legend entry 634 \return A rectangle filled with the color of the symbol pen 635 636 \param index Index of the legend entry 634 637 ( usually there is only one ) 635 \param size Icon size 636 637 \sa setLegendIconSize(), legendData() 638 */ 638 \param size Icon size 639 640 \sa setLegendIconSize(), legendData() 641 */ 639 642 QwtGraphic QwtPlotTradingCurve::legendIcon( int index, 640 const QSizeF &size ) const643 const QSizeF& size ) const 641 644 { 642 645 Q_UNUSED( index ); 643 return defaultIcon( d_data->symbolPen.color(), size );644 } 645 646 /*! 647 Calculate the symbol width in paint coordinates 648 649 The width is calculated by scaling the symbol extent into 650 paint device coordinates bounded by the minimum/maximum 651 symbol width. 652 653 \param xMap Maps x-values into pixel coordinates. 654 \param yMap Maps y-values into pixel coordinates. 655 \param canvasRect Contents rectangle of the canvas 656 657 \return Symbol width in paint coordinates 658 659 \sa symbolExtent(), minSymbolWidth(), maxSymbolWidth() 660 */ 646 return defaultIcon( m_data->symbolPen.color(), size ); 647 } 648 649 /*! 650 Calculate the symbol width in paint coordinates 651 652 The width is calculated by scaling the symbol extent into 653 paint device coordinates bounded by the minimum/maximum 654 symbol width. 655 656 \param xMap Maps x-values into pixel coordinates. 657 \param yMap Maps y-values into pixel coordinates. 658 \param canvasRect Contents rectangle of the canvas 659 660 \return Symbol width in paint coordinates 661 662 \sa symbolExtent(), minSymbolWidth(), maxSymbolWidth() 663 */ 661 664 double QwtPlotTradingCurve::scaledSymbolWidth( 662 const QwtScaleMap &xMap, const QwtScaleMap&yMap,663 const QRectF &canvasRect ) const665 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 666 const QRectF& canvasRect ) const 664 667 { 665 668 Q_UNUSED( canvasRect ); 666 669 667 if ( d_data->maxSymbolWidth > 0.0 &&668 d_data->minSymbolWidth >=d_data->maxSymbolWidth )669 { 670 return d_data->minSymbolWidth;671 } 672 673 const QwtScaleMap *map =670 if ( m_data->maxSymbolWidth > 0.0 && 671 m_data->minSymbolWidth >= m_data->maxSymbolWidth ) 672 { 673 return m_data->minSymbolWidth; 674 } 675 676 const QwtScaleMap* map = 674 677 ( orientation() == Qt::Vertical ) ? &xMap : &yMap; 675 678 676 const double pos = map->transform( map->s1() + d_data->symbolExtent );679 const double pos = map->transform( map->s1() + m_data->symbolExtent ); 677 680 678 681 double width = qAbs( pos - map->p1() ); 679 682 680 width = q Max( width,d_data->minSymbolWidth );681 if ( d_data->maxSymbolWidth > 0.0 )682 width = q Min( width,d_data->maxSymbolWidth );683 width = qwtMaxF( width, m_data->minSymbolWidth ); 684 if ( m_data->maxSymbolWidth > 0.0 ) 685 width = qwtMinF( width, m_data->maxSymbolWidth ); 683 686 684 687 return width;
Note:
See TracChangeset
for help on using the changeset viewer.
