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