Class interactor#
Defined in File interactor.h
Nested Relationships#
Nested Types#
Class Documentation#
-
class interactor#
Class used to control interaction and animation.
A class to control interaction with the window as well as animation. It also provide a timer callback if needed and can record/play interaction file.
Bindings
-
enum class ModifierKeys : unsigned char#
Enumeration of supported modifier combination, in binary.
Values:
-
enumerator ANY#
-
enumerator NONE#
-
enumerator CTRL#
-
enumerator SHIFT#
-
enumerator CTRL_SHIFT#
-
enumerator ANY#
-
virtual interactor &initBindings() = 0#
Remove all existing interaction commands and add all default bindings see INTERACTIONS.md for details.
-
virtual interactor &addBinding(const std::string &interaction, ModifierKeys modifiers, std::vector<std::string> commands) = 0#
Use this method to add binding, in order to trigger commands for a specified interaction and modifiers flag.
interaction can be a pressed key symbol, eg: “C”, or a dedicated key symbol for special keys: “Left”, “Right”, “Up”, “Down”, “Space”, “Enter”, “Escape”, “Question”.
modifiers is a binary flag from the dedicated enum that represent KeyModifiers.
When the corresponding interaction and modifiers happens, the provided commands will be triggered using triggerCommand. Considering checking if an interaction exists or removing it before adding it to avoid potential conflicts.
ANY modifier interactions will only be triggered if no other interaction bind with modifier is found.
Adding commands for an existing combination of interaction and modifier will throw a interactor::already_exists_exception.
-
virtual interactor &addBinding(const std::string &interaction, ModifierKeys modifiers, std::string command) = 0#
See addBinding Convenience method to add a single command for an interaction, similar as addBinding(interaction, modifiers, {command})
Adding command for an existing combination of interaction and modifier will throw a interactor::already_exists_exception.
-
inline interactor &addBinding(const std::string &interaction, ModifierKeys modifiers, std::initializer_list<std::string> list)#
Convenience initializer list signature for add binding method
-
virtual interactor &removeBinding(std::string interaction, ModifierKeys modifiers) = 0#
Remove binding corresponding to provided interaction and modifiers
-
virtual std::vector<std::pair<std::string, ModifierKeys>> getBindingInteractions() const = 0#
Return a string vector of all currently defined bind interactions
Command
-
virtual interactor &initCommands() = 0#
Remove all existing commands and add all default commands, see COMMANDS.md for details.
-
virtual interactor &addCommand(const std::string &action, std::function<void(const std::vector<std::string>&)> callback) = 0#
Use this method to add a command to be called using triggerCommand. Adding a command with an already existing action throw a interactor::already_exists_exception. Considering namespacing dedicated action to avoid conflicts with default action, eg:
my_app::action
-
virtual interactor &removeCommand(const std::string &action) = 0#
Remove a command for provided action, does not do anything if it does not exists.
-
virtual std::vector<std::string> getCommandActions() const = 0#
Return a string vector containing all currently defined actions of commands
-
virtual bool triggerCommand(std::string_view command) = 0#
Trigger provided command, see COMMANDS.md for details about supported commands and syntax.
If the command fails, it prints a debug log explaining why.
Return true if the command succeeded, false otherwise. Throw an interactor::command_runtime_exception if the command callback throw an unrecognized exception. Note that default commands cannot throw such an exception.
Animation
-
virtual void toggleAnimation() = 0#
Control the animation.
-
virtual void startAnimation() = 0#
Control the animation.
-
virtual void stopAnimation() = 0#
Control the animation.
-
virtual bool isPlayingAnimation() = 0#
Control the animation.
Movement
-
virtual void enableCameraMovement() = 0#
Control if camera movements are enabled, which they are by default.
-
virtual void disableCameraMovement() = 0#
Control if camera movements are enabled, which they are by default.
Public Functions
-
virtual unsigned long createTimerCallBack(double time, std::function<void()> callBack) = 0#
Use this method to create your own timer callback. You callback will be called once every time ms. Return an id to use in removeTimeCallBack.
-
virtual void removeTimerCallBack(unsigned long id) = 0#
Remove a previously created timer callback using the id.
-
virtual bool playInteraction(const std::string &file) = 0#
Play a VTK interaction file.
-
virtual bool recordInteraction(const std::string &file) = 0#
Start interaction and record it all in a VTK interaction file.
-
virtual void start() = 0#
Start the interactor.
-
virtual void stop() = 0#
Stop the interactor.
Public Static Functions
-
static const std::vector<std::pair<std::string, std::string>> &getDefaultInteractionsInfo()#
Get a structure of strings describing default interactions.
-
struct already_exists_exception : public f3d::exception#
An exception that can be thrown by the interactor when adding something that already exists internally
Public Functions
-
explicit already_exists_exception(const std::string &what = "")#
-
explicit already_exists_exception(const std::string &what = "")#
-
struct command_runtime_exception : public f3d::exception#
An exception that can be thrown by interactor::triggerCommand when a command callback throw an exception
Public Functions
-
explicit command_runtime_exception(const std::string &what = "")#
-
explicit command_runtime_exception(const std::string &what = "")#
-
enum class ModifierKeys : unsigned char#