MCPcopy Create free account
hub / github.com/avaxman/Directional / callbackFunc

Function callbackFunc

tutorial/301_PowerFields/main.cpp:56–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void 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;

Callers

nothing calls this directly

Calls 8

recompute_fieldFunction · 0.70
update_visualizationFunction · 0.70
maxCoeffMethod · 0.45
rowsMethod · 0.45
conservativeResizeMethod · 0.45
sizeMethod · 0.45
rowMethod · 0.45
normalizedMethod · 0.45

Tested by

no test coverage detected