Skip to content

Commit 299c608

Browse files
committed
feat(paint): match brush cursor to selected segment color
1 parent c16a32d commit 299c608

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎src/components/tools/paint/PaintWidget2D.vue‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { VtkViewContext } from '@/src/components/vtk/context';
2424
import { Maybe } from '@/src/types';
2525
import { PaintMode } from '@/src/core/tools/paint';
2626
import { usePaintInteractionMode } from '@/src/segmentation/composables/usePaintInteractionMode';
27+
import { useSegmentStore } from '@/src/segmentation/segments';
2728
import eyedropperCursor from '@/src/assets/eyedropper-cursor.svg?url';
2829
import { useActionHeld } from '@/src/composables/useKeyboardShortcuts';
2930
@@ -70,6 +71,14 @@ export default defineComponent({
7071
7172
// --- widget representation config --- //
7273
74+
const { segments } = useSegmentStore();
75+
watchEffect(() => {
76+
const [r, g, b] = segments.appearanceOf(
77+
segments.selectedSegmentId.value
78+
).color;
79+
widgetState.getBrush().setColor3([r, g, b]);
80+
});
81+
7382
// Every mask uses the parent voxel grid. Selection and mask growth do not
7483
// change the brush's world-space footprint.
7584
watchEffect(() => {

‎src/vtk/PaintBrushContextRepresentation/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ function vtkPaintBrushContextRepresentation(publicAPI, model) {
122122

123123
const actorProperty = model.pipelines.brush.actor.getProperty();
124124
actorProperty.setLineWidth(2);
125-
actorProperty.setColor([1, 0, 0]);
126125
actorProperty.setDisplayLocation(DisplayLocation.FOREGROUND);
127126
actorProperty.setRepresentation(Representation.SURFACE);
128127

@@ -135,6 +134,7 @@ function vtkPaintBrushContextRepresentation(publicAPI, model) {
135134

136135
const stencil = widgetState.getStencil();
137136
const brush = widgetState.getBrush();
137+
actorProperty.setColor(brush.getColor3().map((channel) => channel / 255));
138138
const { indexToWorld, worldToIndex } = model;
139139

140140
if (stencil && brush.getOrigin()) {

‎src/vtk/PaintWidget/state.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export interface PaintPointWidgetState extends vtkWidgetState {
1010
getScale1(): number;
1111
setVisible(visible: boolean): boolean;
1212
getVisible(): boolean;
13-
setColor(color: number): boolean;
14-
getColor(): number;
13+
setColor3(color: Vector3): boolean;
14+
getColor3(): Vector3;
1515
}
1616

1717
export interface PaintWidgetState extends vtkWidgetState {
@@ -26,7 +26,7 @@ export default function generateState() {
2626
.addStateFromMixin({
2727
labels: ['brush'],
2828
name: 'brush',
29-
mixins: ['origin', 'scale1', 'visible', 'color'],
29+
mixins: ['origin', 'scale1', 'visible', 'color3'],
3030
initialValues: {
3131
scale1: 1,
3232
origin: null,

0 commit comments

Comments
 (0)