Skip to content

Commit

Permalink
Merge pull request #296 from zhujun98/gui
Browse files Browse the repository at this point in the history
Improve Slice control GUI
  • Loading branch information
zhujun98 authored Feb 26, 2024
2 parents a46b030 + 5cff4b5 commit b10795d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
21 changes: 10 additions & 11 deletions gui/src/graphics/items/recon_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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<Slice::Plane, std::string> plane_options {
{Slice::Plane::XY, "X-Y"},
{Slice::Plane::YZ, "Y-Z"},
Expand All @@ -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;
}
}

Expand Down
5 changes: 3 additions & 2 deletions gui/src/graphics/slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down

0 comments on commit b10795d

Please sign in to comment.