[4271] | 1 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
---|
| 2 | * Qwt Widget Library
|
---|
| 3 | * Copyright (C) 1997 Josef Wilgen
|
---|
| 4 | * Copyright (C) 2002 Uwe Rathmann
|
---|
| 5 | *
|
---|
| 6 | * This library is free software; you can redistribute it and/or
|
---|
| 7 | * modify it under the terms of the Qwt License, Version 1.0
|
---|
| 8 | *****************************************************************************/
|
---|
| 9 |
|
---|
| 10 | #include "qwt_plot_seriesitem.h"
|
---|
| 11 |
|
---|
[8127] | 12 | class QwtPlotSeriesItem::PrivateData
|
---|
[4271] | 13 | {
|
---|
| 14 | public:
|
---|
| 15 | PrivateData():
|
---|
| 16 | orientation( Qt::Vertical )
|
---|
| 17 | {
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | Qt::Orientation orientation;
|
---|
| 21 | };
|
---|
| 22 |
|
---|
| 23 | /*!
|
---|
| 24 | Constructor
|
---|
| 25 | \param title Title of the curve
|
---|
| 26 | */
|
---|
[8127] | 27 | QwtPlotSeriesItem::QwtPlotSeriesItem( const QwtText &title ):
|
---|
[4271] | 28 | QwtPlotItem( title )
|
---|
| 29 | {
|
---|
| 30 | d_data = new PrivateData();
|
---|
[8127] | 31 | setItemInterest( QwtPlotItem::ScaleInterest, true );
|
---|
[4271] | 32 | }
|
---|
| 33 |
|
---|
| 34 | /*!
|
---|
| 35 | Constructor
|
---|
| 36 | \param title Title of the curve
|
---|
| 37 | */
|
---|
[8127] | 38 | QwtPlotSeriesItem::QwtPlotSeriesItem( const QString &title ):
|
---|
[4271] | 39 | QwtPlotItem( QwtText( title ) )
|
---|
| 40 | {
|
---|
| 41 | d_data = new PrivateData();
|
---|
[9383] | 42 | setItemInterest( QwtPlotItem::ScaleInterest, true );
|
---|
[4271] | 43 | }
|
---|
| 44 |
|
---|
| 45 | //! Destructor
|
---|
[8127] | 46 | QwtPlotSeriesItem::~QwtPlotSeriesItem()
|
---|
[4271] | 47 | {
|
---|
| 48 | delete d_data;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | /*!
|
---|
| 52 | Set the orientation of the item.
|
---|
| 53 |
|
---|
| 54 | The orientation() might be used in specific way by a plot item.
|
---|
| 55 | F.e. a QwtPlotCurve uses it to identify how to display the curve
|
---|
| 56 | int QwtPlotCurve::Steps or QwtPlotCurve::Sticks style.
|
---|
| 57 |
|
---|
| 58 | \sa orientation()
|
---|
| 59 | */
|
---|
[8127] | 60 | void QwtPlotSeriesItem::setOrientation( Qt::Orientation orientation )
|
---|
[4271] | 61 | {
|
---|
| 62 | if ( d_data->orientation != orientation )
|
---|
| 63 | {
|
---|
| 64 | d_data->orientation = orientation;
|
---|
[8127] | 65 |
|
---|
| 66 | legendChanged();
|
---|
[4271] | 67 | itemChanged();
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | /*!
|
---|
| 72 | \return Orientation of the plot item
|
---|
| 73 | \sa setOrientation()
|
---|
| 74 | */
|
---|
[8127] | 75 | Qt::Orientation QwtPlotSeriesItem::orientation() const
|
---|
[4271] | 76 | {
|
---|
| 77 | return d_data->orientation;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | /*!
|
---|
| 81 | \brief Draw the complete series
|
---|
| 82 |
|
---|
| 83 | \param painter Painter
|
---|
| 84 | \param xMap Maps x-values into pixel coordinates.
|
---|
| 85 | \param yMap Maps y-values into pixel coordinates.
|
---|
[8127] | 86 | \param canvasRect Contents rectangle of the canvas
|
---|
[4271] | 87 | */
|
---|
[8127] | 88 | void QwtPlotSeriesItem::draw( QPainter *painter,
|
---|
[4271] | 89 | const QwtScaleMap &xMap, const QwtScaleMap &yMap,
|
---|
| 90 | const QRectF &canvasRect ) const
|
---|
| 91 | {
|
---|
| 92 | drawSeries( painter, xMap, yMap, canvasRect, 0, -1 );
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[8127] | 95 | QRectF QwtPlotSeriesItem::boundingRect() const
|
---|
| 96 | {
|
---|
| 97 | return dataRect();
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | void QwtPlotSeriesItem::updateScaleDiv(
|
---|
| 101 | const QwtScaleDiv &xScaleDiv, const QwtScaleDiv &yScaleDiv )
|
---|
[9383] | 102 | {
|
---|
[8127] | 103 | const QRectF rect = QRectF(
|
---|
| 104 | xScaleDiv.lowerBound(), yScaleDiv.lowerBound(),
|
---|
| 105 | xScaleDiv.range(), yScaleDiv.range() );
|
---|
[9383] | 106 |
|
---|
[8127] | 107 | setRectOfInterest( rect );
|
---|
[9383] | 108 | }
|
---|
[8127] | 109 |
|
---|
| 110 | void QwtPlotSeriesItem::dataChanged()
|
---|
| 111 | {
|
---|
| 112 | itemChanged();
|
---|
| 113 | }
|
---|