qwt_point_data.cpp
Go to the documentation of this file.
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 {
56 }
57 
63 {
64  return m_interval;
65 }
66 
78 void QwtSyntheticPointData::setRectOfInterest( const QRectF& rect )
79 {
80  m_rectOfInterest = rect;
82  rect.left(), rect.right() ).normalized();
83 }
84 
90 {
91  return m_rectOfInterest;
92 }
93 
106 {
107  if ( m_size == 0 ||
109  {
110  return QRectF( 1.0, 1.0, -2.0, -2.0 ); // something invalid
111  }
112 
113  return qwtBoundingRect( *this );
114 }
115 
125 QPointF 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 
148 double QwtSyntheticPointData::x( uint index ) const
149 {
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 }
QwtInterval::isValid
bool isValid() const
Definition: qwt_interval.h:210
QwtSyntheticPointData::size
virtual size_t size() const QWT_OVERRIDE
Definition: qwt_point_data.cpp:42
QwtInterval::minValue
double minValue() const
Definition: qwt_interval.h:192
QwtSyntheticPointData::QwtSyntheticPointData
QwtSyntheticPointData(size_t size, const QwtInterval &=QwtInterval())
Definition: qwt_point_data.cpp:20
QwtSyntheticPointData::m_intervalOfInterest
QwtInterval m_intervalOfInterest
Definition: qwt_point_data.h:188
QwtSyntheticPointData::m_rectOfInterest
QRectF m_rectOfInterest
Definition: qwt_point_data.h:187
qwtBoundingRect
static QRectF qwtBoundingRect(const QPointF &sample)
Definition: qwt_series_data.cpp:13
qwt_point_data.h
QwtSyntheticPointData::y
virtual double y(double x) const =0
QwtSyntheticPointData::setRectOfInterest
virtual void setRectOfInterest(const QRectF &) QWT_OVERRIDE
Definition: qwt_point_data.cpp:78
nonstd::span_lite::size
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1554
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:22
QwtSyntheticPointData::boundingRect
virtual QRectF boundingRect() const QWT_OVERRIDE
Calculate the bounding rectangle.
Definition: qwt_point_data.cpp:105
QwtInterval::width
double width() const
Return the width of an interval.
Definition: qwt_interval.h:227
QwtSyntheticPointData::x
virtual double x(uint index) const
Definition: qwt_point_data.cpp:148
QwtSyntheticPointData::m_interval
QwtInterval m_interval
Definition: qwt_point_data.h:186
QwtSyntheticPointData::setSize
void setSize(size_t size)
Definition: qwt_point_data.cpp:33
QwtSyntheticPointData::m_size
size_t m_size
Definition: qwt_point_data.h:185
QwtSyntheticPointData::sample
virtual QPointF sample(size_t index) const QWT_OVERRIDE
Definition: qwt_point_data.cpp:125
QwtSyntheticPointData::rectOfInterest
QRectF rectOfInterest() const
Definition: qwt_point_data.cpp:89
QwtInterval::normalized
QwtInterval normalized() const
Normalize the limits of the interval.
Definition: qwt_interval.cpp:29
QwtSyntheticPointData::setInterval
void setInterval(const QwtInterval &)
Definition: qwt_point_data.cpp:53
QwtSyntheticPointData::interval
QwtInterval interval() const
Definition: qwt_point_data.cpp:62


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46