Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation + imglib2-mesh + anti-aliasing #10

Merged
merged 45 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
731edfc
animation panel v1
ekatrukha Aug 7, 2024
77ed3d0
keyframe anim
ekatrukha Aug 9, 2024
e057289
keyframe anim v2
ekatrukha Aug 9, 2024
5bfe39e
animate clipbox
ekatrukha Aug 9, 2024
2ed1dd3
uncoil animation progress
ekatrukha Aug 13, 2024
ad76efc
test scifio
ekatrukha Aug 14, 2024
ceb62ec
test scifio
ekatrukha Aug 14, 2024
47f325d
scifio test 4D image save
ekatrukha Aug 14, 2024
1f3d803
uncoil progress
ekatrukha Aug 16, 2024
b5ed9fe
compression option
ekatrukha Aug 16, 2024
2c1bd85
check bit depth of template
ekatrukha Aug 16, 2024
e190660
uncoil dialog checks
ekatrukha Aug 16, 2024
0fa4f03
cleanup before full hdf5 test
ekatrukha Aug 20, 2024
ed03495
hdf5 export
ekatrukha Aug 20, 2024
8110227
hdf5 export cleanup
ekatrukha Aug 20, 2024
fe14f98
simpler hdf5 export
ekatrukha Aug 21, 2024
354756e
animation player
ekatrukha Aug 21, 2024
2733538
added animation player settings
ekatrukha Aug 22, 2024
1124272
update play slider toggle button
ekatrukha Aug 23, 2024
1460fd4
total animation time change dialog options
ekatrukha Aug 23, 2024
704a232
edit keyframe button
ekatrukha Aug 23, 2024
74fc4a0
render v1
ekatrukha Aug 23, 2024
edad52b
renderer update
ekatrukha Aug 29, 2024
b9f69da
load save storyline animation
ekatrukha Sep 12, 2024
abb4047
render window and AA lines attempt 1
ekatrukha Sep 16, 2024
ff30840
clean up
ekatrukha Sep 16, 2024
b69befc
aa_lines v2
ekatrukha Sep 16, 2024
834cf7b
aa lines box
ekatrukha Sep 16, 2024
634a634
aa lines clean up
ekatrukha Sep 16, 2024
20e4d3c
aa lines clean up
ekatrukha Sep 16, 2024
968409a
clip aa lines
ekatrukha Sep 16, 2024
2d10d27
aa lines for wire mode of ROIs
ekatrukha Sep 16, 2024
a59424f
cleanup aa lines
ekatrukha Sep 16, 2024
2c30cd3
added back sharp rendering
ekatrukha Sep 17, 2024
3601d3d
scene screen size independence implemented
ekatrukha Sep 17, 2024
39db193
render width height dialog
ekatrukha Sep 17, 2024
3954e92
render window size
ekatrukha Sep 18, 2024
e44d5d1
render window size
ekatrukha Sep 18, 2024
e230bd7
render frame index from one
ekatrukha Sep 18, 2024
8c6cee3
animation panel settings
ekatrukha Sep 18, 2024
730b1bd
renaming and credit for 3d AA lines
ekatrukha Sep 18, 2024
cf45ce2
fix uncoil anisotropic
ekatrukha Sep 18, 2024
fd9a083
scalebar option int the animation
ekatrukha Sep 19, 2024
96efce5
imagej 32bit read
ekatrukha Oct 2, 2024
a32ac46
v.0.5.0
ekatrukha Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<dependency>
<groupId>nl.uu.science.cellbiology</groupId>
<artifactId>bvv-playground</artifactId>
<version>0.2.1</version>
<version>0.2.6</version>
</dependency>

<!-- BIOFORMATS -->
Expand Down Expand Up @@ -180,14 +180,22 @@
<groupId>org.joml</groupId>
<artifactId>joml</artifactId>
</dependency>

<!-- BDV dependencies -->
<dependency>
<groupId>sc.fiji</groupId>
<artifactId>bigdataviewer-core</artifactId>
</dependency>
<dependency>
<groupId>sc.fiji</groupId>
<artifactId>bigdataviewer_fiji</artifactId>
</dependency>

<dependency>
<groupId>net.imagej</groupId>
<artifactId>ij</artifactId>
</dependency>

<dependency>
<groupId>gov.nist.math</groupId>
<artifactId>jama</artifactId>
Expand Down
153 changes: 120 additions & 33 deletions src/main/java/bigtrace/BigTrace.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.List;

import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

Expand Down Expand Up @@ -57,26 +56,29 @@
import bdv.viewer.ViewerState;

import btbvv.vistools.BvvFunctions;
import btbvv.vistools.BvvHandleFrame;
import btbvv.vistools.Bvv;
import btbvv.vistools.BvvStackSource;
import btbvv.core.render.RenderData;
import btbvv.core.render.VolumeRenderer.RepaintType;
import btbvv.btuitools.BvvGamma;
import btbvv.btuitools.GammaConverterSetup;
import btbvv.core.VolumeViewerFrame;
import btbvv.core.VolumeViewerPanel;
import btbvv.core.util.MatrixMath;

import bigtrace.animation.Scene;
import bigtrace.geometry.Cuboid3D;
import bigtrace.geometry.Intersections3D;
import bigtrace.geometry.Line3D;
import bigtrace.gui.AnisotropicTransformAnimator3D;
import bigtrace.gui.GuiMisc;
import bigtrace.math.OneClickTrace;
import bigtrace.math.TraceBoxMath;
import bigtrace.math.TracingBGVect;
import bigtrace.rois.Box3D;
import bigtrace.rois.LineTrace3D;
import bigtrace.rois.RoiManager3D;
import bigtrace.scene.VisPolyLineSimple;
import bigtrace.scene.VisPolyLineAA;
import bigtrace.volume.VolumeMisc;


Expand Down Expand Up @@ -108,12 +110,15 @@ public class BigTrace < T extends RealType< T > & NativeType< T > > implements P

/** Panel of BigVolumeViewer **/
public VolumeViewerPanel viewer;

/** Frame of BigVolumeViewer **/
public VolumeViewerFrame bvvFrame;

/** flag to check if user interface is frozen **/
public volatile boolean bInputLock = false;

/** visualization of coordinates origin axes **/
ArrayList<VisPolyLineSimple> originVis = new ArrayList<>();
ArrayList<VisPolyLineAA> originVis = new ArrayList<>();

/** box around volume **/
Box3D volumeBox;
Expand Down Expand Up @@ -263,8 +268,9 @@ public void initOriginAndBox(double axis_length)
basis.move((-1.0)*axis_length, i);
float [] color_orig = new float[3];
color_orig[i] = 1.0f;
originVis.add(new VisPolyLineSimple( point_coords, 3.0f,new Color(color_orig[0],color_orig[1],color_orig[2])));
originVis.add(new VisPolyLineAA( point_coords, 5.0f,new Color(color_orig[0],color_orig[1],color_orig[2])));
}

float [][] nDimBox = new float [2][3];

for(i=0;i<3;i++)
Expand All @@ -274,9 +280,12 @@ public void initOriginAndBox(double axis_length)
nDimBox[0][i]=btData.nDimIni[0][i]+0.5f;
nDimBox[1][i]=(btData.nDimIni[1][i]-1.0f);
}
volumeBox = new Box3D(nDimBox,0.5f,0.0f,Color.LIGHT_GRAY,Color.LIGHT_GRAY, 0);
clipBox = new Box3D(nDimBox,0.5f,0.0f,Color.LIGHT_GRAY,Color.LIGHT_GRAY, 0);
volumeBox = new Box3D(nDimBox,1.0f,0.0f,Color.WHITE,Color.WHITE, 0);

// volumeBox = new Box3D(nDimBox,1.0f,0.0f,Color.LIGHT_GRAY,Color.LIGHT_GRAY, 0);
clipBox = new Box3D(nDimBox,1.0f,0.0f,Color.LIGHT_GRAY,Color.LIGHT_GRAY, 0);
}

public void initSourcesCanvas(double origin_axis_length)
{

Expand All @@ -293,6 +302,7 @@ public void initSourcesCanvas(double origin_axis_length)

viewer = bvv_main.getBvvHandle().getViewerPanel();
viewer.setRenderScene(this::renderScene);

btActions = new BigTraceActions<>(this);
setInitialTransform();
viewer.addTimePointListener(this);
Expand All @@ -303,23 +313,27 @@ private void createAndShowGUI()
{
btPanel = new BigTraceControlPanel<>(this, btData,roiManager);
btPanel.finFrame = new JFrame("BigTrace");

btPanel.bvv_frame=(JFrame) SwingUtilities.getWindowAncestor(viewer);

btPanel.finFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
btPanel.bvv_frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);


bvvFrame = ((BvvHandleFrame)bvv_main.getBvvHandle()).getBigVolumeViewer().getViewerFrame();

bvvFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);


btPanel.finFrame.add(btPanel);

//Display the window.
btPanel.finFrame.setSize(400,600);
btPanel.finFrame.setVisible(true);
java.awt.Point bvv_p = btPanel.bvv_frame.getLocationOnScreen();
java.awt.Dimension bvv_d = btPanel.bvv_frame.getSize();
java.awt.Point bvv_p = bvvFrame.getLocationOnScreen();
java.awt.Dimension bvv_d = bvvFrame.getSize();

btPanel.finFrame.setLocation(bvv_p.x+bvv_d.width, bvv_p.y);
btPanel.finFrame.addWindowListener(this);
btPanel.bvv_frame.addWindowListener(this);
bvvFrame.addWindowListener(this);


bInputLock = false;
}

Expand Down Expand Up @@ -416,6 +430,20 @@ public IntervalView<T> getTraceInterval(boolean bClippedInterval)
return Views.interval(full_int, full_int);
}

public synchronized void setLockMode(boolean bLockMode)
{

boolean bState = !bLockMode;

GuiMisc.setPanelStatusAllComponents(roiManager, bState);
GuiMisc.setPanelStatusAllComponents(btPanel.roiMeasure, bState);
GuiMisc.setPanelStatusAllComponents(btPanel.btTracksPanel, bState);
GuiMisc.setPanelStatusAllComponents(btPanel.btAniPanel, bState);
btPanel.voxelSizePanel.allowVoxelSizeChange(bState);
btPanel.clipPanel.butExtractClipped.setEnabled( bState );
//keep it on
roiManager.butShowAll.setEnabled(true);
}
/** calculate optimal path **/
public void getSemiAutoTrace(RealPoint target)
{
Expand Down Expand Up @@ -659,7 +687,7 @@ public void removeTraceBox()
public void setTraceBoxMode(boolean bStatus)
{
bTraceMode = bStatus;
roiManager.setLockMode(bStatus);
setLockMode(bStatus);
//entering trace mode,
//let's save current view
if(bStatus)
Expand Down Expand Up @@ -710,6 +738,8 @@ public void renderScene(final GL3 gl, final RenderData data)
{
originVis.get(i).draw(gl, pvm);
}


}

//render a box around the volume
Expand Down Expand Up @@ -818,9 +848,43 @@ public void initBVVSourcesSpimData()
bvv_main = bvv_sources.get(0);
viewer = bvv_main.getBvvHandle().getViewerPanel();

//AffineTransform3D transformfin = new AffineTransform3D();
//translate all sources so they are at the zero
AffineTransform3D transformTranslation = new AffineTransform3D();
double [] shiftTR = new double [3];
for (int d=0;d<3;d++)
{
shiftTR[d]=Double.MAX_VALUE;
}

for ( SourceAndConverter< ? > source : viewer.state().getSources() )
{
AffineTransform3D transformSource = new AffineTransform3D();

for(int nTP=0;nTP<BigTraceData.nNumTimepoints;nTP++)
{
if(source.getSpimSource().isPresent( nTP ))
{
(( TransformedSource< ? > ) source.getSpimSource() ).getSourceTransform(nTP, 0, transformSource);

for(int d=0;d<3;d++)
{
if(transformSource.get(d, 3)<shiftTR[d])
{
shiftTR[d]=transformSource.get(d, 3);
}
}
}
}
}
for (int d=0;d<3;d++)
{
shiftTR[d]*=(-1);
}
transformTranslation.identity();
transformTranslation.translate(shiftTR);


// Remove voxel scale and any translation transforms for all sources.
// Remove voxel scale for all sources.
// We needed it, because later voxel size transform is applied to the general ViewerPanel.
for ( SourceAndConverter< ? > source : viewer.state().getSources() )
{
Expand All @@ -829,23 +893,15 @@ public void initBVVSourcesSpimData()
(( TransformedSource< ? > ) source.getSpimSource() ).getSourceTransform(0, 0, transformSource);

AffineTransform3D transformScale = new AffineTransform3D();
AffineTransform3D transformTranslation = new AffineTransform3D();
transformTranslation.identity();
double [] shiftTR = new double [3];

for(int j=0;j<3;j++)
{
//BigTraceData.globCal[j] = transformSource.get(j, j);
{
transformScale.set(1.0/BigTraceData.globCal[j], j, j);
shiftTR[j]= (-1.0)*transformSource.get(j, 3);
}
transformTranslation.identity();
transformTranslation.translate(shiftTR);
//AffineTransform3D transformFinal = transformScale.concatenate(transformTranslation);

AffineTransform3D transformFinal = transformScale.concatenate(transformTranslation);
(( TransformedSource< ? > ) source.getSpimSource() ).setFixedTransform(transformFinal);
// (( TransformedSource< ? > ) source.getSpimSource() ).setIncrementalTransform(transformFinal);

//(( TransformedSource< ? > ) source.getSpimSource() ).getSourceTransform(0, 0, transformfin);

}

if(bApplyLLSTransform)
Expand Down Expand Up @@ -1458,6 +1514,38 @@ public void timePointChanged(int timePointIndex)
}
}

/** get current scene (view transform + crop for now) **/
public Scene getCurrentScene()
{
final AffineTransform3D transform = new AffineTransform3D();
viewer.state().getViewerTransform(transform);
int canvasW = viewer.getWidth();
int canvasH = viewer.getHeight();
transform.set( transform.get( 0, 3 ) - canvasW / 2, 0, 3 );
transform.set( transform.get( 1, 3 ) - canvasH / 2, 1, 3 );
transform.scale( 1.0/ canvasW );

return new Scene(transform, BigTraceData.nDimCurr, btData.nCurrTimepoint);
}

public void setScene(final Scene scene)
{
final AffineTransform3D affine = new AffineTransform3D();
affine.set( scene.getViewerTransform());
int width = viewer.getWidth();
int height = viewer.getHeight();
affine.scale( width );
affine.set( affine.get( 0, 3 ) + width / 2, 0, 3 );
affine.set( affine.get( 1, 3 ) + height / 2, 1, 3 );
viewer.state().setViewerTransform( affine );
int nTimePoint = scene.getTimeFrame();
if(nTimePoint<BigTraceData.nNumTimepoints)
{
viewer.state().setCurrentTimepoint(nTimePoint);
}
btPanel.clipPanel.setBoundingBox( scene.getClipBox());
}


@Override
public void windowActivated(WindowEvent arg0) {
Expand Down Expand Up @@ -1504,9 +1592,8 @@ public void windowOpened(WindowEvent arg0) {

public void closeWindows()
{

viewer.stop();
btPanel.bvv_frame.dispose();
bvvFrame.dispose();
btPanel.finFrame.dispose();
}

Expand Down Expand Up @@ -1585,8 +1672,8 @@ public static void main(String... args) throws Exception

testI.run("");
//testI.run("/home/eugene/Desktop/projects/BigTrace/BigTrace_data/ExM_MT.tif");
//testI.run("/home/eugene/Desktop/projects/BigTrace/BT_tracks/Snejana_small_example.tif");

///testI.run("/home/eugene/Desktop/projects/BigTrace/BT_tracks/Snejana_small_example.tif");
//testI.run("/home/eugene/Desktop/bend/test_bend_2ch/output/trace1514947168.xml");

///macros test
// testI.run("/home/eugene/Desktop/projects/BigTrace/BigTrace_data/ExM_MT_8bit.tif");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/bigtrace/BigTraceActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void actionAddPoint()
}
}

bt.roiManager.setLockMode(true);
bt.setLockMode(true);
bt.runOneClickTrace(target, bMakeNewTrace);
break;
default:
Expand Down
Loading
Loading