Virtual Testbed
Ship dynamics simulator for extreme conditions
TestbedGUI.hh
1 #ifndef VTESTBED_GUI_TESTBEDGUI_HH
2 #define VTESTBED_GUI_TESTBEDGUI_HH
3 
4 #include <vtestbed/core/macros.hh>
5 #include <vtestbed/core/types.hh>
6 #include <vtestbed/core/testbed.hh>
7 #include <vtestbed/graphics/AxisSurface.hh>
8 #include <vtestbed/graphics/ShipCompartments.hh>
9 #include <vtestbed/graphics/ShipHullObject.hh>
10 #include <vtestbed/graphics/WavySurfaceObject.hh>
11 #include <vtestbed/graphics/WindFieldObject.hh>
12 #include <vtestbed/gui/ApplicationBase.hh>
13 #include <vtestbed/gui/CircularLineBuffer.hh>
14 #include <vtestbed/gui/RootWindow.hh>
15 #include <vtestbed/gui/ScreenRecorder.hh>
16 
17 VTB_WARNING_IGNORE_PUSH("-Wnon-virtual-dtor")
18 
19 namespace vtb {
20 
22  namespace gui {
23 
29  template <class T>
30  class TestbedGUI: public ApplicationBase {
31 
32  private:
34  using vec3 = vtb::core::Vector3<T>;
36 
37  private:
41  RootWindow<T> _rootWindow;
43  vtb::graphics::AxisSurface _bodyFixedAxis;
44  DrawableGroup3D _drawables;
45  std::unique_ptr<ScreenRecorder> _screenRecorder;
46  Matrix4 _efmatrix;
47  Float _zFar = 10000.0f;
48  Float _zNear = 0.1f;
49  bool _recording = false;
50  bool _recordThisFrame = false;
51 
52  public:
53 
54  explicit
55  TestbedGUI(
56  const Arguments& arguments,
57  const Configuration& conf,
59  );
60 
61  virtual ~TestbedGUI() = default;
62 
63  void step(const testbed_type& testbed);
64 
65  inline void
66  setNearFar(Float zNear, Float zFar) {
67  this->_zNear = zNear;
68  this->_zFar = zFar;
69  }
70 
71  inline ScreenRecorder* screenRecorder() { return this->_screenRecorder.get(); }
72 
73  inline void screenRecorder(ScreenRecorder* rhs) {
74  this->_screenRecorder.reset(rhs);
75  }
76 
77  void startScreenRecorder();
78  void recording(bool rhs);
79  inline void stopScreenRecorder() { this->_screenRecorder.reset(); }
80  inline Vector2i windowSize() { return this->ApplicationBase::windowSize(); }
81 
82  inline vtb::graphics::ShipHullObject<T>& hull() { return this->_hull; }
83  inline vtb::graphics::ShipCompartments<T>& compartments() { return this->_compartments; }
84 
85  void init(const testbed_type& testbed);
86 
87  void start();
88  void pause();
89  void stop();
90 
91  protected:
92  void drawEvent() override;
93  void keyPressEvent(KeyEvent& event) override;
94 
95  private:
96 
97  void loadShip(ship_type& entity);
98  void primitiveShipHull();
99  Matrix4 earthFixedTransfomationMatrix(const testbed_type& testbed) const;
100  inline const Matrix4 earth_fixed_matrix() const { return this->_efmatrix; }
101  inline DrawableGroup3D* drawables() { return &this->_drawables; }
102 
103  };
104 
105  }
106 
107 }
108 
109 VTB_WARNING_POP
110 
111 #endif // vim:filetype=cpp
Main namespace.
Definition: convert.hh:9
Main class for interacting with virtual testbed via GUI.
Definition: TestbedGUI.hh:30