1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
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
*****************************************************************************/
11
#include "qwt_interval_data.h"
14
QwtIntervalData::QwtIntervalData()
19
QwtIntervalData::QwtIntervalData(
20
const QwtArray<QwtDoubleInterval> &intervals,
21
const QwtArray<double> &values):
22
d_intervals(intervals),
28
QwtIntervalData::~QwtIntervalData()
33
void QwtIntervalData::setData(
34
const QwtArray<QwtDoubleInterval> &intervals,
35
const QwtArray<double> &values)
37
d_intervals = intervals;
42
Calculate the bounding rectangle of the samples
44
The x coordinates of the rectangle are built from the intervals,
45
the y coordinates from the values.
47
\return Bounding rectangle
49
QwtDoubleRect QwtIntervalData::boundingRect() const
51
double minX, maxX, minY, maxY;
52
minX = maxX = minY = maxY = 0.0;
56
const size_t sz = size();
57
for ( size_t i = 0; i < sz; i++ )
59
const QwtDoubleInterval intv = interval(i);
60
if ( !intv.isValid() )
63
const double v = value(i);
67
minX = intv.minValue();
68
maxX = intv.maxValue();
75
if ( intv.minValue() < minX )
76
minX = intv.minValue();
77
if ( intv.maxValue() > maxX )
78
maxX = intv.maxValue();
87
return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid
89
return QwtDoubleRect(minX, minY, maxX - minX, maxY - minY);