Skip to content

Commit

Permalink
Merge pull request micro-manager#33 from micro-manager/internal_reorg
Browse files Browse the repository at this point in the history
Internal refactor of NDViewer + fix contrast bugs
  • Loading branch information
henrypinkard authored Aug 1, 2023
2 parents 76481b7 + 30950db commit 6da0576
Show file tree
Hide file tree
Showing 19 changed files with 931 additions and 558 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.micro-manager.ndviewer</groupId>
<artifactId>NDViewer</artifactId>
<version>0.9.1</version>
<version>0.10.0</version>
<packaging>jar</packaging>
<name>NDViewer image viewer</name>
<description>Java-based multidimensional image viewer</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public interface NDViewerAPI {
* @param axisMins map of axis names to miniumum extents (can be negative)
* @param axisMaxs map of axis names to maximum extents
*/
@Deprecated
void initializeViewerToLoaded(List<String> channelNames,
JSONObject displaySettings,
HashMap<String, Object> axisMins,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
*/
public interface NDViewerDataSource {


/**
* Is the dataset still acquiring data/be written
*/
public boolean isFinished();

/**
* The minimal and maximal pixel coordinates of the image to be viewed
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private void addTextBox(String[] text, Overlay overlay) {

private Overlay createDefaultOverlay(DataViewCoords viewCoords) {
Overlay overlay = new Overlay();
if (display_.isImageXYBounded()) {
if (display_.getDataSource().getBounds() != null) {
drawZoomIndicator(overlay, viewCoords);
}
if (showScalebar_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.HashMap;

import org.micromanager.ndviewer.api.NDViewerDataSource;
import org.micromanager.ndviewer.main.NDViewer;

/**
*
Expand All @@ -23,16 +24,16 @@ public class DataViewCoords {
private double xView_, yView_; //top left pixel in full res coordinates
private HashMap<String, Object> axes_ = new HashMap<String, Object>();
private int resolutionIndex_;
private NDViewerDataSource cache_;
private NDViewerDataSource data_;
private boolean rgb_;
private boolean sourceDataWidthInitialized_ = false;

//Parameters that track what part of the dataset is being viewed
public int xMax_, yMax_, xMin_, yMin_;

public DataViewCoords(NDViewerDataSource cache, double xView, double yView,
public DataViewCoords(NDViewerDataSource data, double xView, double yView,
Double initialWidth, Double initialHeight, int[] imageBounds, boolean rgb) {
cache_ = cache;
data_ = data;
xView_ = 0;
yView_ = 0;
if (initialWidth == null) {
Expand Down Expand Up @@ -108,13 +109,15 @@ public double getMagnification() {

private void updateResIndex() {
double resIndexFloat = Math.log(sourceDataFullResWidth_ / (double) displayImageWidth_) / Math.log(2);
resolutionIndex_ = (int) Math.max(0, Math.ceil(resIndexFloat));
int newResIndex = (int) Math.max(0, Math.ceil(resIndexFloat));

// Let the storage know the viewer will be requesting data at this resolution
int currentMaxResIndex = cache_.getMaxResolutionIndex();
if (resolutionIndex_ > currentMaxResIndex) {
cache_.increaseMaxResolutionLevel(resolutionIndex_);
int currentMaxResIndex = data_.getMaxResolutionIndex();
if (newResIndex > currentMaxResIndex && !data_.isFinished()) {
// Try to increase max resolution level, though not guarenteed it will happen
data_.increaseMaxResolutionLevel(newResIndex);
}
resolutionIndex_ = Math.min(newResIndex, data_.getMaxResolutionIndex());
}

/**
Expand Down Expand Up @@ -158,7 +161,7 @@ public Object getAxisPosition(String axis) {
}

public DataViewCoords copy() {
DataViewCoords view = new DataViewCoords(cache_, xView_, yView_,
DataViewCoords view = new DataViewCoords(data_, xView_, yView_,
sourceDataFullResWidth_, sourceDataFullResHeight_, new int[]{xMin_, yMin_, xMax_, yMax_}, rgb_);
for (String axisName : axes_.keySet()) {
view.axes_.put(axisName, axes_.get(axisName));
Expand All @@ -174,17 +177,17 @@ public DataViewCoords copy() {
return view;
}

public String getActiveChannel() {
return axes_.get("channel") != null ? "" + axes_.get("channel") : "" ;
}
// public String getActiveChannel() {
// return axes_.get("channel") != null ? "" + axes_.get("channel") : "" ;
// }

public HashMap<String, Object> getAxesPositions() {
return axes_;
}

public void setActiveChannel(String channelName) {
axes_.put("channel", channelName);
}
// public void setActiveChannel(String channelName) {
// axes_.put(NDViewer.CHANNEL_AXIS, channelName);
// }

public int[] getBounds() {
return new int[]{xMin_, yMin_, xMax_, yMax_};
Expand Down
Loading

0 comments on commit 6da0576

Please sign in to comment.