kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #24658
[RFC] Undo buffer refactoring
-
To:
KiCad Developers <kicad-developers@xxxxxxxxxxxxxxxxxxx>
-
From:
Maciej Sumiński <maciej.suminski@xxxxxxx>
-
Date:
Fri, 13 May 2016 15:08:17 +0200
-
Authentication-results:
spf=pass (sender IP is 188.184.36.50) smtp.mailfrom=cern.ch; lists.launchpad.net; dkim=none (message not signed) header.d=none;lists.launchpad.net; dmarc=bestguesspass action=none header.from=cern.ch;
-
Spamdiagnosticmetadata:
NSPM
-
Spamdiagnosticoutput:
1:23
-
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0
I would like to solve once and for all the problem of GAL view/ratsnest
not being occasionally updated.
I am still getting related bug reports, as there are just many places in
the source code that need to have "item->ViewUpdate();
ratsnest->Update(item)" added.
1. Replace UR_MODEDIT with UR_CHANGED, to avoid repeating
if(IsType(FRAME_PCB)) and stop treating modules in a special way. Make
UR_CHANGED create a MODULE copy?
2. Include OnModify() in SaveCopyInUndoList(), as it is called every
time anyway.
3. Add an Observer interface, so other objects interested in model
changes (e.g. VIEW & RATSNEST) might be notified, when there is an undo
buffer entry created/restored. Observers would have to register
themselves to EDA_DRAW_FRAME, as registering to every single BOARD_ITEM
does not make sense. Notification type can be described with UNDO_REDO_T
enum.
4. It would be also required to notify observers when there is no undo
buffer entry created (e.g. mass track removal, SPECCTRA import), so they
have a chance to react properly.
5. During certain operations (e.g. replacing a footprint), it is
necessary to notify observer twice: when the old BOARD_ITEM is removed
and when the new is added. Otherwise observers will keep stale pointers.
A few more steps to make code more generic:
1. Create BOARD_ITEM_CONTAINER class as a common base class for BOARD &
MODULE.
class BOARD_ITEM_CONTAINER {
Add(BOARD_ITEM*);
Remove/Delete(BOARD_ITEM*);
Remove/DeleteType(KICAD_T);
Count(KICAD_T);
};
2. Add BOARD_ITEM_CONTAINER* PCB_BASE_FRAME::GetModel()
3. Unify undo buffer code, so items are added to/removed (UR_NEW,
UR_DELETED) from the current BOARD_ITEM_CONTAINER.
4. Get rid of UR_MOVED/UR_ROTATED, etc. and store an item copy instead.
Regards,
Orson
Attachment:
signature.asc
Description: OpenPGP digital signature
Follow ups