Refactor the code to separate ui logic from application logic

This is a first leg of work aimed at separating the UI logic from the application logic.

This introduces two new objects:
- `Segment`, is used for storing the segment data
- `SegmentScene`, analogous to GraphicsScene, is used for tracking the segments in the scene. All the operations that relate to segments within a scene go through the segment scene.

There are various events for tracking when segments are added or updated. This allows the UI to react accordingly. The SegmentScene also allows UI elements to keep track of each other by associating objects to segments.

There's been a number of changes throughout to make this happen, as a lot of code across the application would directly address the various UI elements to get/set non-UI data.

There is still more work to do (in particular in app.y) but this should lay the foundation for this.