compas-dev / compas_view2

Standalone viewer for COMPAS
https://compas.dev/compas_view2/
MIT License
6 stars 8 forks source link

A `command` software architecture #181

Open ZacZhangzhuo opened 10 months ago

ZacZhangzhuo commented 10 months ago

Feature Request

Thinking deeper about issue #172, I found that a more sustainable way of developing the power of keyboard shortcuts is having a command architecture. The current way of adding code in the main class can only support a very limited number of commands and will make the code messy.

Many CAD software like AutoCAD are command-line-based, and the keyboard is just an alias for the corresponding command. Rhino even put the command line UI in front of the user, which is a successful design in my view. image

Details

I would suggest the following update:

Some additional thoughts

@Licini

Licini commented 10 months ago

The controller class and config.json already do something like this, see https://github.com/compas-dev/compas_view2/blob/3f58a432a948869a633500e8eb8e81a63b84b27f/src/compas_view2/app/config.json#L37 where it calls a function at https://github.com/compas-dev/compas_view2/blob/3f58a432a948869a633500e8eb8e81a63b84b27f/src/compas_view2/app/controller.py#L192

They can be extended to achieve what you are describing

ZacZhangzhuo commented 10 months ago

cool, i will follow it.

maybe the event functions like the keyReleaseEvent in View should be categorized in Controller ?