Hi Stuart,

The PNS router uses a proxy model of the board, and ITEM is the base class
for these proxy representations.  See pns_item.h
You can get back to the BOARD_ITEM using Parent(), but you may not need to;
the geometry of tracks will be represented inside the proxy ITEMs.=

-Jon

On Mon, Sep 18, 2023 at 4:40 PM Stuart Tyler <[email protected]>
wrote:

> My first sticking point on understanding how to transport my code:
>
> I originally interfaced to the selected parts through selection which was
> loopable as an EDA_ITEM and could dynamic_cast to PCB_TRACK and access the
> track detail.
>
> *** start of code snip ***
>     for( EDA_ITEM* item : selection )
>     {
>         ++count;
>         BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( item );
>         FOOTPRINT*  footprint = dynamic_cast<FOOTPRINT*>( item );
>         PCB_TRACK*  trackItem = dynamic_cast<PCB_TRACK*>( item );
>
>         if (trackItem)
>         {
>             printf( "Item %d was able to be cast to a track start %d , %d
> end %d , %d.\r\n", count,
> *** end of code snip ***
>
> But are now passed in as class ITEM.
>
> *** start of new code snip ***
>     for( ITEM* item : aPrimitives.Items() )
>     {
> *** end of new code snip ***
>
> I am not too sure on how to get to the PCB_TRACK class when given the ITEM
> class.
>
> Getting to the PCB_TRACK class is important to access all the track end
> point data for the algorithm computations. Help appreciated.
>
> Regards
> Stuart Tyler
>
>
> Stuart Tyler wrote:
>
>
> Ok, I have spent some time looking at the branch, getting it to compile
> and understanding the multi-drag extension code. As you say this is not an
> implementation, but a demo of the integration.
>
> I have an algorithm implementation that I want to try out.
>
> What I think I next need to do is to port my code into the branch that you
> have provided. Are you expecting me to commit my edits into your Gitlab
> repo? I am happy to do that, just checking you want me to do that.
>
> My main issue is my poor C++ reading and coding skills. My methods are
> very hacky and I think I have succeeded in proving the algorithm is
> correct, but I am not comfortable in implementing it correctly. I am happy
> for others proficient in C++ to correct my code.
>
> What I spend much time on is 'How do I ....' issues - like, how do I go
> through the list of currently selected track and find the closest one to
> the aP? I know what I want to do to the selected list of tracks, just how
> to code that in C++ is tricky. What I would like to know is: Is there a C++
> coder in the team that would like to spend some time assisting me? I am
> currently in Europe and happy to do a few evenings on knocking this over?
>
> If there is, I am happy to work on this as a team. I use Slack or MSTeams
> or any other platform that would assist in implementing this together. If
> there is no-one available then I will continue to work away slowly on this.
>
> My repo with edit_tools_move_fct.cpp has the core algorithm in it. I am
> going to head off and see if I can transport this code into Toms Github
> example code, and do local commits until I am told I can commit to Toms
> GitHub. Hopefully someone with decent C++ skills can help me out and assist
> in closing this out.
>
> I understand that 8.00 release is near, so I will continue working local
> until I hear something from the team, and I understand if this is not soon.
> I will shout out if I work it out on my own.
>
> Regards
> Stuart Tyler
>
>
> Stuart Tyler wrote:
>
>
> Hi Tom,
>
> Was a great catch up with the developers in Spain.
>
> Thanks for prompting me about the below email and branch. I will get this
> and look at it during this week and attempt to add the algorithm there.
>
> Talk soon.
>
> Regards
> Stuart
>
>
>
> Get BlueMail for Android
> On 24 July 2023, at 4:40 pm, Tomasz Wlostowski <[email protected]>
> wrote:
>>
>> On 18/07/2023 20:06, Stuart Tyler wrote:
>>
>>>  Hi Jon,
>>>
>>>  Thanks for the feedback. Yes, I agree with all your points. I started
>>>  off copying drag track but backed out of this as I got stuck accessing
>>>  the multiple selections, but totally agree with your points.
>>>
>>>  I have not looked through the component dragger as yet and will visit
>>>  that over the next couple of days. I think your comparison is correct -
>>>  I will attempt to follow its track movement and addition style - I now
>>>  understand the algorithm and what is needed at least.
>>>
>>>  Appreciate the pointer to looking at component dragger.
>>>
>>> Hi Stuart,
>>
>> I encourage you to have a look at this branch:
>> https://gitlab.com/twlostow/kicad/-/commits/tom-multidrag-demo-clean
>>
>> It contains a very shitty multi-drag algorithm - but my intention there
>> was not to develop one, but to show how I would see it integrated in the
>> router & tool stack of pcbnew. I hope you can build a decent multi-trace
>> dragger on top of this code.
>>
>> I'll be happy to answer any questions you might have, but be prepared
>> for some delay with responses.
>>
>> Regards,
>> Tom
>>
>>
>>
>>  Regards
>>>  Stuart Tyler
>>>
>>>
>>>
>>>  Jon Evans wrote:
>>>
>>>
>>>  Hi Stuart,
>>>>
>>>>  Some general comments on this project:
>>>>
>>>>  1) This functionality should be built into the router, not into the
>>>>  edit routines outside the router IMO.  So this should be implemented
>>>>  as part of DRAGGER probably.  If you look at how the rest of the
>>>>  router works, you should be able to re-use all its functionality for
>>>>  creating and modifying items in the board.
>>>>
>>>>  2) The functionality you're looking for is at some level similar to
>>>>  the work that is done by the PNS component dragger (since it has to be
>>>>  able to reroute multiple different tracks), so you might get some
>>>>  additional hints from that class.
>>>>
>>>>  3) There is no need for a new action / hotkey.  The existing actions
>>>>  should be able to handle single-track vs multi-track dragging based on
>>>>  what the selection contains.
>>>>
>>>>  Best,
>>>>  Jon
>>>>
>>>>  On Tue, Jul 18, 2023 at 1:44 PM Stuart Tyler <[email protected]
>>>>  <mailto:[email protected]>> wrote:
>>>>
>>>>      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
>>>>              <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]
>>>>      <mailto:[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
>>>>  
>>>> <https://groups.google.com/a/kicad.org/d/msgid/devlist/64d0d1d5-6a24-41c4-8231-a4a721f267c7n%40kicad.org?utm_medium=email&utm_source=footer>.
>>>>
>>>
>>>  --
>>>  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]
>>>  <mailto:[email protected]>.
>>>  To view this discussion on the web visit
>>>  
>>> https://groups.google.com/a/kicad.org/d/msgid/devlist/4b954b95c8997.e6c27fd20fe7b%40gmail.com
>>>  
>>> <https://groups.google.com/a/kicad.org/d/msgid/devlist/4b954b95c8997.e6c27fd20fe7b%40gmail.com?utm_medium=email&utm_source=footer>.
>>>
>>
>>

-- 
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/CA%2BqGbCDBrCZHbQs2uETFLFQhWW09p3W9B8g4ewsMOTRwT-MHcA%40mail.gmail.com.

Reply via email to