Skip to content
Open
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
3 changes: 3 additions & 0 deletions doc/user/07-COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ eg: `azimuth_camera 120`.
`set_camera front/top/right/back/bottom/left/isometric`: A specific command to position the camera in the specified location relative to the model.
Supports `front`, `top`, `right`, `back`, `bottom`, `left`, `isometric` arguments. eg: `set_camera top`.

`set_camera x y z`: A specific command to position the camera at the specified x y z location.
eg: `set_camera 1.0 1.0 1.0`.

`toggle_volume_rendering`: A specific command to toggle `model.volume.enable` and print coloring information. No argument.

`cycle_interactor_style`: A specific command to cycle between interaction styles (default, trackball, 2d). No argument.
Expand Down
84 changes: 50 additions & 34 deletions library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1239,47 +1239,63 @@ interactor& interactor_impl::initCommands()
{
return;
}
check_args(args, 1, "set_camera");
std::string_view type = args[0];
if (type == "front")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_FRONT);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "top")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_TOP);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "right")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_RIGHT);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "back")
if (args.size() == 1)
{
this->Internals->SetViewOrbit(internals::ViewType::VT_BACK);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "bottom")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_BOTTOM);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "left")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_LEFT);
this->Internals->Style->ResetTemporaryUp();
check_args(args, 1, "set_camera");
std::string_view type = args[0];
if (type == "front")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_FRONT);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "top")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_TOP);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "right")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_RIGHT);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "back")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_BACK);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "bottom")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_BOTTOM);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "left")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_LEFT);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "isometric")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_ISOMETRIC);
this->Internals->Style->ResetTemporaryUp();
}
else
{
throw interactor::invalid_args_exception(std::string("Command: set_camera arg:\"") +
std::string(type) + "\" is not recognized.");
}
}
else if (type == "isometric")
else if (args.size() == 3)
{
this->Internals->SetViewOrbit(internals::ViewType::VT_ISOMETRIC);
this->Internals->Style->ResetTemporaryUp();
check_args(args, 3, "set_camera");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_args calls here and above are not needed anymore.

this->Internals->Window.getCamera().position(options::parse<float>(args[0]),
options::parse<float>(args[1]), options::parse<float>(args[2]));
this->Internals->Style->SetTemporaryUp(
this->Internals->Window.getCamera().getViewUp().data());
}
else
{
throw interactor::invalid_args_exception(
std::string("Command: set_camera arg:\"") + std::string(type) + "\" is not recognized.");
"Command: set_camera expects either 1 argument or 3 arguments");
}
},
command_documentation_t{ "set_camera front/top/right/back/bottom/left/isometric",
Expand Down
Loading
Loading