Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ function setActiveSegmentIndex(

viewportIds.forEach((viewportId) => {
const toolGroup = getToolGroupForViewport(viewportId);
if (!toolGroup) {
return;
}
invalidateBrushCursor(toolGroup.id);
});
}
Expand Down
10 changes: 6 additions & 4 deletions packages/tools/src/tools/base/ContourSegmentationBaseTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ abstract class ContourSegmentationBaseTool extends ContourBaseTool {

const viewportIds = getViewportIdsWithSegmentation(segmentationId);

const toolGroupIds = viewportIds.map((viewportId) => {
const toolGroup = getToolGroupForViewport(viewportId);
return toolGroup.id;
});
const toolGroupIds = viewportIds
.map((viewportId) => {
const toolGroup = getToolGroupForViewport(viewportId);
return toolGroup?.id;
})
.filter((toolGroupId): toolGroupId is string => toolGroupId != null);

triggerAnnotationRenderForToolGroupIds(toolGroupIds);
}
Expand Down
28 changes: 19 additions & 9 deletions packages/tools/src/tools/segmentation/strategies/BrushStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export type InitializedOperationData = LabelmapToolOperationDataAny & {
viewportIdsToRender: string[];
centerCanvas?: Array<number>;
viewport: Types.IViewport;
}
};
memo?: LabelmapMemo;
modified?: boolean;
};
Expand Down Expand Up @@ -183,18 +183,24 @@ export default class BrushStrategy {
this.configurationName = name;

// Ensuring backwards compatibility - always have a circular cursor if none is defined
const cursorGeometryInitializer = initializers.find(init => init.hasOwnProperty(StrategyCallbacks.CalculateCursorGeometry))
const renderCursorInitializer = initializers.find(init => init.hasOwnProperty(StrategyCallbacks.RenderCursor));
const cursorGeometryInitializer = initializers.find((init) =>
init.hasOwnProperty(StrategyCallbacks.CalculateCursorGeometry)
);
const renderCursorInitializer = initializers.find((init) =>
init.hasOwnProperty(StrategyCallbacks.RenderCursor)
);

if(!cursorGeometryInitializer) {
if (!cursorGeometryInitializer) {
initializers.push({
[StrategyCallbacks.CalculateCursorGeometry]: compositions.circularCursor.calculateCursorGeometry
[StrategyCallbacks.CalculateCursorGeometry]:
compositions.circularCursor.calculateCursorGeometry,
});
}

if(!renderCursorInitializer) {
if (!renderCursorInitializer) {
initializers.push({
[StrategyCallbacks.RenderCursor]: compositions.circularCursor.renderCursor
[StrategyCallbacks.RenderCursor]:
compositions.circularCursor.renderCursor,
});
}

Expand Down Expand Up @@ -263,7 +269,12 @@ export default class BrushStrategy {

const data = getStrategyData({ operationData, viewport, strategy: this });

if (!data) {
if (
!data ||
!data.imageVoxelManager ||
!data.segmentationVoxelManager ||
!data.segmentationImageData
) {
return null;
}

Expand Down Expand Up @@ -411,7 +422,6 @@ export default class BrushStrategy {
enabledElement: Types.IEnabledElement,
operationData: InitializedOperationData
) => void;

}
/**
* Adds a list method to the set of defined methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ function getOrCreateSegmentationVolume(
segmentationId: string
): Types.IImageVolume | undefined {
const { representationData } = getSegmentation(segmentationId);
if (!representationData.Labelmap) {
return;
}

let { volumeId } =
representationData.Labelmap as LabelmapSegmentationDataVolume;

Expand Down
Loading