use of org.scijava.vecmath.AxisAngle4d in project GDSC-SMLM by aherbert.
the class ImageJ3DResultsViewer method menuActionPerformed.
private void menuActionPerformed(ActionEvent event) {
final Object src = event.getSource();
ContentAction action = null;
// Adapted from univ.resetView()
if (src == resetRotation) {
univ.fireTransformationStarted();
// rotate so that y shows downwards
final Transform3D t = new Transform3D();
final AxisAngle4d aa = new AxisAngle4d(1, 0, 0, Math.PI);
t.set(aa);
univ.getRotationTG().setTransform(t);
univ.fireTransformationUpdated();
univ.fireTransformationFinished();
return;
}
if (src == resetTranslation) {
univ.fireTransformationStarted();
final Transform3D t = new Transform3D();
univ.getTranslateTG().setTransform(t);
univ.recalculateGlobalMinMax();
univ.getViewPlatformTransformer().centerAt(univ.getGlobalCenterPoint());
univ.fireTransformationUpdated();
univ.fireTransformationFinished();
return;
}
if (src == resetZoom) {
univ.fireTransformationStarted();
final Transform3D t = new Transform3D();
univ.getZoomTG().setTransform(t);
final Point3d max = new Point3d();
final Point3d min = new Point3d();
univ.getGlobalMaxPoint(max);
univ.getGlobalMinPoint(min);
final float range = (float) (max.x - min.x);
final double d = (range) / Math.tan(Math.PI / 8);
univ.getViewPlatformTransformer().zoomTo(d);
univ.fireTransformationUpdated();
univ.fireTransformationFinished();
return;
}
if (src == updateSettings) {
final ImageJ3DResultsViewerSettings.Builder settings = SettingsManager.readImageJ3DResultsViewerSettings(0).toBuilder();
final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
final ResultsSettings.Builder s = ResultsSettings.newBuilder();
ResultsTableSettings localResultsTableSettings = resultsTableSettings.get();
s.setResultsTableSettings(localResultsTableSettings);
gd.addMessage("Click on the image to view localisation data.\nCtrl/Alt key must be pressed.");
final TextField[] tf = new TextField[1];
gd.addStringField("Highlight_colour", settings.getHighlightColour(), new OptionListener<String>() {
@Override
public boolean collectOptions(String value) {
createHighlightColour(value);
int red;
int green;
int blue;
final Color3f color = highlightColor.get();
if (color == null) {
red = blue = 0;
green = 255;
} else {
red = (int) (color.x * 255);
green = (int) (color.y * 255);
blue = (int) (color.z * 255);
}
final ExtendedGenericDialog egd = new ExtendedGenericDialog("Highlight colour", null);
egd.addSlider("Red", 0, 255, red);
egd.addSlider("Green", 0, 255, green);
egd.addSlider("Blue", 0, 255, blue);
egd.showDialog(true, gd);
if (egd.wasCanceled()) {
return false;
}
red = (int) egd.getNextNumber();
green = (int) egd.getNextNumber();
blue = (int) egd.getNextNumber();
final Color c = new Color(red, green, blue);
final String cvalue = c.getRed() + "," + c.getGreen() + "," + c.getBlue();
tf[0].setText(cvalue);
return true;
}
@Override
public boolean collectOptions() {
return false;
}
});
tf[0] = gd.getLastTextField();
gd.addCheckbox("Add_to_selection", settings.getAddToSelection());
ResultsManager.addTableResultsOptions(gd, s, ResultsManager.FLAG_NO_SECTION_HEADER);
gd.addMessage("Allow the 'Find Eye Point' command to save to settings");
gd.addCheckbox("Save_eye_point", settings.getSaveEyePoint());
// Same as CropResults
gd.addChoice("Crop_name_option", CropResults.NAME_OPTIONS, settings.getNameOption(), new OptionListener<Integer>() {
@Override
public boolean collectOptions(Integer value) {
settings.setNameOption(value);
final ExtendedGenericDialog egd = new ExtendedGenericDialog(TITLE);
if (settings.getNameOption() == CropResults.NAME_OPTION_NAME) {
return false;
} else if (settings.getNameOption() == CropResults.NAME_OPTION_SUFFIX) {
final String name = (TextUtils.isNullOrEmpty(settings.getNameSuffix())) ? " Cropped" : settings.getNameSuffix();
egd.addStringField("Name_suffix", name, MathUtils.clip(20, 60, name.length()));
} else if (settings.getNameOption() == CropResults.NAME_OPTION_SEQUENCE) {
final String name = settings.getNameSuffix();
egd.addStringField("Name_suffix", name, MathUtils.clip(20, 60, name.length()));
int counter = settings.getNameCounter();
if (counter < 1) {
counter = 1;
}
egd.addNumericField("Name_counter", counter, 0);
} else {
throw new IllegalStateException("Unknown name option: " + settings.getNameOption());
}
egd.showDialog(true, gd);
if (egd.wasCanceled()) {
return false;
}
if (settings.getNameOption() == CropResults.NAME_OPTION_SUFFIX) {
settings.setNameSuffix(egd.getNextString());
} else if (settings.getNameOption() == CropResults.NAME_OPTION_SEQUENCE) {
settings.setNameSuffix(egd.getNextString());
settings.setNameCounter(Math.max(1, (int) egd.getNextNumber()));
}
return true;
}
@Override
public boolean collectOptions() {
return false;
}
});
gd.addCheckbox("Update_existing_tables", localResultsTableSettings.getUpdateExistingTables());
addHelp(gd);
gd.showDialog();
if (gd.wasCanceled()) {
return;
}
settings.setHighlightColour(gd.getNextString());
boolean add = gd.getNextBoolean();
addToSelection.set(add);
settings.setAddToSelection(add);
final ResultsTableSettings.Builder resultsTableSettingsBuilder = s.getResultsTableSettingsBuilder();
resultsTableSettingsBuilder.setShowTable(gd.getNextBoolean());
settings.setSaveEyePoint(gd.getNextBoolean());
settings.setNameOption(gd.getNextChoiceIndex());
resultsTableSettingsBuilder.setUpdateExistingTables(gd.getNextBoolean());
createHighlightColour(settings.getHighlightColour());
// Save updated settings
localResultsTableSettings = resultsTableSettingsBuilder.build();
settings.setResultsTableSettings(localResultsTableSettings);
SettingsManager.writeSettings(settings);
// Update the table settings for all the selection models
if (resultsTableSettingsBuilder.getUpdateExistingTables()) {
for (final Triple<PeakResultTableModel, ?, ?> t : resultsTables.values()) {
t.getLeft().setTableSettings(localResultsTableSettings);
}
}
action = new UpdateHighlightColourAction();
}
if (src == toggleDynamicTransparency) {
final long total = getTotalTransparentObjects(univ, "");
final View view = univ.getViewer().getView();
final boolean activate = view.getTransparencySortingPolicy() == View.TRANSPARENCY_SORT_NONE;
activateDynamicTransparency(univ, total, activate);
return;
}
// Actions to perform on content
if (src == changeColour) {
action = new ChangeColourContentAction();
} else if (src == resetAll) {
univ.resetView();
univ.select(null);
action = new ResetViewContentAction(false);
} else if (src == resetSelectedView) {
action = new ResetViewContentAction(true);
} else if (src == findEyePoint) {
action = new FindEyePointContentAction();
} else if (src == sortBackToFront) {
action = new SortContentAction(false);
} else if (src == sortFrontToBack) {
action = new SortContentAction(true);
} else if (src == colourSurface) {
action = new ColourSurfaceContentAction();
} else if (src == toggleTransparent) {
action = new ToggleTransparentAction();
} else if (src == toggleShaded) {
action = new ToggleShadedAction();
} else if (src == changePointSize) {
action = new ChangePointSizeContentAction();
} else if (src == increasePointSize) {
action = UpdatePointSizeContentAction.INCREASE;
} else if (src == decreasePointSize) {
action = UpdatePointSizeContentAction.DECREASE;
} else if (src == cropResults) {
action = new CropResultsAction();
} else if (src == showHelp) {
showHelp();
return;
}
if (action == null) {
return;
}
if (univ.getSelected() != null) {
action.run(univ.getSelected());
} else {
for (final Iterator<Content> it = univ.contents(); it.hasNext(); ) {
if (action.run(it.next()) < 0) {
break;
}
}
}
action.finish();
}
Aggregations