Skip to content

Commit 996b808

Browse files
committed
refactor(volumeCropping): Adjust viewport width and clean up unused code in VolumeCroppingTool and VolumeCroppingControlTool
1 parent 1b8045f commit 996b808

File tree

3 files changed

+18
-43
lines changed

3 files changed

+18
-43
lines changed

packages/tools/examples/volumeCroppingTool/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ element3.style.height = '33.33%';
103103
element3.style.minHeight = '200px';
104104

105105
// Set styles for the 3D viewport (on the left)
106-
element4.style.width = '100%';
106+
element4.style.width = '75%';
107107
element4.style.height = '100%';
108108
element4.style.minHeight = '600px';
109109
element4.style.position = 'relative';

packages/tools/src/tools/VolumeCroppingControlTool.ts

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class VolumeCroppingControlTool extends AnnotationTool {
105105
toolCenter: Types.Point3 = [0, 0, 0]; // NOTE: it is assumed that all the active/linked viewports share the same crosshair center.
106106
toolCenterMin: Types.Point3 = [0, 0, 0];
107107
toolCenterMax: Types.Point3 = [0, 0, 0];
108-
// This because the rotation operation rotates also all the other active/intersecting reference lines of the same angle
109108
_getReferenceLineColor?: (viewportId: string) => string;
110109
_getReferenceLineControllable?: (viewportId: string) => boolean;
111110
constructor(
@@ -250,7 +249,6 @@ class VolumeCroppingControlTool extends AnnotationTool {
250249

251250
_getViewportsInfo = () => {
252251
const viewports = getToolGroup(this.toolGroupId).viewportsInfo;
253-
254252
return viewports;
255253
};
256254

@@ -393,13 +391,12 @@ class VolumeCroppingControlTool extends AnnotationTool {
393391
const secondPlane = csUtils.planar.planeEquation(normal2, point2);
394392
const thirdPlane = csUtils.planar.planeEquation(normal3, point3);
395393

396-
//viewport.render();
397394
const toolCenter = csUtils.planar.threePlaneIntersection(
398395
firstPlane,
399396
secondPlane,
400397
thirdPlane
401398
);
402-
399+
//viewport.render();
403400
// this.setToolCenter(toolCenter);
404401
};
405402

@@ -433,11 +430,11 @@ class VolumeCroppingControlTool extends AnnotationTool {
433430
toolCenter: this.toolCenter,
434431
toolMin: this.toolCenterMin,
435432
toolMax: this.toolCenterMax,
436-
handleType: this.editData?.annotation?.data?.handles?.activeType, // Pass activeType here
433+
handleType: handleType, // Pass activeType here
437434
viewportOrientation: [
438435
viewportAnnotation.data.referenceLines[0][0].options.orientation,
439436
viewportAnnotation.data.referenceLines[1][0].options.orientation,
440-
], // viewportId: data.viewportId,
437+
],
441438
});
442439
}
443440
}
@@ -864,30 +861,6 @@ class VolumeCroppingControlTool extends AnnotationTool {
864861
canvasUnitVectorFromCenter,
865862
canvasDiagonalLength * 100
866863
);
867-
/*
868-
const refLinePointMinOne = vec2.create();
869-
const refLinePointMinTwo = vec2.create();
870-
871-
let refLinesCenter = vec2.clone(crosshairCenterCanvas);
872-
if (!otherViewportControllable) {
873-
refLinesCenter = vec2.clone(otherViewportCenterCanvas);
874-
}
875-
vec2.add(refLinePointMinOne, refLinesCenter, canvasVectorFromCenterLong);
876-
vec2.subtract(
877-
refLinePointMinTwo,
878-
refLinesCenter,
879-
canvasVectorFromCenterLong
880-
);
881-
882-
// Clipping lines to be only included in a box (canvas), we don't want
883-
// the lines goes beyond canvas
884-
liangBarksyClip(refLinePointMinOne, refLinePointMinTwo, canvasBox);
885-
referenceLines.push([
886-
otherViewport,
887-
refLinePointMinOne,
888-
refLinePointMinTwo,
889-
]);
890-
*/
891864
// For min center
892865
const refLinesCenterMin = otherViewportControllable
893866
? vec2.clone(crosshairCenterCanvasMin)
@@ -970,10 +943,10 @@ class VolumeCroppingControlTool extends AnnotationTool {
970943
lineWidth = 2.5;
971944
}
972945

973-
let lineUID = `${lineIndex}`;
946+
const lineUID = `${lineIndex}`;
974947
if (viewportControllable) {
975-
lineUID = `${lineIndex}One`;
976-
lineUID = `${lineIndex}Two`;
948+
// lineUID = `${lineIndex}One`;
949+
// lineUID = `${lineIndex}Two`;
977950
drawLineSvg(
978951
svgDrawingHelper,
979952
annotationUID,

packages/tools/src/tools/VolumeCroppingTool.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,6 @@ class VolumeCroppingTool extends AnnotationTool {
465465
this.sphereStates[2].sphereSource.setCenter(
466466
this.sphereStates[2].point
467467
);
468-
/*
469-
this.sphereStates[2].sphereSource.setCenter(
470-
this.sphereStates[2].point[0],
471-
planeYmin.getOrigin()[1],
472-
this.sphereStates[2].point[2]
473-
);
474-
*/
475468
this.sphereStates[2].sphereSource.modified();
476469
console.debug(
477470
'update ymin with : ',
@@ -490,6 +483,7 @@ class VolumeCroppingTool extends AnnotationTool {
490483
) {
491484
state.point[1] = newYCenter;
492485
state.sphereSource.setCenter(state.point);
486+
state.sphereSource.modified();
493487
console.debug('updating for y change: ', state);
494488
}
495489
});
@@ -780,8 +774,16 @@ class VolumeCroppingTool extends AnnotationTool {
780774
});
781775
}
782776

783-
sphereState.point = newPoint;
784-
sphereState.sphereSource.setCenter(newPoint);
777+
sphereState.point = [
778+
newPoint[0],
779+
newPoint[1],
780+
newPoint[2],
781+
] as Types.Point3;
782+
sphereState.sphereSource.setCenter([
783+
newPoint[0],
784+
newPoint[1],
785+
newPoint[2],
786+
]);
785787
sphereState.sphereSource.modified();
786788
const volumeActor = viewport.getDefaultActor()?.actor;
787789
if (!volumeActor) {

0 commit comments

Comments
 (0)