mastodon-sc / mastodon

Mastodon – a large-scale tracking and track-editing framework for large, multi-view images.
BSD 2-Clause "Simplified" License
67 stars 20 forks source link

Serialize gui state to the Mastodon project. #86

Closed tinevez closed 4 years ago

tinevez commented 5 years ago

The state of each opened view is serialized with the Mastodon project. The state includes window position, transform, current coloring, ...

Serialization is made in a XML file in the project file:

<?xml version="1.0" encoding="UTF-8"?>
<MamutGui version="0.3">
  <Windows>
    <Window>
      <Type>MamutViewBdv</Type>
      <FramePosition>1236 160 800 681</FramePosition>
      <CurrentTimepoint>22</CurrentTimepoint>
      <CurrentGroup>0</CurrentGroup>
      <CurrentSource>0</CurrentSource>
      <Interpolation>NEARESTNEIGHBOR</Interpolation>
      <DisplayMode>SINGLE</DisplayMode>
      <BdvTransform>9.047531577216374 -7.308699511743868 -0.51107405630934 245.47491068936677 0.0 -0.8121047141929758 11.61363848317617 -381.0970600885638 -7.326546611057458 -9.02549224502162 -0.6311238989152388 1330.8443254543372</BdvTransform>
    </Window>
    <Window>
      <Type>MamutViewTrackScheme</Type>
      <FramePosition>374 398 815 674</FramePosition>
      <TrackSchemeTransform>-1.0 10.576227390180879 14.163380852140573 23.893960726900346 775.0 580.0</TrackSchemeTransform>
      <NoColoring>false</NoColoring>
      <TagSet>Fruits</TagSet>
    </Window>
  </Windows>
</MamutGui>

To access this data, the MamutViews exposes their content (trackscheme or bdv + coloringModel).

Deserialization is made by unmarshalling the XML into a Map<String, Object> that is passed to the constructors of MamutViewBdv and MamutViewTrackScheme, setting the state adequately, and when possible before the JFrame is made visible.

xulman commented 4 years ago

note the related PR #115

related in that it also reads some of the internal data of TrackScheme window, something is the same idea/plan, something is a bit different

tinevez commented 4 years ago

Hello Vlado. I will have to rewrite all of this anyway...

xulman commented 4 years ago

Hi Jean-Yves, well I don't know... I find it actually very educational, at least for me, to see how things can be read out... pity, I have discovered it only today (while I have prepared material for my PR much earlier).

I left the comment here only beacuse I found a non-zero intersection between the two PRs.

tinevez commented 4 years ago

Hello Vlado, Now that the master has new methods I will rewrite this and thrash this branch & PR. You ok with that?

xulman commented 4 years ago

Hi Jean-Yves, well, I don't know...

the new methods on master only do what your commit c26d467 was proposing plus they allow to retrieve the currently opened/viewed time point (and most likely only the time point of the given track scheme window, AFAIR).

As far as I understand your/this PR, it does much more: one can store/restore the layout of a session -- which I find actually very useful; I actually think the second commit of this PR is still valid

I would dare to back up and left this decision up to you -- I'm fine w/ and even w/o this PR existing (w/ + checkbox in load dialog "do you want to restore the precious session layout" would be the best IMHO)

long reply, low information, typical Vlado

tinevez commented 4 years ago

Superseded by #117