Skip to content

Commit

Permalink
adding info window
Browse files Browse the repository at this point in the history
  • Loading branch information
wkjarosz committed Feb 10, 2024
1 parent f6fcc93 commit 4394c62
Show file tree
Hide file tree
Showing 2 changed files with 210 additions and 12 deletions.
198 changes: 197 additions & 1 deletion src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ HDRViewApp::HDRViewApp()
file_window.rememberIsVisible = true;
file_window.GuiFunction = [this] { draw_file_window(); };

// A console window named "Console" will be placed in "ConsoleSpace". It uses the HelloImGui logger gui
HelloImGui::DockableWindow info_window;
info_window.label = "Info";
info_window.dockSpaceName = "FileSpace";
info_window.isVisible = true;
info_window.rememberIsVisible = true;
info_window.GuiFunction = [this] { draw_info_window(); };

// the channels window
HelloImGui::DockableWindow channel_window;
channel_window.label = "Channels";
Expand All @@ -211,7 +219,8 @@ HDRViewApp::HDRViewApp()

// docking layouts
m_params.dockingParams.layoutName = "Standard";
m_params.dockingParams.dockableWindows = {histogram_window, file_window, channel_window, console_window};
m_params.dockingParams.dockableWindows = {histogram_window, file_window, info_window, channel_window,
console_window};
m_params.dockingParams.dockingSplits = {
HelloImGui::DockingSplit{"MainDockSpace", "HistogramSpace", ImGuiDir_Left, 0.2f},
HelloImGui::DockingSplit{"HistogramSpace", "FileSpace", ImGuiDir_Down, 0.75f},
Expand Down Expand Up @@ -621,6 +630,193 @@ void HDRViewApp::run()

HDRViewApp::~HDRViewApp() {}

void HDRViewApp::draw_info_window()
{
if (auto img = current_image())
{
auto &io = ImGui::GetIO();

auto p = int2{pixel_at_app_pos(io.MousePos)};

// ImGui::PushFont(m_mono_bold.at(ImGui::GetFontSize()));
float4 hovered = image_pixel(p);
auto &group = img->groups[img->selected_group];
// if (img->contains(p))
{
// ImGui::LabelText("Resolution", "%d " ICON_FA_XMARK " %d", img->size().x, img->size().y);
// ImGui::LabelText("Data window", "%s",
// fmt::format("({}, {}) : ({}, {})\n", img->data_window.min.x, img->data_window.min.y,
// img->data_window.max.x, img->data_window.max.y)
// .c_str());
// ImGui::LabelText("Display window", "%s",
// fmt::format("({}, {}) : ({}, {})\n", img->display_window.min.x,
// img->display_window.min.y,
// img->display_window.max.x, img->display_window.max.y)
// .c_str());

if (ImGui::BeginTable("properties", 2))
{
ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
ImGui::TableSetupColumn(ICON_FA_CROSSHAIRS, ImGuiTableColumnFlags_WidthFixed,
ImGui::CalcTextSize(" To Rec 709 RGB:").x);
ImGui::TableSetupColumn(ICON_FA_CROSSHAIRS, ImGuiTableColumnFlags_WidthStretch);
ImGui::PopFont();

ImGui::TableNextRow();
ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
ImGui::TableNextColumn();
ImGui::AlignCursor("File path:", 1.f);
ImGui::TextUnformatted("File path:");
ImGui::PopFont();
ImGui::TableNextColumn();
ImGui::TextWrapped(img->filename.c_str());

if (!img->partname.empty())
{
ImGui::TableNextRow();
ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
ImGui::TableNextColumn();
ImGui::AlignCursor("Part name:", 1.f);
ImGui::TextUnformatted("Part name:");
ImGui::PopFont();
ImGui::TableNextColumn();
ImGui::TextWrapped(img->partname.c_str());
}

ImGui::TableNextRow();
ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
ImGui::TableNextColumn();
ImGui::AlignCursor("Resolution:", 1.f);
ImGui::TextUnformatted("Resolution:");
ImGui::PopFont();
ImGui::TableNextColumn();
ImGui::Text("%d" ICON_FA_XMARK " %d", img->size().x, img->size().y);

ImGui::TableNextRow();
ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
ImGui::TableNextColumn();
ImGui::AlignCursor("Data window:", 1.f);
ImGui::TextUnformatted("Data window:");
ImGui::PopFont();
ImGui::TableNextColumn();
ImGui::TextUnformatted(fmt::format("({}, {}) : ({}, {})\n", img->data_window.min.x,
img->data_window.min.y, img->data_window.max.x,
img->data_window.max.y)
.c_str());

ImGui::TableNextRow();
ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
ImGui::TableNextColumn();
ImGui::AlignCursor("Display window:", 1.f);
ImGui::TextUnformatted("Display window:");
ImGui::PopFont();
ImGui::TableNextColumn();
ImGui::TextUnformatted(fmt::format("({}, {}) : ({}, {})\n", img->display_window.min.x,
img->display_window.min.y, img->display_window.max.x,
img->display_window.max.y)
.c_str());

if (img->luminance_weights != Image::Rec709_luminance_weights)
{
ImGui::TableNextRow();
ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
ImGui::TableNextColumn();
ImGui::AlignCursor("Lumi. weights:", 1.f);
ImGui::TextUnformatted("Lumi. weights:");
ImGui::PopFont();
ImGui::TableNextColumn();
ImGui::TextUnformatted(fmt::format("{:7.4f}", img->luminance_weights).c_str());
}

if (img->M_to_Rec709 != float4x4{la::identity})
{
ImGui::TableNextRow();
ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
ImGui::TableNextColumn();
ImGui::AlignCursor("To Rec 709 RGB:", 1.f);
ImGui::TextUnformatted("To Rec 709 RGB:");
ImGui::PopFont();
ImGui::TableNextColumn();
ImGui::TextWrapped(fmt::format("{:> 6.3f}", img->M_to_Rec709).c_str());
}

ImGui::EndTable();
}

// for (int c = 0; c < group.num_channels; ++c)
// {
// auto &channel = img->channels[group.channels[c]];
// string name = Channel::tail(channel.name);
// ImGui::LabelText(name.c_str(), "%6.3f", color32[c]);
// }
// float4 minimum, maximum, average;
PixelStatistics *stats[4] = {nullptr, nullptr, nullptr, nullptr};
// for (int c = 0; c < group.num_channels; ++c)
// {
// stats[c] = channel.get_statistics();
// minimum[c] = stats[c]->minimum;
// maximum[c] = stats[c]->maximum;
// average[c] = stats[c]->average;
// }
// string name = group.name;
// ImGui::InputScalarN(name.c_str(), ImGuiDataType_Float, &hovered[0], group.num_channels, nullptr, nullptr,
// "%6.3f", ImGuiInputTextFlags_ReadOnly);
// ImGui::InputScalarN("Minimum", ImGuiDataType_Float, &minimum[0], group.num_channels, nullptr, nullptr,
// "%6.3f", ImGuiInputTextFlags_ReadOnly);
// ImGui::InputScalarN("Average", ImGuiDataType_Float, &average[0], group.num_channels, nullptr, nullptr,
// "%6.3f", ImGuiInputTextFlags_ReadOnly);
// ImGui::InputScalarN("Maximum", ImGuiDataType_Float, &maximum[0], group.num_channels, nullptr, nullptr,
// "%6.3f", ImGuiInputTextFlags_ReadOnly);

ImGui::SeparatorText("Channel statistics");
static ImGuiTableFlags table_flags = ImGuiTableFlags_BordersOuterV | ImGuiTableFlags_BordersH;
if (ImGui::BeginTable("table1", 5, table_flags))
{
// ImGui::TableNextRow(), ImGui::TableNextColumn();
// ImGui::TextUnformatted("Hover"), ImGui::TableNextColumn();
ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
// // ImGui::TextUnformatted("##Channel"),
// ImGui::TableNextColumn();
// ImGui::TextUnformatted("Min"), ImGui::TableNextColumn();
// ImGui::TextUnformatted("Avg"), ImGui::TableNextColumn();
// ImGui::TextUnformatted("Max"); //, ImGui::TableNextColumn();

// const float icon_width = ImGui::CalcTextSize(ICON_FA_EYE_LOW_VISION).x;
ImGui::TableSetupColumn(ICON_FA_LAYER_GROUP, ImGuiTableColumnFlags_WidthFixed,
ImGui::CalcTextSize("channel").x);
ImGui::TableSetupColumn(ICON_FA_CROSSHAIRS, ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Min", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Avg", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Max", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableHeadersRow();
ImGui::PopFont();

for (int c = 0; c < group.num_channels; ++c)
{
auto &channel = img->channels[group.channels[c]];
string name = Channel::tail(channel.name);
auto stats = channel.get_statistics();
ImGui::TableNextRow(), ImGui::TableNextColumn();
// ImGui::Text("%6.3f", hovered[c]), ImGui::TableNextColumn();

ImGui::PushFont(m_sans_bold.at(ImGui::GetFontSize()));
ImGui::Text(" %s", name.c_str()), ImGui::TableNextColumn();
ImGui::PopFont();
ImGui::Text("%6.3f", hovered[c]), ImGui::TableNextColumn();
ImGui::Text("%6.3f", stats->minimum), ImGui::TableNextColumn();
// ImGui::PushID(c);
// ImGui::InputFloat("##", &stats->minimum, 0, 0, "6.3f", ImGuiInputTextFlags_ReadOnly);
// ImGui::PopID(), ImGui::TableNextColumn();
ImGui::Text("%6.3f", stats->average), ImGui::TableNextColumn();
ImGui::Text("%6.3f", stats->maximum); //, ImGui::TableNextColumn();
}
ImGui::EndTable();
}
}
// ImGui::PopFont();
}
}

void HDRViewApp::draw_histogram_window()
{
if (auto img = current_image())
Expand Down
24 changes: 13 additions & 11 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,19 @@ class HDRViewApp
float2 image_position(ConstImagePtr img = nullptr) const;
float2 image_scale(ConstImagePtr img = nullptr) const;

void draw_background();
void draw_histogram_window();
void draw_about_dialog();
void draw_pixel_info() const;
void draw_pixel_grid() const;
void draw_image() const;
void draw_top_toolbar();
void draw_image_border() const;
void draw_file_window();
void draw_channel_window();
void process_hotkeys();
void draw_background();
void draw_histogram_window();
void draw_info_window();
void draw_about_dialog();
void draw_pixel_info() const;
void draw_pixel_grid() const;
void draw_image() const;
void draw_top_toolbar();
void draw_image_border() const;
void draw_file_window();
void draw_channel_window();
void process_hotkeys();

float4 image_pixel(int2 p) const
{
auto img = current_image();
Expand Down

0 comments on commit 4394c62

Please sign in to comment.