Skip to content
Snippets Groups Projects
Commit 11e3dc53 authored by Tobias Pietzsch's avatar Tobias Pietzsch
Browse files

add "go to bookmark rotation" action

parent b1783336
No related branches found
No related tags found
No related merge requests found
......@@ -103,6 +103,11 @@ public class BigDataViewer
bookmarkEditor.initGoToBookmark();
}
public void initGoToBookmarkRotation()
{
bookmarkEditor.initGoToBookmarkRotation();
}
private static String createSetupName( final BasicViewSetup setup )
{
if ( setup.hasName() )
......@@ -465,8 +470,8 @@ public class BigDataViewer
public static void main( final String[] args )
{
// final String fn = "/Users/Pietzsch/Desktop/spimrec2/dataset.xml";
// final String fn = "/Users/Pietzsch/Desktop/bdv example/drosophila 2.xml";
final String fn = "/Users/pietzsch/Desktop/data/clusterValia/140219-1/valia-140219-1.xml";
final String fn = "/Users/Pietzsch/Desktop/bdv example/drosophila 2.xml";
// final String fn = "/Users/pietzsch/Desktop/data/clusterValia/140219-1/valia-140219-1.xml";
// final String fn = "/Users/Pietzsch/Desktop/data/catmaid.xml";
// final String fn = "/Users/Pietzsch/Desktop/data/openconnectome-bock11-neariso.xml";
// final String fn = "/Users/Pietzsch/Desktop/data/catmaid-confocal.xml";
......
......@@ -24,6 +24,7 @@ public class BigDataViewerActions
public static final String RECORD_MOVIE = "record movie";
public static final String SET_BOOKMARK = "set bookmark";
public static final String GO_TO_BOOKMARK = "go to bookmark";
public static final String GO_TO_BOOKMARK_ROTATION = "go to bookmark rotation";
/**
* Create BigDataViewer actions and install them in the specified
......@@ -59,6 +60,7 @@ public class BigDataViewerActions
map.put( SAVE_SETTINGS, "F11" );
map.put( LOAD_SETTINGS, "F12" );
map.put( GO_TO_BOOKMARK, "B" );
map.put( GO_TO_BOOKMARK_ROTATION, "O" );
map.put( SET_BOOKMARK, "shift B" );
return inputMap;
......@@ -77,6 +79,7 @@ public class BigDataViewerActions
map.put( new ManualTransformAction( bdv ) );
map.put( new SetBookmarkAction( bdv ) );
map.put( new GoToBookmarkAction( bdv ) );
map.put( new GoToBookmarkRotationAction( bdv ) );
map.put( new SaveSettingsAction( bdv ) );
map.put( new LoadSettingsAction( bdv ) );
......@@ -144,6 +147,22 @@ public class BigDataViewerActions
private static final long serialVersionUID = 1L;
}
public static class GoToBookmarkRotationAction extends ViewerAction
{
public GoToBookmarkRotationAction( final BigDataViewer bdv )
{
super( GO_TO_BOOKMARK_ROTATION, bdv );
}
@Override
public void actionPerformed( final ActionEvent e )
{
bdv.initGoToBookmarkRotation();
}
private static final long serialVersionUID = 1L;
}
public static class SaveSettingsAction extends ViewerAction
{
public SaveSettingsAction( final BigDataViewer bdv )
......
......@@ -11,10 +11,13 @@ import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.KeyStroke;
import net.imglib2.Point;
import net.imglib2.realtransform.AffineTransform3D;
import bdv.util.Affine3DHelpers;
import bdv.viewer.InputActionBindings;
import bdv.viewer.ViewerPanel;
import bdv.viewer.animate.RigidTransformAnimator;
import bdv.viewer.animate.SimilarityTransformAnimator;
import bdv.viewer.animate.RotationAnimator;
public class BookmarkEditor
{
......@@ -103,11 +106,28 @@ public class BookmarkEditor
final double cY = viewer.getDisplay().getHeight() / 2.0;
c.set( c.get( 0, 3 ) - cX, 0, 3 );
c.set( c.get( 1, 3 ) - cY, 1, 3 );
viewer.setTransformAnimator( new RigidTransformAnimator( c, t, cX, cY, 300 ) );
viewer.setTransformAnimator( new SimilarityTransformAnimator( c, t, cX, cY, 300 ) );
}
animator.fadeOut( "go to bookmark: " + key, 500 );
}
break;
case RECALL_ORIENTATION:
{
final AffineTransform3D t = bookmarks.get( key );
if ( t != null )
{
final AffineTransform3D c = new AffineTransform3D();
viewer.getState().getViewerTransform( c );
final Point p = new Point( 2 );
viewer.getMouseCoordinates( p );
final double[] qTarget = new double[ 4 ];
Affine3DHelpers.extractRotation( t, qTarget );
viewer.setTransformAnimator(
new RotationAnimator( c, p.getDoublePosition( 0 ), p.getDoublePosition( 1 ), qTarget, 300 ) );
}
animator.fadeOut( "go to bookmark orientation: " + key, 500 );
}
break;
default:
break;
}
......@@ -125,28 +145,31 @@ public class BookmarkEditor
done();
}
public synchronized void initSetBookmark()
protected synchronized void init( final Mode mode, final String message )
{
initialKey = true;
mode = Mode.SET;
this.mode = mode;
bindings.addInputMap( "bookmarks", inputMap, "bdv", "navigation" );
if ( animator != null )
animator.clear();
animator = new BookmarkTextOverlayAnimator( viewer );
viewer.addOverlayAnimator( animator );
animator.fadeIn( "set bookmark: ", 100 );
animator.fadeIn( message, 100 );
}
public synchronized void initSetBookmark()
{
init( Mode.SET, "set bookmark: " );
}
public synchronized void initGoToBookmark()
{
initialKey = true;
mode = Mode.RECALL_TRANSFORM;
bindings.addInputMap( "bookmarks", inputMap, "bdv", "navigation" );
if ( animator != null )
animator.clear();
animator = new BookmarkTextOverlayAnimator( viewer );
viewer.addOverlayAnimator( animator );
animator.fadeIn( "go to bookmark: ", 100 );
init( Mode.RECALL_TRANSFORM, "go to bookmark: " );
}
public void initGoToBookmarkRotation()
{
init( Mode.RECALL_ORIENTATION, "go to bookmark orientation: " );
}
public synchronized void done()
......
......@@ -367,6 +367,16 @@ public class ViewerPanel extends JPanel implements OverlayRenderer, TransformLis
viewerTransform.applyInverse( gPos, lPos );
}
/**
* TODO
* @param p
*/
public synchronized void getMouseCoordinates( final Positionable p )
{
assert p.numDimensions() == 2;
mouseCoordinates.getMouseCoordinates( p );
}
@Override
public void paint()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment