C++ SDK Reference  12.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyView.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) 1992-2013 Boston Dynamics
4  * ALL RIGHTS RESERVED.
5  *
6  * These coded instructions, statements, and computer programs
7  * contain unpublished proprietary information of Boston Dynamics
8  * and are protected by Copyright Laws of the United States.
9  * They may not be used, duplicated, or disclosed in any form, in
10  * whole or in part, without the prior written consent from Boston
11  * Dynamics.
12  *
13  * RESTRICTED RIGHTS LEGEND
14  * Use, duplication, or disclosure by the government is subject
15  * to restrictions as set forth in FAR 52.227.19(c)(2) or
16  * subparagraph (c)(1)(ii) of the Rights in Technical Data and
17  * Computer Software clause at DFARS 252.227-7013 and/or in
18  * similar or successor clauses in the FAR, or the DOD or NASA
19  * FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the
20  * Commercial Computer Software--Restricted Rights at 48 CFR
21  * 52.227-19, as applicable. Unpublished-rights reserved under
22  * the Copyright Laws of the United States.
23  * Contractor/Manufacturer is:
24  * Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.
25  */
26 
27 /*********************************************************************
28  **
29  *t diguyView
30  **
31  *b Link against: libdiguy
32  */
33 
34 #ifndef __diguyView_H
35 #define __diguyView_H
36 
37 #ifdef SWIG
38 %module diguyView
39 #else
40 #define CPLUSPLUS_ONLY
41 #endif
42 
43 #ifdef CPLUSPLUS_ONLY
44 
45 class bdiScenarioView;
46 class diguyView;
47 class diguyViewCamera;
48 class diguyViewFog;
49 class diguyViewLight;
50 
51 #include <stdio.h> // for NULL
52 #include <diguy_constants.h>
53 #include <diguy_typedefs.h>
54 
55 
56 #endif /* CPLUSPLUS_ONLY */
57 
58 
59 #include <declspec_diguy.h>
60 
61 /****************************************************************************/
62 class BDI_DECLSPEC_diguy diguyView
63 {
64 
65 public:
66 
67  /*l
68  *b Description:
69  **
70  ** Returns the name of the object. This pointer will
71  ** never be NULL.
72  **
73  *b Returns:
74  **
75  ** name of the view
76  **
77  *b Callable From:
78  **
79  *- - C++
80  *- - Script
81  */
82  const char* get_name();
83 
84  /*l
85  *b Description:
86  **
87  ** Returns the type name of the object. This pointer will
88  ** never be NULL.
89  **
90  *b Returns:
91  **
92  ** type name of the object
93  **
94  *b Callable From:
95  **
96  *- - C++
97  *- - Script
98  */
99  const char* get_type_name();
100 
101  /*l
102  *b Description:
103  **
104  ** Shows the view.
105  **
106  *b Returns:
107  **
108  ** 0 on success, -1 on failure
109  **
110  *b Callable From:
111  **
112  *- - C++
113  *- - Script
114  *- - Decision Bead
115  */
116  int show();
117 
118  /*l
119  *b Description:
120  **
121  ** Hides the view.
122  **
123  *b Returns:
124  **
125  ** 0 on success, -1 on failure
126  **
127  *b Callable From:
128  **
129  *- - C++
130  *- - Script
131  *- - Decision Bead
132  */
133  int hide();
134 
135  /*l
136  *b Returns:
137  **
138  ** Returns 1 if the view is showing, 0 if not.
139  **
140  *b Callable From:
141  **
142  *- - C++
143  *- - Script
144  *- - Decision Bead
145  */
146  int is_showing();
147 
148  /*l
149  *b Description:
150  **
151  ** Returns the window title of the view. This pointer will
152  ** never be NULL.
153  **
154  *b Returns:
155  **
156  ** window title of the view
157  **
158  *b Callable From:
159  **
160  *- - C++
161  *- - Script
162  */
163  const char* get_window_title();
164 
165  /*l
166  *b Description:
167  **
168  ** This function sets the window title of the view.
169  **
170  *b Arguments:
171  **
172  *a window_title - new window title
173  **
174  *b Returns:
175  **
176  ** 0 on success, -1 on failure
177  **
178  *b Callable From:
179  **
180  *- - C++
181  *- - Script
182  */
183  int set_window_title(const char* window_title);
184 
185  /*l
186  *b Description:
187  **
188  ** This function returns a pointer to the view camera.
189  **
190  *b Callable From:
191  **
192  *- - C++
193  *- - Script
194  **
195  *b Returns:
196  **
197  ** pointer of type diguyViewCamera; should never be NULL
198  */
199  diguyViewCamera* get_camera();
200 
201  /*l
202  *b Description:
203  **
204  ** This function returns a pointer to the view fog.
205  **
206  *b Returns:
207  **
208  ** pointer of type diguyViewFog; should never be NULL
209  **
210  *b Callable From:
211  **
212  *- - C++
213  *- - Script
214  */
215  diguyViewFog* get_fog();
216 
217  /*l
218  *b Description:
219  **
220  ** This function returns a pointer to the view lights.
221  **
222  *b Arguments:
223  **
224  *a number - number of light to be found
225  **
226  *b Returns:
227  **
228  ** pointer of type diguyViewLight; can be NULL if light at
229  ** specified index doesn't exist
230  **
231  *b Callable From:
232  **
233  *- - C++
234  *- - Script
235  */
236  diguyViewLight* get_light(int number = 0);
237 
238 
239 /*****************************************************************************/
245  /*l
246  *b Description:
247  **
248  ** Sets the width of the view, in pixels.
249  **
250  *b Arguments:
251  **
252  *a width - new width of view, in pixels
253  **
254  *b Returns:
255  **
256  ** 0 on success, -1 on failure
257  **
258  *b Callable From:
259  **
260  *- - C++
261  *- - Script
262  */
263  int set_width(int width);
264 
265  /*l
266  *b Returns:
267  **
268  ** width in pixels of the view
269  **
270  *b Callable From:
271  **
272  *- - C++
273  *- - Script
274  */
275  int get_width();
276 
277  /*l
278  *b Description:
279  **
280  ** Sets the height of the view, in pixels. Increasing height value
281  ** moves the view window bottom edge lower.
282  **
283  *b Arguments:
284  **
285  *a width - new height of view, in pixels
286  **
287  *b Returns:
288  **
289  ** 0 on success, -1 on failure
290  **
291  *b Callable From:
292  **
293  *- - C++
294  *- - Script
295  */
296  int set_height(int height);
297 
298  /*l
299  *b Returns:
300  **
301  ** height in pixels of the view
302  **
303  *b Callable From:
304  **
305  *- - C++
306  *- - Script
307  */
308  int get_height();
309 
310  /*l
311  *b Description:
312  **
313  ** Sets the current x position of the view window relative to the
314  ** left-hand edge of the screen.
315  **
316  *b Arguments:
317  **
318  *a x - new x coordinate of view
319  **
320  *b Returns:
321  **
322  ** 0 on success, -1 on failure
323  **
324  *b Callable From:
325  **
326  *- - C++
327  *- - Script
328  */
329  int set_x(int x);
330 
331  /*l
332  *b Returns:
333  **
334  ** current x coordinate of the view window; see set_x()
335  **
336  *b Callable From:
337  **
338  *- - C++
339  *- - Script
340  */
341  int get_x();
342 
343  /*l
344  *b Description:
345  **
346  ** Sets the current y position of the view window relative to the
347  ** upper edge of the screen. Increasing y moves the view window
348  ** lower.
349  **
350  *b Arguments:
351  **
352  *a y - new y coordinate of view
353  **
354  *b Returns:
355  **
356  ** 0 on success, -1 on failure
357  **
358  *b Callable From:
359  **
360  *- - C++
361  *- - Script
362  */
363  int set_y(int y);
364 
365  /*l
366  *b Returns:
367  **
368  ** current y coordinate of the view window; see set_y()
369  **
370  *b Callable From:
371  **
372  *- - C++
373  *- - Script
374  */
375  int get_y();
376 
377 
378 /*****************************************************************************/
384  /*l
385  *b Description:
386  **
387  ** This is an enumeration of the different callbacks
388  ** that can be registered with add_callback() and
389  ** add_callback_script().
390  **
391  *b Usable From:
392  **
393  *- - C++
394  *- - Script
395  */
396  enum {
397  CALLBACK_ID_SHOW = 1,
398  CALLBACK_ID_HIDE,
399  CALLBACK_ID_WINDOW_TITLE_CHANGED,
400  CALLBACK_ID_WINDOW_GEOMETRY_CHANGED
401  };
402 
403 #ifdef CPLUSPLUS_ONLY
404 
405  /*l
406  *b Description:
407  **
408  ** This function adds a user callback.
409  **
410  *b Arguments:
411  **
412  *a callback - pointer to function with prototype
413  *a diguyViewCallback (typedefed above)
414  *a callback_id - integer id of when this callback is to be called
415  *a callback_params - not currently used; pass NULL
416  *a callback_user_data - pointer for user's own use; DI-Guy will
417  *a do nothing to the contents of this pointer
418  *a beyond passing it back when the callback is
419  *a invoked
420  **
421  ** callback_id should be one of the following values:
422  **
423  *i CALLBACK_ID_SHOW
424  **
425  ** This callback will be called whenever the view is
426  ** to be shown, whether due to a call to the diguyView::show()
427  ** function above or due to the result of a decision
428  ** or script.
429  **
430  ** There are no parameters for this callback.
431  **
432  *i CALLBACK_ID_HIDE
433  **
434  ** This callback will be called whenever the view is
435  ** to be hidden, whether due to a call to the diguyView::hide()
436  ** function above or due to the result of a decision
437  ** or script.
438  **
439  ** There are no parameters for this callback.
440  **
441  *i CALLBACK_ID_WINDOW_TITLE_CHANGED
442  **
443  ** This callback will be called whenever the view's
444  ** window title has been changed.
445  **
446  ** There are no parameters for this callback.
447  **
448  *i Callback Return Values:
449  **
450  ** Callbacks return a value of type diguyCallbackReturn,
451  ** which will be DIGUY_CALLBACK_STOP or DIGUY_CALLBACK_CONTINUE.
452  ** If the callback returns DIGUY_CALLBACK_STOP, the default handler
453  ** of the function will not be called; the callback is asserting
454  ** that it has done everything necessary for the function call.
455  ** If the callback returns DIGUY_CALLBACK_CONTINUE, the default
456  ** handler for the function will be called after the callback.
457  **
458  *b Returns:
459  **
460  ** 0 on success, -1 on failure
461  **
462  *b Returns:
463  **
464  ** 0 on success, -1 on failure
465  **
466  *b Callable From:
467  **
468  *- - C++
469  */
470  int add_callback(int callback_id,
471  diguyViewCallback* callback,
472  void* callback_params = 0,
473  void* callback_user_data = 0);
474 
475  /*l
476  *b Description:
477  **
478  ** This function removes a user callback. All callbacks matching
479  ** the specified callback_id and callback function will be removed.
480  **
481  *b Arguments:
482  **
483  *a callback_id - integer id of when this callback is to be called
484  *a callback - pointer to function with prototype
485  *a diguyCharacterCallback (typedefed above)
486  **
487  *b Returns:
488  **
489  ** 0 on success, -1 on failure
490  */
491  int remove_callback(int callback_id,
492  diguyViewCallback* callback);
493 
494  /*l
495  *b Description:
496  **
497  ** This function removes a user callback. All callbacks matching
498  ** the specified callback_id and callback_user_data pointer will
499  ** be removed.
500  **
501  *b Arguments:
502  **
503  *a callback_id - integer id of when this callback is to be called
504  *a callback_user_data - pointer for user's own use
505  **
506  *b Returns:
507  **
508  ** 0 on success, -1 on failure
509  */
510  int remove_callback_with_user_data(int callback_id,
511  void* callback_user_data);
512 
513 #endif /* CPLUSPLUS_ONLY */
514 
515  /*l
516  *b Description:
517  **
518  ** This function adds a user callback script. Callback scripts can
519  ** be removed with remove_callback_script().
520  **
521  ** See diguyCharacter::add_callback_script() for an example
522  ** of use.
523  **
524  *b Arguments:
525  **
526  *a callback_id - integer id of the callback
527  *a callback_script - script text of callback to be added
528  *a callback_script_type - the type of script contained in
529  *a callback_script
530  **
531  ** If NULL is passed for callback_script_type, a default script type
532  ** will be derived based on the default script interpreter of the
533  ** scenario.
534  **
535  *i Lua specific:
536  **
537  ** When the script is called, the object for which it is being called
538  ** will be in the callback_object global.
539  **
540  ** To pass NULL when calling from a lua script, use nil.
541  **
542  *b Returns:
543  **
544  ** 0 on success, -1 on failure
545  **
546  *b Callable From:
547  **
548  *- - C++
549  *- - Script
550  */
551  int add_callback_script(int callback_id,
552  const char* callback_script,
553  const char* callback_script_type = NULL);
554 
555  /*l
556  *b Description:
557  **
558  ** This function removes a user callback script previously added with
559  ** add_callback_script().
560  **
561  ** See diguyCharacter::remove_callback_script() for an example
562  ** of use.
563  **
564  *b Arguments:
565  **
566  *a callback_id - integer id of the callback
567  *a callback_script - script text of callback previously added
568  *a callback_script_type - the type of script contained in
569  *a callback_script
570  **
571  ** If NULL is passed for callback_script, all callback
572  ** scripts whose ids match callback_id and whose types match
573  ** callback_script_type will be removed.
574  **
575  ** If NULL is passed for callback_script_type, a default script type
576  ** will be derived based on the default script interpreter of the
577  ** scenario.
578  **
579  *i Lua specific:
580  **
581  ** To pass NULL when calling from a lua script, use nil.
582  **
583  *b Returns:
584  **
585  ** 0 on success, -1 on failure
586  **
587  *b Callable From:
588  **
589  *- - C++
590  *- - Script
591  */
592  int remove_callback_script(int callback_id,
593  const char* callback_script,
594  const char* callback_script_type = NULL);
595 
596 
602 #ifdef CPLUSPLUS_ONLY
603 
604  bdiScenarioView* get_scripted_object() {return m_scripted_object;}
605 
606 private:
607 
608  /*l
609  ** A private constructor.
610  */
611  diguyView(bdiScenarioView* view);
612 
613  /*l
614  ** A pointer to internal data.
615  */
616  bdiScenarioView* m_scripted_object;
617 
618  friend class bdiScenarioView;
619 
620 #endif /* CPLUSPLUS_ONLY */
621 
622 };
623 
624 #endif /* __diguyView_H */
625