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