Skip to content

Commit f0b2815

Browse files
feat: Add bottom/right orientation markers (#120)
1 parent 52703b9 commit f0b2815

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

src/CornerstoneViewport/CornerstoneViewport.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class CornerstoneViewport extends Component {
8181
style: PropTypes.object,
8282
className: PropTypes.string,
8383
isOverlayVisible: PropTypes.bool,
84+
orientationMarkers: PropTypes.arrayOf(PropTypes.string),
8485
};
8586

8687
static defaultProps = {
@@ -101,6 +102,7 @@ class CornerstoneViewport extends Component {
101102
resizeRefreshMode: 'debounce',
102103
tools: [],
103104
onNewImageDebounceTime: 0,
105+
orientationMarkers: ['top', 'left'],
104106
};
105107

106108
constructor(props) {
@@ -375,7 +377,7 @@ class CornerstoneViewport extends Component {
375377
* @memberof CornerstoneViewport
376378
*/
377379
getOrientationMarkersOverlay() {
378-
const { imageIds } = this.props;
380+
const { imageIds, orientationMarkers } = this.props;
379381
const {
380382
imageIdIndex,
381383
rotationDegrees,
@@ -403,6 +405,7 @@ class CornerstoneViewport extends Component {
403405
rotationDegrees={rotationDegrees}
404406
isFlippedVertically={isFlippedVertically}
405407
isFlippedHorizontally={isFlippedHorizontally}
408+
orientationMarkers={orientationMarkers}
406409
/>
407410
);
408411
}

src/ViewportOrientationMarkers/ViewportOrientationMarkers.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@
1515
top: 47%;
1616
left: 5px;
1717
}
18+
19+
.ViewportOrientationMarkers .right-mid {
20+
top: 47%;
21+
left: 97%;
22+
}
23+
24+
.ViewportOrientationMarkers .bottom-mid {
25+
top: 97%;
26+
left: 47%;
27+
}

src/ViewportOrientationMarkers/ViewportOrientationMarkers.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@ function getOrientationMarkers(
3535
const markers = {
3636
top: oppositeColumnString,
3737
left: oppositeRowString,
38+
right: rowString,
39+
bottom: columnString,
3840
};
3941

4042
// If any vertical or horizontal flips are applied, change the orientation strings ahead of
4143
// the rotation applications
4244
if (isFlippedVertically) {
4345
markers.top = invertOrientationString(markers.top);
46+
markers.bottom = invertOrientationString(markers.bottom);
4447
}
4548

4649
if (isFlippedHorizontally) {
4750
markers.left = invertOrientationString(markers.left);
51+
markers.right = invertOrientationString(markers.right);
4852
}
4953

5054
// Swap the labels accordingly if the viewport has been rotated
@@ -53,16 +57,22 @@ function getOrientationMarkers(
5357
return {
5458
top: markers.left,
5559
left: invertOrientationString(markers.top),
60+
right: invertOrientationString(markers.bottom),
61+
bottom: markers.right, // left
5662
};
5763
} else if (rotationDegrees === -90 || rotationDegrees === 270) {
5864
return {
5965
top: invertOrientationString(markers.left),
6066
left: markers.top,
67+
bottom: markers.left,
68+
right: markers.bottom,
6169
};
6270
} else if (rotationDegrees === 180 || rotationDegrees === -180) {
6371
return {
6472
top: invertOrientationString(markers.top),
6573
left: invertOrientationString(markers.left),
74+
bottom: invertOrientationString(markers.bottom),
75+
right: invertOrientationString(markers.right),
6676
};
6777
}
6878

@@ -76,6 +86,11 @@ class ViewportOrientationMarkers extends PureComponent {
7686
rotationDegrees: PropTypes.number.isRequired,
7787
isFlippedVertically: PropTypes.bool.isRequired,
7888
isFlippedHorizontally: PropTypes.bool.isRequired,
89+
orientationMarkers: PropTypes.arrayOf(PropTypes.string),
90+
};
91+
92+
static defaultProps = {
93+
orientationMarkers: ['top', 'left'],
7994
};
8095

8196
render() {
@@ -85,6 +100,7 @@ class ViewportOrientationMarkers extends PureComponent {
85100
rotationDegrees,
86101
isFlippedVertically,
87102
isFlippedHorizontally,
103+
orientationMarkers,
88104
} = this.props;
89105

90106
if (!rowCosines || !columnCosines) {
@@ -99,10 +115,19 @@ class ViewportOrientationMarkers extends PureComponent {
99115
isFlippedHorizontally
100116
);
101117

118+
const getMarkers = orientationMarkers =>
119+
orientationMarkers.map((m, index) => (
120+
<div
121+
className={`${m}-mid orientation-marker`}
122+
key={`${m}-mid orientation-marker`}
123+
>
124+
{markers[m]}
125+
</div>
126+
));
127+
102128
return (
103129
<div className="ViewportOrientationMarkers noselect">
104-
<div className="top-mid orientation-marker">{markers.top}</div>
105-
<div className="left-mid orientation-marker">{markers.left}</div>
130+
{getMarkers(orientationMarkers)}
106131
</div>
107132
);
108133
}

0 commit comments

Comments
 (0)