Dear Author ul,
Yes, it can be implemented using OCAF framework.
You can communicate us via Contact Form to exchange information about the needs of your company projects and our services and solutions.
Best regards,
Commenter-1
Archived discussion
Hello everyone,
I have a query regarding handling undos and redos for custom defined attributes. I have defined my own attributes classes that inherit from TDF_Attribute class. My question is does the OCAF framework offers a possibility to handle undos and redos if the data contained in my custom defined attributes (that inherit from TDF_Attribute) gets changed in a document?
I have already tried the undos and redos with addition/ removal of labels and attributes in a document and that seems to work fine.
Regards,
Author ul Azam
Discussion
Posts are displayed in their archived order.
Dear Author ul,
Yes, it can be implemented using OCAF framework.
You can communicate us via Contact Form to exchange information about the needs of your company projects and our services and solutions.
Best regards,
Commenter-1
Thank you Commenter-1 for your response. I have found out the solution that works for me. I am sharing it in this thread so that other users of OCCT can benefit from it.
To handle undos/redos when the data contained in custom defined attribute classes gets changed (these attribute classes obviously inherit from TDF_Attribute class) is the following:
1. Implement the pure virtual method (virtual void Restore (const Handle< TDF_Attribute > &anAttribute) = 0) contained in TDF_Attribute class in your custom attribute class. This method actually should set the data of your current object with the data of passed attribute object.
2. Lets say you have a handle to the instance of TDocStd_Document in your application with name document.
Then simply the procedure is to:
i. Open a transaction on this document
ii. Backup your custom attribute in this transaction
iii. Make changes to your custom attribute
iv. Commit the transaction
e.g.
Handle(TDocStd_Document) document; // your document instance
Handle(TDF_Attribute) example_attribute; // your custom attribute
document -> OpenCommand();
example_attribute -> Backup();
// make changes to your attribute
document -> CommitCommand();
// now you will have added one undo in the list of undos
// you can see it
std::cout << document -> GetAvailableUndos() << std::endl;