← Back to team overview

kicad-developers team mailing list archive

Re: BOARD_ITEMs removal

 

On 12/18/2013 09:00 PM, Wayne Stambaugh wrote:
On 12/4/2013 2:06 PM, Maciej Sumiński wrote:
I am digging through the code responsible for BOARD_ITEMs removal and I
have a few questions that are probably easy to answer for people, who
know the source code better than I do.

I have found two places where removal happens:
- void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
called when there is only one item to remove (user pressed the Delete
key when an item was under the cursor)

- void PCB_EDIT_FRAME::Block_Delete()
used for removal of block of items (user selected a block of items,
right-clicked and chose "Delete block")

Why are they handled in a different way? Is it only to avoid multiple
ratsnest compilations or refreshing the whole canvas vs xoring single
items to erase?

There are also various way to remove items:
- void BOARD_ITEM::UnLink() & void BOARD_ITEM::DeleteStructure()
- BOARD_ITEM* BOARD::Remove( BOARD_ITEM* aBoardItem ) & void
BOARD::Delete( BOARD_ITEM* aBoardItem )

I can easily say the difference between BOARD_ITEM::Unlink &
DeleteStructure or BOARD::Remove & BOARD::Delete, but I am not able to
say why BOARD_ITEM::Unlink() and BOARD::Remove() coexist. Do not they
simply remove items from DLISTs stored in the BOARD class?

Thanks in advance,
Orson


Orson,

The only reason I see that BOARD::Remove() has to stay is that
MARKER_PCB and ZONE_CONTAINER objects are not stored DLISTs.  They are
std::vectors so BOARD_ITEM::Unlink() would not remove them from a
vector.  I'm not sure why this was done this way.  If they were changed
to DLISTs, BOARD::Remove() could be eliminated.

Wayne

Thank you for the explanation, it is quite clear now. I am going to investigate if it can be changed without creating new problems, in order to unify this and avoid confusion.

Regards,
Orson


References