Added Standalone Client-only Viewer with build instructions
This commit is contained in:
1 parent
18de1deff3
commit
a5a6e3a6bd
52 files changed
+2793
-2
No files matched your search
@@ -0,0 +1,9 @@
|
||||
html
|
||||
width: 100%
|
||||
height: 100%
|
||||
|
||||
body
|
||||
width: 100%
|
||||
height: 100%
|
||||
overflow: hidden
|
||||
position: fixed
|
||||
@@ -0,0 +1,10 @@
|
||||
<template name="flexboxLayout">
|
||||
<div class="viewerSection">
|
||||
<div class="sidebarMenu sidebar-left {{#if leftSidebarOpen}}sidebar-open{{/if}}">
|
||||
{{> studyBrowser (clone this)}}
|
||||
</div>
|
||||
<div class="mainContent {{#if leftSidebarOpen}}sidebar-left-open{{/if}} {{#if rightSidebarOpen}}sidebar-right-open{{/if}}">
|
||||
{{> standaloneViewerMain (clone this)}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,19 @@
|
||||
Template.flexboxLayout.events({
|
||||
'transitionend .sidebarMenu'(event) {
|
||||
if (!event.target.classList.contains('sidebarMenu')) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleResize();
|
||||
}
|
||||
});
|
||||
|
||||
Template.flexboxLayout.helpers({
|
||||
leftSidebarOpen() {
|
||||
return Template.instance().data.state.get('leftSidebar');
|
||||
},
|
||||
|
||||
rightSidebarOpen() {
|
||||
return Template.instance().data.state.get('rightSidebar');
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,80 @@
|
||||
@import "{design}/app"
|
||||
|
||||
$lesionsSidebarMenuWidth = 450px
|
||||
|
||||
.viewerSection
|
||||
display: flex
|
||||
flex: 1
|
||||
flex-flow: row nowrap
|
||||
align-items: stretch
|
||||
height: 'calc(100% - %s)' % $toolbarHeight;
|
||||
width: 100%
|
||||
|
||||
.sidebarMenu
|
||||
height: 100%
|
||||
// required transformation to make inner fixed elements relative to this one
|
||||
transform(scale(1))
|
||||
transition($sidebarTransition)
|
||||
|
||||
.sidebar-option
|
||||
height: 100%
|
||||
position: fixed
|
||||
transform(translateX(100%))
|
||||
transition($sidebarTransition)
|
||||
width: 100%
|
||||
|
||||
&.active
|
||||
transform(translateX(0%))
|
||||
|
||||
.sidebar-left
|
||||
theme('border-right', '%s solid $uiBorderColor' % $uiBorderThickness)
|
||||
flex: 1
|
||||
margin-left: - $studiesSidebarMenuWidth
|
||||
max-width: $studiesSidebarMenuWidth
|
||||
order: 1
|
||||
|
||||
&.sidebar-open
|
||||
margin-left: 0
|
||||
|
||||
.mainContent
|
||||
flex: 1
|
||||
order: 2
|
||||
width: 100%
|
||||
height: 100%
|
||||
overflow: hidden
|
||||
transition($sidebarTransition)
|
||||
|
||||
.sidebar-right
|
||||
flex: 1
|
||||
margin-left: -6px
|
||||
margin-right: - $lesionsSidebarMenuWidth
|
||||
max-width: $lesionsSidebarMenuWidth
|
||||
order: 3
|
||||
padding-left: 6px
|
||||
position: relative
|
||||
|
||||
&[data-timepoints="3"]
|
||||
margin-right: - ($lesionsSidebarMenuWidth + 135.5px)
|
||||
max-width: $lesionsSidebarMenuWidth + 135.5px
|
||||
|
||||
&[data-timepoints="4"]
|
||||
margin-right: - ($lesionsSidebarMenuWidth + 270px)
|
||||
max-width: $lesionsSidebarMenuWidth + 270px
|
||||
|
||||
&:before
|
||||
theme('background-color', '$uiBorderColor')
|
||||
content: ''
|
||||
display: block
|
||||
height: 100%
|
||||
left: 5px
|
||||
position: absolute
|
||||
top: 0
|
||||
width: $uiBorderThickness
|
||||
|
||||
&.sidebar-open
|
||||
margin-right: 0
|
||||
|
||||
.studiesListedChanger
|
||||
theme('border-bottom', '%s solid $uiBorderColor' % $uiBorderThickness)
|
||||
padding: 20px 10px
|
||||
text-align: center
|
||||
@@ -0,0 +1,17 @@
|
||||
<template name="standaloneViewer">
|
||||
<div class="topBar noselect">
|
||||
<div class="clearfix p-x-1 p-t-1">
|
||||
<a target='_blank'
|
||||
class="brandSection pull-left"
|
||||
href="http://ohif.org">
|
||||
<svg class="logoImage">
|
||||
<use xlink:href="/packages/viewerbase/assets/icons.svg#icon-ohif-logo"></use>
|
||||
</svg>
|
||||
<div class="logoText">
|
||||
Open Health Imaging Foundation
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{> viewer }}
|
||||
</template>
|
||||
@@ -0,0 +1,6 @@
|
||||
// Define the ViewerData global object
|
||||
// If there is currently any Session data for this object,
|
||||
// use this to repopulate the variable
|
||||
Template.standaloneViewer.onCreated(() => {
|
||||
ViewerData = Session.get('ViewerData') || {};
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
@import "{design}/app"
|
||||
|
||||
$expandedHeight = 160px
|
||||
|
||||
.logoImage
|
||||
display: inline-block
|
||||
height: 100%
|
||||
float: left
|
||||
|
||||
.topBar
|
||||
height: $topBarHeight
|
||||
theme('color', '$textPrimaryColor')
|
||||
theme('background-color', '$primaryBackgroundColor')
|
||||
transition(all 0.5s ease)
|
||||
|
||||
.brandSection
|
||||
height: 30px
|
||||
display: inline-block
|
||||
text-decoration: none
|
||||
|
||||
.logoImage
|
||||
margin: 0 8px
|
||||
width: 30px
|
||||
|
||||
.logoText
|
||||
display: inline-block
|
||||
font-family: $logoFontFamily
|
||||
font-weight: $logoFontWeight
|
||||
theme('color', '$textPrimaryColor')
|
||||
line-height: 30px
|
||||
|
||||
.btn
|
||||
theme('color', '$textSecondaryColor')
|
||||
cursor: pointer
|
||||
font-size: 13px
|
||||
font-weight: 500
|
||||
line-height: 26px
|
||||
margin-top: 3px
|
||||
|
||||
&:hover
|
||||
theme('color', '$hoverColor')
|
||||
|
||||
&:active
|
||||
theme('color', '$activeColor')
|
||||
|
||||
&.studyList
|
||||
background-color: rgba(21, 25, 30, 0.7)
|
||||
height: $expandedHeight
|
||||
|
||||
.brandSection
|
||||
height: 100%
|
||||
width: 80%
|
||||
padding-left: 50px
|
||||
line-height: $expandedHeight
|
||||
|
||||
.logoImage
|
||||
width: 50px
|
||||
margin: 0 20px
|
||||
|
||||
.logoText
|
||||
font-size: 30px
|
||||
|
||||
#worklistTabs
|
||||
height: "calc(100% - %s)" % $topBarHeight
|
||||
|
||||
.tab-pane
|
||||
.viewerContainer
|
||||
.loadingTextDiv
|
||||
theme('color', '$textSecondaryColor')
|
||||
font-size: 30px
|
||||
@@ -0,0 +1,6 @@
|
||||
<template name="standaloneViewerMain">
|
||||
<div class="viewerMain">
|
||||
<div id='layoutManagerTarget'>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,31 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Template.standaloneViewerMain.onCreated(() => {
|
||||
// Attach the Window resize listener
|
||||
$(window).on('resize', handleResize);
|
||||
|
||||
// Create the synchronizer used to update reference lines
|
||||
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer('CornerstoneNewImage', cornerstoneTools.updateImageSynchronizer);
|
||||
});
|
||||
|
||||
Template.standaloneViewerMain.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
const studies = instance.data.studies;
|
||||
const parentElement = instance.$('#layoutManagerTarget').get(0);
|
||||
window.layoutManager = new LayoutManager(parentElement, studies);
|
||||
window.layoutManager.updateViewports();
|
||||
|
||||
// Enable hotkeys
|
||||
enableHotkeys();
|
||||
});
|
||||
|
||||
Template.standaloneViewerMain.onDestroyed(() => {
|
||||
// Remove the Window resize listener
|
||||
$(window).off('resize', handleResize);
|
||||
|
||||
// Destroy the synchronizer used to update reference lines
|
||||
OHIF.viewer.updateImageSynchronizer.destroy();
|
||||
|
||||
delete window.layoutManager;
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
@import "{design}/app"
|
||||
|
||||
.viewerMain
|
||||
width: 100%
|
||||
height: 100%
|
||||
|
||||
#layoutManagerTarget
|
||||
width: 100%
|
||||
height: 100%
|
||||
transition(all 0.3s ease)
|
||||
|
||||
#imageViewerViewports
|
||||
padding-right: 0 !important // Top remove odd borders from non-existant right Sidebar
|
||||
|
||||
.viewportContainer
|
||||
theme('border', '%s solid $uiBorderColorDark' % $viewportBorderThickness)
|
||||
float: left
|
||||
|
||||
outline: 0 // Prevent blue outline in Chrome
|
||||
|
||||
&:hover
|
||||
&.active
|
||||
&:hover.active
|
||||
outline: 0 // Prevent blue outline in Chrome
|
||||
|
||||
&:hover
|
||||
theme('border', '%s solid $uiBorderColor' % $viewportBorderThickness)
|
||||
|
||||
&.active, &:hover.active
|
||||
theme('border', '%s solid $uiBorderColorActive' % $viewportBorderThickness)
|
||||
|
||||
.removable
|
||||
width: 100%
|
||||
height: 100%
|
||||
position: relative // Necessary so that the viewportOverlay is on top of the viewports
|
||||
@@ -0,0 +1,12 @@
|
||||
<template name="toolbarSection">
|
||||
<div class="toolbarSection noselect p-x-2">
|
||||
<div class="clearfix">
|
||||
<div class="pull-left m-t-1">
|
||||
{{>roundedButtonGroup leftSidebarToggleButtonData}}
|
||||
</div>
|
||||
{{> toolbarSectionTools
|
||||
toolbarButtons=toolbarButtons
|
||||
extraToolbarButtons=extraToolbarButtons}}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,213 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Template.toolbarSection.helpers({
|
||||
leftSidebarToggleButtonData() {
|
||||
const instance = Template.instance();
|
||||
return {
|
||||
toggleable: true,
|
||||
key: 'leftSidebar',
|
||||
value: instance.data.state,
|
||||
options: [{
|
||||
value: 'studies',
|
||||
svgLink: '/packages/viewerbase/assets/icons.svg#icon-studies',
|
||||
svgWidth: 15,
|
||||
svgHeight: 13,
|
||||
bottomLabel: 'Series'
|
||||
}]
|
||||
};
|
||||
},
|
||||
|
||||
rightSidebarToggleButtonData() {
|
||||
const instance = Template.instance();
|
||||
return {
|
||||
toggleable: true,
|
||||
key: 'rightSidebar',
|
||||
value: instance.data.state,
|
||||
options: [{
|
||||
value: 'hangingprotocols',
|
||||
iconClasses: 'fa fa-cog',
|
||||
bottomLabel: 'Hanging'
|
||||
}]
|
||||
};
|
||||
},
|
||||
|
||||
toolbarButtons() {
|
||||
var buttonData = [];
|
||||
buttonData.push({
|
||||
id: 'zoom',
|
||||
title: 'Zoom',
|
||||
classes: 'imageViewerTool',
|
||||
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-zoom'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'wwwc',
|
||||
title: 'Levels',
|
||||
classes: 'imageViewerTool',
|
||||
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-levels'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'pan',
|
||||
title: 'Pan',
|
||||
classes: 'imageViewerTool',
|
||||
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-pan'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'length',
|
||||
title: 'Length',
|
||||
classes: 'imageViewerTool toolbarSectionButton',
|
||||
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-temp'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'annotate',
|
||||
title: 'Annotate',
|
||||
classes: 'imageViewerTool',
|
||||
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-non-target'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'angle',
|
||||
title: 'Angle',
|
||||
classes: 'imageViewerTool',
|
||||
iconClasses: 'fa fa-angle-left'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'resetViewport',
|
||||
title: 'Reset',
|
||||
classes: 'imageViewerCommand',
|
||||
iconClasses: 'fa fa-undo'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'toggleCinePlay',
|
||||
title: 'Toggle CINE Play',
|
||||
classes: 'imageViewerCommand',
|
||||
buttonTemplateName: 'playClipButton'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'toggleCineDialog',
|
||||
title: 'CINE',
|
||||
classes: 'imageViewerCommand',
|
||||
iconClasses: 'fa fa-youtube-play'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'layout',
|
||||
title: 'Layout',
|
||||
iconClasses: 'fa fa-th-large',
|
||||
buttonTemplateName: 'layoutButton'
|
||||
});
|
||||
|
||||
return buttonData;
|
||||
},
|
||||
|
||||
extraToolbarButtons() {
|
||||
let buttonData = [];
|
||||
|
||||
buttonData.push({
|
||||
id: 'stackScroll',
|
||||
title: 'Stack Scroll',
|
||||
classes: 'imageViewerTool',
|
||||
iconClasses: 'fa fa-bars'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'magnify',
|
||||
title: 'Magnify',
|
||||
classes: 'imageViewerTool toolbarSectionButton',
|
||||
iconClasses: 'fa fa-circle'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'wwwcRegion',
|
||||
title: 'ROI Window',
|
||||
classes: 'imageViewerTool',
|
||||
iconClasses: 'fa fa-square'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'dragProbe',
|
||||
title: 'Probe',
|
||||
classes: 'imageViewerTool',
|
||||
iconClasses: 'fa fa-dot-circle-o'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'ellipticalRoi',
|
||||
title: 'Ellipse',
|
||||
classes: 'imageViewerTool',
|
||||
iconClasses: 'fa fa-circle-o'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'rectangleRoi',
|
||||
title: 'Rectangle',
|
||||
classes: 'imageViewerTool',
|
||||
iconClasses: 'fa fa-square-o'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'invert',
|
||||
title: 'Invert',
|
||||
classes: 'imageViewerCommand',
|
||||
iconClasses: 'fa fa-adjust'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'clearTools',
|
||||
title: 'Clear',
|
||||
classes: 'imageViewerCommand',
|
||||
iconClasses: 'fa fa-trash'
|
||||
});
|
||||
|
||||
return buttonData;
|
||||
},
|
||||
|
||||
hangingProtocolButtons() {
|
||||
let buttonData = [];
|
||||
|
||||
buttonData.push({
|
||||
id: 'previousPresentationGroup',
|
||||
title: 'Prev. Stage',
|
||||
iconClasses: 'fa fa-step-backward',
|
||||
buttonTemplateName: 'previousPresentationGroupButton'
|
||||
});
|
||||
|
||||
buttonData.push({
|
||||
id: 'nextPresentationGroup',
|
||||
title: 'Next Stage',
|
||||
iconClasses: 'fa fa-step-forward',
|
||||
buttonTemplateName: 'nextPresentationGroupButton'
|
||||
});
|
||||
|
||||
return buttonData;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Template.toolbarSection.onRendered(function() {
|
||||
const instance = Template.instance();
|
||||
|
||||
instance.$('#layout').dropdown();
|
||||
|
||||
// Set disabled/enabled tool buttons that are set in toolManager
|
||||
const states = toolManager.getToolDefaultStates();
|
||||
const disabledToolButtons = states.disabledToolButtons;
|
||||
const allToolbarButtons = $('#toolbar').find('button');
|
||||
if (disabledToolButtons && disabledToolButtons.length > 0) {
|
||||
for (var i = 0; i < allToolbarButtons.length; i++) {
|
||||
const toolbarButton = allToolbarButtons[i];
|
||||
$(toolbarButton).prop('disabled', false);
|
||||
|
||||
const index = disabledToolButtons.indexOf($(toolbarButton).attr('id'));
|
||||
if (index !== -1) {
|
||||
$(toolbarButton).prop('disabled', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
@import "{design}/app"
|
||||
|
||||
.toolbarSection
|
||||
theme('border-bottom', '%s solid $uiBorderColor' % $uiBorderThickness)
|
||||
flex: 0 0 auto
|
||||
height: $toolbarHeight
|
||||
overflow: hidden
|
||||
padding-top: 6px
|
||||
position: relative
|
||||
transition(height 300ms ease)
|
||||
width: 100%
|
||||
|
||||
&.expanded
|
||||
height: $toolbarHeight + $toolbarDrawerHeight
|
||||
@@ -0,0 +1,15 @@
|
||||
<template name="viewer">
|
||||
{{#if Template.subscriptionsReady}}
|
||||
<div class="viewerDialogs">
|
||||
{{> cineDialog}}
|
||||
{{> layoutChooser }}
|
||||
{{> annotationDialogs }}
|
||||
</div>
|
||||
<div id="viewer">
|
||||
{{> toolbarSection (clone this)}}
|
||||
{{> flexboxLayout (clone this)}}
|
||||
</div>
|
||||
{{else}}
|
||||
{{> loadingText}}
|
||||
{{/if}}
|
||||
</template>
|
||||
@@ -0,0 +1,73 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
OHIF.viewer = OHIF.viewer || {};
|
||||
OHIF.viewer.loadIndicatorDelay = 500;
|
||||
OHIF.viewer.defaultTool = 'wwwc';
|
||||
OHIF.viewer.refLinesEnabled = true;
|
||||
OHIF.viewer.isPlaying = {};
|
||||
OHIF.viewer.cine = {
|
||||
framesPerSecond: 24,
|
||||
loop: true
|
||||
};
|
||||
|
||||
OHIF.viewer.functionList = {
|
||||
toggleCineDialog: toggleCineDialog,
|
||||
toggleCinePlay: toggleCinePlay,
|
||||
clearTools: clearTools,
|
||||
resetViewport: resetViewport,
|
||||
invert: invert
|
||||
};
|
||||
|
||||
Session.set('activeContentId', 'standalone');
|
||||
|
||||
Session.setDefault('activeViewport', false);
|
||||
Session.setDefault('leftSidebar', false);
|
||||
Session.setDefault('rightSidebar', false);
|
||||
|
||||
Template.viewer.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
instance.data.state = new ReactiveDict();
|
||||
instance.data.state.set('leftSidebar', Session.get('leftSidebar'));
|
||||
instance.data.state.set('rightSidebar', Session.get('rightSidebar'));
|
||||
|
||||
const contentId = instance.data.contentId;
|
||||
|
||||
if (ViewerData[contentId] && ViewerData[contentId].loadedSeriesData) {
|
||||
log.info('Reloading previous loadedSeriesData');
|
||||
OHIF.viewer.loadedSeriesData = ViewerData[contentId].loadedSeriesData;
|
||||
} else {
|
||||
log.info('Setting default ViewerData');
|
||||
OHIF.viewer.loadedSeriesData = {};
|
||||
ViewerData[contentId] = {};
|
||||
ViewerData[contentId].loadedSeriesData = OHIF.viewer.loadedSeriesData;
|
||||
|
||||
// Update the viewer data object
|
||||
ViewerData[contentId].viewportColumns = 1;
|
||||
ViewerData[contentId].viewportRows = 1;
|
||||
ViewerData[contentId].activeViewport = 0;
|
||||
}
|
||||
|
||||
Session.set('activeViewport', ViewerData[contentId].activeViewport || 0);
|
||||
|
||||
// Update the ViewerStudies collection with the loaded studies
|
||||
ViewerStudies.remove({});
|
||||
|
||||
ViewerData[contentId].studyInstanceUids = [];
|
||||
instance.data.studies.forEach(study => {
|
||||
study.selected = true;
|
||||
study.displaySets = createStacks(study);
|
||||
ViewerStudies.insert(study);
|
||||
ViewerData[contentId].studyInstanceUids.push(study.studyInstanceUid);
|
||||
});
|
||||
|
||||
Session.set('ViewerData', ViewerData);
|
||||
});
|
||||
|
||||
Template.viewer.events({
|
||||
'click .js-toggle-studies'() {
|
||||
const instance = Template.instance();
|
||||
const current = instance.data.state.get('leftSidebar');
|
||||
instance.data.state.set('leftSidebar', !current);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
@import "{design}/app"
|
||||
|
||||
#viewer
|
||||
background-color: black
|
||||
height: "calc(100% - %s)" % $topBarHeight
|
||||
width: 100%
|
||||
|
||||
.loadingTextDiv
|
||||
theme('color', '$textSecondaryColor')
|
||||
font-size: 30px
|
||||
@@ -0,0 +1,164 @@
|
||||
/*! cornerstoneWebImageLoader - v0.6.0 - 2016-02-09 | (c) 2015 Chris Hafey | https://github.com/chafey/cornerstoneWebImageLoader */
|
||||
cornerstoneWebImageLoader = {};
|
||||
//
|
||||
// This is a cornerstone image loader for web images such as PNG and JPEG
|
||||
//
|
||||
|
||||
(function ($, cornerstone, cornerstoneWebImageLoader) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
var lastImageIdDrawn = "";
|
||||
|
||||
|
||||
var options = {
|
||||
// callback allowing customization of the xhr (e.g. adding custom auth headers, cors, etc)
|
||||
beforeSend : function(xhr) {}
|
||||
};
|
||||
|
||||
function createImageObject(image, imageId)
|
||||
{
|
||||
// extract the attributes we need
|
||||
var rows = image.naturalHeight;
|
||||
var columns = image.naturalWidth;
|
||||
|
||||
function getPixelData()
|
||||
{
|
||||
var imageData = getImageData();
|
||||
var imageDataData = imageData.data;
|
||||
var numPixels = image.naturalHeight * image.naturalWidth;
|
||||
var storedPixelData = new Uint8Array(numPixels * 4);
|
||||
var imageDataIndex = 0;
|
||||
var storedPixelDataIndex = 0;
|
||||
for(var i=0; i < numPixels; i++) {
|
||||
storedPixelData[storedPixelDataIndex++] = imageDataData[imageDataIndex++];
|
||||
storedPixelData[storedPixelDataIndex++] = imageDataData[imageDataIndex++];
|
||||
storedPixelData[storedPixelDataIndex++] = imageDataData[imageDataIndex++];
|
||||
storedPixelData[storedPixelDataIndex++] = 255; // alpha
|
||||
imageDataIndex++;
|
||||
}
|
||||
return storedPixelData;
|
||||
}
|
||||
|
||||
function getImageData()
|
||||
{
|
||||
var context;
|
||||
if(lastImageIdDrawn !== imageId) {
|
||||
canvas.height = image.naturalHeight;
|
||||
canvas.width = image.naturalWidth;
|
||||
context = canvas.getContext('2d');
|
||||
context.drawImage(image, 0, 0);
|
||||
lastImageIdDrawn = imageId;
|
||||
}
|
||||
else {
|
||||
context = canvas.getContext('2d');
|
||||
}
|
||||
return context.getImageData(0, 0, image.naturalWidth, image.naturalHeight);
|
||||
}
|
||||
|
||||
function getCanvas()
|
||||
{
|
||||
if(lastImageIdDrawn === imageId) {
|
||||
return canvas;
|
||||
}
|
||||
|
||||
canvas.height = image.naturalHeight;
|
||||
canvas.width = image.naturalWidth;
|
||||
var context = canvas.getContext('2d');
|
||||
context.drawImage(image, 0, 0);
|
||||
lastImageIdDrawn = imageId;
|
||||
return canvas;
|
||||
}
|
||||
|
||||
function getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
// Extract the various attributes we need
|
||||
return {
|
||||
imageId : imageId,
|
||||
minPixelValue : 0, // calculated below
|
||||
maxPixelValue : 255, // calculated below
|
||||
slope: 1.0,
|
||||
intercept: 0,
|
||||
windowCenter : 128,
|
||||
windowWidth : 255,
|
||||
render: cornerstone.renderColorImage,
|
||||
getPixelData: getPixelData,
|
||||
getImageData: getImageData,
|
||||
getCanvas: getCanvas,
|
||||
getImage: getImage,
|
||||
//storedPixelData: extractStoredPixels(image),
|
||||
rows: rows,
|
||||
columns: columns,
|
||||
height: rows,
|
||||
width: columns,
|
||||
color: true,
|
||||
columnPixelSpacing: undefined,
|
||||
rowPixelSpacing: undefined,
|
||||
invert: false,
|
||||
sizeInBytes : rows * columns * 4 // we don't know for sure so we over estimate to be safe
|
||||
};
|
||||
}
|
||||
|
||||
// Loads an image given a url to an image
|
||||
function loadImage(imageId) {
|
||||
|
||||
// create a deferred object
|
||||
var deferred = $.Deferred();
|
||||
|
||||
var image = new Image();
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", imageId, true);
|
||||
xhr.responseType = "arraybuffer";
|
||||
options.beforeSend(xhr);
|
||||
xhr.onload = function() {
|
||||
var arrayBufferView = new Uint8Array(this.response);
|
||||
var blob = new Blob([arrayBufferView], {type: "image/jpeg"});
|
||||
var urlCreator = window.URL || window.webkitURL;
|
||||
var imageUrl = urlCreator.createObjectURL(blob);
|
||||
image.src = imageUrl;
|
||||
image.onload = function() {
|
||||
var imageObject = createImageObject(image, imageId);
|
||||
deferred.resolve(imageObject);
|
||||
urlCreator.revokeObjectURL(imageUrl);
|
||||
};
|
||||
image.onerror = function() {
|
||||
urlCreator.revokeObjectURL(imageUrl);
|
||||
deferred.reject();
|
||||
};
|
||||
};
|
||||
xhr.onprogress = function(oProgress) {
|
||||
|
||||
if (oProgress.lengthComputable) { //evt.loaded the bytes browser receive
|
||||
//evt.total the total bytes seted by the header
|
||||
//
|
||||
var loaded = oProgress.loaded;
|
||||
var total = oProgress.total;
|
||||
var percentComplete = Math.round((loaded / total)*100);
|
||||
|
||||
$(cornerstone).trigger('CornerstoneImageLoadProgress', {
|
||||
imageId: imageId,
|
||||
loaded: loaded,
|
||||
total: total,
|
||||
percentComplete: percentComplete
|
||||
});
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
function configure(opts) {
|
||||
options = opts;
|
||||
}
|
||||
|
||||
// steam the http and https prefixes so we can use standard web urls directly
|
||||
cornerstone.registerImageLoader('http', loadImage);
|
||||
cornerstone.registerImageLoader('https', loadImage);
|
||||
cornerstoneWebImageLoader.configure = configure;
|
||||
return cornerstone;
|
||||
}($, cornerstone, cornerstoneWebImageLoader));
|
||||
@@ -0,0 +1,14 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OHIF DICOM Viewer</title>
|
||||
<meta name="description" content="OHIF DICOM Viewer">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1,maximum-scale=1,user-scalable=no">
|
||||
<!--Best display for mobile devices-->
|
||||
<meta http-equiv="cleartype" content="on">
|
||||
<meta name="MobileOptimized" content="320">
|
||||
<meta name="HandheldFriendly" content="True">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
|
||||
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
|
||||
<link href='http://fonts.googleapis.com/css?family=Sanchez:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
|
||||
</head>
|
||||
@@ -0,0 +1,3 @@
|
||||
// Create application logger using loglevel
|
||||
// https://atmospherejs.com/spacejamio/loglevel
|
||||
log = loglevel.createAppLogger('StandaloneViewer', defaultLevel = 'info');
|
||||
Reference in new issue
Block a user