Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:30

0001 // Created by: Kirill GAVRILOV
0002 // Copyright (c) 2013-2015 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _Font_Rect_H__
0016 #define _Font_Rect_H__
0017 
0018 #include <NCollection_Vec2.hxx>
0019 #include <Standard_Dump.hxx>
0020 
0021 //! Auxiliary POD structure - 2D rectangle definition.
0022 struct Font_Rect
0023 {
0024 
0025   float Left;   //!< left   position
0026   float Right;  //!< right  position
0027   float Top;    //!< top    position
0028   float Bottom; //!< bottom position
0029 
0030   //! Top-left corner as vec2.
0031   NCollection_Vec2<float> TopLeft() const
0032   {
0033     return NCollection_Vec2<float> (Left, Top);
0034   }
0035 
0036   //! Top-left corner as vec2.
0037   NCollection_Vec2<float>& TopLeft (NCollection_Vec2<float>& theVec) const
0038   {
0039     theVec.x() = Left;
0040     theVec.y() = Top;
0041     return theVec;
0042   }
0043 
0044   //! Top-right corner as vec2.
0045   NCollection_Vec2<float>& TopRight (NCollection_Vec2<float>& theVec) const
0046   {
0047     theVec.x() = Right;
0048     theVec.y() = Top;
0049     return theVec;
0050   }
0051 
0052   //! Bottom-left corner as vec2.
0053   NCollection_Vec2<float>& BottomLeft (NCollection_Vec2<float>& theVec) const
0054   {
0055     theVec.x() = Left;
0056     theVec.y() = Bottom;
0057     return theVec;
0058   }
0059 
0060   //! Bottom-right corner as vec2.
0061   NCollection_Vec2<float>& BottomRight (NCollection_Vec2<float>& theVec) const
0062   {
0063     theVec.x() = Right;
0064     theVec.y() = Bottom;
0065     return theVec;
0066   }
0067 
0068   //! Rectangle width.
0069   float Width() const
0070   {
0071     return Right - Left;
0072   }
0073 
0074   //! Rectangle height.
0075   float Height() const
0076   {
0077     return Top - Bottom;
0078   }
0079 
0080   //! Dumps the content of me into the stream
0081   void DumpJson (Standard_OStream& theOStream, Standard_Integer) const
0082   {
0083     OCCT_DUMP_CLASS_BEGIN (theOStream, Font_Rect)
0084 
0085     OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Left)
0086     OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Right)
0087     OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Top)
0088     OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Bottom)
0089   }
0090 };
0091 
0092 #endif // _Font_Rect_H__