GL Studio API
gls_mutex_group.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsMutexGroup 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 
41 #ifndef _GLS_MUTEX_GROUP_H
42 #define _GLS_MUTEX_GROUP_H
43 
44 #include "group.h"
45 #include "gls_cpp_lang_support.h"
46 
47 //////////////////// Provides support for creating DLLs ////////////////////////
48 #if (defined(GLSGEN_EXPORT_GLSMUTEXGROUP) || \
49  defined(GLSGEN_IMPORT_GLSMUTEXGROUP) || \
50  defined(GLS_EXPORT_GENERATED) || \
51  defined(GLS_IMPORT_GENERATED)) \
52  && defined(_MSC_VER)
53 # if defined(GLSGEN_EXPORT_GLSMUTEXGROUP) || defined(GLS_EXPORT_GENERATED)
54 # define GLSGEN_GLSMUTEXGROUP_EXPORT __declspec(dllexport)
55 # else
56 # define GLSGEN_GLSMUTEXGROUP_EXPORT __declspec(dllimport)
57 # endif
58 #else
59 # define GLSGEN_GLSMUTEXGROUP_EXPORT
60 #endif
61 ///////////////////////////////////////////////////////////////////////////////
62 
63 #define LIB_BASE_NAME "gls_mutex_group"
64 #include "gls_auto_lib.h"
65 #undef LIB_BASE_NAME
66 
67 namespace disti
68 {
69 
70 // These are specific to GlsMutexGroup
71 static AttributeName MetaMutexState("MutexState");
72 static AttributeName MetaState("State");
73 static AttributeName MetaCalculateInvisibleStates("CalculateInvisibleStates");
74 static AttributeName MetaPickInvisibleStates("PickInvisibleStates");
75 static AttributeName MetaPredrawInvisibleStates("PreDrawInvisibleStates");
76 static AttributeName MetaInputDeviceBehavior("InputDeviceBehavior");
77 
78 // SetValue enumerations
79 enum {
80  GLS_MUTEX_GROUP_STATE = GLS_LAST_INITIALIZER+1,
81  GLS_MUTEX_GROUP_CALC_INVISIBLE_STATES,
82  GLS_MUTEX_GROUP_PICK_INVISIBLE_STATES,
83  GLS_MUTEX_GROUP_PREDRAW_INVISIBLE_STATES,
84  GLS_MUTEX_GROUP_INPUT_DEVICE_BEHAVIOR
85 };
86 
87 #ifdef GLES
88 class GlsGloFileAttribute;
89 #endif
90 
91 /** Runtime implementation of a GlsMutexGroup */
92 class GlsMutexGroup : public Group
93 {
94 private:
95  GlsMutexGroup& operator=( const GlsMutexGroup& ) DISTI_SPECIAL_MEM_FUN_DELETE;
96  GlsMutexGroup( const GlsMutexGroup& ) DISTI_SPECIAL_MEM_FUN_DELETE;
97 
98 public:
99 
100  friend class GlsMutexGroupEditor;
101  typedef Group _BaseClass;
102 
103  /** Create a new GlsMutexGroup.
104  * \param generateInstance Whether or not to generate an instance name
105  * for this mutex group */
106  GLSGEN_GLSMUTEXGROUP_EXPORT GlsMutexGroup(bool generateInstance=false);
107 
108  GLSGEN_GLSMUTEXGROUP_EXPORT GlsMutexGroup( const GlsMutexGroup& that, const bool generateNames );
109 
110  /** Destructs a GlsMutexGroup object */
111  virtual GLSGEN_GLSMUTEXGROUP_EXPORT ~GlsMutexGroup();
112 
113  static GLSGEN_GLSMUTEXGROUP_EXPORT DisplayObject* CreateInstance();
114 
115  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void SetAvailableAttributes(unsigned int value);
116 
117  virtual GLSGEN_GLSMUTEXGROUP_EXPORT DisplayObject* CloneObject(bool generateNames = false);
118 
119  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void CopyProperties(DisplayObject *src);
120 
121 #ifndef GLES
122  virtual GLSGEN_GLSMUTEXGROUP_EXPORT InterfaceListType* GetCppInterfaceDescription(InterfaceListType* addToThisList= NULL );
123  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void GetCppInterfaceDescriptionFree(InterfaceListType* array);
124 #endif
125 
126  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void Calculate(double time);
127  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void PreDraw(const OpenGLMatrices& parentMatrices,Culler &culler);
128  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void Draw(void);
129 
130  virtual GLSGEN_GLSMUTEXGROUP_EXPORT DisplayObject* Pick3D(const Vector& winLoc,
131  const Vector& logicalCoords,
132  float scale,
133  const Vector& directionVector,
134  Vector& collisionWinLoc /*Returned*/,
135  const OpenGLMatrices& drawnMatrices);
136 
137  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void SetValue(int spec,va_list &args);
138 
139  //////////////////////////////////////////////////
140  // GlsMutexGroup specific operations
141  //////////////////////////////////////////////////
142 
143  /** \return The mutex state of this group, -1 = none */
144  GLSGEN_GLSMUTEXGROUP_EXPORT int MutexState(void) { return _state; }
145 
146  /** Sets the mutex state of this group, -1 = none
147  * \param state The new mutex state
148  */
149  GLSGEN_GLSMUTEXGROUP_EXPORT void MutexState(int state);
150 
151  // For legacy InputDevices
152  /** \return The InputDevice state of this group, 1 to N */
153  GLSGEN_GLSMUTEXGROUP_EXPORT int State(void) { return _state; }
154 
155  // For legacy InputDevices
156  /** Sets the InputDevice state of this group, 1 to N.
157  * \param state The new InputDevice state
158  */
159  GLSGEN_GLSMUTEXGROUP_EXPORT void State(int state);
160 
161  /** \return The calculate option of this group, true = calculate all objects, false = calculate active object only */
162  GLSGEN_GLSMUTEXGROUP_EXPORT bool CalculateInvisibleStates(void) { return _calculateInvisibleStates; }
163 
164  /** Sets the calculate option of this group
165  * \param value The new calculate option, true = calculate all objects, false = calculate active object only
166  */
167  GLSGEN_GLSMUTEXGROUP_EXPORT void CalculateInvisibleStates(bool value);
168 
169  /** \return The picking option of this group, true = pick all objects, false = pick active object only */
170  GLSGEN_GLSMUTEXGROUP_EXPORT bool PickInvisibleStates(void) { return _pickInvisibleStates; }
171 
172  /** Sets the picking option of this group
173  * \param value The new picking option, true = pick all objects, false = pick active object only
174  */
175  GLSGEN_GLSMUTEXGROUP_EXPORT void PickInvisibleStates(bool value);
176 
177  /** \return The predraw option of this group, true = predraw all objects, false = predraw active object only */
178  GLSGEN_GLSMUTEXGROUP_EXPORT bool PreDrawInvisibleStates(void) { return _predrawInvisibleStates; }
179 
180  /** Sets the predraw option of this group
181  * \param value The new predraw option, true = predraw all objects, false = predraw active object only
182  */
183  GLSGEN_GLSMUTEXGROUP_EXPORT void PreDrawInvisibleStates(bool value);
184 
185  /** \return Simulate the legacy InputDevice behavior, where state 0 is always shown and the state is one-based. */
186  GLSGEN_GLSMUTEXGROUP_EXPORT bool InputDeviceBehavior(void) { return _inputDevice; }
187 
188  /** Sets the simulation of legacy InputDevice behavior, where state 0 is always shown
189  * \param value True = InputDevice, False = MutexGroup
190  */
191  GLSGEN_GLSMUTEXGROUP_EXPORT void InputDeviceBehavior(bool value);
192 
193 protected:
194 
195  bool ValidMutexState(const int state) const
196  {
197  return (state >= 0 && state < (int)(_objects.Count()));
198  }
199 
200  bool ValidInputDeviceState(const int state) const
201  {
202  // 0 is not a valid state
203  return (state > 0 && state < (int)(_objects.Count()));
204  }
205 
206  /** Helper routine for Pick3D */
207  DisplayObject* Pick3DUtil(const Vector& winLoc,
208  const Vector& logicalCoords,
209  float scale,
210  const Vector& directionVector,
211  Vector& collisionWinLoc /*Returned*/,
212  const OpenGLMatrices& drawnMatrices);
213 
214 #ifdef GLES
215  /** Set a single attribute from the GLO file.
216  * \param data The attribute to set and its associated data.
217  */
218  virtual void SetFromGloData(GlsGloFileAttribute &data);
219 #endif
220 
221  bool _inputDevice; /*< True = InputDevice functionality (state 0 always showing)
222  False = MutexGroup functionality */
223 
224  int _state; /*< The index of the currently active object in the group, 0 to N, anything else = none */
225 
226  bool _calculateInvisibleStates; /*< Whether or not to call calculate on invisible states */
227  bool _pickInvisibleStates; /*< Whether or not to call pick on invisible states */
228  bool _predrawInvisibleStates; /*< Whether or not to call predraw on invisible states */
229 };
230 
231 } // namespace disti
232 
233 #endif
234 
Definition: cull.h:50
DisplayObject * Pick3DUtil(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices)
int MutexState(void)
Definition: gls_mutex_group.h:144
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 PickInvisibleStates(void)
Definition: gls_mutex_group.h:170
virtual ~GlsMutexGroup()
Definition: display.h:98
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler)
bool InputDeviceBehavior(void)
Definition: gls_mutex_group.h:186
int State(void)
Definition: gls_mutex_group.h:153
DisplayObject(float x, float y, float z)
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices)
virtual void SetValue(int spec, va_list &args)
virtual void CopyProperties(DisplayObject *src)
virtual DisplayObject * CloneObject(bool generateNames=false)
VertexNoColor Vector
Definition: gls_font_base.h:68
void Count(const unsigned int count)
Definition: dynamic_array.h:120
virtual void SetAvailableAttributes(unsigned int value)
Definition: gls_mutex_group.h:92
The gls_auto_lib.
Definition: group.h:53
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
Definition: vertex.h:84
bool PreDrawInvisibleStates(void)
Definition: gls_mutex_group.h:178
Macros and helper code to determine what subset of C++11/14/17 is available.
virtual void Draw(void)
Definition: bmpimage.h:46
virtual void Calculate(double time)
bool CalculateInvisibleStates(void)
Definition: gls_mutex_group.h:162