50c598a8ddab62eb7d6bed435093cacbec5912e7
[occt.git] / src / Font / Font_Rect.hxx
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>
19
20 //! Auxiliary POD structure - 2D rectangle definition.
21 struct Font_Rect
22 {
23
24   float Left;   //!< left   position
25   float Right;  //!< right  position
26   float Top;    //!< top    position
27   float Bottom; //!< bottom position
28
29   //! Top-left corner as vec2.
30   NCollection_Vec2<float> TopLeft() const
31   {
32     return NCollection_Vec2<float> (Left, Top);
33   }
34
35   //! Top-left corner as vec2.
36   NCollection_Vec2<float>& TopLeft (NCollection_Vec2<float>& theVec) const
37   {
38     theVec.x() = Left;
39     theVec.y() = Top;
40     return theVec;
41   }
42
43   //! Top-right corner as vec2.
44   NCollection_Vec2<float>& TopRight (NCollection_Vec2<float>& theVec) const
45   {
46     theVec.x() = Right;
47     theVec.y() = Top;
48     return theVec;
49   }
50
51   //! Bottom-left corner as vec2.
52   NCollection_Vec2<float>& BottomLeft (NCollection_Vec2<float>& theVec) const
53   {
54     theVec.x() = Left;
55     theVec.y() = Bottom;
56     return theVec;
57   }
58
59   //! Bottom-right corner as vec2.
60   NCollection_Vec2<float>& BottomRight (NCollection_Vec2<float>& theVec) const
61   {
62     theVec.x() = Right;
63     theVec.y() = Bottom;
64     return theVec;
65   }
66
67   //! Rectangle width.
68   float Width() const
69   {
70     return Right - Left;
71   }
72
73   //! Rectangle height.
74   float Height() const
75   {
76     return Top - Bottom;
77   }
78
79 };
80
81 #endif // _Font_Rect_H__