| 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 |  | 
|---|
| 12 | class QwtPlotAbstractSeriesItem::PrivateData | 
|---|
| 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 | */ | 
|---|
| 27 | QwtPlotAbstractSeriesItem::QwtPlotAbstractSeriesItem( const QwtText &title ): | 
|---|
| 28 | QwtPlotItem( title ) | 
|---|
| 29 | { | 
|---|
| 30 | d_data = new PrivateData(); | 
|---|
| 31 | } | 
|---|
| 32 |  | 
|---|
| 33 | /*! | 
|---|
| 34 | Constructor | 
|---|
| 35 | \param title Title of the curve | 
|---|
| 36 | */ | 
|---|
| 37 | QwtPlotAbstractSeriesItem::QwtPlotAbstractSeriesItem( const QString &title ): | 
|---|
| 38 | QwtPlotItem( QwtText( title ) ) | 
|---|
| 39 | { | 
|---|
| 40 | d_data = new PrivateData(); | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 | //! Destructor | 
|---|
| 44 | QwtPlotAbstractSeriesItem::~QwtPlotAbstractSeriesItem() | 
|---|
| 45 | { | 
|---|
| 46 | delete d_data; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | /*! | 
|---|
| 50 | Set the orientation of the item. | 
|---|
| 51 |  | 
|---|
| 52 | The orientation() might be used in specific way by a plot item. | 
|---|
| 53 | F.e. a QwtPlotCurve uses it to identify how to display the curve | 
|---|
| 54 | int QwtPlotCurve::Steps or QwtPlotCurve::Sticks style. | 
|---|
| 55 |  | 
|---|
| 56 | \sa orientation() | 
|---|
| 57 | */ | 
|---|
| 58 | void QwtPlotAbstractSeriesItem::setOrientation( Qt::Orientation orientation ) | 
|---|
| 59 | { | 
|---|
| 60 | if ( d_data->orientation != orientation ) | 
|---|
| 61 | { | 
|---|
| 62 | d_data->orientation = orientation; | 
|---|
| 63 | itemChanged(); | 
|---|
| 64 | } | 
|---|
| 65 | } | 
|---|
| 66 |  | 
|---|
| 67 | /*! | 
|---|
| 68 | \return Orientation of the plot item | 
|---|
| 69 | \sa setOrientation() | 
|---|
| 70 | */ | 
|---|
| 71 | Qt::Orientation QwtPlotAbstractSeriesItem::orientation() const | 
|---|
| 72 | { | 
|---|
| 73 | return d_data->orientation; | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 | /*! | 
|---|
| 77 | \brief Draw the complete series | 
|---|
| 78 |  | 
|---|
| 79 | \param painter Painter | 
|---|
| 80 | \param xMap Maps x-values into pixel coordinates. | 
|---|
| 81 | \param yMap Maps y-values into pixel coordinates. | 
|---|
| 82 | \param canvasRect Contents rect of the canvas | 
|---|
| 83 | */ | 
|---|
| 84 | void QwtPlotAbstractSeriesItem::draw( QPainter *painter, | 
|---|
| 85 | const QwtScaleMap &xMap, const QwtScaleMap &yMap, | 
|---|
| 86 | const QRectF &canvasRect ) const | 
|---|
| 87 | { | 
|---|
| 88 | drawSeries( painter, xMap, yMap, canvasRect, 0, -1 ); | 
|---|
| 89 | } | 
|---|
| 90 |  | 
|---|