Skip to content

Commit

Permalink
feat(UI): Add view mode icons
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Feb 2, 2018
1 parent dcb3a4d commit 16896b5
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/createViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ window.addEventListener('resize', proxyManager.resizeAllViews);

const createViewer = (
rootContainer,
{ viewerConfig, image, use2D, viewerState }
{ viewerConfig, image, use2D = false, viewerState }
) => {
userInterface.emptyContainer(rootContainer);

Expand Down Expand Up @@ -71,6 +71,7 @@ const createViewer = (
const uiContainer = userInterface.createMainUI(
rootContainer,
config.isBackgroundDark,
use2D,
imageSource,
view
);
Expand Down
17 changes: 17 additions & 0 deletions src/userInterface/ItkVtkImageViewer.mcss
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,23 @@
-webkit-filter: invert(100%);
}

.viewModeButton {
flex: 1;
height: 1.5em;
width: 1.5em;
padding-top: 6px;
padding-bottom: 2px;
padding-left: 6px;
padding-right: 6px;
cursor: pointer;
z-index: 1000;
}

.viewModeButton svg {
width: 1.3em;
height: 1.3em;
}

.shadowButton {
height: 1.3em;
width: 1.3em;
Expand Down
54 changes: 53 additions & 1 deletion src/userInterface/createMainUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ import style from './ItkVtkImageViewer.mcss';
import toggleIcon from './icons/toggle.svg';
import uploadIcon from './icons/upload.svg';
import screenshotIcon from './icons/screenshot.svg';
import volumeRenderingIcon from './icons/volume-rendering.svg';
import xPlaneIcon from './icons/x-plane.svg';
import yPlaneIcon from './icons/y-plane.svg';
import zPlaneIcon from './icons/z-plane.svg';

function createMainUI(rootContainer, isBackgroundDark, imageSource, view) {
function createMainUI(
rootContainer,
isBackgroundDark,
use2D,
imageSource,
view
) {
const uiContainer = document.createElement('div');
rootContainer.appendChild(uiContainer);
uiContainer.setAttribute('class', style.uiContainer);
Expand Down Expand Up @@ -77,6 +87,48 @@ function createMainUI(rootContainer, isBackgroundDark, imageSource, view) {
screenshotButton.addEventListener('click', takeScreenshot);
mainUIRow.appendChild(screenshotButton);

function setViewModeXPlane() {
view.setViewMode('XPlane');
}
function setViewModeYPlane() {
view.setViewMode('YPlane');
}
function setViewModeZPlane() {
view.setViewMode('ZPlane');
}
function setViewModeVolumeRendering() {
view.setViewMode('VolumeRendering');
}
if (!use2D) {
const xPlaneButton = document.createElement('div');
xPlaneButton.innerHTML = `<div class="${
style.viewModeButton
}">${xPlaneIcon}</div>`;
xPlaneButton.addEventListener('click', setViewModeXPlane);
mainUIRow.appendChild(xPlaneButton);

const yPlaneButton = document.createElement('div');
yPlaneButton.innerHTML = `<div class="${
style.viewModeButton
}">${yPlaneIcon}</div>`;
yPlaneButton.addEventListener('click', setViewModeYPlane);
mainUIRow.appendChild(yPlaneButton);

const zPlaneButton = document.createElement('div');
zPlaneButton.innerHTML = `<div class="${
style.viewModeButton
}">${zPlaneIcon}</div>`;
zPlaneButton.addEventListener('click', setViewModeZPlane);
mainUIRow.appendChild(zPlaneButton);

const volumeRenderingButton = document.createElement('div');
volumeRenderingButton.innerHTML = `<div class="${
style.viewModeButton
}">${volumeRenderingIcon}</div>`;
volumeRenderingButton.addEventListener('click', setViewModeVolumeRendering);
mainUIRow.appendChild(volumeRenderingButton);
}

uiContainer.appendChild(mainUIGroup);

return uiContainer;
Expand Down
3 changes: 3 additions & 0 deletions src/userInterface/icons/volume-rendering.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/userInterface/icons/x-plane.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/userInterface/icons/y-plane.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/userInterface/icons/z-plane.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 16896b5

Please sign in to comment.