/*****************************************************************************
 * $LastChangedDate: 2010-04-14 13:55:46 -0400 (Wed, 14 Apr 2010) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Keyboard-controlled manipulator (OSG specific).
 *//*
 * LEGAL:   COPYRIGHT (C) 2009 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef VIEW_MANIPULATOR_KEYBOARD_HH
#define VIEW_MANIPULATOR_KEYBOARD_HH 1

#include "math/types_trig.hh"
using namespace math;
#include "view/manipulator.hh"

namespace view {

////////////////////////////////////////////////////////////////////////////////
/// @brief Keyboard-controlled manipulator (OSG specific).
///
/// Manipulates viewpoint using keyboard.
/// Cursor/PageUp/Down : move viewpoint
/// Shift-Cursor       : rotation viewpoint
///
class KeyboardManipulator : public Manipulator
{
public:
                            KeyboardManipulator( void );
    virtual                 ~KeyboardManipulator();

// OSG-specific:
    virtual void            home( double currentTime );
    virtual void            home( const osgGA::GUIEventAdapter& event, osgGA::GUIActionAdapter& action );
    virtual bool            handle( const osgGA::GUIEventAdapter& event, osgGA::GUIActionAdapter& action );
    virtual void            setByMatrix( const osg::Matrixd& matrix );
    virtual osg::Matrixd    getMatrix( void ) const /*suppress checks.sh*/;
    virtual void            setByInverseMatrix( const osg::Matrixd& matrix );
    virtual osg::Matrixd    getInverseMatrix( void ) const /*suppress checks.sh*/;

private:
    void                    RestoreMatrix( const Matrix& srcMatrix );
    void                    MoveLeftRightOrYaw( const int sign, const bool modifier );
    void                    MoveForwardBackwardOrPitch( const int sign, const bool modifier );
    void                    MoveUpDown( const int sign );

private:
    Matrix          mMatrix;            ///< view-matrix
    Matrix          mMatrixDefault;     ///< view-matrix
    Matrix          mMatrixSaved;       ///< saved view-matrix
    const Radian    mYawRad;            ///< rotation
    const Radian    mPitchRad;          ///< rotation
    const fp        mStep;              ///< translation
};

} // namespace view

#endif // VIEW_MANIPULATOR_KEYBOARD_HH
