| 54 | } |
| 55 | |
| 56 | void callbackFunc() |
| 57 | { |
| 58 | ImGui::PushItemWidth(300); |
| 59 | |
| 60 | if (ImGui::Checkbox("Normalize Field", &normalizeField)){ |
| 61 | recompute_field(); |
| 62 | update_visualization(); |
| 63 | } |
| 64 | |
| 65 | const char* items[] = { "Hard prescription", "Soft prescription"}; |
| 66 | static const char* current_item = NULL; |
| 67 | |
| 68 | float combo_width = 0.0f; |
| 69 | if (combo_width == 0.0f) { |
| 70 | ImGuiStyle& style = ImGui::GetStyle(); |
| 71 | for (auto& item : items) |
| 72 | combo_width = std::max(combo_width, ImGui::CalcTextSize(item).x); |
| 73 | combo_width += style.FramePadding.x * 5.0 + ImGui::GetFontSize() + style.ItemInnerSpacing.x; |
| 74 | } |
| 75 | |
| 76 | ImGui::PushItemWidth(combo_width); |
| 77 | if (ImGui::BeginCombo("Viewing mode", current_item)) // The second parameter is the label previewed before opening the combo. |
| 78 | { |
| 79 | for (int n = 0; n < IM_ARRAYSIZE(items); n++) |
| 80 | { |
| 81 | bool is_selected = (current_item == items[n]); // You can store your selection however you want, outside or inside your objects |
| 82 | if (ImGui::Selectable(items[n], is_selected)){ |
| 83 | current_item = items[n]; |
| 84 | switch (n){ |
| 85 | case 0: |
| 86 | viewFieldHard = true; |
| 87 | break; |
| 88 | case 1: |
| 89 | viewFieldHard = false; |
| 90 | break; |
| 91 | } |
| 92 | update_visualization(); |
| 93 | } |
| 94 | if (is_selected) |
| 95 | ImGui::SetItemDefaultFocus(); // You may set the initial focus when opening the combo (scrolling + for keyboard navigation support) |
| 96 | } |
| 97 | ImGui::EndCombo(); |
| 98 | } |
| 99 | |
| 100 | viewer.psSurfaceMeshList[0]->setSelectionMode(polyscope::MeshSelectionMode::FacesOnly); |
| 101 | ImGuiIO& io = ImGui::GetIO(); |
| 102 | if (io.MouseClicked[0]) { // if clicked |
| 103 | glm::vec2 screenCoords{io.MousePos.x, io.MousePos.y}; |
| 104 | polyscope::PickResult pickResult = polyscope::pickAtScreenCoords(screenCoords); |
| 105 | |
| 106 | if(pickResult.isHit && pickResult.structure == viewer.psSurfaceMeshList[0]) { |
| 107 | polyscope::SurfaceMeshPickResult meshPickResult = |
| 108 | viewer.psSurfaceMeshList[0]->interpretPickResult(pickResult); |
| 109 | |
| 110 | //Polyscope doesn't allow different color vectors, so we are setting two fields - one combed one not |
| 111 | if(meshPickResult.elementType == polyscope::MeshElement::FACE) { |
| 112 | |
| 113 | Eigen::Vector3d::Index maxCol; |
nothing calls this directly
no test coverage detected