source: ntrip/trunk/BNC/qwt/qwt_point_3d.h@ 10220

Last change on this file since 10220 was 8127, checked in by stoecker, 7 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

File size: 3.9 KB
Line 
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/*! \file */
11#ifndef QWT_POINT_3D_H
12#define QWT_POINT_3D_H 1
13
14#include "qwt_global.h"
15#include <qpoint.h>
16#ifndef QT_NO_DEBUG_STREAM
17#include <qdebug.h>
18#endif
19
20/*!
21 \brief QwtPoint3D class defines a 3D point in double coordinates
22*/
23
24class QWT_EXPORT QwtPoint3D
25{
26public:
27 QwtPoint3D();
28 QwtPoint3D( double x, double y, double z );
29 QwtPoint3D( const QwtPoint3D & );
30 QwtPoint3D( const QPointF & );
31
32 bool isNull() const;
33
34 double x() const;
35 double y() const;
36 double z() const;
37
38 double &rx();
39 double &ry();
40 double &rz();
41
42 void setX( double x );
43 void setY( double y );
44 void setZ( double y );
45
46 QPointF toPoint() const;
47
48 bool operator==( const QwtPoint3D & ) const;
49 bool operator!=( const QwtPoint3D & ) const;
50
51private:
52 double d_x;
53 double d_y;
54 double d_z;
55};
56
57Q_DECLARE_TYPEINFO(QwtPoint3D, Q_MOVABLE_TYPE);
58
59#ifndef QT_NO_DEBUG_STREAM
60QWT_EXPORT QDebug operator<<( QDebug, const QwtPoint3D & );
61#endif
62
63/*!
64 Constructs a null point.
65 \sa isNull()
66*/
67inline QwtPoint3D::QwtPoint3D():
68 d_x( 0.0 ),
69 d_y( 0.0 ),
70 d_z( 0.0 )
71{
72}
73
74//! Constructs a point with coordinates specified by x, y and z.
75inline QwtPoint3D::QwtPoint3D( double x, double y, double z = 0.0 ):
76 d_x( x ),
77 d_y( y ),
78 d_z( z )
79{
80}
81
82/*!
83 Copy constructor.
84 Constructs a point using the values of the point specified.
85*/
86inline QwtPoint3D::QwtPoint3D( const QwtPoint3D &other ):
87 d_x( other.d_x ),
88 d_y( other.d_y ),
89 d_z( other.d_z )
90{
91}
92
93/*!
94 Constructs a point with x and y coordinates from a 2D point,
95 and a z coordinate of 0.
96*/
97inline QwtPoint3D::QwtPoint3D( const QPointF &other ):
98 d_x( other.x() ),
99 d_y( other.y() ),
100 d_z( 0.0 )
101{
102}
103
104/*!
105 \return True if the point is null; otherwise returns false.
106
107 A point is considered to be null if x, y and z-coordinates
108 are equal to zero.
109*/
110inline bool QwtPoint3D::isNull() const
111{
112 return d_x == 0.0 && d_y == 0.0 && d_z == 0.0;
113}
114
115//! \return The x-coordinate of the point.
116inline double QwtPoint3D::x() const
117{
118 return d_x;
119}
120
121//! \return The y-coordinate of the point.
122inline double QwtPoint3D::y() const
123{
124 return d_y;
125}
126
127//! \return The z-coordinate of the point.
128inline double QwtPoint3D::z() const
129{
130 return d_z;
131}
132
133//! \return A reference to the x-coordinate of the point.
134inline double &QwtPoint3D::rx()
135{
136 return d_x;
137}
138
139//! \return A reference to the y-coordinate of the point.
140inline double &QwtPoint3D::ry()
141{
142 return d_y;
143}
144
145//! \return A reference to the z-coordinate of the point.
146inline double &QwtPoint3D::rz()
147{
148 return d_z;
149}
150
151//! Sets the x-coordinate of the point to the value specified by x.
152inline void QwtPoint3D::setX( double x )
153{
154 d_x = x;
155}
156
157//! Sets the y-coordinate of the point to the value specified by y.
158inline void QwtPoint3D::setY( double y )
159{
160 d_y = y;
161}
162
163//! Sets the z-coordinate of the point to the value specified by z.
164inline void QwtPoint3D::setZ( double z )
165{
166 d_z = z;
167}
168
169/*!
170 \return 2D point, where the z coordinate is dropped.
171*/
172inline QPointF QwtPoint3D::toPoint() const
173{
174 return QPointF( d_x, d_y );
175}
176
177//! \return True, if this point and other are equal; otherwise returns false.
178inline bool QwtPoint3D::operator==( const QwtPoint3D &other ) const
179{
180 return ( d_x == other.d_x ) && ( d_y == other.d_y ) && ( d_z == other.d_z );
181}
182
183//! \return True if this rect and other are different; otherwise returns false.
184inline bool QwtPoint3D::operator!=( const QwtPoint3D &other ) const
185{
186 return !operator==( other );
187}
188
189#endif
Note: See TracBrowser for help on using the repository browser.