GL Studio C++ Runtime API
gls_rso_interface_impl.h
Go to the documentation of this file.
1 /*! \file
2  \brief Standard GL Studio implementation of the safe interface to version 2 RSOs (component side).
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 INCLUDED_GLS_RSO_INTERFACE_IMPL_H
41 #define INCLUDED_GLS_RSO_INTERFACE_IMPL_H
42 
43 #include "events.h"
44 #include "gls_include.h"
45 #include "gls_resources.h"
46 #ifdef GLES
47 # include "rso_interface_es_2.h"
48 typedef disti::RSOInterfaceES2 RsoImplBaseClass;
49 typedef disti::RSOInterfaceES1 RsoImplBaseInterface;
50 typedef disti::RSOInterfaceES1 RsoImplMultiTouchInterface;
51 typedef disti::RSOInterfaceES1::MatrixF RSOMatrixT;
52 typedef disti::RSOInterfaceES2::RSOPainter RSOPainterT;
53 #else
54 # include "rso_interface_5.h"
60 #endif
61 
62 namespace disti
63 {
64 class ComponentBase;
65 
66 /** Wraps a GlsResourceFilter so it can be passed to the RSO Interface's GetResources call */
68 {
69 private:
70  GlsResourceFilter* _filter;
71 
72 public:
73  GLS_EDITOR RSOResourceFilterImpl( GlsResourceFilter* filter ) { _filter = filter; }
74  GLS_EDITOR ~RSOResourceFilterImpl() {}
75 
76  // How many levels of qualification to show in the name.
77  // -1 means full qualification.
78  // Default: 0 // TODO: confirm this default
79  int LevelsUp() const DISTI_METHOD_OVERRIDE { return _filter->LevelsUp(); }
80  void LevelsUp( int value ) DISTI_METHOD_OVERRIDE { _filter->LevelsUp( value ); }
81 
82  // How many levels of children to show.
83  // 0 means don't show any children properties
84  // -1 means all the way down.
85  // Default: -1
86  int GroupLevelsDown() const DISTI_METHOD_OVERRIDE { return _filter->GroupLevelsDown(); }
87  void GroupLevelsDown( int value ) DISTI_METHOD_OVERRIDE { _filter->GroupLevelsDown( value ); }
88 
89  // If true, only a list of names will be returned.
90  // Values will not be returned.
91  // The format changes to not include the ":".
92  // Default: false
93  bool NamesOnly() const DISTI_METHOD_OVERRIDE { return _filter->NamesOnly(); }
94  void NamesOnly( bool value ) DISTI_METHOD_OVERRIDE { _filter->NamesOnly( value ); }
95 
96  // Manage the list of excluded attributes
97  void AddExclude( const char* str ) DISTI_METHOD_OVERRIDE { _filter->AddExclude( str ); }
98  // Returns the number of entries in the exclude list.
99  // Default: 0
100  int ExcludeCount() const DISTI_METHOD_OVERRIDE { return _filter->ExcludeCount(); }
101  // Returns NULL if index >= ExcludeCount() or index < -1
102  const char* GetExclude( int index ) const DISTI_METHOD_OVERRIDE { return _filter->GetExclude( index ); }
103 
104  // Manage the list of included attributes
105  void AddInclude( const char* str ) DISTI_METHOD_OVERRIDE { _filter->AddInclude( str ); }
106  // Returns the number of entries in the include list.
107  // Default: 0
108  int IncludeCount() const DISTI_METHOD_OVERRIDE { return _filter->IncludeCount(); }
109  // Returns NULL if index >= IncludeCount() or index < -1
110  const char* GetInclude( int index ) const DISTI_METHOD_OVERRIDE { return _filter->GetInclude( index ); }
111 
112  // Check a name against the filters
113  // Exclude list takes precedence
114  bool PassFilter( const char* name ) const DISTI_METHOD_OVERRIDE { return _filter->PassFilter( name ); }
115 
116  // Manage the stack of parent object names
117  void PushParentName( const char* parent ) { _filter->PushParentName( parent ); }
118  void PopParentName() { _filter->PopParentName(); }
119  // Returns the number of entries in the parent name stack
120  unsigned int ParentNameCount() const { return _filter->ParentNameCount(); }
121  // Returns NULL if index >= ParentNameCount() or index < -1
122  const char* GetParentName( unsigned int index ) const { return _filter->GetParentName( index ); }
123 };
124 
125 /** Implementation of RSOInterface. */
127  , virtual public GlsPainter
128 {
129 protected:
130  // Reference to the component being wrapped
131  // GlsRSOInterface1Impl will delete this object
132  ComponentBase* _component;
133 
134  // The containers event handler
135  RsoImplBaseInterface::EmittedEventHandler* _emittedEventHandler;
136 
137  // string to return from Resources methods
138  std::string _resourcesRetVal;
139 
140  // RSOInterface2 implementation
141 
142  typedef std::map<ResourceHandle, DistiAttributeBase*> ResourceHandleMap;
143 
144  ResourceHandleMap _resourceHandleMap;
145  ResourceHandle _nextResourceHandle;
146  bool _firstDraw;
147 
148  RSOPainterT* _painter;
149  bool _redraw;
150 
151  DistiAttributeBase& GetAttribute( ResourceHandle handle );
152 
153  // Protected constructor - Call CreateInstance instead
154  GLS_EXPORT GlsRSOInterfaceImpl( ComponentBase* component );
155 
156  // Protected destructor - Call DeleteInstance instead
157  virtual GLS_EXPORT ~GlsRSOInterfaceImpl();
158 
159 public:
160  static GLS_EXPORT GlsRSOInterfaceImpl* CreateInstance( ComponentBase* component );
161 
162  // Pass an event that was emitted from the component to the container
163  GLS_EXPORT int LiveComponentEventHandlerCb( ComponentBase*, disti::DisplayEvent* ev );
164 
165  // RSOInterface1 overrides
166 
167  GLS_EXPORT void Calculate( double time ) DISTI_METHOD_OVERRIDE;
168 
169  GLS_EXPORT RsoImplBaseInterface* CloneObject() DISTI_METHOD_OVERRIDE;
170 
171  GLS_EXPORT void DeleteInstance() DISTI_METHOD_OVERRIDE;
172 
173  GLS_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
174 
175  GLS_EXPORT bool SetEmittedEventHandler( RsoImplBaseInterface::EmittedEventHandler* handler ) DISTI_METHOD_OVERRIDE;
176 
177  GLS_EXPORT bool GetBoundingSphere( RsoImplBaseInterface::Vector* center, float* radius ) DISTI_METHOD_OVERRIDE;
178 
179  GLS_EXPORT bool GetBoundingBox( RsoImplBaseInterface::Vector* min, RsoImplBaseInterface::Vector* max, const RSOMatrixT* transform = NULL ) DISTI_METHOD_OVERRIDE;
180 
181  GLS_EXPORT bool HandleInput( RsoImplBaseInterface::Event* lci1_ev ) DISTI_METHOD_OVERRIDE;
182 
183  GLS_EXPORT bool HandleMultiTouchInput( RsoImplMultiTouchInterface::MouseMultiTouchEvent* lci3_ev ) DISTI_METHOD_OVERRIDE;
184 
185  GLS_EXPORT bool Pick3D( const RsoImplBaseInterface::Vector& winLoc,
186  const RsoImplBaseInterface::Vector& logicalCoords,
187  float scale,
188  const RsoImplBaseInterface::Vector& directionVector,
189  RsoImplBaseInterface::Vector& collisionWinLoc,
190  const RsoImplBaseInterface::OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
191 
192  GLS_EXPORT void PreDraw( const RsoImplBaseInterface::OpenGLMatrices& parentMatrices, RsoImplBaseInterface::Culler& culler ) DISTI_METHOD_OVERRIDE;
193 
194  GLS_EXPORT void SetResource( const char* resourceName, const char* resourceVal ) DISTI_METHOD_OVERRIDE;
195 
196  GLS_EXPORT const char* GetResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
197 
198  GLS_EXPORT const char* GetResources( RsoImplBaseInterface::ResourceFilter* filter = NULL ) DISTI_METHOD_OVERRIDE;
199 
200  // RSOInterface2 implementation
201 
202  ResourceHandle CreateResourceHandle( const char* resourceName ) DISTI_METHOD_OVERRIDE;
203 
204  void ReleaseResourceHandle( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
205 
206  bool IsResourceHandleValid( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
207 
208  void SetResource( ResourceHandle resourceHandle, const char* resourceVal ) DISTI_METHOD_OVERRIDE;
209 
210  const char* GetResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
211 
212  void SetIntResource( const char* resourceName, long resourceVal ) DISTI_METHOD_OVERRIDE;
213 
214  long GetIntResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
215 
216  void SetIntResource( ResourceHandle resourceHandle, long resourceVal ) DISTI_METHOD_OVERRIDE;
217 
218  long GetIntResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
219 
220  void SetFloatResource( const char* resourceName, double resourceVal ) DISTI_METHOD_OVERRIDE;
221 
222  double GetFloatResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
223 
224  void SetFloatResource( ResourceHandle resourceHandle, double resourceVal ) DISTI_METHOD_OVERRIDE;
225 
226  double GetFloatResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
227 
228  CallbackID RegisterResourceObserver( ResourceHandle resourceHandle, ResourceObserver* obs ) DISTI_METHOD_OVERRIDE;
229  void UnregisterResourceObserver( ResourceHandle resourceHandle, CallbackID id ) DISTI_METHOD_OVERRIDE;
230 
231 #ifdef GLES
232  unsigned int GetMaxNumLights() DISTI_METHOD_OVERRIDE;
233  void SetLightData( unsigned int numLights, LightData* lightData ) DISTI_METHOD_OVERRIDE;
234 
235  unsigned int GetMaxClipPlanes() DISTI_METHOD_OVERRIDE;
236  void SetClipPlaneData( unsigned int numClipPlanes, float** equations ) DISTI_METHOD_OVERRIDE;
237 
238  void SetMatrix( int type, const float* matrix ) DISTI_METHOD_OVERRIDE;
239  void SetDefaultOpenGLState() DISTI_METHOD_OVERRIDE;
240 #endif
241 
242  /** Calls Invalidate on the parent's painter, causing the scene to redraw in conditional rendering. */
243  void GLS_EXPORT Invalidate() DISTI_METHOD_OVERRIDE;
244 
245  /** Returns whether or not the parent's painter has already been invalidated */
246  bool GLS_EXPORT IsInvalidated() const DISTI_METHOD_OVERRIDE;
247 
248  /** Assigns a parent painter to this RSO which will be updated when any RSO child object causes invalidation. */
249  void GLS_EXPORT SetPainter( RSOPainterT* painter ) DISTI_METHOD_OVERRIDE;
250 };
251 
252 } // end namespace disti
253 
254 #endif
int LevelsUp() const override
Definition: gls_rso_interface_impl.h:79
Definition: rso_interface_1.h:578
void SetPainter(RSOPainterT *painter) override
const char * GetParentName(unsigned int index) const
bool GetBoundingSphere(RsoImplBaseInterface::Vector *center, float *radius) override
void ReleaseResourceHandle(ResourceHandle resourceHandle) override
Disposes of a resource handle.
void SetFloatResource(const char *resourceName, double resourceVal) override
Set the value as a float for a given named resource.
bool NamesOnly() const override
Definition: gls_rso_interface_impl.h:93
Definition: rso_interface_5.h:64
void Invalidate() override
bool Pick3D(const RsoImplBaseInterface::Vector &winLoc, const RsoImplBaseInterface::Vector &logicalCoords, float scale, const RsoImplBaseInterface::Vector &directionVector, RsoImplBaseInterface::Vector &collisionWinLoc, const RsoImplBaseInterface::OpenGLMatrices &drawnMatrices) override
Pick3D returns true if the RSO was picked.
int GroupLevelsDown() const override
Definition: gls_rso_interface_impl.h:86
void SetIntResource(const char *resourceName, long resourceVal) override
Set the value as an integer for a given named resource.
Definition: rso_interface_1.h:290
const char * GetInclude(unsigned int index) const
ResourceHandle CreateResourceHandle(const char *resourceName) override
Definition: rso_interface_5.h:61
bool HandleMultiTouchInput(RsoImplMultiTouchInterface::MouseMultiTouchEvent *lci3_ev) override
bool GetBoundingBox(RsoImplBaseInterface::Vector *min, RsoImplBaseInterface::Vector *max, const RSOMatrixT *transform=NULL) override
Definition: gls_rso_interface_impl.h:67
unsigned int ExcludeCount() const
Returns the number of exclude entries in the filter.
bool IsResourceHandleValid(ResourceHandle resourceHandle) override
Checks if a given resource handle is valid.
double GetFloatResource(const char *resourceName) override
Get the value as a float for a given named resource.
bool SetEmittedEventHandler(RsoImplBaseInterface::EmittedEventHandler *handler) override
const char * GetResources(RsoImplBaseInterface::ResourceFilter *filter=NULL) override
bool NamesOnly()
Definition: gls_resources.h:103
A file for all GL Studio files to include.
unsigned int ParentNameCount() const
Definition: rso_interface_4.h:63
void AddInclude(const char *str) override
Manage the list of included attributes.
Definition: gls_rso_interface_impl.h:105
Definition: component_base.h:67
Definition: gls_painter.h:51
Definition: rso_interface_1.h:302
The standard Mouse and keyboard events and event structures.
const char * GetExclude(int index) const override
Returns NULL if index >= ExcludeCount() or index < -1.
Definition: gls_rso_interface_impl.h:102
void AddInclude(const char *name)
Definition: gls_rso_interface_impl.h:126
const char * GetResource(const char *resourceName) override
Get the string value for the given resource.
virtual bool PassFilter(const char *name)
Test a resource name against the filter.
Definition: rso_interface_1.h:592
unsigned int IncludeCount() const
Returns the number of includes in the filter.
bool PassFilter(const char *name) const override
Definition: gls_rso_interface_impl.h:114
void SetResource(const char *resourceName, const char *resourceVal) override
Set the string value for a given named resource.
bool IsInvalidated() const override
Definition: rso_interface_1.h:60
void AddExclude(const char *name)
Definition: rso_interface_1.h:209
Definition: disti_metadata.h:183
Definition: rso_interface_3.h:60
Definition: rso_interface_3.h:64
Definition: events.h:112
void UnregisterResourceObserver(ResourceHandle resourceHandle, CallbackID id) override
Definition: rso_interface_1.h:185
int LevelsUp()
Definition: gls_resources.h:79
void DeleteInstance() override
Safely delete the object.
Definition: rso_interface_1.h:242
int GroupLevelsDown()
Definition: gls_resources.h:96
bool HandleInput(RsoImplBaseInterface::Event *lci1_ev) override
CallbackID RegisterResourceObserver(ResourceHandle resourceHandle, ResourceObserver *obs) override
void AddExclude(const char *str) override
Manage the list of excluded attributes.
Definition: gls_rso_interface_impl.h:97
void Calculate(double time) override
The RSO Interface methods.
int IncludeCount() const override
Definition: gls_rso_interface_impl.h:108
RsoImplBaseInterface * CloneObject() override
void PreDraw(const RsoImplBaseInterface::OpenGLMatrices &parentMatrices, RsoImplBaseInterface::Culler &culler) override
Definition: gls_resources.h:50
disti::GlsResourceFilter classes and methods.
const char * GetExclude(unsigned int index) const
int ExcludeCount() const override
Definition: gls_rso_interface_impl.h:100
unsigned int CallbackID
Type for unique identifiers.
Definition: rso_interface_4.h:79
Definition: bmpimage.h:46
Defines the RSO interface v5, which extends v4 to add conditional rendering support.
long GetIntResource(const char *resourceName) override
Get the value as an integer for a given named resource.
void PushParentName(const char *parent)