coralnet-toolbox 0.0.67__py2.py3-none-any.whl → 0.0.68__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- coralnet_toolbox/Explorer/QtDataItem.py +300 -0
- coralnet_toolbox/Explorer/QtExplorer.py +713 -955
- coralnet_toolbox/Explorer/QtSettingsWidgets.py +5 -1
- coralnet_toolbox/QtEventFilter.py +16 -5
- coralnet_toolbox/QtLabelWindow.py +23 -11
- coralnet_toolbox/__init__.py +1 -1
- {coralnet_toolbox-0.0.67.dist-info → coralnet_toolbox-0.0.68.dist-info}/METADATA +11 -6
- {coralnet_toolbox-0.0.67.dist-info → coralnet_toolbox-0.0.68.dist-info}/RECORD +12 -14
- coralnet_toolbox/Explorer/QtAnnotationDataItem.py +0 -97
- coralnet_toolbox/Explorer/QtAnnotationImageWidget.py +0 -183
- coralnet_toolbox/Explorer/QtEmbeddingPointItem.py +0 -30
- {coralnet_toolbox-0.0.67.dist-info → coralnet_toolbox-0.0.68.dist-info}/WHEEL +0 -0
- {coralnet_toolbox-0.0.67.dist-info → coralnet_toolbox-0.0.68.dist-info}/entry_points.txt +0 -0
- {coralnet_toolbox-0.0.67.dist-info → coralnet_toolbox-0.0.68.dist-info}/licenses/LICENSE.txt +0 -0
- {coralnet_toolbox-0.0.67.dist-info → coralnet_toolbox-0.0.68.dist-info}/top_level.txt +0 -0
@@ -457,16 +457,20 @@ class EmbeddingSettingsWidget(QGroupBox):
|
|
457
457
|
self.param2_slider.valueChanged.connect(lambda v: self.param2_value_label.setText(f"{v/10.0:.1f}"))
|
458
458
|
|
459
459
|
elif technique == "PCA":
|
460
|
-
# Disable both rows for PCA
|
460
|
+
# Disable both rows for PCA and reset to minimum values
|
461
461
|
self.param1_label.setEnabled(False)
|
462
462
|
self.param1_slider.setEnabled(False)
|
463
463
|
self.param1_value_label.setEnabled(False)
|
464
464
|
self.param1_label.setText(" ")
|
465
|
+
self.param1_slider.setValue(self.param1_slider.minimum())
|
466
|
+
self.param1_value_label.setText(str(self.param1_slider.minimum()))
|
465
467
|
|
466
468
|
self.param2_label.setEnabled(False)
|
467
469
|
self.param2_slider.setEnabled(False)
|
468
470
|
self.param2_value_label.setEnabled(False)
|
469
471
|
self.param2_label.setText(" ")
|
472
|
+
self.param2_slider.setValue(self.param2_slider.minimum())
|
473
|
+
self.param2_value_label.setText(str(self.param2_slider.minimum()))
|
470
474
|
|
471
475
|
def get_embedding_parameters(self):
|
472
476
|
"""Returns a dictionary of the current embedding parameters."""
|
@@ -72,11 +72,22 @@ class GlobalEventFilter(QObject):
|
|
72
72
|
self.annotation_window.cycle_annotations(1)
|
73
73
|
return True
|
74
74
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
# Delete (backspace or delete key) selected annotations when select tool is active
|
76
|
+
if event.key() == Qt.Key_Delete or event.key() == Qt.Key_Backspace:
|
77
|
+
|
78
|
+
# First, check if the Explorer window exists and is the active window
|
79
|
+
if (self.main_window.explorer_window and
|
80
|
+
self.main_window.explorer_window.isActiveWindow()):
|
81
|
+
|
82
|
+
# If it is, let the Explorer handle its own key press events.
|
83
|
+
# Returning False passes the event along instead of consuming it.
|
84
|
+
return False
|
85
|
+
|
86
|
+
# If Explorer is not active, proceed with the original logic for the main window
|
87
|
+
if self.main_window.select_tool_action.isChecked():
|
88
|
+
if self.annotation_window.selected_annotations:
|
89
|
+
self.annotation_window.delete_selected_annotations()
|
90
|
+
# Consume the event so it doesn't do anything else
|
80
91
|
return True
|
81
92
|
|
82
93
|
# Handle image cycling hotkeys
|
@@ -395,23 +395,35 @@ class LabelWindow(QWidget):
|
|
395
395
|
"""Update the annotation count display with current selection and total count."""
|
396
396
|
annotations = self.annotation_window.get_image_annotations()
|
397
397
|
|
398
|
-
# Check if we're in Explorer mode
|
399
|
-
explorer_selected_count = 0
|
398
|
+
# Check if we're in Explorer mode
|
400
399
|
if (hasattr(self.main_window, 'explorer_window') and
|
401
400
|
self.main_window.explorer_window and
|
402
401
|
hasattr(self.main_window.explorer_window, 'annotation_viewer')):
|
403
|
-
|
402
|
+
|
403
|
+
annotation_viewer = self.main_window.explorer_window.annotation_viewer
|
404
|
+
|
405
|
+
# --- REORDERED LOGIC ---
|
406
|
+
# Priority 1: Always check for a selection in Explorer first.
|
407
|
+
explorer_selected_count = len(annotation_viewer.selected_widgets)
|
408
|
+
if explorer_selected_count > 0:
|
409
|
+
if explorer_selected_count == 1:
|
410
|
+
text = "Annotation: 1"
|
411
|
+
else:
|
412
|
+
text = f"Annotations: {explorer_selected_count}"
|
413
|
+
self.annotation_count_display.setText(text)
|
414
|
+
return # Exit early, selection count is most important.
|
415
|
+
|
416
|
+
# Priority 2: If no selection, THEN check for isolation mode.
|
417
|
+
if annotation_viewer.isolated_mode:
|
418
|
+
count = len(annotation_viewer.isolated_widgets)
|
419
|
+
text = f"Annotations: {count}"
|
420
|
+
self.annotation_count_display.setText(text)
|
421
|
+
return # Exit early
|
404
422
|
|
405
|
-
#
|
423
|
+
# --- ORIGINAL FALLBACK LOGIC (Unchanged) ---
|
406
424
|
annotation_window_selected_count = len(self.annotation_window.selected_annotations)
|
407
425
|
|
408
|
-
|
409
|
-
if explorer_selected_count > 0:
|
410
|
-
if explorer_selected_count == 1:
|
411
|
-
text = f"Annotation: 1"
|
412
|
-
else:
|
413
|
-
text = f"Annotations: {explorer_selected_count}"
|
414
|
-
elif annotation_window_selected_count == 0:
|
426
|
+
if annotation_window_selected_count == 0:
|
415
427
|
text = f"Annotations: {len(annotations)}"
|
416
428
|
elif annotation_window_selected_count > 1:
|
417
429
|
text = f"Annotations: {annotation_window_selected_count}"
|
coralnet_toolbox/__init__.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: coralnet-toolbox
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.68
|
4
4
|
Summary: Tools for annotating and developing ML models for benthic imagery
|
5
5
|
Author-email: Jordan Pierce <jordan.pierce@noaa.gov>
|
6
6
|
License: MIT License
|
@@ -136,12 +136,17 @@ These models enable fast, accurate, and flexible annotation workflows for a wide
|
|
136
136
|
|
137
137
|
<div align="center">
|
138
138
|
|
139
|
-
|
|
139
|
+
| <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Patches.gif" alt="Patch Annotation Tool" width="256" height="256"/><br><sub>**Patch Annotation**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Rectangles.gif" alt="Rectangle Annotation Tool" width="256" height="256"/><br><sub>**Rectangle Annotation**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Polygons.gif" alt="Polygon Annotation Tool" width="256" height="256"/><br><sub>**(Multi) Polygon Annotation**</sub> |
|
140
140
|
|:--:|:--:|:--:|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
| <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Classification.gif" alt="Patch-based Image Classification" width="256" height="256"/><br><sub>**Image Classification**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Object_Detection.gif" alt="Object Detection" width="256" height="256"/><br><sub>**Object Detection**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Instance_Segmentation.gif" alt="Instance Segmentation" width="256" height="256"/><br><sub>**Instance Segmentation**</sub> |
|
142
|
+
| <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Segment_Anything.gif" alt="Segment Anything Model (SAM)" width="256" height="256"/><br><sub>**Segment Anything (SAM)**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Classifying_Polygons.gif" alt="Polygon Classification" width="256" height="256"/><br><sub>**Polygon Classification**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Work_Areas.gif" alt="Region-based Detection" width="256" height="256"/><br><sub>**Region-based Detection**</sub> |
|
143
|
+
| <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Cut.gif" alt="Cut" width="256" height="256"/><br><sub>**Cut**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Combine.gif" alt="Combine" width="256" height="256"/><br><sub>**Combine**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Simplify.gif" alt="Simplify" width="256" height="256"/><br><sub>**Simplify**</sub> |
|
144
|
+
| <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/See_Anything.gif" alt="See Anything (YOLOE)" width="256" height="256"/><br><sub>**See Anything (YOLOE)**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Classifying_Orthomosaics.gif" alt="Patch-based LAI Classification" width="256" height="256"/><br><sub>**LAI Classification**</sub> | |
|
145
|
+
|
146
|
+
<br>
|
147
|
+
|
148
|
+
| <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Analytics.gif" alt="Video Inference" width="450"/><br><sub>**Video Inference**</sub> | <img src="https://raw.githubusercontent.com/Jordan-Pierce/CoralNet-Toolbox/refs/heads/main/figures/tools/Explorer.gif" alt="Explorer" width="450"/><br><sub>**Explorer**</sub> |
|
149
|
+
|:--:|:--:|
|
145
150
|
|
146
151
|
</div>
|
147
152
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
coralnet_toolbox/QtAnnotationWindow.py,sha256=ohYkvUdUAdNmZJXqKtCGnnXQ3cPtnSkFEtwH_mWnn3c,37808
|
2
2
|
coralnet_toolbox/QtConfidenceWindow.py,sha256=L5hR23uW91GpqnsNS9R1XF3zCTe2aU7w0iDoQMV0oyE,16190
|
3
|
-
coralnet_toolbox/QtEventFilter.py,sha256=
|
3
|
+
coralnet_toolbox/QtEventFilter.py,sha256=RpZpJjvO4MIblYRry3s_3v1OyyDP_-w0Lf9QIR8PJZM,6602
|
4
4
|
coralnet_toolbox/QtImageWindow.py,sha256=vLziMSEWFfVRSBN0nUNkosgk3LiNxZDqPwbinz9ZivQ,49356
|
5
|
-
coralnet_toolbox/QtLabelWindow.py,sha256
|
5
|
+
coralnet_toolbox/QtLabelWindow.py,sha256=-4GCk4pTY9g4ADH1iE__4xwqT-7UR_7VCT8v-bJzerk,50869
|
6
6
|
coralnet_toolbox/QtMainWindow.py,sha256=kkd27oCLnrwQkTi_dxcPE83gJg4ZSMy7MJdPW2qJ1FE,110105
|
7
7
|
coralnet_toolbox/QtPatchSampling.py,sha256=Ehj06auBGfQwIruLNYQjF8eFOCpl8G72p42UXXb2mUo,29013
|
8
8
|
coralnet_toolbox/QtProgressBar.py,sha256=pnozUOcVjfO_yTS9z8wOMPcrrrOtG_FeCknTcdI6eyk,6250
|
9
9
|
coralnet_toolbox/QtWorkArea.py,sha256=YXRvHQKpWUtWyv_o9lZ8rmxfm28dUOG9pmMUeimDhQ4,13578
|
10
|
-
coralnet_toolbox/__init__.py,sha256=
|
10
|
+
coralnet_toolbox/__init__.py,sha256=NKSxRf_um61feYVSn-Ok9M8drT3lJjt668eGAffey2c,207
|
11
11
|
coralnet_toolbox/main.py,sha256=6j2B_1reC_KDmqvq1C0fB-UeSEm8eeJOozp2f4XXMLQ,1573
|
12
12
|
coralnet_toolbox/utilities.py,sha256=eUkxXuWaNFH83LSW-KniwujkXKJ2rK04czx3k3OPiAY,27115
|
13
13
|
coralnet_toolbox/Annotations/QtAnnotation.py,sha256=I2Givo3p92gfyVYnnFHBjxso-hmQCCXM531Pygiebfw,29242
|
@@ -35,11 +35,9 @@ coralnet_toolbox/Common/QtUpdateImagePaths.py,sha256=_hJYx6hXdAOfH_m77f75AQduQ0W
|
|
35
35
|
coralnet_toolbox/CoralNet/QtAuthenticate.py,sha256=Y__iY0Kcosz6AOV7dlJBwiB6Hte40wHahHe-OmRngZA,13267
|
36
36
|
coralnet_toolbox/CoralNet/QtDownload.py,sha256=HBb8TpZRIEFirGIaIAV1v8qg3fL4cP6Bf-hUiqXoiLE,48516
|
37
37
|
coralnet_toolbox/CoralNet/__init__.py,sha256=ILkAZh6mlAK1UaCCZjCB9JZxd-oY4cIgfnIC8UgjjIU,188
|
38
|
-
coralnet_toolbox/Explorer/
|
39
|
-
coralnet_toolbox/Explorer/
|
40
|
-
coralnet_toolbox/Explorer/
|
41
|
-
coralnet_toolbox/Explorer/QtExplorer.py,sha256=cyo6X4W2pbIJqj-QFtbGk328Fmw63D9XxCIriGl2WMI,90169
|
42
|
-
coralnet_toolbox/Explorer/QtSettingsWidgets.py,sha256=9SUcGaxBBoIDWNhjKGzJoJ4iFwvg1Om4XmZ9T4WsjrE,20584
|
38
|
+
coralnet_toolbox/Explorer/QtDataItem.py,sha256=7IT6sViN1yqkifrSHHXRz1l3ty9ln37H1NMLYa-OphU,11930
|
39
|
+
coralnet_toolbox/Explorer/QtExplorer.py,sha256=fMto27Op99PE9vdNhYwXic7_0V7LvOwnG-ZFEGKKGaA,79066
|
40
|
+
coralnet_toolbox/Explorer/QtSettingsWidgets.py,sha256=hAdRkWwfa42mC9jJ370VOx_-4dxj7D-qzsN8hlNw4j4,20910
|
43
41
|
coralnet_toolbox/Explorer/__init__.py,sha256=wZPhf2oaUUyIQ2WK48Aj-4q1ENIZG2dGl1HF_mjhI6w,116
|
44
42
|
coralnet_toolbox/IO/QtExportAnnotations.py,sha256=xeaS0BukC3cpkBIGT9DXRqHmvHhp-vOU47h6EoANpNg,4474
|
45
43
|
coralnet_toolbox/IO/QtExportCoralNetAnnotations.py,sha256=4royhF63EmeOlSIBX389EUjjvE-SF44_maW6qm52mdA,2778
|
@@ -216,9 +214,9 @@ coralnet_toolbox/Tools/QtTool.py,sha256=2MCjT151gYBN8KbsK0GX4WOrEg1uw3oeSkp7Elw1
|
|
216
214
|
coralnet_toolbox/Tools/QtWorkAreaTool.py,sha256=-CDrEPenOdSI3sf5wn19Cip4alE1ef7WsRDxQFDkHlc,22162
|
217
215
|
coralnet_toolbox/Tools/QtZoomTool.py,sha256=F9CAoABv1jxcUS7dyIh1FYjgjOXYRI1xtBPNIR1g62o,4041
|
218
216
|
coralnet_toolbox/Tools/__init__.py,sha256=218iQ8IFXIkKXiUDVYtXk9e08UY9-LhHjcryaJAanQ0,797
|
219
|
-
coralnet_toolbox-0.0.
|
220
|
-
coralnet_toolbox-0.0.
|
221
|
-
coralnet_toolbox-0.0.
|
222
|
-
coralnet_toolbox-0.0.
|
223
|
-
coralnet_toolbox-0.0.
|
224
|
-
coralnet_toolbox-0.0.
|
217
|
+
coralnet_toolbox-0.0.68.dist-info/licenses/LICENSE.txt,sha256=AURacZ_G_PZKqqPQ9VB9Sqegblk67RNgWSGAYKwXXMY,521
|
218
|
+
coralnet_toolbox-0.0.68.dist-info/METADATA,sha256=8bXO26D1r1thJ7dWD73C1PBHE2YkkBQi88O58lkZtjE,17872
|
219
|
+
coralnet_toolbox-0.0.68.dist-info/WHEEL,sha256=JNWh1Fm1UdwIQV075glCn4MVuCRs0sotJIq-J6rbxCU,109
|
220
|
+
coralnet_toolbox-0.0.68.dist-info/entry_points.txt,sha256=oEeMoDlJ_2lq95quOeDHIx9hZpubUlSo80OLtgbcrbM,63
|
221
|
+
coralnet_toolbox-0.0.68.dist-info/top_level.txt,sha256=SMWPh4_9JfB8zVpPOOvjucV2_B_hvWW7bNWmMjG0LsY,17
|
222
|
+
coralnet_toolbox-0.0.68.dist-info/RECORD,,
|
@@ -1,97 +0,0 @@
|
|
1
|
-
import warnings
|
2
|
-
|
3
|
-
import os
|
4
|
-
|
5
|
-
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
6
|
-
|
7
|
-
|
8
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
9
|
-
# Classes
|
10
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
11
|
-
|
12
|
-
|
13
|
-
class AnnotationDataItem:
|
14
|
-
"""Holds annotation information for consistent display across viewers."""
|
15
|
-
|
16
|
-
def __init__(self, annotation, embedding_x=None, embedding_y=None, embedding_id=None):
|
17
|
-
self.annotation = annotation
|
18
|
-
self.embedding_x = embedding_x if embedding_x is not None else 0.0
|
19
|
-
self.embedding_y = embedding_y if embedding_y is not None else 0.0
|
20
|
-
self.embedding_id = embedding_id if embedding_id is not None else 0
|
21
|
-
self._is_selected = False
|
22
|
-
self._preview_label = None
|
23
|
-
self._original_label = annotation.label
|
24
|
-
self._marked_for_deletion = False # Track deletion status
|
25
|
-
|
26
|
-
@property
|
27
|
-
def effective_label(self):
|
28
|
-
"""Get the current effective label (preview if exists, otherwise original)."""
|
29
|
-
return self._preview_label if self._preview_label else self.annotation.label
|
30
|
-
|
31
|
-
@property
|
32
|
-
def effective_color(self):
|
33
|
-
"""Get the effective color for this annotation."""
|
34
|
-
return self.effective_label.color
|
35
|
-
|
36
|
-
@property
|
37
|
-
def is_selected(self):
|
38
|
-
"""Check if this annotation is selected."""
|
39
|
-
return self._is_selected
|
40
|
-
|
41
|
-
def set_selected(self, selected):
|
42
|
-
"""Set the selection state."""
|
43
|
-
self._is_selected = selected
|
44
|
-
|
45
|
-
def set_preview_label(self, label):
|
46
|
-
"""Set a preview label for this annotation."""
|
47
|
-
self._preview_label = label
|
48
|
-
|
49
|
-
def clear_preview_label(self):
|
50
|
-
"""Clear the preview label and revert to original."""
|
51
|
-
self._preview_label = None
|
52
|
-
|
53
|
-
def has_preview_changes(self):
|
54
|
-
"""Check if this annotation has preview changes."""
|
55
|
-
return self._preview_label is not None
|
56
|
-
|
57
|
-
def mark_for_deletion(self):
|
58
|
-
"""Mark this annotation for deletion."""
|
59
|
-
self._marked_for_deletion = True
|
60
|
-
|
61
|
-
def unmark_for_deletion(self):
|
62
|
-
"""Unmark this annotation for deletion."""
|
63
|
-
self._marked_for_deletion = False
|
64
|
-
|
65
|
-
def is_marked_for_deletion(self):
|
66
|
-
"""Check if this annotation is marked for deletion."""
|
67
|
-
return self._marked_for_deletion
|
68
|
-
|
69
|
-
def apply_preview_permanently(self):
|
70
|
-
"""Apply the preview label permanently to the annotation."""
|
71
|
-
if self._preview_label:
|
72
|
-
self.annotation.update_label(self._preview_label)
|
73
|
-
self.annotation.update_user_confidence(self._preview_label)
|
74
|
-
self._original_label = self._preview_label
|
75
|
-
self._preview_label = None
|
76
|
-
return True
|
77
|
-
return False
|
78
|
-
|
79
|
-
def get_display_info(self):
|
80
|
-
"""Get display information for this annotation."""
|
81
|
-
return {
|
82
|
-
'id': self.annotation.id,
|
83
|
-
'label': self.effective_label.short_label_code,
|
84
|
-
'confidence': self.get_effective_confidence(),
|
85
|
-
'type': type(self.annotation).__name__,
|
86
|
-
'image': os.path.basename(self.annotation.image_path),
|
87
|
-
'embedding_id': self.embedding_id,
|
88
|
-
'color': self.effective_color
|
89
|
-
}
|
90
|
-
|
91
|
-
def get_effective_confidence(self):
|
92
|
-
"""Get the effective confidence value."""
|
93
|
-
if self.annotation.verified and hasattr(self.annotation, 'user_confidence') and self.annotation.user_confidence:
|
94
|
-
return list(self.annotation.user_confidence.values())[0]
|
95
|
-
elif hasattr(self.annotation, 'machine_confidence') and self.annotation.machine_confidence:
|
96
|
-
return list(self.annotation.machine_confidence.values())[0]
|
97
|
-
return 0.0
|
@@ -1,183 +0,0 @@
|
|
1
|
-
import warnings
|
2
|
-
|
3
|
-
from PyQt5.QtGui import QPen, QColor, QPainter
|
4
|
-
from PyQt5.QtCore import Qt, QTimer
|
5
|
-
|
6
|
-
from PyQt5.QtWidgets import (QVBoxLayout, QLabel, QWidget)
|
7
|
-
|
8
|
-
|
9
|
-
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
10
|
-
|
11
|
-
|
12
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
13
|
-
# Constants
|
14
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
15
|
-
|
16
|
-
ANNOTATION_WIDTH = 5
|
17
|
-
|
18
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
19
|
-
# Classes
|
20
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
21
|
-
|
22
|
-
|
23
|
-
class AnnotationImageWidget(QWidget):
|
24
|
-
"""Widget to display a single annotation image crop with selection support."""
|
25
|
-
|
26
|
-
def __init__(self, data_item, widget_height=96, annotation_viewer=None, parent=None):
|
27
|
-
super(AnnotationImageWidget, self).__init__(parent)
|
28
|
-
self.data_item = data_item
|
29
|
-
self.annotation = data_item.annotation
|
30
|
-
self.annotation_viewer = annotation_viewer
|
31
|
-
|
32
|
-
self.widget_height = widget_height
|
33
|
-
self.aspect_ratio = 1.0 # Default to a square aspect ratio
|
34
|
-
self.pixmap = None # Cache the original, unscaled pixmap
|
35
|
-
|
36
|
-
self.animation_offset = 0
|
37
|
-
self.animation_timer = QTimer(self)
|
38
|
-
self.animation_timer.timeout.connect(self._update_animation_frame)
|
39
|
-
self.animation_timer.setInterval(75)
|
40
|
-
|
41
|
-
self.setup_ui()
|
42
|
-
self.load_and_set_image() # Changed from load_annotation_image
|
43
|
-
|
44
|
-
def setup_ui(self):
|
45
|
-
"""Set up the basic UI with a label for the image."""
|
46
|
-
layout = QVBoxLayout(self)
|
47
|
-
layout.setContentsMargins(4, 4, 4, 4)
|
48
|
-
|
49
|
-
self.image_label = QLabel()
|
50
|
-
self.image_label.setAlignment(Qt.AlignCenter)
|
51
|
-
self.image_label.setScaledContents(True)
|
52
|
-
self.image_label.setStyleSheet("border: none;")
|
53
|
-
|
54
|
-
layout.addWidget(self.image_label)
|
55
|
-
|
56
|
-
def load_and_set_image(self):
|
57
|
-
"""Load image, calculate its aspect ratio, and set the widget's initial size."""
|
58
|
-
try:
|
59
|
-
# Use get_cropped_image_graphic() to get the QPixmap
|
60
|
-
cropped_pixmap = self.annotation.get_cropped_image_graphic()
|
61
|
-
if cropped_pixmap and not cropped_pixmap.isNull():
|
62
|
-
self.pixmap = cropped_pixmap
|
63
|
-
# Safely calculate aspect ratio
|
64
|
-
if self.pixmap.height() > 0:
|
65
|
-
self.aspect_ratio = self.pixmap.width() / self.pixmap.height()
|
66
|
-
else:
|
67
|
-
self.aspect_ratio = 1.0
|
68
|
-
else:
|
69
|
-
self.image_label.setText("No Image\nAvailable")
|
70
|
-
self.pixmap = None
|
71
|
-
self.aspect_ratio = 1.0
|
72
|
-
except Exception as e:
|
73
|
-
print(f"Error loading annotation image: {e}")
|
74
|
-
self.image_label.setText("Error\nLoading Image")
|
75
|
-
self.pixmap = None
|
76
|
-
self.aspect_ratio = 1.0
|
77
|
-
|
78
|
-
# Trigger an initial size update
|
79
|
-
self.update_height(self.widget_height)
|
80
|
-
|
81
|
-
def update_height(self, new_height):
|
82
|
-
"""Updates the widget's height and rescales its width and content accordingly."""
|
83
|
-
self.widget_height = new_height
|
84
|
-
|
85
|
-
# Calculate the new width based on the stored aspect ratio
|
86
|
-
new_width = int(self.widget_height * self.aspect_ratio)
|
87
|
-
|
88
|
-
# Set the new fixed size for the entire widget
|
89
|
-
self.setFixedSize(new_width, new_height)
|
90
|
-
|
91
|
-
if self.pixmap:
|
92
|
-
# Scale the cached pixmap to fit the new widget size, leaving room for the border
|
93
|
-
# Note: We use the widget's new dimensions directly
|
94
|
-
scaled_pixmap = self.pixmap.scaled(
|
95
|
-
new_width - 8, # Account for horizontal margins
|
96
|
-
new_height - 8, # Account for vertical margins
|
97
|
-
Qt.KeepAspectRatio,
|
98
|
-
Qt.SmoothTransformation
|
99
|
-
)
|
100
|
-
self.image_label.setPixmap(scaled_pixmap)
|
101
|
-
|
102
|
-
self.update() # Schedule a repaint if needed
|
103
|
-
|
104
|
-
# Replace update_size with update_height
|
105
|
-
def update_size(self, new_size):
|
106
|
-
"""Kept for compatibility, redirects to update_height."""
|
107
|
-
self.update_height(new_size)
|
108
|
-
|
109
|
-
def set_selected(self, selected):
|
110
|
-
"""Set the selection state and update visual appearance."""
|
111
|
-
was_selected = self.is_selected()
|
112
|
-
|
113
|
-
# Update the shared data item
|
114
|
-
self.data_item.set_selected(selected)
|
115
|
-
|
116
|
-
# Start or stop the animation timer based on the new selection state
|
117
|
-
if selected:
|
118
|
-
if not self.animation_timer.isActive():
|
119
|
-
self.animation_timer.start()
|
120
|
-
else:
|
121
|
-
if self.animation_timer.isActive():
|
122
|
-
self.animation_timer.stop()
|
123
|
-
# Reset offset when deselected to ensure a consistent starting look
|
124
|
-
self.animation_offset = 0
|
125
|
-
|
126
|
-
# A repaint is needed if the selection state changed OR if the item remains
|
127
|
-
# selected (to keep the animation running).
|
128
|
-
if was_selected != selected or selected:
|
129
|
-
self.update()
|
130
|
-
|
131
|
-
def is_selected(self):
|
132
|
-
"""Return whether this widget is selected via the data item."""
|
133
|
-
return self.data_item.is_selected
|
134
|
-
|
135
|
-
def _update_animation_frame(self):
|
136
|
-
"""Update the animation offset and schedule a repaint."""
|
137
|
-
self.animation_offset = (self.animation_offset + 1) % 20
|
138
|
-
self.update()
|
139
|
-
|
140
|
-
def paintEvent(self, event):
|
141
|
-
"""Handle custom drawing for the widget, including the border."""
|
142
|
-
super().paintEvent(event)
|
143
|
-
painter = QPainter(self)
|
144
|
-
painter.setRenderHint(QPainter.Antialiasing)
|
145
|
-
|
146
|
-
# Get the label that is currently active (which could be a preview)
|
147
|
-
effective_label = self.data_item.effective_label
|
148
|
-
|
149
|
-
# Check if the active label is the special "Review" label (id == "-1")
|
150
|
-
if effective_label and effective_label.id == "-1":
|
151
|
-
# If it is, ALWAYS use a black pen for visibility against the white background.
|
152
|
-
pen_color = QColor("black")
|
153
|
-
else:
|
154
|
-
# Otherwise, use the effective color from the data item.
|
155
|
-
pen_color = self.data_item.effective_color
|
156
|
-
|
157
|
-
if self.is_selected():
|
158
|
-
pen = QPen(pen_color, ANNOTATION_WIDTH)
|
159
|
-
pen.setStyle(Qt.CustomDashLine)
|
160
|
-
pen.setDashPattern([2, 3])
|
161
|
-
pen.setDashOffset(self.animation_offset)
|
162
|
-
else:
|
163
|
-
pen = QPen(pen_color, ANNOTATION_WIDTH)
|
164
|
-
pen.setStyle(Qt.SolidLine)
|
165
|
-
|
166
|
-
painter.setPen(pen)
|
167
|
-
painter.setBrush(Qt.NoBrush)
|
168
|
-
|
169
|
-
width = pen.width()
|
170
|
-
half_width = (width - 1) // 2
|
171
|
-
rect = self.rect().adjusted(half_width, half_width, -half_width, -half_width)
|
172
|
-
painter.drawRect(rect)
|
173
|
-
|
174
|
-
def mousePressEvent(self, event):
|
175
|
-
"""Handle mouse press events for selection."""
|
176
|
-
if event.button() == Qt.LeftButton:
|
177
|
-
if self.annotation_viewer and hasattr(self.annotation_viewer, 'handle_annotation_selection'):
|
178
|
-
self.annotation_viewer.handle_annotation_selection(self, event)
|
179
|
-
# Ignore right mouse button clicks - don't call super() to prevent any selection
|
180
|
-
elif event.button() == Qt.RightButton:
|
181
|
-
event.ignore()
|
182
|
-
return
|
183
|
-
super().mousePressEvent(event)
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import warnings
|
2
|
-
|
3
|
-
from PyQt5.QtWidgets import QGraphicsEllipseItem, QStyle
|
4
|
-
|
5
|
-
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
6
|
-
|
7
|
-
|
8
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
9
|
-
# Classes
|
10
|
-
# ----------------------------------------------------------------------------------------------------------------------
|
11
|
-
|
12
|
-
|
13
|
-
class EmbeddingPointItem(QGraphicsEllipseItem):
|
14
|
-
"""
|
15
|
-
A custom QGraphicsEllipseItem that prevents the default selection
|
16
|
-
rectangle from being drawn, and dynamically gets its color from the
|
17
|
-
shared AnnotationDataItem.
|
18
|
-
"""
|
19
|
-
|
20
|
-
def paint(self, painter, option, widget):
|
21
|
-
# Get the shared data item, which holds the current state
|
22
|
-
data_item = self.data(0)
|
23
|
-
if data_item:
|
24
|
-
# Set the brush color based on the item's effective color
|
25
|
-
# This ensures preview colors are reflected instantly.
|
26
|
-
self.setBrush(data_item.effective_color)
|
27
|
-
|
28
|
-
# Remove the 'State_Selected' flag to prevent the default box
|
29
|
-
option.state &= ~QStyle.State_Selected
|
30
|
-
super(EmbeddingPointItem, self).paint(painter, option, widget)
|
File without changes
|
File without changes
|
{coralnet_toolbox-0.0.67.dist-info → coralnet_toolbox-0.0.68.dist-info}/licenses/LICENSE.txt
RENAMED
File without changes
|
File without changes
|