SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppDemoSceneView.cpp
Go to the documentation of this file.
1 /**
2  * \file AppDemoSceneView.cpp
3  * \date August 2019
4  * \remarks Please use clangformat to format the code. See more code style on
5  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
6  * \authors Marcus Hudritsch, Michael Göttlicher
7  * \copyright http://opensource.org/licenses/GPL-3.0
8  */
9 
10 #include <AppDemoSceneView.h>
11 #include <AppCommon.h>
12 #include <AppDemoGui.h>
13 #include <AppDemoSceneID.h>
14 
15 //-----------------------------------------------------------------------------
17  int dpi,
18  SLInputManager& inputManager)
19  : SLSceneView(s, dpi, inputManager)
20 {
21 }
22 //-----------------------------------------------------------------------------
23 /*! This method overrides the same method from the base class SLSceneView.
24  It runs some app-specific code if a certain key is pressed and calls the
25  default implementation from SLSceneView if it doesn't consume the event.
26 */
28 {
29  // Keyboard shortcuts for next or previous sceneID loading
30  if (mod & K_alt && mod & K_shift)
31  {
33  if (key == '0' && sv)
34  {
36  return true;
37  }
38  else if (key == K_left && sv &&
39  AppCommon::sceneID > 0 &&
41  {
43  return true;
44  }
45  else if (key == K_right && sv &&
47  {
49  return true;
50  }
51  }
52 
53  return SLSceneView::onKeyPress(key, mod);
54 }
55 //-----------------------------------------------------------------------------
56 /*! This method overrides the same method from the base class SLSceneView.
57  It runs some app-specific code if a certain key is pressed and calls the
58  default implementation from SLSceneView if it doesn't consume the event.
59 */
61 {
63  {
64  AppDemoGui::hideUI = false;
65  return true;
66  }
67 
68  return SLSceneView::onKeyRelease(key, mod);
69 }
70 //-----------------------------------------------------------------------------
71 /*! This method overrides the same method from the base class SLSceneView.
72  Most events such as all mouse and keyboard events from the OS are forwarded to
73  SLSceneview. SLSceneview implements a default behaviour. If you want a
74  different or additional behaviour for a certain eventhandler you have to sub-
75  class SLSceneView and override the eventhandler.
76  Because all video processing (capturing and calibration) is handled outside
77  of the core SLProject we need to add an additional handling for mouse down
78  withing the calibration routine.
79  */
81  SLint x,
82  SLint y,
83  SLKey mod)
84 {
85  // Call base class event-handler for default mouse and touchdown behaviour
86  bool baseClassResult = SLSceneView::onMouseDown(button, x, y, mod);
87 
88  // Grab image during calibration if calibration stream is running
91  {
92  grab = true;
93  }
94 
95  return baseClassResult;
96 }
97 //-----------------------------------------------------------------------------
The AppCommon class holds the top-level instances of the app-demo.
C++ Header file for the class AppDemoGui.h.
Definition of scene IDs in the demo app.
@ SID_VideoCalibrateScnd
@ SID_MaxNoBenchmarks
@ SID_Empty
@ SID_VideoCalibrateMain
static SLint dpi
Dot per inch resolution of screen.
Definition: AppGLFW.cpp:41
bool SLbool
Definition: SL.h:175
int SLint
Definition: SL.h:170
int SLSceneID
Scene identifier.
Definition: SLEnums.h:91
SLMouseButton
Mouse button codes.
Definition: SLEnums.h:98
SLKey
Keyboard key codes enumeration.
Definition: SLEnums.h:16
@ K_shift
Definition: SLEnums.h:62
@ K_right
Definition: SLEnums.h:26
@ K_alt
Definition: SLEnums.h:64
@ K_left
Definition: SLEnums.h:27
static optional< SLSceneID > sceneToLoad
Scene id to load at start up.
Definition: AppCommon.h:90
static SLVSceneView sceneViews
Vector of sceneview pointers.
Definition: AppCommon.h:62
static SLSceneID sceneID
ID of currently loaded scene.
Definition: AppCommon.h:89
static SLbool hideUI
Flag if menubar should be shown.
Definition: AppDemoGui.h:56
SLbool onKeyRelease(SLKey key, SLKey mod) final
SLbool onKeyPress(SLKey key, SLKey mod) final
SLbool onMouseDown(SLMouseButton button, SLint x, SLint y, SLKey mod) final
AppDemoSceneView(SLScene *s, int dpi, SLInputManager &inputManager)
SLInputManager. manages system input and custom input devices.
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
virtual SLbool onKeyRelease(SLKey key, SLKey mod)
virtual SLbool onKeyPress(SLKey key, SLKey mod)
virtual SLbool onMouseDown(SLMouseButton button, SLint scrX, SLint scrY, SLKey mod)
T mod(T a, T b)
Definition: Utils.h:250