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 
150  DistiAttributeBase& GetAttribute( ResourceHandle handle );
151 
152  // Protected constructor - Call CreateInstance instead
153  GLS_EXPORT GlsRSOInterfaceImpl( ComponentBase* component );
154 
155  // Protected destructor - Call DeleteInstance instead
156  virtual GLS_EXPORT ~GlsRSOInterfaceImpl();
157 
158 public:
159  static GLS_EXPORT GlsRSOInterfaceImpl* CreateInstance( ComponentBase* component );
160 
161  // Pass an event that was emitted from the component to the container
162  GLS_EXPORT int LiveComponentEventHandlerCb( ComponentBase*, disti::DisplayEvent* ev );
163 
164  // RSOInterface1 overrides
165 
166  GLS_EXPORT void Calculate( double time ) DISTI_METHOD_OVERRIDE;
167 
168  GLS_EXPORT RsoImplBaseInterface* CloneObject() DISTI_METHOD_OVERRIDE;
169 
170  GLS_EXPORT void DeleteInstance() DISTI_METHOD_OVERRIDE;
171 
172  GLS_EXPORT void Draw() DISTI_METHOD_OVERRIDE;
173 
174  GLS_EXPORT bool SetEmittedEventHandler( RsoImplBaseInterface::EmittedEventHandler* handler ) DISTI_METHOD_OVERRIDE;
175 
176  GLS_EXPORT bool GetBoundingSphere( RsoImplBaseInterface::Vector* center, float* radius ) DISTI_METHOD_OVERRIDE;
177 
178  GLS_EXPORT bool GetBoundingBox( RsoImplBaseInterface::Vector* min, RsoImplBaseInterface::Vector* max, const RSOMatrixT* transform = NULL ) DISTI_METHOD_OVERRIDE;
179 
180  GLS_EXPORT bool HandleInput( RsoImplBaseInterface::Event* lci1_ev ) DISTI_METHOD_OVERRIDE;
181 
182  GLS_EXPORT bool HandleMultiTouchInput( RsoImplMultiTouchInterface::MouseMultiTouchEvent* lci3_ev ) DISTI_METHOD_OVERRIDE;
183 
184  GLS_EXPORT bool Pick3D( const RsoImplBaseInterface::Vector& winLoc,
185  const RsoImplBaseInterface::Vector& logicalCoords,
186  float scale,
187  const RsoImplBaseInterface::Vector& directionVector,
188  RsoImplBaseInterface::Vector& collisionWinLoc,
189  const RsoImplBaseInterface::OpenGLMatrices& drawnMatrices ) DISTI_METHOD_OVERRIDE;
190 
191  GLS_EXPORT void PreDraw( const RsoImplBaseInterface::OpenGLMatrices& parentMatrices, RsoImplBaseInterface::Culler& culler ) DISTI_METHOD_OVERRIDE;
192 
193  GLS_EXPORT void SetResource( const char* resourceName, const char* resourceVal ) DISTI_METHOD_OVERRIDE;
194 
195  GLS_EXPORT const char* GetResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
196 
197  GLS_EXPORT const char* GetResources( RsoImplBaseInterface::ResourceFilter* filter = NULL ) DISTI_METHOD_OVERRIDE;
198 
199  // RSOInterface2 implementation
200 
201  ResourceHandle CreateResourceHandle( const char* resourceName ) DISTI_METHOD_OVERRIDE;
202 
203  void ReleaseResourceHandle( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
204 
205  bool IsResourceHandleValid( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
206 
207  void SetResource( ResourceHandle resourceHandle, const char* resourceVal ) DISTI_METHOD_OVERRIDE;
208 
209  const char* GetResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
210 
211  void SetIntResource( const char* resourceName, long resourceVal ) DISTI_METHOD_OVERRIDE;
212 
213  long GetIntResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
214 
215  void SetIntResource( ResourceHandle resourceHandle, long resourceVal ) DISTI_METHOD_OVERRIDE;
216 
217  long GetIntResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
218 
219  void SetFloatResource( const char* resourceName, double resourceVal ) DISTI_METHOD_OVERRIDE;
220 
221  double GetFloatResource( const char* resourceName ) DISTI_METHOD_OVERRIDE;
222 
223  void SetFloatResource( ResourceHandle resourceHandle, double resourceVal ) DISTI_METHOD_OVERRIDE;
224 
225  double GetFloatResource( ResourceHandle resourceHandle ) DISTI_METHOD_OVERRIDE;
226 
227  CallbackID RegisterResourceObserver( ResourceHandle resourceHandle, ResourceObserver* obs ) DISTI_METHOD_OVERRIDE;
228  void UnregisterResourceObserver( ResourceHandle resourceHandle, CallbackID id ) DISTI_METHOD_OVERRIDE;
229 
230 #ifdef GLES
231  unsigned int GetMaxNumLights() DISTI_METHOD_OVERRIDE;
232  void SetLightData( unsigned int numLights, LightData* lightData ) DISTI_METHOD_OVERRIDE;
233 
234  unsigned int GetMaxClipPlanes() DISTI_METHOD_OVERRIDE;
235  void SetClipPlaneData( unsigned int numClipPlanes, float** equations ) DISTI_METHOD_OVERRIDE;
236 
237  void SetMatrix( int type, const float* matrix ) DISTI_METHOD_OVERRIDE;
238  void SetDefaultOpenGLState() DISTI_METHOD_OVERRIDE;
239 #endif
240 
241  /** Calls Invalidate on the parent's painter, causing the scene to redraw in conditional rendering. */
242  virtual void GLS_EXPORT Invalidate();
243 
244  /** Assigns a parent painter to this RSO which will be updated when any RSO child object causes invalidation. */
245  virtual void GLS_EXPORT SetPainter( RSOPainterT* painter );
246 };
247 
248 } // end namespace disti
249 
250 #endif
bool GetBoundingSphere(RsoImplBaseInterface::Vector *center, float *radius)
Definition: rso_interface_1.h:578
void SetResource(const char *resourceName, const char *resourceVal)
Set the string value for a given named resource.
const char * GetParentName(unsigned int index) const
void SetIntResource(const char *resourceName, long resourceVal)
Set the value as an integer for a given named resource.
Definition: rso_interface_5.h:64
Definition: rso_interface_1.h:290
void PreDraw(const RsoImplBaseInterface::OpenGLMatrices &parentMatrices, RsoImplBaseInterface::Culler &culler)
const char * GetInclude(unsigned int index) const
Definition: rso_interface_5.h:61
double GetFloatResource(const char *resourceName)
Get the value as a float for a given named resource.
Definition: gls_rso_interface_impl.h:67
bool IsResourceHandleValid(ResourceHandle resourceHandle)
Checks if a given resource handle is valid.
unsigned int ExcludeCount() const
Returns the number of exclude entries in the filter.
RsoImplBaseInterface * CloneObject()
long GetIntResource(const char *resourceName)
Get the value as an integer for a given named resource.
int IncludeCount() const
Definition: gls_rso_interface_impl.h:108
bool NamesOnly()
Definition: gls_resources.h:103
const char * GetExclude(int index) const
Returns NULL if index >= ExcludeCount() or index < -1.
Definition: gls_rso_interface_impl.h:102
A file for all GL Studio files to include.
unsigned int ParentNameCount() const
int GroupLevelsDown() const
Definition: gls_rso_interface_impl.h:86
Definition: rso_interface_4.h:63
Definition: component_base.h:67
Definition: gls_painter.h:51
const char * GetResource(const char *resourceName)
Get the string value for the given resource.
Definition: rso_interface_1.h:302
void AddInclude(const char *str)
Manage the list of included attributes.
Definition: gls_rso_interface_impl.h:105
The standard Mouse and keyboard events and event structures.
void AddInclude(const char *name)
Definition: gls_rso_interface_impl.h:126
bool PassFilter(const char *name) const
Definition: gls_rso_interface_impl.h:114
void UnregisterResourceObserver(ResourceHandle resourceHandle, CallbackID id)
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.
void SetFloatResource(const char *resourceName, double resourceVal)
Set the value as a float for a given named resource.
Definition: rso_interface_1.h:60
void AddExclude(const char *name)
Definition: rso_interface_1.h:209
Definition: disti_metadata.h:180
int LevelsUp() const
Definition: gls_rso_interface_impl.h:79
Definition: rso_interface_3.h:60
Definition: rso_interface_3.h:64
bool Pick3D(const RsoImplBaseInterface::Vector &winLoc, const RsoImplBaseInterface::Vector &logicalCoords, float scale, const RsoImplBaseInterface::Vector &directionVector, RsoImplBaseInterface::Vector &collisionWinLoc, const RsoImplBaseInterface::OpenGLMatrices &drawnMatrices)
Pick3D returns true if the RSO was picked.
Definition: events.h:111
ResourceHandle CreateResourceHandle(const char *resourceName)
CallbackID RegisterResourceObserver(ResourceHandle resourceHandle, ResourceObserver *obs)
Definition: rso_interface_1.h:185
const char * GetResources(RsoImplBaseInterface::ResourceFilter *filter=NULL)
int LevelsUp()
Definition: gls_resources.h:79
void Calculate(double time)
The RSO Interface methods.
Definition: rso_interface_1.h:242
int GroupLevelsDown()
Definition: gls_resources.h:96
bool NamesOnly() const
Definition: gls_rso_interface_impl.h:93
bool HandleInput(RsoImplBaseInterface::Event *lci1_ev)
void DeleteInstance()
Safely delete the object.
Definition: gls_resources.h:50
disti::GlsResourceFilter classes and methods.
const char * GetExclude(unsigned int index) const
void ReleaseResourceHandle(ResourceHandle resourceHandle)
Disposes of a resource handle.
unsigned int CallbackID
Type for unique identifiers.
Definition: rso_interface_4.h:79
bool HandleMultiTouchInput(RsoImplMultiTouchInterface::MouseMultiTouchEvent *lci3_ev)
Definition: bmpimage.h:46
void AddExclude(const char *str)
Manage the list of excluded attributes.
Definition: gls_rso_interface_impl.h:97
virtual void SetPainter(RSOPainterT *painter)
Defines the RSO interface v5, which extends v4 to add conditional rendering support.
int ExcludeCount() const
Definition: gls_rso_interface_impl.h:100
bool SetEmittedEventHandler(RsoImplBaseInterface::EmittedEventHandler *handler)
bool GetBoundingBox(RsoImplBaseInterface::Vector *min, RsoImplBaseInterface::Vector *max, const RSOMatrixT *transform=NULL)
void PushParentName(const char *parent)