From 7a06cd3d889a41dfad18b16d03fc6ff720bab384 Mon Sep 17 00:00:00 2001 From: Jun Zhu Date: Mon, 26 Feb 2024 09:33:21 +0100 Subject: [PATCH 1/2] Make Slice GUI more compact --- gui/src/graphics/items/recon_item.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/gui/src/graphics/items/recon_item.cpp b/gui/src/graphics/items/recon_item.cpp index e5e08ee6..0f88ea35 100644 --- a/gui/src/graphics/items/recon_item.cpp +++ b/gui/src/graphics/items/recon_item.cpp @@ -515,7 +515,7 @@ void ReconItem::renderImSliceControl(const char* header) { static const char* BTN_2D[] = {"2D##RECON_SLI_0", "2D##RECON_SLI_1", "2D##RECON_SLI_2"}; static const char* BTN_3D[] = {"3D##RECON_SLI_0", "3D##RECON_SLI_1", "3D##RECON_SLI_2"}; static const char* BTN_DISABLE[] = {"Disable##RECON_SLI_0", "Disable##RECON_SLI_1", "Disable##RECON_SLI_2"}; - static const char* COMBO[] = {"Orientation##RECON_PLANE_0", "Orientation##RECON_PLANE_1", "Orientation##RECON_PLANE_2"}; + static const char* COMBO[] = {"##RECON_PLANE_0", "##RECON_PLANE_1", "##RECON_PLANE_2"}; static const ImVec4 K_HEADER_COLOR = (ImVec4)ImColor(65, 145, 151); auto& [timestamp, _, slice] = slices_[index]; @@ -526,16 +526,6 @@ void ReconItem::renderImSliceControl(const char* header) { ImGui::PopStyleColor(); if (expand) { - bool cd = false; - - cd |= ImGui::RadioButton(BTN_2D[index], &std::get<1>(slices_[index]), SHOW2D_SLI); - ImGui::SameLine(); - cd |= ImGui::RadioButton(BTN_3D[index], &std::get<1>(slices_[index]), SHOW3D_SLI); - ImGui::SameLine(); - cd |= ImGui::RadioButton(BTN_DISABLE[index], &std::get<1>(slices_[index]), DISABLE_SLI); - - if (cd) update_min_max_val_ = true; - static const std::map plane_options { {Slice::Plane::XY, "X-Y"}, {Slice::Plane::YZ, "Y-Z"}, @@ -556,6 +546,15 @@ void ReconItem::renderImSliceControl(const char* header) { ImGui::EndCombo(); } ImGui::PopItemWidth(); + + ImGui::SameLine(); + bool cd = false; + cd |= ImGui::RadioButton(BTN_2D[index], &std::get<1>(slices_[index]), SHOW2D_SLI); + ImGui::SameLine(); + cd |= ImGui::RadioButton(BTN_3D[index], &std::get<1>(slices_[index]), SHOW3D_SLI); + ImGui::SameLine(); + cd |= ImGui::RadioButton(BTN_DISABLE[index], &std::get<1>(slices_[index]), DISABLE_SLI); + if (cd) update_min_max_val_ = true; } } From 5cff4b51800aff1d4224012c75ba60644f4b5ad9 Mon Sep 17 00:00:00 2001 From: Jun Zhu Date: Mon, 26 Feb 2024 09:33:39 +0100 Subject: [PATCH 2/2] Fix slice highlighting bug --- gui/src/graphics/slice.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gui/src/graphics/slice.cpp b/gui/src/graphics/slice.cpp index a876142c..d2ae5c7d 100644 --- a/gui/src/graphics/slice.cpp +++ b/gui/src/graphics/slice.cpp @@ -120,12 +120,13 @@ void Slice::render(const glm::mat4& view, glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } - if (hovered_ || !sample_slice) { + bool highlighted = hovered_ || highlighted_; + if (highlighted || !sample_slice) { frame_shader_->use(); frame_shader_->setMat4("view", view); frame_shader_->setMat4("projection", projection); frame_shader_->setMat4("orientationMatrix", model); - if (hovered_ || highlighted_) { + if (highlighted) { frame_shader_->setVec4("frameColor", K_HIGHLIGHTED_FRAME_COLOR_); } else { frame_shader_->setVec4("frameColor", K_EMPTY_FRAME_COLOR_);