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  DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
98  typedef Group _BaseClass;
99  typedef Group BaseClass;
100 
101  /** Create a new GlsMutexGroup.
102  * \param generateInstance Whether or not to generate an instance name
103  * for this mutex group */
104  GLSGEN_GLSMUTEXGROUP_EXPORT GlsMutexGroup( bool generateInstance = false );
105 
106  GLSGEN_GLSMUTEXGROUP_EXPORT GlsMutexGroup( const GlsMutexGroup& that, const bool generateNames );
107 
108  /** Destructs a GlsMutexGroup object */
109  virtual GLSGEN_GLSMUTEXGROUP_EXPORT ~GlsMutexGroup();
110 
111  static GLSGEN_GLSMUTEXGROUP_EXPORT DisplayObject* CreateInstance();
112 
113  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
114 
115  virtual GLSGEN_GLSMUTEXGROUP_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
116 
117  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
118 
119 #ifndef GLES
120  virtual GLSGEN_GLSMUTEXGROUP_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
121  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
122 #endif
123 
124  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void Calculate( double time ) DISTI_METHOD_OVERRIDE;
125  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
126  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void Draw( void ) DISTI_METHOD_OVERRIDE;
127 
128  virtual GLSGEN_GLSMUTEXGROUP_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
129  const Vector& logicalCoords,
130  float scale,
131  const Vector& directionVector,
132  Vector& collisionWinLoc /*Returned*/,
133  const OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
134 
135  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
136 
137  /** Traverses upward in the hierarchy to determine if this object is visible in the scene.
138  */
139  GLSGEN_GLSMUTEXGROUP_EXPORT bool IsVisibleInScene( const DisplayObject* obj = NULL ) const DISTI_METHOD_OVERRIDE;
140 
141  //////////////////////////////////////////////////
142  // GlsMutexGroup specific operations
143  //////////////////////////////////////////////////
144 
145  /** \return The mutex state of this group, -1 = none */
146  GLSGEN_GLSMUTEXGROUP_EXPORT int MutexState( void ) const { return _state; }
147 
148  /** Sets the mutex state of this group, -1 = none
149  * \param state The new mutex state
150  */
151  GLSGEN_GLSMUTEXGROUP_EXPORT void MutexState( int state );
152 
153  // For legacy InputDevices
154  /** \return The InputDevice state of this group, 1 to N */
155  GLSGEN_GLSMUTEXGROUP_EXPORT int State( void ) { return _state; }
156 
157  // For legacy InputDevices
158  /** Sets the InputDevice state of this group, 1 to N.
159  * \param state The new InputDevice state
160  */
161  GLSGEN_GLSMUTEXGROUP_EXPORT void State( int state );
162 
163  /** \return The calculate option of this group, true = calculate all objects, false = calculate active object only */
164  GLSGEN_GLSMUTEXGROUP_EXPORT bool CalculateInvisibleStates( void ) { return _calculateInvisibleStates; }
165 
166  /** Sets the calculate option of this group
167  * \param value The new calculate option, true = calculate all objects, false = calculate active object only
168  */
169  GLSGEN_GLSMUTEXGROUP_EXPORT void CalculateInvisibleStates( bool value );
170 
171  /** \return The picking option of this group, true = pick all objects, false = pick active object only */
172  GLSGEN_GLSMUTEXGROUP_EXPORT bool PickInvisibleStates( void ) { return _pickInvisibleStates; }
173 
174  /** Sets the picking option of this group
175  * \param value The new picking option, true = pick all objects, false = pick active object only
176  */
177  GLSGEN_GLSMUTEXGROUP_EXPORT void PickInvisibleStates( bool value );
178 
179  /** \return The predraw option of this group, true = predraw all objects, false = predraw active object only */
180  GLSGEN_GLSMUTEXGROUP_EXPORT bool PreDrawInvisibleStates( void ) { return _predrawInvisibleStates; }
181 
182  /** Sets the predraw option of this group
183  * \param value The new predraw option, true = predraw all objects, false = predraw active object only
184  */
185  GLSGEN_GLSMUTEXGROUP_EXPORT void PreDrawInvisibleStates( bool value );
186 
187  /** \return Simulate the legacy InputDevice behavior, where state 0 is always shown and the state is one-based. */
188  GLSGEN_GLSMUTEXGROUP_EXPORT bool InputDeviceBehavior( void ) { return _inputDevice; }
189 
190  /** Sets the simulation of legacy InputDevice behavior, where state 0 is always shown
191  * \param value True = InputDevice, False = MutexGroup
192  */
193  GLSGEN_GLSMUTEXGROUP_EXPORT void InputDeviceBehavior( bool value );
194 
195 protected:
196  bool ValidMutexState( const int state ) const
197  {
198  return ( state >= 0 && state < (int)( _objects.Count() ) );
199  }
200 
201  bool ValidInputDeviceState( const int state ) const
202  {
203  // 0 is not a valid state
204  return ( state > 0 && state < (int)( _objects.Count() ) );
205  }
206 
207  /** Helper routine for Pick3D */
208  DisplayObject* Pick3DUtil( const Vector& winLoc,
209  const Vector& logicalCoords,
210  float scale,
211  const Vector& directionVector,
212  Vector& collisionWinLoc /*Returned*/,
213  const OpenGLMatrices& drawnMatrices );
214 
215 #ifdef GLES
216  /** Set a single attribute from the GLO file.
217  * \param data The attribute to set and its associated data.
218  */
219  virtual GLSGEN_GLSMUTEXGROUP_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
220 #endif
221 
222  bool _inputDevice; /*< True = InputDevice functionality (state 0 always showing)
223  False = MutexGroup functionality */
224 
225  int _state; /*< The index of the currently active object in the group, 0 to N, anything else = none */
226 
227  bool _calculateInvisibleStates; /*< Whether or not to call calculate on invisible states */
228  bool _pickInvisibleStates; /*< Whether or not to call pick on invisible states */
229  bool _predrawInvisibleStates; /*< Whether or not to call predraw on invisible states */
230 };
231 
232 } // namespace disti
233 
234 #endif
Definition: cull.h:49
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
DisplayObject * Pick3DUtil(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices)
virtual void Calculate(double time) DISTI_METHOD_OVERRIDE
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
unsigned Count() const
Definition: dynamic_array.h:204
Definition: dynamic_array.h:66
The disti::Group class. Implements groups of objects.
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:473
int MutexState(void) const
Definition: gls_mutex_group.h:146
bool PickInvisibleStates(void)
Definition: gls_mutex_group.h:172
virtual ~GlsMutexGroup()
Definition: display.h:98
bool InputDeviceBehavior(void)
Definition: gls_mutex_group.h:188
int State(void)
Definition: gls_mutex_group.h:155
DisplayObject(float x, float y, float z)
VertexNoColor Vector
Definition: gls_font_base.h:66
Definition: gls_mutex_group.h:89
The gls_auto_lib.
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL) DISTI_METHOD_OVERRIDE
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices) DISTI_METHOD_OVERRIDE
virtual void Draw(void) DISTI_METHOD_OVERRIDE
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
Definition: group.h:52
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
Definition: vertex.h:84
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
bool PreDrawInvisibleStates(void)
Definition: gls_mutex_group.h:180
bool IsVisibleInScene(const DisplayObject *obj=NULL) const DISTI_METHOD_OVERRIDE
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: bmpimage.h:46
bool CalculateInvisibleStates(void)
Definition: gls_mutex_group.h:164
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array) DISTI_METHOD_OVERRIDE