Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-11 09:17:33

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 { return NCollection_Vec2<float>(Left, Top); }
0032 
0033   //! Top-left corner as vec2.
0034   NCollection_Vec2<float>& TopLeft(NCollection_Vec2<float>& theVec) const
0035   {
0036     theVec.x() = Left;
0037     theVec.y() = Top;
0038     return theVec;
0039   }
0040 
0041   //! Top-right corner as vec2.
0042   NCollection_Vec2<float>& TopRight(NCollection_Vec2<float>& theVec) const
0043   {
0044     theVec.x() = Right;
0045     theVec.y() = Top;
0046     return theVec;
0047   }
0048 
0049   //! Bottom-left corner as vec2.
0050   NCollection_Vec2<float>& BottomLeft(NCollection_Vec2<float>& theVec) const
0051   {
0052     theVec.x() = Left;
0053     theVec.y() = Bottom;
0054     return theVec;
0055   }
0056 
0057   //! Bottom-right corner as vec2.
0058   NCollection_Vec2<float>& BottomRight(NCollection_Vec2<float>& theVec) const
0059   {
0060     theVec.x() = Right;
0061     theVec.y() = Bottom;
0062     return theVec;
0063   }
0064 
0065   //! Rectangle width.
0066   float Width() const { return Right - Left; }
0067 
0068   //! Rectangle height.
0069   float Height() const { return Top - Bottom; }
0070 
0071   //! Dumps the content of me into the stream
0072   void DumpJson(Standard_OStream& theOStream, int) const
0073   {
0074     OCCT_DUMP_CLASS_BEGIN(theOStream, Font_Rect)
0075 
0076     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Left)
0077     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Right)
0078     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Top)
0079     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Bottom)
0080   }
0081 };
0082 
0083 #endif // _Font_Rect_H__