LuciadCPillar 2023.1.04
luciad::MapNavigator::PanAction Class Referencefinal

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

#include <luciad/maps/MapNavigator.h>

Public Member Functions

 ~PanAction ()
 
PanActionanimate (bool animated)
 Specifies if the action should use an animation. More...
 
PanActionduration (std::chrono::milliseconds duration)
 Specifies the duration of the animation. More...
 
PanActionfrom (const Point &fromMapLocation)
 Sets the Map location (i.e. More...
 
PanActionfromViewLocation (Coordinate fromViewLocation)
 Sets the location in view (device independent pixel) coordinates from which the pan action will start. More...
 
void pan () const
 Executes the pan action by moving the 'from' Map location (PanAction::from or PanAction::fromViewLocation) to the location in view (device independent pixels) coordinates (PanAction::toLocation). More...
 
PanActiontoLocation (const Coordinate &toViewLocation)
 Executes the pan action by moving the 'from' Map location (PanAction::from or PanAction::fromViewLocation) to the given location in view (device independent pixel) coordinates. More...
 

Detailed Description

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

Panning works by

  • 'grabbing' a point on the map: see from
  • defining where that point ends up after the pan operation: see toLocation

Example of an immediate pan action:

const auto& viewMapTransformation = map->getViewMapTransformation();
auto mapPoint = viewMapTransformation.viewToMap(Map::LocationMode::ClosestSurface, fromLocationPixels);
if (mapPoint) {
map->getMapNavigator().newPanAction().from(*mapPoint).toLocation(toLocationPixels).pan();
}
@ ClosestSurface
Defines the view-to-map transformation mode where, for a given view point (pixels),...

Example of an incremental pan action (for example based on a mouse drag):

const auto& viewMapTransformation = map->getViewMapTransformation();
auto point = viewMapTransformation.viewToMap(Map::LocationMode::ClosestSurface, fromViewLocation);
if (point) {
panAction = map->getMapNavigator().newPanAction().from(*point);
// When a drag event arrives
panAction->toLocation({event.x, event.y, 0}).pan();
// When another drag event arrives
panAction->toLocation({event.x, event.y, 0}).pan();
// When the drag gesture stops: cleanup
panAction.reset();
}
void pan() const
Executes the pan action by moving the 'from' Map location (PanAction::from or PanAction::fromViewLoca...
PanAction & fromViewLocation(Coordinate fromViewLocation)
Sets the location in view (device independent pixel) coordinates from which the pan action will start...

Constructor & Destructor Documentation

◆ ~PanAction()

luciad::MapNavigator::PanAction::~PanAction ( )

Member Function Documentation

◆ animate()

PanAction & luciad::MapNavigator::PanAction::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()

PanAction & luciad::MapNavigator::PanAction::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

◆ from()

PanAction & luciad::MapNavigator::PanAction::from ( const Point fromMapLocation)

Sets the Map location (i.e.

a coordinate defined in Map::getReference) from which the pan action will start. This point will be moved to a new view location when the pan action is executed.

Setting the from location is mandatory. Make sure to call either this method or the fromViewLocation method. Not setting the from location will cause the PanAction::pan method to throw an exception. When it is set more than once, only the last call to one of the 'from' methods will be taken into account.

Parameters
fromMapLocationa point defined in the reference of the Map
Returns
this
Exceptions
luciad::InvalidArgumentExceptionif the from location is not set in the map coordinate reference.

◆ fromViewLocation()

PanAction & luciad::MapNavigator::PanAction::fromViewLocation ( Coordinate  fromViewLocation)

Sets the location in view (device independent pixel) coordinates from which the pan action will start.

This point on the map that corresponds to this view location will be moved to a new view location when the pan action is executed.

Additionally, when using this method the panning behavior will be slightly different compared to when using the from method: when using a point near the horizon, the movement of the camera will be limited to prevent very large changes to it.

If no point on the map corresponds to this view location, the pan action will have no effect.

Setting the from location is mandatory. Make sure to call either this method or the from method. Not setting the from location will cause the PanAction::pan method to throw an exception. When it is set more than once, only the last call to one of the 'from' methods will be taken into account.

Parameters
fromViewLocationthe location in view (device independent pixel) coordinates from which the pan action will start.
Returns
this
Since
2023.0

◆ pan()

void luciad::MapNavigator::PanAction::pan ( ) const

Executes the pan action by moving the 'from' Map location (PanAction::from or PanAction::fromViewLocation) to the location in view (device independent pixels) coordinates (PanAction::toLocation).

If PanAction::animate is called with true as argument, this method will start a pan animation.

It is possible to call this method multiple times with different parameters. This allows to start a pan session. A pan session is useful, for example, when navigating using the mouse, for example using a drag gesture.

See MapNavigator::PanAction for an example usage.

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

◆ toLocation()

PanAction & luciad::MapNavigator::PanAction::toLocation ( const Coordinate toViewLocation)

Executes the pan action by moving the 'from' Map location (PanAction::from or PanAction::fromViewLocation) to the given location in view (device independent pixel) coordinates.

If PanAction::animate is called with true as argument, this method will start a pan animation.

Parameters
toViewLocationa location in view (device independent pixel) coordinates