GL Studio C++ Runtime API
gls_switch.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsSwitch 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_SWITCH_H
41 #define _GLS_SWITCH_H
42 
43 #include "gls_cpp_lang_support.h"
44 #include "glsutil.h"
45 #include "group.h"
46 
47 //////////////////// Provides support for creating DLLs ////////////////////////
48 #if( defined( GLSGEN_EXPORT_GlsSwitch ) || defined( GLSGEN_IMPORT_GlsSwitch ) || defined( GLS_EXPORT_GENERATED ) || defined( GLS_IMPORT_GENERATED ) ) \
49  && defined( _MSC_VER )
50 # if defined( GLSGEN_EXPORT_GlsSwitch ) || defined( GLS_EXPORT_GENERATED )
51 # define GLSGEN_GlsSwitch_EXPORT __declspec( dllexport )
52 # else
53 # define GLSGEN_GlsSwitch_EXPORT __declspec( dllimport )
54 # endif
55 #else
56 # define GLSGEN_GlsSwitch_EXPORT
57 #endif
58 ///////////////////////////////////////////////////////////////////////////////
59 
60 #define LIB_BASE_NAME "gls_switch"
61 #include "gls_auto_lib.h"
62 #undef LIB_BASE_NAME
63 
64 namespace disti
65 {
66 enum
67 {
68  GLS_GLSSWITCH_INITIAL_DETENT_VAL = GLS_LAST_INITIALIZER + 1,
69  GLS_GLSSWITCH_WHICH_OBJECT_BACKGROUND,
70  GLS_GLSSWITCH_FIRST_DETENT_SNAPBACK, // for normal or snapback behavior
71  GLS_GLSSWITCH_LAST_DETENT_SNAPBACK, // for normal or snapback behavior
72  GLS_GLSSWITCH_EMIT_DETENT_VAL_EVENT,
73  GLS_GLSSWITCH_EMIT_LIMIT_EVENT,
74  GLS_GLSSWITCH_EMIT_RELEASE_EVENT
75 };
76 
77 /** Runtime implementation of a switch */
78 class GlsSwitch : public Group
79 {
80 private:
81  GlsSwitch& operator=( const GlsSwitch& ) DISTI_SPECIAL_MEM_FUN_DELETE;
82  GlsSwitch( const GlsSwitch& ) DISTI_SPECIAL_MEM_FUN_DELETE;
83 
84 public:
85  friend class GlsSwitchEditor;
86  typedef Group _BaseClass;
87 
88  int _detentVal; // CurrentPosition
89  bool _firstDetentSnapback;
90  bool _lastDetentSnapback;
91  int _whichObjectBackground; // the geometry index (plus 1) to serve as the switch background. 0 is no background object.
92  bool _emitDetentValEvent;
93 
94  /** Set if a DetentVal event should be emitted */
95  inline void EmitDetentValEvent( const bool& value );
96  /** Get if a DetentVal event should be emitted */
97  inline bool EmitDetentValEvent() { return _emitDetentValEvent; }
98 
99  /** Set if a Limit event should be emitted */
100  inline void EmitLimitEvent( const bool& value );
101  /** Get if a Limit event should be emitted */
102  inline bool EmitLimitEvent() { return _emitLimitEvent; }
103 
104  /** Set if a Release event should be emitted */
105  inline void EmitReleaseEvent( const bool& value );
106  /** Get if a Release event should be emitted */
107  inline bool EmitReleaseEvent() { return _emitReleaseEvent; }
108 
109  /** Returns the number of detents on this switch */
110  GLSGEN_GlsSwitch_EXPORT int NumDetents();
111  /** Returns the geometry associated with the detent */
112  GLSGEN_GlsSwitch_EXPORT DisplayObject* DetentGeometry( int detent );
113  /** Returns the geometry specified as the background.
114  * NULL is returned if none
115  */
116  GLSGEN_GlsSwitch_EXPORT DisplayObject* BackgroundGeometry();
117 
118  /** Create a new GlsSwitch.
119  * \param generateInstance Whether or not to generate an instance name
120  * for this inputdevice */
121  GLSGEN_GlsSwitch_EXPORT GlsSwitch( bool generateInstance = false );
122 
123  GLSGEN_GlsSwitch_EXPORT GlsSwitch( const GlsSwitch& that, const bool generateNames );
124 
125  /** Destroy a GlsSwitch object */
126  virtual GLSGEN_GlsSwitch_EXPORT ~GlsSwitch();
127 
128  static GLSGEN_GlsSwitch_EXPORT DisplayObject* CreateInstance();
129 
130  virtual GLSGEN_GlsSwitch_EXPORT void SetAvailableAttributes( unsigned int value );
131 
132  virtual GLSGEN_GlsSwitch_EXPORT DisplayObject* CloneObject( bool generateNames = false );
133 
134  virtual GLSGEN_GlsSwitch_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler );
135 
136  virtual GLSGEN_GlsSwitch_EXPORT void Draw( void );
137 
138  virtual GLSGEN_GlsSwitch_EXPORT void CopyProperties( DisplayObject* src );
139 
140 #ifndef GLES
141  /* See base class */
142  virtual GLSGEN_GlsSwitch_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
143  virtual GLSGEN_GlsSwitch_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
144 #endif
145 
146  /* Calculates if this switch is horizontal or vertical relative to the y axis */
147  InputOrientationEnum InputType( void );
148 
149  GLSGEN_GlsSwitch_EXPORT DisplayObject* handle( DisplayEvent* ev );
150 
151  /* See base class */
152  virtual GLSGEN_GlsSwitch_EXPORT void SetValue( int spec, va_list& args );
153 
154  //////////////////////////////////////////////////
155  // Switch specific operations
156  //////////////////////////////////////////////////
157 
158  /** Sets current detent of the switch
159  * \param val New detent of the switch
160  */
161  virtual GLSGEN_GlsSwitch_EXPORT void DetentVal( const int& val );
162 
163  /** Returns the current detent of the switch
164  * \return Current switch detent
165  */
166  virtual GLSGEN_GlsSwitch_EXPORT int DetentVal();
167 
168  /** Sets current background geometry index value of the switch
169  * \param val New switch background geometry index value
170  */
171  virtual GLSGEN_GlsSwitch_EXPORT void WhichObjectBackground( const int& val );
172 
173  /** Returns the current background geometry index value of the switch
174  * \return Current switch background geometry index value
175  */
176  virtual GLSGEN_GlsSwitch_EXPORT int WhichObjectBackground();
177 
178 protected:
179  bool _emitLimitEvent;
180  bool _emitReleaseEvent;
181 
182  Vector _mouseDownOCoords;
183 
184  bool _mouseWasDown;
185  unsigned int _currentCursor; // the current cursor used for interaction. Any other cursors are ignored while interacting.
186 
187  /** Uses event data to calculate a new switch position based on the DCS of the object.
188  * This is not intended to be called directly.
189  */
191  InputOrientationEnum inputType, int numPositions,
192  float scale = 1.0f );
193 
194 #ifdef GLES
195  /** Set a single attribute from the GLO file.
196  * \param data The attribute to set and its associated data.
197  */
198  virtual GLSGEN_GlsSwitch_EXPORT void SetFromGloData( GlsGloFileAttribute& data );
199 #endif
200 };
201 
202 } // namespace disti
203 
204 #endif
Definition: cull.h:49
virtual ~GlsSwitch()
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
Definition: dynamic_array.h:62
The disti::Group class. Implements groups of objects.
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:276
bool EmitDetentValEvent()
Definition: gls_switch.h:97
DisplayObject * BackgroundGeometry()
Definition: display.h:98
int CalcSwitchPosDCS(DisplayObject *self, DisplayEvent *ev, InputOrientationEnum inputType, int numPositions, float scale=1.0f)
InputOrientationEnum
Enumeration for Input Operators.
Definition: glsutil.h:262
bool EmitLimitEvent()
Definition: gls_switch.h:102
Definition: gls_glo_file.h:982
virtual int WhichObjectBackground()
Definition: gls_switch.h:78
virtual void CopyProperties(DisplayObject *src)
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
virtual void SetValue(int spec, va_list &args)
DisplayObject * DetentGeometry(int detent)
Definition: events.h:111
DisplayObject * handle(DisplayEvent *ev)
The gls_auto_lib.
Definition: group.h:52
Definition: vertex.h:83
virtual int DetentVal()
Macros and helper code to determine what subset of C++11/14/17 is available.
virtual DisplayObject * CloneObject(bool generateNames=false)
GL Studio helper functions.
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
Definition: bmpimage.h:46
virtual void Draw(void)
bool EmitReleaseEvent()
Definition: gls_switch.h:107
virtual void SetAvailableAttributes(unsigned int value)