| 56 | } |
| 57 | |
| 58 | void ImageView::onGUI() { |
| 59 | |
| 60 | if(!_showGUI) { |
| 61 | return; |
| 62 | } |
| 63 | const std::string guiName = name() + " options"; |
| 64 | if(ImGui::Begin(guiName.c_str())) { |
| 65 | |
| 66 | ImGui::Text("Size: %dx%d. Scale: %.2f%%", int(_size.get()[0]), int(_size.get()[1]), 100.0f * _scale); |
| 67 | |
| 68 | if (ImGui::Button("Reset view")) { |
| 69 | _pos = sibr::Vector2f(0.0f, 0.0f); |
| 70 | _scale = 1.0f; |
| 71 | } |
| 72 | ImGui::SameLine(); |
| 73 | ImGui::Checkbox("Correct aspect ratio", &_correctRatio.get()); |
| 74 | |
| 75 | ImGui::Separator(); |
| 76 | |
| 77 | ImGui::Text("Channels"); ImGui::SameLine(); |
| 78 | ImGui::Checkbox("R", &_showChannels[0]); ImGui::SameLine(); |
| 79 | ImGui::Checkbox("G", &_showChannels[1]); ImGui::SameLine(); |
| 80 | ImGui::Checkbox("B", &_showChannels[2]); ImGui::SameLine(); |
| 81 | ImGui::Checkbox("A", &_showChannels[3]); |
| 82 | |
| 83 | ImGui::ColorEdit3("Background", &_bgColor[0]); |
| 84 | |
| 85 | ImGui::Separator(); |
| 86 | |
| 87 | const float dragSpeed = 0.05f; |
| 88 | bool editBounds = false; |
| 89 | |
| 90 | if(_lockChannels) { |
| 91 | // Only display one value and ensure synchronisation between the RGB components. |
| 92 | editBounds = ImGui::DragFloat("Min.", &_minVal.get()[0], dragSpeed) || editBounds; |
| 93 | editBounds = ImGui::DragFloat("Max.", &_maxVal.get()[0], dragSpeed) || editBounds; |
| 94 | } else { |
| 95 | editBounds = ImGui::DragFloat4("Min.", &_minVal.get()[0], dragSpeed) || editBounds; |
| 96 | editBounds = ImGui::DragFloat4("Max.", &_maxVal.get()[0], dragSpeed) || editBounds; |
| 97 | } |
| 98 | // Ensure internal state consistency. |
| 99 | if(editBounds && _lockChannels) { |
| 100 | _minVal.get()[3] = _minVal.get()[2] = _minVal.get()[1] = _minVal.get()[0]; |
| 101 | _maxVal.get()[3] = _maxVal.get()[2] = _maxVal.get()[1] = _maxVal.get()[0]; |
| 102 | } |
| 103 | // Ensure ordering. |
| 104 | if(editBounds) { |
| 105 | const sibr::Vector4f temp = _minVal; |
| 106 | _minVal = temp.cwiseMin(_maxVal.get()); |
| 107 | _maxVal = temp.cwiseMax(_maxVal.get()); |
| 108 | } |
| 109 | |
| 110 | ImGui::Checkbox("Lock values", &_lockChannels); |
| 111 | ImGui::SameLine(); |
| 112 | if (ImGui::Button("Reset values")) { |
| 113 | _minVal = sibr::Vector4f(0.0f, 0.0f, 0.0f, 0.0f); |
| 114 | _maxVal = sibr::Vector4f(1.0f, 1.0f, 1.0f, 1.0f); |
| 115 | } |