Playing with how routes access ViewModel context and SopClassHandlers that map meta to ViewModel (displaySets)
This commit is contained in:
parent
b54e3734a7
commit
3242bbcf76
@ -1,27 +1,24 @@
|
|||||||
|
import { dicomMetadataStore } from '@ohif/core';
|
||||||
|
|
||||||
export default class SOPClassHandlerManager {
|
export default class SOPClassHandlerManager {
|
||||||
constructor(sopClassHandlerIds) {
|
constructor(extensionManager, sopClassHandlerIds) {
|
||||||
this.SOPClassHandlers = sopClassHandlerIds.map(getSOPClassHandler);
|
this.SOPClassHandlers = sopClassHandlerIds.map(
|
||||||
|
extensionManager.getModuleEntry
|
||||||
|
);
|
||||||
|
|
||||||
|
dicomMetadataStore.listen(this.onSeriesMetadataLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
async createDisplaySets() {
|
onSeriesMetadataLoaded = instances => {
|
||||||
const SOPClassHandlers = this.SOPClassHandlers;
|
const SOPClassHandlers = this.SOPClassHandlers;
|
||||||
|
|
||||||
const displaySets = [];
|
for (let i = 0; i < SOPClassHandlers.length; i++) {
|
||||||
|
const handler = SOPClassHandlers[i];
|
||||||
// TODO
|
|
||||||
StudyMetadata.forEachSeries(series => {
|
|
||||||
for (let i = 0; i < SOPClassHandlers.length; i++) {
|
|
||||||
const handler = SOPClassHandlers[i];
|
|
||||||
|
|
||||||
|
if (handler.sopClassUids.includes(instances[0].SOPClassUID)) {
|
||||||
// TODO: This step is still unclear to me
|
// TODO: This step is still unclear to me
|
||||||
const displaySet = handler(series);
|
return handler.getDisplaySetFromSeries(series);
|
||||||
|
|
||||||
if (displaySet) {
|
|
||||||
displaySets.push(displaySet);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
};
|
||||||
return displaySets;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
33
platform/viewer/src/routes/ViewModelContext.js
Normal file
33
platform/viewer/src/routes/ViewModelContext.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
|
const ViewModelContext = React.createContext({
|
||||||
|
displaySetInstanceUids: [],
|
||||||
|
setDisplaySetInstanceUids: () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
class ViewModelProvider extends Component {
|
||||||
|
state = {
|
||||||
|
displaySetInstanceUids: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const setDisplaySetInstanceUids = displaySetInstanceUids => {
|
||||||
|
this.setState({ displaySetInstanceUids });
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ViewModelContext.Provider
|
||||||
|
value={{
|
||||||
|
displaySetInstanceUids: this.state.displaySetInstanceUids,
|
||||||
|
setDisplaySetInstanceUids,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{this.props.children}
|
||||||
|
</ViewModelContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ViewModelContext;
|
||||||
|
|
||||||
|
export { ViewModelProvider };
|
||||||
Loading…
Reference in New Issue
Block a user