Changeset 4442


Ignore:
Timestamp:
May 26, 2020 2:38:22 PM (16 months ago)
Author:
toby
Message:

better atom selection; try to fix packaging bug

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • install/g2complete/meta.yaml.template

    r4439 r4442  
    1010
    1111requirements:
     12  build:
     13    - python>=3.7
     14    - numpy>=1.18
    1215  run:
    1316    - python>=3.7
  • install/g2full/construct.yaml.template

    r4407 r4442  
    44
    55channels:
    6 #  - http://repo.continuum.io/pkgs/free/
    76  - http://repo.continuum.io/pkgs/main/
    87
  • trunk/GSASIIphsGUI.py

    r4434 r4442  
    10961096#### Phase editing routines
    10971097################################################################################
     1098def getAtomSelections(AtmTbl,action='action'):
     1099    '''get selected atoms from table or ask user if none are selected'''
     1100    indx = AtmTbl.GetSelectedRows()
     1101    indx += [row for row,col in AtmTbl.GetSelectedCells()]
     1102    for top,bottom in zip([r for r,c in AtmTbl.GetSelectionBlockTopLeft()],
     1103                          [r for r,c in AtmTbl.GetSelectionBlockBottomRight()]):
     1104            indx += list(range(top,bottom+1))
     1105    indx = list(set(indx))
     1106    if indx: return indx
     1107    choices = []
     1108    for i in range(AtmTbl.GetNumberRows()):
     1109        val = AtmTbl.GetCellValue(i,0)
     1110        if val in choices:
     1111            val += '_' + str(i)
     1112        choices.append(val)
     1113    if not choices: return
     1114    dlg = G2G.G2MultiChoiceDialog(AtmTbl.GetTopLevelParent(),
     1115        'Select atoms','Select atoms for '+action,choices)
     1116    if dlg.ShowModal() == wx.ID_OK:
     1117        indx = dlg.GetSelections()
     1118    dlg.Destroy()
     1119    return indx
     1120
    10981121def SetPhaseWindow(phasePage,mainSizer=None,Scroll=0):
    10991122    if mainSizer is not None:
     
    34443467        '''Inserts a new atom into list immediately before every selected atom
    34453468        '''
    3446         indx = GetSelectedAtoms()
     3469        indx = getAtomSelections(Atoms)
    34473470        for a in reversed(sorted(indx)):
    34483471            AtomInsert(a,0.,0.,0.)
     
    34643487        '''Adds H atoms to fill out coordination sphere for selected atoms
    34653488        '''
    3466         indx = GetSelectedAtoms()
     3489        indx = getAtomSelections(Atoms)
    34673490        if not indx: return
    34683491        DisAglCtls = {}
     
    35933616        cx = colLabels.index('x')
    35943617        ci = colLabels.index('I/A')
    3595         indx = GetSelectedAtoms()
     3618        indx = getAtomSelections(Atoms)
    35963619        if len(indx) != 1:
    35973620            G2frame.ErrorDialog('Atom move error','Only one atom can be moved')
     
    36923715        HydIds = data['General']['HydIds']
    36933716        ci = colLabels.index('I/A')
    3694         indx = GetSelectedAtoms()
     3717        indx = getAtomSelections(Atoms)
    36953718        IDs = []
    36963719        if not indx: return
     
    37183741            G2frame.dataWindow.AtomEdit.Enable(G2G.wxID_UPDATEHATOM,False)
    37193742        event.StopPropagation()
    3720 
    3721     def GetSelectedAtoms(action='action'):
    3722         '''Get all atoms that are selected by row or by having any cell
    3723         selected. If no atoms are selected ask user.
    3724         '''
    3725         indx = list(set([row for row,col in Atoms.GetSelectedCells()]+Atoms.GetSelectedRows()))
    3726         # if indx:
    3727         #     return indx
    3728         # else:
    3729         #     G2G.G2MessageBox(G2frame,'Warning: no atoms were selected','Nothing selected')
    3730         if indx: return indx
    3731         choices = []
    3732         for i in range(Atoms.GetNumberRows()):
    3733             val = Atoms.GetCellValue(i,0)
    3734             if val in choices:
    3735                 val += '_' + Atoms.GetCellValue(i,5)
    3736             choices.append(val)
    3737         if not choices: return
    3738         dlg = G2G.G2MultiChoiceDialog(Atoms.GetTopLevelParent(),
    3739             'Select atoms','Select atoms for '+action,choices)
    3740         if dlg.ShowModal() == wx.ID_OK:
    3741             indx = dlg.GetSelections()
    3742         dlg.Destroy()
    3743         return indx
    37443743       
    37453744    def AtomRefine(event):
    37463745        colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())]
    37473746        c = colLabels.index('refine')
    3748         indx = GetSelectedAtoms()
     3747        indx = getAtomSelections(Atoms)
    37493748        if not indx: return
    37503749        atomData = data['Atoms']
     
    37683767
    37693768    def AtomModify(event):
    3770         indx = GetSelectedAtoms()
     3769        indx = getAtomSelections(Atoms)
    37713770        if not indx: return
    37723771        atomData = data['Atoms']
     
    38783877
    38793878    def AtomTransform(event):
    3880         indx = GetSelectedAtoms()
     3879        indx = getAtomSelections(Atoms)
    38813880        if not indx: return
    38823881        generalData = data['General']
     
    39473946#            'yz':np.array([[0,i,j] for i in range(3) for j in range(3)])-np.array([1,1,0]),
    39483947#            'xyz':np.array([[i,j,k] for i in range(3) for j in range(3) for k in range(3)])-np.array([1,1,1])}
    3949 #        indx = GetSelectedAtoms()
     3948#        indx = getAtomSelections(Atoms)
    39503949#        if indx:
    39513950#            generalData = data['General']
     
    39913990               
    39923991    def MakeMolecule(event):     
    3993         indx = GetSelectedAtoms()
     3992        indx = getAtomSelections(Atoms)
    39943993        DisAglCtls = {}
    39953994        if indx is not None and len(indx) == 1:
     
    40404039    def OnDistAngle(event,fp=None):
    40414040        'Compute distances and angles'   
    4042         indx = GetSelectedAtoms()
     4041        indx = getAtomSelections(Atoms)
    40434042        Oxyz = []
    40444043        xyz = []
     
    70707069#### Structure drawing GUI stuff               
    70717070################################################################################
    7072     def getAtomSelections(drawAtoms,action='action'):
    7073         '''get selected atoms from table or ask user if none selected'''
    7074         #indx = drawAtoms.GetSelectedRows()
    7075         indx = list(set([row for row,col in drawAtoms.GetSelectedCells()]+
    7076                             drawAtoms.GetSelectedRows()))
    7077         if indx: return indx
    7078         choices = []
    7079         for i in range(drawAtoms.GetNumberRows()):
    7080             val = drawAtoms.GetCellValue(i,0)
    7081             if val in choices:
    7082                 val += '_' + drawAtoms.GetCellValue(i,5)
    7083             choices.append(val)
    7084         if not choices: return
    7085         dlg = G2G.G2MultiChoiceDialog(drawAtoms.GetTopLevelParent(),
    7086             'Select atoms','Select atoms for '+action,choices)
    7087         if dlg.ShowModal() == wx.ID_OK:
    7088             indx = dlg.GetSelections()
    7089         dlg.Destroy()
    7090         return indx
    7091 
    70927071    def SetupDrawingData():
    70937072        generalData = data['General']
Note: See TracChangeset for help on using the changeset viewer.