Skip to content

Commit

Permalink
Merge pull request #11 from MonashDeepNeuron/clean_up_gui
Browse files Browse the repository at this point in the history
Encapsulate get_current_draw_type()
  • Loading branch information
Kevin-Duignan committed Mar 20, 2024
2 parents 959aacf + 2e30aa5 commit 77c95c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion headers/const.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using std::size_t;
using s_size_t = std::make_signed_t<size_t>;

// Unsigned versions of programs base defaults
constexpr size_t AXIS_SIZE = 150;
constexpr size_t AXIS_SIZE = 80;
constexpr size_t BUFFER_SIZE = (AXIS_SIZE + 2) * (AXIS_SIZE + 2);
constexpr size_t CELL_SIZE = 5;

Expand Down
14 changes: 7 additions & 7 deletions headers/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <iostream>
#include <string>
#include <tuple>
#include <cmath>

using std::size_t;

Expand All @@ -21,14 +22,13 @@ class gui {
const std::string window_text = "Fluid Simulation";
sf::RenderWindow window;

public:
enum class draw_type : short { GREY,
HSV,
VEL };

HSV,
VEL };
draw_type current_draw_type = draw_type::GREY;

draw_type get_current_draw_type() const { return current_draw_type; }

public:
gui()
: window(sf::VideoMode(screen_width, screen_height), window_text)
{
Expand Down Expand Up @@ -73,10 +73,10 @@ class gui {

return event;
}
auto update_display(std::array<float, BUFFER_SIZE>& data, draw_type type) -> void
auto update_display(std::array<float, BUFFER_SIZE>& data) -> void
{
window.clear();
switch (type) {
switch (current_draw_type) {
case draw_type::GREY:
GreyScaleMatrixToSFML(data);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ auto main() -> int
event_mouse_click = my_event_manager.check_left_mouse_button();

if (event_mouse_click != 0) {
ds.add_density(10, event_mouse_click);
ds.add_density(3, event_mouse_click);
}

fluid_gui.update_display(ds.x(), fluid_gui.get_current_draw_type());
fluid_gui.update_display(ds.x());

std::this_thread::sleep_for(ms(5));

Expand Down

0 comments on commit 77c95c1

Please sign in to comment.