Thu, 05/18/2017 - 19:10
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,
Zia ul Azam
Fri, 05/19/2017 - 19:07
Dear Zia 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,
Forum supervisor
Mon, 12/04/2017 - 19:27
Thank you Forum Supervisor 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.