• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • graphics API Reference
  • KDE Home
  • Contact Us
 

digikam

  • extragear
  • graphics
  • digikam
  • core
  • libs
  • dngwriter
  • extra
  • dng_sdk
dng_rect.h
Go to the documentation of this file.
1 /*****************************************************************************/
2 // Copyright 2006-2007 Adobe Systems Incorporated
3 // All Rights Reserved.
4 //
5 // NOTICE: Adobe permits you to use, modify, and distribute this file in
6 // accordance with the terms of the Adobe license agreement accompanying it.
7 /*****************************************************************************/
8 
9 /* $Id: //mondo/dng_sdk_1_3/dng_sdk/source/dng_rect.h#1 $ */
10 /* $DateTime: 2009/06/22 05:04:49 $ */
11 /* $Change: 578634 $ */
12 /* $Author: tknoll $ */
13 
14 /*****************************************************************************/
15 
16 #ifndef __dng_rect__
17 #define __dng_rect__
18 
19 /*****************************************************************************/
20 
21 #include "dng_types.h"
22 #include "dng_point.h"
23 #include "dng_utils.h"
24 
25 /*****************************************************************************/
26 
27 class dng_rect
28  {
29 
30  public:
31 
32  int32 t;
33  int32 l;
34  int32 b;
35  int32 r;
36 
37  public:
38 
39  dng_rect ()
40  : t (0)
41  , l (0)
42  , b (0)
43  , r (0)
44  {
45  }
46 
47  dng_rect (int32 tt, int32 ll, int32 bb, int32 rr)
48  : t (tt)
49  , l (ll)
50  , b (bb)
51  , r (rr)
52  {
53  }
54 
55  dng_rect (uint32 h, uint32 w)
56  : t (0)
57  , l (0)
58  , b (h)
59  , r (w)
60  {
61  }
62 
63  dng_rect (const dng_point &size)
64  : t (0)
65  , l (0)
66  , b (size.v)
67  , r (size.h)
68  {
69  }
70 
71  void Clear ()
72  {
73  *this = dng_rect ();
74  }
75 
76  bool operator== (const dng_rect &rect) const;
77 
78  bool operator!= (const dng_rect &rect) const
79  {
80  return !(*this == rect);
81  }
82 
83  bool IsZero () const;
84 
85  bool NotZero () const
86  {
87  return !IsZero ();
88  }
89 
90  bool IsEmpty () const
91  {
92  return (t >= b) || (l >= r);
93  }
94 
95  bool NotEmpty () const
96  {
97  return !IsEmpty ();
98  }
99 
100  uint32 W () const
101  {
102  return (r >= l ? (uint32) (r - l) : 0);
103  }
104 
105  uint32 H () const
106  {
107  return (b >= t ? (uint32) (b - t) : 0);
108  }
109 
110  dng_point TL () const
111  {
112  return dng_point (t, l);
113  }
114 
115  dng_point TR () const
116  {
117  return dng_point (t, r);
118  }
119 
120  dng_point BL () const
121  {
122  return dng_point (b, l);
123  }
124 
125  dng_point BR () const
126  {
127  return dng_point (b, r);
128  }
129 
130  dng_point Size () const
131  {
132  return dng_point (H (), W ());
133  }
134 
135  real64 Diagonal () const
136  {
137  return hypot ((real64) W (),
138  (real64) H ());
139  }
140 
141  };
142 
143 /*****************************************************************************/
144 
145 class dng_rect_real64
146  {
147 
148  public:
149 
150  real64 t;
151  real64 l;
152  real64 b;
153  real64 r;
154 
155  public:
156 
157  dng_rect_real64 ()
158  : t (0.0)
159  , l (0.0)
160  , b (0.0)
161  , r (0.0)
162  {
163  }
164 
165  dng_rect_real64 (real64 tt, real64 ll, real64 bb, real64 rr)
166  : t (tt)
167  , l (ll)
168  , b (bb)
169  , r (rr)
170  {
171  }
172 
173  dng_rect_real64 (real64 h, real64 w)
174  : t (0)
175  , l (0)
176  , b (h)
177  , r (w)
178  {
179  }
180 
181  dng_rect_real64 (const dng_point_real64 &size)
182  : t (0)
183  , l (0)
184  , b (size.v)
185  , r (size.h)
186  {
187  }
188 
189  dng_rect_real64 (const dng_rect &rect)
190  : t ((real64) rect.t)
191  , l ((real64) rect.l)
192  , b ((real64) rect.b)
193  , r ((real64) rect.r)
194  {
195  }
196 
197  void Clear ()
198  {
199  *this = dng_point_real64 ();
200  }
201 
202  bool operator== (const dng_rect_real64 &rect) const;
203 
204  bool operator!= (const dng_rect_real64 &rect) const
205  {
206  return !(*this == rect);
207  }
208 
209  bool IsZero () const;
210 
211  bool NotZero () const
212  {
213  return !IsZero ();
214  }
215 
216  bool IsEmpty () const
217  {
218  return (t >= b) || (l >= r);
219  }
220 
221  bool NotEmpty () const
222  {
223  return !IsEmpty ();
224  }
225 
226  real64 W () const
227  {
228  return Max_real64 (r - l, 0.0);
229  }
230 
231  real64 H () const
232  {
233  return Max_real64 (b - t, 0.0);
234  }
235 
236  dng_point_real64 TL () const
237  {
238  return dng_point_real64 (t, l);
239  }
240 
241  dng_point_real64 TR () const
242  {
243  return dng_point_real64 (t, r);
244  }
245 
246  dng_point_real64 BL () const
247  {
248  return dng_point_real64 (b, l);
249  }
250 
251  dng_point_real64 BR () const
252  {
253  return dng_point_real64 (b, r);
254  }
255 
256  dng_point_real64 Size () const
257  {
258  return dng_point_real64 (H (), W ());
259  }
260 
261  dng_rect Round () const
262  {
263  return dng_rect (Round_int32 (t),
264  Round_int32 (l),
265  Round_int32 (b),
266  Round_int32 (r));
267  }
268 
269  real64 Diagonal () const
270  {
271  return hypot (W (), H ());
272  }
273 
274  };
275 
276 /*****************************************************************************/
277 
278 dng_rect operator& (const dng_rect &a,
279  const dng_rect &b);
280 
281 dng_rect operator| (const dng_rect &a,
282  const dng_rect &b);
283 
284 /*****************************************************************************/
285 
286 dng_rect_real64 operator& (const dng_rect_real64 &a,
287  const dng_rect_real64 &b);
288 
289 dng_rect_real64 operator| (const dng_rect_real64 &a,
290  const dng_rect_real64 &b);
291 
292 /*****************************************************************************/
293 
294 inline dng_rect operator+ (const dng_rect &a,
295  const dng_point &b)
296  {
297 
298  return dng_rect (a.t + b.v,
299  a.l + b.h,
300  a.b + b.v,
301  a.r + b.h);
302 
303  }
304 
305 /*****************************************************************************/
306 
307 inline dng_rect_real64 operator+ (const dng_rect_real64 &a,
308  const dng_point_real64 &b)
309  {
310 
311  return dng_rect_real64 (a.t + b.v,
312  a.l + b.h,
313  a.b + b.v,
314  a.r + b.h);
315 
316  }
317 
318 /*****************************************************************************/
319 
320 inline dng_rect operator- (const dng_rect &a,
321  const dng_point &b)
322  {
323 
324  return dng_rect (a.t - b.v,
325  a.l - b.h,
326  a.b - b.v,
327  a.r - b.h);
328 
329  }
330 
331 /*****************************************************************************/
332 
333 inline dng_rect_real64 operator- (const dng_rect_real64 &a,
334  const dng_point_real64 &b)
335  {
336 
337  return dng_rect_real64 (a.t - b.v,
338  a.l - b.h,
339  a.b - b.v,
340  a.r - b.h);
341 
342  }
343 
344 /*****************************************************************************/
345 
346 inline dng_rect Transpose (const dng_rect &a)
347  {
348 
349  return dng_rect (a.l, a.t, a.r, a.b);
350 
351  }
352 
353 /*****************************************************************************/
354 
355 inline dng_rect_real64 Transpose (const dng_rect_real64 &a)
356  {
357 
358  return dng_rect_real64 (a.l, a.t, a.r, a.b);
359 
360  }
361 
362 /*****************************************************************************/
363 
364 inline void HalfRect (dng_rect &rect)
365  {
366 
367  rect.r = rect.l + (rect.W () >> 1);
368  rect.b = rect.t + (rect.H () >> 1);
369 
370  }
371 
372 /*****************************************************************************/
373 
374 inline void DoubleRect (dng_rect &rect)
375  {
376 
377  rect.r = rect.l + (rect.W () << 1);
378  rect.b = rect.t + (rect.H () << 1);
379 
380  }
381 
382 /*****************************************************************************/
383 
384 inline void InnerPadRect (dng_rect &rect,
385  int32 pad)
386  {
387 
388  rect.l += pad;
389  rect.r -= pad;
390  rect.t += pad;
391  rect.b -= pad;
392 
393  }
394 
395 /*****************************************************************************/
396 
397 inline void OuterPadRect (dng_rect &rect,
398  int32 pad)
399  {
400 
401  InnerPadRect (rect, -pad);
402 
403  }
404 
405 /*****************************************************************************/
406 
407 inline void InnerPadRectH (dng_rect &rect,
408  int32 pad)
409  {
410 
411  rect.l += pad;
412  rect.r -= pad;
413 
414  }
415 
416 /*****************************************************************************/
417 
418 inline void InnerPadRectV (dng_rect &rect,
419  int32 pad)
420  {
421 
422  rect.t += pad;
423  rect.b -= pad;
424 
425  }
426 
427 /*****************************************************************************/
428 
429 inline dng_rect MakeHalfRect (const dng_rect &rect)
430  {
431 
432  dng_rect out = rect;
433 
434  HalfRect (out);
435 
436  return out;
437 
438  }
439 
440 /*****************************************************************************/
441 
442 inline dng_rect MakeDoubleRect (const dng_rect &rect)
443  {
444 
445  dng_rect out = rect;
446 
447  DoubleRect (out);
448 
449  return out;
450 
451  }
452 
453 /*****************************************************************************/
454 
455 inline dng_rect MakeInnerPadRect (const dng_rect &rect,
456  int32 pad)
457  {
458 
459  dng_rect out = rect;
460 
461  InnerPadRect (out, pad);
462 
463  return out;
464 
465  }
466 
467 /*****************************************************************************/
468 
469 #endif
470 
471 /*****************************************************************************/
dng_point
Definition: dng_point.h:26
dng_point::h
int32 h
Definition: dng_point.h:32
dng_rect::b
int32 b
Definition: dng_rect.h:34
operator-
dng_rect operator-(const dng_rect &a, const dng_point &b)
Definition: dng_rect.h:320
pad
#define pad
dng_rect::NotEmpty
bool NotEmpty() const
Definition: dng_rect.h:95
dng_rect_real64::Clear
void Clear()
Definition: dng_rect.h:197
dng_rect_real64::b
real64 b
Definition: dng_rect.h:152
dng_rect::BR
dng_point BR() const
Definition: dng_rect.h:125
dng_rect_real64::t
real64 t
Definition: dng_rect.h:150
dng_rect_real64::dng_rect_real64
dng_rect_real64()
Definition: dng_rect.h:157
dng_rect_real64::dng_rect_real64
dng_rect_real64(const dng_point_real64 &size)
Definition: dng_rect.h:181
dng_rect_real64::BL
dng_point_real64 BL() const
Definition: dng_rect.h:246
dng_rect_real64::dng_rect_real64
dng_rect_real64(real64 tt, real64 ll, real64 bb, real64 rr)
Definition: dng_rect.h:165
dng_rect_real64::BR
dng_point_real64 BR() const
Definition: dng_rect.h:251
dng_rect::TR
dng_point TR() const
Definition: dng_rect.h:115
dng_types.h
dng_rect_real64::dng_rect_real64
dng_rect_real64(real64 h, real64 w)
Definition: dng_rect.h:173
int32
signed long int32
Definition: dng_types.h:54
dng_rect_real64::Diagonal
real64 Diagonal() const
Definition: dng_rect.h:269
dng_rect_real64::TL
dng_point_real64 TL() const
Definition: dng_rect.h:236
DoubleRect
void DoubleRect(dng_rect &rect)
Definition: dng_rect.h:374
dng_rect::TL
dng_point TL() const
Definition: dng_rect.h:110
InnerPadRectH
void InnerPadRectH(dng_rect &rect, int32 pad)
Definition: dng_rect.h:407
dng_rect_real64::dng_rect_real64
dng_rect_real64(const dng_rect &rect)
Definition: dng_rect.h:189
dng_rect::NotZero
bool NotZero() const
Definition: dng_rect.h:85
dng_point.h
dng_rect::r
int32 r
Definition: dng_rect.h:35
MakeDoubleRect
dng_rect MakeDoubleRect(const dng_rect &rect)
Definition: dng_rect.h:442
real64
double real64
Definition: dng_types.h:74
dng_rect_real64::operator!=
bool operator!=(const dng_rect_real64 &rect) const
Definition: dng_rect.h:204
dng_rect::dng_rect
dng_rect(const dng_point &size)
Definition: dng_rect.h:63
dng_rect::Diagonal
real64 Diagonal() const
Definition: dng_rect.h:135
InnerPadRect
void InnerPadRect(dng_rect &rect, int32 pad)
Definition: dng_rect.h:384
dng_rect_real64
Definition: dng_rect.h:145
dng_rect::BL
dng_point BL() const
Definition: dng_rect.h:120
operator+
dng_rect operator+(const dng_rect &a, const dng_point &b)
Definition: dng_rect.h:294
HalfRect
void HalfRect(dng_rect &rect)
Definition: dng_rect.h:364
dng_rect_real64::TR
dng_point_real64 TR() const
Definition: dng_rect.h:241
dng_rect::Size
dng_point Size() const
Definition: dng_rect.h:130
dng_rect::dng_rect
dng_rect()
Definition: dng_rect.h:39
Max_real64
real64 Max_real64(real64 x, real64 y)
Definition: dng_utils.h:377
dng_point_real64
Definition: dng_point.h:63
dng_rect::operator==
bool operator==(const dng_rect &rect) const
Definition: dng_rect.cpp:22
dng_rect
Definition: dng_rect.h:27
dng_rect::Clear
void Clear()
Definition: dng_rect.h:71
dng_rect_real64::IsZero
bool IsZero() const
Definition: dng_rect.cpp:55
dng_rect_real64::NotEmpty
bool NotEmpty() const
Definition: dng_rect.h:221
dng_point_real64::h
real64 h
Definition: dng_point.h:69
dng_rect_real64::r
real64 r
Definition: dng_rect.h:153
MakeInnerPadRect
dng_rect MakeInnerPadRect(const dng_rect &rect, int32 pad)
Definition: dng_rect.h:455
dng_rect::dng_rect
dng_rect(int32 tt, int32 ll, int32 bb, int32 rr)
Definition: dng_rect.h:47
dng_point::v
int32 v
Definition: dng_point.h:31
dng_rect::IsEmpty
bool IsEmpty() const
Definition: dng_rect.h:90
dng_rect::dng_rect
dng_rect(uint32 h, uint32 w)
Definition: dng_rect.h:55
Round_int32
int32 Round_int32(real32 x)
Definition: dng_utils.h:407
MakeHalfRect
dng_rect MakeHalfRect(const dng_rect &rect)
Definition: dng_rect.h:429
dng_rect::l
int32 l
Definition: dng_rect.h:33
dng_rect_real64::H
real64 H() const
Definition: dng_rect.h:231
dng_rect_real64::NotZero
bool NotZero() const
Definition: dng_rect.h:211
operator|
dng_rect operator|(const dng_rect &a, const dng_rect &b)
Definition: dng_rect.cpp:89
Transpose
dng_rect Transpose(const dng_rect &a)
Definition: dng_rect.h:346
dng_rect_real64::Round
dng_rect Round() const
Definition: dng_rect.h:261
InnerPadRectV
void InnerPadRectV(dng_rect &rect, int32 pad)
Definition: dng_rect.h:418
dng_rect::H
uint32 H() const
Definition: dng_rect.h:105
dng_utils.h
dng_rect_real64::Size
dng_point_real64 Size() const
Definition: dng_rect.h:256
operator&
dng_rect operator&(const dng_rect &a, const dng_rect &b)
Definition: dng_rect.cpp:64
uint32
unsigned long uint32
Definition: dng_types.h:63
OuterPadRect
void OuterPadRect(dng_rect &rect, int32 pad)
Definition: dng_rect.h:397
dng_rect_real64::IsEmpty
bool IsEmpty() const
Definition: dng_rect.h:216
dng_rect::t
int32 t
Definition: dng_rect.h:32
dng_rect::operator!=
bool operator!=(const dng_rect &rect) const
Definition: dng_rect.h:78
dng_rect_real64::operator==
bool operator==(const dng_rect_real64 &rect) const
Definition: dng_rect.cpp:43
dng_rect::W
uint32 W() const
Definition: dng_rect.h:100
dng_rect_real64::l
real64 l
Definition: dng_rect.h:151
dng_rect_real64::W
real64 W() const
Definition: dng_rect.h:226
dng_point_real64::v
real64 v
Definition: dng_point.h:68
dng_rect::IsZero
bool IsZero() const
Definition: dng_rect.cpp:34
b
long b
Definition: 62/jpegint.h:371
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Tue Dec 10 2019 04:05:29 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

digikam

Skip menu "digikam"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages
-->

graphics API Reference

Skip menu "graphics API Reference"
  • digikam
  • KDiagram
  •     KChart
  •     KGantt
  • KPhotoAlbum
  •   AndroidRemoteControl
  • Krita
  •   libs
  •     KritaBasicFlakes
  •     brush
  •     KritaUndo2
  •     KritaFlake
  •     image
  •     KritaPlugin
  •     Krita
  •     KritaOdf
  •     KritaPigment
  •     KritaStore
  •     ui
  •     KritaWidgets
  •     KritaWidgetUtils
  •   plugins
  •     Assitants
  •     Extensions
  •     Filters
  •         KritaText
  •         KritaTextLayout
  •     Generators
  •     Formats
  •             src
  •     PaintOps
  •       libpaintop
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal