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