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