qwt_point_data.cpp
Go to the documentation of this file.
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_point_data.h"
11 #include "qwt_math.h"
12 #include <string.h>
13 
23  const QVector<double> &x, const QVector<double> &y ):
24  d_x( x ),
25  d_y( y )
26 {
27 }
28 
38  const double *y, size_t size )
39 {
40  d_x.resize( size );
41  ::memcpy( d_x.data(), x, size * sizeof( double ) );
42 
43  d_y.resize( size );
44  ::memcpy( d_y.data(), y, size * sizeof( double ) );
45 }
46 
56 {
57  if ( d_boundingRect.width() < 0 )
59 
60  return d_boundingRect;
61 }
62 
65 {
66  return qMin( d_x.size(), d_y.size() );
67 }
68 
75 QPointF QwtPointArrayData::sample( size_t index ) const
76 {
77  return QPointF( d_x[int( index )], d_y[int( index )] );
78 }
79 
81 const QVector<double> &QwtPointArrayData::xData() const
82 {
83  return d_x;
84 }
85 
87 const QVector<double> &QwtPointArrayData::yData() const
88 {
89  return d_y;
90 }
91 
106  const double *x, const double *y, size_t size ):
107  d_x( x ),
108  d_y( y ),
109  d_size( size )
110 {
111 }
112 
122 {
123  if ( d_boundingRect.width() < 0 )
124  d_boundingRect = qwtBoundingRect( *this );
125 
126  return d_boundingRect;
127 }
128 
130 size_t QwtCPointerData::size() const
131 {
132  return d_size;
133 }
134 
141 QPointF QwtCPointerData::sample( size_t index ) const
142 {
143  return QPointF( d_x[int( index )], d_y[int( index )] );
144 }
145 
147 const double *QwtCPointerData::xData() const
148 {
149  return d_x;
150 }
151 
153 const double *QwtCPointerData::yData() const
154 {
155  return d_y;
156 }
157 
167  size_t size, const QwtInterval &interval ):
168  d_size( size ),
169  d_interval( interval )
170 {
171 }
172 
180 {
181  d_size = size;
182 }
183 
189 {
190  return d_size;
191 }
192 
200 {
201  d_interval = interval.normalized();
202 }
203 
209 {
210  return d_interval;
211 }
212 
225 {
226  d_rectOfInterest = rect;
228  rect.left(), rect.right() ).normalized();
229 }
230 
236 {
237  return d_rectOfInterest;
238 }
239 
252 {
253  if ( d_size == 0 ||
255  {
256  return QRectF( 1.0, 1.0, -2.0, -2.0 ); // something invalid
257  }
258 
259  return qwtBoundingRect( *this );
260 }
261 
271 QPointF QwtSyntheticPointData::sample( size_t index ) const
272 {
273  if ( index >= d_size )
274  return QPointF( 0, 0 );
275 
276  const double xValue = x( index );
277  const double yValue = y( xValue );
278 
279  return QPointF( xValue, yValue );
280 }
281 
294 double QwtSyntheticPointData::x( uint index ) const
295 {
298 
299  if ( !interval.isValid() )
300  return 0.0;
301 
302  if ( d_size <= 1 )
303  return interval.minValue();
304 
305  const double dx = interval.width() / ( d_size - 1 );
306  return interval.minValue() + index * dx;
307 }
virtual size_t size() const
QwtInterval normalized() const
Normalize the limits of the interval.
virtual double x(uint index) const
QRectF d_boundingRect
Can be used to cache a calculated bounding rectangle.
A class representing an interval.
Definition: qwt_interval.h:26
virtual QPointF sample(size_t i) const
const QVector< double > & xData() const
double minValue() const
Definition: qwt_interval.h:193
const double * d_x
virtual QPointF sample(size_t i) const
QVector< double > d_x
const double * d_y
QwtInterval d_intervalOfInterest
const double * yData() const
QwtCPointerData(const double *x, const double *y, size_t size)
QwtPointArrayData(const QVector< double > &x, const QVector< double > &y)
void setInterval(const QwtInterval &)
QwtSyntheticPointData(size_t size, const QwtInterval &=QwtInterval())
virtual size_t size() const
virtual QRectF boundingRect() const
Calculate the bounding rectangle.
TFSIMD_FORCE_INLINE Vector3 normalized() const
virtual QRectF boundingRect() const
Calculate the bounding rectangle.
virtual size_t size() const
static QRectF qwtBoundingRect(const QPointF &sample)
bool isValid() const
Definition: qwt_interval.h:211
void setSize(size_t size)
virtual void setRectOfInterest(const QRectF &)
virtual QPointF sample(size_t i) const
const QVector< double > & yData() const
QRectF rectOfInterest() const
QVector< double > d_y
double width() const
Return the width of an interval.
Definition: qwt_interval.h:228
virtual QRectF boundingRect() const
Calculate the bounding rectangle.
virtual double y(double x) const =0
const double * xData() const
QwtInterval interval() const


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17