~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/libnr/nr-point-l.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SEEN_NR_POINT_L_H
 
2
#define SEEN_NR_POINT_L_H
 
3
 
 
4
#include <stdexcept>
 
5
#include <libnr/nr-i-coord.h>
 
6
#include <libnr/nr-point.h>
 
7
 
 
8
struct NRPointL {
 
9
    NR::ICoord x, y;
 
10
};
 
11
 
 
12
namespace NR {
 
13
 
 
14
class IPoint {
 
15
public:
 
16
    IPoint()
 
17
    { }
 
18
 
 
19
    IPoint(ICoord x, ICoord y) {
 
20
        _pt[X] = x;
 
21
        _pt[Y] = y;
 
22
    }
 
23
 
 
24
    IPoint(NRPointL const &p) {
 
25
        _pt[X] = p.x;
 
26
        _pt[Y] = p.y;
 
27
    }
 
28
 
 
29
    IPoint(IPoint const &p) {
 
30
        for (unsigned i = 0; i < 2; ++i) {
 
31
            _pt[i] = p._pt[i];
 
32
        }
 
33
    }
 
34
 
 
35
    IPoint &operator=(IPoint const &p) {
 
36
        for (unsigned i = 0; i < 2; ++i) {
 
37
            _pt[i] = p._pt[i];
 
38
        }
 
39
        return *this;
 
40
    }
 
41
 
 
42
    operator Point() {
 
43
        return Point(_pt[X], _pt[Y]);
 
44
    }
 
45
 
 
46
    ICoord operator[](unsigned i) const throw(std::out_of_range) {
 
47
        if ( i > Y ) {
 
48
            throw std::out_of_range("index out of range");
 
49
        }
 
50
        return _pt[i];
 
51
    }
 
52
 
 
53
    ICoord &operator[](unsigned i) throw(std::out_of_range) {
 
54
        if ( i > Y ) {
 
55
            throw std::out_of_range("index out of range");
 
56
        }
 
57
        return _pt[i];
 
58
    }
 
59
 
 
60
    ICoord operator[](Dim2 d) const throw() { return _pt[d]; }
 
61
    ICoord &operator[](Dim2 d) throw() { return _pt[d]; }
 
62
 
 
63
    IPoint &operator+=(IPoint const &o) {
 
64
        for ( unsigned i = 0 ; i < 2 ; ++i ) {
 
65
            _pt[i] += o._pt[i];
 
66
        }
 
67
        return *this;
 
68
    }
 
69
  
 
70
    IPoint &operator-=(IPoint const &o) {
 
71
        for ( unsigned i = 0 ; i < 2 ; ++i ) {
 
72
            _pt[i] -= o._pt[i];
 
73
        }
 
74
        return *this;
 
75
    }
 
76
 
 
77
    bool operator==(IPoint const &other) const {
 
78
        return _pt[X] == other[X] && _pt[Y] == other[Y];
 
79
    }
 
80
 
 
81
    bool operator!=(IPoint const &other) const {
 
82
        return _pt[X] != other[X] || _pt[Y] != other[Y];
 
83
    }
 
84
 
 
85
private:
 
86
    ICoord _pt[2];
 
87
};
 
88
 
 
89
 
 
90
}  // namespace NR
 
91
 
 
92
#endif /* !SEEN_NR_POINT_L_H */
 
93
 
 
94
/*
 
95
  Local Variables:
 
96
  mode:c++
 
97
  c-file-style:"stroustrup"
 
98
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
99
  indent-tabs-mode:nil
 
100
  fill-column:99
 
101
  End:
 
102
*/
 
103
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :