GL Studio C++ Runtime API
gls_switch.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsSwitch class.
3
4 \par Copyright Information
5
6 Copyright (c) 2017 by The DiSTI Corporation.<br>
7 11301 Corporate Blvd; Suite 100<br>
8 Orlando, Florida 32817<br>
9 USA<br>
10 <br>
11 All rights reserved.<br>
12
13 This Software contains proprietary trade secrets of DiSTI and may not be
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State of Florida and the United States of America.
38
39*/
40#ifndef _GLS_SWITCH_H
41#define _GLS_SWITCH_H
42
44#include "glsutil.h"
45#include "group.h"
46
47/// Provides support for creating DLLs.
48#if( defined( GLSGEN_EXPORT_GlsSwitch ) || defined( GLSGEN_IMPORT_GlsSwitch ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
49 && defined( _MSC_VER )
50# if defined( GLSGEN_EXPORT_GlsSwitch ) || defined( GLS_EXPORT_GENERATED )
51# define GLSGEN_GlsSwitch_EXPORT __declspec( dllexport )
52# else
53# define GLSGEN_GlsSwitch_EXPORT __declspec( dllimport )
54# endif
55#else
56# define GLSGEN_GlsSwitch_EXPORT
57#endif
58///////////////////////////////////////////////////////////////////////////////
59
60/// Automatically link the runtime library plugin (on Windows).
61#define LIB_BASE_NAME "gls_switch"
62#include "gls_auto_lib.h"
63#undef LIB_BASE_NAME
64
65namespace disti
66{
67enum
68{
69 GLS_GLSSWITCH_INITIAL_DETENT_VAL = GLS_LAST_INITIALIZER + 1,
70 GLS_GLSSWITCH_WHICH_OBJECT_BACKGROUND,
71 GLS_GLSSWITCH_FIRST_DETENT_SNAPBACK, // for normal or snapback behavior
72 GLS_GLSSWITCH_LAST_DETENT_SNAPBACK, // for normal or snapback behavior
73 GLS_GLSSWITCH_EMIT_DETENT_VAL_EVENT,
74 GLS_GLSSWITCH_EMIT_LIMIT_EVENT,
75 GLS_GLSSWITCH_EMIT_RELEASE_EVENT
76};
77
78/** Runtime implementation of a switch */
79class GlsSwitch : public Group
80{
81private:
84
85public:
86 friend class GlsSwitchEditor;
87 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
88 typedef Group _BaseClass; ///< Deprecated typedef for the base class.
89 typedef Group BaseClass; ///< Typedef for the base class.
90
91 int _detentVal; ///< CurrentPosition
92 bool _firstDetentSnapback; ///< If true, the position will snap from the first detent back to the second detent when released.
93 bool _lastDetentSnapback; ///< If true, the position will snap from the last detent back to the second to last detent when released.
94 int _whichObjectBackground; ///< the geometry index (plus 1) to serve as the switch background. 0 is no background object.
95 bool _emitDetentValEvent; ///< If true, events will be emitted whenever the detent value changes.
96
97 /// Set if a DetentVal event should be emitted.
98 /// \param value The new emit event flag to set.
99 inline void EmitDetentValEvent( const bool& value );
100
101 /// \return Whether or not a DetentVal event should be emitted.
102 inline bool EmitDetentValEvent() { return _emitDetentValEvent; }
103
104 /// Set if a Limit event should be emitted.
105 /// \param value The new emit event flag to set.
106 inline void EmitLimitEvent( const bool& value );
107
108 /// \return Whether or not a Limit event should be emitted.
109 inline bool EmitLimitEvent() { return _emitLimitEvent; }
110
111 /// Set if a Release event should be emitted.
112 /// \param value The new emit event flag to set.
113 inline void EmitReleaseEvent( const bool& value );
114
115 /// \return Whether or not a Release event should be emitted.
116 inline bool EmitReleaseEvent() { return _emitReleaseEvent; }
117
118 /// \return The number of detents on this switch.
120
121 /// \returns The geometry associated with the detent.
122 /// \param detent The index of the detent whose geometry is to be returned.
124
125 /// \return The geometry specified as the background, NULL is returned if none.
127
128 /// Create a new GlsSwitch.
129 /// \param generateInstance Whether or not to generate an instance name for this object.
130 GLSGEN_GlsSwitch_EXPORT GlsSwitch( bool generateInstance = false );
131
132 /// Copy constructor
133 /// \param that The object to copy from.
134 /// \param generateNames Whether or not to generate an instance name for this object.
135 GLSGEN_GlsSwitch_EXPORT GlsSwitch( const GlsSwitch& that, const bool generateNames );
136
137 /** Destroy a GlsSwitch object */
139
140 /// \return A pointer to a new GlsSwitch object.
142
144
146
147 virtual GLSGEN_GlsSwitch_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
148
150
152
153#ifndef GLES
156#endif
157
158 /// \return Whether or not this switch is horizontal or vertical relative to the y axis.
160
162
163 virtual GLSGEN_GlsSwitch_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
164
166
167 //////////////////////////////////////////////////
168 // Switch specific operations
169 //////////////////////////////////////////////////
170
171 /** Sets current detent of the switch
172 * \param val New detent of the switch
173 */
174 virtual GLSGEN_GlsSwitch_EXPORT void DetentVal( const int& val );
175
176 /** Returns the current detent of the switch
177 * \return Current switch detent
178 */
180
181 /** Sets current background geometry index value of the switch
182 * \param val New switch background geometry index value
183 */
184 virtual GLSGEN_GlsSwitch_EXPORT void WhichObjectBackground( const int& val );
185
186 /** Returns the current background geometry index value of the switch
187 * \return Current switch background geometry index value
188 */
190
191 /** Returns the current background geometry index value of the switch
192 * \deprecated this method is not const correct, use const version instead
193 * \return Current switch background geometry index value
194 */
195 DISTI_DEPRECATED( "Use the const version instead." )
197 {
198 return const_cast<const GlsSwitch*>( this )->WhichObjectBackground();
199 }
200
201protected:
202 bool _emitLimitEvent; ///< If true, an event will be emitted when the switch hits its maximum or minimum state.
203 bool _emitReleaseEvent; ///< If true, an event will be emitted when the switch is released.
204
205 Vector _mouseDownOCoords; ///< Stores the object coordinates of the last mouse down on this object.
206
207 bool _mouseWasDown; ///< Whether or not the mouse is down on this object.
208 unsigned int _currentCursor; ///< The current cursor used for interaction. Any other cursors are ignored while interacting.
209
210 /// Uses event data to calculate a new switch position based on the DCS of the object.
211 /// \note This is not intended to be called directly.
212 /// \param self This object.
213 /// \param ev The input event.
214 /// \param inputType The input type of this switch.
215 /// \param numPositions The number of positions in this switch.
216 /// \param scale Additional scale to be applied.
217 /// \return The new position of the switch.
219 InputOrientationEnum inputType, int numPositions,
220 float scale = 1.0f );
221
222#ifdef GLES
223 /** Set a single attribute from the GLO file.
224 * \param data The attribute to set and its associated data.
225 */
226 virtual GLSGEN_GlsSwitch_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
227#endif
228};
229
230} // namespace disti
231
232#endif
Definition: cull.h:50
Definition: events.h:113
Definition: display.h:96
Definition: dynamic_array.h:79
Definition: gls_glo_file.h:1243
Definition: gls_switch.h:80
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
int _detentVal
CurrentPosition.
Definition: gls_switch.h:91
bool _emitDetentValEvent
If true, events will be emitted whenever the detent value changes.
Definition: gls_switch.h:95
bool _firstDetentSnapback
If true, the position will snap from the first detent back to the second detent when released.
Definition: gls_switch.h:92
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void Draw() DISTI_METHOD_OVERRIDE
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
unsigned int _currentCursor
The current cursor used for interaction. Any other cursors are ignored while interacting.
Definition: gls_switch.h:208
GlsSwitch(bool generateInstance=false)
GlsSwitch(const GlsSwitch &that, const bool generateNames)
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
virtual int DetentVal()
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
virtual void DetentVal(const int &val)
virtual ~GlsSwitch()
bool _mouseWasDown
Whether or not the mouse is down on this object.
Definition: gls_switch.h:207
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
static DisplayObject * CreateInstance()
bool IsVisibleInScene(const DisplayObject *obj=NULL) const DISTI_METHOD_OVERRIDE
bool _emitReleaseEvent
If true, an event will be emitted when the switch is released.
Definition: gls_switch.h:203
InputOrientationEnum InputType()
void EmitLimitEvent(const bool &value)
Vector _mouseDownOCoords
Stores the object coordinates of the last mouse down on this object.
Definition: gls_switch.h:205
DisplayObject * BackgroundGeometry() const
virtual void WhichObjectBackground(const int &val)
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
int _whichObjectBackground
the geometry index (plus 1) to serve as the switch background. 0 is no background object.
Definition: gls_switch.h:94
bool EmitDetentValEvent()
Definition: gls_switch.h:102
void EmitReleaseEvent(const bool &value)
virtual int WhichObjectBackground() const
bool _emitLimitEvent
If true, an event will be emitted when the switch hits its maximum or minimum state.
Definition: gls_switch.h:202
bool EmitReleaseEvent()
Definition: gls_switch.h:116
bool _lastDetentSnapback
If true, the position will snap from the last detent back to the second to last detent when released.
Definition: gls_switch.h:93
int CalcSwitchPosDCS(DisplayObject *self, DisplayEvent *ev, InputOrientationEnum inputType, int numPositions, float scale=1.0f)
bool EmitLimitEvent()
Definition: gls_switch.h:109
DisplayObject * DetentGeometry(int detent) const
Definition: group.h:53
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
Definition: vertex.h:85
The gls_auto_lib.
Macros and helper code to determine what subset of C++11/14/17 is available.
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:235
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:457
#define DISTI_FINAL
Macro to wrap the final keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:216
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
#define GLSGEN_GlsSwitch_EXPORT
Provides support for creating DLLs.
Definition: gls_switch.h:56
GL Studio helper functions.
The disti::Group class. Implements groups of objects.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47
InputOrientationEnum
Enumeration for Input Operators.
Definition: glsutil.h:271