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
14reproduced, in whole or part, in any form, or by any means of electronic,
15mechanical, or otherwise, without the written permission of DiSTI. Said
16permission may be derived through the purchase of applicable DiSTI product
17licenses which detail the distribution rights of this content and any
18Derivative Works based on this or other copyrighted DiSTI Software.
19
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34EXCEED FIVE DOLLARS (US$5.00).
35
36 The aforementioned terms and restrictions are governed by the laws of the
37State 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"
47typedef disti::RSOInterfaceES1 RsoImplBaseInterface; ///< Typedef for the original RSO interface.
48typedef disti::RSOInterfaceES2::RSOPainter RSOPainterT; ///< Typedef for the RSO interface painter type.
49#else
50# include "rso_interface_5.h"
51typedef disti::RSOInterface1 RsoImplBaseInterface; ///< Typedef for the original RSO interface.
52typedef disti::RSOInterface5::RSOPainter RSOPainterT; ///< Typedef for the RSO interface painter type.
53#endif
54
55namespace disti
56{
57class AttributeWrapperMap;
58class EmittedEventHandlerImpl;
59class MouseEvent;
60
61/** The GlsRSOWrapper class wraps an RsoImplBaseInterface object
62 so that it can be inserted into the GL Studio heirarchy.
63 */
65 , virtual public RSOPainterT
66{
67public:
68 DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
69 typedef ComponentBase _BaseClass; ///< Deprecated typedef for the base class.
70 typedef ComponentBase BaseClass; ///< Typedef for the base class.
71
72 /// Constructor
73 /// \param rso The RSO to wrap.
74 /// \param RSOVersion The highest RSOInterface the RSO supports (e.g. 1,2,3).
75 GLS_EXPORT GlsRSOWrapper( RsoImplBaseInterface* rso, unsigned int RSOVersion );
76
77 /// Call CreateInstance() and Destroy() instead of new and delete
78 /// in a mixed-library environment to ensure that matching
79 /// new and delete operators are called.
80 /// \param rso The RSO to wrap.
81 /// \param RSOVersion The highest RSOInterface the RSO supports (e.g. 1,2,3).
82 /// \return A pointer to a new GlsRSOWrapper object.
83 static GLS_EXPORT GlsRSOWrapper* CreateInstance( RsoImplBaseInterface* rso, unsigned int RSOVersion );
84
85 /** Destructor
86 * Don't call "delete yourComponent;", instead call "yourComponent->Destroy();"
87 * to ensure that the object is deleted correctly.
88 */
90
91 /** Utility Method: Users should call Destroy() instead.
92 * Safely delete an object that was created using CreateInstance.
93 */
94 virtual GLS_EXPORT void DeleteInstance();
95
96 /** Replace the RSO that the GlsRSOWrapper is wrapping.
97 * \param rso The new RSO to use
98 * \param deleteCurrent Whether to delete the currently referenced rso. If false, then the caller is responsible for deleting it.
99 */
100 GLS_EXPORT void ChangeRSO( RsoImplBaseInterface* rso, bool deleteCurrent = true );
101
102 /// \return The current RSOInterface object.
104
105 /// \return The rso version.
106 unsigned int GetRSOVersion() const
107 {
108 return _rsoVersion;
109 }
110
111 /// Handle an event that was emitted from the RSO.
112 /// \param ev The event to handle.
113 /// \return Non-zero if the event was handled, otherwise zero.
114 GLS_EXPORT int HandleEmittedEvent( RsoImplBaseInterface::Event* ev );
115
116 /// \return The qualified instance name of the initiator of the last
117 /// event that was passed to HandleEmittedEvent or "" if no events
118 /// have been passed to HandleEmittedEvent.
120
121 /// \copydoc DisplayObject::AlphaMode(int)
123 /// \copydoc DisplayObject::AlphaMode()
125 /// \copydoc DisplayObject::AntiAlias(bool)
126 virtual GLS_EXPORT void AntiAlias( bool alias ) DISTI_METHOD_OVERRIDE;
127 /// \copydoc DisplayObject::AntiAlias()
129 /// \copydoc DisplayObject::SetBlendColor(const GlsColor&)
131 /// \copydoc DisplayObject::GetBlendColor()
133 /// \copydoc DisplayObject::GetColor()
135 /// \copydoc DisplayObject::SetColor(const GlsColor&)
136 virtual GLS_EXPORT void SetColor( const GlsColor& color ) DISTI_METHOD_OVERRIDE;
137 /// \copydoc DisplayObject::CullBackFace(const bool)
138 virtual GLS_EXPORT void CullBackFace( const bool val ) DISTI_METHOD_OVERRIDE;
139 /// \copydoc DisplayObject::CullBackFace()
141 /// \copydoc DisplayObject::DepthTest()
143 /// \copydoc DisplayObject::DepthTest(unsigned char)
144 virtual GLS_EXPORT void DepthTest( unsigned char zbuf ) DISTI_METHOD_OVERRIDE;
145 /// \copydoc DisplayObject::LightingEnabled()
147 /// \copydoc DisplayObject::LightingEnabled(bool)
148 virtual GLS_EXPORT void LightingEnabled( bool lighting ) DISTI_METHOD_OVERRIDE;
149 /// \copydoc DisplayObject::LineStippleMultiplier()
151 /// \copydoc DisplayObject::LineStippleMultiplier(int)
153 /// \copydoc DisplayObject::LineStipplePattern()
155 /// \copydoc DisplayObject::LineStipplePattern(int)
157 /// \copydoc DisplayObject::LineWidth()
159 /// \copydoc DisplayObject::LineWidth(float)
160 virtual GLS_EXPORT void LineWidth( float width ) DISTI_METHOD_OVERRIDE;
161 /// \copydoc DisplayObject::MaterialIndex()
163 /// \copydoc DisplayObject::MaterialIndex(int)
165 /// \copydoc DisplayObject::PolygonMode()
167 /// \copydoc DisplayObject::PolygonMode(int)
169 /// \copydoc DisplayObject::PolygonEnd()
171 /// \copydoc DisplayObject::PolygonEnd(const int)
173 /// \copydoc DisplayObject::Shading()
175 /// \copydoc DisplayObject::Shading(const int)
176 virtual GLS_EXPORT void Shading( const int shading ) DISTI_METHOD_OVERRIDE;
177 /// \copydoc DisplayObject::TextureIndex()
179 /// \copydoc DisplayObject::TextureIndex(int)
180 virtual GLS_EXPORT void TextureIndex( int textureIndex ) DISTI_METHOD_OVERRIDE;
181 /// \copydoc DisplayObject::TextureRepeat()
183 /// \copydoc DisplayObject::TextureRepeat(const int)
184 virtual GLS_EXPORT void TextureRepeat( const int rep ) DISTI_METHOD_OVERRIDE;
185 /// \copydoc DisplayObject::TextureMappingTechnique()
187 /// \copydoc DisplayObject::TextureMappingTechnique(const int)
189 /// \copydoc DisplayObject::TextureMagnificationFilter()
191 /// \copydoc DisplayObject::TextureMagnificationFilter(const int)
193 /// \copydoc DisplayObject::TextureMinificationFilter()
195 /// \copydoc DisplayObject::TextureMinificationFilter(const int)
197
198 /// \copydoc ComponentBase::AbsolutePlacement(bool)
200
201 /// \copydoc DisplayObject::Calculate
202 virtual GLS_EXPORT void Calculate( double time ) DISTI_METHOD_OVERRIDE;
203 /// \copydoc Group::CalculateBoundingBox
205 /// \copydoc DisplayObject::CloneObject
206 virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false ) DISTI_METHOD_OVERRIDE;
207 /// \copydoc DisplayObject::CopyGeometry
209 /// \copydoc DisplayObject::CopyProperties
211
212#ifndef GLES
213 /// \copydoc DisplayObject::GetCppInterfaceDescription
214 virtual GLS_EXPORT InterfaceListType* GetCppInterfaceDescription( InterfaceListType* addToThisList = NULL ) DISTI_METHOD_OVERRIDE;
215 /// \copydoc DisplayObject::GetCppInterfaceDescriptionFree
216 virtual GLS_EXPORT void GetCppInterfaceDescriptionFree( InterfaceListType* array ) DISTI_METHOD_OVERRIDE;
217#endif
218 /// \copydoc ComponentBase::CreateObjects
220
221 /// \copydoc DisplayObject::Draw
223
224 /// \copydoc DisplayObject::GetExtents
225 virtual GLS_EXPORT void GetExtents( float& x, float& y, float& z, float& x1, float& y1, float& z1 ) DISTI_METHOD_OVERRIDE;
226
227 /// \copydoc DisplayObject::GetTransformedExtents
228 virtual GLS_EXPORT void GetTransformedExtents( Vector& min, Vector& max, const GlsMatrixType& matrix, bool resetMinMax = true ) DISTI_METHOD_OVERRIDE;
229
230 /// \copydoc DisplayObject::handle
232
233 /// \copydoc ComponentBase::HandleInput
235
236 /// \copydoc ComponentBase::Init
238
239 /// \copydoc ComponentBase::Initialize
241
242 /// \copydoc DisplayObject::Pick3D
243 virtual GLS_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
244 const Vector& logicalCoords,
245 float scale,
246 const Vector& directionVector,
247 Vector& collisionWinLoc /*Returned*/,
248 const OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
249
250 /// \copydoc DisplayObject::PreDraw
251 virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler ) DISTI_METHOD_OVERRIDE;
252
253 /// \copydoc DisplayObject::GetResources
254 virtual GLS_EXPORT void GetResources( std::ostream& outstr, GlsResourceFilter* filter = NULL ) DISTI_METHOD_OVERRIDE;
255
256 /// \copydoc DisplayObject::Resource
258
259 /* Unhides base class implementation. */
260 using ComponentBase::Rotate;
261 using ComponentBase::Scale;
262
263 /// \copydoc DisplayObject::UpdateBoundingVolume
265
266 /// \copydoc DisplayObject::SetValue
267 GLS_EXPORT void SetValue( int spec, va_list& args ) DISTI_METHOD_OVERRIDE;
268
269 /// Invalidates the painter set on this object if that painter exists.
270 virtual void GLS_EXPORT Invalidate();
271 /// \copydoc DisplayObject::SetPainter
273
274protected:
275 /** enum that guides the state machine for multitouch handling for RSO's that don't support multitouch.
276 * An RSO starts in the READY_FOR_INPUT state. When it handles a mouse drag event, it moves to PROCESSING_MOUSE_DRAG
277 * state. It will ignore any other mouse events if they are not for the original cursor_id. Then, once the RSO either receives the
278 * 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
279 * 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
280 */
282 {
283 READY_FOR_INPUT,
284 PROCESSING_MOUSE_DRAG,
285 WAITING_FOR_MOUSE_DOWN
286 };
287
288 RsoImplBaseInterface* _rsoInterface; ///< The RSO being wrapped by this interface.
289 AttributeWrapperMap* _attributeWrapperMap; ///< A map of attributes that wrap to the attributes within the RSO.
290 EmittedEventHandlerImpl* _rsoEmittedEventHandler; ///< The event handler for the RSO.
291 char* _lastEmittedEventInitiatorName; ///< The name of the last object who emitted an event that made it to the event handler.
292 MultitouchState _multitouchState; ///< The current multitouch input state, \see MultitouchState
293 unsigned int _currentCursor; ///< The cursor id of the current mouse / touch interacting with the RSO.
294 unsigned int _rsoVersion; ///< The interface version of the wrapped RSO.
295
296 /// Set the name of the object who most recently emitted an event that was handled by the event handler.
297 /// \note Not normally called by users.
298 /// \param name The new object name to set.
300
301 /// This function should be called to handle mouse events if the RSO handles multitouch (RSO version 3 or greater).
302 /// \note Not normally called by users.
303 /// \param mev The event to handle.
304 /// \return A pointer to the object that received the event, or NULL.
306};
307
308} // namespace disti
309
310#endif
Definition: component_base.h:68
bool AbsolutePlacement() const
Definition: component_base.h:124
Definition: cull.h:50
Definition: events.h:113
virtual float Scale()
Definition: display_frame.h:134
Definition: display.h:96
Definition: disti_metadata.h:220
Definition: dynamic_array.h:79
Definition: gls_color.h:54
Definition: gls_painter.h:51
Definition: gls_rso_wrapper.h:66
virtual int PolygonMode() override
virtual int TextureMagnificationFilter() override
const char * LastEmittedEventInitiatorName() const
virtual GlsColor GetBlendColor() override
virtual void Calculate(double time) override
virtual DisplayObject * CloneObject(bool generateNames=false) override
unsigned int _currentCursor
The cursor id of the current mouse / touch interacting with the RSO.
Definition: gls_rso_wrapper.h:293
virtual bool TextureRepeat() override
virtual void CreateObjects() override
virtual float LineWidth() override
virtual int TextureMappingTechnique() override
virtual void Rotate(const Vector &orig, float angle, const Vector &axis) override
virtual void GetResources(std::ostream &outstr, GlsResourceFilter *filter=NULL) override
virtual void DeleteInstance()
void LastEmittedEventInitiatorName(const char *name)
virtual GlsColor GetColor() override
virtual int LineStippleMultiplier() override
virtual int LineStipplePattern() override
virtual int TextureMinificationFilter() override
virtual void CalculateBoundingBox() override
void SetValue(int spec, va_list &args) override
AttributeWrapperMap * _attributeWrapperMap
A map of attributes that wrap to the attributes within the RSO.
Definition: gls_rso_wrapper.h:289
unsigned int _rsoVersion
The interface version of the wrapped RSO.
Definition: gls_rso_wrapper.h:294
virtual void Initialize() override
MultitouchState
Definition: gls_rso_wrapper.h:282
unsigned int GetRSOVersion() const
Definition: gls_rso_wrapper.h:106
RsoImplBaseInterface * _rsoInterface
The RSO being wrapped by this interface.
Definition: gls_rso_wrapper.h:288
virtual void SetColor(const GlsColor &color) override
virtual DistiAttributeBase & Resource(const char *name) override
virtual void GetExtents(float &x, float &y, float &z, float &x1, float &y1, float &z1) override
virtual DisplayObject * HandleInput(DisplayEvent *ev) override
virtual int TextureIndex() override
virtual void AlphaMode(int mode) override
virtual bool CullBackFace() override
EmittedEventHandlerImpl * _rsoEmittedEventHandler
The event handler for the RSO.
Definition: gls_rso_wrapper.h:290
virtual bool LightingEnabled() override
virtual void CopyProperties(DisplayObject *src) override
virtual int AlphaMode() override
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &drawnMatrices) override
virtual bool AntiAlias() override
RsoImplBaseInterface * RSOInterface()
MultitouchState _multitouchState
The current multitouch input state,.
Definition: gls_rso_wrapper.h:292
virtual void Draw() override
virtual void SetPainter(GlsPainter *painter) override
virtual int Shading() override
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler) override
char * _lastEmittedEventInitiatorName
The name of the last object who emitted an event that made it to the event handler.
Definition: gls_rso_wrapper.h:291
virtual DisplayObject * handle(DisplayEvent *ev) override
virtual void UpdateBoundingVolume() override
int HandleEmittedEvent(RsoImplBaseInterface::Event *ev)
virtual void Invalidate()
Invalidates the painter set on this object if that painter exists.
void ChangeRSO(RsoImplBaseInterface *rso, bool deleteCurrent=true)
virtual int PolygonEnd() override
virtual void Init() override
virtual void GetTransformedExtents(Vector &min, Vector &max, const GlsMatrixType &matrix, bool resetMinMax=true) override
virtual void CopyGeometry(DisplayObject *src) override
virtual int MaterialIndex() override
virtual DisplayObject * HandleMultiTouchInput(MouseEvent *mev)
virtual void SetBlendColor(const GlsColor &color) override
virtual int DepthTest() override
Definition: gls_resources.h:51
Definition: group.h:53
static DisplayObject * CreateInstance()
Definition: events.h:225
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:544
Definition: rso_interface_1.h:61
Definition: rso_interface_5.h:66
Definition: vertex.h:85
The disti::ComponentBase class.
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:488
#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
#define GLS_EXPORT
Macro denoting which functions should be visible from the runtime library.
Definition: gls_include.h:52
disti::RSOInterfaceES2::RSOPainter RSOPainterT
Typedef for the RSO interface painter type.
Definition: gls_rso_interface_impl.h:52
disti::RSOInterfaceES1 RsoImplBaseInterface
Typedef for the original RSO interface.
Definition: gls_rso_wrapper.h:47
disti::RSOInterfaceES2::RSOPainter RSOPainterT
Typedef for the RSO interface painter type.
Definition: gls_rso_wrapper.h:48
Definition: bmpimage.h:47
RSOInterfaceES1 RsoImplBaseInterface
Typedef for the original RSO interface.
Definition: live_component_lib_ref.h:53
DistiAttribDict::const_iterator end(const DistiAttribDict &dict)
Definition: disti_metadata.h:975
Defines the RSO interface v5, which extends v4 to add conditional rendering support.