1 // Copyright (c) 2016 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Graphic3d_CameraTile_HeaderFile
15 #define _Graphic3d_CameraTile_HeaderFile
17 #include <Graphic3d_Vec2.hxx>
18 #include <Standard_Integer.hxx>
19 #include <Standard_TypeDef.hxx>
21 //! Class defines the area (Tile) inside a view.
22 class Graphic3d_CameraTile
26 Graphic3d_Vec2i TotalSize; //!< total size of the View area, in pixels
27 Graphic3d_Vec2i TileSize; //!< size of the Tile, in pixels
28 Graphic3d_Vec2i Offset; //!< the lower-left corner of the Tile relative to the View area (or upper-left if IsTopDown is true), in pixels
29 bool IsTopDown; //!< indicate the offset coordinate system - lower-left (default) or top-down
33 //! Default constructor.
34 //! Initializes the empty Tile of zero size and lower-left offset orientation.
35 //! Such Tile is considered uninitialized (invalid).
36 Graphic3d_CameraTile() : IsTopDown (false) {}
38 //! Return true if Tile has been defined.
41 return TotalSize.x() > 0 && TotalSize.y() > 0
42 && TileSize.x() > 0 && TileSize.y() > 0;
45 //! Return offset position from lower-left corner.
46 Graphic3d_Vec2i OffsetLowerLeft() const
48 return Graphic3d_Vec2i (Offset.x(),
51 : TotalSize.y() - Offset.y() - 1);
54 //! Return the copy cropped by total size
55 Graphic3d_CameraTile Cropped() const
57 Graphic3d_CameraTile aTile = *this;
63 aTile.Offset.x() = Max (Offset.x(), 0);
64 aTile.Offset.y() = Max (Offset.y(), 0);
66 const Standard_Integer anX = Min (Offset.x() + TileSize.x(), TotalSize.x());
67 const Standard_Integer anY = Min (Offset.y() + TileSize.y(), TotalSize.y());
68 aTile.TileSize.x() = anX - Offset.x();
69 aTile.TileSize.y() = anY - Offset.y();
74 bool operator== (const Graphic3d_CameraTile& theOther) const
76 const Graphic3d_Vec2i anOffset1 = OffsetLowerLeft();
77 const Graphic3d_Vec2i anOffset2 = theOther.OffsetLowerLeft();
78 return TotalSize.x() == theOther.TotalSize.x()
79 && TotalSize.y() == theOther.TotalSize.y()
80 && TileSize.x() == theOther.TileSize.x()
81 && TileSize.y() == theOther.TileSize.y()
82 && anOffset1.x() == anOffset2.x()
83 && anOffset1.y() == anOffset2.y();
88 #endif // _Graphic3d_CameraTile_HeaderFile