SchematicEditor: Fix net label offset after mirroring #451
…s.cpp Co-Authored-By: U. Bruhin <email@example.com>
Co-Authored-By: U. Bruhin <firstname.lastname@example.org>
Well, proposing changes with incomplete and inconsistent result - not very friendly for contributors.
Please merge changes to your discretion. I see no sense to overcome problems that didn't exist in original pull request.
Unfortunately GitHub Suggestions are not powerful enough to make perfect, fully functional code change suggestions:
After all, I consider this feature just as an alternative to explaining the suggestion in words (code is often easier to write and understand than text). In the end there is often no way to avoid implementing/improving/code-formatting/testing the suggestions locally, and IMHO it would be strange to do all these things before making a suggestion, just to be able to create perfect formatted and tested suggestions (it's still only a suggestion to the PR author, not a strong change request).
Sorry for the inconvenience because it was not clear in advance how my suggestions are meant
Oops, I didn't notice that
newpos.setX(newpos.getX() - netlabel->getWidth().mappedToGrid(*mSchematic.getGridProperties().getInterval()));
Now I also tested your implementation. For horizontal labels it works as expected, but vertical labels (rotation +/- 90° or +/- 270°) they are shifted too far. In that case you should only shift by the height (not width) of the netlabel (which could actually be considered to always be 2.54mm).
Combination of Mirror->Mirror->Rotate->Mirror->Rotate->Mirror in some combinations gives weird results with random offsets to left and right. But seems it has close correlation with overall elements shift. So all operations should have better rotation/mirror center than now.
Thanks for the update!
Maybe that's because you check only for 0° and 180°, but not for -180°. You can check it when first rotating the items clockwise (Shift+R) and mirror afterwards -> offset of netlabels.
Could you fix this too? Then I would say this is ready to merge. Btw, I think