Hi,
I have been busy extending pcbnew to include multiple track dragging functionality. I have made some reasonable progress in getting to understanding the problem and learning new stuff in c++ since I last used it, and lots of KiCad internals, and fun geometry.
Anyway my code is a mess, but my first objective was to understand the geometry, which I have partly sorted out, and there are many corner cases still to resolve. My major issue is that the method EDIT_TOOL::doEndMoveTracksSelection() that does all the work needs to make/break some track and push these back to the pcb.
I have been through the code several times and a bit confused on how to do this at all. I have looked at other pcb tools and get mixed up in various methods at the low level LINE_PLACER, and then how to get this into the pcb through BOARD.
So in my fork of KiCad (
https://gitlab.com/stuarttyler/kicad), branch MultiTrackEndMove, I have modified edit_tool_move_fct.cpp and lines 1244/1312/1332 the existing track is stolen to see an output. This should not happen and new tracks should be formed.
EDIT_TOOL::doEndMoveTracksSelection() started out as a copy of EDIT_TOOL::doMoveSelection()
This was good as it showed me how to handle multiple selections. But it does not do any track additions, so I cannot seem to work that part out.
Is this the best way to share my request? By posting a link to my fork and point to my code?
Currently I have added a new menu item and key press ctrl-M. When there are multiple traces selected, the ends closest to the cursor all move in the direction commanded. There are a few bugs still to resolve, but I think Im about 60% there with the major 3 situations identified. There are a number of fold back situations that need sorting out.
First of all I need help on adding/breaking a trace inside EDIT_TOOL::doEndMoveTracksSelection()
In summary:
sel_items is a vector of BOARD_ITEM*
std::vector<BOARD_ITEM*> sel_items;
item get picked out using a cpp for loop to EDA_ITEM*
for( EDA_ITEM* item : sel_items )
I have worked out how to modify the PCB_TRACK start and end locations
dynamic_cast<PCB_TRACK*>( item )->SetEnd( myNewEndLocation );
But I cannot work out how to break this track into 2, or add a new track to the board.
What I think I want to do is to make a new BOARD_ITEM or EDA_ITEM but I am obviously missing something on PCB_TRACK manipulation and EDIT_TOOL.
Please help.
Thanks Stuart
PS - I know my code is very messy and horrible. I am currently just getting to terms with all the new geometry and method/functions/internals.
PSS - I plan on having something more sensible/presentable in a few weeks.