| 66 | |
| 67 | |
| 68 | void callbackFunc() { |
| 69 | ImGui::PushItemWidth(100); |
| 70 | ImGui::Text("Prescribed singularity index: %d", singIndices[0]); |
| 71 | ImGui::SameLine(); |
| 72 | if (ImGui::Button("+")) { |
| 73 | singIndices[0]++; |
| 74 | singIndices[1]--; |
| 75 | update_directional_field(); |
| 76 | } |
| 77 | ImGui::SameLine(); |
| 78 | if (ImGui::Button("-")) { |
| 79 | singIndices[0]--; |
| 80 | singIndices[1]++; |
| 81 | update_directional_field(); |
| 82 | } |
| 83 | if (ImGui::Button("Global Rotation")) { |
| 84 | globalRotation += std::numbers::pi / 16; |
| 85 | update_directional_field(); |
| 86 | } |
| 87 | const char* items[] = { "Prescribed singularity", "Principal-matching singularities", "Interpolated Field"}; |
| 88 | static const char* current_item = NULL; |
| 89 | |
| 90 | static float combo_width = 0.0f; |
| 91 | if (combo_width == 0.0f) { |
| 92 | ImGuiStyle& style = ImGui::GetStyle(); |
| 93 | for (auto& item : items) |
| 94 | combo_width = std::max(combo_width, ImGui::CalcTextSize(item).x); |
| 95 | combo_width += style.FramePadding.x * 5.0 + ImGui::GetFontSize() + style.ItemInnerSpacing.x; |
| 96 | } |
| 97 | |
| 98 | ImGui::PushItemWidth(combo_width); |
| 99 | if (ImGui::BeginCombo("Viewing Mode", current_item)) // The second parameter is the label previewed before opening the combo. |
| 100 | { |
| 101 | for (int n = 0; n < IM_ARRAYSIZE(items); n++) |
| 102 | { |
| 103 | bool is_selected = (current_item == items[n]); |
| 104 | if (ImGui::Selectable(items[n], is_selected)){ |
| 105 | current_item = items[n]; |
| 106 | switch (n){ |
| 107 | case 0: |
| 108 | viewingMode = TRIVIAL_ONE_SING; |
| 109 | break; |
| 110 | case 1: |
| 111 | viewingMode = TRIVIAL_PRINCIPAL_MATCHING; |
| 112 | break; |
| 113 | case 2: |
| 114 | viewingMode = IMPLICIT_FIELD; |
| 115 | break; |
| 116 | } |
| 117 | update_directional_field(); |
| 118 | } |
| 119 | if (is_selected) |
| 120 | ImGui::SetItemDefaultFocus(); |
| 121 | } |
| 122 | ImGui::EndCombo(); |
| 123 | } |
| 124 | |
| 125 | ImGui::PopItemWidth(); |
nothing calls this directly
no test coverage detected