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