|
@@ -436,6 +436,57 @@ function setOriginalSize(viewport) {
|
|
|
viewport.render();
|
|
|
}
|
|
|
|
|
|
+function activateMagnifier() {
|
|
|
+ console.log('Activating Magnifier');
|
|
|
+ const isActive =
|
|
|
+ toolGroup.getActivePrimaryMouseButtonTool() === MagnifyTool.toolName;
|
|
|
+ if (isActive) {
|
|
|
+ toolGroup.setToolPassive(MagnifyTool.toolName, {
|
|
|
+ removeAllBindings: true,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ toolGroup.setToolActive(MagnifyTool.toolName, {
|
|
|
+ bindings: [
|
|
|
+ {
|
|
|
+ mouseButton: MouseBindings.Primary, // Left Click
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function invertContrast() {
|
|
|
+ const viewport =
|
|
|
+ cornerstone.getEnabledElementByViewportId(currentViewportId).viewport;
|
|
|
+ const targetBool = !viewport.getProperties().invert;
|
|
|
+ viewport.setProperties({
|
|
|
+ invert: targetBool,
|
|
|
+ });
|
|
|
+ viewport.render();
|
|
|
+}
|
|
|
+
|
|
|
+function rotateAnyAngle() {
|
|
|
+ const planar = toolGroup.getToolInstance(PlanarRotateTool.toolName); // Reset rotation angle
|
|
|
+ const isActive = planar.mode === csToolsEnums.ToolModes.Active;
|
|
|
+ console.log(
|
|
|
+ `PlanarRotateTool is currently ${isActive ? 'active' : 'inactive'}`
|
|
|
+ );
|
|
|
+ if (isActive) {
|
|
|
+ toolGroup.setToolPassive(PlanarRotateTool.toolName, {
|
|
|
+ removeAllBindings: true,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ toolGroup.setToolActive(PlanarRotateTool.toolName, {
|
|
|
+ bindings: [
|
|
|
+ {
|
|
|
+ mouseButton: MouseBindings.Primary, // Left Click
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.log('Rotating Image by Any Angle');
|
|
|
+}
|
|
|
+
|
|
|
const StackViewer = ({
|
|
|
imageIndex = 0,
|
|
|
imageUrls = [],
|
|
@@ -554,27 +605,7 @@ const StackViewer = ({
|
|
|
break;
|
|
|
case 'Rotate Any Angle':
|
|
|
// Implement the logic to rotate the image by any angle
|
|
|
- {
|
|
|
- const planar = toolGroup.getToolInstance(PlanarRotateTool.toolName); // Reset rotation angle
|
|
|
- const isActive = planar.mode === csToolsEnums.ToolModes.Active;
|
|
|
- console.log(
|
|
|
- `PlanarRotateTool is currently ${isActive ? 'active' : 'inactive'}`
|
|
|
- );
|
|
|
- if (isActive) {
|
|
|
- toolGroup.setToolPassive(PlanarRotateTool.toolName, {
|
|
|
- removeAllBindings: true,
|
|
|
- });
|
|
|
- } else {
|
|
|
- toolGroup.setToolActive(PlanarRotateTool.toolName, {
|
|
|
- bindings: [
|
|
|
- {
|
|
|
- mouseButton: MouseBindings.Primary, // Left Click
|
|
|
- },
|
|
|
- ],
|
|
|
- });
|
|
|
- }
|
|
|
- console.log('Rotating Image by Any Angle');
|
|
|
- }
|
|
|
+ rotateAnyAngle();
|
|
|
break;
|
|
|
case 'AddMask':
|
|
|
addMask();
|
|
@@ -599,17 +630,7 @@ const StackViewer = ({
|
|
|
break;
|
|
|
case 'Invert Contrast':
|
|
|
// Implement the logic to invert the contrast
|
|
|
- {
|
|
|
- const viewport =
|
|
|
- cornerstone.getEnabledElementByViewportId(
|
|
|
- currentViewportId
|
|
|
- ).viewport;
|
|
|
- const targetBool = !viewport.getProperties().invert;
|
|
|
- viewport.setProperties({
|
|
|
- invert: targetBool,
|
|
|
- });
|
|
|
- viewport.render();
|
|
|
- }
|
|
|
+ invertContrast();
|
|
|
console.log('Inverting Contrast');
|
|
|
break;
|
|
|
case '1x1 Layout':
|
|
@@ -630,24 +651,7 @@ const StackViewer = ({
|
|
|
break;
|
|
|
case 'Magnifier': {
|
|
|
// Implement the logic for magnifier
|
|
|
- console.log('Activating Magnifier');
|
|
|
- const isActive =
|
|
|
- toolGroup.getActivePrimaryMouseButtonTool() ===
|
|
|
- MagnifyTool.toolName;
|
|
|
- if (isActive) {
|
|
|
- toolGroup.setToolPassive(MagnifyTool.toolName, {
|
|
|
- removeAllBindings: true,
|
|
|
- });
|
|
|
- } else {
|
|
|
- toolGroup.setToolActive(MagnifyTool.toolName, {
|
|
|
- bindings: [
|
|
|
- {
|
|
|
- mouseButton: MouseBindings.Primary, // Left Click
|
|
|
- },
|
|
|
- ],
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
+ activateMagnifier();
|
|
|
break;
|
|
|
}
|
|
|
case 'Fit Size': {
|