.. _custom-navigation-tutorial:

########################################################################################
Visualization: Create a Custom Navigation Handler to Support a Custom Navigation Scheme
########################################################################################

.. image:: ../images/tut_customnavigation.png
    :height: 300
    :align: center

The cee::vis::Camera has an input handler that handles user input (mouse and keyboard events) and manipulates 
the camera based on these events. This is used to move the camera around the scene to inspect the model.

|ProductName| provides two default Input Handlers:

-   :class:`cee::vis::CameraInputHandlerZoom`: Envision style zoom navigation. This is the default navigation handler.
-   :class:`cee::vis::CameraInputHandlerWalk`: Envision style walk navigation.  

In this tutorial we will show how to create a custom navigation scheme by subclassing the 
:class:`cee::vis::CameraInputHandler`.

.. note::
    This tutorial expect the application to have a correctly configured :class:`cee::vis::View`
    in place. See the demo applications on how to set up a :class:`cee::vis::View` in your application.


**Create the custom input handler**

Create a class that derives from cee::vis::CameraInputHandler and override the two following methods:

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/CustomNavigation.cpp
    :language: cpp
    :lines: 39-72

The :func:`navigationTypeFromInputState() <cee::vis::CameraInputHandler::navigationTypeFromInputState>` method should 
return the wanted navigation type (PAN, ROTATE, WALK, ZOOM) based on the mouse and keyboard input state.

The :func:`wheelNavigationType() <cee::vis::CameraInputHandler::wheelNavigationType>` determines the use of the mouse 
wheel. Usually WALK or ZOOM.

**Use the custom input handler**

Use of the new input handler by setting it as the input handler for the current camera.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/CustomNavigation.cpp
    :language: cpp
    :lines: 80-81

Then, create a model to demonstrate the new navigation scheme. Here we use the GeometryModel.

.. literalinclude:: ../../../../EnvisionDesktop/Tutorials/CustomNavigation.cpp
    :language: cpp
    :lines: 89-113

**See the complete source code here:**

:ref:`custom-navigation-example`

