d2eddacc |
1 | // Created by: Kirill GAVRILOV |
2 | // Copyright (c) 2013-2015 OPEN CASCADE SAS |
3 | // |
4 | // This file is part of Open CASCADE Technology software library. |
5 | // |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
11 | // |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
14 | |
15 | #ifndef _Font_Rect_H__ |
16 | #define _Font_Rect_H__ |
17 | |
18 | #include <NCollection_Vec2.hxx> |
bc73b006 |
19 | #include <Standard_Dump.hxx> |
d2eddacc |
20 | |
21 | //! Auxiliary POD structure - 2D rectangle definition. |
22 | struct Font_Rect |
23 | { |
24 | |
25 | float Left; //!< left position |
26 | float Right; //!< right position |
27 | float Top; //!< top position |
28 | float Bottom; //!< bottom position |
29 | |
30 | //! Top-left corner as vec2. |
31 | NCollection_Vec2<float> TopLeft() const |
32 | { |
33 | return NCollection_Vec2<float> (Left, Top); |
34 | } |
35 | |
36 | //! Top-left corner as vec2. |
37 | NCollection_Vec2<float>& TopLeft (NCollection_Vec2<float>& theVec) const |
38 | { |
39 | theVec.x() = Left; |
40 | theVec.y() = Top; |
41 | return theVec; |
42 | } |
43 | |
44 | //! Top-right corner as vec2. |
45 | NCollection_Vec2<float>& TopRight (NCollection_Vec2<float>& theVec) const |
46 | { |
47 | theVec.x() = Right; |
48 | theVec.y() = Top; |
49 | return theVec; |
50 | } |
51 | |
52 | //! Bottom-left corner as vec2. |
53 | NCollection_Vec2<float>& BottomLeft (NCollection_Vec2<float>& theVec) const |
54 | { |
55 | theVec.x() = Left; |
56 | theVec.y() = Bottom; |
57 | return theVec; |
58 | } |
59 | |
60 | //! Bottom-right corner as vec2. |
61 | NCollection_Vec2<float>& BottomRight (NCollection_Vec2<float>& theVec) const |
62 | { |
63 | theVec.x() = Right; |
64 | theVec.y() = Bottom; |
65 | return theVec; |
66 | } |
67 | |
68 | //! Rectangle width. |
69 | float Width() const |
70 | { |
71 | return Right - Left; |
72 | } |
73 | |
74 | //! Rectangle height. |
75 | float Height() const |
76 | { |
77 | return Top - Bottom; |
78 | } |
79 | |
bc73b006 |
80 | //! Dumps the content of me into the stream |
81 | void DumpJson (Standard_OStream& theOStream, Standard_Integer) const |
82 | { |
83 | OCCT_DUMP_CLASS_BEGIN (theOStream, Font_Rect) |
84 | |
85 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Left) |
86 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Right) |
87 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Top) |
88 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Bottom) |
89 | } |
d2eddacc |
90 | }; |
91 | |
92 | #endif // _Font_Rect_H__ |