Skip to content

Commit

Permalink
fix: better display for 2d sources
Browse files Browse the repository at this point in the history
  • Loading branch information
bogovicj committed Mar 10, 2022
1 parent 15c4ca9 commit 7fdfcca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
13 changes: 7 additions & 6 deletions src/main/java/bdv/viewer/BigWarpOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ public void paint( final Graphics2D g )
g.setColor( color );
g.setStroke( stroke );

double x = 0.0, y = 0.0, z = 0.0;
// spot = landmarkModel.getPoints( isMoving ).get( index );
landmarkModel.copyPointSafe(spot, index, isMoving);

// if the viewer is moving but transformed, render the points
Expand Down Expand Up @@ -176,15 +174,18 @@ public void paint( final Graphics2D g )

transform.apply( spot, viewerCoords );

// final double rad = radius * transformScale * radiusRatio;
final double rad = radius * radiusRatio;
final double zv = viewerCoords[ 2 ];
final double dz2 = zv * zv;

if ( dz2 < rad * rad )
if ( !is3d || dz2 < rad * rad )
{
final double arad = Math.sqrt( rad * rad - dz2 );

final double arad;
if( is3d )
arad = Math.sqrt( rad * rad - dz2 );
else
arad = rad;

// vary size
g.fillOval( ( int ) ( viewerCoords[ 0 ] - arad ),
( int ) ( viewerCoords[ 1 ] - arad ),
Expand Down
22 changes: 15 additions & 7 deletions src/main/java/bdv/viewer/BigWarpViewerPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import bdv.cache.CacheControl;
Expand All @@ -40,6 +41,7 @@
import bigwarp.util.Rotation2DHelpers;
import net.imglib2.RealPoint;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.realtransform.Translation3D;

public class BigWarpViewerPanel extends ViewerPanel
{
Expand Down Expand Up @@ -415,13 +417,19 @@ public synchronized void animateTransformation( final AffineTransform3D destinat
centerY = getHeight() / 2.0;
centerX = getWidth() / 2.0;
}

// TODO fixes to transform handlers mean the 3d animator works.
// 2d similar animator is still broken though.
// if( ndims == 2 )
// currentAnimator = new SimilarityTransformAnimator2D( startXfm, destinationXfm, centerX, centerY, millis );
// else
// currentAnimator = new SimilarityTransformAnimator3D( startXfm, destinationXfm, centerX, centerY, millis/2 );

if( ndims == 2 )
{
// if 2d, make sure the viewer transform change doesn't change the z-slice shown
final double[] tmp = new double[3];
startXfm.applyInverse(tmp, tmp);
final double zstart = tmp[2];

Arrays.fill(tmp, 0);
destinationXfm.applyInverse(tmp, tmp);
final Translation3D t = new Translation3D( 0, 0, (tmp[2] - zstart) );
destinationXfm.concatenate(t);
}

currentAnimator = new SimilarityTransformAnimator3D( startXfm, destinationXfm, centerX, centerY, millis/2 );

Expand Down

0 comments on commit 7fdfcca

Please sign in to comment.