Changeset 1407


Ignore:
Timestamp:
Jul 3, 2014 11:17:39 AM (7 years ago)
Author:
vondreele
Message:

implement copy equation in parametric stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1405 r1407  
    136136
    137137[ wxID_RENAMESEQSEL,wxID_SAVESEQSEL,wxID_SAVESEQSELCSV,wxID_PLOTSEQSEL,
    138   wxADDSEQVAR,wxDELSEQVAR,wxEDITSEQVAR,
     138  wxADDSEQVAR,wxDELSEQVAR,wxEDITSEQVAR,wxCOPYPARFIT,
    139139  wxADDPARFIT,wxDELPARFIT,wxEDITPARFIT,wxDOPARFIT,
    140 ] = [wx.NewId() for item in range(11)]
     140] = [wx.NewId() for item in range(12)]
    141141
    142142[ wxID_MODELCOPY,wxID_MODELFIT,wxID_MODELADD,wxID_ELEMENTADD,wxID_ELEMENTDELETE,
     
    28072807            help='Add a new equation to minimize')
    28082808        self.SequentialPfit.Append(
     2809            id=wxCOPYPARFIT, kind=wx.ITEM_NORMAL,text='Copy equation',
     2810            help='Copy an equation to minimize - edit it next')
     2811        self.SequentialPfit.Append(
    28092812            id=wxDELPARFIT, kind=wx.ITEM_NORMAL,text='Delete equation',
    28102813            help='Delete an equation for parametric minimization')
     
    40154018        if dlg.Show():
    40164019            newNames = dlg.GetValues()           
    4017             variableLabels.update(dict(zip(colNames,newNames)))
     4020            variableLabels.update(dict(zip(colNames,newNames)))
     4021        data['variableLabels'] = variableLabels
    40184022        dlg.Destroy()
    40194023        UpdateSeqResults(G2frame,data,G2frame.dataDisplay.GetSize()) # redisplay variables
     
    44964500        usedvarlist = []
    44974501        for obj in Controls['SeqParFitEqList']:
    4498             eq = obj.expression           
    44994502            for var in obj.freeVars:
    45004503                if obj.freeVars[var][0] not in usedvarlist: usedvarlist.append(obj.freeVars[var][0])
     
    45114514            Controls['SeqParFitEqList'].append(obj)
    45124515            EnableParFitEqMenus()
     4516            if Controls['SeqParFitEqList']: DoParEqFit(event)
     4517               
     4518    def CopyParFitEq(event):
     4519        'Copy an existing parametric equation to be fit to sequential results'
     4520        # compile the variable names used in previous freevars to avoid accidental name collisions
     4521        usedvarlist = []
     4522        for obj in Controls['SeqParFitEqList']:
     4523            for var in obj.freeVars:
     4524                if obj.freeVars[var][0] not in usedvarlist: usedvarlist.append(obj.freeVars[var][0])
     4525        txtlst = [obj.GetDepVar()+' = '+obj.expression for obj in Controls['SeqParFitEqList']]
     4526        if len(txtlst) == 1:
     4527            selected = 0
     4528        else:
     4529            selected = ItemSelector(
     4530                txtlst,G2frame.dataFrame,
     4531                multiple=False,
     4532                title='Select a parametric equation to copy',
     4533                header='Copy equation')
     4534        if selected is not None:
     4535            newEqn = copy.deepcopy(Controls['SeqParFitEqList'][selected])
     4536            for var in newEqn.freeVars:
     4537                newEqn.freeVars[var][0] = G2obj.MakeUniqueLabel(newEqn.freeVars[var][0],usedvarlist)
     4538            dlg = G2exG.ExpressionDialog(
     4539                G2frame.dataDisplay,indepVarDict,
     4540                newEqn,
     4541                depVarDict=depVarDict,
     4542                header="Edit the formula for this minimization function",
     4543                ExtraButton=['Fit',SingleParEqFit])
     4544            newobj = dlg.Show(True)
     4545            if newobj:
     4546                calcobj = G2obj.ExpressionCalcObj(newobj)
     4547                Controls['SeqParFitEqList'].append(newobj)
     4548                EnableParFitEqMenus()
    45134549            if Controls['SeqParFitEqList']: DoParEqFit(event)
    45144550                                           
     
    46454681    G2frame.dataFrame.Bind(wx.EVT_MENU, EditPseudoVar, id=wxEDITSEQVAR)
    46464682    G2frame.dataFrame.Bind(wx.EVT_MENU, AddNewParFitEq, id=wxADDPARFIT)
     4683    G2frame.dataFrame.Bind(wx.EVT_MENU, CopyParFitEq, id=wxCOPYPARFIT)
    46474684    G2frame.dataFrame.Bind(wx.EVT_MENU, DelParFitEq, id=wxDELPARFIT)
    46484685    G2frame.dataFrame.Bind(wx.EVT_MENU, EditParFitEq, id=wxEDITPARFIT)
Note: See TracChangeset for help on using the changeset viewer.