Playing with how routes access ViewModel context and SopClassHandlers that map meta to ViewModel (displaySets)

This commit is contained in:
dannyrb 2020-05-07 14:05:57 -04:00 committed by James A. Petts
parent b54e3734a7
commit 3242bbcf76
2 changed files with 48 additions and 18 deletions

View File

@ -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;
}
} }

View 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 };