Skip to content

Add option to change paint-erase brush size with mouse wheel#63

Merged
Thibault-Pelletier merged 1 commit intomainfrom
change-paint-brush-size-on-shift-wheel
Mar 17, 2026
Merged

Add option to change paint-erase brush size with mouse wheel#63
Thibault-Pelletier merged 1 commit intomainfrom
change-paint-brush-size-on-shift-wheel

Conversation

@Jo-Byr
Copy link
Copy Markdown
Collaborator

@Jo-Byr Jo-Byr commented Feb 2, 2026

No description provided.

@Jo-Byr Jo-Byr marked this pull request as draft February 2, 2026 08:46
@Jo-Byr
Copy link
Copy Markdown
Collaborator Author

Jo-Byr commented Feb 2, 2026

The current implementation prevents changing slice with the wheel when in paint mode (without shift pressed)


def increase_brush_size(self, *_args, **_kwargs):
proxy = self._get_proxy()
proxy.brush_diameter *= 1.1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't 1.1 be a class variable with a default value defined as a global variable ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Thibault-Pelletier should it be defined as a class constant in the segmentation effect, or in the pipeline and passed as a parameter, or somewhere else ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can define it as an instance attribute to make it a bit cleaner.
Adding setter / getter is overkill in my opinion.

@Jo-Byr Jo-Byr force-pushed the change-paint-brush-size-on-shift-wheel branch from e26650f to a96f71e Compare February 2, 2026 08:49
def _on_effect_changed(self, _effect_name: str) -> None:
self._refresh_brush()
if self.is_active():
self.effect.on_brush_diameter_changed.connect(self._set_brush_diameter)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is the best way to connect responsiveness for parameters.

SegmentationEffects manage nodes in the scene and nodes in the scene impact the effect pipeline (when there are any).

The way to connect trame <-> Slicer is usually to monitor for scene changes and then to update the UI accordingly.

In Slicer application, we usually do UI updates from MRML and inverse.
I'll investigate how we can generalize this pattern to handle effects parameters as a whole.

Comment thread trame_slicer/segmentation/segmentation_paint_pipeline.py
Comment thread trame_slicer/segmentation/segmentation_paint_pipeline.py
Comment thread trame_slicer/segmentation/segmentation_effect_paint_erase.py Outdated
Comment thread trame_slicer/segmentation/segmentation_effect_paint_erase.py Outdated
Comment thread trame_slicer/segmentation/segmentation_effect_paint_erase.py Outdated
Comment thread trame_slicer/segmentation/segmentation_effect.py Outdated
Comment thread examples/viewer_lib/logic/segmentation/paint_erase_effect_logic.py Outdated
Comment thread examples/viewer_lib/logic/segmentation/paint_erase_effect_logic.py Outdated
Comment thread examples/viewer_lib/logic/segmentation/paint_erase_effect_logic.py
@Jo-Byr Jo-Byr force-pushed the change-paint-brush-size-on-shift-wheel branch from 407990c to c841eac Compare March 16, 2026 15:36
@Jo-Byr Jo-Byr force-pushed the change-paint-brush-size-on-shift-wheel branch from c841eac to d3bbc80 Compare March 17, 2026 10:13
@Jo-Byr Jo-Byr marked this pull request as ready for review March 17, 2026 10:14
@Thibault-Pelletier
Copy link
Copy Markdown
Collaborator

LGTM

@Thibault-Pelletier Thibault-Pelletier merged commit 7c77aad into main Mar 17, 2026
3 checks passed
@Thibault-Pelletier Thibault-Pelletier deleted the change-paint-brush-size-on-shift-wheel branch March 17, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants