Virtual Testbed
Ship dynamics simulator for extreme conditions
PlainWavePanel.hh
1 #ifndef VTESTBED_GUI_PLAINWAVEPANEL_HH
2 #define VTESTBED_GUI_PLAINWAVEPANEL_HH
3 
4 #include <typeindex>
5 #include <vector>
6 
7 #include <vtestbed/core/plain_wave_generator.hh>
8 #include <vtestbed/core/types.hh>
9 #include <vtestbed/core/units.hh>
10 
11 namespace vtb {
12 
13  namespace gui {
14 
15  template <class T>
17 
18  public:
25  using policy_type = vtb::core::Policy;
27 
28  private:
29  using constructor_type =
30  wavy_surface_generator_ptr(*)(const PlainWavePanel<T>*,policy_type);
31 
32  private:
33  amplitude_type _amplitude{T{1}};
34  length_type _length{T{40}};
35  direction_type _direction{T{}};
38  std::vector<constructor_type> _constructors;
39  int _selectedIndex = 1;
40  bool _waves = true;
41 
42  public:
44 
45  inline void set_waves(bool b) { this->_waves = b; }
46  inline bool get_waves() { return this->_waves; }
47  void type(std::type_index t);
48 
49  void init(const testbed_type& testbed);
50  void draw();
51 
52  inline amplitude_type amplitude() const { return this->_amplitude; }
53  inline length_type length() const { return this->_length; }
54  inline direction_type direction() const { return this->_direction; }
55  void wave(const wave_type& rhs);
56 
57  wavy_surface_generator_ptr generator(policy_type policy) const;
58 
59  private:
60 
61  template <class Wave>
62  inline void add_wave(const char* name) {
63  using namespace vtb::core;
64  this->_names.emplace_back(name);
65  this->_types.emplace_back(typeid(Plain_wave_generator<T,3,Wave>));
66  auto ctr = [] (const PlainWavePanel* p, policy_type policy) {
67  return make_plain_wave_generator<T,3>(
68  Wave(p->amplitude(), p->length(), p->direction()), policy);
69  };
70  this->_constructors.emplace_back(ctr);
71  }
72 
73  };
74 
75  }
76 }
77 
78 #endif // vim:filetype=cpp
Core components.
Definition: bstream.hh:181
Wavy surface generator that produces elevation grid for individual wave.
Main namespace.
Definition: convert.hh:9
Base class for wavy surface generators.
Definition: core/types.hh:50
Base class for water waves.
Definition: core/types.hh:49