Skip to content

Commit

Permalink
add menu to show mask image
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Dec 12, 2023
1 parent 6c87cbd commit 44fa710
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions larch/wxxrd/xrd1d_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ def createMenus(self):
self.unset_mask_menu = m
m.Enable(False)

m = MenuItem(self, cmenu, "Show Mask Image",
"Show image of mask", self.onShowMask)
self.show_mask_menu = m
m.Enable(False)

menubar = wx.MenuBar()
menubar.Append(fmenu, "&File")
menubar.Append(cmenu, "&Calibration and Mask")
Expand Down Expand Up @@ -422,6 +427,7 @@ def onUnsetMask(self, event=None):
if dlg.GetResponse():
self.mask = None
self.unset_mask_menu.Enable(False)
self.show_mask_menu.Enable(False)

def onReadMask(self, event=None):
sfile = FileOpen(self, 'Read Mask Image File',
Expand All @@ -439,11 +445,17 @@ def onReadMask(self, event=None):
if valid_mask:
self.mask = (1 - img[::-1, :]).astype(img.dtype)
self.unset_mask_menu.Enable(True)
self.show_mask_menu.Enable(True)
else:
title = "Could not use mask file"
message = [f"Could not use {sfile:s} as a mask file"]
o = ExceptionPopup(self, title, message)

def onShowMask(self, event=None):
if self.mask is not None:
imd = self.get_imdisplay()
imd.display(self.mask, colomap='gray', auto_contrast=True)

def onReadTIFF(self, event=None):
sfile = FileOpen(self, 'Read TIFF XRD Image',
default_file='XRD.tiff',
Expand Down

0 comments on commit 44fa710

Please sign in to comment.