Skip to content

Commit

Permalink
Merge pull request #52 from Kitware/cornerstone_integration
Browse files Browse the repository at this point in the history
Cornerstone integration
  • Loading branch information
floryst authored May 9, 2018
2 parents 55fefa4 + fd0fd00 commit 26c42dc
Show file tree
Hide file tree
Showing 38 changed files with 2,278 additions and 186 deletions.
1 change: 1 addition & 0 deletions Distribution/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<script inline type="text/javascript" src="glance.js"></script>
<script type="text/javascript" src="glance-external-ITKReader.js"></script>
<script type="text/javascript" src="glance-external-Workbox.js"></script>
<script type="text/javascript" src="glance-external-MedicalCornerstone.js"></script>
<script type="text/javascript">
const container = document.querySelector('.root-container');
const viewer = Glance.createViewer(container);
Expand Down
5 changes: 3 additions & 2 deletions Sources/MainView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import PropTypes from 'prop-types';
import { ToastContainer, Slide } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

import Configs from './config';
import UI from './ui';
import Layouts from './layouts';
import LayoutConfig from './config/glanceLayoutConfig';
import style from './pv-explorer.mcss';
import icons from './icons';

Expand Down Expand Up @@ -114,7 +114,7 @@ export default class MainView extends React.Component {
<LayoutGrid
proxyManager={this.props.proxyManager}
className={style.content}
initialConfig={LayoutConfig}
initialConfig={Configs[this.props.mode].Layout}
layout={this.state.layout}
/>
</div>
Expand Down Expand Up @@ -143,6 +143,7 @@ export default class MainView extends React.Component {
}

MainView.propTypes = {
mode: PropTypes.string.isRequired,
remoteControl: PropTypes.object.isRequired,
proxyManager: PropTypes.object.isRequired,
};
Expand Down
144 changes: 5 additions & 139 deletions Sources/config/Generic/index.js
Original file line number Diff line number Diff line change
@@ -1,142 +1,8 @@
import vtk2DView from 'vtk.js/Sources/Proxy/Core/View2DProxy';
import vtkGeometryRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/GeometryRepresentationProxy';
import vtkSkyboxRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/SkyboxRepresentationProxy';
import vtkGlyphRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/GlyphRepresentationProxy';
import vtkLookupTableProxy from 'vtk.js/Sources/Proxy/Core/LookupTableProxy';
import vtkMoleculeRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/MoleculeRepresentationProxy';
import vtkPiecewiseFunctionProxy from 'vtk.js/Sources/Proxy/Core/PiecewiseFunctionProxy';
import vtkProxySource from 'vtk.js/Sources/Proxy/Core/SourceProxy';
import vtkSliceRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/SliceRepresentationProxy';
import vtkView from 'vtk.js/Sources/Proxy/Core/ViewProxy';
import vtkVolumeRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/VolumeRepresentationProxy';
import Layout from './layout';
import Proxy from './proxy';

import ConfigUtils from '../configUtils';

import proxyUI from './proxyUI';
import proxyFilter from './proxyFilter';
import proxyViewRepresentationMapping from './proxyViewRepresentationMapping';

const { createProxyDefinition, activateOnCreate } = ConfigUtils;

function createDefaultView(classFactory, ui) {
return activateOnCreate(
createProxyDefinition(classFactory, ui, [
{
type: 'application',
link: 'AnnotationOpacity',
property: 'annotationOpacity',
},
{
type: 'application',
link: 'OrientationAxesVisibility',
property: 'orientationAxesVisibility',
},
{
type: 'application',
link: 'OrientationAxesPreset',
property: 'presetToOrientationAxes',
},
])
);
}

// ----------------------------------------------------------------------------
export default {
name: 'Generic',
definitions: {
Proxy: {
LookupTable: createProxyDefinition(vtkLookupTableProxy),
PiecewiseFunction: createProxyDefinition(vtkPiecewiseFunctionProxy),
},
Sources: {
TrivialProducer: createProxyDefinition(vtkProxySource),
Contour: proxyFilter.Contour,
},
Representations: {
Geometry: createProxyDefinition(
vtkGeometryRepresentationProxy,
proxyUI.Geometry
),
Skybox: createProxyDefinition(
vtkSkyboxRepresentationProxy,
proxyUI.Skybox
),
Slice: createProxyDefinition(vtkSliceRepresentationProxy, proxyUI.Slice, [
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
]),
SliceX: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
[
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
{ link: 'SliceX', property: 'slice' },
]
),
SliceY: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
[
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
{ link: 'SliceY', property: 'slice' },
]
),
SliceZ: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
[
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
{ link: 'SliceZ', property: 'slice' },
]
),
Volume: createProxyDefinition(
vtkVolumeRepresentationProxy,
proxyUI.Volume,
[
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
{ link: 'SliceX', property: 'xSlice' },
{ link: 'SliceY', property: 'ySlice' },
{ link: 'SliceZ', property: 'zSlice' },
{ link: 'Shadow', property: 'useShadow' },
{ link: 'SampleDistance', property: 'sampleDistance' },
{ link: 'EdgeGradient', property: 'edgeGradient' },
]
),
Molecule: createProxyDefinition(
vtkMoleculeRepresentationProxy,
proxyUI.Molecule
),
Glyph: createProxyDefinition(vtkGlyphRepresentationProxy, proxyUI.Glyph),
},
Views: {
View3D: createDefaultView(vtkView, proxyUI.View3D),
View2D: createDefaultView(vtk2DView, proxyUI.View2D),
View2D_X: createDefaultView(vtk2DView, proxyUI.View2D),
View2D_Y: createDefaultView(vtk2DView, proxyUI.View2D),
View2D_Z: createDefaultView(vtk2DView, proxyUI.View2D),
},
},
representations: {
View3D: proxyViewRepresentationMapping.View3D,
View2D: proxyViewRepresentationMapping.View2D,
View2D_X: Object.assign({}, proxyViewRepresentationMapping.View2D, {
vtkImageData: { name: 'SliceX' },
}),
View2D_Y: Object.assign({}, proxyViewRepresentationMapping.View2D, {
vtkImageData: { name: 'SliceY' },
}),
View2D_Z: Object.assign({}, proxyViewRepresentationMapping.View2D, {
vtkImageData: { name: 'SliceZ' },
}),
},
filters: {
vtkPolyData: [],
vtkImageData: ['Contour'],
vtkMolecule: [],
Glyph: [],
},
Name: 'Generic',
Layout,
Proxy,
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Layout2D from '../layouts/Layout2D';
import Layout3D from '../layouts/Layout3D';
import Layout2D from '../../layouts/Layout2D';
import Layout3D from '../../layouts/Layout3D';

export default {
layouts: {
Expand Down
141 changes: 141 additions & 0 deletions Sources/config/Generic/proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import vtk2DView from 'vtk.js/Sources/Proxy/Core/View2DProxy';
import vtkGeometryRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/GeometryRepresentationProxy';
import vtkSkyboxRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/SkyboxRepresentationProxy';
import vtkGlyphRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/GlyphRepresentationProxy';
import vtkLookupTableProxy from 'vtk.js/Sources/Proxy/Core/LookupTableProxy';
import vtkMoleculeRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/MoleculeRepresentationProxy';
import vtkPiecewiseFunctionProxy from 'vtk.js/Sources/Proxy/Core/PiecewiseFunctionProxy';
import vtkProxySource from 'vtk.js/Sources/Proxy/Core/SourceProxy';
import vtkSliceRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/SliceRepresentationProxy';
import vtkView from 'vtk.js/Sources/Proxy/Core/ViewProxy';
import vtkVolumeRepresentationProxy from 'vtk.js/Sources/Proxy/Representations/VolumeRepresentationProxy';

import ConfigUtils from '../configUtils';

import proxyUI from './proxyUI';
import proxyFilter from './proxyFilter';
import proxyViewRepresentationMapping from './proxyViewRepresentationMapping';

const { createProxyDefinition, activateOnCreate } = ConfigUtils;

function createDefaultView(classFactory, ui) {
return activateOnCreate(
createProxyDefinition(classFactory, ui, [
{
type: 'application',
link: 'AnnotationOpacity',
property: 'annotationOpacity',
},
{
type: 'application',
link: 'OrientationAxesVisibility',
property: 'orientationAxesVisibility',
},
{
type: 'application',
link: 'OrientationAxesPreset',
property: 'presetToOrientationAxes',
},
])
);
}

// ----------------------------------------------------------------------------
export default {
definitions: {
Proxy: {
LookupTable: createProxyDefinition(vtkLookupTableProxy),
PiecewiseFunction: createProxyDefinition(vtkPiecewiseFunctionProxy),
},
Sources: {
TrivialProducer: createProxyDefinition(vtkProxySource),
Contour: proxyFilter.Contour,
},
Representations: {
Geometry: createProxyDefinition(
vtkGeometryRepresentationProxy,
proxyUI.Geometry
),
Skybox: createProxyDefinition(
vtkSkyboxRepresentationProxy,
proxyUI.Skybox
),
Slice: createProxyDefinition(vtkSliceRepresentationProxy, proxyUI.Slice, [
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
]),
SliceX: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
[
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
{ link: 'SliceX', property: 'slice' },
]
),
SliceY: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
[
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
{ link: 'SliceY', property: 'slice' },
]
),
SliceZ: createProxyDefinition(
vtkSliceRepresentationProxy,
proxyUI.Slice,
[
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
{ link: 'SliceZ', property: 'slice' },
]
),
Volume: createProxyDefinition(
vtkVolumeRepresentationProxy,
proxyUI.Volume,
[
{ link: 'ColorWindow', property: 'colorWindow' },
{ link: 'ColorLevel', property: 'colorLevel' },
{ link: 'SliceX', property: 'xSlice' },
{ link: 'SliceY', property: 'ySlice' },
{ link: 'SliceZ', property: 'zSlice' },
{ link: 'Shadow', property: 'useShadow' },
{ link: 'SampleDistance', property: 'sampleDistance' },
{ link: 'EdgeGradient', property: 'edgeGradient' },
]
),
Molecule: createProxyDefinition(
vtkMoleculeRepresentationProxy,
proxyUI.Molecule
),
Glyph: createProxyDefinition(vtkGlyphRepresentationProxy, proxyUI.Glyph),
},
Views: {
View3D: createDefaultView(vtkView, proxyUI.View3D),
View2D: createDefaultView(vtk2DView, proxyUI.View2D),
View2D_X: createDefaultView(vtk2DView, proxyUI.View2D),
View2D_Y: createDefaultView(vtk2DView, proxyUI.View2D),
View2D_Z: createDefaultView(vtk2DView, proxyUI.View2D),
},
},
representations: {
View3D: proxyViewRepresentationMapping.View3D,
View2D: proxyViewRepresentationMapping.View2D,
View2D_X: Object.assign({}, proxyViewRepresentationMapping.View2D, {
vtkImageData: { name: 'SliceX' },
}),
View2D_Y: Object.assign({}, proxyViewRepresentationMapping.View2D, {
vtkImageData: { name: 'SliceY' },
}),
View2D_Z: Object.assign({}, proxyViewRepresentationMapping.View2D, {
vtkImageData: { name: 'SliceZ' },
}),
},
filters: {
vtkPolyData: [],
vtkImageData: ['Contour'],
vtkMolecule: [],
Glyph: [],
},
};
36 changes: 8 additions & 28 deletions Sources/config/Medical/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
import ConfigUtils from '../configUtils';
import Generic from '../Generic';

import proxyDefs from './proxyDefs';
import proxyUI from './proxyUI';

const { deepCopyPath, objAssignPath } = ConfigUtils;

function copyAssign(config, path, value) {
const newConfig = deepCopyPath(config, path);
objAssignPath(newConfig, path, value);
return newConfig;
}

let config = Generic;
config = copyAssign(config, 'name', 'Medical');

config = copyAssign(
config,
'definitions.Representations.Volume.options.ui',
proxyUI.Volume
);

// Our views come with lps orientation axes by default
config = copyAssign(config, 'definitions.Views', proxyDefs.Views);

const Medical = config;
export default Medical;
import Layout from './layout';
import Proxy from './proxy';

export default {
Name: 'Medical',
Layout,
Proxy,
};
3 changes: 3 additions & 0 deletions Sources/config/Medical/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Generic from '../Generic';

export default Generic.Layout;
Loading

0 comments on commit 26c42dc

Please sign in to comment.