GL Studio C++ Runtime API
gls_knob.h
Go to the documentation of this file.
1/*! \file
2 \brief The disti::GlsKnob 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_KNOB_H
41#define _GLS_KNOB_H
42
44#include "group.h"
45
46/// Provides support for creating DLLs.
47#if( defined( GLSGEN_EXPORT_GlsKnob ) || defined( GLSGEN_IMPORT_GlsKnob ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
48 && defined( _MSC_VER )
49# if defined( GLSGEN_EXPORT_GlsKnob ) || defined( GLS_EXPORT_GENERATED )
50# define GLSGEN_GlsKnob_EXPORT __declspec( dllexport )
51# else
52# define GLSGEN_GlsKnob_EXPORT __declspec( dllimport )
53# endif
54#else
55# define GLSGEN_GlsKnob_EXPORT
56#endif
57///////////////////////////////////////////////////////////////////////////////
58
59/// Automatically link the runtime library plugin (on Windows).
60#define LIB_BASE_NAME "gls_knob"
61#include "gls_auto_lib.h"
62#undef LIB_BASE_NAME
63
64namespace disti
65{
66enum
67{
68 GLS_GLSKNOB_CHANGE_CALLBACK = GLS_LAST_INITIALIZER + 1,
69 GLS_GLSKNOB_ANGLERANGE,
70 GLS_GLSKNOB_CONTINUOUS,
71 GLS_GLSKNOB_POSITIONVAL,
72 GLS_GLSKNOB_DETENTPOSITIONS,
73 GLS_GLSKNOB_WHICHOBJECT,
74 GLS_GLSKNOB_STARTANGLE,
75 GLS_GLSKNOB_EMITDETENTVALEVENT,
76 GLS_GLSKNOB_EMITPOSITIONVALEVENT,
77 GLS_GLSKNOB_EMITLIMITEVENT,
78 GLS_GLSKNOB_EMITRELEASEEVENT,
79 GLS_GLSKNOB_SHOWDETENTSONLY,
80 GLS_GLSKNOB_CLICKSELECTSDETENT
81};
82
83/** Runtime implementation of a knob */
84class GlsKnob : public Group
85{
86public:
87 friend class GlsKnobEditor;
88 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
89 typedef Group _BaseClass; ///< Deprecated typedef for the base class.
90 typedef Group BaseClass; ///< Typedef for the base class.
91
92 float _angleRange; ///< In degrees.
93 int _numDetents; ///< Number of detents, snap points of the knob.
94 DynamicArray<float> _detentPositions; ///< Range 0-100.
95 float _positionVal; ///< Current knob position.
96 bool _continuous; ///< If true, the knob can spin all the way around.
97 int _whichObject; ///< The object index in the group to be the knob.
98 float _startAngle; ///< An angle offset from the begining position.
99 bool _emitDetentValEvent; ///< If true, will emit an event when snapping to a detent.
100 bool _emitPositionValEvent; ///< If true, will emit an event when the position is changed.
101
102 /// Set if object should emit the DeventVal event.
103 /// \param value The new flag to set.
104 inline void EmitDetentValEvent( const bool& value );
105
106 /// \return Whether object should emit the DeventVal event.
107 inline bool EmitDetentValEvent() { return _emitDetentValEvent; }
108
109 /// Set if object should emit the PositionVal event.
110 /// \param value The new flag to set.
111 inline void EmitPositionValEvent( const bool& value );
112
113 /// \return Whether object should emit the PositionVal event.
115
116 /// Set if object should emit the Limit event.
117 /// \param value The new flag to set.
118 inline void EmitLimitEvent( const bool& value );
119
120 /// \return Whether object should emit the Limit event.
121 inline bool EmitLimitEvent() { return _emitLimitEvent; }
122
123 /// Set if object should emit the Release event.
124 /// \param value The new flag to set.
125 inline void EmitReleaseEvent( const bool& value );
126
127 /// \return Whether object should emit the Release event.
128 inline bool EmitReleaseEvent() { return _emitReleaseEvent; }
129
130 /** Create a new GlsKnob.
131 * \param generateInstance Whether or not to generate an instance name
132 * for this inputdevice */
133 GLSGEN_GlsKnob_EXPORT GlsKnob( bool generateInstance = false );
134
135 /// Copy constructor
136 /// \param that The object to copy from.
137 /// \param generateNames Whether or not to generate an instance name.
138 GLSGEN_GlsKnob_EXPORT GlsKnob( const GlsKnob& that, const bool generateNames );
139
140 /** Destroy a GlsKnob object */
142
143 /// \return A pointer to a new GlsKnob object.
145
148 virtual GLSGEN_GlsKnob_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
151
152#ifndef GLES
155#endif
156
157 virtual GLSGEN_GlsKnob_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
159
160 //////////////////////////////////////////////////
161 // Knob specific operations
162 //////////////////////////////////////////////////
163
164 /// Set the value of the ShowDetentsOnly property.
165 /// \param value The new value to set.
166 GLSGEN_GlsKnob_EXPORT void ShowDetentsOnly( const bool& value );
167
168 /// \return The value of the ShowDetentsOnly property.
169 inline bool ShowDetentsOnly() { return _showDetentsOnly; }
170
171 /// Sets the value of the ClickSelectsDetent property.
172 /// \param value The new value to set.
173 inline void ClickSelectsDetent( const bool& value ) { _clickSelectsDetent = value; }
174
175 /// \return The value of the ClickSelectsDetent property.
176 inline bool ClickSelectsDetent() { return _clickSelectsDetent; }
177
178 /** Moves the knob to the specified detent
179 * Sets the detent value
180 * \param value Desired detent, first detent == 1
181 */
182 virtual GLSGEN_GlsKnob_EXPORT void DetentVal( const int& value );
183
184 /** Returns the nearest detent for the knob's current poistion.
185 * \return Nearest detent, first detent == 1
186 */
188
189 /** Sets current position of the knob (0.0 - 100.0)
190 * \param value New position of the knob (0.0 - 100.0)
191 */
192 virtual GLSGEN_GlsKnob_EXPORT void PositionVal( const float& value );
193
194 /** Returns the current position of the knob (0.0 - 100.0)
195 * \return Current knob position (0.0 - 100.0)
196 */
198
199 /** Sets the current knob geometry index value
200 * \param value Knob geometry index value
201 */
202 virtual GLSGEN_GlsKnob_EXPORT void WhichObject( const int& value );
203
204 /** Returns the current knob geometry index value
205 * \return Knob geometry index value
206 */
208
209protected:
210 bool _showDetentsOnly; ///< If true, knob will only rotate to exact detents, nothing in between.
211 bool _clickSelectsDetent; ///< If true, clicking on a detent will snap the knob to that detent.
212
213 bool _emitLimitEvent; ///< If true, an event will be emitted when the knob reaches its upper or lower limit.
214 bool _emitReleaseEvent; ///< If true, an event will be emitted when the knob is released (mouse up).
215
216 // Some private data for internal calculations
217 int _initialDetentVal; ///< Stores the initial detent position based on the starting rotation.
218 float _mouseDownoX; ///< X position of the last mouse down in logical coordinates.
219 float _mouseDownoY; ///< Y position of the last mouse down in logical coordinates.
220 float _mouseDownoZ; ///< Z position of the last mouse down in logical coordinates.
221 Vector _mouseDownDirectionVector; ///< Unused, kept for backward compatibility.
222 float _mouseDownAngle; ///< Rotation angle of the knob when the mouse was pressed.
223 float _mouseLastAngle; ///< The rotation angle of the knob on the previous frame.
224 bool _atCwStop; ///< If true, the knob has reached its clockwise most position.
225 bool _atCcwStop; ///< If true, the knob has reached its counter clockwise most position.
226
227 bool _sideMode; ///< If true, the knob is being viewed at or almost side on.
228
229 /// \return The current rotation of the knob in degrees.
231
232 bool _mouseWasDown; ///< If true, the mouse was clicked on a previous frame.
233 unsigned int _currentCursor; ///< The current cursor used for interaction. Any other cursors are ignored while interacting.
234
235#ifdef GLES
236 /** Set a single attribute from the GLO file.
237 * \param data The attribute to set and its associated data.
238 */
239 virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
240#endif
241
242private:
243 // disallow implicit assignments and copy constructor
244 GlsKnob& operator=( const GlsKnob& ) DISTI_SPECIAL_MEM_FUN_DELETE;
246};
247
248} // namespace disti
249
250#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_knob.h:85
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
GlsKnob(bool generateInstance=false)
float _mouseDownoY
Y position of the last mouse down in logical coordinates.
Definition: gls_knob.h:219
bool _emitDetentValEvent
If true, will emit an event when snapping to a detent.
Definition: gls_knob.h:99
bool _atCcwStop
If true, the knob has reached its counter clockwise most position.
Definition: gls_knob.h:225
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
virtual void Draw() DISTI_METHOD_OVERRIDE
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
int _numDetents
Number of detents, snap points of the knob.
Definition: gls_knob.h:93
unsigned int _currentCursor
The current cursor used for interaction. Any other cursors are ignored while interacting.
Definition: gls_knob.h:233
void ShowDetentsOnly(const bool &value)
bool _sideMode
If true, the knob is being viewed at or almost side on.
Definition: gls_knob.h:227
float CalcRotationAngle()
float _startAngle
An angle offset from the begining position.
Definition: gls_knob.h:98
DynamicArray< float > _detentPositions
Range 0-100.
Definition: gls_knob.h:94
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
bool _continuous
If true, the knob can spin all the way around.
Definition: gls_knob.h:96
bool EmitPositionValEvent()
Definition: gls_knob.h:114
bool _atCwStop
If true, the knob has reached its clockwise most position.
Definition: gls_knob.h:224
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
void ClickSelectsDetent(const bool &value)
Definition: gls_knob.h:173
float _mouseDownoZ
Z position of the last mouse down in logical coordinates.
Definition: gls_knob.h:220
virtual int DetentVal()
GlsKnob(const GlsKnob &that, const bool generateNames)
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
float _mouseDownAngle
Rotation angle of the knob when the mouse was pressed.
Definition: gls_knob.h:222
int _initialDetentVal
Stores the initial detent position based on the starting rotation.
Definition: gls_knob.h:217
bool _mouseWasDown
If true, the mouse was clicked on a previous frame.
Definition: gls_knob.h:232
virtual void PositionVal(const float &value)
bool ClickSelectsDetent()
Definition: gls_knob.h:176
bool _emitPositionValEvent
If true, will emit an event when the position is changed.
Definition: gls_knob.h:100
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
virtual void WhichObject(const int &value)
static DisplayObject * CreateInstance()
virtual float PositionVal()
bool _clickSelectsDetent
If true, clicking on a detent will snap the knob to that detent.
Definition: gls_knob.h:211
bool _emitReleaseEvent
If true, an event will be emitted when the knob is released (mouse up).
Definition: gls_knob.h:214
virtual ~GlsKnob()
virtual void DetentVal(const int &value)
Vector _mouseDownDirectionVector
Unused, kept for backward compatibility.
Definition: gls_knob.h:221
void EmitLimitEvent(const bool &value)
float _angleRange
In degrees.
Definition: gls_knob.h:92
bool ShowDetentsOnly()
Definition: gls_knob.h:169
bool _showDetentsOnly
If true, knob will only rotate to exact detents, nothing in between.
Definition: gls_knob.h:210
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
bool EmitDetentValEvent()
Definition: gls_knob.h:107
void EmitReleaseEvent(const bool &value)
void EmitPositionValEvent(const bool &value)
float _positionVal
Current knob position.
Definition: gls_knob.h:95
bool _emitLimitEvent
If true, an event will be emitted when the knob reaches its upper or lower limit.
Definition: gls_knob.h:213
bool EmitReleaseEvent()
Definition: gls_knob.h:128
float _mouseDownoX
X position of the last mouse down in logical coordinates.
Definition: gls_knob.h:218
bool EmitLimitEvent()
Definition: gls_knob.h:121
virtual int WhichObject()
int _whichObject
The object index in the group to be the knob.
Definition: gls_knob.h:97
float _mouseLastAngle
The rotation angle of the knob on the previous frame.
Definition: gls_knob.h:223
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_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:214
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
#define GLSGEN_GlsKnob_EXPORT
Provides support for creating DLLs.
Definition: gls_knob.h:55
The disti::Group class. Implements groups of objects.
Force inclusion of the DirectShow library.
Definition: bmpimage.h:47