Changeset 2603


Ignore:
Timestamp:
Dec 26, 2016 2:24:57 PM (5 years ago)
Author:
toby
Message:

more editing of masks: Put up more title, allow RB to cancel; create config vars for mask sizes;fix bug on incomplete poly mask

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r2602 r2603  
    41244124        Page.canvas.draw()
    41254125    elif G2frame.MaskKey == 's':
    4126         Masks['Points'].append([])
     4126        new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False)
     4127        Page.figure.suptitle('Left-click to create a spot mask',color='r',fontweight='bold')
     4128        Page.canvas.draw()
    41274129    elif G2frame.MaskKey == 'a':
    4128         Masks['Arcs'].append([])
     4130        new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False)
     4131        Page.figure.suptitle('Left-click to create an arc mask',color='r',fontweight='bold')
     4132        Page.canvas.draw()
    41294133    elif G2frame.MaskKey == 'r':
    4130         Masks['Rings'].append([])
     4134        new,plotNum,Page,Plot,lim = G2frame.G2plotNB.FindPlotTab('2D Powder Image','mpl',newImage=False)
     4135        Page.figure.suptitle('Left-click to create a ring mask',color='r',fontweight='bold')
     4136        Page.canvas.draw()
    41314137    G2imG.UpdateMasks(G2frame,Masks)
    41324138   
     
    41554161        G2frame.MaskKey = 'm'
    41564162        (x0,y0),(x1,y1) = Plot.get_position().get_points()
    4157         Page.figure.suptitle('Multiple spot mode on',color='r',fontweight='bold')
     4163        Page.figure.suptitle('Multiple spot mode on, press m or right-click to end',color='r',fontweight='bold')
    41584164        Page.Choice[-1] = 'm: stop multiple spot mask mode'
    41594165        Page.canvas.draw()
     
    42854291                    return
    42864292                if not (event.xdata and event.ydata): return
    4287                 spot = [event.xdata,event.ydata,1.]
     4293                d = GSASIIpath.GetConfigValue('Spot_mask_diameter',1.0)
     4294                spot = [event.xdata,event.ydata,d]
    42884295                Masks['Points'].append(spot)
    42894296                artist = Circle(spot[:2],radius=spot[2]/2,fc='none',ec='r',picker=3)
     
    46274634                return
    46284635            if G2frame.MaskKey == 'm':
    4629                 spot = [Xpos,Ypos,1.]
    4630                 Masks['Points'].append(spot)
    4631                 artist = Circle((Xpos,Ypos),radius=spot[2]/2,fc='none',ec='r',picker=3)
    4632                 Page.figure.gca().add_artist(artist)
    4633                 artist.itemNumber = len(Masks['Points'])-1
    4634                 artist.itemType = 'Spot'
    4635                 G2imG.UpdateMasks(G2frame,Masks)
    4636                 Page.canvas.draw()
     4636                if event.button == 3:
     4637                    ToggleMultiSpotMask(G2frame)
     4638                else:
     4639                    d = GSASIIpath.GetConfigValue('Spot_mask_diameter',1.0)
     4640                    spot = [Xpos,Ypos,d]
     4641                    Masks['Points'].append(spot)
     4642                    artist = Circle((Xpos,Ypos),radius=spot[2]/2,fc='none',ec='r',picker=3)
     4643                    Page.figure.gca().add_artist(artist)
     4644                    artist.itemNumber = len(Masks['Points'])-1
     4645                    artist.itemType = 'Spot'
     4646                    G2imG.UpdateMasks(G2frame,Masks)
     4647                    Page.canvas.draw()
    46374648                return
    4638             elif G2frame.MaskKey == 's' and event.button == 1:
    4639                 Masks['Points'][-1] = [Xpos,Ypos,1.]
     4649            elif G2frame.MaskKey == 's':
     4650                if event.button == 1:
     4651                    d = GSASIIpath.GetConfigValue('Spot_mask_diameter',1.0)
     4652                    spot = [Xpos,Ypos,d]
     4653                    Masks['Points'].append(spot)
     4654                    G2imG.UpdateMasks(G2frame,Masks)
     4655                G2frame.MaskKey = ''
     4656                wx.CallAfter(PlotImage,G2frame,newImage=True)
     4657                return
     4658            elif G2frame.MaskKey == 'r':
     4659                if event.button == 1:
     4660                    tth = G2img.GetTth(Xpos,Ypos,Data)
     4661                    t = GSASIIpath.GetConfigValue('Ring_mask_thickness',0.1)               
     4662                    Masks['Rings'].append([tth,t])
     4663                    G2imG.UpdateMasks(G2frame,Masks)
    46404664                G2frame.MaskKey = ''               
    4641             elif G2frame.MaskKey == 'r' and event.button == 1:
    4642                 tth = G2img.GetTth(Xpos,Ypos,Data)
    4643                 Masks['Rings'][-1] = [tth,0.1]
    4644                 G2frame.MaskKey = ''               
    4645             elif G2frame.MaskKey == 'a' and event.button == 1:
    4646                 tth,azm = G2img.GetTthAzm(Xpos,Ypos,Data)
    4647                 azm = int(azm)               
    4648                 Masks['Arcs'][-1] = [tth,[azm-5,azm+5],0.1]
    4649                 G2frame.MaskKey = ''               
     4665                wx.CallAfter(PlotImage,G2frame,newImage=True)
     4666                return
     4667            elif G2frame.MaskKey == 'a':
     4668                if event.button == 1:
     4669                    tth,azm = G2img.GetTthAzm(Xpos,Ypos,Data)
     4670                    azm = int(azm)               
     4671                    t = GSASIIpath.GetConfigValue('Ring_mask_thickness',0.1)               
     4672                    a = GSASIIpath.GetConfigValue('Arc_mask_azimuth',10.0)               
     4673                    Masks['Arcs'].append([tth,[azm-a/2.,azm+a/2.],t])
     4674                    G2imG.UpdateMasks(G2frame,Masks)
     4675                G2frame.MaskKey = ''
     4676                wx.CallAfter(PlotImage,G2frame,newImage=True)
     4677                return
    46504678            elif G2frame.MaskKey =='p' or G2frame.MaskKey =='f':
    46514679                if G2frame.MaskKey =='p':
     
    46604688                    if len(polygon) <= 2: # too few points
    46614689                        if G2frame.MaskKey =='p':
    4662                             del Masks['Polygons']
     4690                            del Masks['Polygons'][-1]
    46634691                        else:
    46644692                            Masks['Frames'] = []
  • trunk/config_example.py

    r2455 r2603  
    106106GSAS-II is started.
    107107'''
     108
     109Spot_mask_diameter = 1.0
     110'''Specifies the default diameter for creation of spot masks. Default is 1.0 mm
     111'''
     112
     113Ring_mask_thickness = 0.1
     114'''Specifies the default thickness for creation of ring and arc masks.
     115Default is 0.1 degrees 2-theta.
     116'''
     117
     118Arc_mask_azimuth = 10.0
     119'''Specifies the default azimuthal range for creation of arc masks.
     120Default is 10.0 degrees 2-theta.
     121'''
  • trunk/help/gsasII.html

    r2602 r2603  
    31883188right mouse button. The left button click is generated otherwise. 
    31893189
    3190 <h2><a name=Programmers><strong>Programmers documentation</strong></a><strong>:<o:p></o:p></strong></h2>
     3190<h3><a name=Preferences><strong>Configuration Variables</strong></a><strong>:<o:p></o:p></strong></h3>
     3191
     3192<p class=MsoNormal><span style='mso-fareast-font-family:"Times New
     3193Roman"'>GSAS-II provides a number of configuration settings that can
     3194be changed via variables that can be set and saved. These are
     3195controlled in the File/Preferences menu item (on Mac the Preferences
     3196menu is found in the usual place, in the main application menu). These
     3197settings are optionally saved from for subsequent runs in a file named
     3198<tt>config.py</tt>. More information about this can be found in the
     3199<a
     3200href="https://subversion.xray.aps.anl.gov/pyGSAS/sphinxdocs/build/html/GSASIIutil.html#module-config_example">
     3201appropriate section of the Programmer's documentation</a>.
     3202
     3203<h3><a name=Programmers><strong>Programmers documentation</strong></a><strong>:<o:p></o:p></strong></h3>
    31913204
    31923205<p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'>The
     
    55575570  three ways to create spot masks with the keyboard:
    55585571 <UL>
    5559 <LI style='margin-left:.2in'>Press the 's' key and then click on the mask location.   
     5572<LI style='margin-left:.2in'>Press the 's' key and then left-click on the mask location.   
     5573(<a href="#Mac_rightclick">Right-click*</a> to cancel.)
    55605574<LI style='margin-left:.2in'>Press the 'm' key and
    5561    then click successively on multiple locations for spot masks. Press the 'm' key again
     5575   then left-click successively on multiple locations for spot
     5576   masks. Press the 'm' key again or <a href="#Mac_rightclick">right-click*</a>
    55625577   to stop adding spot masks.
    55635578<LI style='margin-left:.2in'>Move the mouse to the position for a
     
    55655580   this can be used while the plot is in Zoom or Pan mode.)
    55665581</UL>
     5582<P style='margin-left:.45in'>The default size for newly-created spot
     5583masks is determined by the <tt>Spot_mask_diameter</tt>
     5584<A Href=#Preferences>configuration variable</a> or 1.0 mm, if not specified.
    55675585<P style='margin-left:.25in'><B>Edit Spot mask location</B> by left-clicking inside
    55685586  or on the edge the of the mask and then drag the spot mask to a new
    55695587  location.
    5570 <P style='margin-left:.25in'><B>Edit Spot mask radius</B> by <a href="#Mac_rightclick">right-clicking*</a> inside
    5571   the mask and then dragging to change the mask size.
     5588<P style='margin-left:.25in'><B>Edit Spot mask radius</B> by
     5589<a href="#Mac_rightclick">right-clicking*</a> inside
     5590the mask and then dragging to change the mask size.
    55725591
    55735592<LI style='margin-left:.5in'>Ring masks: occludes a specific Bragg
     
    55755594  location and thickness of the ring are specified in degrees
    55765595  2-theta.
    5577 <P style='margin-left:.25in'><B>Create Ring masks</B> with a menu command and then by clicking on
    5578   the location on the image that should be masked. Or, by pressing the
    5579   'r' key and then clicking at the appropriate radius. Initially the
    5580   mask is given a thickness of 0.1 degrees.
     5596<P style='margin-left:.25in'><B>Create Ring masks</B> with a menu command and then by left-clicking on
     5597  the mask center; Or, by pressing the
     5598  'r' key and then left-clicking.
     5599(<a href="#Mac_rightclick">Right-click*</a> to cancel.)
     5600<P style='margin-left:.45in'>The default thickness for newly-created ring
     5601masks is determined by the <tt>Ring_mask_thickness</tt>
     5602<A Href=#Preferences>configuration variable</a> or 0.1 degrees
     5603  (2theta) if not specified.
    55815604<P style='margin-left:.25in'><B>Edit Ring mask location</B> by
    55825605  left-clicking on either the inner or outer circle and drag the
     
    55885611<LI style='margin-left:.5in'>Arc masks: occludes a section of a Bragg
    55895612  reflection, similar to a ring mask, except that in addition to the
    5590   location and thickness of the ring (in degrees
    5591   2-theta), the starting and ending
    5592   azimuthal angles are also specified in degrees.
    5593 
    5594 <P style='margin-left:.25in'><B>Create Arc masks</B> with a menu command and then by clicking on
    5595   the location on the image that should be masked. Or, by pressing the
    5596   'a' key and then clicking at the appropriate radius. Initially the
    5597   mask is given a thickness of 0.1 degrees and an azimuthal range of
    5598   10 degrees. 
     5613  location and thickness of the ring, the mask has a starting and ending
     5614  azimuthal angle.
     5615<P style='margin-left:.25in'><B>Create Arc masks</B> with a menu command and then by left-clicking on
     5616  at the mask center; Or, by pressing the
     5617  'a' key and then left-clicking.
     5618(<a href="#Mac_rightclick">Right-click*</a> to cancel.)
     5619<P style='margin-left:.45in'>The default size for newly-created ring
     5620masks is determined by
     5621<A Href=#Preferences>configuration variables</a><BR>
     5622thickness: <tt>Ring_mask_thickness</tt> (0.1 degrees 2theta if not specified) and
     5623<BR>azimuthal range: <tt>Arc_mask_azimuth</tt> (10.0 degrees if not specified.)
    55995624<P style='margin-left:.25in'><B>Edit Arc mask location</B> by
    56005625  left-clicking on either the inner or outer circle and drag the
     
    76407665style='mso-bookmark:Pawley'><o:p>&nbsp;</o:p></span></p>
    76417666
    7642 <p class=MsoNormal style='margin-left:.5in'><span style='mso-bookmark:Pawley'><!-- hhmts start -->Last modified: Sun Dec 25 21:30:18 CST 2016 <!-- hhmts end --></span></p>
     7667<p class=MsoNormal style='margin-left:.5in'><span style='mso-bookmark:Pawley'><!-- hhmts start -->Last modified: Mon Dec 26 14:20:05 CST 2016 <!-- hhmts end --></span></p>
    76437668
    76447669</div>
Note: See TracChangeset for help on using the changeset viewer.