The intent for this change is to allow faster labeling when there
are streaks of the same label occasionally, but not consistently
enough to enable "default label" mode. With this PR the user can
simply click again to confirm the previous selection, without
having to aim for the OK button, or move either hand to the
ENTER button.
The alignment and position change of the buttons is for two reasons:
- it covers less of the drawn shape, easing verification of the
label to be selected
- the alignment wasn't taken into account for offset calculation.
It works if the dialog is shown, but that causes the dialog to
briefly flicker in the old position. Presumably an `adjustSize`
or similar is needed on more widgets, but I was unable to
figure out which.
The previous variant calculates the delta by checking how many
"image pixels" the cursor was moved, and then emit an absolute
scrollbar move based on that. However, when zoomed in a single
image pixel can be multiple scroll bar units.
The effect was that panning a zoomed in image was very slow,
giving a rubber band kind of effect. Wiggling the mouse would emit
more deltas, eventually moving the image below the cursor again.
This PR uses the absolute coordinates instead, which keeps the
image closer to the cursor. There is still a slight rubber band
effect, probably due to slight differences between painter and
scroll bar positions/units.
The result is that panning a zoomed in image feels less sluggish.
This fixes a crash with the following steps to reproduce:
1. highlight a vertex or shape with the cursor
2. swap image using keyboard controls (i.e. press D)
3. left click on image without moving cursor. No shape may be below
cursor.
What happens is that the canvas will emit a selection signal for
the shape from the previous image, which then can't be found anymore
in `shapes_to_items`, causing this error:
```
Traceback (most recent call last):
File "/home/stefan/code/labelImg/./labelImg.py", line 806, in shape_selection_changed
self.shapes_to_items[shape].setSelected(True)
KeyError: <libs.shape.Shape object at 0x7fdb281d06a0>
```
This builds upon the fix from #858, which fixed the issue for
selected shapes, but not highlights.
The use case is adjusting shapes by moving their vertexes, even if
they are adjacent or overlapping another shape. Currently always
the "later drawn" shape wins, making it impossible to adjust an
earlier shape without re-creating it. Adjusting existing shapes is
common for review scenarios.
I have experimented with preferring the highlighted shape, but
I found it finicky and less clear as to how the vertex preference
works. JOSM (and OpenStreetMap editor) also uses the "prefer
selected" approach and it works well there.
For any shape with a dimension smaller than 2*epsilon, there can be
multiple potential points to select from. In practice this resulted
in e.g. the top right corner being highlighted when the cursor was
placed below the bottom right corner.
* Fix
Error "IndexError: list index out of range" occurs when there is no "predefined_classes.txt".
* Fix an error when default label is null.
Error "IndexError: list index out of range" occurs when there is no "/data/predefined_classes.txt".
* Update README.rst
ADD: Package as a separate exe file method.
* Fixed an error after opening a file to cancel
The cause of the error:
QFileDialog.getOpenFileName(...) second parameter required cannot be empty.
* Fix
Error "IndexError: list index out of range" occurs when there is no "predefined_classes.txt".
* Fix an error when default label is null.
Error "IndexError: list index out of range" occurs when there is no "/data/predefined_classes.txt".
* Update README.rst
ADD: Package as a separate exe file method.
* Modified the default label text box into a drop down
* Unchecked the box at startup
* Removed commented code
* Removed unnecessary update method for the combobox
* Changed naming style for class
In some cases, arithmetic results (in particular from division) on zoom
levels return floats; however, the PyQt API requires int values to
function correctly. Therefore, explicit conversion to int or integer
division has been added for these cases.
A behavior bug causing sudden crashes was fixed. When a rectangular box
is dragged with the right mouse button, but the left mouse button is
touched prior to release of the right mouse button, the program
crashed. The root cause seems to be that this deselects the dragged
object so it is no longer available (i.e. `self.canvas.selected_shape is
None`). The new behavior does nothing / cancels the operation if this
occurs.
Added a shortcut for switching file format (CTRL+Y) since I often use
this functionality.
Steps to reproduce this particular issue:
1. draw a box
2. select the box
3. hover over one of the corners as if you want to resize the box (no click needed)
4. press DEL to delete the box
5. left click on the canvas
Note there are two more destructive operations on the canvas' `shape` in
`undo_last_line` and `reset_all_lines`, but former is dead code and latter
I don't know how to trigger. Thus I can't be sure un-highlighting will not
lead to visual glitches.
There are other potential fixes, e.g. checking in `selected_vertex`. I can
rework the patch, but then again, the fix is so straight forward that telling
me is probably more effort than just rewriting it.
See #750
See #605