Skip to content

Commit

Permalink
Add method to ManualTransformationEditor to transform a custom set of…
Browse files Browse the repository at this point in the history
… sources
  • Loading branch information
tischi authored and tpietzsch committed Nov 17, 2023
1 parent e947a42 commit c312cc0
Showing 1 changed file with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;

Expand Down Expand Up @@ -76,6 +77,8 @@ public class ManualTransformationEditor implements TransformListener< AffineTran

private final Consumer< String > viewerMessageDisplay;

private Collection< SourceAndConverter< ? > > customSources;

public ManualTransformationEditor( final AbstractViewerPanel viewer, final InputActionBindings inputActionBindings )
{
this( viewer.transformListeners(), viewer.state(), viewer::showMessage, inputActionBindings );
Expand Down Expand Up @@ -154,6 +157,12 @@ public synchronized void reset()
}
}

public synchronized void transform( Collection< SourceAndConverter< ? > > customSources )
{
this.customSources = customSources;
setActive( true );
}

public synchronized void setActive( final boolean a )
{
if ( this.active == a )
Expand All @@ -163,18 +172,25 @@ public synchronized void setActive( final boolean a )
{
// Enter manual edit mode
final ViewerState state = this.viewerState.snapshot();
final List< SourceAndConverter< ? > > currentSources = new ArrayList<>();
switch ( state.getDisplayMode() )
final List< SourceAndConverter< ? > > transformableSources = new ArrayList<>();
if ( customSources != null )
{
case FUSED:
currentSources.add( state.getCurrentSource() );
break;
case FUSEDGROUP:
currentSources.addAll( state.getSourcesInGroup( state.getCurrentGroup() ) );
break;
default:
viewerMessageDisplay.accept( "Can only do manual transformation when in FUSED mode." );
return;
transformableSources.addAll( customSources );
}
else
{
switch ( state.getDisplayMode() )
{
case FUSED:
transformableSources.add( state.getCurrentSource() );
break;
case FUSEDGROUP:
transformableSources.addAll( state.getSourcesInGroup( state.getCurrentGroup() ) );
break;
default:
viewerMessageDisplay.accept( "Can only do manual transformation when in FUSED mode." );
return;
}
}
state.getViewerTransform( frozenTransform );
sourcesToModify.clear();
Expand All @@ -183,7 +199,7 @@ public synchronized void setActive( final boolean a )
{
if ( source.getSpimSource() instanceof TransformedSource )
{
if ( currentSources.contains( source ) )
if ( transformableSources.contains( source ) )
sourcesToModify.add( ( TransformedSource< ? > ) source.getSpimSource() );
else
sourcesToFix.add( ( TransformedSource< ? > ) source.getSpimSource() );
Expand All @@ -198,6 +214,7 @@ public synchronized void setActive( final boolean a )
{
// Exit manual edit mode.
active = false;
customSources = null;
viewerTransformListeners.remove( this );
bindings.removeInputMap( "manual transform" );
final AffineTransform3D tmp = new AffineTransform3D();
Expand Down

0 comments on commit c312cc0

Please sign in to comment.