Skip to content

Commit

Permalink
Fix WEA-313 - Image without a spatial calibration should always show
Browse files Browse the repository at this point in the history
values in pixel unit
  • Loading branch information
nroduit committed Mar 17, 2015
1 parent 01ec362 commit ccfca21
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Expand Up @@ -217,17 +217,16 @@ public String getPixelSizeCalibrationDescription() {
}

public MeasurementsAdapter getMeasurementAdapter(Unit displayUnit) {
Unit unit;
double unitRatio;
if (displayUnit == null) {
unit = pixelSpacingUnit;
unitRatio = getPixelSize();
} else if (displayUnit.equals(Unit.PIXEL)) {
Unit unit = displayUnit;
if (unit == null || pixelSpacingUnit == null || pixelSpacingUnit.equals(Unit.PIXEL)) {
unit = Unit.PIXEL;
}

double unitRatio;
if (unit.equals(Unit.PIXEL)) {
unitRatio = 1.0;
} else {
unit = displayUnit;
unitRatio = getPixelSize() * displayUnit.getConversionRatio(pixelSpacingUnit.getConvFactor());
unitRatio = getPixelSize() * unit.getConversionRatio(pixelSpacingUnit.getConvFactor());
}
return new MeasurementsAdapter(unitRatio, 0, 0, false, 0, unit.getAbbreviation());
}
Expand Down
Expand Up @@ -528,6 +528,11 @@ protected void setImage(E img) {
imageLayer.setEnableDispOperations(false);
if (img == null) {
actionsInView.put(ActionW.SPATIAL_UNIT.cmd(), Unit.PIXEL);
ActionState spUnitAction = eventManager.getAction(ActionW.SPATIAL_UNIT);
if (spUnitAction instanceof ComboItemListener) {
((ComboItemListener) spUnitAction).setSelectedItemWithoutTriggerAction(actionsInView
.get(ActionW.SPATIAL_UNIT.cmd()));
}
// Force the update for null image
imageLayer.setEnableDispOperations(true);
imageLayer.setImage(null, null);
Expand All @@ -539,6 +544,11 @@ protected void setImage(E img) {
if (img != null && !img.equals(oldImage)) {
actionsInView.put(ActionW.SPATIAL_UNIT.cmd(), img.getPixelSpacingUnit());
actionsInView.put(ActionW.PREPROCESSING.cmd(), null);
ActionState spUnitAction = eventManager.getAction(ActionW.SPATIAL_UNIT);
if (spUnitAction instanceof ComboItemListener) {
((ComboItemListener) spUnitAction).setSelectedItemWithoutTriggerAction(actionsInView
.get(ActionW.SPATIAL_UNIT.cmd()));
}

final Rectangle modelArea = getImageBounds(img);
Rectangle2D area = getViewModel().getModelArea();
Expand All @@ -562,11 +572,6 @@ protected void setImage(E img) {
}
imageLayer.setImage(img, (OpManager) actionsInView.get(ActionW.PREPROCESSING.cmd()));

ActionState spUnitAction = eventManager.getAction(ActionW.SPATIAL_UNIT);
if (spUnitAction instanceof ComboItemListener) {
((ComboItemListener) spUnitAction).setSelectedItemWithoutTriggerAction(actionsInView
.get(ActionW.SPATIAL_UNIT.cmd()));
}
AbstractLayer layer = getLayerModel().getLayer(AbstractLayer.MEASURE);
if (layer != null) {
synchronized (this) {
Expand Down

0 comments on commit ccfca21

Please sign in to comment.