Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/cs3d 2 #4347

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions .webpack/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const cssToJavaScript = require('./rules/cssToJavaScript.js');
// const stylusToJavaScript = require('./rules/stylusToJavaScript.js');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');


// ~~ ENV VARS
const NODE_ENV = process.env.NODE_ENV;
const QUICK_BUILD = process.env.QUICK_BUILD;
Expand Down Expand Up @@ -101,14 +100,18 @@ module.exports = (env, argv, { SRC_DIR, ENTRY }) => {
module: {
noParse: [/(codec)/, /(dicomicc)/],
rules: [
...(isProdBuild ? [] : [{
test: /\.[jt]sx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
plugins: ['react-refresh/babel'],
},
}]),
...(isProdBuild
? []
: [
{
test: /\.[jt]sx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
plugins: ['react-refresh/babel'],
},
},
]),
{
test: /\.svg?$/,
oneOf: [
Expand All @@ -123,11 +126,11 @@ module.exports = (env, argv, { SRC_DIR, ENTRY }) => {
name: 'preset-default',
params: {
overrides: {
removeViewBox: false
removeViewBox: false,
},
},
},
]
],
},
prettier: false,
svgo: true,
Expand All @@ -141,11 +144,6 @@ module.exports = (env, argv, { SRC_DIR, ENTRY }) => {
},
],
},
{
test: /\.js$/,
enforce: 'pre',
use: 'source-map-loader',
},
transpileJavaScriptRule(mode),
loadWebWorkersRule,
// loadShadersRule,
Expand Down Expand Up @@ -185,8 +183,8 @@ module.exports = (env, argv, { SRC_DIR, ENTRY }) => {
'@hooks': path.resolve(__dirname, '../platform/app/src/hooks'),
'@routes': path.resolve(__dirname, '../platform/app/src/routes'),
'@state': path.resolve(__dirname, '../platform/app/src/state'),
'@cornerstonejs/dicom-image-loader':
'@cornerstonejs/dicom-image-loader/dist/dynamic-import/cornerstoneDICOMImageLoader.min.js',
'dicom-microscopy-viewer':
'dicom-microscopy-viewer/dist/dynamic-import/dicomMicroscopyViewer.min.js',
},
// Which directories to search when resolving modules
modules: [
Expand Down
2 changes: 1 addition & 1 deletion addOns/externals/devDependencies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@kitware/vtk.js": "30.4.1",
"@kitware/vtk.js": "32.1.0",
"clsx": "^2.1.1",
"core-js": "^3.2.1",
"moment": "^2.9.4"
Expand Down
6 changes: 3 additions & 3 deletions extensions/cornerstone-dicom-pmap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.77.6",
"@cornerstonejs/core": "^1.77.6",
"@kitware/vtk.js": "30.4.1",
"@cornerstonejs/adapters": "^2.0.0-beta.27",
"@cornerstonejs/core": "^2.0.0-beta.27",
"@kitware/vtk.js": "32.1.0",
"react-color": "^2.19.3"
}
}
16 changes: 6 additions & 10 deletions extensions/cornerstone-dicom-rt/src/utils/promptHydrateRT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function promptHydrateRT({
servicesManager,
rtDisplaySet,
viewportId,
toolGroupId = 'default',
preHydrateCallbacks,
hydrateRTDisplaySet,
}: withAppTypes) {
Expand All @@ -27,16 +26,13 @@ function promptHydrateRT({
callback();
});

window.setTimeout(async () => {
const isHydrated = await hydrateRTDisplaySet({
rtDisplaySet,
viewportId,
toolGroupId,
servicesManager,
});
const isHydrated = await hydrateRTDisplaySet({
rtDisplaySet,
viewportId,
servicesManager,
});

resolve(isHydrated);
}, 0);
resolve(isHydrated);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function OHIFCornerstoneRTViewport(props: withAppTypes) {
newSelectedSegmentIndex = numberOfSegments - 1;
}

segmentationService.jumpToSegmentCenter(segmentationId, newSelectedSegmentIndex, toolGroupId);
segmentationService.jumpToSegmentCenter(segmentationId, newSelectedSegmentIndex, viewportId);
setSelectedSegment(newSelectedSegmentIndex);
},
[selectedSegment]
Expand Down Expand Up @@ -243,7 +243,7 @@ function OHIFCornerstoneRTViewport(props: withAppTypes) {

return () => {
// remove the segmentation representations if seg displayset changed
segmentationService.removeSegmentationRepresentationFromToolGroup(toolGroupId);
segmentationService.removeSegmentationRepresentationFromViewport(viewportId);

toolGroupService.destroyToolGroup(toolGroupId);
};
Expand All @@ -254,7 +254,7 @@ function OHIFCornerstoneRTViewport(props: withAppTypes) {

return () => {
// remove the segmentation representations if seg displayset changed
segmentationService.removeSegmentationRepresentationFromToolGroup(toolGroupId);
segmentationService.removeSegmentationRepresentationFromViewport(viewportId);
referencedDisplaySetRef.current = null;
};
}, [rtDisplaySet]);
Expand Down
6 changes: 3 additions & 3 deletions extensions/cornerstone-dicom-seg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.81.6",
"@cornerstonejs/core": "^1.81.6",
"@kitware/vtk.js": "30.4.1",
"@cornerstonejs/adapters": "^2.0.0-beta.27",
"@cornerstonejs/core": "^2.0.0-beta.27",
"@kitware/vtk.js": "32.1.0",
"react-color": "^2.19.3"
}
}
15 changes: 6 additions & 9 deletions extensions/cornerstone-dicom-seg/src/commandsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,14 @@ const commandsModule = ({
{ label: `Segmentation ${currentSegmentations.length + 1}` }
);

const toolGroupId = viewport.viewportOptions.toolGroupId;

await segmentationService.addSegmentationRepresentationToToolGroup(
toolGroupId,
await segmentationService.addSegmentationRepresentationToViewport(
viewportId,
segmentationId
);

// Add only one segment for now
segmentationService.addSegment(segmentationId, {
toolGroupId,
viewportId,
segmentIndex: 1,
properties: {
label: 'Segment 1',
Expand Down Expand Up @@ -161,9 +159,8 @@ const commandsModule = ({

segmentationService.addOrUpdateSegmentation(segmentation);

const toolGroupId = viewport.viewportOptions.toolGroupId;
await segmentationService.addSegmentationRepresentationToToolGroup(
toolGroupId,
await segmentationService.addSegmentationRepresentationToViewport(
viewportId,
segmentationId
);

Expand All @@ -173,7 +170,7 @@ const commandsModule = ({
}
segmentationService.addSegment(segmentationId, {
segmentIndex: segment.segmentIndex,
toolGroupId,
viewportId,
properties: {
color: segment.color,
label: segment.label,
Expand Down
42 changes: 20 additions & 22 deletions extensions/cornerstone-dicom-seg/src/panels/PanelSegmentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ export default function PanelSegmentation({
};
}, []);

const getToolGroupIds = segmentationId => {
const toolGroupIds = segmentationService.getToolGroupIdsWithSegmentation(segmentationId);
const getViewportIds = segmentationId => {
const viewportIds = segmentationService.getViewportIdsWithSegmentation(segmentationId);

return toolGroupIds;
return viewportIds;
};

const onSegmentationAdd = async () => {
Expand All @@ -130,7 +130,7 @@ export default function PanelSegmentation({
};

const onSegmentationClick = (segmentationId: string) => {
segmentationService.setActiveSegmentationForToolGroup(segmentationId);
segmentationService.setActiveSegmentationForViewport(segmentationId);
};

const onSegmentationDelete = (segmentationId: string) => {
Expand All @@ -144,12 +144,11 @@ export default function PanelSegmentation({
const onSegmentClick = (segmentationId, segmentIndex) => {
segmentationService.setActiveSegment(segmentationId, segmentIndex);

const toolGroupIds = getToolGroupIds(segmentationId);
const viewportIds = getViewportIds(segmentationId);

toolGroupIds.forEach(toolGroupId => {
// const toolGroupId =
segmentationService.setActiveSegmentationForToolGroup(segmentationId, toolGroupId);
segmentationService.jumpToSegmentCenter(segmentationId, segmentIndex, toolGroupId);
viewportIds.forEach(viewportId => {
segmentationService.setActiveSegmentationForViewport(segmentationId, viewportId);
segmentationService.jumpToSegmentCenter(segmentationId, segmentIndex, viewportId);
});
};

Expand Down Expand Up @@ -224,16 +223,11 @@ export default function PanelSegmentation({
const segmentation = segmentationService.getSegmentation(segmentationId);
const segmentInfo = segmentation.segments[segmentIndex];
const isVisible = !segmentInfo.isVisible;
const toolGroupIds = getToolGroupIds(segmentationId);
const viewportIds = getViewportIds(segmentationId);

// Todo: right now we apply the visibility to all tool groups
toolGroupIds.forEach(toolGroupId => {
segmentationService.setSegmentVisibility(
segmentationId,
segmentIndex,
isVisible,
toolGroupId
);
viewportIds.forEach(viewportId => {
segmentationService.setSegmentVisibility(segmentationId, segmentIndex, isVisible, viewportId);
});
};

Expand All @@ -247,15 +241,15 @@ export default function PanelSegmentation({
const isVisible = segmentation.isVisible;
const segments = segmentation.segments;

const toolGroupIds = getToolGroupIds(segmentationId);
const viewportIds = getViewportIds(segmentationId);

toolGroupIds.forEach(toolGroupId => {
viewportIds.forEach(viewportId => {
segments.forEach((segment, segmentIndex) => {
segmentationService.setSegmentVisibility(
segmentationId,
segmentIndex,
isVisible,
toolGroupId
viewportId
);
});
});
Expand Down Expand Up @@ -352,8 +346,12 @@ export default function PanelSegmentation({
setRenderFill={value =>
_setSegmentationConfiguration(selectedSegmentationId, 'renderFill', value)
}
setRenderInactiveSegmentations={value =>
_setSegmentationConfiguration(selectedSegmentationId, 'renderInactiveSegmentations', value)
setrenderInactiveRepresentations={value =>
_setSegmentationConfiguration(
selectedSegmentationId,
'renderInactiveRepresentations',
value
)
}
setOutlineWidthActive={value =>
_setSegmentationConfiguration(selectedSegmentationId, 'outlineWidthActive', value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const initialState = {
outlineWidth: 3,
fillOpacity: 0.9,
fillOpacityInactive: 0.8,
renderInactiveSegmentations: true,
renderInactiveRepresentations: true,
};

const reducer = (state, action) => {
Expand All @@ -24,7 +24,7 @@ const reducer = (state, action) => {
case 'SET_FILL_OPACITY_INACTIVE':
return { ...state, fillOpacityInactive: action.payload.value };
case 'RENDER_INACTIVE_SEGMENTATIONS':
return { ...state, renderInactiveSegmentations: action.payload.value };
return { ...state, renderInactiveRepresentations: action.payload.value };
default:
return state;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function OHIFCornerstoneSEGViewport(props: withAppTypes) {
newSelectedSegmentIndex = numberOfSegments - 1;
}

segmentationService.jumpToSegmentCenter(segmentationId, newSelectedSegmentIndex, toolGroupId);
segmentationService.jumpToSegmentCenter(segmentationId, newSelectedSegmentIndex, viewportId);
setSelectedSegment(newSelectedSegmentIndex);
},
[selectedSegment]
Expand Down Expand Up @@ -229,7 +229,7 @@ function OHIFCornerstoneSEGViewport(props: withAppTypes) {

return () => {
// remove the segmentation representations if seg displayset changed
segmentationService.removeSegmentationRepresentationFromToolGroup(toolGroupId);
segmentationService.removeSegmentationRepresentationFromViewport(viewportId);

// Only destroy the viewport specific implementation
toolGroupService.destroyToolGroup(toolGroupId);
Expand All @@ -241,7 +241,7 @@ function OHIFCornerstoneSEGViewport(props: withAppTypes) {

return () => {
// remove the segmentation representations if seg displayset changed
segmentationService.removeSegmentationRepresentationFromToolGroup(toolGroupId);
segmentationService.removeSegmentationRepresentationFromViewport(viewportId);
referencedDisplaySetRef.current = null;
};
}, [segDisplaySet]);
Expand Down
6 changes: 3 additions & 3 deletions extensions/cornerstone-dicom-sr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.82.4",
"@cornerstonejs/core": "^1.82.4",
"@cornerstonejs/tools": "^1.82.4",
"@cornerstonejs/adapters": "^2.0.0-beta.27",
"@cornerstonejs/core": "^2.0.0-beta.27",
"@cornerstonejs/tools": "^2.0.0-beta.27",
"classnames": "^2.3.2"
}
}
5 changes: 2 additions & 3 deletions extensions/cornerstone-dynamic-volume/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/core": "^1.82.4",
"@cornerstonejs/streaming-image-volume-loader": "^1.82.4",
"@cornerstonejs/tools": "^1.82.4",
"@cornerstonejs/core": "^2.0.0-beta.27",
"@cornerstonejs/tools": "^2.0.0-beta.27",
"classnames": "^2.3.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,14 @@ function _getSegmentationData(segmentation, volumesTimePointsCache, displaySetSe

// since we only use one segmentation representation per segmentationId
// it is fine to pick the first one
const segmentationRepresentations = csTools.segmentation.state.getSegmentationIdRepresentations(
segmentation.id
);
const segmentationRepresentations =
csTools.segmentation.state.getSegmentationRepresentationsForSegmentation(segmentation.id);

const segmentationRepresentationUID =
segmentationRepresentations[0].segmentationRepresentationUID;

const toolGroupId = csTools.segmentation.state.getToolGroupIdFromSegmentationRepresentationUID(
segmentationRepresentationUID
);

// Todo: this is useless we should be able to grab color with just segRepUID and segmentIndex
const color = csTools.segmentation.config.color.getColorForSegmentIndex(
toolGroupId,
const color = csTools.segmentation.config.color.getSegmentIndexColor(
segmentationRepresentationUID,
1 // segmentIndex
);
Expand Down
Loading
Loading