LuciadCPillar 2023.1.03
luciad::MapNavigator::ZoomAction Class Referencefinal

Class that allows to build a zoom action and apply it, either directly or using an animation. More...

#include <luciad/maps/MapNavigator.h>

Public Member Functions

 ~ZoomAction ()
 
ZoomActionanimate (bool animated)
 Specifies if the action should use an animation. More...
 
ZoomActionduration (std::chrono::milliseconds duration)
 Specifies the duration of the animation. More...
 
ZoomActionfactor (double factor)
 Sets the zoom factor. More...
 
ZoomActiontargetScale (MapScale targetScale)
 Sets the map scale to which to zoom to. More...
 
ZoomActiontoLocation (const Point &toMapLocation)
 Sets the location (in Map coordinates) towards which the MapNavigator will zoom. More...
 
void zoom () const
 Executes the zoom action. More...
 

Detailed Description

Class that allows to build a zoom action and apply it, either directly or using an animation.

Zooming works by:

Example: zoom in 50% (2x zoom)

const auto& viewMapTransformation = map->getViewMapTransformation();
auto point = viewMapTransformation.viewToMap(Map::LocationMode::ClosestSurface, toViewLocation);
if (point) {
map->getMapNavigator().newZoomAction().toLocation(*point).factor(0.5).zoom();
}
@ ClosestSurface
Defines the view-to-map transformation mode where, for a given view point (pixels),...

Constructor & Destructor Documentation

◆ ~ZoomAction()

luciad::MapNavigator::ZoomAction::~ZoomAction ( )

Member Function Documentation

◆ animate()

ZoomAction & luciad::MapNavigator::ZoomAction::animate ( bool  animated)

Specifies if the action should use an animation.

Parameters
animatedif this action should use an animation. The default is false.
Returns
this

◆ duration()

ZoomAction & luciad::MapNavigator::ZoomAction::duration ( std::chrono::milliseconds  duration)

Specifies the duration of the animation.

This parameter is only used if animate(bool) is called with true as argument.

Parameters
durationthe duration of the animation in milliseconds. The default is 2000 (=2 seconds)
Returns
this

◆ factor()

ZoomAction & luciad::MapNavigator::ZoomAction::factor ( double  factor)

Sets the zoom factor.

A value larger than 1 will zoom out. A value between ]0, 1[ will zoom in.

For example: A zoom factor of 0.5 will move the camera twice as close to the target location. A value of 2.0 will move the camera away twice as far from the target location.

It is mandatory to set either this property, or the targetScale property. Not setting either of them will cause the ZoomAction::zoom method to throw an exception. If both methods are called, the one called last has precedence.

Parameters
factorthe zoom factor, a value between ]0, 1[ to zoom in and between ]1, +inf[ to zoom out.
Returns
this
Exceptions
luciad::InvalidArgumentExceptionif the factor value is invalid.

◆ targetScale()

ZoomAction & luciad::MapNavigator::ZoomAction::targetScale ( MapScale  targetScale)

Sets the map scale to which to zoom to.

It is mandatory to set either this property, or the factor property. Not setting either of them will cause the ZoomAction::zoom method to throw an exception. If both methods are called, the one called last has precedence.

Parameters
targetScalethe target scale to zoom to
Returns
this

◆ toLocation()

ZoomAction & luciad::MapNavigator::ZoomAction::toLocation ( const Point toMapLocation)

Sets the location (in Map coordinates) towards which the MapNavigator will zoom.

This property is mandatory. Not setting it will cause the ZoomAction::zoom method to throw an exception.

Parameters
toMapLocationa location, defined in the reference of the Map
Returns
this
Exceptions
luciad::InvalidArgumentExceptionif the toMapLocation parameter is not in the map coordinate reference.

◆ zoom()

void luciad::MapNavigator::ZoomAction::zoom ( ) const

Executes the zoom action.

Exceptions
luciad::LogicExceptionif the action is not built correctly, for example if mandatory parameters are missing, or if incompatible parameters are configured.