Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
qwt_point_data.cpp
1/******************************************************************************
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
21 size_t size, const QwtInterval& interval )
22 : m_size( size )
23 , m_interval( interval )
24{
25}
26
34{
35 m_size = size;
36}
37
43{
44 return m_size;
45}
46
54{
55 m_interval = interval.normalized();
56}
57
63{
64 return m_interval;
65}
66
79{
80 m_rectOfInterest = rect;
81 m_intervalOfInterest = QwtInterval(
82 rect.left(), rect.right() ).normalized();
83}
84
90{
91 return m_rectOfInterest;
92}
93
106{
107 if ( m_size == 0 ||
108 !( m_interval.isValid() || m_intervalOfInterest.isValid() ) )
109 {
110 return QRectF( 1.0, 1.0, -2.0, -2.0 ); // something invalid
111 }
112
113 return qwtBoundingRect( *this );
114}
115
125QPointF QwtSyntheticPointData::sample( size_t index ) const
126{
127 if ( index >= m_size )
128 return QPointF( 0, 0 );
129
130 const double xValue = x( index );
131 const double yValue = y( xValue );
132
133 return QPointF( xValue, yValue );
134}
135
148double QwtSyntheticPointData::x( uint index ) const
149{
150 const QwtInterval& interval = m_interval.isValid() ?
151 m_interval : m_intervalOfInterest;
152
153 if ( !interval.isValid() )
154 return 0.0;
155
156 if ( m_size <= 1 )
157 return interval.minValue();
158
159 const double dx = interval.width() / ( m_size - 1 );
160 return interval.minValue() + index * dx;
161}
A class representing an interval.
double minValue() const
QwtInterval normalized() const
Normalize the limits of the interval.
double width() const
Return the width of an interval.
bool isValid() const
void setInterval(const QwtInterval &)
virtual QPointF sample(size_t index) const override
QwtInterval interval() const
void setSize(size_t size)
QRectF rectOfInterest() const
virtual double x(uint index) const
virtual size_t size() const override
QwtSyntheticPointData(size_t size, const QwtInterval &=QwtInterval())
virtual QRectF boundingRect() const override
Calculate the bounding rectangle.
virtual double y(double x) const =0
virtual void setRectOfInterest(const QRectF &) override