| 519 | } |
| 520 | |
| 521 | void InteractiveCameraHandler::onGUI(const std::string& suffix) { |
| 522 | |
| 523 | const std::string fullName = (suffix); |
| 524 | |
| 525 | |
| 526 | // Saving camera. |
| 527 | if (ImGui::Begin(fullName.c_str())) { |
| 528 | |
| 529 | ImGui::PushScaledItemWidth(130); |
| 530 | ImGui::Combo("Mode", (int*)&_currentMode, "FPS\0Orbit\0Interp.\0Trackball\0None\0\0"); |
| 531 | switchMode(_currentMode); |
| 532 | ImGui::SameLine(); |
| 533 | if (ImGui::Button("Load camera")) { |
| 534 | std::string selectedFile; |
| 535 | if (sibr::showFilePicker(selectedFile, Default)) { |
| 536 | if (!selectedFile.empty()) { |
| 537 | sibr::InputCamera savedCam; |
| 538 | savedCam.loadFromBinary(selectedFile); |
| 539 | SIBR_LOG << "Loaded saved camera (" << selectedFile << ")." << std::endl; |
| 540 | fromCamera(savedCam, false); |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | ImGui::SameLine(); |
| 546 | if (ImGui::Button("Save camera (bin)")) { |
| 547 | std::string selectedFile; |
| 548 | if (sibr::showFilePicker(selectedFile, Save)) { |
| 549 | if (!selectedFile.empty()) { |
| 550 | if (selectedFile[selectedFile.size() - 1] == '/' || selectedFile[selectedFile.size() - 1] == '\\') { |
| 551 | selectedFile.append("default_camera.bin"); |
| 552 | } |
| 553 | _currentCamera.saveToBinary(selectedFile); |
| 554 | SIBR_LOG << "Saved camera (" << selectedFile << ")." << std::endl; |
| 555 | } |
| 556 | } |
| 557 | } |
| 558 | |
| 559 | |
| 560 | ImGui::Separator(); |
| 561 | if (ImGui::Button("Snap to closest")) { |
| 562 | _currentCamId = findNearestCamera(_interpPath); |
| 563 | snapToCamera(_currentCamId); |
| 564 | } |
| 565 | ImGui::SameLine(); |
| 566 | if (ImGui::InputInt("Snap to", &_currentCamId, 1, 10)) { |
| 567 | _currentCamId = sibr::clamp(_currentCamId, 0, int(_interpPath.size()) - 1); |
| 568 | snapToCamera(_currentCamId); |
| 569 | } |
| 570 | |
| 571 | if (_currentMode == TRACKBALL) { |
| 572 | ImGui::SameLine(); |
| 573 | ImGui::Checkbox("Show trackball", &_trackball.drawThis); |
| 574 | } |
| 575 | |
| 576 | if (ImGui::InputFloat("Fov Y", &_cameraFovDeg, 1.0f, 5.0f)) { |
| 577 | _cameraFovDeg = sibr::clamp(_cameraFovDeg, 1.0f, 180.0f); |
| 578 | _currentCamera.fovy(_cameraFovDeg * float(M_PI) / 180.0f); |
nothing calls this directly
no test coverage detected