Skip to content

Allow painting straight lines by holding the shift key#21393

Open
wawanbreton wants to merge 1 commit intomainfrom
paint-lines
Open

Allow painting straight lines by holding the shift key#21393
wawanbreton wants to merge 1 commit intomainfrom
paint-lines

Conversation

@wawanbreton
Copy link
Contributor

@wawanbreton wawanbreton commented Feb 11, 2026

Kooha-2026-02-11-09-05-30.webm

You can now draw straight lines by holding the shift key, and mix free drawing with straight lines.

Requires Ultimaker/Uranium#1024
Suggested in #21377

@github-actions
Copy link
Contributor

Test Results

24 592 tests  ±0   24 590 ✅ ±0   51s ⏱️ -1s
     1 suites ±0        2 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit e2a8604. ± Comparison against base commit 2e1a12c.

@HellAholic HellAholic self-assigned this Feb 11, 2026
@PartySausage
Copy link

PartySausage commented Feb 11, 2026

I tested this out on my 5.11.0 build with the updated controller.py but finding that when I hold the shift key and select the second point to apply the straight line the view is reverting to solid view & exiting paint mode

2026-02-11 13:22:13,226 - DEBUG - [MainThread] UM.Controller._updateActiveView [150]: Setting active view to PaintTool 2026-02-11 13:22:13,248 - DEBUG - [MainThread] UM.View.GL.ShaderProgram.load [62]: Loading [C:\Program Files\UltiMaker Cura 5.11.0\share\cura\plugins\PaintTool\paint.shader]... 2026-02-11 13:22:13,291 - DEBUG - [MainThread] UM.View.GL.ShaderProgram.load [62]: Loading [C:\Program Files\UltiMaker Cura 5.11.0\share\cura\resources\shaders\camera_distance.shader]... 2026-02-11 13:22:33,835 - DEBUG - [MainThread] UM.Controller._updateActiveView [150]: Setting active view to SolidView 2026-02-11 13:22:33,856 - DEBUG - [MainThread] UM.View.GL.ShaderProgram.load [62]: Loading [C:\Program Files\UltiMaker Cura 5.11.0\share\cura\resources\shaders\xray.shader]... 2026-02-11 13:26:16,784 - WARNING - [MainThread] UM.Qt.QtApplication.__onQmlWarning [449]: file:///C:/Program Files/UltiMaker Cura 5.11.0/share/cura/plugins/PaintTool/PaintTool.qml:191:17: Unable to assign [undefined] to int 2026-02-11 13:26:16,786 - DEBUG - [MainThread] UM.Controller._updateActiveView [150]: Setting active view to PaintTool 2026-02-11 13:26:21,797 - DEBUG - [MainThread] UM.Controller._updateActiveView [150]: Setting active view to SolidView 2026-02-11 13:26:21,814 - DEBUG - [MainThread] UM.View.GL.ShaderProgram.load [62]: Loading [C:\Program Files\UltiMaker Cura 5.11.0\share\cura\resources\shaders\xray.shader]... 
@wawanbreton
Copy link
Contributor Author

I tested this out on my 5.11.0 build with the updated controller.py but finding that when I hold the shift key and select the second point to apply the straight line the view is reverting to solid view & exiting paint mode

Then you must have updated only the code in the Cura part, you also need to apply this change: Ultimaker/Uranium#1024. I just found out that it causes some behavior changes in the object selection though, so will provide a fix later.

@PartySausage
Copy link

Then you must have updated only the code in the Cura part, you also need to apply this change: Ultimaker/Uranium#1024. I just found out that it causes some behavior changes in the object selection though, so will provide a fix later.

Yes I applied that, unless the previous version is cached somewhere and it's not being updated

@wawanbreton
Copy link
Contributor Author

Yes I applied that, unless the previous version is cached somewhere and it's not being updated

Indeed, if I remember correctly, on a Windows installation part of the application runs from a frozen version (even if the Python source is also provided). The PaintTool can be updated because it is an "embedded plugin", so not part of the frozen core. But the Controller is part of the core, so there is no way to update it, at least none that I know of. Maybe @rburema or @HellAholic know a way ?

@PartySausage
Copy link

Yes I applied that, unless the previous version is cached somewhere and it's not being updated

Indeed, if I remember correctly, on a Windows installation part of the application runs from a frozen version (even if the Python source is also provided). The PaintTool can be updated because it is an "embedded plugin", so not part of the frozen core. But the Controller is part of the core, so there is no way to update it, at least none that I know of. Maybe @rburema or @HellAholic know a way ?

Ahh That'll be the culprit then... If it's not updatable I'll just have to be patient & wait for 5.12

@rburema
Copy link
Member

rburema commented Feb 11, 2026

I think it might be possible, but not without a whole lot of hassle, and at the risk of breaking the current install. It's better to wait for 5.12 I think, as these changes have been made on top of the in-development 5.12 as well.

@PartySausage
Copy link

I think it might be possible, but not without a whole lot of hassle, and at the risk of breaking the current install. It's better to wait for 5.12 I think, as these changes have been made on top of the in-development 5.12 as well.

I think that's a very good idea. Looking forward to trying some of the new features I've seen popping up :-)

@wawanbreton
Copy link
Contributor Author

I think it might be possible, but not without a whole lot of hassle, and at the risk of breaking the current install. It's better to wait for 5.12 I think, as these changes have been made on top of the in-development 5.12 as well.

I don't will it will make it into 5.12 though. We already have passed feature freeze and this is definitely a new feature 😬 so I am afraid you will have to wait until 5.13...

@PartySausage
Copy link

I think it might be possible, but not without a whole lot of hassle, and at the risk of breaking the current install. It's better to wait for 5.12 I think, as these changes have been made on top of the in-development 5.12 as well.

I don't will it will make it into 5.12 though. We already have passed feature freeze and this is definitely a new feature 😬 so I am afraid you will have to wait until 5.13...
😭

@HellAholic
Copy link
Contributor

HellAholic commented Feb 11, 2026

I have a separate installation of Cura that I use for development, the changes that are in UM require the conan create . --build=missing then I copy over the package that is built manually to that installation. It's just a lazy way of running from source.
So....

I just replaced the key 😝 instead of shift as the modifier, I used Q 🤷

 # Handle Q key for drawing straight lines if event.type == Event.KeyPressEvent: from UM.Event import KeyEvent if cast(KeyEvent, event).key == Qt.Key.Key_Q: self._q_key_pressed = True return True elif event.type == Event.KeyReleaseEvent: from UM.Event import KeyEvent if cast(KeyEvent, event).key == Qt.Key.Key_Q: self._q_key_pressed = False return True 

and the shift pressed was replaced with q_pressed

q_pressed = self._q_key_pressed 

So if you are not hellbent on using shift for testing, you can use the file below, and hold Q
Changes are then contained to Cura plugin only.
PaintTool_Q_Key.zip

image
@PartySausage
Copy link

So if you are not hellbent on using shift for testing, you can use the file below, and hold Q
Changes are then contained to Cura plugin only.
PaintTool.zip

Awesome. Thank You. 😊

From the brief testing I've done so far I do have a couple of observations, which I don't know how relevant they are to the pukka version

After clicking the toolbar button, The paint tool doesn't fully activate until the Q key at least momentarily pressed & you can't paint either freehand or straight lines until you've done that
Similarly, You can't manipulate the view with the mouse or keyboard until the Q button is momentarily pressed. Although menus, icons, buttons, right click, dropdowns & fields still respond the mouse click events

Once the Q button has been pressed the paint tool activates & works as normal in the active session, even when loading new models as long as it's in the same session

Maybe these are the 'behaviour changes' @wawanbreton was referring to earlier

@HellAholic
Copy link
Contributor

HellAholic commented Feb 11, 2026

@PartySausage That one is on me.
The value is not initialized for the key_press bool
open the file and add self._q_key_pressed: bool = False to line 70
Or 👇
PaintTool_Q_Key.zip

Alternative version with Ctrl instead of Q
PaintTool_Ctrl_key.zip

@PartySausage
Copy link

That's great work thanks for the quick turn around on the fix. This is going to save a load of trial & error painting seams.

If I was to ever suggest additional improvements to this feature it would be to have a single point click option which then automatically paints a full vertical seam for the height of the model

@HellAholic
Copy link
Contributor

In scope of the change, I have the following feedback

  • The last coordinate is shared between Seam and Material
    Could we use a dict to store the last coords per paint type allowing for future expansion: dict[str, Optional[numpy.ndarray]] = {}

  • Shift vs Ctrl discussion (or both 😝)
    Shift for drawing lines at (π/4)*Int angle intervals, Ctrl for Flat(ish) line Vs Free-Form

  • The line connects from the last clicked coordinates to the current mouse pointer coordinates. On curved/sloped models we might need a different approach 👇
    drawing_line_curved_surface

@HellAholic HellAholic removed their assignment Feb 11, 2026
@wawanbreton
Copy link
Contributor Author

* The last coordinate is shared between Seam and Material Could we use a dict to store the last coords per paint type allowing for future expansion: `dict[str, Optional[numpy.ndarray]] = {}` 

Makes sense, I overlooked that

* Shift vs Ctrl discussion (or both 😝) Shift for drawing lines at `(π/4)*Int` angle intervals, Ctrl for Flat(ish) line Vs Free-Form 

Drawing π/4-aligned lines could be interesting indeed, that comes together with the idea of drawing a full vertical line

* The line connects from the last clicked coordinates to the current mouse pointer coordinates. On curved/sloped models we might need a different approach 👇 

That would be nice indeed, but painting a consistent line over a curved 3D mesh is much more complex than our currrent approach 😛

@wawanbreton
Copy link
Contributor Author

Once the Q button has been pressed the paint tool activates & works as normal in the active session, even when loading new models as long as it's in the same session

Maybe these are the 'behaviour changes' @wawanbreton was referring to earlier

Nope, but the Q key is not handled as the Shift key, so with Shift you should not have this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants