Skip to content

Commit

Permalink
fix(Layout2D): Update corner annotations when no active source exists
Browse files Browse the repository at this point in the history
Explicitly set the active representation to newRep even when newRep is
undefined/null. This allows other logic to tell if there even is an
active representation.
  • Loading branch information
floryst committed Feb 27, 2018
1 parent da47702 commit 8000044
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sources/layouts/Layout2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export default class Layout2D extends React.Component {
this.repSubscription = null;
}
if (newRep) {
this.activeRepresentation = newRep;
this.repSubscription = newRep.onModified(() => {
if (this.activeRepresentation && this.activeRepresentation.getSlice) {
this.slider.setValue(Number(this.activeRepresentation.getSlice()));
Expand All @@ -118,12 +117,20 @@ export default class Layout2D extends React.Component {
});
}

this.activeRepresentation = newRep;

if (this.activeRepresentation && this.activeRepresentation.getColorWindow) {
this.view.updateCornerAnnotation({
colorWindow: Math.round(this.activeRepresentation.getColorWindow()),
colorLevel: Math.round(this.activeRepresentation.getColorLevel()),
});
} else {
this.view.updateCornerAnnotation({
colorWindow: '(none)',
colorLevel: '(none)',
});
}

this.updateSlider();

// update slider visibility based on current active source/representation
Expand All @@ -144,6 +151,10 @@ export default class Layout2D extends React.Component {
this.view.updateCornerAnnotation({
slice: Number(this.activeRepresentation.getSlice()).toFixed(2),
});
} else {
this.view.updateCornerAnnotation({
slice: '(none)',
});
}
}

Expand Down

0 comments on commit 8000044

Please sign in to comment.