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 
21  size_t size, const QwtInterval &interval ):
22  d_size( size ),
23  d_interval( interval )
24 {
25 }
26 
34 {
35  d_size = size;
36 }
37 
43 {
44  return d_size;
45 }
46 
54 {
55  d_interval = interval.normalized();
56 }
57 
63 {
64  return d_interval;
65 }
66 
78 void QwtSyntheticPointData::setRectOfInterest( const QRectF &rect )
79 {
80  d_rectOfInterest = rect;
82  rect.left(), rect.right() ).normalized();
83 }
84 
90 {
91  return d_rectOfInterest;
92 }
93 
106 {
107  if ( d_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 >= d_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 ( d_size <= 1 )
157  return interval.minValue();
158 
159  const double dx = interval.width() / ( d_size - 1 );
160  return interval.minValue() + index * dx;
161 }
QwtInterval normalized() const
Normalize the limits of the interval.
virtual double x(uint index) const
virtual void setRectOfInterest(const QRectF &) QWT_OVERRIDE
virtual QPointF sample(size_t index) const QWT_OVERRIDE
A class representing an interval.
Definition: qwt_interval.h:22
double minValue() const
Definition: qwt_interval.h:190
virtual size_t size() const QWT_OVERRIDE
QwtInterval d_intervalOfInterest
void setInterval(const QwtInterval &)
QwtSyntheticPointData(size_t size, const QwtInterval &=QwtInterval())
static QRectF qwtBoundingRect(const QPointF &sample)
virtual QRectF boundingRect() const QWT_OVERRIDE
Calculate the bounding rectangle.
bool isValid() const
Definition: qwt_interval.h:208
void setSize(size_t size)
QRectF rectOfInterest() const
double width() const
Return the width of an interval.
Definition: qwt_interval.h:225
virtual double y(double x) const =0
QwtInterval interval() const


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:10