Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump "camera" info should dump information about all options #1809

Merged
merged 8 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions doc/user/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
1 change: 0 additions & 1 deletion doc/user/INTERACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Camera Hotkeys:
Other hotkeys and interactions are available:

* <kbd>H</kbd>: key to toggle the display of a cheat sheet showing all these hotkeys and their statuses.
* <kbd>?</kbd>: key to print scene description to the terminal.
* <kbd>CTRL</kbd> + <kbd>Q</kbd>: close the window and quit F3D.
* <kbd>Esc</kbd>: display/hide the console.
* <kbd>Space</kbd>: play the animation if any.
Expand Down
6 changes: 6 additions & 0 deletions library/private/scene_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef f3d_scene_impl_h
#define f3d_scene_impl_h

#include "log.h"
#include "scene.h"

#include <memory>
Expand Down Expand Up @@ -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> Internals;
Expand Down
22 changes: 19 additions & 3 deletions library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,27 @@ interactor& interactor_impl::initCommands()
[&](const std::vector<std::string>&) { this->Internals->IncreaseLightIntensity(true); });

this->addCommand("print_scene_info",
[&](const std::vector<std::string>&)
{ this->Internals->Window.PrintSceneDescription(log::VerboseLevel::INFO); });

this->addCommand("print_coloring_info",
[&](const std::vector<std::string>&)
{ this->Internals->Window.PrintColoringDescription(log::VerboseLevel::INFO); });

this->addCommand("print_mesh_info",
[&](const std::vector<std::string>&)
{ this->Internals->Scene.PrintImporterDescription(log::VerboseLevel::INFO); });

this->addCommand("print_options_info",
[&](const std::vector<std::string>&)
{
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",
Expand Down Expand Up @@ -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"));
Expand Down
19 changes: 12 additions & 7 deletions library/src/scene_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Meakk marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionCheatsheetConfigFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestInteractionConsoleTypingSceneInfo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions testing/scripts/TestCommandScriptPrintColoring.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print_coloring_info
1 change: 1 addition & 0 deletions testing/scripts/TestCommandScriptPrintMesh.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print_mesh_info
1 change: 1 addition & 0 deletions testing/scripts/TestCommandScriptPrintOptions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print_options_info
1 change: 1 addition & 0 deletions testing/scripts/TestCommandScriptPrintScene.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print_scene_info
Loading