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

Command line / Scripting interactions in a vim-like manner #595

Open
mwestphal opened this issue Feb 1, 2023 · 4 comments
Open

Command line / Scripting interactions in a vim-like manner #595

mwestphal opened this issue Feb 1, 2023 · 4 comments
Assignees
Labels
type:enhancement New feature or request
Milestone

Comments

@mwestphal
Copy link
Contributor

mwestphal commented Feb 1, 2023

Let user use small command to control F3D, based on the libf3d::options with a unified api, eg:

  • :render.effect.ssao toggle
  • :render.effect.ssao on
  • :render.effect.ssao off
  • :render.effect.ssao reset

It could also include specific action, eg:

  • :camera.fit

Of course, a libf3d API would need to be designed for this.

more discussions here: #535

First implementation in libf3d added in #1680

Autocompletion will be needed in the future and should be added on the command API using a dedicated callback

@mwestphal mwestphal added the type:enhancement New feature or request label Feb 1, 2023
@mwestphal mwestphal added this to the 3.0.0 milestone Jul 5, 2023
@mwestphal
Copy link
Contributor Author

So moving forward with this, here are my thoughts and a design proposal.

Introducing f3dCommand

f3dCommand will let user interact with f3d in a text based way and script certain f3d interactions.
It is centered on a few standard commands:

set, inc, dec, toggle, print, alias

And a few specific commands:

exit, reset.

Standard commands takes a libf3d options as arguments. specific commands do not support arguments at all.

set

Usage: set option value

  • option is any of the libf3d option
  • value is convertable-from-string value that will be converted to the correct type and passed to the option

Set the value of option to value. No effect if value is incompatible with option.

inc/dec

Usage: inc option

  • option is a libf3d option that supports inc/dec

Increase/Decrease the value of option. The actual change depends of the option, which will be documented by option. May have no effect on certains options.

Note: CycleScalars and such will be handled here.

toggle

Usage: toggle option

  • option is a libf3d option that supports toggle (boolean)

Toggle the the value of a boolean option.

Note: toggle animation will be handled here and added as an option instead/in supplement of being a dedicated C++ call.

print

Usage: print [option]

  • option is any of the libf3d option

Print the value of an option, without option, print info about the scene (current ? binding)

alias

Usage: alias option value

  • option is any of the libf3d option
  • value is a string alias to be used for the option

Add an alias for option named value. value can then be used anywhere instead of option.
All command-line long options will be provided as alias for the libf3d option counterpart by default in F3D application.

Note: We could extend the alias method and support not only option but any multi-word string but then separator and escaping characters will come into play. I'd rather avoid it unless we absolutely need it.

exit

Usage: exit

Stop the interactor and give back control to the applicative side

reset

Usage: reset

Reset the camera position to its default position (current "Enter" binding)

@mwestphal
Copy link
Contributor Author

mwestphal commented Nov 24, 2023

Notes from internal discussions:

@snoyer @Meakk remarked that we should plan for integration with imgui and autocompletion.

@snoyer suggested unset command, which would reset the value to default. @mwestphal suggested that reset option could be used for the same thing but in any case, it requires improvement to the options framework for implementation.

@Meakk suggested to separate between inc/dec and prev/next but it did not reach consensus and finally the idea was let down (I think?).

@snoyer suggested inverting the logic and avoiding separators (eg: fxaa_toggle) but it did not reach consensus).

@mwestphal
Copy link
Contributor Author

Implementation tryouts:

A command class or namespace does not seem very usefull.

Simply adding a

interactor& interactor::command(const std::string& command) should be enough for the public API.

In terms of actual implementation, most of the logic will go in the interactor_impl class.

Regarding the imgui integration needs, (autocompletion, option listing), it will require improvements to the options class and be provided by the interaction_impl class. But it is not required in the first implementation.

@mwestphal mwestphal mentioned this issue Jan 31, 2024
23 tasks
@mwestphal mwestphal added this to F3D Feb 3, 2024
@mwestphal mwestphal modified the milestone: 3.0.0 Feb 3, 2024
@mwestphal mwestphal moved this to Investigate in F3D Feb 4, 2024
@mwestphal mwestphal modified the milestones: 3.0.0, 3.1.0 Jul 13, 2024
@mwestphal mwestphal self-assigned this Oct 27, 2024
@mwestphal
Copy link
Contributor Author

libf3d command API has been added in #1680

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement New feature or request
Projects
Status: Investigate
Development

No branches or pull requests

1 participant