MoveHandle / Undo
-
On 18/08/2014 at 06:58, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 13-15
Platform: Windows ;
Language(s) : C++ ;---------
Hi,is there a way to prevent swapping the *op with *undo if the user clicks undo after MoveHandle?
My objectdata plugin works with rather complex data managing a kind of a grid consisting of splines, that are connected. These connection data is stored in private memory. The user is able to move these conection points around using handles. Works all perfect unless undo is clicked. Then, the private memory is invalid, since the object is swapped by the undo copy.
I've already overwritte the MoveHandle method, so that it doesn't call GetHandle from the undo copy.
Bool XXX::MoveHandle(BaseObject *op, BaseObject *undo, const Vector &mouse;_pos, LONG hit_id, QUALIFIER qualifier, BaseDraw *bd) { HandleInfo info; GetHandle(op,hit_id,info); SetHandle(op,hit_id,info.CalculateNewPosition(bd, op->GetMg(), mouse_pos),info); return TRUE; }
So I either need to prevent the undo copy swapping and provide a custom undo functionality or I need to find a way, that the undo copy includes the private data.
Any help is very appreciated!
Thanks,
Klaus -
On 18/08/2014 at 08:42, xxxxxxxx wrote:
just found NodeData::CopyTo() and it does the copy of the private data. Undo now restores the data, but certainly not the splines, the child objects of the generator object.
Any ideas? I'm thinking of adding AddUndos for each child, but at which point?
Thanks in advance,
-
On 18/08/2014 at 09:22, xxxxxxxx wrote:
ok. Got it. Just added undos for each child in CopyTo() :
BaseDocument *doc = snode->GetDocument(); if (doc) { BaseObject *cp = ((BaseObject * )snode)->GetDown(); while (cp) { doc->AddUndo(UNDOTYPE_CHANGE, cp); cp = cp->GetNext(); } }