Changeset 1583


Ignore:
Timestamp:
Nov 25, 2014 1:36:57 PM (9 years ago)
Author:
toby
Message:

cleanup masks before integration; add zoom buttons to mpl window; wx2.9+ fix for seq ref window

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1580 r1583  
    53595359                G2frame.dataDisplay.SetCellStyle(row,deltaChiCol,color=wx.Colour(255,255,0))
    53605360    G2frame.dataDisplay.InstallGridToolTip(GridSetToolTip,GridColLblToolTip)
     5361    G2frame.dataDisplay.SendSizeEvent() # resize needed on mac
     5362    G2frame.dataDisplay.Refresh() # shows colored text on mac
    53615363   
    53625364################################################################################
  • trunk/GSASIIimgGUI.py

    r1580 r1583  
    118118    def OnRecalibrate(event):
    119119        G2img.ImageRecalibrate(G2frame,data,masks)
    120         UpdateImageControls(G2frame,data,masks)
     120        wx.CallAfter(UpdateImageControls,G2frame,data,masks)
    121121       
    122122    def OnClearCalib(event):
     
    128128           
    129129    def OnIntegrate(event):
     130        CleanupMasks(masks)
    130131        blkSize = 128   #this seems to be optimal; will break in polymask if >1024
    131132        Nx,Ny = data['size']
     
    220221                                    G2frame.PatternTree.SetItemPyData(
    221222                                        G2gd.GetPatternTreeItemId(G2frame,G2frame.Image, 'Masks'),Masks)
     223                                CleanupMasks(Masks)
    222224                                if len(backImage):                               
    223225                                    G2frame.Integrate = G2img.ImageIntegrate(image+backImage,Data,Masks,blkSize,dlgp)
     
    338340                data.update(save)
    339341                G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,G2frame.Image, 'Image Controls'),copy.deepcopy(data))
    340                 UpdateImageControls(G2frame,data,masks)
     342                wx.CallAfter(UpdateImageControls,G2frame,data,masks)
    341343                G2plt.PlotExposedImage(G2frame,event=event)
    342344               
     
    627629                data['fullIntegrate'] = True
    628630                data['LRazimuth'] = [Lazm,Lazm+360]
    629             UpdateImageControls(G2frame,data,masks)
     631            wx.CallAfter(UpdateImageControls,G2frame,data,masks)
    630632            G2plt.PlotExposedImage(G2frame,event=event)
    631633           
     
    10221024##### Masks
    10231025################################################################################
     1026def CleanupMasks(data):
     1027    '''If a mask creation is not completed, an empty mask entry is created in the
     1028    masks array. This cleans them out. It is called when the masks page is first loaded
     1029    and before saving them or after reading them in. This should also probably be done
     1030    before they are used for integration.
     1031    '''
     1032    for key in ['Points','Rings','Arcs','Polygons']:
     1033        data[key] = data.get(key,[])
     1034        l1 = len(data[key])
     1035        data[key] = [i for i in data[key] if i]
     1036        l2 = len(data[key])
     1037        if GSASIIpath.GetConfigValue('debug') and l1 != l2:
     1038            print 'Mask Cleanup:',key,'was',l1,'entries','now',l2
    10241039   
    10251040def UpdateMasks(G2frame,data):
     
    10861101               
    10871102    def OnSaveMask(event):
     1103        CleanupMasks(data)
    10881104        dlg = wx.FileDialog(G2frame, 'Choose image mask file', '.', '',
    10891105            'image mask files (*.immask)|*.immask',wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT|wx.CHANGE_DIR)
     
    11261142                            save[key][1][1] = min(oldThreshold[1],save[key][1][1])
    11271143                    S = File.readline()
     1144                File.close()
    11281145                data.update(save)
     1146                CleanupMasks(data)
    11291147                wx.CallAfter(UpdateMasks,G2frame,data)
    11301148                G2plt.PlotExposedImage(G2frame,event=event)               
    1131                 File.close()
    11321149        finally:
    11331150            dlg.Destroy()
     
    11621179        startScroll = G2frame.dataDisplay.GetScrollPos(wx.VERTICAL) # save scroll position
    11631180        G2frame.dataDisplay.Destroy()
     1181    else:
     1182        CleanupMasks(data) # posting page for 1st time; clean out anything unfinished
    11641183    G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.MaskMenu)
    11651184    G2frame.dataFrame.Bind(wx.EVT_MENU, OnCopyMask, id=G2gd.wxID_MASKCOPY)
  • trunk/GSASIIplot.py

    r1582 r1583  
    210210       
    211211class GSASIItoolbar(Toolbar):
    212     'needs a doc string'
     212    'Override the matplotlib toolbar so we can add more icons'
    213213    ON_MPL_HELP = wx.NewId()
    214214    ON_MPL_KEY = wx.NewId()
     215    arrows = {}
     216    for direc in ('left','right','up','down','Expand X',
     217                  'Expand Y','Shrink X','Shrink Y'):
     218        arrows[direc] = wx.NewId()
    215219    def __init__(self,plotCanvas):
     220        '''Adds additional icons to toolbar'''
    216221        Toolbar.__init__(self,plotCanvas)
    217         POSITION_OF_CONFIGURE_SUBPLOTS_BTN = 6
     222        self.plotCanvas = plotCanvas
     223        POSITION_OF_CONFIGURE_SUBPLOTS_BTN = 6 # remove one button
    218224        self.DeleteToolByPos(POSITION_OF_CONFIGURE_SUBPLOTS_BTN)
    219225        parent = self.GetParent()
     
    224230        self.AddSimpleTool(self.ON_MPL_HELP,_load_bitmap(help),'Help on','Show help on')
    225231        wx.EVT_TOOL(self,self.ON_MPL_HELP,self.OnHelp)
     232        # add arrow keys to control zooming
     233        for direc in ('left','right','up','down'):
     234            wx.EVT_TOOL(self,self.arrows[direc],self.OnArrow)
     235            icon =  os.path.join(os.path.split(__file__)[0],direc[0]+'arrow.ico')
     236            self.AddSimpleTool(self.arrows[direc],_load_bitmap(icon),
     237                               'Shift '+direc,'Shift plot '+direc)
     238        for direc in ('Expand X','Expand Y','Shrink X','Shrink Y'):
     239            fil = ''.join([i[0].lower() for i in direc.split()]+['arrow.ico'])
     240            wx.EVT_TOOL(self,self.arrows[direc],self.OnArrow)
     241            icon =  os.path.join(os.path.split(__file__)[0],fil)
     242            self.AddSimpleTool(self.arrows[direc],_load_bitmap(icon),
     243                               direc,'Zoom: '+direc)
     244    def OnArrow(self,event):
     245        'reposition limits to scan or zoom by button press'
     246        ax = self.plotCanvas.figure.get_axes()[0]
     247        xmin,xmax,ymin,ymax = ax.axis()
     248        #print xmin,xmax,ymin,ymax
     249        if event.Id == self.arrows['right']:
     250            delta = (xmax-xmin)/10.
     251            xmin -= delta
     252            xmax -= delta
     253        elif event.Id == self.arrows['left']:
     254            delta = (xmax-xmin)/10.
     255            xmin += delta
     256            xmax += delta
     257        elif event.Id == self.arrows['up']:
     258            delta = (ymax-ymin)/10.
     259            ymin -= delta
     260            ymax -= delta
     261        elif event.Id == self.arrows['down']:
     262            delta = (ymax-ymin)/10.
     263            ymin += delta
     264            ymax += delta
     265        elif event.Id == self.arrows['Expand X']:
     266            delta = (xmax-xmin)/10.
     267            #xmin += delta
     268            xmax -= delta
     269        elif event.Id == self.arrows['Expand Y']:
     270            delta = (ymax-ymin)/10.
     271            #ymin += delta
     272            ymax -= delta
     273        elif event.Id == self.arrows['Shrink X']:
     274            delta = (xmax-xmin)/10.
     275            #xmin -= delta
     276            xmax += delta
     277        elif event.Id == self.arrows['Shrink Y']:
     278            delta = (ymax-ymin)/10.
     279            #ymin -= delta
     280            ymax += delta
     281        else:
     282            # should not happen!
     283            GSASIIpath.IPyBreak()
     284        ax.axis((xmin,xmax,ymin,ymax))
     285        #print xmin,xmax,ymin,ymax
     286        self.plotCanvas.figure.canvas.draw()
     287       
    226288    def OnHelp(self,event):
    227         'needs a doc string'
     289        'Respond to press of help button on plot toolbar'
    228290        Page = self.GetParent().GetParent()
    229291        pageNo = Page.GetSelection()
     
    232294        G2gd.ShowHelp(bookmark,self.TopLevelParent)
    233295    def OnKey(self,event):
    234         'needs a doc string'
     296        '''Provide user with list of keystrokes defined for plot as well as an
     297        alternate way to access the same functionality
     298        '''
    235299        parent = self.GetParent()
    236300        if parent.Choice:
     
    9451009                G2frame.Interpolate = 'nearest'
    9461010            dlg.Destroy()
    947            
     1011        else:
     1012            print 'no binding for key',event.key
     1013            #GSASIIpath.IPyBreak()
     1014            return
    9481015        wx.CallAfter(PlotPatterns,G2frame,newPlot=newPlot,plotType=plottype)
    9491016       
Note: See TracChangeset for help on using the changeset viewer.