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 - take 2. #117

Closed tinevez closed 2 years ago

tinevez commented 4 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:

(base) tinevez@mastodon:~/Development/Mastodon/mastodon/samples$ unzip -c test-serialize-gui.mastodon gui.xml
Archive:  test-serialize-gui.mastodon
  inflating: gui.xml               
<?xml version="1.0" encoding="UTF-8"?>
<MamutGui version="0.3">
  <Windows>
    <Window>
      <Type>MamutViewBdv</Type>
      <FramePosition>393 441 432 424</FramePosition>
      <LockGroupId>-1</LockGroupId>
      <SettingsPanelVisible>false</SettingsPanelVisible>
      <BdvState>
        <ViewerState>
          <Sources>
            <Source>
              <active>true</active>
            </Source>
          </Sources>
          <SourceGroups>
            <SourceGroup>
              <active>true</active>
              <name>group 1</name>
              <id>0</id>
            </SourceGroup>
            <SourceGroup>
              <active>true</active>
              <name>group 2</name>
            </SourceGroup>
            <SourceGroup>
              <active>true</active>
              <name>group 3</name>
            </SourceGroup>
            <SourceGroup>
              <active>true</active>
              <name>group 4</name>
            </SourceGroup>
            <SourceGroup>
              <active>true</active>
              <name>group 5</name>
            </SourceGroup>
            <SourceGroup>
              <active>true</active>
              <name>group 6</name>
            </SourceGroup>
            <SourceGroup>
              <active>true</active>
              <name>group 7</name>
            </SourceGroup>
            <SourceGroup>
              <active>true</active>
              <name>group 8</name>
            </SourceGroup>
            <SourceGroup>
              <active>true</active>
              <name>group 9</name>
            </SourceGroup>
            <SourceGroup>
              <active>true</active>
              <name>group 10</name>
            </SourceGroup>
          </SourceGroups>
          <DisplayMode>ss</DisplayMode>
          <Interpolation>nlinear</Interpolation>
          <CurrentSource>0</CurrentSource>
          <CurrentGroup>0</CurrentGroup>
          <CurrentTimePoint>15</CurrentTimePoint>
        </ViewerState>
      </BdvState>
      <BdvTransform>10.68114656457987 0.0 0.0 -629.6109506413089 0.0 10.68114656457987 0.0 -240.48014109552344 0.0 0.0 10.68114656457987 -610.9531886710823</BdvTransform>
      <NoColoring>false</NoColoring>
      <TagSet>Evil</TagSet>
    </Window>
    <Window>
      <Type>MamutViewTrackScheme</Type>
      <FramePosition>826 124 420 667</FramePosition>
      <LockGroupId>-1</LockGroupId>
      <SettingsPanelVisible>true</SettingsPanelVisible>
      <TrackSchemeTransform>-0.8475935828877006 12.8475935828877 -0.7919020715630882 30.791902071563086 395.0 647.0</TrackSchemeTransform>
      <NoColoring>false</NoColoring>
      <TagSet>Evil</TagSet>
      <ContextProvider>BigDataViewer 1</ContextProvider>
    </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

wow, you gave it some love, very nice

:+1:

tinevez commented 2 years ago

Integrated for beta-22