GL Studio Safety Critical Embedded C++ Runtime Library
gls_input_manager.h
Go to the documentation of this file.
1#ifndef _GLS_INPUT_MANAGER_H
2#define _GLS_INPUT_MANAGER_H
3
4/*! \file gls_input_manager.h
5\brief This header defines the Input Manager class for managing user input
6 in the GL Studio DO-178B Runtime Library.
7
8\par Copyright Information
9Copyright (C) 1999-2012 The DiSTI Corporation<br>
10Orlando, FL USA<br>
11All rights reserved.<br>
12
13 This file is copyrighted software and contains proprietary trade secrets of
14DiSTI, and embodies substantial creative efforts as well as confidential
15information, ideas, and expressions.
16
17 Permission to use, and copy this software and its documentation for any
18purpose is hereby granted per the Distribution Agreement and/or the Licensing
19Agreement signed with DiSTI. This permission is granted provided that:
20 1. The above copyright notice appears in all copies.
21 2. That both the copyright notice and this permission notice appear in
22 the supporting documentation.
23 3. That the names DiSTI and GL Studio not be used in advertising or
24 publicity pertaining to distribution of the software without specific,
25 written prior permission of DiSTI.
26
27 Permission to modify the software is granted, but not the right to
28distribute the source code whether modified, or non-modified. Modifying the
29software might invalidate the DO-178B certification package.
30
31 Permission to distribute binaries produced by compiling source code, or
32modified source code is granted, provided you:
33 1. Provide your name and address as the primary contact for the support
34 of your modified version.
35 2. Retain our contact information in regard to use of the base software.
36
37 DiSTI does not provide warranty for this software or guarantee that it
38satisfies any specification or requirement unless otherwise stated in a
39specific contractual arrangement between the customer and DiSTI.
40
41*/
42
43#include "gls_include.h"
44#include "gls_types.h"
46#include "gls_display_object.h"
47#include "gls_class_invariant.h"
48
49/** This class manages user input.
50 * \invariant GLMatrixAffineFIsValid( _projMatrix )
51 * GLMatrixAffineFIsValid( _modelMatrix )
52 */
54{
55public:
57
58 /** describes a rectangular render viewport */
59 struct Viewport
60 {
61 GlsInt32 x; /**< x coord of lower left corner in pixels */
62 GlsInt32 y; /**< y coord of lower left corner in pixels */
63 GlsUInt32 width; /**< width of viewport in pixels */
64 GlsUInt32 height; /**< height of viewport in pixels */
65 };
66
67 /** initialization parameters for a GlsInputManager */
69 {
70 const Viewport viewport; /**< initial GL viewport */
71 const GlsMatrixAffineD::GLMatrixAffineF projMatrix; /**< initial GL projection matrix */
72 const GlsMatrixAffineD::GLMatrixAffineF modelMatrix; /**< initial GL model matrix */
73 GlsDisplayObject &topLevelObject; /**< top level object receiving input */
74
75 #if defined( GLS_DEBUG )
76 /** Determine if the initialization parameters are valid
77 * \return GLS_TRUE if valid else GLS_FALSE
78 * \pre none
79 * \post none
80 */
81 GlsBool IsValid( void ) const;
82 #endif // GLS_DEBUG
83 };
84
85 /** Initialize (and create) the singleton GlsInputManager instance. Can only be called once
86 * \param initParameters initialization parameters
87 * \pre singleton must not already exist, initParameters.IsValid()
88 * \post GlsInputManager singleton instance is created and initialized
89 */
90 static void Initialize( InitParameters &initParameters );
91
92 /** Get the singleton GlsInputManager instance
93 * \return the singleton GlsInputManager instance
94 * \pre singleton instance must exist ( must have called Initialize() )
95 * \post none
96 */
98
99 /** Handle the given event
100 * \param event event in question
101 * \return GLS_TRUE if event was handled else GLS_FALSE
102 * \pre event.IsValid()
103 * \post event is handled if return value is GLS_TRUE
104 */
106
107 /** Update the input manager with the current GL viewport. Call if/when
108 * GL viewport changes from initial viewport given to Initialize() call.
109 * \param viewport updated GL viewport
110 * \pre none
111 * \post view port is updated
112 */
113 void UpdateViewport( const Viewport &viewport );
114
115 /** Update the input manager with the current GL projection matrix. Call if/when
116 * GL projection matrix changes from initial projection matrix given to Initialize() call.
117 * \param projMatrix updated projection matrix
118 * \pre GLMatrixAffineFIsValid( projMatrix )
119 * \post projection matrix is updated
120 */
122
123 /** Update the input manager with the current top level GL model matrix. Call if/when
124 * top level GL model matrix changes from initial model matrix given to Initialize() call.
125 * \param modelMatrix updated model matrix
126 * \pre GLMatrixAffineFIsValid( modelMatrix )
127 * \post model matrix is updated
128 */
130
131 /** Project the given point into screen coordinates using the given GL draw matrix and
132 * the current projection matrix and viewport
133 * \param p point in question
134 * \param drawMatrix GL draw matrix
135 * \param projected [out] receives projected point in screen coordinates
136 * \pre p.IsValid(), GLMatrixAffineFIsValid( drawMatrix )
137 * \post projected contains p projected into screen space
138 */
140 GlsVector2D &projected ) const;
141
142protected:
143 Viewport _viewport; /**< current GL display viewport */
144 GlsMatrixAffineD::GLMatrixAffineF _projMatrix; /**< current GL projection matrix */
145 GlsMatrixAffineD::GLMatrixAffineF _modelMatrix; /**< current GL model matrix */
146 GlsDisplayObject &_topLevelObject; /**< top level object receiving input */
147 GlsDisplayObject *_focusObject; /**< current object with focus else GLS_NULL */
148 GlsDisplayObject *_dragObject; /**< current object for dragging else GLS_NULL */
149
150 GlsBool _invalidatePickCache; /**< GLS_TRUE if pick cache of top level component needs to
151 * be invalidated before the next pick can occur */
152
153 /** Constructor - create an instance
154 * \param initParameters initialization parameters
155 * \pre initParameters.IsValid()
156 * \post instance created
157 */
158 GlsInputManager( InitParameters &initParameters );
159
160 /** Destructor - shall never be called
161 * \pre none
162 * \post none
163 */
165
166private:
167 // Disable implicit generated Members
168 GlsInputManager& operator=( const GlsInputManager &rhs );
169 GlsInputManager( const GlsInputManager &src );
170};
171
172#endif // _GLS_INPUT_MANAGER_H
Definition: gls_display_object.h:65
Definition: gls_input_manager.h:54
GlsInputManager(InitParameters &initParameters)
GlsMatrixAffineD::GLMatrixAffineF _modelMatrix
Definition: gls_input_manager.h:145
void UpdateProjectionMatrix(const GlsMatrixAffineD::GLMatrixAffineF &projMatrix)
virtual ~GlsInputManager()
GlsDisplayObject & _topLevelObject
Definition: gls_input_manager.h:146
GlsDisplayObject * _dragObject
Definition: gls_input_manager.h:148
GlsBool HandleEvent(GlsEvent &event)
static GlsInputManager & GetInputManager(void)
static void Initialize(InitParameters &initParameters)
void ProjectPoint(const GlsVector3D &p, const GlsMatrixAffineD::GLMatrixAffineF &drawMatrix, GlsVector2D &projected) const
GlsBool _invalidatePickCache
Definition: gls_input_manager.h:150
GlsMatrixAffineD::GLMatrixAffineF _projMatrix
Definition: gls_input_manager.h:144
Viewport _viewport
Definition: gls_input_manager.h:143
void UpdateViewport(const Viewport &viewport)
void UpdateModelMatrix(const GlsMatrixAffineD::GLMatrixAffineF &modelMatrix)
GlsDisplayObject * _focusObject
Definition: gls_input_manager.h:147
GLfloat GLMatrixAffineF[DIMENSION *DIMENSION]
Definition: gls_matrix_affine_double.h:63
This header defines a GLS_DEBUG only macro for facilitating evaluating class invariants in the GL Stu...
#define GLS_CLASS_INVARIANT_DECLARATION(ClassName)
Definition: gls_class_invariant.h:80
This header defines the base class for all graphical objects in the GL Studio DO-178B Runtime Library...
This header defines any preprocessor defines needed to configure the GL Studio DO-178B Runtime Librar...
This header defines The GlsMatrixAffineD class for use in the GL Studio DO-178B Runtime Library.
This header defines the basic types used by the GL Studio DO-178B Runtime Library.
int GlsInt32
Definition: gls_types.h:66
bool GlsBool
Definition: gls_types.h:96
unsigned int GlsUInt32
Definition: gls_types.h:73
Definition: gls_event.h:53
Definition: gls_input_manager.h:69
const GlsMatrixAffineD::GLMatrixAffineF modelMatrix
Definition: gls_input_manager.h:72
const GlsMatrixAffineD::GLMatrixAffineF projMatrix
Definition: gls_input_manager.h:71
const Viewport viewport
Definition: gls_input_manager.h:70
GlsDisplayObject & topLevelObject
Definition: gls_input_manager.h:73
Definition: gls_input_manager.h:60
GlsInt32 y
Definition: gls_input_manager.h:62
GlsUInt32 width
Definition: gls_input_manager.h:63
GlsUInt32 height
Definition: gls_input_manager.h:64
GlsInt32 x
Definition: gls_input_manager.h:61
Definition: gls_vertex.h:50
Definition: gls_vertex.h:66