Loading...
Searching...
No Matches
qwt_point_data.cpp
/******************************************************************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include "qwt_point_data.h"
QwtSyntheticPointData::QwtSyntheticPointData(
size_t size, const QwtInterval& interval )
: m_size( size )
, m_interval( interval )
{
}
void QwtSyntheticPointData::setSize( size_t size )
{
m_size = size;
}
size_t QwtSyntheticPointData::size() const
{
return m_size;
}
void QwtSyntheticPointData::setInterval( const QwtInterval& interval )
{
m_interval = interval.normalized();
}
QwtInterval QwtSyntheticPointData::interval() const
{
return m_interval;
}
void QwtSyntheticPointData::setRectOfInterest( const QRectF& rect )
{
m_rectOfInterest = rect;
m_intervalOfInterest = QwtInterval(
rect.left(), rect.right() ).normalized();
}
QRectF QwtSyntheticPointData::rectOfInterest() const
{
return m_rectOfInterest;
}
QRectF QwtSyntheticPointData::boundingRect() const
{
if ( m_size == 0 ||
!( m_interval.isValid() || m_intervalOfInterest.isValid() ) )
{
return QRectF( 1.0, 1.0, -2.0, -2.0 ); // something invalid
}
return qwtBoundingRect( *this );
}
QPointF QwtSyntheticPointData::sample( size_t index ) const
{
if ( index >= m_size )
return QPointF( 0, 0 );
const double xValue = x( index );
const double yValue = y( xValue );
return QPointF( xValue, yValue );
}
double QwtSyntheticPointData::x( uint index ) const
{
const QwtInterval& interval = m_interval.isValid() ?
m_interval : m_intervalOfInterest;
if ( !interval.isValid() )
return 0.0;
if ( m_size <= 1 )
return interval.minValue();
const double dx = interval.width() / ( m_size - 1 );
return interval.minValue() + index * dx;
}
QwtInterval
A class representing an interval.
Definition qwt_interval.h:23
QwtInterval::minValue
double minValue() const
Definition qwt_interval.h:192
QwtInterval::normalized
QwtInterval normalized() const
Normalize the limits of the interval.
Definition qwt_interval.cpp:29
QwtInterval::width
double width() const
Return the width of an interval.
Definition qwt_interval.h:227
QwtInterval::isValid
bool isValid() const
Definition qwt_interval.h:210
QwtSyntheticPointData::setInterval
void setInterval(const QwtInterval &)
Definition qwt_point_data.cpp:53
QwtSyntheticPointData::sample
virtual QPointF sample(size_t index) const override
Definition qwt_point_data.cpp:125
QwtSyntheticPointData::interval
QwtInterval interval() const
Definition qwt_point_data.cpp:62
QwtSyntheticPointData::setSize
void setSize(size_t size)
Definition qwt_point_data.cpp:33
QwtSyntheticPointData::rectOfInterest
QRectF rectOfInterest() const
Definition qwt_point_data.cpp:89
QwtSyntheticPointData::x
virtual double x(uint index) const
Definition qwt_point_data.cpp:148
QwtSyntheticPointData::size
virtual size_t size() const override
Definition qwt_point_data.cpp:42
QwtSyntheticPointData::QwtSyntheticPointData
QwtSyntheticPointData(size_t size, const QwtInterval &=QwtInterval())
Definition qwt_point_data.cpp:20
QwtSyntheticPointData::boundingRect
virtual QRectF boundingRect() const override
Calculate the bounding rectangle.
Definition qwt_point_data.cpp:105
QwtSyntheticPointData::y
virtual double y(double x) const =0
QwtSyntheticPointData::setRectOfInterest
virtual void setRectOfInterest(const QRectF &) override
Definition qwt_point_data.cpp:78