1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtCore module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QLINE_H
|
---|
43 | #define QLINE_H
|
---|
44 |
|
---|
45 | #include <QtCore/qpoint.h>
|
---|
46 |
|
---|
47 | QT_BEGIN_HEADER
|
---|
48 |
|
---|
49 | QT_BEGIN_NAMESPACE
|
---|
50 |
|
---|
51 | QT_MODULE(Core)
|
---|
52 |
|
---|
53 | /*******************************************************************************
|
---|
54 | * class QLine
|
---|
55 | *******************************************************************************/
|
---|
56 |
|
---|
57 | class Q_CORE_EXPORT QLine
|
---|
58 | {
|
---|
59 | public:
|
---|
60 | inline QLine();
|
---|
61 | inline QLine(const QPoint &pt1, const QPoint &pt2);
|
---|
62 | inline QLine(int x1, int y1, int x2, int y2);
|
---|
63 |
|
---|
64 | inline bool isNull() const;
|
---|
65 |
|
---|
66 | inline QPoint p1() const;
|
---|
67 | inline QPoint p2() const;
|
---|
68 |
|
---|
69 | inline int x1() const;
|
---|
70 | inline int y1() const;
|
---|
71 |
|
---|
72 | inline int x2() const;
|
---|
73 | inline int y2() const;
|
---|
74 |
|
---|
75 | inline int dx() const;
|
---|
76 | inline int dy() const;
|
---|
77 |
|
---|
78 | inline void translate(const QPoint &p);
|
---|
79 | inline void translate(int dx, int dy);
|
---|
80 |
|
---|
81 | inline QLine translated(const QPoint &p) const;
|
---|
82 | inline QLine translated(int dx, int dy) const;
|
---|
83 |
|
---|
84 | inline void setP1(const QPoint &p1);
|
---|
85 | inline void setP2(const QPoint &p2);
|
---|
86 | inline void setPoints(const QPoint &p1, const QPoint &p2);
|
---|
87 | inline void setLine(int x1, int y1, int x2, int y2);
|
---|
88 |
|
---|
89 | inline bool operator==(const QLine &d) const;
|
---|
90 | inline bool operator!=(const QLine &d) const { return !(*this == d); }
|
---|
91 |
|
---|
92 | private:
|
---|
93 | QPoint pt1, pt2;
|
---|
94 | };
|
---|
95 | Q_DECLARE_TYPEINFO(QLine, Q_MOVABLE_TYPE);
|
---|
96 |
|
---|
97 | /*******************************************************************************
|
---|
98 | * class QLine inline members
|
---|
99 | *******************************************************************************/
|
---|
100 |
|
---|
101 | inline QLine::QLine() { }
|
---|
102 |
|
---|
103 | inline QLine::QLine(const QPoint &pt1_, const QPoint &pt2_) : pt1(pt1_), pt2(pt2_) { }
|
---|
104 |
|
---|
105 | inline QLine::QLine(int x1pos, int y1pos, int x2pos, int y2pos) : pt1(QPoint(x1pos, y1pos)), pt2(QPoint(x2pos, y2pos)) { }
|
---|
106 |
|
---|
107 | inline bool QLine::isNull() const
|
---|
108 | {
|
---|
109 | return pt1 == pt2;
|
---|
110 | }
|
---|
111 |
|
---|
112 | inline int QLine::x1() const
|
---|
113 | {
|
---|
114 | return pt1.x();
|
---|
115 | }
|
---|
116 |
|
---|
117 | inline int QLine::y1() const
|
---|
118 | {
|
---|
119 | return pt1.y();
|
---|
120 | }
|
---|
121 |
|
---|
122 | inline int QLine::x2() const
|
---|
123 | {
|
---|
124 | return pt2.x();
|
---|
125 | }
|
---|
126 |
|
---|
127 | inline int QLine::y2() const
|
---|
128 | {
|
---|
129 | return pt2.y();
|
---|
130 | }
|
---|
131 |
|
---|
132 | inline QPoint QLine::p1() const
|
---|
133 | {
|
---|
134 | return pt1;
|
---|
135 | }
|
---|
136 |
|
---|
137 | inline QPoint QLine::p2() const
|
---|
138 | {
|
---|
139 | return pt2;
|
---|
140 | }
|
---|
141 |
|
---|
142 | inline int QLine::dx() const
|
---|
143 | {
|
---|
144 | return pt2.x() - pt1.x();
|
---|
145 | }
|
---|
146 |
|
---|
147 | inline int QLine::dy() const
|
---|
148 | {
|
---|
149 | return pt2.y() - pt1.y();
|
---|
150 | }
|
---|
151 |
|
---|
152 | inline void QLine::translate(const QPoint &point)
|
---|
153 | {
|
---|
154 | pt1 += point;
|
---|
155 | pt2 += point;
|
---|
156 | }
|
---|
157 |
|
---|
158 | inline void QLine::translate(int adx, int ady)
|
---|
159 | {
|
---|
160 | this->translate(QPoint(adx, ady));
|
---|
161 | }
|
---|
162 |
|
---|
163 | inline QLine QLine::translated(const QPoint &p) const
|
---|
164 | {
|
---|
165 | return QLine(pt1 + p, pt2 + p);
|
---|
166 | }
|
---|
167 |
|
---|
168 | inline QLine QLine::translated(int adx, int ady) const
|
---|
169 | {
|
---|
170 | return translated(QPoint(adx, ady));
|
---|
171 | }
|
---|
172 |
|
---|
173 | inline void QLine::setP1(const QPoint &aP1)
|
---|
174 | {
|
---|
175 | pt1 = aP1;
|
---|
176 | }
|
---|
177 |
|
---|
178 | inline void QLine::setP2(const QPoint &aP2)
|
---|
179 | {
|
---|
180 | pt2 = aP2;
|
---|
181 | }
|
---|
182 |
|
---|
183 | inline void QLine::setPoints(const QPoint &aP1, const QPoint &aP2)
|
---|
184 | {
|
---|
185 | pt1 = aP1;
|
---|
186 | pt2 = aP2;
|
---|
187 | }
|
---|
188 |
|
---|
189 | inline void QLine::setLine(int aX1, int aY1, int aX2, int aY2)
|
---|
190 | {
|
---|
191 | pt1 = QPoint(aX1, aY1);
|
---|
192 | pt2 = QPoint(aX2, aY2);
|
---|
193 | }
|
---|
194 |
|
---|
195 | inline bool QLine::operator==(const QLine &d) const
|
---|
196 | {
|
---|
197 | return pt1 == d.pt1 && pt2 == d.pt2;
|
---|
198 | }
|
---|
199 |
|
---|
200 | #ifndef QT_NO_DEBUG_STREAM
|
---|
201 | Q_CORE_EXPORT QDebug operator<<(QDebug d, const QLine &p);
|
---|
202 | #endif
|
---|
203 |
|
---|
204 | #ifndef QT_NO_DATASTREAM
|
---|
205 | Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QLine &);
|
---|
206 | Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QLine &);
|
---|
207 | #endif
|
---|
208 |
|
---|
209 | /*******************************************************************************
|
---|
210 | * class QLineF
|
---|
|
---|