leozide / leocad

A CAD application for creating virtual LEGO models
https://www.leocad.org
2.49k stars 211 forks source link

New feature, dialog to edit train track system in an easy way. #948

Open cambrialas opened 1 month ago

cambrialas commented 1 month ago

This is a feature, which can create train track systems in an easy way.

How to use:

  1. Open the dialog pressing Ctrl+T or 'Menu -> Piece -> Train Track system wizard'
  2. Choose the wanted track section type in the parts selector.
  3. Click on track section where the new track section should be connected to. This is on the two center studs in the end of the track section.
  4. While pressing the mouse button the new track section can be rotated to the next connection point, pressing the arrow right key. Release mouse button when rotated as wanted.
  5. Delete a track section click in the middle of the section.
  6. Press 'ok' button to get the train track system into the main editor window.

This pull request is to hear what you think about this feature.

Kind regards Train track system wizard - example

leozide commented 3 weeks ago

This is an interesting idea, it reminds me of the old Track Designer app.

There were a few crashes, but I managed to get it to run. Ideally, this wouldn't be a separate dialog, and instead, we could experiment with new gizmos on the main view when a track piece is focused for a seamless editing experience.

cambrialas commented 3 weeks ago

Cool to hear you like the idea.

Agree, it's better to have the train track system editor integrated into the main window.

My thoughts about, how it could be integrated, is as follows:

  1. When a track piece is focused (selected), it should show a gizmo, in the end of the train track section to indicate, that there is something.
  2. When hovering over this gizmo, it shows a graphic context panel, with the different train track types, which is possible to connect to the selected connection point on the selected track section.
  3. When the section type is chosen, it shows another graphics context panel, with two arrows to rotate the new section and an icon to confirm the placement of the new section.

And to make it fast to place a new track section, it could be using keyboard accelerators, as follows: Hovering over the gizmo, choose section type by arrow keys 'up/down' keys and rotate by 'right/left' keys and place section by hitting 'enter' key.

I was thinking to implement the gizmo by inheriting from the 'object' class?

Best regard

leozide commented 2 weeks ago

I've checked in an initial implementation of how I think this should work.

cambrialas commented 1 week ago

It works very well, with the track system editor in main window.

In commit 'f460e65', there is added functionality, so the track can be rotated, when a new preview track section is selected. While holding the mouse left button down, the track can be rotated, moving the mouse right or left. Track section is set when the mouse button is released.