jim-easterbrook / Photini

An easy to use digital photograph metadata (Exif, IPTC, XMP) editing application.
https://photini.readthedocs.io/
GNU General Public License v3.0
158 stars 24 forks source link

Unable to edit region below #267

Open regexgit opened 1 week ago

regexgit commented 1 week ago

I create 2 polygon regions: photini_bug_1

I don't want to overlap, so I would like to modify the 1st one (the one below) as follows: photini_bug_3

To do this I select the first polygon and and rigth-click on the line, but apparently it was the 2nd polygon that received the event: photini_bug_2

with the error:

14:31:03: ERROR: photini.pyqt: 'PolygonRegion' object has no attribute 'highlight'
Traceback (most recent call last):
  File "/home/gto/.local/lib/python3.9/site-packages/photini/pyqt.py", line 190, in wrapper
    return func(*args, **kwds)
  File "/home/gto/.local/lib/python3.9/site-packages/photini/regions.py", line 350, in contextMenuEvent
    self.new_vertex(event.pos())
  File "/home/gto/.local/lib/python3.9/site-packages/photini/regions.py", line 370, in new_vertex
    self.highlight.setPolygon(polygon)
AttributeError: 'PolygonRegion' object has no attribute 'highlight'

Need to move the 1st one, modify it and put it back in place (no big deal).

Photini 2024.8.2 Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] python-exiv2 0.16.1, exiv2 0.27.7 PyQt 5.15.10, Qt 5.15.2 (idem with PyQt6)

jim-easterbrook commented 1 week ago

Thanks for reporting this - as you can guess, it's not a situation I'd tried. Something else to fix before the next release. (Would not have happened if you could only see one shape at a time!)

You can right-click anywhere inside the polygon, not just on the line, which might help in some cases. The new vertex is created on the nearest edge to where you click.

jim-easterbrook commented 1 week ago

I've just done some tests and I think this bug was fixed in commit 0a52b1e, although that was intended to fix something else.

jim-easterbrook commented 1 week ago

Commit 0a52b1e ensures the active region has a higher Z index than the other regions (i.e. it's on top of them) so it receives the right-click events. An exception is if the active region completely covers another region. In that case the other region has a higher Z index, so you can click on it to select it. Commit 5e133ad3 ensures that unselected regions ignore right-click events.