(This is identical to the previously closed PR #81, except that it's been rebased onto the geom-redesign branch)
Finally! 😌 Sorry this feature took so long to implement, but I am really happy with the results.
This PR enables the application to automatically save and restore it's state, persisting across browser sessions and page reloads. The state is saved silently in the background and will be restored automatically when the page loads. This feature will save:
All settings in the Control Panel
The current Selection(s)
Camera position in GeometryCanvas
Created tracks
To achieve this, and to make future changes easier, a major overhaul was made internally to how state is retained, and all of the widgets were ported to this new system. You can find all the details in the code comments and individual commit messages, but in brief:
The Controller class (formally used just for Selections) has been generalized to handle all settings and state. It has methods to change any setting and fires events for these changes.
The ContactMapCanvas, GeometryCanvas, ControlPanel and TrackPanel are all instances of the same, new base class, Component. This class has functionality to register a Controller instance and provides handler methods for all events emitted by the Controller. When more than one Component is registered to the same Controller, then changes made to the settings by one Component will trigger appropriate handlers in all other registered Components.
Controller's can have their entire state serialized and deserialized.
With this system in place, compare.js has some code set to listen for any event from the Controller. When triggered, it will serialize Controller and save the result in the browser's local storage. When the page loads, we look for a previously saved state and, if there is one, restore it.
(This is identical to the previously closed PR #81, except that it's been rebased onto the geom-redesign branch)
Finally! 😌 Sorry this feature took so long to implement, but I am really happy with the results.
This PR enables the application to automatically save and restore it's state, persisting across browser sessions and page reloads. The state is saved silently in the background and will be restored automatically when the page loads. This feature will save:
GeometryCanvas
To achieve this, and to make future changes easier, a major overhaul was made internally to how state is retained, and all of the widgets were ported to this new system. You can find all the details in the code comments and individual commit messages, but in brief:
Controller
class (formally used just for Selections) has been generalized to handle all settings and state. It has methods to change any setting and fires events for these changes.ContactMapCanvas
,GeometryCanvas
,ControlPanel
andTrackPanel
are all instances of the same, new base class,Component
. This class has functionality to register aController
instance and provides handler methods for all events emitted by the Controller. When more than one Component is registered to the same Controller, then changes made to the settings by one Component will trigger appropriate handlers in all other registered Components.With this system in place,
compare.js
has some code set to listen for any event from the Controller. When triggered, it will serialize Controller and save the result in the browser's local storage. When the page loads, we look for a previously saved state and, if there is one, restore it.