| 76 | |
| 77 | |
| 78 | void callbackFunc() { |
| 79 | ImGui::PushItemWidth(300); |
| 80 | |
| 81 | bool recomputeField = false; |
| 82 | recomputeField = recomputeField || ImGui::InputDouble("RoSy Weight", &roSyWeight); |
| 83 | recomputeField = recomputeField || ImGui::InputDouble("Alignment Weight", &alignWeight); |
| 84 | |
| 85 | if (recomputeField) { |
| 86 | recompute_field(); |
| 87 | update_visualization(); |
| 88 | } |
| 89 | |
| 90 | const char* items[] = { "Only Constraints", "Hard prescription", "Soft prescription"}; |
| 91 | static const char* current_item = NULL; |
| 92 | |
| 93 | float combo_width = 0.0f; |
| 94 | if (combo_width == 0.0f) { |
| 95 | ImGuiStyle& style = ImGui::GetStyle(); |
| 96 | for (auto& item : items) |
| 97 | combo_width = std::max(combo_width, ImGui::CalcTextSize(item).x); |
| 98 | combo_width += style.FramePadding.x * 5.0 + ImGui::GetFontSize() + style.ItemInnerSpacing.x; |
| 99 | } |
| 100 | |
| 101 | ImGui::PushItemWidth(combo_width); |
| 102 | if (ImGui::BeginCombo("Viewing mode", current_item)) // The second parameter is the label previewed before opening the combo. |
| 103 | { |
| 104 | for (int n = 0; n < IM_ARRAYSIZE(items); n++) |
| 105 | { |
| 106 | bool is_selected = (current_item == items[n]); // You can store your selection however you want, outside or inside your objects |
| 107 | if (ImGui::Selectable(items[n], is_selected)){ |
| 108 | current_item = items[n]; |
| 109 | switch (n){ |
| 110 | case 0: |
| 111 | viewingMode = CONSTRAINTS; |
| 112 | break; |
| 113 | case 1: |
| 114 | viewingMode = HARD_PRESCRIPTION; |
| 115 | break; |
| 116 | case 2: |
| 117 | viewingMode = SOFT_PRESCRIPTION; |
| 118 | break; |
| 119 | } |
| 120 | update_visualization(); |
| 121 | } |
| 122 | if (is_selected) |
| 123 | ImGui::SetItemDefaultFocus(); // You may set the initial focus when opening the combo (scrolling + for keyboard navigation support) |
| 124 | } |
| 125 | ImGui::EndCombo(); |
| 126 | } |
| 127 | |
| 128 | if (ImGui::Button("Save Raw Field")) |
| 129 | directional::write_raw_field(TUTORIAL_OUTPUT_PATH "/polyvector.rawfield", (viewingMode==HARD_PRESCRIPTION ? rawFieldHard : rawFieldSoft)); |
| 130 | |
| 131 | ImGui::PopItemWidth(); |
| 132 | } |
| 133 | |
| 134 | |
| 135 | int main() |
nothing calls this directly
no test coverage detected