You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.8 KiB
71 lines
1.8 KiB
15 years ago
|
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
||
|
* Qwt Widget Library
|
||
|
* Copyright (C) 1997 Josef Wilgen
|
||
|
* Copyright (C) 2002 Uwe Rathmann
|
||
14 years ago
|
*
|
||
15 years ago
|
* 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_math.h"
|
||
|
#include "qwt_interval_data.h"
|
||
|
|
||
|
QwtIntervalData::QwtIntervalData()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
QwtIntervalData::QwtIntervalData(
|
||
14 years ago
|
const QwtArray<QwtDoubleInterval> &intervals,
|
||
|
const QwtArray<double> &values):
|
||
15 years ago
|
d_intervals(intervals),
|
||
|
d_values(values)
|
||
|
{
|
||
|
}
|
||
14 years ago
|
|
||
15 years ago
|
void QwtIntervalData::setData(
|
||
|
const QwtArray<QwtDoubleInterval> &intervals,
|
||
|
const QwtArray<double> &values)
|
||
|
{
|
||
|
d_intervals = intervals;
|
||
|
d_values = values;
|
||
|
}
|
||
|
|
||
|
QwtDoubleRect QwtIntervalData::boundingRect() const
|
||
|
{
|
||
|
double minX, maxX, minY, maxY;
|
||
|
minX = maxX = minY = maxY = 0.0;
|
||
|
|
||
|
bool isValid = false;
|
||
|
|
||
|
const size_t sz = size();
|
||
14 years ago
|
for ( size_t i = 0; i < sz; i++ ) {
|
||
15 years ago
|
const QwtDoubleInterval intv = interval(i);
|
||
|
if ( !intv.isValid() )
|
||
|
continue;
|
||
|
|
||
|
const double v = value(i);
|
||
|
|
||
14 years ago
|
if ( !isValid ) {
|
||
15 years ago
|
minX = intv.minValue();
|
||
|
maxX = intv.maxValue();
|
||
|
minY = maxY = v;
|
||
|
|
||
|
isValid = true;
|
||
14 years ago
|
} else {
|
||
15 years ago
|
if ( intv.minValue() < minX )
|
||
|
minX = intv.minValue();
|
||
|
if ( intv.maxValue() > maxX )
|
||
|
maxX = intv.maxValue();
|
||
|
|
||
|
if ( v < minY )
|
||
|
minY = v;
|
||
|
if ( v > maxY )
|
||
|
maxY = v;
|
||
|
}
|
||
|
}
|
||
|
if ( !isValid )
|
||
|
return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid
|
||
|
|
||
|
return QwtDoubleRect(minX, minY, maxX - minX, maxY - minY);
|
||
|
}
|