| 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
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*/
40#ifndef _GLS_KNOB_H
41#define _GLS_KNOB_H
42
43#include "gls_cpp_lang_support.h"
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
64 namespace disti
65{
66 enum
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 */
84 class GlsKnob : public Group
85{
86 public:
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.
114 inline bool EmitPositionValEvent() { return _emitPositionValEvent; }
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 */
141 virtual GLSGEN_GlsKnob_EXPORT ~GlsKnob();
142
143 /// \return A pointer to a new GlsKnob object.
144 static GLSGEN_GlsKnob_EXPORT DisplayObject* CreateInstance();
145
146 virtual GLSGEN_GlsKnob_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
147 virtual GLSGEN_GlsKnob_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
148 virtual GLSGEN_GlsKnob_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
149 virtual GLSGEN_GlsKnob_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
150 virtual GLSGEN_GlsKnob_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
151
152#ifndef GLES
153 virtual GLSGEN_GlsKnob_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
154 virtual GLSGEN_GlsKnob_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
155#endif
156
157 virtual GLSGEN_GlsKnob_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
158 GLSGEN_GlsKnob_EXPORT DisplayObject* handle( DisplayEvent* ev ) 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 */
187 virtual GLSGEN_GlsKnob_EXPORT int DetentVal();
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 */
197 virtual GLSGEN_GlsKnob_EXPORT float PositionVal();
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 */
207 virtual GLSGEN_GlsKnob_EXPORT int WhichObject();
208
209 protected:
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.
230 GLSGEN_GlsKnob_EXPORT float CalcRotationAngle();
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
242 private:
243 // disallow implicit assignments and copy constructor
244 GlsKnob& operator=( const GlsKnob& ) DISTI_SPECIAL_MEM_FUN_DELETE;
245 GlsKnob( const GlsKnob& ) DISTI_SPECIAL_MEM_FUN_DELETE;
246};
247
248} // namespace disti
249
250#endif
disti::Culler
Definition: cull.h:50
disti::DisplayEvent
Definition: events.h:113
disti::DisplayObject
Definition: display.h:96
disti::DynamicArray
Definition: dynamic_array.h:79
disti::GlsGloFileAttribute
Definition: gls_glo_file.h:1243
disti::GlsKnob
Definition: gls_knob.h:85
disti::GlsKnob::GlsKnob
GlsKnob(bool generateInstance=false)
disti::GlsKnob::_mouseDownoY
float _mouseDownoY
Y position of the last mouse down in logical coordinates.
Definition: gls_knob.h:219
disti::GlsKnob::_emitDetentValEvent
bool _emitDetentValEvent
If true, will emit an event when snapping to a detent.
Definition: gls_knob.h:99
disti::GlsKnob::_atCcwStop
bool _atCcwStop
If true, the knob has reached its counter clockwise most position.
Definition: gls_knob.h:225
disti::GlsKnob::SetAvailableAttributes
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
disti::GlsKnob::Draw
virtual void Draw() DISTI_METHOD_OVERRIDE
disti::GlsKnob::_numDetents
int _numDetents
Number of detents, snap points of the knob.
Definition: gls_knob.h:93
disti::GlsKnob::_currentCursor
unsigned int _currentCursor
The current cursor used for interaction. Any other cursors are ignored while interacting.
Definition: gls_knob.h:233
disti::GlsKnob::ShowDetentsOnly
void ShowDetentsOnly(const bool &value)
disti::GlsKnob::_sideMode
bool _sideMode
If true, the knob is being viewed at or almost side on.
Definition: gls_knob.h:227
disti::GlsKnob::CalcRotationAngle
float CalcRotationAngle()
disti::GlsKnob::_startAngle
float _startAngle
An angle offset from the begining position.
Definition: gls_knob.h:98
disti::GlsKnob::_detentPositions
DynamicArray< float > _detentPositions
Range 0-100.
Definition: gls_knob.h:94
disti::GlsKnob::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
disti::GlsKnob::SetFromGloData
virtual GLS_EXPORT void SetFromGloData(GlsGloFileAttribute &data) DISTI_METHOD_OVERRIDE
disti::GlsKnob::_continuous
bool _continuous
If true, the knob can spin all the way around.
Definition: gls_knob.h:96
disti::GlsKnob::EmitPositionValEvent
bool EmitPositionValEvent()
Definition: gls_knob.h:114
disti::GlsKnob::_atCwStop
bool _atCwStop
If true, the knob has reached its clockwise most position.
Definition: gls_knob.h:224
disti::GlsKnob::PreDraw
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
disti::GlsKnob::ClickSelectsDetent
void ClickSelectsDetent(const bool &value)
Definition: gls_knob.h:173
disti::GlsKnob::_mouseDownoZ
float _mouseDownoZ
Z position of the last mouse down in logical coordinates.
Definition: gls_knob.h:220
disti::GlsKnob::DetentVal
virtual int DetentVal()
disti::GlsKnob::GlsKnob
GlsKnob(const GlsKnob &that, const bool generateNames)
disti::GlsKnob::SetValue
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
disti::GlsKnob::_mouseDownAngle
float _mouseDownAngle
Rotation angle of the knob when the mouse was pressed.
Definition: gls_knob.h:222
disti::GlsKnob::_initialDetentVal
int _initialDetentVal
Stores the initial detent position based on the starting rotation.
Definition: gls_knob.h:217
disti::GlsKnob::_mouseWasDown
bool _mouseWasDown
If true, the mouse was clicked on a previous frame.
Definition: gls_knob.h:232
disti::GlsKnob::PositionVal
virtual void PositionVal(const float &value)
disti::GlsKnob::ClickSelectsDetent
bool ClickSelectsDetent()
Definition: gls_knob.h:176
disti::GlsKnob::_emitPositionValEvent
bool _emitPositionValEvent
If true, will emit an event when the position is changed.
Definition: gls_knob.h:100
disti::GlsKnob::handle
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
disti::GlsKnob::WhichObject
virtual void WhichObject(const int &value)
disti::GlsKnob::CreateInstance
static DisplayObject * CreateInstance()
disti::GlsKnob::PositionVal
virtual float PositionVal()
disti::GlsKnob::_clickSelectsDetent
bool _clickSelectsDetent
If true, clicking on a detent will snap the knob to that detent.
Definition: gls_knob.h:211
disti::GlsKnob::_emitReleaseEvent
bool _emitReleaseEvent
If true, an event will be emitted when the knob is released (mouse up).
Definition: gls_knob.h:214
disti::GlsKnob::~GlsKnob
virtual ~GlsKnob()
disti::GlsKnob::DetentVal
virtual void DetentVal(const int &value)
disti::GlsKnob::_mouseDownDirectionVector
Vector _mouseDownDirectionVector
Unused, kept for backward compatibility.
Definition: gls_knob.h:221
disti::GlsKnob::EmitLimitEvent
void EmitLimitEvent(const bool &value)
disti::GlsKnob::_angleRange
float _angleRange
In degrees.
Definition: gls_knob.h:92
disti::GlsKnob::ShowDetentsOnly
bool ShowDetentsOnly()
Definition: gls_knob.h:169
disti::GlsKnob::_showDetentsOnly
bool _showDetentsOnly
If true, knob will only rotate to exact detents, nothing in between.
Definition: gls_knob.h:210
disti::GlsKnob::CopyProperties
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
disti::GlsKnob::EmitDetentValEvent
bool EmitDetentValEvent()
Definition: gls_knob.h:107
disti::GlsKnob::EmitReleaseEvent
void EmitReleaseEvent(const bool &value)
disti::GlsKnob::EmitPositionValEvent
void EmitPositionValEvent(const bool &value)
disti::GlsKnob::_positionVal
float _positionVal
Current knob position.
Definition: gls_knob.h:95
disti::GlsKnob::_emitLimitEvent
bool _emitLimitEvent
If true, an event will be emitted when the knob reaches its upper or lower limit.
Definition: gls_knob.h:213
disti::GlsKnob::EmitReleaseEvent
bool EmitReleaseEvent()
Definition: gls_knob.h:128
disti::GlsKnob::_mouseDownoX
float _mouseDownoX
X position of the last mouse down in logical coordinates.
Definition: gls_knob.h:218
disti::GlsKnob::EmitLimitEvent
bool EmitLimitEvent()
Definition: gls_knob.h:121
disti::GlsKnob::WhichObject
virtual int WhichObject()
disti::GlsKnob::_whichObject
int _whichObject
The object index in the group to be the knob.
Definition: gls_knob.h:97
disti::GlsKnob::_mouseLastAngle
float _mouseLastAngle
The rotation angle of the knob on the previous frame.
Definition: gls_knob.h:223
disti::Group
Definition: group.h:53
disti::OpenGLMatrices
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
disti::VertexNoColor
Definition: vertex.h:85
gls_auto_lib.h
The gls_auto_lib.
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_SPECIAL_MEM_FUN_DELETE
#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:246
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
GLS_EXPORT
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
GLSGEN_GlsKnob_EXPORT
#define GLSGEN_GlsKnob_EXPORT
Provides support for creating DLLs.
Definition: gls_knob.h:55
group.h
The disti::Group class. Implements groups of objects.
disti
Definition: bmpimage.h:47