Honor saved border/city color everywhere in viewer

This commit is contained in:
Jamie Vital 2023-10-14 13:06:21 -04:00
parent 83b26bb9f3
commit 45b860a28f
7 changed files with 23 additions and 25 deletions

View file

@ -184,7 +184,7 @@ namespace satdump
if (map_overlay)
{
logger->info("Drawing map overlay...");
unsigned short color[3] = {(unsigned short)(color_borders.x * 65535.0f), (unsigned short)(color_borders.y * 65535.0f), (unsigned short)(color_borders.z * 65535.0f)};
unsigned short color[3] = {(unsigned short)(viewer_color_borders.x * 65535.0f), (unsigned short)(viewer_color_borders.y * 65535.0f), (unsigned short)(viewer_color_borders.z * 65535.0f)};
map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")},
current_image,
color,
@ -194,7 +194,7 @@ namespace satdump
if (cities_overlay)
{
logger->info("Drawing cities overlay...");
unsigned short color[3] = {(unsigned short)(color_cities.x * 65535.0f), (unsigned short)(color_cities.y * 65535.0f), (unsigned short)(color_cities.z * 65535.0f)};
unsigned short color[3] = {(unsigned short)(viewer_color_cities.x * 65535.0f), (unsigned short)(viewer_color_cities.y * 65535.0f), (unsigned short)(viewer_color_cities.z * 65535.0f)};
map::drawProjectedCitiesGeoJson({resources::getResourcePath("maps/ne_10m_populated_places_simple.json")},
current_image,
color,
@ -674,11 +674,11 @@ namespace satdump
if (ImGui::Checkbox("Borders", &map_overlay))
asyncUpdate();
ImGui::SameLine();
ImGui::ColorEdit3("##borders", (float *)&color_borders, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::ColorEdit3("##borders", (float *)&viewer_color_borders, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
if (ImGui::Checkbox("Cities", &cities_overlay))
asyncUpdate();
ImGui::SameLine();
ImGui::ColorEdit3("##cities", (float *)&color_cities, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::ColorEdit3("##cities", (float *)&viewer_color_cities, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::SliderInt("Cities Font Size", &cities_size, 10, 500);
static const char *items[] = {"Capitals Only", "Capitals + Regional Capitals", "All (by Scale Rank)"};
if (ImGui::Combo("Cities Type", &cities_type, items, IM_ARRAYSIZE(items)))

View file

@ -80,9 +80,6 @@ namespace satdump
bool project_old_algorithm = false;
ImVec4 color_borders = {0, 1, 0, 1};
ImVec4 color_cities = {1, 0, 0, 1};
// Utils
void updateScaleImage();
void updateCorrectionFactors(bool first = false);

View file

@ -68,7 +68,7 @@ namespace satdump
{
auto proj_func = satdump::reprojection::setupProjectionFunction(current_img.width(), current_img.height(), current_image_proj, {});
logger->info("Drawing map overlay...");
unsigned short color[3] = {(unsigned short)(color_borders.x * 65535.0f), (unsigned short)(color_borders.y * 65535.0f), (unsigned short)(color_borders.z * 65535.0f)};
unsigned short color[3] = {(unsigned short)(viewer_color_borders.x * 65535.0f), (unsigned short)(viewer_color_borders.y * 65535.0f), (unsigned short)(viewer_color_borders.z * 65535.0f)};
map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")},
current_img,
color,
@ -157,7 +157,7 @@ namespace satdump
if (ImGui::Checkbox("Borders", &map_overlay))
update();
ImGui::SameLine();
ImGui::ColorEdit3("##borders", (float *)&color_borders, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::ColorEdit3("##borders", (float *)&viewer_color_borders, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
if (selected_visualization_id != 1)
style::endDisabled();
}

View file

@ -44,7 +44,6 @@ namespace satdump
image::Image<uint16_t> projected_img;
bool map_overlay = false;
ImVec4 color_borders = {0, 1, 0, 1};
void init();
void update();

View file

@ -16,6 +16,9 @@ void SelectableColor(ImU32 color) // funkcja pozwalająca na pokolorowanie komó
namespace satdump
{
ImVec4 viewer_color_borders = { 0, 1, 0, 1 };
ImVec4 viewer_color_cities = { 1, 0, 0, 1 };
ViewerApplication::ViewerApplication()
: Application("viewer")
{
@ -27,17 +30,17 @@ namespace satdump
if (config::main_cfg["user"]["viewer_state"].contains("borders_color"))
{
std::vector<float> color = config::main_cfg["user"]["viewer_state"]["borders_color"].get<std::vector<float>>();
color_borders.x = color[0];
color_borders.y = color[1];
color_borders.z = color[2];
viewer_color_borders.x = color[0];
viewer_color_borders.y = color[1];
viewer_color_borders.z = color[2];
}
if (config::main_cfg["user"]["viewer_state"].contains("cities_color"))
{
std::vector<float> color = config::main_cfg["user"]["viewer_state"]["cities_color"].get<std::vector<float>>();
color_cities.x = color[0];
color_cities.y = color[1];
color_cities.z = color[2];
viewer_color_cities.x = color[0];
viewer_color_cities.y = color[1];
viewer_color_cities.z = color[2];
}
@ -153,8 +156,8 @@ namespace satdump
ViewerApplication::~ViewerApplication()
{
config::main_cfg["user"]["viewer_state"]["panel_ratio"] = panel_ratio;
config::main_cfg["user"]["viewer_state"]["borders_color"] = {color_borders.x, color_borders.y, color_borders.z};
config::main_cfg["user"]["viewer_state"]["cities_color"] = {color_cities.x, color_cities.y, color_cities.z};
config::main_cfg["user"]["viewer_state"]["borders_color"] = { viewer_color_borders.x, viewer_color_borders.y, viewer_color_borders.z};
config::main_cfg["user"]["viewer_state"]["cities_color"] = { viewer_color_cities.x, viewer_color_cities.y, viewer_color_cities.z};
}
ImRect ViewerApplication::renderHandler(ProductsHandler &ph, int index)

View file

@ -40,6 +40,8 @@ namespace satdump
static std::shared_ptr<ViewerHandler> getInstance();
};
extern ImVec4 viewer_color_borders;
extern ImVec4 viewer_color_cities;
extern std::map<std::string, std::function<std::shared_ptr<ViewerHandler>()>> viewer_handlers_registry;
void registerViewerHandlers();
@ -163,9 +165,6 @@ namespace satdump
bool projections_draw_cities_overlay = true;
int projections_cities_scale = 50;
ImVec4 color_borders = {0, 1, 0, 1};
ImVec4 color_cities = {1, 0, 0, 1};
int projections_current_selected_proj = 0;
/////////////
float projections_equirectangular_tl_lon = -180;

View file

@ -399,10 +399,10 @@ namespace satdump
{
ImGui::Checkbox("Map Overlay##Projs", &projections_draw_map_overlay);
ImGui::SameLine();
ImGui::ColorEdit3("##borders", (float *)&color_borders, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::ColorEdit3("##borders", (float *)&viewer_color_borders, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::Checkbox("Cities Overlay##Projs", &projections_draw_cities_overlay);
ImGui::SameLine();
ImGui::ColorEdit3("##cities", (float *)&color_cities, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::ColorEdit3("##cities", (float *)&viewer_color_cities, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel);
ImGui::SliderInt("Cities Font Size##Projs", &projections_cities_scale, 10, 500);
}
@ -518,7 +518,7 @@ namespace satdump
if (projections_draw_map_overlay)
{
logger->info("Drawing map overlay...");
unsigned short color[4] = {(unsigned short)(color_borders.x * 65535.0f), (unsigned short)(color_borders.y * 65535.0f), (unsigned short)(color_borders.z * 65535.0f), 65535};
unsigned short color[4] = {(unsigned short)(viewer_color_borders.x * 65535.0f), (unsigned short)(viewer_color_borders.y * 65535.0f), (unsigned short)(viewer_color_borders.z * 65535.0f), 65535};
map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")},
projected_image_result,
color,
@ -529,7 +529,7 @@ namespace satdump
if (projections_draw_cities_overlay)
{
logger->info("Drawing map overlay...");
unsigned short color[4] = {(unsigned short)(color_cities.x * 65535.0f), (unsigned short)(color_cities.y * 65535.0f), (unsigned short)(color_cities.z * 65535.0f), 65535};
unsigned short color[4] = {(unsigned short)(viewer_color_cities.x * 65535.0f), (unsigned short)(viewer_color_cities.y * 65535.0f), (unsigned short)(viewer_color_cities.z * 65535.0f), 65535};
map::drawProjectedCapitalsGeoJson({resources::getResourcePath("maps/ne_10m_populated_places_simple.json")},
projected_image_result,
color,