Skip to content

Commit

Permalink
feat: add colormap selector to settings window
Browse files Browse the repository at this point in the history
  • Loading branch information
vtx22 committed Mar 8, 2025
1 parent 046d12a commit 6ab9402
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ConfigHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ void ConfigHandler::write_config()
std::cerr << "Failed to write config.ini!" << std::endl;
ImGui::InsertNotification({ImGuiToastType::Error, 3000, "Failed to write config.ini!"});
}
}

void ConfigHandler::apply_in_context_settings()
{
ImPlot::GetStyle().Colormap = (ImPlotColormap)std::stoi(ini["color"]["colormap"]);
}
4 changes: 4 additions & 0 deletions src/ConfigHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <string>
#include <iostream>

#include "implot.h"

#include "sparq_config.h"

#include "mini/ini.h"
Expand All @@ -21,6 +23,8 @@ class ConfigHandler
void read_config();
void write_config();

void apply_in_context_settings();

private:
ConfigHandler();
};
20 changes: 20 additions & 0 deletions src/SettingsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ void SettingsWindow::update_content()
{
show_graphics_settings();
show_downsampling_settings();
show_color_settings();

if (_settings_changed)
{
Expand Down Expand Up @@ -111,4 +112,23 @@ void SettingsWindow::show_graphics_settings()
_settings_changed = true;
}
}
}

void SettingsWindow::show_color_settings()
{
if (ImGui::CollapsingHeader("Color"))
{

ImGui::Text("Color Map:");
ImGui::SameLine();

ImPlotColormap cm_prev = ImPlot::GetStyle().Colormap;
ImPlot::ShowColormapSelector("##Colormap");

if (cm_prev != ImPlot::GetStyle().Colormap)
{
_config_handler.ini["color"]["colormap"] = std::to_string(ImPlot::GetStyle().Colormap);
_settings_changed = true;
}
}
}
1 change: 1 addition & 0 deletions src/SettingsWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SettingsWindow : public Window

void show_downsampling_settings();
void show_graphics_settings();
void show_color_settings();

private:
bool _settings_changed = false;
Expand Down
3 changes: 3 additions & 0 deletions src/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ enabled = 1
mode = 1
max_samples = 100000
max_samples_type = 0

[color]
colormap = 5
2 changes: 2 additions & 0 deletions src/sparq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ int SPARQ::window_init()

_window = &window;

config.apply_in_context_settings();

return 0;
}

Expand Down

0 comments on commit 6ab9402

Please sign in to comment.