/usr/include/plotmm/doublerect.h is in libplotmm-dev 0.1.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Plot Widget Library
* Copyright (C) 2004 Andy Thaller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the LGPL
*****************************************************************************/
/* ported from qwt */
#ifndef PLOTMM_DOUBLE_RECT_H
#define PLOTMM_DOUBLE_RECT_H
namespace Gdk {
class Point;
}
namespace PlotMM {
/*! @brief Class defining a point in double coordinates
*/
class DoublePoint
{
public:
DoublePoint();
DoublePoint(double x, double y);
DoublePoint(const Gdk::Point &);
inline bool is_null() const;
inline double get_x() const;
inline double get_y() const;
inline void set_x(double x);
inline void set_y(double y);
bool operator==(const DoublePoint &) const;
bool operator!=(const DoublePoint &) const;
const DoublePoint operator-() const;
const DoublePoint operator+(const DoublePoint &) const;
const DoublePoint operator-(const DoublePoint &) const;
const DoublePoint operator*(double) const;
const DoublePoint operator/(double) const;
DoublePoint &operator+=(const DoublePoint &);
DoublePoint &operator-=(const DoublePoint &);
DoublePoint &operator*=(double);
DoublePoint &operator/=(double);
private:
double d_x;
double d_y;
};
/*! @brief Class defining a size in double coordinates
*/
class DoubleSize
{
public:
DoubleSize();
DoubleSize(double width, double height);
// DoubleSize(const QSize &);
inline bool is_null() const;
inline bool is_empty() const;
inline bool is_valid() const;
inline double get_width() const;
inline double get_height() const;
inline void set_width( double w );
inline void set_height( double h );
void transpose();
DoubleSize expanded_to(const DoubleSize &) const;
DoubleSize bounded_to(const DoubleSize &) const;
bool operator==(const DoubleSize &) const;
bool operator!=(const DoubleSize &) const;
const DoubleSize operator-() const;
const DoubleSize operator+(const DoubleSize &) const;
const DoubleSize operator-(const DoubleSize &) const;
const DoubleSize operator*(double) const;
const DoubleSize operator/(double) const;
DoubleSize &operator+=(const DoubleSize &);
DoubleSize &operator-=(const DoubleSize &);
DoubleSize &operator*=(double c);
DoubleSize &operator/=(double c);
private:
double d_width;
double d_height;
};
/*! @brief Class defining a size in double coordinates.
*/
class DoubleRect
{
public:
DoubleRect();
DoubleRect(double x1, double x2, double y1, double y2);
DoubleRect(double x, double y, const DoubleSize &);
inline bool is_null() const;
inline bool is_empty() const;
inline bool is_valid() const;
DoubleRect normalize() const;
inline double get_x1() const;
inline double get_x2() const;
inline double get_y1() const;
inline double get_y2() const;
inline void set_x1(double);
inline void set_x2(double);
inline void set_y1(double);
inline void set_y2(double);
DoublePoint center() const;
void move_x(double x);
void move_y(double y );
void move(double x, double y);
void move_by(double dx, double dy);
void move_center(const DoublePoint &);
void move_center(double dx, double dy);
void set_rect(double x1, double x2, double y1, double y2);
inline double get_width() const;
inline double get_height() const;
inline DoubleSize size() const;
inline void set_width(double w );
inline void set_height(double h );
void set_size(const DoubleSize &);
DoubleRect operator|(const DoubleRect &r) const;
DoubleRect operator&(const DoubleRect &r) const;
DoubleRect &operator|=(const DoubleRect &r);
DoubleRect &operator&=(const DoubleRect &r);
bool operator==( const DoubleRect &) const;
bool operator!=( const DoubleRect &) const;
bool contains(const DoublePoint &p, bool proper = false) const;
bool contains(double x, double y, bool proper = false) const;
bool contains(const DoubleRect &r, bool proper=false) const;
DoubleRect unite(const DoubleRect &) const;
DoubleRect intersect(const DoubleRect &) const;
bool intersects(const DoubleRect &) const;
private:
double d_x1;
double d_x2;
double d_y1;
double d_y2;
};
/*!
* Returns TRUE if both the x value and the y value are 0;
* otherwise returns false.
*/
inline bool DoublePoint::is_null() const
{
return d_x == 0.0 && d_y == 0.0;
}
//! Returns the x coordinate of the point.
inline double DoublePoint::get_x() const
{
return d_x;
}
//! Returns the y coordinate of the point.
inline double DoublePoint::get_y() const
{
return d_y;
}
//! Sets the x coordinate of the point to x.
inline void DoublePoint::set_x(double x)
{
d_x = x;
}
//! Sets the y coordinate of the point to x.
inline void DoublePoint::set_y(double y)
{
d_y = y;
}
/*!
* Returns TRUE if the width is 0 and the height is 0;
* otherwise returns false.
*/
inline bool DoubleSize::is_null() const
{
return d_width == 0.0 && d_height == 0.0;
}
/*!
* Returns TRUE if the width is <= 0 or the height is <= 0,
* otherwise false.
*/
inline bool DoubleSize::is_empty() const
{
return d_width <= 0.0 || d_height <= 0.0;
}
/*
* Returns TRUE if the width is equal to or greater than 0 and the height
* is equal to or greater than 0; otherwise returns false.
*/
inline bool DoubleSize::is_valid() const
{
return d_width >= 0.0 && d_height >= 0.0;
}
//! Returns the width.
inline double DoubleSize::get_width() const
{
return d_width;
}
//! Returns the height.
inline double DoubleSize::get_height() const
{
return d_height;
}
//! Sets the width to width.
inline void DoubleSize::set_width(double width)
{
d_width = width;
}
//! Sets the height to height.
inline void DoubleSize::set_height(double height)
{
d_height = height;
}
/*!
* Returns TRUE if the rectangle is a null rectangle;
* otherwise returns false.
*
* A rect is null when x1() == x2() && y1() == y2().
*/
inline bool DoubleRect::is_null() const
{
return d_x2 == d_x1 && d_y2 == d_y1;
}
/*!
* Returns TRUE if the rectangle is a empty rectangle;
* otherwise returns false.
*
* A rect is null when x1() >= x2() && y1() >= y2().
*/
inline bool DoubleRect::is_empty() const
{
return d_x1 >= d_x2 || d_y1 >= d_y2;
}
/*!
* Returns TRUE if the rectangle is a valid rectangle;
* otherwise returns false.
*
* A rect is valid when x1() <= x2() && y1() <= y2().
*/
inline bool DoubleRect::is_valid() const
{
return d_x1 <= d_x2 && d_y1 <= d_y2;
}
//! Returns x1
inline double DoubleRect::get_x1() const
{
return d_x1;
}
//! Returns x2
inline double DoubleRect::get_x2() const
{
return d_x2;
}
//! Returns y1
inline double DoubleRect::get_y1() const
{
return d_y1;
}
//! Returns y2
inline double DoubleRect::get_y2() const
{
return d_y2;
}
//! Set x1
inline void DoubleRect::set_x1(double x1)
{
d_x1 = x1;
}
//! Set x2
inline void DoubleRect::set_x2(double x2)
{
d_x2 = x2;
}
//! Set y1
inline void DoubleRect::set_y1(double y1)
{
d_y1 = y1;
}
//! Set y2
inline void DoubleRect::set_y2(double y2)
{
d_y2 = y2;
}
//! Returns the width
inline double DoubleRect::get_width() const
{
return d_x2 - d_x1;
}
//! Returns the height
inline double DoubleRect::get_height() const
{
return d_y2 - d_y1;
}
//! Returns the size
inline DoubleSize DoubleRect::size() const
{
return DoubleSize(get_width(), get_height());
}
//! Set the width, by x2 = x1 + w;
inline void DoubleRect::set_width(double w)
{
d_x2 = d_x1 + w;
}
//! Set the height, by y2 = y1 + h;
inline void DoubleRect::set_height(double h)
{
d_y2 = d_y1 + h;
}
}
#endif // PLOT_DOUBLE_RECT_H
|