Skip to content

Commit

Permalink
A behaviour to scroll through time-points in bdv with mouse-wheel.
Browse files Browse the repository at this point in the history
Not binded by default.
We have to make special behaviour for it, because the behaviour
mechanism for mouse-wheel is implemented in a special behaviour
hierarchy.
  • Loading branch information
tinevez committed Nov 11, 2024
1 parent e722e4d commit 51bec1e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/mastodon/mamut/views/bdv/MamutViewBdv.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.mastodon.ui.keymap.KeyConfigContexts;
import org.mastodon.views.bdv.BdvContextProvider;
import org.mastodon.views.bdv.BigDataViewerActionsMamut;
import org.mastodon.views.bdv.BigDataViewerBehavioursMamut;
import org.mastodon.views.bdv.BigDataViewerMamut;
import org.mastodon.views.bdv.SharedBigDataViewerData;
import org.mastodon.views.bdv.ViewerFrameMamut;
Expand Down Expand Up @@ -149,6 +150,7 @@ public MamutViewBdv( final ProjectModel appModel )

MastodonFrameViewActions.install( viewActions, this );
BigDataViewerActionsMamut.install( viewActions, bdv );
BigDataViewerBehavioursMamut.install( viewBehaviours, bdv );

/*
* We have to build the coloring menu handles now. But the other actions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.mastodon.views.bdv;

import org.mastodon.ui.keymap.KeyConfigContexts;
import org.mastodon.ui.keymap.KeyConfigScopes;
import org.mastodon.views.bdv.overlay.OverlayEdge;
import org.mastodon.views.bdv.overlay.OverlayVertex;
import org.scijava.plugin.Plugin;
import org.scijava.ui.behaviour.ScrollBehaviour;
import org.scijava.ui.behaviour.io.gui.CommandDescriptionProvider;
import org.scijava.ui.behaviour.io.gui.CommandDescriptions;
import org.scijava.ui.behaviour.util.Behaviours;

import bdv.viewer.ViewerPanel;

public class BigDataViewerBehavioursMamut
{

public static final String SCROLL_TIMEPOINTS = "scroll timepoint";

private static final String[] SCROLL_TIMEPOINTS_KEYS = new String[] { "not mapped" };

public static < V extends OverlayVertex< V, E >, E extends OverlayEdge< E, V > > void install(
final Behaviours behaviours,
final BigDataViewerMamut bdv )
{
behaviours.behaviour( new ScrollTimePointsBehaviour( bdv.getViewer() ), SCROLL_TIMEPOINTS, SCROLL_TIMEPOINTS_KEYS );
}

/*
* Command descriptions for all provided commands
*/
@Plugin( type = CommandDescriptionProvider.class )
public static class Descriptions extends CommandDescriptionProvider
{
public Descriptions()
{
super( KeyConfigScopes.MASTODON, KeyConfigContexts.BIGDATAVIEWER );
}

@Override
public void getCommandDescriptions( final CommandDescriptions descriptions )
{
descriptions.add( SCROLL_TIMEPOINTS, SCROLL_TIMEPOINTS_KEYS, "Use mouse-wheel to scroll through time-points." );
}
}

private static class ScrollTimePointsBehaviour implements ScrollBehaviour
{

private final ViewerPanel viewer;

public ScrollTimePointsBehaviour( final ViewerPanel viewerPanel )
{
this.viewer = viewerPanel;
}

@Override
public void scroll( final double wheelRotation, final boolean isHorizontal, final int x, final int y )
{
if ( wheelRotation > 0 )
viewer.nextTimePoint();
else
viewer.previousTimePoint();
}

}

}

0 comments on commit 51bec1e

Please sign in to comment.