fritzing / fritzing-app

Fritzing desktop application
http://fritzing.org
Other
3.87k stars 814 forks source link

Automatic terminal points (schematic) #4130

Closed KjellMorgenstern closed 1 week ago

KjellMorgenstern commented 3 months ago

Problem

We have quite frequently parts with incorrect or missing terminal points, especially in the schematic. Even if done correctly, the additional amount of work and error checking is considerable. At least I messed them up already many times, and had to go through another iteration when testing a new part in Fritzing. From the number of errors about this, I think I am not the only one.

Proposed Solution

Automatic terminal points, add a new default for schematic view:

Rules:

Note: Fritzing Parts Editor uses center, north, east, south, west, and does not know about "auto". This is a bit more work to adapt, because it immediately translates these into coordinates. To align the editor with Fritzing, we could still add terminalPos in the future. But for now it is not sure if we need it.

I also considered using a "terminalPos" attribute, that could then be "east, south, west, north, center, auto". A bit less code would be to have magic terminalIDs instead of terminalPos, but also that sounds a but hacky.

I think adding an automatic default for the schematic view is the easiest way to do it, and clean enough.

KjellMorgenstern commented 3 months ago

Related: Pads in the PCB view already support user defined terminal points: image

Can we allow this as an option, so all parts could enable that feature for their connectors?

mMerlin commented 3 months ago

That should work for 99+% of the cases. I worked on a part where it might cause issues, without keeping an override to specify where the terminal is. A board that had a user selectable jumper to choose pin functionality. That was represented in schematic as a 'internal' (inside the body of the image) connection points, that needed a wire from one to either of the other 2. The automatic calculation would get the wrong (outer) end for those.

KjellMorgenstern commented 3 months ago

The current mechanism with the terminalID and a rectangle with that ID will continue to work. So, existing parts would not change, except for those that currently don't have a terminalID in the schematic, which is probably a bug anyways.

Also, this will not on its own fix parts that have a zero size terminal element. The problem is that such elements are removed early by QSvgRenderer, and we would need an extra pass on the xml to identify and inflate them ( I don't want to add such a step). In these cases, the FZP has a terminalID, but FSvgRenderer can not match it. One open question is, should Fritzing warn about such unmatched terminalIDs, or should it just ignore / log that and fallback to automatic terminal points?

The first will cause a bit more work, we would have to fix these parts by removing all terminals. The second will be more confusing, because broken terminalIDs would just stay in the part files. We would only remove broken terminalIDs. Removing them on healthy parts would degrade these parts for older versions of Fritzing without any need.

vanepp commented 3 months ago

I like this idea! This is probably the most common part error (no terminalId in schematic which results in a connection to the middle of the pin.) Automatically fixing that would be ideal if it can be done without causing other problems! FritizngCheckPart.py currently checks for this, but in some cases produces false positives for cases (such as circles) where a terminalId isn't sensible.

KjellMorgenstern commented 3 months ago

The rule "square connector: terminal at the center of the connector" checks for the bounding box of the connector, so circles are covered, too. It will set the terminal at the center.

That rule was meant for breadboard and pcb views, but should also work on schematic views. @vanepp Did you observe schematic parts with square or circular connector shapes?

KjellMorgenstern commented 3 months ago

I marked this as solved, right now limited to schematic view.

Created #4132 for the PCB view.

vanepp commented 3 months ago

I was thinking of these screw terminals and can't immediately find another example (although I think I have seen some in non core parts, but am now unsure if they too have proper connectors as well and I am just mis remembering.)

capture

and this one has a proper connector and terminalId.

KjellMorgenstern commented 1 week ago

This fix adds support for automatic terminals. Together with the 1.0.3 we have also fixed a lot of broken terminals by simply removing them (so they become automatic).

However, the fix does not yet detect and override broken terminals, they still need to be removed or fixed manually. An error message is shown in the log for terminals that appear to be broken.