Hi, I have tried to add a track, but its not appearing on the board.
Here is my code in my code that does the track add. Is in
edit_tool_move_fct.cpp (1259)
printf( "*** Adding new track to board ***\r\n" );
std::vector<BOARD_ITEM*> bulkAddedItems;
PCB_TRACK* pcbTrackOfItem =
dynamic_cast<PCB_TRACK*>( item );
auto newTrack = new PCB_TRACK(
pcbTrackOfItem );
BOARD_ITEM* newBoardItem =
dynamic_cast<BOARD_ITEM*>( newTrack );
newBoardItem->SetPosition(
nearestEndLocation[itemCount] );
dynamic_cast<PCB_TRACK*>( newBoardItem )->SetEnd(
furtherestEndLocation[itemCount] );
board->Add( newBoardItem, ADD_MODE::BULK_INSERT,
false );
bulkAddedItems.push_back( newBoardItem );
board->FinalizeBulkAdd( bulkAddedItems );
.. and later
newBoardItem->SetModified();
Can anyone spot the issue with my code and why I would not get a track
showing up?
Ta
Stuart
On Saturday, July 15, 2023 at 1:29:04 PM UTC+1 Stuart Tyler wrote:
> I have updated the code and I think the geometry manipulation is now close.
> Please note the move multiple tracks key press that I have coded up is
> Alt-M, not Ctrl-M.
>
> Just need some help on adding tracks to a pcb so that the solution can be
> fully visualised. There are probably a few other corner cases that need
> handling yet, but its probably useable once the track adds are fixed.
>
> Ta
> Stuart
>
>
> On Saturday, July 15, 2023 at 12:22:49 AM UTC+1 Stuart Tyler wrote:
>
>> 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.
>>
>
--
You received this message because you are subscribed to the Google Groups
"KiCad Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/a/kicad.org/d/msgid/devlist/64d0d1d5-6a24-41c4-8231-a4a721f267c7n%40kicad.org.