How best to make Undo?

Discussion forum for contributors and developers who are using the QCAD ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Post Reply
pietro_72_
Full Member
Posts: 76
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

How best to make Undo?

Post by pietro_72_ » Mon Feb 10, 2020 2:59 pm

I'm trying to add an Undo method to my program to correct errors made by the user in the construction of the 3D object, should I create a sort of log of the operations performed in order to possibly cancel them?

Currently it does not have a log of the operations performed
Attachments
Redo.svg
(1.25 KiB) Downloaded 5 times
Undo.svg
(1.24 KiB) Downloaded 5 times
OrthogonalProjections.js
(107.15 KiB) Downloaded 5 times
OrthogonalProjections.ui
(16.8 KiB) Downloaded 5 times

User avatar
andrew
Site Admin
Posts: 6562
Joined: Fri Mar 30, 2007 6:07 am

Re: How best to make Undo?

Post by andrew » Mon Feb 10, 2020 3:14 pm

If you are using operations (e.g. RAddObjectsOperation), undo / redo is automatically built in.

pietro_72_
Full Member
Posts: 76
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Re: How best to make Undo?

Post by pietro_72_ » Tue Feb 11, 2020 12:06 am

Thank you

I had used 3

Code: Select all

op = new RModifyObjectsOperation ();
starting at line 1837
in

Code: Select all

OrthogonalProjections.prototype.slotUndo = function () {
in line 1800
to cancel the 3 graphic representations in orthogonal projections of a 3D vertex
you mean in this sense? e_confused
But I don't think that the operations can operate on the multidimensional array that I made in which I save the 3D data, or am I wrong? e_confused (for example see line 1816)

A ... another thing how can I get the name of the path and the dwg / dxf file the user is working on? I thought of making a nearby file with the same name in which to save the data of the 3D entities under construction

User avatar
andrew
Site Admin
Posts: 6562
Joined: Fri Mar 30, 2007 6:07 am

Re: How best to make Undo?

Post by andrew » Tue Feb 11, 2020 10:27 am

pietro_72_ wrote:
Tue Feb 11, 2020 12:06 am
But I don't think that the operations can operate on the multidimensional array that I made in which I save the 3D data, or am I wrong? e_confused (for example see line 1816)
Operations keep track of the changes they make on a document. These changes can be undone / redone. If you change things other than the document, that is not covered.
A ... another thing how can I get the name of the path and the dwg / dxf file the user is working on? I thought of making a nearby file with the same name in which to save the data of the 3D entities under construction
doc.getFileName()

pietro_72_
Full Member
Posts: 76
Joined: Fri Apr 17, 2015 6:40 am
Location: http://creativitainformaticart.altervista.org

Re: How best to make Undo?

Post by pietro_72_ » Tue Feb 11, 2020 2:12 pm

OK thanks

Post Reply

Return to “QCAD Developers and Contributors”