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