Gizmo Measure - Handling of [ESC] key

When two features are selected -> unselected second feature

When one feature is selected -> unselect first feature

When no feature is selected -> close gizmo
This commit is contained in:
enricoturri1966 2022-11-21 11:20:14 +01:00
parent f0e8a22504
commit 621a43c3a2
3 changed files with 35 additions and 2 deletions

View File

@ -480,6 +480,16 @@ bool GLGizmoMeasure::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_po
m_selection_raycasters.clear();
m_parent.request_extra_frame();
}
else if (action == SLAGizmoEventType::Escape) {
if (!m_selected_features.first.feature.has_value())
return false;
else {
if (m_selected_features.second.feature.has_value())
m_selected_features.second.feature.reset();
else
m_selected_features.first.feature.reset();
}
}
return true;
}
@ -1755,8 +1765,27 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
++row_count;
}
if (m_selected_features.first.feature.has_value() || m_selected_features.second.feature.has_value()) {
add_row_to_table(
[this]() {
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, _u8L("Esc"));
},
[this]() {
m_imgui->text_colored(ImGui::GetStyleColorVec4(ImGuiCol_Text), _u8L("Unselect"));
ImGui::SameLine();
const ImVec2 pos = ImGui::GetCursorScreenPos();
const float rect_size = ImGui::GetTextLineHeight();
const ColorRGBA color = m_selected_features.second.feature.has_value() ? SELECTED_2ND_COLOR : SELECTED_1ST_COLOR;
ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + 1.0f, pos.y + 1.0f), ImVec2(pos.x + rect_size, pos.y + rect_size), ImGuiWrapper::to_ImU32(color));
ImGui::Dummy(ImVec2(rect_size, rect_size));
}
);
++row_count;
}
// add dummy rows to keep dialog size fixed
for (unsigned int i = row_count; i < 4; ++i) {
for (unsigned int i = row_count; i < 5; ++i) {
add_strings_row_to_table(*m_imgui, " ", ImGuiWrapper::COL_ORANGE_LIGHT, " ", ImGui::GetStyleColorVec4(ImGuiCol_Text));
}

View File

@ -29,6 +29,7 @@ enum class SLAGizmoEventType : unsigned char {
ShiftDown,
ShiftUp,
AltUp,
Escape,
ApplyChanges,
DiscardChanges,
AutomaticGeneration,

View File

@ -524,7 +524,10 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt)
case WXK_ESCAPE:
{
if (m_current != Undefined) {
if ((m_current != SlaSupports) || !gizmo_event(SLAGizmoEventType::DiscardChanges))
if (m_current == Measure && gizmo_event(SLAGizmoEventType::Escape)) {
// do nothing
}
else if (m_current != SlaSupports || !gizmo_event(SLAGizmoEventType::DiscardChanges))
reset_all_states();
processed = true;