VisioMove-Sample  2.1.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Pages
VgMyStackedLayerAndCameraHandler Class Reference

Controls the camera & the Layer display. More...

Inheritance diagram for VgMyStackedLayerAndCameraHandler:
Inheritance graph

Public Types

enum  VgMyConfigurableParam {
  eFarAwayHeight, eStackViewHeading, eStackViewPitch, eLayerMaxSize,
  eStackViewDistance, eLayerDistance, eLayerDistanceFromCurrent, eAnimateToDetailCameraDuration,
  eAnimateToGlobalCameraDuration, eAnimateToGlobalLayerDuration, eAnimateToDetailLayerDuration, eAnimateChangeOfLayerDuration,
  eAnimateCancelPinchDuration, eAnimateCancelDragDuration, eAnimateMaxViewPointDuration, eChangeLayerTriggerThreshold,
  eStackNonActiveLayerAngle, eStackActiveLayerAngle, eMaxDoubleParams
}
 The below enum represents parameters that can be configured to change the behaviour of the VgMyStackedLayerAndCameraHandler object. More...
 
enum  eFromToViewEnum { eFromStackToDetailedView, eFromDetailedToStackView, eFromGlobalToGlobaView }
 
typedef enum
VgMyStackedLayerAndCameraHandler::VgMyConfigurableParam 
VgMyConfigurableParam
 The below enum represents parameters that can be configured to change the behaviour of the VgMyStackedLayerAndCameraHandler object. More...
 

Public Member Functions

 VgMyStackedLayerAndCameraHandler (VgApplication::VgIApplication *pVgApplication, VgMyLayerAndCameraListener *pListener, unsigned int pViewWidthInPixels, unsigned int pViewHeightInPixels)
 
virtual ~VgMyStackedLayerAndCameraHandler ()
 
bool isGlobalView ()
 
void switchToGlobalView (bool pIsAnimated=true)
 Switches from the detailledView to the global view. More...
 
void switchToDetailedView (bool pIsAnimated=true)
 Switches from the global to the detailled view. More...
 
const std::string & getFocusedLayerName ()
 Gets the focused layer's name. More...
 
void gotoLayer (const std::string &pLayerName, bool pIsAnimated=true)
 Focus a specific layer. More...
 
unsigned int getNumberOfLayers ()
 Returns the number of layers. More...
 
bool getLayerName (const unsigned int pLayerIndex, std::string &pLayerNameOut)
 Returns the layer name for a given indes. More...
 
void gotoLayer (const unsigned int pLayerIndex, bool pIsAnimated=true)
 Focus a specific layer. More...
 
void gotoViewpoint (const VgEngine::VgIViewPoint &pViewpoint, const std::string &pLayerName, bool pIsAnimated=true)
 Moves the camera to a specific view point. More...
 
void gotoLookAtPosition (const VgEngine::VgPosition &pPosition, const std::string &pLayerName, bool pIsAnimated=true)
 Moves the camera so that it is focused on a given position. More...
 
void refreshParameters (unsigned int pWidth, unsigned int pHeight)
 Refreshes the inner parameters. More...
 
unsigned int getWidth ()
 Retrieves the map view's width. More...
 
unsigned int getHeight ()
 Retrieves the map view's height. More...
 
unsigned int getCurrentLayerIndex () const
 
VgEngine::VgPosition * getCameraPosition ()
 
void onLayerSelected ()
 
void onSelectorReady ()
 
void animateCameraToViewPoint (const VgEngine::VgIViewPoint &pViewPoint, float pDuration, bool pIsAnimated)
 
void animateLayersFromCloseToStackView (eFromToViewEnum pDirection, float pDuration, bool pIsAnimated)
 
VgEngine::VgPosition getPositionForLayerInGlobalView (unsigned int pLayerIndex, unsigned int pFocusedLayer)
 Gets the position for a layer when in global view. More...
 
VgEngine::VgPosition getPositionForLayerInDetailedView (unsigned int pLayerIndex, unsigned int pFocusedLayer)
 Gets the position for a layer when in detailed view. More...
 
void animateLayerToPositionAndRotation (VgEngine::VgRefPtr< VgEngine::VgLayer >const &pLayer, const VgEngine::VgPosition &pStartPos, const VgEngine::VgPosition &pEndPos, VgEngine::VgRefPtr< VgEngine::VgIAnimationCallback >const &pCallback, float pDuration, float pStartAngle, float pEndAngle)
 Gets the position for a layer when in detailed view. More...
 
VgEngine::VgIViewPoint & getStackViewPoint ()
 
void setStackCenterPosition (const VgEngine::VgPosition &pCenter)
 Sets the stack center position. More...
 
const VgEngine::VgPosition & getStackCenter ()
 Get the stack center. More...
 
void refreshStackView ()
 Force the global stack view to redraw it self. More...
 
void setParam (const VgMyConfigurableParam pParam, const double pDouble)
 Allows application to customise the look and feel of the VgMyStackedLayerAndCameraHandler. More...
 
double getParam (const VgMyConfigurableParam pParam)
 Retrieve a parameter value. More...
 
void updateManipulatorForGlobalView (bool pIsGlobalView)
 Updates the manipulator, according to the stack state. More...
 

Static Public Member Functions

static double computeAngularDistance (double pA, double pB)
 Computes the angular distance between two angle values in degrees. More...
 

Protected Member Functions

VgEngine::VgRefPtr
< VgEngine::VgIAnimationCallback > 
registerCallback (VgEngine::VgRefPtr< VgEngine::VgIAnimationCallback > pCallback, unsigned int pLayerIndex)
 
void setDefaultStackParams ()
 
void calculateDynamicStackParams ()
 
void gotoLayerInGlobalView (const unsigned int pLayerIndex, bool pIsAnimated)
 
void gotoLayerInDetailedView (const unsigned int pLayerIndex, bool pIsAnimated)
 

Protected Attributes

bool mSetFovOnce
 
bool mUsePinchToSwitchGlobalToDetailed
 
VgApplication::VgIApplication * mVgApplication
 
VgMyLayerAndCameraListenermLayerUpdateListener
 
unsigned int mCurrentLayerIndex
 
unsigned int mPreviousLayerIndex
 
bool mIsLayerStackDisplayed
 
bool mIsViewModeInitialized
 
VgEngine::VgIViewPoint mCamStartViewPoint
 
double mParam [eMaxDoubleParams]
 
VgEngine::VgPosition mStackCenter
 
VgEngine::VgIViewPoint mCameraGlobalViewPoint
 
VgEngine::VgRefPtr
< VgEngine::VgIAnimationCallback > 
mCameraCallback
 
std::vector
< VgEngine::VgRefPtr
< VgEngine::VgIAnimationCallback > > 
mLayersCallback
 
VgEngine::VgRefPtr
< FloorSelectorManipulator
mManipulatorListener
 
std::hash_map< std::string, float > mLODsFactors
 
std::hash_map< std::string, float > mLoadFactors
 
unsigned int mViewSize [2]
 

Detailed Description

Controls the camera & the Layer display.

This helper simplifies the management of the camera wihtin a stack of layer. This layers are usually floors.

IMPLEMENTATION TIPS: This is an advanced class. You can customize it at will to change its behavior or get some inspiration to build other eye-candy display & behavior for your layers (carousel for example) This would require knowledge in 3D mathematics.

Member Typedef Documentation

The below enum represents parameters that can be configured to change the behaviour of the VgMyStackedLayerAndCameraHandler object.

Member Enumeration Documentation

Enumerator
eFromStackToDetailedView 
eFromDetailedToStackView 
eFromGlobalToGlobaView 

The below enum represents parameters that can be configured to change the behaviour of the VgMyStackedLayerAndCameraHandler object.

Enumerator
eFarAwayHeight 

This distance will be applied to the layers which are neighbouring the current layers when in detailed view.

eStackViewHeading 

Heading used when the stack is displayed.

Note: The default heading comes from "yaw" attribute of the "camera" tag within the bundles configuration file.

eStackViewPitch 

Pitch used when the stack is displayed.

eLayerMaxSize 

The maximum distance (meters) across the dataset.

Setting this parameter will automatically reset the following parameters:

  • eStackViewDistance
  • eLayerDistance
  • eLayerDistanceFromCurrent Note the default max size is calculated from the limits of the dataset indicated by the bundles configuration file.
eStackViewDistance 

Distance between the camera and the layer stack.

Note: This param will be re-calculated automatically given the following conditions

  • when eLayerMaxSize is set.
  • when the refreshParameters(pWidth, pHeight) is called.

When this value is calculated automatically, the camera will be displaced just far enough away to ensure that the width of the eLayerMaxSize will fit within the available view width.

eLayerDistance 

Distance between layers (except ones around the current)

Note: This param will be re-calculated automatically given the following conditions

  • when eLayerMaxSize is set.
  • when the refreshParameters(pWidth, pHeight) is called.
eLayerDistanceFromCurrent 

Distance between layers around the current.

Note: This param will be re-calculated automatically given the following conditions

  • when eLayerMaxSize is set.
  • when the refreshParameters(pWidth, pHeight) is called.
eAnimateToDetailCameraDuration 

Duration of of camera animation when moving to detailed view.

Note : camera animation duration must be <= layer animation duration due to the manipulator change at the end of layers animation.

eAnimateToGlobalCameraDuration 

Duration of camera animation when moving to global view (seconds).

eAnimateToGlobalLayerDuration 

Duration of layer animation when moving to global view (seconds).

eAnimateToDetailLayerDuration 

See note assocated with eAnimateToDetailCameraDuration to see restrictions associated with this value (seconds).

eAnimateChangeOfLayerDuration 

Duration of animation when changing layer within the global view (seconds).

eAnimateCancelPinchDuration 

Duration of animation when cancelling a pinch gesture (seconds).

eAnimateCancelDragDuration 

Duration of animation when cancelling a drag gesture (seconds).

eAnimateMaxViewPointDuration 

Limits the maximum possible duration when animating to a view point.

eChangeLayerTriggerThreshold 

This threshold determines how long a drag is required in the global stack view before the current layer is changed.

Measured as a percentage value [0.0 - 1.0] of the views pixel.

eStackNonActiveLayerAngle 

Angle on stack view for non active layer (in degrees)

eStackActiveLayerAngle 

Angle on stack view for non active layer (in degrees)

eMaxDoubleParams 

DO NOT USE.

Constructor & Destructor Documentation

VgMyStackedLayerAndCameraHandler::VgMyStackedLayerAndCameraHandler ( VgApplication::VgIApplication *  pVgApplication,
VgMyLayerAndCameraListener pListener,
unsigned int  pViewWidthInPixels,
unsigned int  pViewHeightInPixels 
)
virtual VgMyStackedLayerAndCameraHandler::~VgMyStackedLayerAndCameraHandler ( )
virtual

Member Function Documentation

void VgMyStackedLayerAndCameraHandler::animateCameraToViewPoint ( const VgEngine::VgIViewPoint &  pViewPoint,
float  pDuration,
bool  pIsAnimated 
)
void VgMyStackedLayerAndCameraHandler::animateLayersFromCloseToStackView ( eFromToViewEnum  pDirection,
float  pDuration,
bool  pIsAnimated 
)
void VgMyStackedLayerAndCameraHandler::animateLayerToPositionAndRotation ( VgEngine::VgRefPtr< VgEngine::VgLayer >const &  pLayer,
const VgEngine::VgPosition &  pStartPos,
const VgEngine::VgPosition &  pEndPos,
VgEngine::VgRefPtr< VgEngine::VgIAnimationCallback >const &  pCallback,
float  pDuration,
float  pStartAngle,
float  pEndAngle 
)

Gets the position for a layer when in detailed view.

Parameters
pLayerpointer to layer to manipulate
pStartPosstarting position of layer. If not the same as its current position it will jump.
pEndPosending position of layer.
pCallbackcallback at end of animation.
pDurationduration of animation in seconds.
pStartAnglestart angle of layer, used for carrousel mode, otherwise use 0.0f
pEndAnglestart angle of layer, used for carrousel mode, otherwise use 0.0f
void VgMyStackedLayerAndCameraHandler::calculateDynamicStackParams ( )
protected
static double VgMyStackedLayerAndCameraHandler::computeAngularDistance ( double  pA,
double  pB 
)
static

Computes the angular distance between two angle values in degrees.

Takes the 360 degrees periodicity into account.

Parameters
pAThe first angle (in degrees).
pBThe second angle (in degrees).
Returns
The angular distance between the two angles (in [0, 180]).
VgEngine::VgPosition* VgMyStackedLayerAndCameraHandler::getCameraPosition ( )
unsigned int VgMyStackedLayerAndCameraHandler::getCurrentLayerIndex ( ) const
const std::string& VgMyStackedLayerAndCameraHandler::getFocusedLayerName ( )
virtual

Gets the focused layer's name.

The "focused" layer is the one that is displayed in the detailled view. if the global view is displayed, the focused layer should be the most visible one.

Returns
The focused layer's name.

Implements VgMyLayerAndCameraHandler.

unsigned int VgMyStackedLayerAndCameraHandler::getHeight ( )
virtual

Retrieves the map view's height.

Implements VgMyLayerAndCameraHandler.

bool VgMyStackedLayerAndCameraHandler::getLayerName ( const unsigned int  pLayerIndex,
std::string &  pLayerNameOut 
)
virtual

Returns the layer name for a given indes.

Parameters
pLayerIndexLayer index, should be less than getNumberOfLayers().
pLayerNameOutstring to set with layer name.
Returns
true if name was set, false if pLayerIndex is greater or equal to getNumberOfLayers().

Implements VgMyLayerAndCameraHandler.

unsigned int VgMyStackedLayerAndCameraHandler::getNumberOfLayers ( )
virtual

Returns the number of layers.

Implements VgMyLayerAndCameraHandler.

double VgMyStackedLayerAndCameraHandler::getParam ( const VgMyConfigurableParam  pParam)

Retrieve a parameter value.

VgEngine::VgPosition VgMyStackedLayerAndCameraHandler::getPositionForLayerInDetailedView ( unsigned int  pLayerIndex,
unsigned int  pFocusedLayer 
)

Gets the position for a layer when in detailed view.

Parameters
pLayerIndexThe index of the layer whose position is to be calculated
pFocusedLayerLayer The index of the layer which currently has the stacked view focus.
Returns
The position for the requested layer.
VgEngine::VgPosition VgMyStackedLayerAndCameraHandler::getPositionForLayerInGlobalView ( unsigned int  pLayerIndex,
unsigned int  pFocusedLayer 
)

Gets the position for a layer when in global view.

Parameters
pLayerIndexThe index of the layer whose position is to be calculated
pFocusedLayerLayer The index of the layer which currently has the stacked view focus.
Returns
The position for the requested layer.
const VgEngine::VgPosition& VgMyStackedLayerAndCameraHandler::getStackCenter ( )

Get the stack center.

VgEngine::VgIViewPoint& VgMyStackedLayerAndCameraHandler::getStackViewPoint ( )
unsigned int VgMyStackedLayerAndCameraHandler::getWidth ( )
virtual

Retrieves the map view's width.

Implements VgMyLayerAndCameraHandler.

void VgMyStackedLayerAndCameraHandler::gotoLayer ( const std::string &  pLayerName,
bool  pIsAnimated = true 
)
virtual

Focus a specific layer.

Parameters
pLayerNameLayer that will be focused. keeps current mode.
pIsAnimatedIf true then animates the transition, otherwise does not.

Implements VgMyLayerAndCameraHandler.

void VgMyStackedLayerAndCameraHandler::gotoLayer ( const unsigned int  pLayerIndex,
bool  pIsAnimated = true 
)
virtual

Focus a specific layer.

Parameters
pLayerIndexLayer index which is associated with the returned list given by VgLayerManager::getLayers(). keeps current mode.
pIsAnimatedIf true then animates the transition, otherwise does not.

Implements VgMyLayerAndCameraHandler.

void VgMyStackedLayerAndCameraHandler::gotoLayerInDetailedView ( const unsigned int  pLayerIndex,
bool  pIsAnimated 
)
protected
void VgMyStackedLayerAndCameraHandler::gotoLayerInGlobalView ( const unsigned int  pLayerIndex,
bool  pIsAnimated 
)
protected
void VgMyStackedLayerAndCameraHandler::gotoLookAtPosition ( const VgEngine::VgPosition &  pPosition,
const std::string &  pLayerName,
bool  pIsAnimated = true 
)
virtual

Moves the camera so that it is focused on a given position.

The camera's view, heading, pitch are always conserved. The altitude of pPosition is automatically set to zero.

If the pLayerName isn't the currently focused layer, then before any camera movement is invoked, pLayerName becomes the focused layer.

Note
If the stack is in global view, the camera will not change.
Parameters
pPositionThe position to focus on.
pLayerNameThe name of the layer associated with the position.
pIsAnimatedIf true then animates the transition, otherwise does not.

Implements VgMyLayerAndCameraHandler.

void VgMyStackedLayerAndCameraHandler::gotoViewpoint ( const VgEngine::VgIViewPoint &  pViewPoint,
const std::string &  pLayerName,
bool  pIsAnimated = true 
)
virtual

Moves the camera to a specific view point.

If the pLayerName isn't the currently focused layer, then before any camera movement is invoked, pLayerName becomes the focused layer.

Note
If the stack is in global view, the camera will not change.
Parameters
pViewPointThe view point to associate with the camera
pLayerNameThe layer which should be given the focus.
pIsAnimatedIf true then animates the transition, otherwise does not.

Implements VgMyLayerAndCameraHandler.

bool VgMyStackedLayerAndCameraHandler::isGlobalView ( )
virtual
Returns
TRUE if the Handler displays the global view. FALSE if displaying the detailed view.

Implements VgMyLayerAndCameraHandler.

void VgMyStackedLayerAndCameraHandler::onLayerSelected ( )
void VgMyStackedLayerAndCameraHandler::onSelectorReady ( )
void VgMyStackedLayerAndCameraHandler::refreshParameters ( unsigned int  pWidth,
unsigned int  pHeight 
)
virtual

Refreshes the inner parameters.

Typically, subclasses can use it to recompute their view parameters when the rendering size changes.

Implements VgMyLayerAndCameraHandler.

void VgMyStackedLayerAndCameraHandler::refreshStackView ( )

Force the global stack view to redraw it self.

Needs to be called after having changed any of the configurable parameters.

VgEngine::VgRefPtr< VgEngine::VgIAnimationCallback > VgMyStackedLayerAndCameraHandler::registerCallback ( VgEngine::VgRefPtr< VgEngine::VgIAnimationCallback >  pCallback,
unsigned int  pLayerIndex 
)
protected
void VgMyStackedLayerAndCameraHandler::setDefaultStackParams ( )
protected
void VgMyStackedLayerAndCameraHandler::setParam ( const VgMyConfigurableParam  pParam,
const double  pDouble 
)

Allows application to customise the look and feel of the VgMyStackedLayerAndCameraHandler.

Parameters
pParamThe parameter to be set. Please see the VgMyConfigurableParam type to gain an understanding of what each configurable parameter is responsible for.
pDoubleThe value to be set.
Note
If parameters are changed via this method, then it is necessary to call refreshStackView() in order for the global stack view to be updated to reflect the new values.
void VgMyStackedLayerAndCameraHandler::setStackCenterPosition ( const VgEngine::VgPosition &  pCenter)

Sets the stack center position.

The stack center position is shared by all the layer that make up the stack.

void VgMyStackedLayerAndCameraHandler::switchToDetailedView ( bool  pIsAnimated = true)
virtual

Switches from the global to the detailled view.

Do nothing if alrady in detailled view.

Parameters
pIsAnimatedIf true then animates the transition, otherwise does not.

Implements VgMyLayerAndCameraHandler.

void VgMyStackedLayerAndCameraHandler::switchToGlobalView ( bool  pIsAnimated = true)
virtual

Switches from the detailledView to the global view.

Do nothing if already in global view.

Parameters
pIsAnimatedIf true then animates the transition, otherwise does not.

Implements VgMyLayerAndCameraHandler.

void VgMyStackedLayerAndCameraHandler::updateManipulatorForGlobalView ( bool  pIsGlobalView)

Updates the manipulator, according to the stack state.

Parameters
pIsGlobalViewTrue if the stack state is currently the global view. False if the the stack state is detailed view.

Member Data Documentation

VgEngine::VgRefPtr< VgEngine::VgIAnimationCallback > VgMyStackedLayerAndCameraHandler::mCameraCallback
protected
VgEngine::VgIViewPoint VgMyStackedLayerAndCameraHandler::mCameraGlobalViewPoint
protected
VgEngine::VgIViewPoint VgMyStackedLayerAndCameraHandler::mCamStartViewPoint
protected
unsigned int VgMyStackedLayerAndCameraHandler::mCurrentLayerIndex
protected
bool VgMyStackedLayerAndCameraHandler::mIsLayerStackDisplayed
protected
bool VgMyStackedLayerAndCameraHandler::mIsViewModeInitialized
protected
std::vector<VgEngine::VgRefPtr< VgEngine::VgIAnimationCallback > > VgMyStackedLayerAndCameraHandler::mLayersCallback
protected
VgMyLayerAndCameraListener* VgMyStackedLayerAndCameraHandler::mLayerUpdateListener
protected
std::hash_map<std::string, float> VgMyStackedLayerAndCameraHandler::mLoadFactors
protected
std::hash_map<std::string, float> VgMyStackedLayerAndCameraHandler::mLODsFactors
protected
VgEngine::VgRefPtr< FloorSelectorManipulator > VgMyStackedLayerAndCameraHandler::mManipulatorListener
protected
double VgMyStackedLayerAndCameraHandler::mParam[eMaxDoubleParams]
protected
unsigned int VgMyStackedLayerAndCameraHandler::mPreviousLayerIndex
protected
bool VgMyStackedLayerAndCameraHandler::mSetFovOnce
protected
VgEngine::VgPosition VgMyStackedLayerAndCameraHandler::mStackCenter
protected
bool VgMyStackedLayerAndCameraHandler::mUsePinchToSwitchGlobalToDetailed
protected
VgApplication::VgIApplication* VgMyStackedLayerAndCameraHandler::mVgApplication
protected
unsigned int VgMyStackedLayerAndCameraHandler::mViewSize[2]
protected

The documentation for this class was generated from the following file:
VisioMove 2.1.3, Visioglobe® 2015