| 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/// Automatically link the runtime library plugin (on Windows).
61#define LIB_BASE_NAME "gls_mutex_group"
62#include "gls_auto_lib.h"
63#undef LIB_BASE_NAME
64
65 namespace disti
66{
67// These are specific to GlsMutexGroup
68 static AttributeName MetaMutexState( "MutexState" );
69 static AttributeName MetaState( "State" );
70 static AttributeName MetaCalculateInvisibleStates( "CalculateInvisibleStates" );
71 static AttributeName MetaPickInvisibleStates( "PickInvisibleStates" );
72 static AttributeName MetaPredrawInvisibleStates( "PreDrawInvisibleStates" );
73 static AttributeName MetaInputDeviceBehavior( "InputDeviceBehavior" );
74
75// SetValue enumerations
76 enum
77{
78 GLS_MUTEX_GROUP_STATE = GLS_LAST_INITIALIZER + 1,
79 GLS_MUTEX_GROUP_CALC_INVISIBLE_STATES,
80 GLS_MUTEX_GROUP_PICK_INVISIBLE_STATES,
81 GLS_MUTEX_GROUP_PREDRAW_INVISIBLE_STATES,
82 GLS_MUTEX_GROUP_INPUT_DEVICE_BEHAVIOR
83};
84
85#ifdef GLES
86 class GlsGloFileAttribute;
87#endif
88
89/** Runtime implementation of a GlsMutexGroup */
90 class GlsMutexGroup : public Group
91{
92 private:
93 GlsMutexGroup& operator=( const GlsMutexGroup& ) DISTI_SPECIAL_MEM_FUN_DELETE;
94 GlsMutexGroup( const GlsMutexGroup& ) DISTI_SPECIAL_MEM_FUN_DELETE;
95
96 public:
97 friend class GlsMutexGroupEditor;
98 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
99 typedef Group _BaseClass; ///< Deprecated typedef for the base class.
100 typedef Group BaseClass; ///< Typedef for the base class.
101
102 /** Create a new GlsMutexGroup.
103 * \param generateInstance Whether or not to generate an instance name
104 * for this mutex group */
105 GLSGEN_GLSMUTEXGROUP_EXPORT GlsMutexGroup( bool generateInstance = false );
106
107 /// Copy constructor
108 /// \param that The object to copy from.
109 /// \param generateNames Whether or not to generate an instance name.
110 GLSGEN_GLSMUTEXGROUP_EXPORT GlsMutexGroup( const GlsMutexGroup& that, const bool generateNames );
111
112 /** Destructs a GlsMutexGroup object */
113 virtual GLSGEN_GLSMUTEXGROUP_EXPORT ~GlsMutexGroup();
114
115 /// \return A pointer to a new GlsMutexGroup object.
116 static GLSGEN_GLSMUTEXGROUP_EXPORT DisplayObject* CreateInstance();
117
118 virtual GLSGEN_GLSMUTEXGROUP_EXPORT void SetAvailableAttributes( unsigned int value ) DISTI_METHOD_OVERRIDE;
119 virtual GLSGEN_GLSMUTEXGROUP_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
120 virtual GLSGEN_GLSMUTEXGROUP_EXPORT void CopyProperties( DisplayObject* src ) DISTI_METHOD_OVERRIDE;
121
122#ifndef GLES
123 virtual GLSGEN_GLSMUTEXGROUP_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
124 virtual GLSGEN_GLSMUTEXGROUP_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
125#endif
126
127 virtual GLSGEN_GLSMUTEXGROUP_EXPORT void Calculate( double time ) DISTI_METHOD_OVERRIDE;
128 virtual GLSGEN_GLSMUTEXGROUP_EXPORT void PreDraw( const OpenGLMatrices& parentMatrices, Culler& culler ) DISTI_METHOD_OVERRIDE;
129 virtual GLSGEN_GLSMUTEXGROUP_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
130
131 virtual GLSGEN_GLSMUTEXGROUP_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
132 const Vector& logicalCoords,
133 float scale,
134 const Vector& directionVector,
135 Vector& collisionWinLoc /*Returned*/,
136 const OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
137
138 virtual GLSGEN_GLSMUTEXGROUP_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
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() 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() { 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() { 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() { 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() { 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() { 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 /// \return True if the incoming state index is valid for this mutex group.
197 /// \param state The index to test.
198 bool ValidMutexState( const int state ) const
199 {
200 return ( state >= 0 && state < (int)( _objects.Count() ) );
201 }
202
203 /// \return True if the incoming legacy input device state index is valid for this mutex group.
204 /// \param state The index to test.
205 bool ValidInputDeviceState( const int state ) const
206 {
207 // 0 is not a valid state
208 return ( state > 0 && state < (int)( _objects.Count() ) );
209 }
210
211 /// Helper routine for Pick3D, \see Pick3D
212 /// \note Not normally called by users.
213 /// \param winLoc Device coordinates for the mouse click. Z value should be set to 0 to ensure pick ray starts at near clip plane.
214 /// \param logicalCoords The start of the pick ray in logical coordinates. Should be calculated from the winLoc using this->WindowToLogical(winLoc, logicalCoords, &directionVector).
215 /// \param scale Current window scale. Affects picking radius of outlines. Initial value should typically be 1.0.
216 /// \param directionVector The direction of the pick ray in logical coordinates. Should be calculated from the winLoc using this->WindowToLogical(winLoc, logicalCoords, &directionVector).
217 /// \param collisionWinLoc Returns where the pick vector intersects the object that is hit in device coordinates.
218 /// \param drawnMatrices The matrices used to draw the object, including matrices set by parents that may have
219 /// dynamically rotated, translated or scaled this object. Initial value should typically be a default OpenGLMatrices() object.
220 /// \return The object that was hit, or NULL if no object hit.
221 DisplayObject* Pick3DUtil( const Vector& winLoc,
222 const Vector& logicalCoords,
223 float scale,
224 const Vector& directionVector,
225 Vector& collisionWinLoc /*Returned*/,
226 const OpenGLMatrices& drawnMatrices );
227
228#ifdef GLES
229 /** Set a single attribute from the GLO file.
230 * \param data The attribute to set and its associated data.
231 */
232 virtual GLSGEN_GLSMUTEXGROUP_EXPORT void SetFromGloData( GlsGloFileAttribute& data ) DISTI_METHOD_OVERRIDE;
233#endif
234
235 bool _inputDevice; ///< True = InputDevice functionality (state 0 always showing)
236 ///< False = MutexGroup functionality
237
238 int _state; ///< The index of the currently active object in the group, 0 to N, anything else = none
239
240 bool _calculateInvisibleStates; ///< Whether or not to call calculate on invisible states.
241 bool _pickInvisibleStates; ///< Whether or not to call pick on invisible states.
242 bool _predrawInvisibleStates; ///< Whether or not to call predraw on invisible states.
243};
244
245} // namespace disti
246
247#endif
disti::Culler
Definition: cull.h:50
disti::DisplayObject
Definition: display.h:96
disti::DynamicArray
Definition: dynamic_array.h:79
disti::DynamicArray::Count
unsigned Count() const
Definition: dynamic_array.h:218
disti::GlsGloFileAttribute
Definition: gls_glo_file.h:1243
disti::GlsMutexGroup
Definition: gls_mutex_group.h:91
disti::GlsMutexGroup::SetAvailableAttributes
virtual void SetAvailableAttributes(unsigned int value) DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::InputDeviceBehavior
bool InputDeviceBehavior()
Definition: gls_mutex_group.h:188
disti::GlsMutexGroup::Draw
virtual void Draw() DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::_predrawInvisibleStates
bool _predrawInvisibleStates
Whether or not to call predraw on invisible states.
Definition: gls_mutex_group.h:242
disti::GlsMutexGroup::Pick3DUtil
DisplayObject * Pick3DUtil(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices)
disti::GlsMutexGroup::PickInvisibleStates
bool PickInvisibleStates()
Definition: gls_mutex_group.h:172
disti::GlsMutexGroup::CloneObject
virtual DisplayObject * CloneObject(bool generateNames=false) DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::State
void State(int state)
disti::GlsMutexGroup::_state
int _state
The index of the currently active object in the group, 0 to N, anything else = none.
Definition: gls_mutex_group.h:238
disti::GlsMutexGroup::PickInvisibleStates
void PickInvisibleStates(bool value)
disti::GlsMutexGroup::SetFromGloData
virtual void SetFromGloData(GlsGloFileAttribute &data) DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::ValidInputDeviceState
bool ValidInputDeviceState(const int state) const
Definition: gls_mutex_group.h:205
disti::GlsMutexGroup::PreDraw
virtual void PreDraw(const OpenGLMatrices &parentMatrices, Culler &culler) DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::MutexState
void MutexState(int state)
disti::GlsMutexGroup::SetValue
virtual void SetValue(int spec, va_list &args) DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::CalculateInvisibleStates
bool CalculateInvisibleStates()
Definition: gls_mutex_group.h:164
disti::GlsMutexGroup::MutexState
int MutexState() const
Definition: gls_mutex_group.h:146
disti::GlsMutexGroup::_calculateInvisibleStates
bool _calculateInvisibleStates
Whether or not to call calculate on invisible states.
Definition: gls_mutex_group.h:240
disti::GlsMutexGroup::Calculate
virtual void Calculate(double time) DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::CreateInstance
static DisplayObject * CreateInstance()
disti::GlsMutexGroup::PreDrawInvisibleStates
void PreDrawInvisibleStates(bool value)
disti::GlsMutexGroup::IsVisibleInScene
bool IsVisibleInScene(const DisplayObject *obj=NULL) const DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::ValidMutexState
bool ValidMutexState(const int state) const
Definition: gls_mutex_group.h:198
disti::GlsMutexGroup::Pick3D
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices) DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::CopyProperties
virtual void CopyProperties(DisplayObject *src) DISTI_METHOD_OVERRIDE
disti::GlsMutexGroup::_inputDevice
bool _inputDevice
Definition: gls_mutex_group.h:235
disti::GlsMutexGroup::State
int State()
Definition: gls_mutex_group.h:155
disti::GlsMutexGroup::CalculateInvisibleStates
void CalculateInvisibleStates(bool value)
disti::GlsMutexGroup::_pickInvisibleStates
bool _pickInvisibleStates
Whether or not to call pick on invisible states.
Definition: gls_mutex_group.h:241
disti::GlsMutexGroup::InputDeviceBehavior
void InputDeviceBehavior(bool value)
disti::GlsMutexGroup::PreDrawInvisibleStates
bool PreDrawInvisibleStates()
Definition: gls_mutex_group.h:180
disti::Group
Definition: group.h:53
disti::Group::_objects
DisplayObjectArray _objects
The objects contained in this group.
Definition: group.h:83
disti::OpenGLMatrices
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
disti::VertexNoColor
Definition: vertex.h:85
gls_auto_lib.h
The gls_auto_lib.
gls_cpp_lang_support.h
Macros and helper code to determine what subset of C++11/14/17 is available.
DISTI_SPECIAL_MEM_FUN_DELETE
#define DISTI_SPECIAL_MEM_FUN_DELETE
Macro to wrap function deletion, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:246
DISTI_DEPRECATED
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
DISTI_METHOD_OVERRIDE
#define DISTI_METHOD_OVERRIDE
Macro to wrap the override keyword, removed on compilers that don't support it.
Definition: gls_cpp_lang_support.h:222
GLSGEN_GLSMUTEXGROUP_EXPORT
#define GLSGEN_GLSMUTEXGROUP_EXPORT
Provides support for creating DLLs.
Definition: gls_mutex_group.h:56
group.h
The disti::Group class. Implements groups of objects.
disti
Definition: bmpimage.h:47