Changeset 2618


Ignore:
Timestamp:
Jan 9, 2017 3:53:35 PM (5 years ago)
Author:
vondreele
Message:

implement spot mask delete from image command (also fix spot move & resize with mouse)

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r2615 r2618  
    24112411        self.ifGetRing = False
    24122412        self.MaskKey = ''           #trigger for making image masks
     2413        self.MskDelete = False      #trigger for mask delete
    24132414        self.StrainKey = ''         #ditto for new strain d-zeros
    24142415        self.EnablePlot = True
  • trunk/GSASIIimage.py

    r2616 r2618  
    11491149    peaks = jndx*pixelSize/1000.
    11501150    tth = GetTth(peaks.T[0],peaks.T[1],Controls)
     1151    histtth,bins = np.histogram(tth,2500)
     1152   
     1153    #should be able to filter out spotty Bragg rings here
    11511154    Peakarray = np.vstack((tth,peaks.T)).T
    11521155    Peakarray = np.array(G2mth.sortArray(Peakarray,0))  #now in 2theta
     
    11541157        txt = 'More than 100 spots found: %d. Are rings spotty?'%(len(jndx))
    11551158        return txt
    1156     #should be able to filter out spotty Bragg rings here
    11571159    Points = np.ones((peaks.shape[0],3))
    11581160    Points[:,:2] = Peakarray[:,1:]
  • trunk/GSASIIimgGUI.py

    r2616 r2618  
    13031303    def OnAutoSpotMask(event):
    13041304        'Do auto search for spot masks'
    1305         wx.MessageDialog(G2frame.dataDisplay,'NB: This will clear any old spot masks','Auto Spot Masks', wx.OK).ShowModal()
    1306         Controls = copy.deepcopy(G2frame.PatternTree.GetItemPyData(
    1307         G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Image Controls')))
    1308         Error = G2img.AutoSpotMasks(G2frame.ImageZ,data,Controls)
    1309         if not Error is None:
    1310             G2frame.ErrorDialog('Auto spot search error',Error)
    1311         wx.CallAfter(UpdateMasks,G2frame,data)
    1312         wx.CallAfter(G2plt.PlotExposedImage,G2frame,event=event)               
     1305        if wx.MessageDialog(G2frame.dataDisplay,'NB: This will clear any old spot masks','Auto Spot Masks', wx.OK|wx.CANCEL).ShowModal() == wx.ID_OK:
     1306            Controls = copy.deepcopy(G2frame.PatternTree.GetItemPyData(
     1307            G2gd.GetPatternTreeItemId(G2frame,G2frame.PatternId,'Image Controls')))
     1308            Error = G2img.AutoSpotMasks(G2frame.ImageZ,data,Controls)
     1309            if not Error is None:
     1310                G2frame.ErrorDialog('Auto spot search error',Error)
     1311            wx.CallAfter(UpdateMasks,G2frame,data)
     1312            wx.CallAfter(G2plt.PlotExposedImage,G2frame,event=event)               
    13131313           
    13141314    def ToggleSpotMaskMode(event):
  • trunk/GSASIIplot.py

    r2616 r2618  
    41404140        Page.figure.suptitle('Left-click to create a ring mask',color='r',fontweight='bold')
    41414141        Page.canvas.draw()
     4142    elif G2frame.MskDelete:
     4143        new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False)
     4144        Page.figure.suptitle('select spot mask to delete',color='r',fontweight='bold')
     4145        Page.canvas.draw()
     4146
    41424147    G2imG.UpdateMasks(G2frame,Masks)
    41434148   
     
    43084313            elif event.key in ['l','p','f','a','r']:
    43094314                G2frame.MaskKey = event.key
     4315                OnStartMask(G2frame)
     4316            elif event.key == 'd':
     4317                G2frame.MskDelete = True
    43104318                OnStartMask(G2frame)
    43114319               
     
    45774585                print('picktype {} should not happen!'.format(pickType))
    45784586                GSASIIpath.IPyBreak()
    4579             if event.mouseevent.button == 3:
    4580                 if pickType == 'Spot':
    4581                     print 'delete',pick.center
    4582                     del Masks['Points'][pick.itemNumber]
    4583                    
    4584                     Page.canvas.draw() # refresh without dotted line & save bitmap
    4585             else:
    4586                 saveLinestyle = [p.get_linestyle() for p in pl]
    4587                 for p in pl: p.set_linestyle('dotted') # set line as dotted
    4588                 Page.canvas.draw() # refresh without dotted line & save bitmap
    4589                 savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox)
    4590                 G2frame.cid = Page.canvas.mpl_connect('motion_notify_event', OnDragMask)
    4591                 for p,s in zip(pl,saveLinestyle): p.set_linestyle(s) # set back to original
     4587            saveLinestyle = [p.get_linestyle() for p in pl]
     4588            for p in pl: p.set_linestyle('dotted') # set line as dotted
     4589            Page.canvas.draw() # refresh without dotted line & save bitmap
     4590            savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox)
     4591            G2frame.cid = Page.canvas.mpl_connect('motion_notify_event', OnDragMask)
     4592            for p,s in zip(pl,saveLinestyle): p.set_linestyle(s) # set back to original
    45924593
    45934594    def OnImRelease(event):
     
    47234724            G2imG.UpdateMasks(G2frame,Masks)
    47244725            wx.CallAfter(PlotImage,G2frame,newImage=False)
     4726        elif G2frame.MskDelete:
     4727            G2frame.MskDelete = False
     4728            if G2frame.itemPicked:
     4729                del Masks['Points'][G2frame.itemPicked.itemNumber]
     4730            G2imG.UpdateMasks(G2frame,Masks)
     4731            wx.CallAfter(PlotImage,G2frame,newImage=True)
    47254732        elif treeItem == 'Stress/Strain' and G2frame.StrainKey:
    47264733            Xpos,Ypos = [event.xdata,event.ydata]
     
    48384845            Page.Choice = [' key press','l: log(I) on','a: arc mask','r: ring mask',
    48394846                'p: polygon mask','f: frame mask',
    4840                 't: add spot mask at mouse position']
     4847                't: add spot mask at mouse position',
     4848                'd: select spot mask to delete with mouse']
    48414849            Page.Choice.append('s: start multiple spot mask mode') # this must be the last choice
    48424850            if G2frame.logPlot:
Note: See TracChangeset for help on using the changeset viewer.