|
46 | 46 | QDoubleSpinBox,
|
47 | 47 | QMessageBox,
|
48 | 48 | QWidget,
|
49 |
| - QScrollArea) |
| 49 | + QScrollArea, |
| 50 | + QLayout, |
| 51 | + QDialogButtonBox, |
| 52 | + QListWidget) |
50 | 53 | import struct
|
51 | 54 | import glob
|
52 | 55 |
|
@@ -80,6 +83,33 @@ def imageFromPath(path):
|
80 | 83 | return image
|
81 | 84 |
|
82 | 85 |
|
| 86 | +class SelectReferenceImageDialog(QDialog): |
| 87 | + |
| 88 | + def __init__(self, parent, test_name, images): |
| 89 | + super().__init__(parent) |
| 90 | + |
| 91 | + self.setWindowTitle('Select reference image') |
| 92 | + |
| 93 | + self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) |
| 94 | + self.button_box.accepted.connect(self.accept) |
| 95 | + self.button_box.rejected.connect(self.reject) |
| 96 | + |
| 97 | + layout = QVBoxLayout() |
| 98 | + layout.addWidget(QLabel('Found multiple matching reference images for {}'.format(test_name))) |
| 99 | + |
| 100 | + self.list = QListWidget() |
| 101 | + layout.addWidget(self.list, 1) |
| 102 | + |
| 103 | + layout.addWidget(self.button_box) |
| 104 | + self.setLayout(layout) |
| 105 | + |
| 106 | + for image in images: |
| 107 | + self.list.addItem(image) |
| 108 | + |
| 109 | + def selected_image(self): |
| 110 | + return self.list.currentItem().text() |
| 111 | + |
| 112 | + |
83 | 113 | class ResultHandler(QDialog):
|
84 | 114 |
|
85 | 115 | def __init__(self, parent=None):
|
@@ -108,6 +138,7 @@ def __init__(self, parent=None):
|
108 | 138 | grid.addWidget(QLabel('New Mask'), 3, 1)
|
109 | 139 | grid.addWidget(self.mask_label, 4, 0)
|
110 | 140 | grid.addWidget(self.new_mask_label, 4, 1)
|
| 141 | + grid.setSizeConstraint(QLayout.SetFixedSize) |
111 | 142 |
|
112 | 143 | self.widget.setLayout(grid)
|
113 | 144 | self.scrollArea.setWidget(self.widget)
|
@@ -225,15 +256,20 @@ def load_images(self, control_image_path, rendered_image_path, mask_image_path):
|
225 | 256 | return
|
226 | 257 |
|
227 | 258 | self.control_label.setPixmap(QPixmap.fromImage(self.control_image))
|
| 259 | + self.control_label.setFixedSize(self.control_image.size()) |
228 | 260 | self.rendered_label.setPixmap(QPixmap.fromImage(self.rendered_image))
|
| 261 | + self.rendered_label.setFixedSize(self.rendered_image.size()) |
229 | 262 | self.mask_label.setPixmap(QPixmap.fromImage(self.mask_image))
|
| 263 | + self.mask_label.setFixedSize(self.mask_image.size()) |
230 | 264 | self.diff_label.setPixmap(QPixmap.fromImage(self.diff_image))
|
| 265 | + self.diff_label.setFixedSize(self.diff_image.size()) |
231 | 266 | self.preview_mask()
|
232 | 267 |
|
233 | 268 | def preview_mask(self):
|
234 | 269 | self.new_mask_image = self.create_mask(
|
235 | 270 | self.control_image, self.rendered_image, self.mask_image, self.overload_spin.value())
|
236 | 271 | self.new_mask_label.setPixmap(QPixmap.fromImage(self.new_mask_image))
|
| 272 | + self.new_mask_label.setFixedSize(self.new_mask_image.size()) |
237 | 273 |
|
238 | 274 | def save_mask(self):
|
239 | 275 | self.new_mask_image.save(self.mask_image_path, "png")
|
@@ -296,15 +332,17 @@ def get_control_image_path(self, test_name):
|
296 | 332 | matching_control_images = [x[0]
|
297 | 333 | for x in os.walk(control_images_folder) if test_name in x[0]]
|
298 | 334 | if len(matching_control_images) > 1:
|
299 |
| - QMessageBox.warning( |
300 |
| - self, 'Result', 'Found multiple matching control images for {}'.format(test_name)) |
301 |
| - return None |
| 335 | + dlg = SelectReferenceImageDialog(self, test_name, matching_control_images) |
| 336 | + if not dlg.exec_(): |
| 337 | + return None |
| 338 | + |
| 339 | + found_control_image_path = dlg.selected_image() |
302 | 340 | elif len(matching_control_images) == 0:
|
303 | 341 | QMessageBox.warning(
|
304 | 342 | self, 'Result', 'No matching control images found for {}'.format(test_name))
|
305 | 343 | return None
|
306 |
| - |
307 |
| - found_control_image_path = matching_control_images[0] |
| 344 | + else: |
| 345 | + found_control_image_path = matching_control_images[0] |
308 | 346 |
|
309 | 347 | # check for a single matching expected image
|
310 | 348 | images = glob.glob(os.path.join(found_control_image_path, '*.png'))
|
|
0 commit comments