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 #define LIB_BASE_NAME "gls_knob"
60 #include "gls_auto_lib.h"
61 #undef LIB_BASE_NAME
62 
63 namespace disti
64 {
65 enum
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 */
83 class GlsKnob : public Group
84 {
85 public:
86  friend class GlsKnobEditor;
87  DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
88  typedef Group _BaseClass;
89  typedef Group BaseClass;
90 
91  float _angleRange; // In degrees
92  int _numDetents;
93  DynamicArray<float> _detentPositions; // Range 0-100
94  float _positionVal; // Current knob position
95  bool _continuous;
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;
99  bool _emitPositionValEvent;
100 
101  /** Set if object should emit the DeventVal event */
102  inline void EmitDetentValEvent( const bool& value );
103  /** Get if object should emit the DeventVal event */
104  inline bool EmitDetentValEvent() { return _emitDetentValEvent; }
105 
106  /** Set if object should emit the PositionVal event */
107  inline void EmitPositionValEvent( const bool& value );
108  /** Get if object should emit the PositionVal event */
109  inline bool EmitPositionValEvent() { return _emitPositionValEvent; }
110 
111  /** Set if object should emit the Limit event */
112  inline void EmitLimitEvent( const bool& value );
113  /** Get if object should emit the Limit event */
114  inline bool EmitLimitEvent() { return _emitLimitEvent; }
115 
116  /** Set if object should emit the Release event */
117  inline void EmitReleaseEvent( const bool& value );
118  /** Get if object should emit the Release event */
119  inline bool EmitReleaseEvent() { return _emitReleaseEvent; }
120 
121  /** Create a new GlsKnob.
122  * \param generateInstance Whether or not to generate an instance name
123  * for this inputdevice */
124  GLSGEN_GlsKnob_EXPORT GlsKnob( bool generateInstance = false );
125 
126  GLSGEN_GlsKnob_EXPORT GlsKnob( const GlsKnob& that, const bool generateNames );
127 
128  /** Destroy a GlsKnob object */
129  virtual GLSGEN_GlsKnob_EXPORT ~GlsKnob();
130 
131  static GLSGEN_GlsKnob_EXPORT DisplayObject* CreateInstance();
132 
133  virtual GLSGEN_GlsKnob_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
134 
135  virtual GLSGEN_GlsKnob_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
136 
137  virtual GLSGEN_GlsKnob_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
138 
139  virtual GLSGEN_GlsKnob_EXPORT void Draw( void ) DISTI_METHOD_OVERRIDE;
140 
141  virtual GLSGEN_GlsKnob_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
142 
143 #ifndef GLES
144  /* See base class */
145  virtual GLSGEN_GlsKnob_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
146  /* See base class */
147  virtual GLSGEN_GlsKnob_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
148 #endif
149  /* See base class */
150  virtual GLSGEN_GlsKnob_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
151 
152  //////////////////////////////////////////////////
153  // Knob specific operations
154  //////////////////////////////////////////////////
155  GLSGEN_GlsKnob_EXPORT DisplayObject* handle( DisplayEvent* ev ) DISTI_METHOD_OVERRIDE;
156 
157  /** Sets the value of the ShowDetentsOnly property.
158  */
159  GLSGEN_GlsKnob_EXPORT void ShowDetentsOnly( const bool& value );
160 
161  /** Returns the value of the ShowDetentsOnly property.
162  */
163  inline bool ShowDetentsOnly() { return _showDetentsOnly; }
164 
165  /** Sets the value of the ClickSelectsDetent property.
166  */
167  inline void ClickSelectsDetent( const bool& value ) { _clickSelectsDetent = value; }
168 
169  /** Returns the value of the ClickSelectsDetent property.
170  */
171  inline bool ClickSelectsDetent() { return _clickSelectsDetent; }
172 
173  /** Moves the knob to the specified detent
174  * Sets the detent value
175  * \param value Desired detent, first detent == 1
176  */
177  virtual GLSGEN_GlsKnob_EXPORT void DetentVal( const int& value );
178 
179  /** Returns the nearest detent for the knob's current poistion.
180  * \return Nearest detent, first detent == 1
181  */
182  virtual GLSGEN_GlsKnob_EXPORT int DetentVal();
183 
184  /** Sets current position of the knob (0.0 - 100.0)
185  * \param value New position of the knob (0.0 - 100.0)
186  */
187  virtual GLSGEN_GlsKnob_EXPORT void PositionVal( const float& value );
188 
189  /** Returns the current position of the knob (0.0 - 100.0)
190  * \return Current knob position (0.0 - 100.0)
191  */
192  virtual GLSGEN_GlsKnob_EXPORT float PositionVal();
193 
194  /** Sets the current knob geometry index value
195  * \param value Knob geometry index value
196  */
197  virtual GLSGEN_GlsKnob_EXPORT void WhichObject( const int& value );
198 
199  /** Returns the current knob geometry index value
200  * \return Knob geometry index value
201  */
202  virtual GLSGEN_GlsKnob_EXPORT int WhichObject();
203 
204 protected:
205  bool _showDetentsOnly;
206  bool _clickSelectsDetent;
207 
208  bool _emitLimitEvent;
209  bool _emitReleaseEvent;
210 
211  // Some private data for internal calculations
212  int _initialDetentVal;
213  float _mouseDownoX, _mouseDownoY, _mouseDownoZ;
214  Vector _mouseDownDirectionVector;
215  float _mouseDownAngle;
216  float _mouseLastAngle;
217  bool _atCwStop;
218  bool _atCcwStop;
219 
220  bool _sideMode;
221  GLSGEN_GlsKnob_EXPORT float CalcRotationAngle();
222 
223  bool _mouseWasDown;
224  unsigned int _currentCursor; // the current cursor used for interaction. Any other cursors are ignored while interacting.
225 
226 #ifdef GLES
227  /** Set a single attribute from the GLO file.
228  * \param data The attribute to set and its associated data.
229  */
230  virtual GLS_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
231 #endif
232 
233 private:
234  // disallow implicit assignments and copy constructor
235  GlsKnob& operator=( const GlsKnob& ) DISTI_SPECIAL_MEM_FUN_DELETE;
236  GlsKnob( const GlsKnob& ) DISTI_SPECIAL_MEM_FUN_DELETE;
237 };
238 
239 } // namespace disti
240 
241 #endif
Definition: cull.h:49
DisplayObject * handle(DisplayEvent *ev) DISTI_METHOD_OVERRIDE
bool EmitLimitEvent()
Definition: gls_knob.h:114
virtual int DetentVal()
virtual float PositionVal()
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
bool ClickSelectsDetent()
Definition: gls_knob.h:171
The disti::Group class. Implements groups of objects.
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:471
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
Definition: display.h:98
bool EmitDetentValEvent()
Definition: gls_knob.h:104
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
Definition: gls_glo_file.h:988
bool EmitReleaseEvent()
Definition: gls_knob.h:119
GlsKnob(bool generateInstance=false)
bool EmitPositionValEvent()
Definition: gls_knob.h:109
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
Definition: events.h:112
virtual ~GlsKnob()
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
bool ShowDetentsOnly()
Definition: gls_knob.h:163
The gls_auto_lib.
void ClickSelectsDetent(const bool &value)
Definition: gls_knob.h:167
Definition: group.h:52
Definition: vertex.h:84
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: gls_knob.h:83
Definition: bmpimage.h:46
virtual void Draw(void) DISTI_METHOD_OVERRIDE
virtual int WhichObject()