source: ntrip/trunk/BNC/qwt/qwt_point_data.h@ 8643

Last change on this file since 8643 was 8127, checked in by stoecker, 8 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

File size: 3.5 KB
RevLine 
[8127]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#ifndef QWT_POINT_DATA_H
11#define QWT_POINT_DATA_H 1
12
13#include "qwt_global.h"
14#include "qwt_series_data.h"
15
16/*!
17 \brief Interface for iterating over two QVector<double> objects.
18*/
19class QWT_EXPORT QwtPointArrayData: public QwtSeriesData<QPointF>
20{
21public:
22 QwtPointArrayData( const QVector<double> &x, const QVector<double> &y );
23 QwtPointArrayData( const double *x, const double *y, size_t size );
24
25 virtual QRectF boundingRect() const;
26
27 virtual size_t size() const;
28 virtual QPointF sample( size_t i ) const;
29
30 const QVector<double> &xData() const;
31 const QVector<double> &yData() const;
32
33private:
34 QVector<double> d_x;
35 QVector<double> d_y;
36};
37
38/*!
39 \brief Data class containing two pointers to memory blocks of doubles.
40 */
41class QWT_EXPORT QwtCPointerData: public QwtSeriesData<QPointF>
42{
43public:
44 QwtCPointerData( const double *x, const double *y, size_t size );
45
46 virtual QRectF boundingRect() const;
47 virtual size_t size() const;
48 virtual QPointF sample( size_t i ) const;
49
50 const double *xData() const;
51 const double *yData() const;
52
53private:
54 const double *d_x;
55 const double *d_y;
56 size_t d_size;
57};
58
59/*!
60 \brief Synthetic point data
61
62 QwtSyntheticPointData provides a fixed number of points for an interval.
63 The points are calculated in equidistant steps in x-direction.
64
65 If the interval is invalid, the points are calculated for
66 the "rectangle of interest", what normally is the displayed area on the
67 plot canvas. In this mode you get different levels of detail, when
68 zooming in/out.
69
70 \par Example
71
72 The following example shows how to implement a sinus curve.
73
74 \code
75#include <cmath>
76#include <qwt_series_data.h>
77#include <qwt_plot_curve.h>
78#include <qwt_plot.h>
79#include <qapplication.h>
80
81class SinusData: public QwtSyntheticPointData
82{
83public:
84 SinusData():
85 QwtSyntheticPointData( 100 )
86 {
87 }
88
89 virtual double y( double x ) const
90 {
91 return qSin( x );
92 }
93};
94
95int main(int argc, char **argv)
96{
97 QApplication a( argc, argv );
98
99 QwtPlot plot;
100 plot.setAxisScale( QwtPlot::xBottom, 0.0, 10.0 );
101 plot.setAxisScale( QwtPlot::yLeft, -1.0, 1.0 );
102
103 QwtPlotCurve *curve = new QwtPlotCurve( "y = sin(x)" );
104 curve->setData( new SinusData() );
105 curve->attach( &plot );
106
107 plot.show();
108 return a.exec();
109}
110 \endcode
111*/
112class QWT_EXPORT QwtSyntheticPointData: public QwtSeriesData<QPointF>
113{
114public:
115 QwtSyntheticPointData( size_t size,
116 const QwtInterval & = QwtInterval() );
117
118 void setSize( size_t size );
119 virtual size_t size() const;
120
121 void setInterval( const QwtInterval& );
122 QwtInterval interval() const;
123
124 virtual QRectF boundingRect() const;
125 virtual QPointF sample( size_t i ) const;
126
127 /*!
128 Calculate a y value for a x value
129
130 \param x x value
131 \return Corresponding y value
132 */
133 virtual double y( double x ) const = 0;
134 virtual double x( uint index ) const;
135
136 virtual void setRectOfInterest( const QRectF & );
137 QRectF rectOfInterest() const;
138
139private:
140 size_t d_size;
141 QwtInterval d_interval;
142 QRectF d_rectOfInterest;
143 QwtInterval d_intervalOfInterest;
144};
145
146#endif
Note: See TracBrowser for help on using the repository browser.