-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from Kitware/app_modes
App modes (adds Medical)
- Loading branch information
Showing
9 changed files
with
169 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Palettes from '../Palettes'; | ||
import Palettes from '../../Palettes'; | ||
|
||
const Volume = [ | ||
{ | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import ConfigUtils from '../configUtils'; | ||
import Generic from '../Generic'; | ||
|
||
import proxyDefs from './proxyDefs'; | ||
|
||
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'); | ||
|
||
// Mark piecewise function editor as advanced. | ||
// Assumed to be the 3rd object in the options array from Generic ui config. | ||
config = copyAssign( | ||
config, | ||
'definitions.Representations.Volume.options.ui.2.advanced', | ||
1 | ||
); | ||
|
||
// Our views come with lps orientation axes by default | ||
config = copyAssign(config, 'definitions.Views', proxyDefs.Views); | ||
|
||
const Medical = config; | ||
export default Medical; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import vtkView from 'vtk.js/Sources/Proxy/Core/ViewProxy'; | ||
import vtk2DView from 'vtk.js/Sources/Proxy/Core/View2DProxy'; | ||
|
||
import ConfigUtils from '../configUtils'; | ||
import proxyUI from '../Generic/proxyUI'; | ||
|
||
const { activateOnCreate, createProxyDefinition } = ConfigUtils; | ||
|
||
function createDefaultView(classFactory, ui) { | ||
return activateOnCreate( | ||
createProxyDefinition( | ||
classFactory, | ||
ui, | ||
[ | ||
{ link: 'AnnotationOpacity', property: 'annotationOpacity' }, | ||
{ | ||
link: 'OrientationAxesVisibility', | ||
property: 'orientationAxesVisibility', | ||
}, | ||
{ | ||
link: 'OrientationAxesPreset', | ||
property: 'presetToOrientationAxes', | ||
}, | ||
], | ||
{}, // definitionOptions | ||
// props | ||
{ | ||
presetToOrientationAxes: 'lps', | ||
} | ||
) | ||
); | ||
} | ||
|
||
const 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), | ||
}; | ||
|
||
export default { | ||
Views, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// ---------------------------------------------------------------------------- | ||
|
||
function createProxyDefinition( | ||
classFactory, | ||
ui = [], | ||
links = [], | ||
definitionOptions = {}, | ||
props = {} | ||
) { | ||
return { | ||
class: classFactory, | ||
options: Object.assign({ links, ui }, definitionOptions), | ||
props, | ||
}; | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
function activateOnCreate(def) { | ||
def.options.activateOnCreate = true; | ||
return def; | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
function deepCopyPath(rootObj, pathSpec) { | ||
const path = typeof pathSpec === 'string' ? pathSpec.split('.') : pathSpec; | ||
const newRootObj = Object.assign({}, rootObj); | ||
|
||
let obj = newRootObj; | ||
while (path.length) { | ||
const prop = path.shift(); | ||
if (Object.prototype.hasOwnProperty.call(obj, prop)) { | ||
if (obj[prop] instanceof Array) { | ||
// handles case when prop is an array | ||
obj[prop] = Array.from(obj[prop]); | ||
} else { | ||
// copy as object | ||
obj[prop] = Object.assign({}, obj[prop]); | ||
} | ||
obj = obj[prop]; | ||
} else { | ||
throw new Error(`Invalid property path given: ${path}`); | ||
} | ||
} | ||
|
||
return newRootObj; | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
function objAssignPath(rootObj, pathSpec, value) { | ||
const path = typeof pathSpec === 'string' ? pathSpec.split('.') : pathSpec; | ||
let obj = rootObj; | ||
|
||
while (path.length > 1) { | ||
const prop = path.shift(); | ||
if (Object.prototype.hasOwnProperty.call(obj, prop)) { | ||
obj = obj[prop]; | ||
} else { | ||
throw new Error(`Invalid property path given: ${path}`); | ||
} | ||
} | ||
|
||
if (path.length === 1) { | ||
const lastProp = path.shift(); | ||
obj[lastProp] = value; | ||
} else { | ||
throw new Error(`Invalid property path given: ${path}`); | ||
} | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
export default { | ||
createProxyDefinition, | ||
activateOnCreate, | ||
deepCopyPath, | ||
objAssignPath, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Generic from './Generic'; | ||
import Medical from './Medical'; | ||
|
||
export default { | ||
Generic, | ||
Medical, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters