Changeset 2538


Ignore:
Timestamp:
Nov 20, 2016 11:43:16 AM (5 years ago)
Author:
toby
Message:

add menu command to move a selected peak

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r2536 r2538  
    19851985        self.PeakEdit.Append(id=wxID_CLEARPEAKS, kind=wx.ITEM_NORMAL,text='Clear peaks',
    19861986            help='Clear the peak list' )
     1987        self.movePeak = self.PeakEdit.Append(id=wx.ID_ANY,kind=wx.ITEM_NORMAL,text='Move selected peak',
     1988            help='Select a peak in the table, then use this to move it with the mouse.')
    19871989        self.PostfillDataMenu()
    19881990        self.UnDo.Enable(False)
  • trunk/GSASIIplot.py

    r2537 r2538  
    14471447        OnPick(None)
    14481448       
     1449    def onMovePeak(event):
     1450        selectedPeaks = list(set([row for row,col in G2frame.dataDisplay.GetSelectedCells()] +
     1451                                G2frame.dataDisplay.GetSelectedRows()))
     1452        if len(selectedPeaks) != 1:
     1453            G2G.G2MessageBox(G2frame,'You must select one peak in the table first. # selected ='+
     1454                             str(len(selectedPeaks)),'Select one peak')
     1455            return
     1456        #GSASIIpath.IPyBreak()
     1457        G2frame.itemPicked = G2frame.Lines[selectedPeaks[0]+2] # 1st 2 lines are limits
     1458        G2frame.G2plotNB.Parent.Raise()
     1459        OnPick(None)
     1460                       
    14491461    def OnPick(event):
    14501462        '''Respond to an item being picked. This usually means that the item
     
    14901502            Page.canvas.blit(Page.figure.gca().bbox)
    14911503
    1492 
    14931504        def OnDragDiffCurve(event):
    14941505            '''Respond to dragging of the difference curve
     
    15061517            mouse = 1
    15071518            pick = G2frame.itemPicked
     1519            ind = np.array([0])
    15081520        else:
    15091521            if G2frame.itemPicked is not None: return
     
    15281540        PickId = G2frame.PickId
    15291541        if G2frame.PatternTree.GetItemText(PickId) == 'Peak List':
    1530             if ind.all() != [0] and ObsLine[0].get_label() in str(pick):    #picked a data point
     1542            if ind.all() != [0] and ObsLine[0].get_label() in str(pick):    #picked a data point, add a new peak
    15311543                data = G2frame.PatternTree.GetItemPyData(G2frame.PickId)
    15321544                XY = G2mth.setPeakparms(Parms,Parms2,xy[0],xy[1])
     
    18101822            G2frame.dataFrame.moveTickLoc.Enable(True)
    18111823            G2frame.dataFrame.moveTickSpc.Enable(True)
     1824    elif G2frame.PatternTree.GetItemText(G2frame.PickId) == 'Peak List':
     1825        G2frame.dataFrame.Bind(wx.EVT_MENU, onMovePeak, id=G2frame.dataFrame.movePeak.GetId())
    18121826    # save information needed to reload from tree and redraw
    18131827    kwargs={'PatternName':G2frame.PatternTree.GetItemText(G2frame.PatternId)}
     
    21292143                            [row for row,col in G2frame.dataDisplay.GetSelectedCells()] +
    21302144                            G2frame.dataDisplay.GetSelectedRows()))
     2145                        G2frame.dataFrame.movePeak.Enable(len(selectedPeaks) == 1) # allow peak move from table when one peak is selected
    21312146                        for i,item in enumerate(data['peaks']):
    21322147                            if i in selectedPeaks:
Note: See TracChangeset for help on using the changeset viewer.