iLand
Public Member Functions | List of all members
Viewport Class Reference

Handles coordinaive transforation between grids (based on real-world metric coordinates). More...

#include <viewport.h>

Public Member Functions

 Viewport ()
 
 Viewport (const QRectF worldrect, const QRect screenrect)
 
const QPointF toWorld (const QPoint pixel)
 toWorld() converts the pixel-information (e.g. by an mouse event) to the corresponding real world coordinates (defined by viewport). More...
 
const QPoint toScreen (const QPointF p)
 toScreen() converts world coordinates in screen coordinates using the defined viewport. More...
 
const QRect toScreen (const QRectF world)
 
const QRectF viewRect () const
 
bool isVisible (const QPointF &world_coord) const
 
bool isVisible (const QRectF &world_rect) const
 
void zoomToAll ()
 show the full extent of the world. More...
 
void zoomTo (const QPoint &screen_point, const double factor)
 zoom using a factor of factor. More...
 
void moveTo (const QPoint &screen_from, const QPoint &screen_to)
 move the viewport. screen_from and screen_to give mouse positions (in pixel) from dragging the mouse. More...
 
void setViewPoint (const QPointF &world_center, const double px_per_meter)
 set 'world_center' as the new center point of the viewport More...
 
double pixelToMeter (const int pixel)
 
int meterToPixel (const double meter)
 
void setViewRect (const QRectF &viewrect)
 
void setWorldRect (const QRectF &worldrect)
 
void setScreenRect (const QRect &viewrect)
 sets the screen rect; this also modifies the viewport. More...
 

Detailed Description

Handles coordinaive transforation between grids (based on real-world metric coordinates).

The visible part of the grid is defined by the "viewport" (defaults to 100% of the grid). The result coordinates are mapped into a "ScreenRect", which is a pixel-based viewing window.

Constructor & Destructor Documentation

◆ Viewport() [1/2]

Viewport::Viewport ( )
inline

◆ Viewport() [2/2]

Viewport::Viewport ( const QRectF  worldrect,
const QRect  screenrect 
)
inline

Member Function Documentation

◆ isVisible() [1/2]

bool Viewport::isVisible ( const QPointF &  world_coord) const

◆ isVisible() [2/2]

bool Viewport::isVisible ( const QRectF &  world_rect) const

◆ meterToPixel()

int Viewport::meterToPixel ( const double  meter)
inline

◆ moveTo()

void Viewport::moveTo ( const QPoint &  screen_from,
const QPoint &  screen_to 
)

move the viewport. screen_from and screen_to give mouse positions (in pixel) from dragging the mouse.

◆ pixelToMeter()

double Viewport::pixelToMeter ( const int  pixel)
inline

◆ setScreenRect()

void Viewport::setScreenRect ( const QRect &  viewrect)

sets the screen rect; this also modifies the viewport.

◆ setViewPoint()

void Viewport::setViewPoint ( const QPointF &  world_center,
const double  px_per_meter 
)

set 'world_center' as the new center point of the viewport

◆ setViewRect()

void Viewport::setViewRect ( const QRectF &  viewrect)
inline

◆ setWorldRect()

void Viewport::setWorldRect ( const QRectF &  worldrect)
inline

◆ toScreen() [1/2]

const QPoint Viewport::toScreen ( const QPointF  p)

toScreen() converts world coordinates in screen coordinates using the defined viewport.

◆ toScreen() [2/2]

const QRect Viewport::toScreen ( const QRectF  world)
inline

◆ toWorld()

const QPointF Viewport::toWorld ( const QPoint  pixel)

toWorld() converts the pixel-information (e.g. by an mouse event) to the corresponding real world coordinates (defined by viewport).

◆ viewRect()

const QRectF Viewport::viewRect ( ) const
inline

◆ zoomTo()

void Viewport::zoomTo ( const QPoint &  screen_point,
const double  factor 
)

zoom using a factor of factor.

Values > 1 means zoom out, < 1 zoom in. (factor=1 would have no effect). after zooming, the world-point under the mouse screen_point is still under the mouse.

◆ zoomToAll()

void Viewport::zoomToAll ( )

show the full extent of the world.


The documentation for this class was generated from the following files: