GUI: seperated out show polygons from show detections
This commit is contained in:
@@ -10,6 +10,7 @@ class SamcamPanel(QWidget):
|
||||
# Signals for when exposure or gain values change
|
||||
changed = Signal(SampleCameraSettings)
|
||||
show_detections_changed = Signal(bool)
|
||||
show_detection_polygons_changed = Signal(bool)
|
||||
show_target_point_changed = Signal(bool)
|
||||
show_target_coordinates_changed = Signal(bool)
|
||||
show_overlay_legend_changed = Signal(bool)
|
||||
@@ -77,6 +78,13 @@ class SamcamPanel(QWidget):
|
||||
self.show_detections_checkbox.toggled.connect(self.show_detections_changed.emit)
|
||||
detections_layout.addWidget(self.show_detections_checkbox)
|
||||
|
||||
#Show detection polygons checkbox
|
||||
detection_polygons_layout = QHBoxLayout()
|
||||
self.show_detection_polygons_checkbox = QCheckBox("Show ML polygons")
|
||||
self.show_detection_polygons_checkbox.setChecked(True)
|
||||
self.show_detection_polygons_checkbox.toggled.connect(self.show_detection_polygons_changed.emit)
|
||||
detection_polygons_layout.addWidget(self.show_detection_polygons_checkbox)
|
||||
|
||||
# Show target point checkbox
|
||||
target_point_layout = QHBoxLayout()
|
||||
self.show_target_point_checkbox = QCheckBox("Show target point")
|
||||
@@ -122,6 +130,7 @@ class SamcamPanel(QWidget):
|
||||
layout.addLayout(screenshot_message_layout)
|
||||
layout.addWidget(self.screenshot_button)
|
||||
layout.addLayout(detections_layout)
|
||||
layout.addLayout(detection_polygons_layout)
|
||||
layout.addLayout(target_point_layout)
|
||||
layout.addLayout(target_coords_layout)
|
||||
layout.addLayout(legend_layout)
|
||||
@@ -143,6 +152,7 @@ class SamcamPanel(QWidget):
|
||||
self,
|
||||
*,
|
||||
show_detections: bool,
|
||||
show_detection_polygons: bool,
|
||||
show_target_point: bool,
|
||||
show_target_coordinates: bool,
|
||||
show_overlay_legend: bool,
|
||||
@@ -151,6 +161,7 @@ class SamcamPanel(QWidget):
|
||||
) -> None:
|
||||
for widget in (
|
||||
self.show_detections_checkbox,
|
||||
self.show_detection_polygons_checkbox,
|
||||
self.show_target_point_checkbox,
|
||||
self.show_target_coordinates_checkbox,
|
||||
self.show_overlay_legend_checkbox,
|
||||
@@ -160,6 +171,7 @@ class SamcamPanel(QWidget):
|
||||
widget.blockSignals(True)
|
||||
|
||||
self.show_detections_checkbox.setChecked(show_detections)
|
||||
self.show_detection_polygons_checkbox.setChecked(show_detection_polygons)
|
||||
self.show_target_point_checkbox.setChecked(show_target_point)
|
||||
self.show_target_coordinates_checkbox.setChecked(show_target_coordinates)
|
||||
self.show_overlay_legend_checkbox.setChecked(show_overlay_legend)
|
||||
@@ -168,6 +180,7 @@ class SamcamPanel(QWidget):
|
||||
|
||||
for widget in (
|
||||
self.show_detections_checkbox,
|
||||
self.show_detection_polygons_checkbox,
|
||||
self.show_target_point_checkbox,
|
||||
self.show_target_coordinates_checkbox,
|
||||
self.show_overlay_legend_checkbox,
|
||||
|
||||
@@ -84,6 +84,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self.__raster_alpha = 127
|
||||
self.__bounding_box = None
|
||||
self.__show_detections = True
|
||||
self.__show_detection_polygons = True
|
||||
|
||||
self.__show_target_point = True
|
||||
self.__show_target_coordinates = True
|
||||
@@ -668,7 +669,9 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
painter.setBrush(Qt.BrushStyle.NoBrush)
|
||||
detection_rect = QRect(int(x1), int(y1), int(max(1, x2 - x1)), int(max(1, y2 - y1)))
|
||||
painter.drawRect(detection_rect)
|
||||
if poly and len(poly) >= 3:
|
||||
|
||||
# Only draw polygon if the separate toggle is enabled
|
||||
if self.__show_detection_polygons and poly and len(poly) >= 3:
|
||||
polygon = QPolygonF([
|
||||
QPointF(x1 + float(p[0]) * sx, y1 + float(p[1]) * sy)
|
||||
for p in poly
|
||||
@@ -899,6 +902,11 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
self.__show_detections = show
|
||||
self.update()
|
||||
|
||||
@Slot(bool)
|
||||
def set_show_detection_polygons(self, show: bool):
|
||||
self.__show_detection_polygons = show
|
||||
self.update()
|
||||
|
||||
@Slot(bool)
|
||||
def set_show_target_point(self, show: bool):
|
||||
self.__show_target_point = show
|
||||
@@ -929,6 +937,7 @@ class SampleCameraImageLabel(QGraphicsView):
|
||||
"show_target_point": self.__show_target_point,
|
||||
"show_target_coordinates": self.__show_target_coordinates,
|
||||
"show_detections": self.__show_detections,
|
||||
"show_detection_polygons": self.__show_detection_polygons,
|
||||
"show_overlay_legend": self.__show_overlay_legend,
|
||||
"compact_overlay_legend": self.__compact_overlay_legend,
|
||||
"target_color": self.__target_color_name,
|
||||
|
||||
Reference in New Issue
Block a user