Changeset 2590 for trunk/GSASIIimgGUI.py


Ignore:
Timestamp:
Dec 16, 2016 12:45:09 PM (5 years ago)
Author:
toby
Message:

Redo color scaling after discussion w/RBVD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimgGUI.py

    r2585 r2590  
    565565            An equal number of pixels are dropped at the minimum and maximum levels.
    566566            '''
    567             val = int(event.GetEventObject().GetLabel()[:-1])  # get value from button
    568             margin = (100-val)/2.
     567            try:
     568                val = int(event.GetEventObject().GetStringSelection()[:-1])
     569                margin = (100-val)/2.
     570            except:
     571                margin = 0
     572                event.GetEventObject().SetSelection(0)
    569573            new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False)
    570             data['range'][1][0] = int(np.percentile(Page.ImgObj.get_array().compressed(),margin))
    571             data['range'][1][1] = int(np.percentile(Page.ImgObj.get_array().compressed(),100-margin))
     574            if margin == 0:
     575                data['range'][1] = list(data['range'][0])
     576            else:
     577                data['range'][1][0] = int(np.percentile(Page.ImgObj.get_array().compressed(),margin))
     578                data['range'][1][1] = int(np.percentile(Page.ImgObj.get_array().compressed(),100-margin))
    572579            DeltOne = data['range'][1][1]-max(0.0,data['range'][0][0])
    573580            sqrtDeltOne = math.sqrt(DeltOne)
     
    579586            Page.canvas.draw_idle()
    580587           
    581         maxSizer = wx.FlexGridSizer(0,4,0,5)
    582         maxSizer.AddGrowableCol(1,1)
    583         maxSizer.SetFlexibleDirection(wx.HORIZONTAL)
     588        maxSizer = wx.GridBagSizer(0,0)
    584589        sqrtDeltZero = max(1.0,math.sqrt(data['range'][0][1]-max(0.0,data['range'][0][0])))
    585590        DeltOne = max(1.0,data['range'][1][1]-max(0.0,data['range'][0][0]))
    586591        sqrtDeltOne = math.sqrt(DeltOne)
    587         maxSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Max intensity'),0,WACV)
     592        r = c = 0
     593        maxSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Max intensity'),(r,c))
     594        c += 1
    588595        maxSel = wx.Slider(parent=G2frame.dataDisplay,style=wx.SL_HORIZONTAL,
    589596            value=int(100*sqrtDeltOne/sqrtDeltZero))
    590         maxSizer.Add(maxSel,1,wx.EXPAND)
     597        maxSizer.Add(maxSel,(r,c),flag=wx.EXPAND)
     598        maxSizer.AddGrowableCol(c)
     599        c += 1
    591600        maxSel.Bind(wx.EVT_SLIDER, OnMaxSlider)
    592601        maxVal = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data['range'][1],1,min=data['range'][0][0]+1,
    593602            max=data['range'][0][1]-1,typeHint=int,OnLeave=OnMaxVal)
    594         maxSizer.Add(maxVal,0,WACV)   
    595         b99 = wx.Button(G2frame.dataDisplay,-1,'99%',style=wx.BU_EXACTFIT)
    596         b99.Bind(wx.EVT_BUTTON,OnAutoSet)
    597         maxSizer.Add(b99,0,WACV)   
    598         maxSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Min intensity'),0,WACV)
     603        maxSizer.Add(maxVal,(r,c))
     604        c += 1
     605        scaleSel = wx.Choice(G2frame.dataDisplay,choices=("100%","99%","95%","90%","80%"),size=(-1,-1))
     606        if (data['range'][1][0] == data['range'][0][0] and
     607            data['range'][1][1] == data['range'][0][1]):
     608            scaleSel.SetSelection(0)
     609        else:
     610            scaleSel.SetLabel("?%")
     611        scaleSel.Bind(wx.EVT_CHOICE,OnAutoSet)
     612        maxSizer.Add(scaleSel,(r,c),(2,1),flag=wx.ALIGN_CENTER)
     613        c = 0
     614        r = 1
     615        maxSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Min intensity'),(r,c))
     616        c += 1
    599617        minSel = wx.Slider(parent=G2frame.dataDisplay,style=wx.SL_HORIZONTAL,
    600618            value=int(100*(data['range'][1][0]-max(0.0,data['range'][0][0]))/DeltOne))
    601         maxSizer.Add(minSel,1,wx.EXPAND)
     619        maxSizer.Add(minSel,(r,c),flag=wx.EXPAND|wx.ALL)
     620        c += 1
    602621        minSel.Bind(wx.EVT_SLIDER, OnMinSlider)
    603622        minVal = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data['range'][1],0,
    604623            max=data['range'][0][1],typeHint=int,OnLeave=OnMinVal)
    605         maxSizer.Add(minVal,0,WACV)
    606         b95 = wx.Button(G2frame.dataDisplay,-1,'95%',style=wx.BU_EXACTFIT)
    607         b95.Bind(wx.EVT_BUTTON,OnAutoSet)
    608         maxSizer.Add(b95,0,WACV)
     624        maxSizer.Add(minVal,(r,c))
    609625        return maxSizer
    610626       
     
    10741090    mainSizer.Add((5,5),0)
    10751091    MaxSizer = MaxSizer()               #keep this so it can be changed in BackSizer   
    1076     mainSizer.Add(MaxSizer,0,wx.ALIGN_LEFT|wx.EXPAND)
     1092    mainSizer.Add(MaxSizer,0,wx.ALIGN_LEFT|wx.EXPAND|wx.ALL)
    10771093   
    10781094    mainSizer.Add((5,5),0)
     
    13461362        An equal number of pixels are dropped at the minimum and maximum levels.
    13471363        '''
    1348         val = int(event.GetEventObject().GetLabel()[:-1])  # get value from button
    1349         margin = (100-val)/2.
     1364        try:
     1365            val = int(event.GetEventObject().GetStringSelection()[:-1])
     1366            margin = (100-val)/2.
     1367        except:
     1368            margin = 0
     1369            event.GetEventObject().SetSelection(0)
    13501370        new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False)
    1351         controlData['range'][1][0] = int(np.percentile(Page.ImgObj.get_array().compressed(),margin))
    1352         controlData['range'][1][1] = int(np.percentile(Page.ImgObj.get_array().compressed(),100-margin))
     1371        if margin == 0:
     1372            controlData['range'][1] = list(controlData['range'][0])
     1373        else:
     1374            controlData['range'][1][0] = int(np.percentile(Page.ImgObj.get_array().compressed(),margin))
     1375            controlData['range'][1][1] = int(np.percentile(Page.ImgObj.get_array().compressed(),100-margin))
    13531376        DeltOne = controlData['range'][1][1]-max(0.0,controlData['range'][0][0])
    13541377        sqrtDeltOne = math.sqrt(DeltOne)
     
    13591382        Page.ImgObj.set_clim([controlData['range'][1][0],controlData['range'][1][1]])
    13601383        Page.canvas.draw_idle()
    1361        
    1362     maxSizer = wx.FlexGridSizer(0,4,0,5)
    1363     maxSizer.AddGrowableCol(1,1)
    1364     maxSizer.SetFlexibleDirection(wx.HORIZONTAL)
     1384
     1385    maxSizer = wx.GridBagSizer(0,0)
    13651386    sqrtDeltZero = max(1.0,math.sqrt(controlData['range'][0][1]-max(0.0,controlData['range'][0][0])))
    13661387    DeltOne = max(1.0,controlData['range'][1][1]-max(0.0,controlData['range'][0][0]))
    13671388    sqrtDeltOne = math.sqrt(DeltOne)
    1368     maxSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Max intensity'),0,WACV)
     1389    r = c = 0
     1390    maxSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Max intensity'),(r,c))
     1391    c += 1
    13691392    maxSel = wx.Slider(parent=G2frame.dataDisplay,style=wx.SL_HORIZONTAL,
    13701393        value=int(100*sqrtDeltOne/sqrtDeltZero),size=[300,-1])
    1371     maxSizer.Add(maxSel,1,wx.EXPAND)
     1394    maxSizer.Add(maxSel,(r,c),flag=wx.EXPAND)
     1395    maxSizer.AddGrowableCol(c)
     1396    c += 1
    13721397    maxSel.Bind(wx.EVT_SLIDER, OnMaxSlider)
    13731398    maxVal = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,controlData['range'][1],1,min=controlData['range'][0][0]+1,
    13741399        max=controlData['range'][0][1]-1,typeHint=int,OnLeave=OnMaxVal)
    1375     maxSizer.Add(maxVal,0,WACV)
    1376     b99 = wx.Button(G2frame.dataDisplay,-1,'99%',style=wx.BU_EXACTFIT)
    1377     b99.Bind(wx.EVT_BUTTON,OnAutoSet)
    1378     maxSizer.Add(b99,0,WACV)   
    1379     maxSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Min intensity'),0,WACV)
     1400    maxSizer.Add(maxVal,(r,c))
     1401    c += 1
     1402    scaleSel = wx.Choice(G2frame.dataDisplay,choices=("100%","99%","95%","90%","80%"),size=(-1,-1))
     1403    if (controlData['range'][1][0] == controlData['range'][0][0] and
     1404        controlData['range'][1][1] == controlData['range'][0][1]):
     1405        scaleSel.SetSelection(0)
     1406    else:
     1407        scaleSel.SetLabelText("?%")
     1408    scaleSel.Bind(wx.EVT_CHOICE,OnAutoSet)
     1409    maxSizer.Add(scaleSel,(r,c),(2,1),flag=wx.ALIGN_CENTER)
     1410    c = 0
     1411    r = 1
     1412    maxSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Min intensity'),(r,c))
     1413    c += 1
    13801414    minSel = wx.Slider(parent=G2frame.dataDisplay,style=wx.SL_HORIZONTAL,
    13811415        value=int(100*(controlData['range'][1][0]-max(0.0,controlData['range'][0][0]))/DeltOne))
    1382     maxSizer.Add(minSel,1,wx.EXPAND)
     1416    maxSizer.Add(minSel,(r,c),flag=wx.EXPAND|wx.ALL)
     1417    c += 1
    13831418    minSel.Bind(wx.EVT_SLIDER, OnMinSlider)
    13841419    minVal = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,controlData['range'][1],0,
    13851420        max=controlData['range'][0][1],typeHint=int,OnLeave=OnMinVal)
    1386     maxSizer.Add(minVal,0,WACV)
    1387     b95 = wx.Button(G2frame.dataDisplay,-1,'95%',style=wx.BU_EXACTFIT)
    1388     b95.Bind(wx.EVT_BUTTON,OnAutoSet)
    1389     maxSizer.Add(b95,0,WACV)
     1421    maxSizer.Add(minVal,(r,c))
    13901422    mainSizer.Add(maxSizer,0,wx.ALIGN_LEFT|wx.EXPAND)
    13911423
Note: See TracChangeset for help on using the changeset viewer.