Gmoccapy: Fixes in calculator and tooledit_widget - #4436
Conversation
|
That was quick, thanks. I haven't dug deep into this but I wonder if we should fix it better in tooledit (or additionally). linuxcnc/lib/python/gladevcp/tooledit_widget.py Lines 513 to 523 in bae5676 This would also fix it in this case. But it might be bad if this function gets accidentally a float value which is cut then. |
Calculator no longer hands back float strings when asking for integers Tooledit_widget now truncates float input values to positive integer values for the tool- and pocket number
b1369d0 to
bb1801a
Compare
|
I noticed that the pocket number column currently allows negative integer values, which I don't think is correct? |
I don't know. Maybe one want to disable a tool by setting pocket to -1? |
|
I use duplicate pocket numbers, stacked tools |
Co-authored-by: Hans Unzner <hansunzner@gmail.com>
|
Just checked in Axis gui (if that is anything to go by):
And yes, there is definitely a use for duplicate pocket number. |
|
Okay, but duplicated tool numbers? You would never know which one will be used. |
Yes, those should indeed not be allowed. |
|
I used programs where the tool ID has to be unique, it is tricky to do it without getting in the way when the user is renumbering tools for whatever reason, some thought need be put into that. Although at the final state there should be no duplicates, when user is wanting to do a renumbering, not having any hard blocks (current behavior) allows to have a moment where there are two tools with the same number; the trick is finding a reasonable way to allow renumbering without getting in the way of the renumbering cleanup flow, some kind of message confirmation, same number already in the table, want to swap number? cancel? |
| if col in(1,2): | ||
| try: | ||
| self.model[path][col] = int(new_text) | ||
| self.model[path][col] = abs(int(float(new_text.replace(',', '.')))) |
There was a problem hiding this comment.
abs() silently flips the sign instead of rejecting negative input: typing -3 is stored as +3 with no feedback. Since the stated intent is to match Axis, note that Axis rejects negative pocket numbers with an error rather than flipping the sign. A >= 0 check with reject would match that behavior. This widget is shared with axis, gscreen and qtdragon, so the sign-flip applies to direct cell edits there too. Also, hansu's point about pocket = -1 to disable a tool is still open in the discussion; abs() would make that impossible to express.
There was a problem hiding this comment.
I can't say much about the use of pockets as I don't use a tool changer. But A valid point is to reject negative values rather than inverting them.
| except: | ||
| pass | ||
| # validate input for orientation: check if int and valid range | ||
| elif col == 15: |
There was a problem hiding this comment.
This did not get the same float-tolerant treatment: it still uses plain int(new_text). Direct cell entry of 3.0 is now accepted for tool/pocket but still silently rejected for orientation. Same int(float(...)) pattern, keeping the existing range check, would unify it.
There was a problem hiding this comment.
What are the lines you are referring to? I think the above lines not.
There was a problem hiding this comment.
GitHub displays it weird because is not in the diff
I could imagine to do the check on save. So it's easy to rename the IDs and have duplicate IDs in between. |
|
Generally I cannot really comment since I don't use the tool table much. Check on save seems the most straight forward to me but we would probably also have to check on load since a tool table can easily be edited outside the gui.
I thought this was only shared by gscreen. |
Fixes #4435