GL Studio C++ Runtime API
gls_knob.h
Go to the documentation of this file.
1/// \file gls_knob.h
2/// \brief The disti::GlsKnob class.
3///
4/// \par Copyright Information
5///
6/// Copyright (c) 2017 by The DiSTI Corporation.<br>
7/// 12249 Science Drive; Suite 300<br>
8/// Orlando, Florida 32826<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
14/// reproduced, in whole or part, in any form, or by any means of electronic,
15/// mechanical, or otherwise, without the written permission of DiSTI. Said
16/// permission may be derived through the purchase of applicable DiSTI product
17/// licenses which detail the distribution rights of this content and any
18/// Derivative Works based on this or other copyrighted DiSTI Software.
19///
20/// NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21/// AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22/// PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23/// AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24/// IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25/// PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26///
27/// LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28/// IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29/// INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30/// DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31/// INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32/// INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33/// OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34/// EXCEED FIVE DOLLARS (US$5.00).
35///
36/// The aforementioned terms and restrictions are governed by the laws of the
37/// State of Florida and the United States of America.
38
39#ifndef DISTI_INCLUDED_GLS_KNOB_H
40#define DISTI_INCLUDED_GLS_KNOB_H
41
43#include "group.h"
44
45/// Provides support for creating DLLs.
46#if( defined( GLSGEN_EXPORT_GlsKnob ) || defined( GLSGEN_IMPORT_GlsKnob ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
47 && defined( _MSC_VER )
48# if defined( GLSGEN_EXPORT_GlsKnob ) || defined( GLS_EXPORT_GENERATED )
49# define GLSGEN_GlsKnob_EXPORT __declspec( dllexport )
50# else
51# define GLSGEN_GlsKnob_EXPORT __declspec( dllimport )
52# endif
53#else
54# define GLSGEN_GlsKnob_EXPORT
55#endif
56///////////////////////////////////////////////////////////////////////////////
57
58/// Automatically link the runtime library plugin (on Windows).
59#define LIB_BASE_NAME "gls_knob"
60#include "gls_auto_lib.h"
61#undef LIB_BASE_NAME
62
63namespace disti
64{
65enum
66{
67 GLS_GLSKNOB_CHANGE_CALLBACK = GLS_LAST_INITIALIZER + 1,
68 GLS_GLSKNOB_ANGLERANGE,
69 GLS_GLSKNOB_CONTINUOUS,
70 GLS_GLSKNOB_POSITIONVAL,
71 GLS_GLSKNOB_DETENTPOSITIONS,
72 GLS_GLSKNOB_WHICHOBJECT,
73 GLS_GLSKNOB_STARTANGLE,
74 GLS_GLSKNOB_EMITDETENTVALEVENT,
75 GLS_GLSKNOB_EMITPOSITIONVALEVENT,
76 GLS_GLSKNOB_EMITLIMITEVENT,
77 GLS_GLSKNOB_EMITRELEASEEVENT,
78 GLS_GLSKNOB_SHOWDETENTSONLY,
79 GLS_GLSKNOB_CLICKSELECTSDETENT
80};
81
82/** Runtime implementation of a knob */
83class GlsKnob : public Group
84{
85public:
86 friend class GlsKnobEditor;
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 float _angleRange; ///< In degrees.
92 int _numDetents; ///< Number of detents, snap points of the knob.
93 DynamicArray<float> _detentPositions; ///< Range 0-100.
94 float _positionVal; ///< Current knob position.
95 bool _continuous; ///< If true, the knob can spin all the way around.
96 int _whichObject; ///< The object index in the group to be the knob.
97 float _startAngle; ///< An angle offset from the begining position.
98 bool _emitDetentValEvent; ///< If true, will emit an event when snapping to a detent.
99 bool _emitPositionValEvent; ///< If true, will emit an event when the position is changed.
100
101 /// Set if object should emit the DeventVal event.
102 /// \param value The new flag to set.
103 void EmitDetentValEvent( const bool& value );
104
105 /// \return Whether object should emit the DeventVal event.
107
108 /// Set if object should emit the PositionVal event.
109 /// \param value The new flag to set.
110 void EmitPositionValEvent( const bool& value );
111
112 /// \return Whether object should emit the PositionVal event.
114
115 /// Set if object should emit the Limit event.
116 /// \param value The new flag to set.
117 void EmitLimitEvent( const bool& value );
118
119 /// \return Whether object should emit the Limit event.
121
122 /// Set if object should emit the Release event.
123 /// \param value The new flag to set.
124 void EmitReleaseEvent( const bool& value );
125
126 /// \return Whether object should emit the Release event.
128
129 /** Create a new GlsKnob.
130 * \param generateInstance Whether or not to generate an instance name
131 * for this inputdevice */
132 GLSGEN_GlsKnob_EXPORT GlsKnob( bool generateInstance = false );
133
134 /// Copy constructor
135 /// \param that The object to copy from.
136 /// \param generateNames Whether or not to generate an instance name.
137 GLSGEN_GlsKnob_EXPORT GlsKnob( const GlsKnob& that, const bool generateNames );
138
139 /** Destroy a GlsKnob object */
141
142 /// \return A pointer to a new GlsKnob object.
144
150
151#ifndef GLES
154#endif
155
156 GLSGEN_GlsKnob_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
158
159 //////////////////////////////////////////////////
160 // Knob specific operations
161 //////////////////////////////////////////////////
162
163 /// Set the value of the ShowDetentsOnly property.
164 /// \param value The new value to set.
165 GLSGEN_GlsKnob_EXPORT void ShowDetentsOnly( const bool& value );
166
167 /// \return The value of the ShowDetentsOnly property.
169
170 /// Sets the value of the ClickSelectsDetent property.
171 /// \param value The new value to set.
172 void ClickSelectsDetent( const bool& value ) { _clickSelectsDetent = value; }
173
174 /// \return The value of the ClickSelectsDetent property.
176
177 /** Moves the knob to the specified detent
178 * Sets the detent value
179 * \param value Desired detent, first detent == 1
180 */
181 virtual GLSGEN_GlsKnob_EXPORT void DetentVal( const int& value );
182
183 /** Returns the nearest detent for the knob's current poistion.
184 * \return Nearest detent, first detent == 1
185 */
187
188 /** Sets current position of the knob (0.0 - 100.0)
189 * \param value New position of the knob (0.0 - 100.0)
190 */
191 virtual GLSGEN_GlsKnob_EXPORT void PositionVal( const float& value );
192
193 /** Returns the current position of the knob (0.0 - 100.0)
194 * \return Current knob position (0.0 - 100.0)
195 */
197
198 /** Sets the current knob geometry index value
199 * \param value Knob geometry index value
200 */
201 virtual GLSGEN_GlsKnob_EXPORT void WhichObject( const int& value );
202
203 /** Returns the current knob geometry index value
204 * \return Knob geometry index value
205 */
207
208protected:
209 bool _showDetentsOnly; ///< If true, knob will only rotate to exact detents, nothing in between.
210 bool _clickSelectsDetent; ///< If true, clicking on a detent will snap the knob to that detent.
211
212 bool _emitLimitEvent; ///< If true, an event will be emitted when the knob reaches its upper or lower limit.
213 bool _emitReleaseEvent; ///< If true, an event will be emitted when the knob is released (mouse up).
214
215 // Some private data for internal calculations
216 int _initialDetentVal; ///< Stores the initial detent position based on the starting rotation.
217 float _mouseDownoX; ///< X position of the last mouse down in logical coordinates.
218 float _mouseDownoY; ///< Y position of the last mouse down in logical coordinates.
219 float _mouseDownoZ; ///< Z position of the last mouse down in logical coordinates.
220 Vector _mouseDownDirectionVector; ///< Unused, kept for backward compatibility.
221 float _mouseDownAngle; ///< Rotation angle of the knob when the mouse was pressed.
222 float _mouseLastAngle; ///< The rotation angle of the knob on the previous frame.
223 bool _atCwStop; ///< If true, the knob has reached its clockwise most position.
224 bool _atCcwStop; ///< If true, the knob has reached its counter clockwise most position.
225
226 bool _sideMode; ///< If true, the knob is being viewed at or almost side on.
227
228 /// \return The current rotation of the knob in degrees.
230
231 bool _mouseWasDown; ///< If true, the mouse was clicked on a previous frame.
232 unsigned int _currentCursor; ///< The current cursor used for interaction. Any other cursors are ignored while interacting.
233
234#ifdef GLES
235 /** Set a single attribute from the GLO file.
236 * \param data The attribute to set and its associated data.
237 */
238 GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
239#endif
240
241private:
242 // disallow implicit assignments and copy constructor
243 GlsKnob& operator=( const GlsKnob& ) DISTI_SPECIAL_MEM_FUN_DELETE;
245};
246
247} // namespace disti
248
249#endif
Definition: cull.h:49
Definition: events.h:111
Definition: display.h:95
Definition: dynamic_array.h:79
Definition: gls_glo_file.h:1241
Definition: gls_knob.h:84
GlsKnob(bool generateInstance=false)
float _mouseDownoY
Y position of the last mouse down in logical coordinates.
Definition: gls_knob.h:218
bool _emitDetentValEvent
If true, will emit an event when snapping to a detent.
Definition: gls_knob.h:98
bool _atCcwStop
If true, the knob has reached its counter clockwise most position.
Definition: gls_knob.h:224
int _numDetents
Number of detents, snap points of the knob.
Definition: gls_knob.h:92
unsigned int _currentCursor
The current cursor used for interaction. Any other cursors are ignored while interacting.
Definition: gls_knob.h:232
void ShowDetentsOnly(const bool &value)
bool _sideMode
If true, the knob is being viewed at or almost side on.
Definition: gls_knob.h:226
float CalcRotationAngle()
void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
float _startAngle
An angle offset from the begining position.
Definition: gls_knob.h:97
DynamicArray< float > _detentPositions
Range 0-100.
Definition: gls_knob.h:93
void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
bool _continuous
If true, the knob can spin all the way around.
Definition: gls_knob.h:95
bool EmitPositionValEvent()
Definition: gls_knob.h:113
bool _atCwStop
If true, the knob has reached its clockwise most position.
Definition: gls_knob.h:223
void ClickSelectsDetent(const bool &value)
Definition: gls_knob.h:172
void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
float _mouseDownoZ
Z position of the last mouse down in logical coordinates.
Definition: gls_knob.h:219
void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
virtual int DetentVal()
GlsKnob(const GlsKnob &that, const bool generateNames)
float _mouseDownAngle
Rotation angle of the knob when the mouse was pressed.
Definition: gls_knob.h:221
int _initialDetentVal
Stores the initial detent position based on the starting rotation.
Definition: gls_knob.h:216
bool _mouseWasDown
If true, the mouse was clicked on a previous frame.
Definition: gls_knob.h:231
virtual void PositionVal(const float &value)
bool ClickSelectsDetent()
Definition: gls_knob.h:175
bool _emitPositionValEvent
If true, will emit an event when the position is changed.
Definition: gls_knob.h:99
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
virtual void WhichObject(const int &value)
void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
static DisplayObject * CreateInstance()
virtual float PositionVal()
void Draw() DISTI_METHOD_OVERRIDE
bool _clickSelectsDetent
If true, clicking on a detent will snap the knob to that detent.
Definition: gls_knob.h:210
bool _emitReleaseEvent
If true, an event will be emitted when the knob is released (mouse up).
Definition: gls_knob.h:213
virtual ~GlsKnob()
virtual void DetentVal(const int &value)
Vector _mouseDownDirectionVector
Unused, kept for backward compatibility.
Definition: gls_knob.h:220
void EmitLimitEvent(const bool &value)
float _angleRange
In degrees.
Definition: gls_knob.h:91
bool ShowDetentsOnly()
Definition: gls_knob.h:168
bool _showDetentsOnly
If true, knob will only rotate to exact detents, nothing in between.
Definition: gls_knob.h:209
bool EmitDetentValEvent()
Definition: gls_knob.h:106
void EmitReleaseEvent(const bool &value)
void EmitPositionValEvent(const bool &value)
float _positionVal
Current knob position.
Definition: gls_knob.h:94
DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
bool _emitLimitEvent
If true, an event will be emitted when the knob reaches its upper or lower limit.
Definition: gls_knob.h:212
bool EmitReleaseEvent()
Definition: gls_knob.h:127
float _mouseDownoX
X position of the last mouse down in logical coordinates.
Definition: gls_knob.h:217
bool EmitLimitEvent()
Definition: gls_knob.h:120
InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
virtual int WhichObject()
int _whichObject
The object index in the group to be the knob.
Definition: gls_knob.h:96
float _mouseLastAngle
The rotation angle of the knob on the previous frame.
Definition: gls_knob.h:222
Definition: group.h:52
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:540
Definition: vertex.h:84
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:245
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:487
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:221
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:50
#define GLSGEN_GlsKnob_EXPORT
Provides support for creating DLLs.
Definition: gls_knob.h:54
The disti::Group class. Implements groups of objects.
Definition: bmpimage.h:46