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

fix(config): support more values for the useSharedArrayBuffer #3688

Merged
merged 9 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion extensions/cornerstone-dicom-seg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/tools": "^1.16.4",
"@cornerstonejs/tools": "^1.19.3",
"react-color": "^2.19.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function _getDisplaySetsFromSeries(instances, servicesManager, extensionManager)
const referencedSeriesSequence = instance.ReferencedSeriesSequence;

if (!referencedSeriesSequence) {
throw new Error('ReferencedSeriesSequence is missing for the SEG');
console.error('ReferencedSeriesSequence is missing for the SEG');
return;
}

const referencedSeries = referencedSeriesSequence[0] || referencedSeriesSequence;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
name: 'Radius (mm)',
id: 'brush-radius',
type: 'range',
min: 0.01,
max: 100,
min: 0.5,
max: 99.5,
value: state.Brush.brushSize,
step: 0.5,
onChange: value => onBrushSizeChange(value, 'Brush'),
Expand Down Expand Up @@ -281,8 +281,8 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
name: 'Radius (mm)',
type: 'range',
id: 'eraser-radius',
min: 0.01,
max: 100,
min: 0.5,
max: 99.5,
value: state.Eraser.brushSize,
step: 0.5,
onChange: value => onBrushSizeChange(value, 'Eraser'),
Expand Down Expand Up @@ -337,8 +337,8 @@ function SegmentationToolbox({ servicesManager, extensionManager }) {
name: 'Radius (mm)',
id: 'threshold-radius',
type: 'range',
min: 0.01,
max: 100,
min: 0.5,
max: 99.5,
value: state.ThresholdBrush.brushSize,
step: 0.5,
onChange: value => onBrushSizeChange(value, 'ThresholdBrush'),
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 @@ -44,9 +44,9 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.16.5",
"@cornerstonejs/core": "^1.16.5",
"@cornerstonejs/tools": "^1.16.5",
"@cornerstonejs/adapters": "^1.19.3",
"@cornerstonejs/core": "^1.19.3",
"@cornerstonejs/tools": "^1.19.3",
"classnames": "^2.3.2"
}
}
10 changes: 5 additions & 5 deletions extensions/cornerstone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.16.5",
"@cornerstonejs/dicom-image-loader": "^1.19.3",
"@ohif/core": "3.7.0-beta.87",
"@ohif/ui": "3.7.0-beta.87",
"dcmjs": "^0.29.6",
Expand All @@ -52,10 +52,10 @@
},
"dependencies": {
"@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^1.16.5",
"@cornerstonejs/core": "^1.16.5",
"@cornerstonejs/streaming-image-volume-loader": "^1.16.5",
"@cornerstonejs/tools": "^1.16.5",
"@cornerstonejs/adapters": "^1.19.3",
"@cornerstonejs/core": "^1.19.3",
"@cornerstonejs/streaming-image-volume-loader": "^1.19.3",
"@cornerstonejs/tools": "^1.19.3",
"@kitware/vtk.js": "27.3.1",
"html2canvas": "^1.4.1",
"lodash.debounce": "4.0.8",
Expand Down
18 changes: 9 additions & 9 deletions extensions/cornerstone/src/init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ export default async function init({
appConfig,
}: Types.Extensions.ExtensionParams): Promise<void> {
// Note: this should run first before initializing the cornerstone
switch (appConfig.useSharedArrayBuffer) {
case 'AUTO':
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.AUTO);
break;
case 'FALSE':
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.FALSE);
break;
default:
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.TRUE);
// DO NOT CHANGE THE ORDER
const value = appConfig.useSharedArrayBuffer;

if (value === 'AUTO') {
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.AUTO);
} else if (value === 'FALSE' || value === false) {
jbocce marked this conversation as resolved.
Show resolved Hide resolved
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.FALSE);
} else {
cornerstone.setUseSharedArrayBuffer(csEnums.SharedArrayBufferModes.TRUE);
}

await cs3DInit({
Expand Down
4 changes: 2 additions & 2 deletions extensions/measurement-tracking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"start": "yarn run dev"
},
"peerDependencies": {
"@cornerstonejs/core": "^1.16.5",
"@cornerstonejs/tools": "^1.16.5",
"@cornerstonejs/core": "^1.19.3",
"@cornerstonejs/tools": "^1.19.3",
"@ohif/core": "3.7.0-beta.87",
"@ohif/extension-cornerstone-dicom-sr": "3.7.0-beta.87",
"@ohif/ui": "3.7.0-beta.87",
Expand Down
37 changes: 10 additions & 27 deletions platform/app/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,6 @@ Cypress.Commands.add('drag', { prevSubject: 'element' }, (...args) =>
DragSimulator.simulate(...args)
);

/**
* Command to perform two clicks into two different positions. Each position must be [x, y].
* The positions are considering the element as reference, therefore, top-left of the element will be (0, 0).
*
* @param {*} viewport - Selector for viewport we would like to interact with
* @param {number[]} firstClick - Click position [x, y]
* @param {number[]} secondClick - Click position [x, y]
*/
Cypress.Commands.add('addLine', (viewport, firstClick, secondClick) => {
const performClick = (alias, x, y) => {
cy.get(alias).as(`axu-${alias}`).click(x, y, { force: true, multiple: true }).wait(1000);
};

cy.get(viewport).as('viewportAlias');
const [x1, y1] = firstClick;
const [x2, y2] = secondClick;

// First click
performClick('@viewportAlias', x1, y1);

// Second click
performClick('@viewportAlias', x2, y2);

cy.wait(1000);
});

/**
* Command to perform three clicks into three different positions. Each position must be [x, y].
* The positions are considering the element as reference, therefore, top-left of the element will be (0, 0).
Expand Down Expand Up @@ -280,7 +254,16 @@ Cypress.Commands.add(

cy.get('@lengthButton').should('have.class', 'active');

cy.addLine('.cornerstone-canvas', firstClick, secondClick);
cy.get('@viewport').then($viewport => {
const [x1, y1] = firstClick;
const [x2, y2] = secondClick;

cy.wrap($viewport)
.click(x1, y1, { force: true })
.wait(1000)
.click(x2, y2, { force: true })
.wait(1000);
});
}
);

Expand Down
2 changes: 1 addition & 1 deletion platform/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.16.5",
"@cornerstonejs/dicom-image-loader": "^1.19.3",
"@ohif/core": "3.7.0-beta.87",
"@ohif/extension-cornerstone": "3.7.0-beta.87",
"@ohif/extension-cornerstone-dicom-rt": "3.7.0-beta.87",
Expand Down
2 changes: 1 addition & 1 deletion platform/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@cornerstonejs/codec-libjpeg-turbo-8bit": "^1.2.2",
"@cornerstonejs/codec-openjpeg": "^1.2.2",
"@cornerstonejs/codec-openjph": "^2.4.2",
"@cornerstonejs/dicom-image-loader": "^1.16.5",
"@cornerstonejs/dicom-image-loader": "^1.19.3",
"@ohif/ui": "3.7.0-beta.87",
"cornerstone-math": "0.1.9",
"dicom-parser": "^1.8.21"
Expand Down
4 changes: 2 additions & 2 deletions platform/ui/src/components/AdvancedToolbox/ToolSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function ToolSettings({ options }) {
className="flex items-center"
key={option.id}
>
<div className="w-1/3 text-xs text-[13px]">{option.name}</div>
<div className="w-1/3 text-[13px]">{option.name}</div>
<div className="w-2/3">
<InputRange
minValue={option.min}
Expand All @@ -45,7 +45,7 @@ function ToolSettings({ options }) {
onChange={e => option.onChange(e)}
allowNumberEdit={true}
showAdjustmentArrows={false}
inputClassName="ml-2 w-4/5"
inputClassName="ml-1 w-4/5"
/>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion platform/ui/src/components/InputNumber/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const InputNumber: React.FC<{
const inputWidth = Math.max(maxDigits * 10, showAdjustmentArrows ? 20 : 28);
const arrowWidth = showAdjustmentArrows ? 20 : 0;
const containerWidth = `${inputWidth + arrowWidth}px`;
const decimalPlaces = Number.isInteger(step) ? 0 : step.toString().split('.')[1].length;

useEffect(() => {
setNumberValue(value);
Expand Down Expand Up @@ -101,7 +102,7 @@ const InputNumber: React.FC<{
<div className="flex">
<input
type="number"
value={numberValue}
value={Number(numberValue).toFixed(decimalPlaces)}
step={step}
onChange={handleChange}
className={'input-number w-full bg-black text-center text-[12px] text-white'}
Expand Down
13 changes: 8 additions & 5 deletions platform/ui/src/components/InputRange/InputRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ const InputRange: React.FC<InputRangeProps> = ({
const handleChange = useCallback(
e => {
const val = Number(e.target.value);
setRangeValue(val);
onChange(val);
const roundedVal = Math.round(val / step) * step;
setRangeValue(roundedVal);
onChange(roundedVal);
},
[onChange]
[onChange, step]
);

const rangeValuePercentage = ((rangeValue - minValue) / (maxValue - minValue)) * 100;
Expand Down Expand Up @@ -92,8 +93,10 @@ const InputRange: React.FC<InputRangeProps> = ({
e.preventDefault();
}}
>
<div className="relative flex w-full items-center">
{showLabel && labelPosition === 'left' && LabelOrEditableNumber}
<div className="relative flex w-full items-center space-x-2">
{showLabel && labelPosition === 'left' && (
<div style={{ width: labelWidth }}>{LabelOrEditableNumber}</div>
)}
<div className="range-track"></div>
<input
type="range"
Expand Down
8 changes: 7 additions & 1 deletion platform/ui/src/utils/getMaxDigits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
* @returns The maximum number of digits required to display a value.
*/
const getMaxDigits = (maxValue: number, step: number) => {
const integerDigits = maxValue.toString().length;
if (step <= 0) {
throw new Error('Step should be greater than zero');
}

// Get the number of integer digits for maxValue
const integerDigits = maxValue.toString().split('.')[0].length;
const decimalDigits = step % 1 === 0 ? 0 : step.toString().split('.')[1].length;

return integerDigits + (decimalDigits ? decimalDigits + 1 : 0);
};

Expand Down
65 changes: 23 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1482,10 +1482,10 @@
resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9"
integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==

"@cornerstonejs/adapters@^1.16.5":
version "1.16.5"
resolved "https://registry.yarnpkg.com/@cornerstonejs/adapters/-/adapters-1.16.5.tgz#cb50044ff7a3c26bdf98bda9c13dadbde4580018"
integrity sha512-wHDpCwWvo70kzAzxR6zGLUv55D3D52QDmLOAZLHMbeMSVHnKCepefU8mF1z7D2MLnOeyzB9rXGAZyqnK/1VVXA==
"@cornerstonejs/adapters@^1.19.3":
version "1.19.3"
resolved "https://registry.yarnpkg.com/@cornerstonejs/adapters/-/adapters-1.19.3.tgz#4480d16bb92346ee63a4737b5dd2b8699b8c79a0"
integrity sha512-aDJLYZ1FaT5LwSr1ZBS2br/bF9Tl5wHOoPBt6MOGP9mMUA+OaEqd4tY4C04tDOqLOBFUfTcI0+NxrpovQ+sLYw==
dependencies:
"@babel/runtime-corejs2" "^7.17.8"
buffer "^6.0.3"
Expand Down Expand Up @@ -1534,62 +1534,43 @@
resolved "https://registry.yarnpkg.com/@cornerstonejs/codec-openjph/-/codec-openjph-2.4.2.tgz#e96721d56f6ec96f7f95c16321d88cc8467d8d81"
integrity sha512-lgdvBvvNezleY+4pIe2ceUsJzlZe/0PipdeubQ3vZZOz3xxtHHMR1XFCl4fgd8gosR8COHuD7h6q+MwgrwBsng==

"@cornerstonejs/core@^1.16.5":
version "1.16.5"
resolved "https://registry.yarnpkg.com/@cornerstonejs/core/-/core-1.16.5.tgz#c83a49c5c63ea384f71fe45a977fb9c47c5d7445"
integrity sha512-uW+wKsdEDshVCo0A4XcYR4G3zxrGQf2xPuTL4G7jpRmASQGAMYgKQJ/0xOlgyJjlKgvkiXb6qrwbfZH0U9S0vA==
"@cornerstonejs/core@^1.19.3":
version "1.19.3"
resolved "https://registry.yarnpkg.com/@cornerstonejs/core/-/core-1.19.3.tgz#30d6360b6bda821c62daf20e0e752e0af7d4c604"
integrity sha512-NJt41RALQXnEbutGALwhvNg6iNoypkTRVYFRdDsMTwTzu03ODSZnVPCZVdgBjiIJS1wb9WknCC49p/opV712qQ==
dependencies:
"@kitware/vtk.js" "27.3.1"
detect-gpu "^5.0.22"
gl-matrix "^3.4.3"
lodash.clonedeep "4.5.0"

"@cornerstonejs/core@^1.16.6":
version "1.16.6"
resolved "https://registry.yarnpkg.com/@cornerstonejs/core/-/core-1.16.6.tgz#a216fc655f3c4b110196e63dcf129e02839d0890"
integrity sha512-ysd+t2N2KVk88TLYg0Nx174uYd47wQRBdFQZ4ApHhI/IHq5lY/qrP8prrtLR/DEtyLyUERIxDyGFRr+lEBZpxg==
dependencies:
"@kitware/vtk.js" "27.3.1"
detect-gpu "^5.0.22"
gl-matrix "^3.4.3"
lodash.clonedeep "4.5.0"

"@cornerstonejs/dicom-image-loader@^1.16.5":
version "1.16.5"
resolved "https://registry.yarnpkg.com/@cornerstonejs/dicom-image-loader/-/dicom-image-loader-1.16.5.tgz#23ca3e27e29b88cd05840c777578b37de60e5b87"
integrity sha512-PfYU9LujMeyr3rnAjJsgbMU77x/BDAVDR/8XDFLRPbxoeCvdfGLeIR0bbiO6ajvgTutjr9sbYQwtdmQiGnqmCg==
"@cornerstonejs/dicom-image-loader@^1.19.3":
version "1.19.3"
resolved "https://registry.yarnpkg.com/@cornerstonejs/dicom-image-loader/-/dicom-image-loader-1.19.3.tgz#f6dce05099fe21abe31f35d6b159d785cd0f360b"
integrity sha512-ouJtxCZaAxfS/hN3i4DdeszEw/VMTtKve43eGK9bL/+/eyhJegsVkrDPJEJyHjtGOK9tjbnxkg1PlpVeNgWJbg==
dependencies:
"@cornerstonejs/codec-charls" "^1.2.3"
"@cornerstonejs/codec-libjpeg-turbo-8bit" "^1.2.2"
"@cornerstonejs/codec-openjpeg" "^1.2.2"
"@cornerstonejs/codec-openjph" "^2.4.2"
"@cornerstonejs/core" "^1.16.5"
"@cornerstonejs/core" "^1.19.3"
dicom-parser "^1.8.9"
pako "^2.0.4"
uuid "^9.0.0"

"@cornerstonejs/streaming-image-volume-loader@^1.16.5":
version "1.16.5"
resolved "https://registry.yarnpkg.com/@cornerstonejs/streaming-image-volume-loader/-/streaming-image-volume-loader-1.16.5.tgz#9af370be2409e932caf1ff47fba9cfcf1b671065"
integrity sha512-98NsgeBPaEPMJnCsYKLDvGydREBh4Gue62o4AwcMyMOmH3tVC1neeMPzRNh0YTHHkQJJfjT5vD18+vYP86hnUw==
dependencies:
"@cornerstonejs/core" "^1.16.5"

"@cornerstonejs/tools@^1.16.4":
version "1.16.6"
resolved "https://registry.yarnpkg.com/@cornerstonejs/tools/-/tools-1.16.6.tgz#0debc17fb9830288bff263bbf3a34cb940b726c2"
integrity sha512-qLjtEC0OGW+bpvvKXQPQs8TEE/ze+NIiBbg1qBSXo2vm7O3YO1DRWbWthJMVL7tIWYuVxZx5OsAI2WOkydQUOA==
"@cornerstonejs/streaming-image-volume-loader@^1.19.3":
version "1.19.3"
resolved "https://registry.yarnpkg.com/@cornerstonejs/streaming-image-volume-loader/-/streaming-image-volume-loader-1.19.3.tgz#8895690efbbcc8cad8cee8b1be8c06be1e420830"
integrity sha512-tGXzeD8CuRNoGvWU+vZsDvU7GA5jy+AimHbPPr5kLM02Ghygrch98BXjW2tA6Cu9PGABE64KxtsZmMayw0nOLg==
dependencies:
"@cornerstonejs/core" "^1.16.6"
lodash.clonedeep "4.5.0"
lodash.get "^4.4.2"
"@cornerstonejs/core" "^1.19.3"

"@cornerstonejs/tools@^1.16.5":
version "1.16.5"
resolved "https://registry.yarnpkg.com/@cornerstonejs/tools/-/tools-1.16.5.tgz#79948216521c591a02f395e2130d72e0b9347eca"
integrity sha512-zUDBB6P13O1HZDiEyIGCORmAN1Ih9Z8QpjE0iM3hATdWUmHFs/2mBvHre/Wjh+BkNdtNTJ6s9pmbmz0CRVScUQ==
"@cornerstonejs/tools@^1.19.3":
version "1.19.3"
resolved "https://registry.yarnpkg.com/@cornerstonejs/tools/-/tools-1.19.3.tgz#d5f8f02adcdc4e5627b6565b4c60c642032a95c4"
integrity sha512-YcxrP6D5SR7epS+gmLZNK+K2yyFMshgPqHBf6PxS0nKq8jhYT6KHFjT0SBBRh+EJNrYCIYgy0D10PPSTg+kmVw==
dependencies:
"@cornerstonejs/core" "^1.16.5"
"@cornerstonejs/core" "^1.19.3"
lodash.clonedeep "4.5.0"
lodash.get "^4.4.2"

Expand Down
Loading