-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Problem] Undo/Redo for sketcher constraints doesn't work correctly #12343
Comments
@PaddleStroke and/or @AjinkyaDahale can one of you guys take a look? |
So if I understand correctly you suggest that the move constraint is done inside a transaction correct? Was this already the case and got broken or is it a feature request? Just to know what I'm looking for. |
@PaddleStroke the redo button going away is more concerning. Apart from that, ideally since we are providing the ability to move the dimensions around they should stay there and be undoable. |
I don't mind. It's probably good to add a transaction because when moving a geometry also a transaction is opened. But this is not my actual point. The bug is that if you press the undo button after moving a constraint it will be removed and it's not possible any more to restore it because the redo button is disabled. If you create and delete a constraint without having moved it the undo/redo works as expected. |
Ok I see, the 'Drag constraint' is not on the undo stack like it should. So doing undo undoes the previous action. At that point the 'Drag constraint' appears which breaks the redo.
|
Ah so comparing drag curve and drag constraint I see that drag curve is doing a Now undoing this transaction still does nothing. It seems that the initial position doesn't seem to be registered anywhere. |
I do not know well the transaction system. Can you please advise : Is that suppose to work?
Or does the command 'actions' has to be 'registered' by wrapping them in 'cmdAppObjectArgs' ? Like drag curve :
|
If we need to use cmdAppObjectArgs, then I guess we need to add a python binding to the moveConstraint function right? And VPSketch does not have a ViewProviderSketchPy.cpp so I guess this needs to be implemented too? |
I don't have a v0.20 but I can confirm the bug in v0.21.
Very strange behaviour. The command shows up in the undo stack but undoing it has no effect. And if a press the Recompute button before dragging the constraint then the command doesn't show up in the undo stack.
Yes, it should work like that.
No, that's not needed. The relevant point is that properties of objects are modified. The document then stores the old values in the transaction objects.
For a correctly working undo/redo all this is not needed. |
Well this is strange then. Because moveConstraint is called at 2 places :
The first thing is that the 'DragConstraint' command is created and commited only in mouseButtonPressed. So the first thing is that undoing it would undo the last call to moveConstraint. So it would virtually be invisible as the constraint moved in mouseMove just before the button release. However I have just commented out the moveConstraint in mouseMove to test. So now the constraint does not move until you release the button. So now the constraint movement is all done during the transaction. |
So what this means is that the function 'moveConstraint' is not changing the properties of the object.
So my guess is that this is not getting saved in the property at this time. So the command is not catching anything. Thoughts? |
I have added #12548 to access the LabelDistance and LabelPosition members of the Constraint class via Python.
To test the code create a sketch with a single line. Add a length constraint and make sure that here isn't another constraint defined. Don't leave the edit mode and execute the code. Now you can press undo & redo and see that the label switches. |
I have discovered the actual problem: |
Yes I noticed that (see above posts). But even commenting out the movement
during mouse Move, the undo was not working correctly.
…On Thu, Feb 22, 2024, 17:31 wwmayer ***@***.***> wrote:
I have discovered the actual problem:
The function moveConstraint() is called for every mouse move event and
internally it directly changes the LabelDistance of the constraint.
When releasing the mouse mouseButtonPressed() is called that opens the
transaction and modifies the constraint. But the LabelDistance is already
set to the latest value and thus the undo/redo doesn't show any effect.
—
Reply to this email directly, view it on GitHub
<#12343 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEYO6MIO6XD7SRYM7PQ5CDTYU5XFFAVCNFSM6AAAAABDDSRBN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJZHAYTQNBTGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Well, I am working on a fix. It's done in several steps:
This already works quite well but is a bit inefficient because using setValues() only needs to be done when the dragging is finished and not for every move event. Thus, I am refactoring moveConstraint() to pass a pointer to the constraint instead of its id. |
…sn't work correctly
…sn't work correctly
Is there an existing issue for this?
Problem description
Result: the length constraint disappears and the redo button is greyed out
Expected result: the constraint should be moved to the old position and the redo button should become active
Full version info
Subproject(s) affected?
Sketcher
Anything else?
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: