Shiokaze Framework
A research-oriented fluid solver for computer graphics
drawable.h
Go to the documentation of this file.
1 /*
2 ** drawable.h
3 **
4 ** This is part of Shiokaze, a research-oriented fluid solver for computer graphics.
5 ** Created by Ryoichi Ando <rand@nii.ac.jp> on May 1, 2017.
6 **
7 ** Permission is hereby granted, free of charge, to any person obtaining a copy of
8 ** this software and associated documentation files (the "Software"), to deal in
9 ** the Software without restriction, including without limitation the rights to use,
10 ** copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
11 ** Software, and to permit persons to whom the Software is furnished to do so,
12 ** subject to the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included in all copies
15 ** or substantial portions of the Software.
16 **
17 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 ** HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 ** CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24 //
25 #ifndef SHKZ_DRAWABLE_H
26 #define SHKZ_DRAWABLE_H
27 //
28 #include <shiokaze/core/runnable.h>
29 #include "UI_interface.h"
30 //
31 #if SPATIAL_DIM == 3
33 #elif SPATIAL_DIM == 2
35 #else
36 #error DSPATIAL_DIM must be defined either 2 or 3.
37 #endif
38 //
40 //
42 class drawable : public runnable, public UI_interface {
45 public:
46  //
47  LONG_NAME("Drawable")
54  virtual void recursive_initialize( const environment_map &environment ) override {
55  m_environment = environment;
56  runnable::recursive_initialize (environment);
57  }
64  virtual bool handle_event( const event_structure &event ) override {
65 #ifdef SPATIAL_DIM
66  bool handled = m_camera->handle_event(event);
67  if( ! handled && m_camera->relay_event(event)) {
68  return UI_interface::handle_event(m_camera->convert(event));
69  }
70  return handled;
71 #else
72  return UI_interface::handle_event(event);
73 #endif
74  }
79  virtual void reinitialize() { recursive_initialize(m_environment); }
90  virtual void setup_window( std::string &name, int &width, int &height ) const {}
97  virtual bool should_quit() const override { return false; }
104  virtual bool should_screenshot() const { return true; }
111  virtual bool hide_logo() const { return false; }
119 #ifdef SPATIAL_DIM
120  return m_camera->get_current_cursor();
121 #else
123 #endif
124  }
125  //
126 protected:
127  //
128  environment_map m_environment;
129  //
130 #if SPATIAL_DIM == 3
131  camera3_driver m_camera{this,"camera3"};
132 #elif SPATIAL_DIM == 2
133  camera2_driver m_camera{this,"camera2"};
134 #endif
135 };
136 //
138 //
139 #endif
drawable::reinitialize
virtual void reinitialize()
Re-initialize instance.
Definition: drawable.h:79
drawable::setup_window
virtual void setup_window(std::string &name, int &width, int &height) const
Set up an initial new window environment.
Definition: drawable.h:90
recursive_configurable::recursive_initialize
virtual void recursive_initialize(const configurable::environment_map &environment=configurable::environment_map())
Initialize the program itself and relay the same to its children. Used to get things ready for actual...
Definition: configurable.h:166
drawable::handle_event
virtual bool handle_event(const event_structure &event) override
Definition: drawable.h:64
runnable
Class that performs a task.
Definition: runnable.h:35
recursive_configurable_driver
Class that encapsulates recursive_configurable class.
Definition: recursive_configurable_module.h:76
drawable
Interface for implementing drawable classes.
Definition: drawable.h:44
camera2_interface.h
camera3_interface.h
UI_interface::handle_event
virtual bool handle_event(const event_structure &event)
Definition: UI_interface.h:172
UI_interface::CURSOR_TYPE
CURSOR_TYPE
Cursor icon type.
Definition: UI_interface.h:211
SHKZ_BEGIN_NAMESPACE
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
drawable::should_screenshot
virtual bool should_screenshot() const
Function to tell the host program that screenshot should be taken.
Definition: drawable.h:104
drawable::should_quit
virtual bool should_quit() const override
Function to tell the host program that program should quit.
Definition: drawable.h:97
LONG_NAME
#define LONG_NAME(long_name)
Macro that defines the full name.
Definition: credit.h:37
UI_interface::event_structure
Event information structure.
Definition: UI_interface.h:96
UI_interface
Interface for input APIs.
Definition: UI_interface.h:38
drawable::hide_logo
virtual bool hide_logo() const
Tell the host program if a SHKZ logo should be hidden.
Definition: drawable.h:111
configurable::environment_map
std::map< std::string, const void * > environment_map
Type for environment_map.
Definition: configurable.h:46
SHKZ_END_NAMESPACE
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
drawable::get_current_cursor
virtual UI_interface::CURSOR_TYPE get_current_cursor() const override
Get current cursor icon.
Definition: drawable.h:118
runnable.h
drawable::recursive_initialize
virtual void recursive_initialize(const environment_map &environment) override
Recursively call configure.
Definition: drawable.h:54
UI_interface.h
UI_interface::ARROW_CURSOR
@ ARROW_CURSOR
Regular arrow cursor.
Definition: UI_interface.h:214