Skip to content

Commit 1d87955

Browse files
committed
position and styling of all detectors implemented
1 parent cc582a4 commit 1d87955

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/py4D_browser/update_views.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,18 @@ def update_realspace_detector(self):
408408
)
409409
assert detector_shape in ["Point", "Rectangular"], detector_shape
410410

411+
main_pen = {"color": "g", "width": 6}
412+
handle_pen = {"color": "r", "width": 9}
413+
hover_pen = {"color": "c", "width": 6}
414+
hover_handle = {"color": "c", "width": 9}
415+
411416
if self.datacube is None:
412417
x0, y0 = 0, 0
413418
xr, yr = 4, 4
414419
else:
415420
x, y = self.datacube.data.shape[2:]
416-
x0, y0 = x // 2, y // 2
417-
xr, yr = x / 10, y / 10
421+
y0, x0 = x // 2, y // 2
422+
xr, yr = (np.minimum(x, y) / 10,) * 2
418423

419424
# Remove existing detector
420425
if hasattr(self, "real_space_point_selector"):
@@ -424,19 +429,27 @@ def update_realspace_detector(self):
424429
self.real_space_widget.view.scene().removeItem(self.real_space_rect_selector)
425430
self.real_space_rect_selector = None
426431

427-
# Rectangular detector
432+
# Point detector
428433
if detector_shape == "Point":
429434
self.real_space_point_selector = pg_point_roi(
430435
self.real_space_widget.getView(),
431436
center=(x0 - 0.5, y0 - 0.5),
437+
pen=main_pen,
438+
hoverPen=hover_pen,
432439
)
433440
self.real_space_point_selector.sigRegionChanged.connect(
434441
partial(self.update_diffraction_space_view, False)
435442
)
436443

444+
# Rectangular detector
437445
elif detector_shape == "Rectangular":
438446
self.real_space_rect_selector = pg.RectROI(
439-
[int(x0 - xr / 2), int(y0 - yr / 2)], [int(xr), int(yr)], pen=(3, 9)
447+
[int(x0 - xr / 2), int(y0 - yr / 2)],
448+
[int(xr), int(yr)],
449+
pen=main_pen,
450+
handlePen=handle_pen,
451+
hoverPen=hover_pen,
452+
handleHoverPen=hover_handle,
440453
)
441454
self.real_space_widget.getView().addItem(self.real_space_rect_selector)
442455
self.real_space_rect_selector.sigRegionChangeFinished.connect(
@@ -465,8 +478,8 @@ def update_diffraction_detector(self):
465478
xr, yr = 4, 4
466479
else:
467480
x, y = self.datacube.data.shape[2:]
468-
x0, y0 = x // 2, y // 2
469-
xr, yr = x / 10, y / 10
481+
y0, x0 = x // 2, y // 2
482+
xr, yr = (np.minimum(x, y) / 10,) * 2
470483

471484
# Remove existing detector
472485
if hasattr(self, "virtual_detector_point"):

0 commit comments

Comments
 (0)