From 2bf1c7102e756385c631986ad81716cc00289476 Mon Sep 17 00:00:00 2001 From: samoncrief <51212088+samoncrief@users.noreply.github.com> Date: Tue, 31 Dec 2024 02:47:56 -0600 Subject: [PATCH] Dump "camera" info should dump information about all options (#1809) * remove ? bind/test, add new commands and tests * docs update * printOptions test fix and baselines * Update TestInteractionCheatsheetAnimationNameRaytracing.png * TestInteractionCheatsheetConfigFileRaytracing baseline --- application/testing/CMakeLists.txt | 9 +++++--- doc/user/COMMANDS.md | 6 +++++ doc/user/INTERACTIONS.md | 1 - library/private/scene_impl.h | 6 +++++ library/src/interactor_impl.cxx | 22 ++++++++++++++++--- library/src/scene_impl.cxx | 19 ++++++++++------ .../TestInteractionCheatsheetConfigFile.png | 4 ++-- ...eractionCheatsheetConfigFileRaytracing.png | 4 ++-- .../TestInteractionConsoleTypingSceneInfo.png | 4 ++-- .../TestCommandScriptPrintColoring.txt | 1 + .../scripts/TestCommandScriptPrintMesh.txt | 1 + .../scripts/TestCommandScriptPrintOptions.txt | 1 + .../scripts/TestCommandScriptPrintScene.txt | 1 + 13 files changed, 59 insertions(+), 20 deletions(-) create mode 100644 testing/scripts/TestCommandScriptPrintColoring.txt create mode 100644 testing/scripts/TestCommandScriptPrintMesh.txt create mode 100644 testing/scripts/TestCommandScriptPrintOptions.txt create mode 100644 testing/scripts/TestCommandScriptPrintScene.txt diff --git a/application/testing/CMakeLists.txt b/application/testing/CMakeLists.txt index fb3f07472c..ff6c382c97 100644 --- a/application/testing/CMakeLists.txt +++ b/application/testing/CMakeLists.txt @@ -806,7 +806,6 @@ f3d_test(NAME TestInteractionConfigFileNoColorBar DATA multi CONFIG ${F3D_SOURCE f3d_test(NAME TestInteractionConfigFileBindings DATA dragon.vtu CONFIG ${F3D_SOURCE_DIR}/testing/configs/bindings.json INTERACTION UI) #Ctrl+Shift+O;Ctrl+O;Shift+O;O;3 f3d_test(NAME TestInteractionConfigFileMulti DATA multi CONFIG ${F3D_SOURCE_DIR}/testing/configs/complex.json INTERACTION UI) #SY;Right;XG;Right;N;Right;Right f3d_test(NAME TestInteractionConfigFileAndCommand DATA multi ARGS -o CONFIG ${F3D_SOURCE_DIR}/testing/configs/complex.json INTERACTION UI) #OX;Right;N;Right;Right;Right -f3d_test(NAME TestInteractionDumpSceneState DATA dragon.vtu NO_BASELINE INTERACTION REGEXP "Camera position: 2.23745,3.83305,507.598")#? f3d_test(NAME TestInteractionCycleVerbose DATA dragon.vtu ARGS --verbose -s NO_BASELINE INTERACTION REGEXP "Not coloring")#SSSSYC f3d_test(NAME TestInteractionEmptyDrop INTERACTION REGEXP "Drop event without any provided files.")#DropEvent Empty; f3d_test(NAME TestInteractionCameraUpdate DATA dragon.vtu INTERACTION) #MouseWheel;MouseWheel;MouseWheel;S @@ -901,6 +900,10 @@ f3d_test(NAME TestInteractionPlay DATA cow.vtp ARGS --interaction-test-play=${CM f3d_test(NAME TestCommandScriptBasic DATA dragon.vtu SCRIPT TestCommandScriptBasic.txt --reference=${F3D_SOURCE_DIR}/testing/baselines/TestCommandScriptBasic.png) f3d_test(NAME TestCommandScriptInvalidCommand DATA dragon.vtu SCRIPT TestCommandScriptInvalid.txt REGEXP "Command: \"INVALID_COMMAND_1\" is not recognized, ignoring" NO_BASELINE) f3d_test(NAME TestCommandScriptMissingFile DATA dragon.vtu SCRIPT TestCommandScriptMissingFile.txt REGEXP "Unable to open command script file" NO_BASELINE) +f3d_test(NAME TestCommandScriptPrintScene DATA dragon.vtu SCRIPT TestCommandScriptPrintScene.txt REGEXP "Camera position: 2.23745,3.83305,507.598" NO_BASELINE) # print_scene_info +f3d_test(NAME TestCommandScriptPrintColoring DATA dragon.vtu SCRIPT TestCommandScriptPrintColoring.txt REGEXP "Not coloring" NO_BASELINE) # print_coloring_info +f3d_test(NAME TestCommandScriptPrintMesh DATA dragon.vtu SCRIPT TestCommandScriptPrintMesh.txt REGEXP "Number of points: 13268" NO_BASELINE) # print_mesh_info +f3d_test(NAME TestCommandScriptPrintOptions DATA dragon.vtu SCRIPT TestCommandScriptPrintOptions.txt REGEXP "interactor.invert_zoom: false" NO_BASELINE) # print_options_info f3d_test(NAME TestParseOptionalBoolExtraArg DATA dragon.vtu SCRIPT TestParseOptionalBoolExtraArg.txt REGEXP "Command: load_previous_file_group takes at most 1 argument, got 2 arguments instead." NO_BASELINE) # Window position test @@ -1093,8 +1096,8 @@ if(F3D_PLUGIN_BUILD_ALEMBIC AND F3D_PLUGIN_BUILD_ASSIMP) f3d_test(NAME TestReadersListMultiplePlugins ARGS --list-readers --load-plugins=assimp,alembic NO_BASELINE REGEXP_FAIL "Plugin failed to load") endif() -# Test list-bindings display -f3d_test(NAME TestBindingsList ARGS --list-bindings REGEXP "Any.Question Print scene descr to terminal") +# Test bindings-list display +f3d_test(NAME TestBindingsList ARGS --list-bindings REGEXP "Any.5 Toggle Orthographic Projection") # Test rendering backends # For some reason the sanitizer detects leaks because of EGL and OSMesa diff --git a/doc/user/COMMANDS.md b/doc/user/COMMANDS.md index c7b9743bcb..afe56e077b 100644 --- a/doc/user/COMMANDS.md +++ b/doc/user/COMMANDS.md @@ -38,6 +38,12 @@ eg: `roll_camera 120`. `print_scene_info`: A specific command to print information about the scene, No argument. +`print_coloring_info`: A specific command to print information about coloring settings, No argument. + +`print_mesh_info`: A specific command to print information from the mesh importer, No argument. + +`print_options_info`: A specific command to print configuration options that have a value, No argument. + `set_camera front/top/right/isometric`: A specific command to position the camera in the specified location relative to the model. Supports `front`, `top`, `right`, `isometric` arguments. eg: `set_camera top`. diff --git a/doc/user/INTERACTIONS.md b/doc/user/INTERACTIONS.md index 9bdf756748..17477b6a39 100644 --- a/doc/user/INTERACTIONS.md +++ b/doc/user/INTERACTIONS.md @@ -66,7 +66,6 @@ Camera Hotkeys: Other hotkeys and interactions are available: * H: key to toggle the display of a cheat sheet showing all these hotkeys and their statuses. -* ?: key to print scene description to the terminal. * CTRL + Q: close the window and quit F3D. * Esc: display/hide the console. * Space: play the animation if any. diff --git a/library/private/scene_impl.h b/library/private/scene_impl.h index 50180c21ea..3f0d4f5b3c 100644 --- a/library/private/scene_impl.h +++ b/library/private/scene_impl.h @@ -9,6 +9,7 @@ #ifndef f3d_scene_impl_h #define f3d_scene_impl_h +#include "log.h" #include "scene.h" #include @@ -46,6 +47,11 @@ class scene_impl : public scene */ void SetInteractor(interactor_impl* interactor); + /** + * Display available cameras in the log + */ + void PrintImporterDescription(log::VerboseLevel level); + private: class internals; std::unique_ptr Internals; diff --git a/library/src/interactor_impl.cxx b/library/src/interactor_impl.cxx index 21ff4f8ead..e724bad08b 100644 --- a/library/src/interactor_impl.cxx +++ b/library/src/interactor_impl.cxx @@ -678,10 +678,27 @@ interactor& interactor_impl::initCommands() [&](const std::vector&) { this->Internals->IncreaseLightIntensity(true); }); this->addCommand("print_scene_info", + [&](const std::vector&) + { this->Internals->Window.PrintSceneDescription(log::VerboseLevel::INFO); }); + + this->addCommand("print_coloring_info", + [&](const std::vector&) + { this->Internals->Window.PrintColoringDescription(log::VerboseLevel::INFO); }); + + this->addCommand("print_mesh_info", + [&](const std::vector&) + { this->Internals->Scene.PrintImporterDescription(log::VerboseLevel::INFO); }); + + this->addCommand("print_options_info", [&](const std::vector&) { - this->Internals->Window.PrintColoringDescription(log::VerboseLevel::INFO); - this->Internals->Window.PrintSceneDescription(log::VerboseLevel::INFO); + for (const std::string& option : this->Internals->Options.getNames()) + { + const std::string val{ this->Internals->Options.getAsString(option) }; + std::string descr{}; + descr.append(option).append(": ").append(val); + log::print(log::VerboseLevel::INFO, descr); + } }); this->addCommand("set_camera", @@ -945,7 +962,6 @@ interactor& interactor_impl::initBindings() this->addBinding({mod_t::NONE, "H"}, "toggle ui.cheatsheet", "Others", std::bind(docStr, "Toggle cheatsheet display")); this->addBinding({mod_t::NONE, "Escape"}, "toggle ui.console", "Others", std::bind(docStr, "Toggle console display")); #endif - this->addBinding({mod_t::ANY, "Question"}, "print_scene_info", "Others", std::bind(docStr, "Print scene descr to terminal")); this->addBinding({mod_t::CTRL, "Q"}, "stop_interactor", "Others", std::bind(docStr, "Stop the interactor")); this->addBinding({mod_t::NONE, "Return"}, "reset_camera", "Others", std::bind(docStr, "Reset camera to initial parameters")); this->addBinding({mod_t::NONE, "Space"}, "toggle_animation", "Others", std::bind(docStr, "Play/Pause animation if any")); diff --git a/library/src/scene_impl.cxx b/library/src/scene_impl.cxx index 5cef75f0f5..5303b23f1e 100644 --- a/library/src/scene_impl.cxx +++ b/library/src/scene_impl.cxx @@ -141,29 +141,29 @@ class scene_impl::internals scene_impl::internals::DisplayAllInfo(this->MetaImporter, this->Window); } - static void DisplayImporterDescription(vtkImporter* importer) + static void DisplayImporterDescription(log::VerboseLevel level, vtkImporter* importer) { vtkIdType availCameras = importer->GetNumberOfCameras(); if (availCameras <= 0) { - log::debug("No camera available"); + log::print(level, "No camera available"); } else { - log::debug("Camera(s) available are:"); + log::print(level, "Camera(s) available are:"); } for (int i = 0; i < availCameras; i++) { - log::debug(i, ": ", importer->GetCameraName(i)); + log::print(level, i, ": ", importer->GetCameraName(i)); } - log::debug(""); - log::debug(importer->GetOutputsDescription(), "\n"); + log::print(level, ""); + log::print(level, importer->GetOutputsDescription(), "\n"); } static void DisplayAllInfo(vtkImporter* importer, window_impl& window) { // Display output description - scene_impl::internals::DisplayImporterDescription(importer); + scene_impl::internals::DisplayImporterDescription(log::VerboseLevel::DEBUG, importer); // Display coloring information window.PrintColoringDescription(log::VerboseLevel::DEBUG); @@ -338,4 +338,9 @@ void scene_impl::SetInteractor(interactor_impl* interactor) this->Internals->AnimationManager.SetInteractor(interactor); this->Internals->Interactor->SetAnimationManager(&this->Internals->AnimationManager); } + +void scene_impl::PrintImporterDescription(log::VerboseLevel level) +{ + scene_impl::internals::DisplayImporterDescription(level, this->Internals->MetaImporter); +} } diff --git a/testing/baselines/TestInteractionCheatsheetConfigFile.png b/testing/baselines/TestInteractionCheatsheetConfigFile.png index a72c6ab111..452e42344f 100644 --- a/testing/baselines/TestInteractionCheatsheetConfigFile.png +++ b/testing/baselines/TestInteractionCheatsheetConfigFile.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e44fe81bac3376181b6d9a4a687956c1d0fd07e20bd14ddc520b0720c1ef0813 -size 254888 +oid sha256:3e98d82eaba786e8f2319773e1a61e397f9c098d9b83db9166015b745c06c901 +size 250941 diff --git a/testing/baselines/TestInteractionCheatsheetConfigFileRaytracing.png b/testing/baselines/TestInteractionCheatsheetConfigFileRaytracing.png index 2afd9d2e06..0dcb52ec21 100644 --- a/testing/baselines/TestInteractionCheatsheetConfigFileRaytracing.png +++ b/testing/baselines/TestInteractionCheatsheetConfigFileRaytracing.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dc0bf0ba171e7ee965065510cd504c2b5502b0273ad8ce2d83f9a5b0c36fd9d9 -size 260087 +oid sha256:23c99f0437fec79df9b974333d5406210dcb7dfa86dcdac1c1ece8320d7dc141 +size 258096 diff --git a/testing/baselines/TestInteractionConsoleTypingSceneInfo.png b/testing/baselines/TestInteractionConsoleTypingSceneInfo.png index 8e05e64365..bd5ba097d7 100644 --- a/testing/baselines/TestInteractionConsoleTypingSceneInfo.png +++ b/testing/baselines/TestInteractionConsoleTypingSceneInfo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ab2ccb17632c90d069ff787745b21ca13f12cc5f6d5e1f0fc288d1a1e1cf9298 -size 19869 +oid sha256:a37855f19a18d791efad08e012c3d74c2b90a881d920fa14e5ac75d7be026167 +size 18041 diff --git a/testing/scripts/TestCommandScriptPrintColoring.txt b/testing/scripts/TestCommandScriptPrintColoring.txt new file mode 100644 index 0000000000..1eb8fa7bca --- /dev/null +++ b/testing/scripts/TestCommandScriptPrintColoring.txt @@ -0,0 +1 @@ +print_coloring_info diff --git a/testing/scripts/TestCommandScriptPrintMesh.txt b/testing/scripts/TestCommandScriptPrintMesh.txt new file mode 100644 index 0000000000..ba22450d28 --- /dev/null +++ b/testing/scripts/TestCommandScriptPrintMesh.txt @@ -0,0 +1 @@ +print_mesh_info diff --git a/testing/scripts/TestCommandScriptPrintOptions.txt b/testing/scripts/TestCommandScriptPrintOptions.txt new file mode 100644 index 0000000000..41d879d670 --- /dev/null +++ b/testing/scripts/TestCommandScriptPrintOptions.txt @@ -0,0 +1 @@ +print_options_info diff --git a/testing/scripts/TestCommandScriptPrintScene.txt b/testing/scripts/TestCommandScriptPrintScene.txt new file mode 100644 index 0000000000..939dd57f2f --- /dev/null +++ b/testing/scripts/TestCommandScriptPrintScene.txt @@ -0,0 +1 @@ +print_scene_info