feat(segmentation mode): Add create, and export SEG with Brushes (#3632)

This commit is contained in:
Alireza authored and GitHub committed 2023-09-22 10:23:44 -04:00
1 parent 896866e9d0
commit 48bbd6281a
186 files changed
+6801 -2883

No files matched your search

@@ -178,8 +178,15 @@ export default class DisplaySetService extends PubSubService {
* @param {string} displaySetInstanceUID
* @returns {object} displaySet
*/
public getDisplaySetByUID = (displaySetInstanceUid: string): DisplaySet =>
displaySetCache.get(displaySetInstanceUid);
public getDisplaySetByUID = (displaySetInstanceUid: string): DisplaySet => {
if (typeof displaySetInstanceUid !== 'string') {
throw new Error(
`getDisplaySetByUID: displaySetInstanceUid must be a string, you passed ${displaySetInstanceUid}`
);
}
return displaySetCache.get(displaySetInstanceUid);
};
/**
*
@@ -523,22 +523,32 @@ export default class HangingProtocolService extends PubSubService {
stage.viewports.push({
viewportOptions: {
...defaultViewportOptions,
viewportId: uuidv4(),
// Use 'default' for the first viewport, and UUIDs for the rest.
viewportId: i === 0 ? 'default' : uuidv4(),
},
displaySets: [],
});
}
} else {
// Clone each viewport to ensure independent objects
stage.viewports = stage.viewports.map(viewport => ({
...viewport,
viewportOptions: {
...(viewport.viewportOptions || defaultViewportOptions),
viewportId: viewport.viewportOptions?.viewportId || uuidv4(),
},
displaySets: viewport.displaySets || [],
}));
stage.viewports = stage.viewports.map((viewport, index) => {
const existingViewportId = viewport.viewportOptions?.viewportId;
return {
...viewport,
viewportOptions: {
...(viewport.viewportOptions || defaultViewportOptions),
// use provided viewportId when available, otherwise use default for first viewport
// and uuid for the rest
viewportId: existingViewportId
? existingViewportId
: index === 0
? 'default'
: uuidv4(),
},
displaySets: viewport.displaySets || [],
};
});
stage.viewports.forEach(viewport => {
viewport.displaySets.forEach(displaySet => {
displaySet.options = displaySet.options || {};
@@ -77,7 +77,7 @@ validate.validators.doesNotEqual = function (value, options, key) {
}
}
} else if (testValue === dicomArrayValue[0]) {
console.debug(dicomArrayValue, testValue);
console.log(dicomArrayValue, testValue);
return `${key} must not equal to ${testValue}`;
}
};
@@ -94,8 +94,10 @@ export default class ToolbarService extends PubSubService {
commandsManager.runCommand(commandName, commandOptions, context);
});
// only set the primary tool if no error was thrown
this.state.primaryToolId = itemId;
// only set the primary tool if no error was thrown.
// if the itemId is not undefined use it; otherwise, set the first tool in
// the commands as the primary tool
this.state.primaryToolId = itemId || commands[0].commandOptions?.toolName;
} catch (error) {
console.warn(error);
}
@@ -164,7 +166,7 @@ export default class ToolbarService extends PubSubService {
this.state.groups[groupId] = itemId;
}
this._broadcastEvent(this.EVENTS.TOOL_BAR_STATE_MODIFIED, {});
this._broadcastEvent(this.EVENTS.TOOL_BAR_STATE_MODIFIED, { ...this.state });
}
getButtons() {
@@ -293,6 +295,10 @@ export default class ToolbarService extends PubSubService {
* @param {*} props - Props set by the Viewer layer
*/
_mapButtonToDisplay(btn, btnSection, metadata, props) {
if (!btn) {
return;
}
const { id, type, component } = btn;
const buttonType = this._buttonTypes()[type];
@@ -74,6 +74,11 @@ class ViewportGridService extends PubSubService {
return this.serviceImplementation._getState();
}
public getActiveViewportId() {
const state = this.getState();
return state.activeViewportId;
}
public setDisplaySetsForViewport(props) {
// Just update a single viewport, but use the multi-viewport update for it.
this.setDisplaySetsForViewports([props]);