~ubuntu-branches/ubuntu/oneiric/qwt/oneiric-proposed

« back to all changes in this revision

Viewing changes to qwt/src/qwt_interval_data.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2011-06-10 11:22:47 UTC
  • mfrom: (1.1.6 upstream) (2.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110610112247-0i1019vvmzaq6p86
Tags: 6.0.0-1
* New upstream release (Closes: #624107):
  - drop Qt3 support. (Closes: #604379, #626868)
* Register documentation with doc-base. (Closes: #626567)
* Drop patches:
  - 01_makefiles.diff
  - 02_add_missing_warnings.diff
  - 03_qwt_branch_pull_r544.diff
* Add qwt_install_paths.patch to fix the hardcoded installation paths.
* Update debian/control:
  - drop libqt3-mt-dev build dependency.
  - bump Standards-Version to 3.9.2 (no changes).
  - drop Qt3 related packages.
  - due to bump soname (and as we dropper Qt3 support):
    - libqwt5-qt4-dev -> libqwt-dev
    - libqwt5-qt4 -> libqwt6
    - libqwt5-doc -> libqwt-doc
* Update debian/copyright file.
* Update debian/rules: drop Qt3 packages support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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_math.h"
11
 
#include "qwt_interval_data.h"
12
 
 
13
 
//! Constructor
14
 
QwtIntervalData::QwtIntervalData()
15
 
{
16
 
}
17
 
 
18
 
//! Constructor
19
 
QwtIntervalData::QwtIntervalData(
20
 
        const QwtArray<QwtDoubleInterval> &intervals, 
21
 
        const QwtArray<double> &values):
22
 
    d_intervals(intervals),
23
 
    d_values(values)
24
 
{
25
 
}
26
 
    
27
 
//! Destructor
28
 
QwtIntervalData::~QwtIntervalData()
29
 
{
30
 
}
31
 
 
32
 
//! Assign samples
33
 
void QwtIntervalData::setData(
34
 
    const QwtArray<QwtDoubleInterval> &intervals,
35
 
    const QwtArray<double> &values)
36
 
{
37
 
    d_intervals = intervals;
38
 
    d_values = values;
39
 
}
40
 
 
41
 
/*! 
42
 
   Calculate the bounding rectangle of the samples
43
 
 
44
 
   The x coordinates of the rectangle are built from the intervals,
45
 
   the y coordinates from the values.
46
 
   
47
 
   \return Bounding rectangle
48
 
*/
49
 
QwtDoubleRect QwtIntervalData::boundingRect() const
50
 
{
51
 
    double minX, maxX, minY, maxY;
52
 
    minX = maxX = minY = maxY = 0.0;
53
 
 
54
 
    bool isValid = false;
55
 
 
56
 
    const size_t sz = size();
57
 
    for ( size_t i = 0; i < sz; i++ )
58
 
    {
59
 
        const QwtDoubleInterval intv = interval(i);
60
 
        if ( !intv.isValid() )
61
 
            continue;
62
 
 
63
 
        const double v = value(i);
64
 
 
65
 
        if ( !isValid )
66
 
        {
67
 
            minX = intv.minValue();
68
 
            maxX = intv.maxValue();
69
 
            minY = maxY = v;
70
 
 
71
 
            isValid = true;
72
 
        }
73
 
        else
74
 
        {
75
 
            if ( intv.minValue() < minX )
76
 
                minX = intv.minValue();
77
 
            if ( intv.maxValue() > maxX )
78
 
                maxX = intv.maxValue();
79
 
 
80
 
            if ( v < minY )
81
 
                minY = v;
82
 
            if ( v > maxY )
83
 
                maxY = v;
84
 
        }
85
 
    }
86
 
    if ( !isValid )
87
 
        return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid
88
 
 
89
 
    return QwtDoubleRect(minX, minY, maxX - minX, maxY - minY);
90
 
}