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