GL Studio C++ Runtime API
gls_rso_wrapper.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GlsRSOWrapper 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 #ifndef _GLS_RSO_WRAPPER_H
41 #define _GLS_RSO_WRAPPER_H
42 
43 #include "component_base.h"
44 
45 #ifdef GLES
46 # include "rso_interface_es_1.h"
47 typedef disti::RSOInterfaceES1 RsoImplBaseInterface;
48 #else
49 # include "rso_interface_1.h"
51 #endif
52 
53 namespace disti
54 {
55 //class RsoImplBaseInterface;
56 //class RsoImplBaseInterface::DisplayEvent;
57 class AttributeWrapperMap;
58 class EmittedEventHandlerImpl;
59 class MouseEvent;
60 
61 /** The GlsRSOWrapper class wraps an RsoImplBaseInterface object
62  so that it can be inserted into the GL Studio heirarchy.
63  */
65 {
66 public:
67  typedef ComponentBase _BaseClass;
68 
69  /** Constructor
70  * \param rso The RSO to wrap
71  * \param RSOVersion the highest RSOInterface the RSO supports (e.g. 1,2,3)
72  */
73  GLS_EXPORT GlsRSOWrapper( RsoImplBaseInterface* rso, unsigned int RSOVersion );
74 
75  /** Call CreateInstance() and Destroy() instead of new and delete
76  * in a mixed-library environment to ensure that matching
77  * new and delete operators are called.
78  * \param rso The RSO to wrap
79  * \param RSOVersion the highest RSOInterface the RSO supports (e.g. 1,2,3)
80  */
81  static GLS_EXPORT GlsRSOWrapper* CreateInstance( RsoImplBaseInterface* rso, unsigned int RSOVersion );
82 
83  /** Destructor
84  * Don't call "delete yourComponent;", instead call "yourComponent->Destroy();"
85  * to ensure that the object is deleted correctly.
86  */
87  virtual GLS_EXPORT ~GlsRSOWrapper();
88 
89  /** Utility Method: Users should call Destroy() instead.
90  * Safely delete an object that was created using CreateInstance.
91  */
92  virtual GLS_EXPORT void DeleteInstance();
93 
94  /** Replace the RSO that the GlsRSOWrapper is wrapping.
95  * \param rso The new RSO to use
96  * \param deleteCurrent Whether to delete the currently referenced rso. If false, then the caller is responsible for deleting it.
97  */
98  GLS_EXPORT void ChangeRSO( RsoImplBaseInterface* rso, bool deleteCurrent = true );
99 
100  /** Returns the current RSOInterface object
101  */
102  GLS_EXPORT RsoImplBaseInterface* RSOInterface();
103 
104  /** Returns the rso version
105  */
106  unsigned int GetRSOVersion() const
107  {
108  return _rsoVersion;
109  }
110 
111  /** Handle an event that was emitted from the RSO.
112  */
113  GLS_EXPORT int HandleEmittedEvent( RsoImplBaseInterface::Event* ev );
114 
115  /** Returns the qualified instance name of the initiator of the last
116  * event that was passed to HandleEmittedEvent or "" if no events
117  * have been passed to HandleEmittedEvent. */
118  GLS_EXPORT const char* LastEmittedEventInitiatorName() const;
119 
120  // DisplayObject overrides
121 
122  virtual GLS_EXPORT void AlphaMode( int mode );
123  virtual GLS_EXPORT int AlphaMode( void );
124  virtual GLS_EXPORT void AntiAlias( bool alias );
125  virtual GLS_EXPORT bool AntiAlias( void );
126  virtual GLS_EXPORT void SetBlendColor( const GlsColor& color );
127  virtual GLS_EXPORT GlsColor GetBlendColor();
128  virtual GLS_EXPORT GlsColor GetColor();
129  virtual GLS_EXPORT void SetColor( const GlsColor& color );
130  virtual GLS_EXPORT void CullBackFace( const bool val );
131  virtual GLS_EXPORT bool CullBackFace( void );
132  virtual GLS_EXPORT int DepthTest( void );
133  virtual GLS_EXPORT void DepthTest( int zbuf );
134  virtual GLS_EXPORT bool LightingEnabled();
135  virtual GLS_EXPORT void LightingEnabled( bool lighting );
136  virtual GLS_EXPORT int LineStippleMultiplier( void );
137  virtual GLS_EXPORT void LineStippleMultiplier( int mult );
138  virtual GLS_EXPORT int LineStipplePattern( void );
139  virtual GLS_EXPORT void LineStipplePattern( int pattern );
140  virtual GLS_EXPORT float LineWidth( void );
141  virtual GLS_EXPORT void LineWidth( float width );
142  virtual GLS_EXPORT int MaterialIndex();
143  virtual GLS_EXPORT void MaterialIndex( unsigned int index );
144  virtual GLS_EXPORT int PolygonMode( void );
145  virtual GLS_EXPORT void PolygonMode( int mode );
146  virtual GLS_EXPORT int PolygonEnd( void );
147  virtual GLS_EXPORT void PolygonEnd( const int end );
148  virtual GLS_EXPORT int PolygonOffset( void ) const;
149  virtual GLS_EXPORT void PolygonOffset( const int offset );
150  virtual GLS_EXPORT int Shading( void );
151  virtual GLS_EXPORT void Shading( const int shading );
152  virtual GLS_EXPORT int TextureIndex( void );
153  virtual GLS_EXPORT void TextureIndex( int textureIndex );
154  virtual GLS_EXPORT bool TextureRepeat( void );
155  virtual GLS_EXPORT void TextureRepeat( const int rep );
156  virtual GLS_EXPORT int TextureMappingTechnique( void );
157  virtual GLS_EXPORT void TextureMappingTechnique( const int map );
158  virtual GLS_EXPORT int TextureMagnificationFilter( void );
159  virtual GLS_EXPORT void TextureMagnificationFilter( const int filter );
160  virtual GLS_EXPORT int TextureMinificationFilter( void );
161  virtual GLS_EXPORT void TextureMinificationFilter( const int filter );
162 
163  virtual GLS_EXPORT void AbsolutePlacement( bool filter );
164 
165  virtual GLS_EXPORT void Calculate( double time );
166 
167  virtual GLS_EXPORT void CalculateBoundingBox( void );
168 
169  virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false );
170 
171  virtual GLS_EXPORT void CopyGeometry( DisplayObject* src );
172 
173  virtual GLS_EXPORT void CopyProperties( DisplayObject* src );
174 
175 #ifndef GLES
176  virtual GLS_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL );
177 
178  virtual GLS_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array );
179 #endif
180  virtual GLS_EXPORT void CreateObjects();
181 
182  virtual GLS_EXPORT void Draw();
183 
184  virtual GLS_EXPORT void GetExtents( float& x, float& y, float& z, float& x1, float& y1, float& z1 );
185 
186  virtual GLS_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax = true );
187 
188  virtual GLS_EXPORT DisplayObject* handle( DisplayEvent* ev );
189 
190  virtual GLS_EXPORT DisplayObject* HandleInput( DisplayEvent* ev );
191 
192  virtual GLS_EXPORT void Init();
193 
194  virtual GLS_EXPORT void Initialize();
195 
196  virtual GLS_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
197  const Vector& logicalCoords,
198  float scale,
199  const Vector& directionVector,
200  Vector& collisionWinLoc /*Returned*/,
201  const OpenGLMatrices& drawnMatrices );
202 
203  virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
204 
205  virtual GLS_EXPORT void GetResources( std::ostream& outstr, GlsResourceFilter* filter = NULL );
206 
207  virtual GLS_EXPORT DistiAttributeBase& Resource( const char* name );
208 
209  /* Unhides base class implementation. */
210  using ComponentBase::Rotate;
211  using ComponentBase::Scale;
212 
213  virtual void GLS_EXPORT UpdateBoundingVolume( void );
214 
215  /** Called on initial creation to set variables */
216  GLS_EXPORT void SetValue( int spec, va_list& args );
217 
218 protected:
219  /** enum that guides the state machine for multitouch handling for RSO's that don't support multitouch.
220  * An RSO starts in the READY_FOR_INPUT state. When it handles a mouse drag event, it moves to PROCESSING_MOUSE_DRAG
221  * state. It will ignore any other mouse events if they are not for the original cursor_id. Then, once the RSO either receives the
222  * MOUSE_UP event or stops handling the MOUSE_DRAG events, the RSO then transitions to WAITING_FOR_MOUSE_DOWN (i.e. it keeps ignoring other cursors
223  * that might have been dragging on it while it was processing its original cursor event). Once it receives a new mouse down, it transitions back to READY_FOR_INPUT
224  */
226  {
227  READY_FOR_INPUT,
228  PROCESSING_MOUSE_DRAG,
229  WAITING_FOR_MOUSE_DOWN
230  };
231 
232  RsoImplBaseInterface* _rsoInterface;
233  AttributeWrapperMap* _attributeWrapperMap;
234  EmittedEventHandlerImpl* _rsoEmittedEventHandler;
235  char* _lastEmittedEventInitiatorName;
236  MultitouchState _multitouchState;
237  unsigned int _currentCursor;
238  unsigned int _rsoVersion;
239 
240  GLS_EXPORT void LastEmittedEventInitiatorName( const char* name );
241 
242  /** this function should be called to handle mouse events if the RSO handles multitouch (RSO version 3 or greater)
243  */
244  virtual GLS_EXPORT DisplayObject* HandleMultiTouchInput( MouseEvent* mev );
245 };
246 
247 } // namespace disti
248 
249 #endif
Definition: cull.h:49
virtual int AlphaMode(void)
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
virtual void Init()
virtual void CreateObjects()
virtual int MaterialIndex()
The disti::ComponentBase class.
virtual int TextureMagnificationFilter(void)
virtual void UpdateBoundingVolume(void)
virtual void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax=true)
int HandleEmittedEvent(RsoImplBaseInterface::Event *ev)
Definition: dynamic_array.h:62
virtual void Rotate(const Vector &orig, float angle, const Vector &axis)
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:278
virtual int DepthTest(void)
virtual int TextureMinificationFilter(void)
Definition: display.h:97
virtual float LineWidth(void)
virtual InterfaceListType * GetCppInterfaceDescription(InterfaceListType *addToThisList=NULL)
virtual int TextureMappingTechnique(void)
virtual int TextureIndex(void)
void ChangeRSO(RsoImplBaseInterface *rso, bool deleteCurrent=true)
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices)
virtual GlsColor GetBlendColor()
virtual ~GlsRSOWrapper()
MultitouchState
Definition: gls_rso_wrapper.h:225
virtual void SetBlendColor(const GlsColor &color)
virtual int Shading(void)
Definition: component_base.h:67
Definition: rso_interface_1.h:302
Defines the RSO interface, which provides a generic way of accessing RSOs and other content...
GlsRSOWrapper(RsoImplBaseInterface *rso, unsigned int RSOVersion)
virtual void CopyProperties(DisplayObject *src)
virtual DisplayObject * HandleMultiTouchInput(MouseEvent *mev)
virtual void Calculate(double time)
virtual DisplayObject * handle(DisplayEvent *ev)
virtual void Draw()
void SetValue(int spec, va_list &args)
virtual int LineStippleMultiplier(void)
virtual void SetColor(const GlsColor &color)
Definition: rso_interface_1.h:60
RsoImplBaseInterface * RSOInterface()
Definition: disti_metadata.h:174
Definition: events.h:110
Definition: gls_color.h:53
virtual DisplayObject * CloneObject(bool generateNames=false)
virtual DistiAttributeBase & Resource(const char *name)
virtual void GetResources(std::ostream &outstr, GlsResourceFilter *filter=NULL)
virtual int PolygonEnd(void)
virtual int PolygonMode(void)
virtual void GetExtents(float &x, float &y, float &z, float &x1, float &y1, float &z1)
virtual void CopyGeometry(DisplayObject *src)
Definition: group.h:52
virtual void GetCppInterfaceDescriptionFree(InterfaceListType *array)
virtual float Scale(void)
Definition: display_frame.h:132
virtual DisplayObject * HandleInput(DisplayEvent *ev)
virtual void DeleteInstance()
const char * LastEmittedEventInitiatorName() const
Definition: vertex.h:83
virtual int LineStipplePattern(void)
virtual bool AntiAlias(void)
unsigned int GetRSOVersion() const
Definition: gls_rso_wrapper.h:106
Definition: gls_rso_wrapper.h:64
Definition: gls_resources.h:50
bool AbsolutePlacement() const
Definition: component_base.h:112
static GlsRSOWrapper * CreateInstance(RsoImplBaseInterface *rso, unsigned int RSOVersion)
virtual GlsColor GetColor()
virtual bool LightingEnabled()
Definition: bmpimage.h:46
Definition: events.h:218
virtual void Initialize()
virtual bool CullBackFace(void)
virtual bool TextureRepeat(void)