← Back to team overview

kicad-developers team mailing list archive

Re: How to SCH_SCREEN::SchematicCleanup?

 

On Tue, Jun 14, 2016 at 7:33 PM, Simon Richter <Simon.Richter@xxxxxxxxxx> wrote:
> Hi,
>
> for net ties, I have to touch the schematic cleanup, because that will
> merge adjacent wires going in the same direction, which is not useful
> for me, as I need all wires going into a tie as separate nets (except
> for ERC, where they are connected).
>
> I'd like to generalize this to "wires are split at junctions and net
> ties." This has an immediate effect of making the Delete key behave the
> same as the Backspace key -- delete a wire segment up to the next junction.
>
> This means that the implementation for the Backspace key can be greatly
> simplified, as we don't have to look out for junctions anymore -- we
> just delete the selected segment and are done.
>
> The Delete key can be given a more useful function: delete across
> corners, but not across junctions. That is a change compared with the
> current implementation, where it would delete a straight wire across
> junctions, but not around a corner. IMO, having a way to delete an
> entire connection quickly is more useful, especially as a one-key undo
> after drawing multiple segments.
>

That sounds great! to that I'd add deleting junctions that have less
than 3 connections after deleting the segment, so deleting the middle
line in:
---*---
|  |  |

Results in:
,-----,
|     |

And this:
  |
--*--
Becomes this after deleting the segment on the right:
  |
--'

This would be for normal junctions of course, not net ties.

> The other questions turning up there are related to the way
> SchematicCleanup works internally.
>
> Right now, it consists of two loops over all schematic elements, with
> the inner loop starting after the current outer element, so for tuples
> (x,y), y > x in almost all cases. Almost, because when an element is
> deleted, the inner loop is restarted from the beginning of the list in
> case the current element was also the one that is now gone.
>
> This is slightly fragile because there is no test that stops a line from
> being merged with itself and subsequently deleted as redundant, but that
> can happen only if the same line was merged already -- so you need three
> redundant lines to trigger that bug.
>
> Other than that, it works well because the only cases handled there are
> wire-wire and junction-junction tuples. However, I need to introduce
> wire-junction tests, so the symmetry is gone. I can see a few ways how
> to proceed here:
>
> 1. Always traverse the entire matrix and start skipping symmetric tests
> after passing the diagonal. This will double the number of iterations,
> but all symmetric tests are skipped in half of them, so the actual
> runtime increase is not that drastic.
>
> 2. Create helper functions with fixed types, and use the appropriate
> parameter order. This is probably the least invasive.
>
> 3. Order the draw list by element type. This would allow us to shave off
> a few more cycles in the O(N^2) cleanup function, but make insertion
> more expensive (although with caching, we can still keep it O(1)). This
> would also make schematic files a bit more easier to compare in version
> control.
>
> 4. Order the draw list by element type and coordinates. This makes
> insertion quite a bit heavier, but saves quite a lot during the cleanup
> as we can terminate the inner loop if the hit boxes for the remaining
> elements can no longer overlap, and it would be really great for
> comparing files in version control as we'd have full normalization.
>
> Questions? Comments?
>
>    Simon
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
>


References