Changeset 3817 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Feb 12, 2019 9:27:27 AM (4 years ago)
Author:
vondreele
Message:

Add Setcursor utility that presents different cursors on the plot depending on Zoom/Pan? buttons pressed on tool bar. Use it in all plots except ogl ones.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r3816 r3817  
    842842            dlg.Destroy()
    843843
     844
    844845    # these routines are not currently in use, but there are probably good
    845846    # places in the graphics to disable the zoom/pan to release the mouse bind
     
    888889            else:
    889890                print('Unable to reset Pan button, please report this with matplotlib version')
     891               
     892def SetCursor(page):
     893    mode = page.toolbar._active
     894    if mode == 'PAN':
     895        page.canvas.Cursor = wx.Cursor(wx.CURSOR_SIZING)
     896    elif mode == 'ZOOM':
     897        page.canvas.Cursor = wx.Cursor(wx.CURSOR_MAGNIFIER)
     898    else:
     899        page.canvas.Cursor = wx.Cursor(wx.CURSOR_CROSS)
    890900           
    891901################################################################################
     
    11621172                    s += fmt.format(*hkl[:n])
    11631173            ypos = event.ydata
    1164             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     1174            SetCursor(Page)
    11651175            try:
    11661176                G2frame.G2plotNB.status.SetStatusText('d =%9.3f F^2 =%9.3f'%(Xpos,ypos),1)                   
     
    19912001       
    19922002    def OnMotion(event):
    1993         mode = Page.toolbar._active
    1994         if mode == 'PAN':
    1995             Page.Cursor = wx.Cursor(wx.CURSOR_SIZING)
    1996         elif mode == 'ZOOM':
    1997             Page.Cursor = wx.Cursor(wx.CURSOR_MAGNIFIER)
    1998         else:
    1999             Page.Cursor = wx.Cursor(wx.CURSOR_CROSS)
    2000            
     2003       
     2004        SetCursor(Page)
    20012005        if event.button and G2frame.Contour and G2frame.TforYaxis:
    20022006            ytics = imgAx.get_yticks()
     
    20072011        if xpos is None: return  #avoid out of frame mouse position
    20082012        ypos = event.ydata
    2009         Page.canvas.SetCursor(wx.CROSS_CURSOR)
    20102013        try:
    20112014            Id = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Instrument Parameters')
     
    42124215        if xpos:                                        #avoid out of frame mouse position
    42134216            ypos = event.ydata
    4214             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     4217            SetCursor(Page)
    42154218            try:
    42164219                if G2frame.Contour:
     
    45024505        if xpos:                                        #avoid out of frame mouse position
    45034506            ypos = event.ydata
    4504             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     4507            SetCursor(Page)
    45054508            try:
    45064509                G2frame.G2plotNB.status.SetStatusText('X =%9.3f %s =%9.3g'%(xpos,Title,ypos),1)                   
     
    46264629        if xpos:                                        #avoid out of frame mouse position
    46274630            ypos = event.ydata
    4628             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     4631            SetCursor(Page)
    46294632            try:
    46304633                G2frame.G2plotNB.status.SetStatusText('X =%9.3f %s =%9.3f'%(xpos,Title,ypos),1)                   
     
    47624765                Xwd = Xmax-Xmin
    47634766                Ywd = Ymax-Ymin
    4764                 Page.canvas.SetCursor(wx.CROSS_CURSOR)
     4767                SetCursor(Page)
    47654768                ix = int(Nxy[0]*(xpos-Xmin)/Xwd)
    47664769                iy = int(Nxy[1]*(ypos-Ymin)/Ywd)
     
    48424845            else:
    48434846                resName = ''
    4844             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     4847            SetCursor(Page)
    48454848            try:
    48464849                if 0 <= xpos < len(resNames):
     
    49004903        if xpos:                                        #avoid out of frame mouse position
    49014904            ypos = event.ydata
    4902             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     4905            SetCursor(Page)
    49034906            try:
    49044907                G2frame.G2plotNB.status.SetStatusText('d-spacing =%9.5f Azimuth =%9.3f'%(ypos,xpos),1)                   
     
    49544957        if xpos:                                        #avoid out of frame mouse position
    49554958            ypos = event.ydata
    4956             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     4959            SetCursor(Page)
    49574960            try:
    49584961                G2frame.G2plotNB.status.SetStatusText('diameter =%9.3f f(D) =%9.3g'%(xpos,ypos),1)                   
     
    49944997        xpos = event.xdata
    49954998        if xpos:                                        #avoid out of frame mouse position
    4996             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     4999            SetCursor(Page)
    49975000            G2frame.G2plotNB.status.SetStatusText('2-theta =%9.3f '%(xpos,),1)
    49985001            if G2frame.PickId and G2frame.GPXtree.GetItemText(G2frame.PickId) in ['Index Peak List','Unit Cells List']:
     
    56975700            ix = int(round(xpos*10))
    56985701            iy = int(round((Slab.shape[0]-1)*(ypos+0.5-Off*0.005)))
    5699             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     5702            SetCursor(Page)
    57005703            try:
    57015704                G2frame.G2plotNB.status.SetStatusText('t =%9.3f %s =%9.3f %s=%9.3f'%(xpos,GkDelta+Ax,ypos,Gkrho,Slab[iy,ix]/8.),1)                   
     
    63596362        if event.xdata and event.ydata and len(G2frame.ImageZ):                 #avoid out of frame errors
    63606363            Page.SetToolTipString('%8.2f %8.2fmm'%(event.xdata,event.ydata))
    6361             Page.canvas.SetCursor(wx.CROSS_CURSOR)
     6364            SetCursor(Page)
    63626365            item = G2frame.itemPicked
    63636366            pixelSize = Data['pixelSize']
     
    73137316    def OnMotion(event):
    73147317        Page.SetToolTipString('')
    7315         Page.canvas.SetCursor(wx.CROSS_CURSOR)
     7318        SetCursor(Page)
    73167319        azm = event.ydata
    73177320        tth = event.xdata
     
    73687371    def OnMotion(event):
    73697372        Page.SetToolTipString('')
    7370         Page.canvas.SetCursor(wx.CROSS_CURSOR)
     7373        SetCursor(Page)
    73717374        azm = event.xdata
    73727375        tth = event.ydata
Note: See TracChangeset for help on using the changeset viewer.