DataDirector API
DDD_RSOAsset.h
Go to the documentation of this file.
1 /*! \file DDD_RSOAsset.h
2 
3  \par Copyright Information
4 
5  Copyright (c) 2012 The DiSTI Corporation.<br>
6  11301 Corporate Blvd; Suite 100<br>
7  Orlando, Florida 32817<br>
8  USA<br>
9  <br>
10  All rights reserved.<br>
11 
12  This Software contains proprietary trade secrets of DiSTI and may not be
13 reproduced, in whole or part, in any form, or by any means of electronic,
14 mechanical, or otherwise, without the written permission of DiSTI. Said
15 permission may be derived through the purchase of applicable DiSTI product
16 licenses which detail the distribution rights of this content and any
17 Derivative Works based on this or other copyrighted DiSTI Software.
18 
19  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
20 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
21 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
22 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
23 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
24 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
25 
26  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
27 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
28 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
29 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
30 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
31 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
32 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
33 EXCEED FIVE DOLLARS (US$5.00).
34 
35  The aforementioned terms and restrictions are governed by the laws of the
36 State of Florida and the United States of America.
37 
38 */
39 
40 #ifndef _DDD_RSOAsset_h_
41 #define _DDD_RSOAsset_h_
42 
43 
44 #include "DDD_Include.h"
45 #include "DDD_AssetBase.h"
46 #include "DDD_AttributeString.h"
47 #include "DDD_AttributeInt.h"
48 #include "DDD_AttributeDouble.h"
49 #include "DDD_AttributeBool.h"
50 #include "DDD_ObjectEvent.h"
52 
53 #include "rso_interface_1.h"
54 #include "component_base.h"
55 #include "display_frame.h"
56 #include "gls_eyepoint.h"
57 #include <string>
58 
59 ///////////////////////////////////////////////////////////
60 // Some macro definitions
61 ///////////////////////////////////////////////////////////
62 #define RSO_ASSET_CLASS "DDD_RSOAsset" /**< Hard-coded identifier for this asset class. */
63 #define RSO_PARAM_DLL_PATH "dllPath" /**< Hard-coded param name for RSO DLL path */
64 #define RSO_PARAM_CLASS_NAME "className" /**< Hard-coded param name for className */
65 #define RSO_PARAM_EYEPOINT "eyepoint" /**< Hard-coded param name for RSO Eyepoint */
66 #define RSO_PARAM_LOC_X "locX" /**< Hard-coded param name for RSO Location X value */
67 #define RSO_PARAM_LOC_Y "locY" /**< Hard-coded param name for RSO Location Y value */
68 #define RSO_PARAM_LOC_Z "locZ" /**< Hard-coded param name for RSO Location Z value */
69 #define RSO_PARAM_SCALE_X "scaleX" /**< Hard-coded param name for RSO Scale X value */
70 #define RSO_PARAM_SCALE_Y "scaleY" /**< Hard-coded param name for RSO Scale Y value */
71 #define RSO_PARAM_SCALE_Z "scaleZ" /**< Hard-coded param name for RSO Scale Z value */
72 #define RSO_INJECTED_EVENT_HANDLER "InjectedEventHandler" /**< Hard-coded param name for the RSOs EventPipe */
73 #define RSO_EVENT_SUBSCRIBER "EventSubscriber" /**< Hard-coded param name for Event Subscriber flag */
74 
75 namespace disti
76 {
77 class GlsMultiView;
78 
79 /** \brief The DDD_RSOAsset class. DataDirector asset class that controls GL Studio RSOs.
80  */
81 class DDD_EXPORT DDD_RSOAsset : public DDD_AssetBase,
82  public DDD_AttributeObserver,
83  public RSOInterface1::EmittedEventHandler,
85 {
86 public:
88 
89  static const char* const DDD_RSO_ASSET_CLASSNAME; /**< Classname string constant. Needed by the AssetFactory */
90 
91 protected:
92  static RSOAssetList _rsoAssetList; /**< List of all loaded RSO assets */
93 
94  /* Function that returns the currently loaded component
95  * \return a pointer to the currently loaded component
96  */
97  disti::ComponentBase* GetLoadedComponent(const std::string &rsoLibName,const std::string &className);
98 
99  /* Helper function that reads the data for connected attributes within a component
100  *
101  */
102  void ReadDataFromDictionary();
103 public:
104 
105  /* Default constructor
106  *
107  */
108  DDD_RSOAsset(DDD_AssetContainer *container);
109 
110  /* Default destructor
111  *
112  */
113  virtual ~DDD_RSOAsset();
114 
115  /* Helper function that returns a string with a description for the
116  * RSOAsset class
117  * \return String with a description for the RSOAsset class
118  */
119  virtual const char *Description(){ return "Wrapper Asset class for RSO Components."; }
120 
121  /* Function used to determine of the component is currently live
122  * \return True if the component is live and False if it is not
123  */
124  virtual bool Live() { return (_component != NULL); }
125 
126  /* Helper function used to retrieve the list of attributes supported
127  * by the loaded component
128  */
129  virtual void PopulateAttributeList();
130 
131  /* Function used to retrieve the class name for this asset
132  * \return The RSO Asset class name
133  */
134  virtual const char* ClassName() { return RSO_ASSET_CLASS; }
135 
136  /* Function used to set the name of the current compoent instance
137  * \param name String identifying the current component
138  */
139  virtual void SetInstanceName(const char *name);
140 
141  /* Helper function used to start and initialize the current component
142  *
143  */
144  virtual void Start();
145 
146  /* Function used to pump the current asset
147  * \param time Time slice since the last pump
148  */
149  virtual void Calculate(double time);
150 
151  /** Resume asset. Do allocations, initializations that should happen when the asset is resumed */
152  virtual void Resume();
153 
154  /* Helper function used to generate the initial instance name.
155  * Overridden from DDD_AssetBase to use RSO Classname instead of DDD_RSOAsset
156  * \param assetList List of assets used to check uniqueness
157  * \post _instanceName will have a unique identifier string
158  */
159  virtual void GenerateInstanceName(const DDD_AssetList& assetList);
160 
161  /* Function that implements the DDD_AttributeObserver interface
162  * \param attribute Pointer to the attribute whose value just
163  * changed
164  */
165  virtual void OnAttributeChanged(DDD_AttributeBase *attribute);
166 
167  /* Returns _displayObject member
168  * \return a pointer to the current displayOjbect
169  */
170  disti::ComponentBase* GetComponent();
171 
172  /** Sets the _topLevelDisplayFrame member, which is only used when the
173  * DataDirector is being embedded into a GlsDisplayFrame via the GlsDisplayFrame adapter
174  */
175  void SetTopLevelDisplayFrame(disti::DisplayFrame *frame);
176 
177  /* Sets the _component member.
178  * \param component Pointer to the component to use for this asset
179  */
180  void SetComponent(disti::ComponentBase *component);
181 
182  /* Sets the width
183  * \param width Value to use for width
184  */
185  void SetWidth(float width) { _width = width; }
186 
187  /* Returns the current width
188  * \return current width
189  */
190  float GetWidth() { return _width; }
191 
192  /* Sets the current height
193  * \param height Value to use for height
194  */
195  void SetHeight(float height) { _height = height; }
196 
197  /* Returns the current height
198  * \return current height
199  */
200  float GetHeight() { return _height; }
201 
202  /* Returns the unscaled original width
203  * \return Unscaled Width value
204  */
205  float GetUnscaledWidth() { return _unscaledWidth; }
206 
207  /* Returns the unscaled original height
208  * \return Unscaled height value
209  */
210  float GetUnscaledHeight() { return _unscaledHeight; }
211 
212  /* Returns the current scale
213  * \param scale reference to a vetor that will be populated with the current scale
214  */
215  void GetScale(disti::Vector& scale);
216 
217  /* Sets the current scale
218  * \param scaleX Scale value to use for X
219  * \param scaleY Scale value to use for Y
220  * \param scaleZ Scale value to use for Z
221  */
222  void Scale(float scaleX, float scaleY, float scaleZ);
223 
224  /* Helper function used to compute the scale
225  * Matric
226  */
227  void ComputeScaleMatrix();
228 
229  /* Returns the current origin
230  * \return a vector describing the current origin
231  */
232  disti::Vector GetOrigin();
233 
234  /* Sets the current origin
235  * \param origin Vector describing the current origin
236  */
237  void SetOrigin(disti::Vector origin);
238 
239  /* Restricts the maximum/minimum size of components on initial
240  * creation- only changes scale
241  */
242  void NormalizeComponentSize();
243 
244  /* Returns the name of the eyepoint that is currently in use
245  * \return std::string containing the name of the current eyepoint
246  */
247  std::string GetEyepointName() { return _eyepointName; }
248 
249  /* Return the current multiview
250  * \return Pointer to a GlsMultiView instance used by the current asst
251  */
252  GlsMultiView* GetMultiView() { return _multiView; }
253 
254  /* Helper function used to determine if the asset uses an eyepoint
255  * \return True if the asset uses an eyepoint and False if it doesn't
256  */
257  bool UsesEyepoint() { return _usesEyepoint; }
258 
259  /* Sets the multivew position for the current asset
260  * \param bottom Value to use for bottom
261  * \param left Value to use for left
262  * \param top Value to use for top
263  * \param right Value to use for right
264  */
265  void SetMultiViewPos(float bottom, float left, float top, float right);
266 
267  /* Implementation for the RSOInterface1::EmittedEventHandler interface
268  * \param ev Event emited by the RSO interface
269  */
270  virtual int HandleEvent(RSOInterface1::Event *ev);
271 
272  /** Event handler for direct connection to a component, not via the RSO interface
273  * This is used when Data Director is embedded into an RSO or glsDisplayFrame
274  * \param self The component producing the event
275  * \param ev The event to handle
276  * \return 1 If this method handled the event
277  */
278  int HandleComponentEvent(ComponentBase *self,DisplayEvent *ev);
279 
280  // From DDD_ObjectEventSubscriber
281  /** Posts an event to the ObjectEvent subscriber
282  * \param newEvent The event to post to the subscriber. The subscriber
283  * must make a local copy of this event
284  */
285  virtual void PostEvent(DDD_ObjectEvent *newEvent);
286 
287 protected:
288  /** If this flag is true, then Data Director is controlling the Calculate clock. If it's false
289  * then the component is doing Calculate on its own and Data Director won't call calculate on it
290  */
292 
293 public:
294  /** Sets the DDD_ControlsClock flag, which determines whether DataDirector should call Calculate on this component
295  * \param val If true, Data Director will call Calculate on this component during the Data Director Calculate traversal
296  */
297  void SetDDDControlsClock(bool val)
298  {
299  _DDD_ControlsClock = val;
300  }
301 
302 protected:
303  /* Helper function used to find an attribute object by name
304  * \param attributeName Name of the attribute we are looking for
305  */
306  virtual disti::DDD_AttributeBase* GetDictionaryAttribute(const char *attributeName);
307 
308  /* Sets the unscaled width. This should only be called once when the component
309  * is instantiated.
310  * \param width Value to set as the unscaled width
311  */
312  void SetUnscaledWidth(float width) { _unscaledWidth = width; }
313 
314  /* Sets the unscaled height. This should only be called once when the component
315  * is instantiated.
316  * \param height Value to set as the unscaled height
317  */
318  void SetUnscaledHeight(float height) { _unscaledHeight = height; }
319 
320  /* Updates scale and location of component from _loc and _scale variables
321  *
322  */
323  void UpdateScaleAndLocation();
324 
325 private:
326  /* Calls CreateLiveComponent and stores the returned value in _displayObject
327  * \return True is succesful False otherwise
328  */
329  bool LoadLiveComponent();
330 
331  /* Used to parse the getPropertiesMetadata resource in the current component
332  * NOTE: the _component variable needs to point to a valid rso instance
333  */
334  void ParseMetadata();
335 
336  /* Helper function used to determine if a particula attribute
337  * exists within the attribute list with the provided name
338  * \param attribName Name of the attribute we are looking for
339  * \return True if the attribute is found and False otherwise
340  */
341  bool IsAttributeInList(const std::string& attribName);
342 
343  /* uses _eyepointName to construct new eyepoint with attributes from given component
344  * if _eyepointName isn't found within component, it returns false
345  * returns false is component or eyepoint pointers are invalid as well
346  * \param component Component to use for setting the eyepoint
347  * \param eyepoint Eyepoint to set
348  * \return True if sucesfull False otherwise
349  */
350  bool GetEyepointFromRSO(disti::ComponentBase *component, disti::GlsEyePoint *eyepoint);
351 
352  /** Get the list of resources and resource values from the RSO and store them into resourceList
353  * \param resourceList A list of resource name/value pairs
354  */
355  void GetResourcesFromRSO(DDD_AttributeList &resourceList);
356 
357  /** Add the exposed params to the attribute list
358  */
359  void AddExposedParamsAsAttributes();
360 
361 private:
362 
363  disti::DisplayFrame *_topLevelDisplayFrame; /**< Pointer to the GlsDisplayFrame that contains this asset. Only used when the GlsDisplayFrameAdapter is used */
364 
365  disti::ComponentBase *_component; /**< Points to the instance of the component for this asset */
366  disti::ComponentBase *_rso; /**< Points to the instance of the RSO for this asset. NOTE: _rso and _component are genarly the same except for when
367  an eyepoint is being used then the _rso is a part of the group inside the _component instance. Use _rso to push/pull data */
368 
369  disti::CallbackMethodCallerBase *_oldCallback; /**< Container for any previously assigned callback to the associated RSO. */
370 
371  float _width; /**< Current width of the component */
372  float _height; /**< Current height of the component */
373 
374 
375  float _unscaledWidth; /**< Unscaled original width loaded from the component */
376  float _unscaledHeight; /**< Unscaled original height loaded from the component */
377 
378  float _unscaledOffsetX; /**< Unscaled original origin X */
379  float _unscaledOffsetY; /**< Unscaled original origin Y */
380 
381  Vector _origin; /**< Lower left corner */
382 
383 
384  std::string _eyepointName; /**< Contains the name of the eyepoint for _displayObject. It has a length()
385  * of 0 if it does not contain one. */
386 
387  bool _usesEyepoint; /**< True if the RSO uses an eyepoint */
388 
389  GlsMultiView *_multiView; /**< GlsMultiView used for viewing the component through its eyepoint */
390 
391  int _supportsAttEvents; /**< True if this RSO supports the more efficient event interface */
392 
393  DDD_ObjectEventList _objectEventQueue; /**< Queue of incoming object events from ALL RSOs, including this one. Populated by DataDirector */
394  DDD_AttributeString *_rsoLibFilename; /**< The name of the RSO DLL to load */
395  DDD_AttributeString *_rsoClassName; /**< The name of the RSO classname within the DLL */
396  DDD_AttributeString *_rsoEyepoint; /**< The name of the RSO eyepoint within the DLL */
397  DDD_AttributeDouble *_locX; /**< The Location of the RSO relative to the window origin (X) */
398  DDD_AttributeDouble *_locY; /**< The Location of the RSO relative to the window origin (Y) */
399  DDD_AttributeDouble *_locZ; /**< The Location of the RSO relative to the window origin (Z) */
400  DDD_AttributeDouble *_scaleX; /**< The Scale of the RSO relative to its original size (X) */
401  DDD_AttributeDouble *_scaleY; /**< The Scale of the RSO relative to its original size (Y) */
402  DDD_AttributeDouble *_scaleZ; /**< The Scale of the RSO relative to its original size (Z) */
403  DDD_AttributeBool *_eventSubscriber; /**< Flag indicating if this RSO wants to receive events */
404 
405  DDD_AttributeDouble *_AttLocX; /**< Attribute for the Location of the RSO relative to the window origin (X) */
406  DDD_AttributeDouble *_AttLocY; /**< Attribute for the Location of the RSO relative to the window origin (Y) */
407  DDD_AttributeDouble *_AttLocZ; /**< Attribute for the Location of the RSO relative to the window origin (Z) */
408  DDD_AttributeDouble *_AttScaleX; /**< Attribute for the Scale of the RSO relative to its original size (X) */
409  DDD_AttributeDouble *_AttScaleY; /**< Attribute for the Scale of the RSO relative to its original size (Y) */
410  DDD_AttributeDouble *_AttScaleZ; /**< Attribute for the Scale of the RSO relative to its original size (Z) */
411 
412  bool _reloadRSO; /**< Flag for notifying asset to reload or load a new component */
413 };
414 
415 } // end namespace disti
416 
417 #endif
418 
A templated array of object pointers. The array dynamically resizes as needed.
Definition: dynamic_ptr_array.h:55
A virtual interface class for subscribers to object events.
Definition: DDD_ObjectEventSubscriber.h:52
A virtual interface class for all DataDirector attribute types.
Definition: DDD_AttributeBase.h:87
virtual bool Live()
Definition: DDD_RSOAsset.h:124
A virtual interface class for all DataDirector assets.
Definition: DDD_AssetBase.h:115
static const char *const DDD_RSO_ASSET_CLASSNAME
Definition: DDD_RSOAsset.h:89
The DDD_AssetList class. Maintains a list of Data Director assets.
Definition: DDD_AssetList.h:51
The DDD_AttributeBool class. Boolean attribute.
A virtual interface class for observers of attributes. AttributeObserver-derived objects are able to ...
Definition: DDD_AttributeBase.h:66
virtual const char * ClassName()
Definition: DDD_RSOAsset.h:134
static RSOAssetList _rsoAssetList
Definition: DDD_RSOAsset.h:92
The DDD_RSOAsset class. DataDirector asset class that controls GL Studio RSOs.
Definition: DDD_RSOAsset.h:81
The DDD_AssetBase class. Base class for Data Director assets.
The DDD_AttributeInt class. Integer attribute.
A virtual interface class for containers of assets. Allows assets to find each other, exchange events and update attributes of each other.
Definition: DDD_AssetBase.h:80
#define RSO_ASSET_CLASS
Definition: DDD_RSOAsset.h:62
virtual const char * Description()
Definition: DDD_RSOAsset.h:119
void SetDDDControlsClock(bool val)
Definition: DDD_RSOAsset.h:297
The DDD_AttributeDouble class. Double precision floating point attribute.
DynamicPtrArray< DDD_ObjectEvent * > DDD_ObjectEventList
The DDD_ObjectEventList class. Maintains a list of DDD_ObjectEvents.
Definition: DDD_ObjectEvent.h:70
The DDD_AttributeString class. String attribute.
Definition: AttributeChangedEmitter.h:46
bool _DDD_ControlsClock
Definition: DDD_RSOAsset.h:291