def OnNameImg(self, evt): """Name the curent Image""" exp = wx.GetApp().ws name = evt.GetString() acho = self.ail_cho achosel = acho.GetSelection() if achosel == wx.NOT_FOUND: exp.add_to_img_list(name) ResetChoice(acho, exp.img_names, name) self.update(loadImage=True, newImage=True) else: exp.img_names[achosel] = name ResetChoice(acho, exp.img_names, name) return
def OnEditImg(self, evt): """Edit image list""" exp = wx.GetApp().ws # # Since images do not have a name attribute, use NamedItem class # to make list with names # ilist = exp.img_list iname = exp.img_names nilist = [NamedItem(iname[i], ilist[i]) for i in range(len(iname))] ssel = self.ail_cho.GetStringSelection() dlg = ListEditDlg(self, wx.NewId(), nilist) dlg.ShowModal() dlg.Destroy() exp.img_list[:] = [item.data for item in nilist] exp.img_names[:] = [item.name for item in nilist] # # Now reset choice by hand in case current image was dropped # if (not ssel): # new names, but no selection ResetChoice(self.ail_cho, exp.img_names, ssel) self.ail_cho.SetSelection(wx.NOT_FOUND) li = False elif (ssel in exp.img_names): # new names, keep old selection exp.active_img = ssel ResetChoice(self.ail_cho, exp.img_names, ssel) li = True else: # new names, old selection gone exp.active_img = None ResetChoice(self.ail_cho, exp.img_names, '') self.ail_cho.SetSelection(wx.NOT_FOUND) li = False ni = not li self.update(newImage=ni, loadImage=li) return
def update(self): """Update panel and interactors from the current exp""" exp = wx.GetApp().ws rdr = exp.activeReader # Reader line: reset choice interactor rnames = [r.name for r in exp.savedReaders] ResetChoice(self.rdrs_cho, rnames, rdr.name) # Name line self.name_txt.ChangeValue(rdr.name) # mode = rdr.imageMode self.mode_cho.SetSelection(IMAGE_MODE_DICT_SEL[mode]) # Agg choice self.agg_cho.SetStringSelection(AGG_MODE_DICT_INV[rdr.aggMode]) # Mode Subpanel self.sizer.Show(self.sp_single, (mode == ImageModes.SINGLE_FRAME)) self.sizer.Show(self.sp_multi, (mode == ImageModes.MULTI_FRAME)) # Image names if mode == ImageModes.SINGLE_FRAME: lctrl = self.sp_single.file_lctrl else: lctrl = self.sp_multi.file_lctrl pass lctrl.DeleteAllItems() for n in rdr.imageNames: index = lctrl.InsertStringItem(sys.maxint, n) if mode == ImageModes.MULTI_FRAME: vals = rdr.imageNameD[n] lctrl.SetStringItem(index, 1, str(vals[0])) lctrl.SetStringItem(index, 3, str(vals[1])) lctrl.SetStringItem(index, 4, str(vals[2])) lctrl.SetStringItem(index, 5, str(vals[3])) # add total number of frames available try: d = rdr.imageDir r = ReadGE( os.path.join(d, n), fmt=exp.activeReader.imageFmt) nframe = r.getNFrames() lctrl.SetStringItem(index, 2, str(nframe)) except: lctrl.SetStringItem(index, 2, '(error)') pass pass pass # info panel self.sp_info.update() self.sizer.Layout() return
def updateFromExp(self): """Update interactors""" app = wx.GetApp() exp = app.ws mat = exp.activeMaterial # Materials line: reset choice interactor ResetChoice(self.mats_cho, exp.matNames, mat.name) # Name line self.name_txt.ChangeValue(mat.name) # Space group info sg = mat.spaceGroup self.sg_spn.SetValue(mat.sgnum) self.hall_txt.ChangeValue(sg.HallSymbol) self.herm_txt.ChangeValue(sg.hermannMauguin) self.laue_txt.ChangeValue(sg.laueGroup) self.ltype_txt.ChangeValue(sg.latticeType) self.hkls_txt.ChangeValue(str(mat.hklMax)) # Lattice parameters A = 'angstrom' D = 'degrees' BG = {True: (200, 255, 200), False: (200, 200, 200)} reqP = mat.spaceGroup.reqParams lprm = mat.latticeParameters enable = lambda i: (self.wDict[i].Enable(i in reqP), self.wDict[i]. SetBackgroundColour(BG[i in reqP])) self.lp_a_txt.ChangeValue(str(lprm[0].getVal(A))) self.lp_b_txt.ChangeValue(str(lprm[1].getVal(A))) self.lp_c_txt.ChangeValue(str(lprm[2].getVal(A))) self.alpha_txt.ChangeValue(str(lprm[3].getVal(D))) self.beta_txt.ChangeValue(str(lprm[4].getVal(D))) self.gamma_txt.ChangeValue(str(lprm[5].getVal(D))) for i in range(6): enable(i) # update ring panel self.ring_pan.updateFromExp() app.getCanvas().update() return
def updateFromExp(self): """Update all subwindows""" exp = wx.GetApp().ws ResetChoice(self.aread_cho, exp.readerNames, exp.activeReader.name) ResetChoice(self.amat_cho, exp.matNames, exp.activeMaterial.name) self.nspot_txt.ChangeValue(str(len(exp.raw_spots))) spots_ind = exp.spots_for_indexing if hasattr(spots_ind, 'nTThAssoc'): nspot_assoc = len(spots_ind) - numpy.sum(spots_ind.nTThAssoc == 0) else: nspot_assoc = 0 self.nspotind_txt.ChangeValue(str(nspot_assoc)) self.rdr_lbx.Set(exp.spot_readers) # Reset sizers self.Layout() return
def updateFromExp(self): """Update all subwindows""" app = wx.GetApp() exp = app.ws mat = exp.activeMaterial ResetChoice(self.mats_cho, exp.matNames, mat.name) self.__showGeoParams() self.ring_pan.updateFromExp() self.__showFitOpts() app.getCanvas().update() return
def update(self, **kwargs): """Update the image according to the options in the option panel KEYWORD ARGS newImage -- if True then display image afresh (False by default) loadImage -- if True, then image was loaded from saved list (False by default) """ kwargs.setdefault('newImage', False) kwargs.setdefault('loadImage', False) kwargs.setdefault('updateImage', False) kwargs.setdefault('onInit', False) ni = kwargs['newImage'] li = kwargs['loadImage'] ui = kwargs['updateImage'] oninit = kwargs['onInit'] # # Show image if box is checked. # app = wx.GetApp() exp = app.ws img = exp.active_img if img is None: # no active image, but possibly one on the axes images = self.axes.get_images() if images: img0 = images[0] img0.set_visible(False) else: si = self.showImage_box.IsChecked() if ni or ui: # not using axes image list self.axes.images = [] self.axes.imshow(img, origin='upper', interpolation='nearest', cmap=self.cmPanel.cmap, vmin=self.cmPanel.cmin_val, vmax=self.cmPanel.cmax_val, visible=si) self.axes.set_autoscale_on(False) self.axes.format_coord = lambda x, y: str(x) + str(y) # else: # set visibility of axes image images = self.axes.get_images() if images: img0 = images[0] img0.set_visible(si) pass pass # # Show calibrant rings/ranges if box is checked. # self.__clearAxesLines() if (self.showCalRings_box.IsChecked()): self.__drawRings() if (self.showCalRanges_box.IsChecked()): self.__drawRanges() # # Update ring list # #rcho = self.rings_cho #ResetChoice(rcho, exp.matNames, rcho.GetStringSelection) # self.draw() # # Update image list # acho = self.ail_cho if li: # set text box to name of interactors name = acho.GetStringSelection() ResetChoice(acho, exp.img_names, name) self.nam_txt.ChangeValue(name) else: if ni or oninit: if exp.img_names: # to handle init case on load exp ResetChoice(acho, exp.img_names, exp.img_names[0]) acho.SetSelection(wx.NOT_FOUND) self.nam_txt.ChangeValue('<unnamed image>') return