|
Darwin Neuroevolution Framework
|
A reusable canvas with support for logical coordinates and auto-scalling the content. More...
#include <canvas.h>
Public Member Functions | |
| Canvas (QWidget *parent) | |
| Creates a new Canvas. | |
| int | borderSize () const |
| Border size value (in pixels) | |
| void | setBorderSize (int border_size) |
| Sets a new border size (pixels) | |
| const QRectF & | viewport () const |
| Current viewport rectangle (in logical coordinates) | |
| void | setViewport (const QRectF &viewport_rect) |
| Sets the viewport rectangle (logical coordinates) More... | |
| void | setViewport (const QPointF &top_left, const QPointF &bottom_right) |
| Sets the viewport rectangle. More... | |
| const QTransform & | transformFromViewport () const |
| Logical viewport coordinates to client window coordinates. | |
| const QTransform & | transformToViewport () const |
| Client window coordinates to logical viewport coordinates. | |
| double | scale () const |
| Returns the current scale factor. | |
A reusable canvas with support for logical coordinates and auto-scalling the content.
Once the logical viewport rectangle is defined, this class maintains the transformations to/from logical viewport coordinates such that the entire viewport is always visible.
Canvas supports both orientations of the y-axis:
Using coordinates with y "pointing up" requires extra care, see Canvas::setViewport()
| void core_ui::Canvas::setViewport | ( | const QRectF & | viewport_rect | ) |
Sets the viewport rectangle (logical coordinates)
In order to use the traditional Cartesian coordinates, with the y-axis pointing up, the height of the viewport rectangle should have a negative value. The top_left viewport corner should still use the top y coordinate. For example, in order to define a (0,0) -> (10,5) viewport you would call:
| void core_ui::Canvas::setViewport | ( | const QPointF & | top_left, |
| const QPointF & | bottom_right | ||
| ) |
Sets the viewport rectangle.
1.8.14