Changeset 2599


Ignore:
Timestamp:
Dec 21, 2016 5:34:47 PM (5 years ago)
Author:
toby
Message:

add keystroke to set calibration dmin; animate dragging of integration range values.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r2592 r2599  
    954954                cutOff.SetValue(limits[2])
    955955                calibSkip.SetValue(str(data['calibskip']))
    956                 calibDmin.SetValue(limits[0])
     956                G2frame.calibDmin.SetValue(limits[0])
    957957            else:
    958958                G2frame.dataFrame.ImageEdit.Enable(id=G2gd.wxID_IMRECALIBRATE,enable=False)
     
    989989        comboSizer = wx.BoxSizer(wx.HORIZONTAL)       
    990990        comboSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Min calib d-spacing '),0,WACV)
    991         calibDmin = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'calibdmin',nDig=(10,2),typeHint=float,min=0.25)
    992         comboSizer.Add(calibDmin,0,WACV)
     991        G2frame.calibDmin = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'calibdmin',nDig=(10,2),typeHint=float,min=0.25)
     992        comboSizer.Add(G2frame.calibDmin,0,WACV)
    993993        calibSizer.Add(comboSizer,0)
    994994       
  • trunk/GSASIIplot.py

    r2596 r2599  
    41454145    from matplotlib.patches import Ellipse,Circle
    41464146    import numpy.ma as ma
     4147    G2frame.cid = None
    41474148    Dsp = lambda tth,wave: wave/(2.*npsind(tth/2.))
    41484149    global Data,Masks,StrSta  # RVD: these are needed for multiple image controls/masks
     
    42394240                    dlg.Destroy()
    42404241                return
     4242            elif event.key in ['d',]:  # set dmin from plot position
     4243                if not (event.xdata and event.ydata): return
     4244                xpos = event.xdata
     4245                ypos = event.ydata
     4246                tth,azm,D,dsp = G2img.GetTthAzmDsp(xpos,ypos,Data)
     4247                G2frame.calibDmin.SetValue(dsp)
    42414248            elif event.key == 'l':
    42424249                G2frame.logPlot = not G2frame.logPlot
     
    42484255           
    42494256    def OnImPick(event):
     4257        def OnDragIntBound(event):
     4258            if event.xdata is None or event.ydata is None:
     4259                # mouse is outside window. Could
     4260                return
     4261            tth,azm,D,dsp = G2img.GetTthAzmDsp(event.xdata,event.ydata,Data)
     4262            itemPicked = str(G2frame.itemPicked)
     4263            if 'line1' in itemPicked and 'Line2D' in itemPicked:
     4264                Data['IOtth'][0] = max(tth,0.001)
     4265            elif 'line2' in itemPicked and 'Line2D' in itemPicked:
     4266                Data['IOtth'][1] = tth
     4267            elif 'line3' in itemPicked and 'Line2D' in itemPicked:
     4268                Data['LRazimuth'][0] = int(azm)
     4269                Data['LRazimuth'][0] %= 360
     4270            elif 'line4' in itemPicked  and 'Line2D' in itemPicked:
     4271                Data['LRazimuth'][1] = int(azm)
     4272                Data['LRazimuth'][1] %= 360
     4273            else:
     4274                return
     4275            if Data['LRazimuth'][0] > Data['LRazimuth'][1]: Data['LRazimuth'][1] += 360
     4276            if Data['fullIntegrate']: Data['LRazimuth'][1] = Data['LRazimuth'][0]+360
     4277            #if Data['IOtth'][0] > Data['IOtth'][1]:
     4278            #    Data['IOtth'][0],Data['IOtth'][1] = Data['IOtth'][1],Data['IOtth'][0]
     4279            # compute arcs, etc
     4280            LRAzim = Data['LRazimuth']                  #NB: integers
     4281            Nazm = Data['outAzimuths']
     4282            delAzm = float(LRAzim[1]-LRAzim[0])/Nazm
     4283            AzmthOff = Data['azmthOff']
     4284            IOtth = Data['IOtth']
     4285            wave = Data['wavelength']
     4286            dspI = wave/(2.0*sind(IOtth[0]/2.0))
     4287            ellI = G2img.GetEllipse(dspI,Data)           #=False if dsp didn't yield an ellipse (ugh! a parabola or a hyperbola)
     4288            dspO = wave/(2.0*sind(IOtth[1]/2.0))
     4289            ellO = G2img.GetEllipse(dspO,Data)           #Ditto & more likely for outer ellipse
     4290            Azm = np.arange(LRAzim[0],LRAzim[1]+1.)-AzmthOff
     4291            if ellI:
     4292                xyI = []
     4293                for azm in Azm:
     4294                    xy = G2img.GetDetectorXY(dspI,azm,Data)
     4295                    if np.any(xy):
     4296                        xyI.append(xy)
     4297                if len(xyI):
     4298                    xyI = np.array(xyI)
     4299                    arcxI,arcyI = xyI.T
     4300            if ellO:
     4301                xyO = []
     4302                for azm in Azm:
     4303                    xy = G2img.GetDetectorXY(dspO,azm,Data)
     4304                    if np.any(xy):
     4305                        xyO.append(xy)
     4306                if len(xyO):
     4307                    xyO = np.array(xyO)
     4308                    arcxO,arcyO = xyO.T               
     4309
     4310            Page.canvas.restore_region(savedplot)
     4311            if 'line1' in itemPicked and 'Line2D' in itemPicked:
     4312                pick.set_data([arcxI,arcyI])
     4313            elif 'line2' in itemPicked and 'Line2D' in itemPicked:
     4314                pick.set_data([arcxO,arcyO])
     4315            elif 'line3' in itemPicked and 'Line2D' in itemPicked:
     4316                pick.set_data([[arcxI[0],arcxO[0]],[arcyI[0],arcyO[0]]])
     4317            elif 'line4' in itemPicked  and 'Line2D' in itemPicked:
     4318                pick.set_data([[arcxI[-1],arcxO[-1]],[arcyI[-1],arcyO[-1]]])
     4319            Page.figure.gca().draw_artist(pick)
     4320            Page.canvas.blit(Page.figure.gca().bbox)
     4321
    42504322        if G2frame.PatternTree.GetItemText(G2frame.PickId) not in ['Image Controls','Masks']:
    42514323            return
    42524324        if G2frame.itemPicked is not None: return
    4253         G2frame.itemPicked = event.artist
     4325        G2frame.itemPicked = pick = event.artist
    42544326        G2frame.mousePicked = event.mouseevent
     4327        if G2frame.PatternTree.GetItemText(G2frame.PickId) == 'Image Controls':
     4328            # prepare to animate move of integration ranges
     4329            Page = G2frame.G2plotNB.nb.GetPage(plotNum)
     4330            saveLinestyle = pick.get_linestyle()
     4331            pick.set_linestyle(':') # set line as dotted
     4332            Page.figure.gca()
     4333            Page.canvas.draw() # refresh without dotted line & save bitmap
     4334            savedplot = Page.canvas.copy_from_bbox(Page.figure.gca().bbox)
     4335            G2frame.cid = Page.canvas.mpl_connect('motion_notify_event', OnDragIntBound)
     4336            pick.set_linestyle(saveLinestyle) # back to original
    42554337       
    42564338    def OnImRelease(event):
     
    42614343        if PickName not in ['Image Controls','Masks','Stress/Strain']:
    42624344            return
     4345        if G2frame.cid is not None:         # if there is a drag connection, delete it
     4346            Page.canvas.mpl_disconnect(G2frame.cid)
     4347            G2frame.cid = None
    42634348        pixelSize = Data['pixelSize']
    42644349        scalex = 1000./pixelSize[0]
     
    44714556    try:
    44724557        if G2frame.PatternTree.GetItemText(G2frame.PickId) in ['Image Controls',]:
    4473             Page.Choice = (' key press','l: log(I) on','x: flip x','y: flip y',)
     4558            Page.Choice = (' key press','l: log(I) on','d: set dmin','x: flip x','y: flip y',)
    44744559            if G2frame.logPlot:
    44754560                Page.Choice[1] = 'l: log(I) off'
     
    45254610        Plot.plot(xcent,ycent,'x')
    45264611        #G2frame.PatternTree.GetItemText(item)
    4527         if Data['showLines']:
     4612        if Data['showLines']: # draw integration range arc/circles/lines
    45284613            LRAzim = Data['LRazimuth']                  #NB: integers
    45294614            Nazm = Data['outAzimuths']
Note: See TracChangeset for help on using the changeset viewer.