As per the documentation I have provided following in the Message
method of my NodeData derived plugin:
case MSG_DESCRIPTION_INITUNDO:
{
DescriptionInitUndo* const uData = static_cast<DescriptionInitUndo*>(data);
// check if data and BaseDocument can be accessed
if (!uData || !uData->doc)
break;
// add undo for dependent entities
BaseDocument* const doc = uData->doc;
doc->AddUndo(UNDOTYPE::CHANGE_SMALL, node);
return true;
}
This handles the storage of the description value when changed by user, and is all that is needed to support undo/redo of the NodeData derived plugin parameters in the Attribute manager.
One of the parameters is the rotation angle of a rectangle.
This rectangle is displayed in a UserArea
which the user can select and rotate interactively.
The user can thus enter the value via the Attribute Manager, or handle the rectangle in the UserArea.
However, after manipulation of the rectangle in UserArea I get the NodeData derived object (via a SceneHook), I get it's BaseContainer and sets the rotation parameter.
This is visually updated in the Attribute Manager, but I do not get a MSG_DESCRIPTION_INITUNDO triggered?
- When I manually enter a value in the Attribute Manager and press undo, the value reverts to the previous one.
- When I rotate the rectangle in the UserArea the value in Attribute Manager gets updated. But when I press undo ... value stays the same.
To make the undo work in step 2, I need to perform:
doc->StartUndo();
doc->AddUndo(UNDOTYPE::CHANGE_SMALL, node);
node->SetParameter(RECTANGLE_ROTATION_ID, GeData(angle), DESCFLAGS_SET::NONE);
doc->EndUndo();
Is there a way to avoid having to create the undo myself, and instead trigger the node's MSG_DESCRIPTION_INITUNDO?