Changeset 4583 for trunk


Ignore:
Timestamp:
Oct 5, 2020 7:10:21 PM (5 years ago)
Author:
toby
Message:

revise graphics & input for Insert Rigid Body

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIdataGUI.py

    r4578 r4583  
    86868686    elif G2frame.GPXtree.GetItemText(parentID) == 'Phases':
    86878687        data = G2frame.GPXtree.GetItemPyData(item)
    8688         # print('Debug: reload G2phG')
    8689         # import imp
    8690         # imp.reload(G2phG)
     8688        # debug stuff
     8689        # if GSASIIpath.GetConfigValue('debug'):
     8690        #     print('Debug: reloading G2phG')
     8691        #     import imp
     8692        #     imp.reload(G2phG)
     8693        # end debug stuff           
    86918694        G2phG.UpdatePhaseData(G2frame,item,data)
    86928695    elif G2frame.GPXtree.GetItemText(parentID) == 'Restraints':
     
    88158818            G2frame.GPXtree.SetItemPyData(item,data) 
    88168819#end patch
     8820        # debug stuff
     8821        #if GSASIIpath.GetConfigValue('debug'):
     8822        #    import imp
     8823        #    imp.reload(G2pdG)  # for testing changes
     8824        #    print('debug: reloaded',G2pdG)
     8825        # end debug stuff
    88178826        G2pdG.UpdateUnitCellsGrid(G2frame,data)
    88188827        if 'PKS' in G2frame.GPXtree.GetItemText(G2frame.PatternId):
  • TabularUnified trunk/GSASIImath.py

    r4578 r4583  
    983983    no translation applied. To be used for numerical derivatives
    984984   
    985     :param type name: description
    986    
    987     :returns: type name: description
    988    
    989     '''
    990     ''' returns crystal coordinates for atoms described by RBObj
     985    :param array Bmat: Orthogonalization matrix, see :func:`GSASIIlattice.cell2AB`
     986    :param array Cart: 2D array of coordinates
     987    :param array Q: quaternion as an np.array
     988   
     989    :returns: 2D array of fractional coordinates, without translation to origin
    991990    '''
    992991    XYZ = np.zeros_like(Cart)
  • TabularUnified trunk/GSASIIphsGUI.py

    r4573 r4583  
    5252import GSASIIddataGUI as G2ddG
    5353import GSASIIplot as G2plt
     54# if GSASIIpath.GetConfigValue('debug'):
     55#     print('Debug reloading',G2plt)
     56#     import imp
     57#     imp.reload(G2plt)
    5458import GSASIIdataGUI as G2gd
    5559import GSASIIIO as G2IO
     
    616620            title = 'Magnetic atom selection'
    617621        wx.Dialog.__init__(self,parent,wx.ID_ANY,title,
    618             pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     622                            pos=wx.DefaultPosition,size=(450,275),
     623                            style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
    619624        self.panel = wxscroll.ScrolledPanel(self)         #just a dummy - gets destroyed in Draw!
    620625#        self.panel = wx.Panel(self)         #just a dummy - gets destroyed in Draw!
     
    13311336   
    13321337def FindCoordination(ind,data,neighborArray,coordsArray,cmx=0,targets=None):
    1333     'Find atoms coordinating atom ind, speed-up version'
     1338    '''Find atoms coordinating atom ind, speed-up version.
     1339    This only searches to atoms already added to the Draw Array, though we might want
     1340    to search to all atoms in the asymmetric unity (which would mean searching against
     1341    atomsAll, but would also require a reformat of atom entry to match difference in
     1342    format between atoms and drawatoms.
     1343    '''
    13341344    generalData = data['General']
    13351345    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
     
    13371347    atomData = data['Drawing']['Atoms']
    13381348    cx,ct,cs,ci = data['Drawing']['atomPtrs']
     1349    #atomsAll = data['Atoms']
     1350    #cxa,cta,csa,cia = generalData['AtomPtrs']
    13391351    SGData = generalData['SGData']
    13401352    cellArray = G2lat.CellBlock(1)
     
    15491561    for key in defaultDrawing:
    15501562        if key not in drawingData: drawingData[key] = defaultDrawing[key]
     1563
     1564def updateAddRBorientText(G2frame,testRBObj,Bmat):
     1565    '''Update all orientation text on the Add RB panel
     1566    '''
     1567    for i,sizer in enumerate(G2frame.testRBObjSizers['Osizers']):
     1568        sizer.SetLabel('%8.5f'%(testRBObj['rbObj']['Orient'][0][i]))
     1569    A,V = G2mth.Q2AVdeg(testRBObj['rbObj']['Orient'][0])
     1570    testRBObj['rbObj']['OrientVec'][0] = A
     1571    testRBObj['rbObj']['OrientVec'][1:] = np.inner(Bmat,V)
     1572    for i,val in enumerate(testRBObj['rbObj']['OrientVec']):
     1573        G2frame.testRBObjSizers['OrientVecSiz'][i].SetValue(val)
     1574    G2frame.testRBObjSizers['OrientVecSiz'][4].SetValue(
     1575        int(10*testRBObj['rbObj']['OrientVec'][0]))
    15511576           
    15521577def UpdatePhaseData(G2frame,Item,data):
     
    56535678            RMCPdict = data['RMC']['fullrmc']
    56545679            # debug stuff
    5655             if GSASIIpath.GetConfigValue('debug'):
    5656                 print('reloading',G2pwd)
    5657                 import imp
    5658                 imp.reload(G2pwd)
     5680            #if GSASIIpath.GetConfigValue('debug'):
     5681            #    print('reloading',G2pwd)
     5682            #    import imp
     5683            #    imp.reload(G2pwd)
    56595684            # end debug stuff           
    56605685            rname = G2pwd.MakefullrmcRun(pName,data,RMCPdict)
     
    1038010405                return matchTable
    1038110406               
     10407            def OnAzSlide(event):
     10408                '''respond to the azimuth slider moving.
     10409                Save & put value into azimuth edit widget; show Q &
     10410                update the plot and table
     10411                '''
     10412                Obj = event.GetEventObject()
     10413                rbObj['OrientVec'][0] = float(Obj.GetValue())/10.
     10414                for i in range(4):
     10415                    val = rbObj['OrientVec'][i]
     10416                    G2frame.testRBObjSizers['OrientVecSiz'][i].SetValue(val)
     10417                Q = G2mth.AVdeg2Q(rbObj['OrientVec'][0],
     10418                                np.inner(Amat,rbObj['OrientVec'][1:]))
     10419                rbObj['Orient'][0] = Q
     10420                A,V = G2mth.Q2AVdeg(Q)
     10421                rbObj['OrientVec'][1:] = np.inner(Bmat,V)
     10422                for i,sizer in enumerate(G2frame.testRBObjSizers['Osizers']):
     10423                    sizer.SetLabel('%8.5f'%(rbObj['Orient'][0][i]))
     10424                G2plt.PlotStructure(G2frame,data,False,UpdateTable)
     10425                UpdateTable()
     10426               
     10427            def UpdateOrientation(*args,**kwargs):
     10428                '''Respond to a change in the azimuth or vector via
     10429                the edit widget; update Q display & azimuth slider
     10430                '''
     10431                Q = G2mth.AVdeg2Q(rbObj['OrientVec'][0],
     10432                                np.inner(Amat,rbObj['OrientVec'][1:]))
     10433                rbObj['Orient'][0] = Q
     10434                for i,sizer in enumerate(G2frame.testRBObjSizers['Osizers']):
     10435                    sizer.SetLabel('%8.5f'%(rbObj['Orient'][0][i]))
     10436                G2frame.testRBObjSizers['OrientVecSiz'][4].SetValue(
     10437                    int(10*rbObj['OrientVec'][0]))               
     10438                G2plt.PlotStructure(G2frame,data,False,UpdateTable)
     10439                UpdateTable()
     10440               
    1038210441            def UpdateTablePlot(*args,**kwargs):
    1038310442                '''update displayed table and plot
     
    1047310532                out = so.leastsq(objectiveDeltaPos,vals,(selDict,data,rbObj))
    1047410533                data['testRBObj']['rbObj']['Orient'][0][:] = G2mth.normQ(out[0])
    10475                 for i,item in enumerate(Osizers):
    10476                     item.SetLabel('%10.4f'%(data['testRBObj']['rbObj']['Orient'][0][i]))
     10534                updateAddRBorientText(G2frame,data['testRBObj'],Bmat)
    1047710535                UpdateTablePlot()
    1047810536               
     
    1049410552                for i,item in enumerate(Xsizers):
    1049510553                    item.SetValue(data['testRBObj']['rbObj']['Orig'][0][i])
    10496                 for i,item in enumerate(Osizers):
    10497                     item.SetLabel('%10.4f'%(data['testRBObj']['rbObj']['Orient'][0][i]))
     10554                updateAddRBorientText(G2frame,data['testRBObj'],Bmat)
    1049810555                UpdateTablePlot()
    1049910556               
     
    1060210659                Osizers.append(orien)
    1060310660            G2frame.testRBObjSizers.update({'Osizers':Osizers})
     10661            mainSizer.Add(OriSizer)
     10662            mainSizer.Add((5,5),0)
     10663            OriSizer = wx.BoxSizer(wx.HORIZONTAL)
     10664            if 'OrientVec' not in rbObj: rbObj['OrientVec'] = [0.,0.,0.,0.]
     10665            rbObj['OrientVec'][0],V = G2mth.Q2AVdeg(rbObj['Orient'][0])
     10666            rbObj['OrientVec'][1:] = np.inner(Bmat,V)
     10667            OriSizer.Add(wx.StaticText(RigidBodies,wx.ID_ANY,'Orientation azimuth: '),0,WACV)
     10668            OrientVecSiz = []
     10669            OrientVecSiz.append(G2G.ValidatedTxtCtrl(RigidBodies,rbObj['OrientVec'],0,nDig=(10,2),
     10670                            xmin=0.,xmax=360.,typeHint=float,
     10671                                                 OnLeave=UpdateOrientation))
     10672            OriSizer.Add(OrientVecSiz[-1],0,WACV)
     10673            azSlide = wx.Slider(RigidBodies,style=wx.SL_HORIZONTAL)
     10674            azSlide.SetRange(0,3600)
     10675            azSlide.SetValue(int(rbObj['OrientVec'][0]*10.))
     10676            azSlide.Bind(wx.EVT_SLIDER, OnAzSlide)
     10677            OriSizer.Add(azSlide,1)
     10678            mainSizer.Add(OriSizer)
     10679            OriSizer = wx.BoxSizer(wx.HORIZONTAL)
     10680            OriSizer.Add(wx.StaticText(RigidBodies,wx.ID_ANY,'Orientation vector'),0,WACV)
     10681            for ix,lbl in enumerate('xyz'):
     10682                OriSizer.Add(wx.StaticText(RigidBodies,wx.ID_ANY,'  '+lbl+': '),0,WACV)
     10683                OrientVecSiz.append(G2G.ValidatedTxtCtrl(RigidBodies,rbObj['OrientVec'],ix+1,nDig=(10,4),
     10684                            xmin=-1.,xmax=1.,typeHint=float,
     10685                                                 OnLeave=UpdateOrientation))
     10686                OriSizer.Add(OrientVecSiz[-1],0,WACV)
     10687            OrientVecSiz.append(azSlide)
     10688            OriSizer.Add(wx.StaticText(RigidBodies,wx.ID_ANY,' (frac coords)'),0,WACV)
     10689            G2frame.testRBObjSizers.update({'OrientVecSiz':OrientVecSiz})
    1060410690            mainSizer.Add(OriSizer)
    1060510691            mainSizer.Add((5,5),0)
  • TabularUnified trunk/GSASIIplot.py

    r4578 r4583  
    83898389                               
    83908390    def SetRBOrigText():
     8391        '''Called w/Locate & Insert Rigid Body to update text in DataWindow
     8392        when the RB origin is moved via a mouse drag
     8393        '''
    83918394        page = getSelection()
    83928395        if page:
     
    84018404           
    84028405    def SetRBOrienText():
     8406        '''Called w/Locate & Insert Rigid Body to update text in DataWindow
     8407        when the RB orientation is changed via a mouse drag
     8408        '''
    84038409        page = getSelection()
    84048410        if page:
    84058411            if G2frame.phaseDisplay.GetPageText(page) == 'RB Models':
    8406                 for i,sizer in enumerate(G2frame.testRBObjSizers['Osizers']):
    8407                     sizer.SetLabel('%8.5f'%(testRBObj['rbObj']['Orient'][0][i]))
     8412                G2phG.updateAddRBorientText(G2frame,testRBObj,Bmat)
    84088413        if pageCallback:
    84098414            try:
     
    87088713        GL.glDisable(GL.GL_COLOR_MATERIAL)
    87098714        GL.glLightfv(GL.GL_LIGHT0,GL.GL_AMBIENT,[.2,.2,.2,1])
     8715
     8716    def RenderRBtriplet(orig,Q,Bmat):
     8717        '''draw an axes triplet located at the origin of a rigid body
     8718        and with the x, y & z axes drawn as red, green and blue.
     8719        '''
     8720        GL.glLightfv(GL.GL_LIGHT0,GL.GL_AMBIENT,[.7,.7,.7,1])
     8721        GL.glEnable(GL.GL_COLOR_MATERIAL)
     8722        GL.glLineWidth(3)
     8723        GL.glEnable(GL.GL_BLEND)
     8724        GL.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA)
     8725        GL.glEnable(GL.GL_LINE_SMOOTH)
     8726        GL.glPushMatrix()
     8727        GL.glTranslate(*orig)
     8728        GL.glBegin(GL.GL_LINES)
     8729        lines = G2mth.RotateRBXYZ(Bmat,np.eye(3),Q)
     8730        colors = [Rd,Gr,Bl]
     8731        # lines along axial directions
     8732        for line,color in zip(lines,colors):
     8733            GL.glColor3ubv(color)
     8734            GL.glVertex3fv(np.zeros(3))
     8735            GL.glVertex3fv(line)
     8736        # arrows on line ends, colored by planes
     8737        for i in range(3):
     8738            for j in (1,-1):
     8739                GL.glColor3ubv(colors[(i+1)%3])
     8740                GL.glVertex3fv(lines[i])
     8741                GL.glVertex3fv(0.7*lines[i]+ j*0.2*lines[(i+1)%3])
     8742                GL.glColor3ubv(colors[(i+2)%3])
     8743                GL.glVertex3fv(lines[i])
     8744                GL.glVertex3fv(0.7*lines[i]+ j*0.2*lines[(i+2)%3])
     8745        # draw vector part of Q in white
     8746        A,V = G2mth.Q2AVdeg(Q)
     8747        Vfrac = np.inner(Bmat,V)
     8748        GL.glColor3ubv([255,255,255])
     8749        GL.glVertex3fv(np.zeros(3))
     8750        GL.glVertex3fv(1.5*Vfrac)
     8751        GL.glEnd()
     8752        GL.glPopMatrix()
     8753        GL.glColor4ubv([0,0,0,0])
     8754        GL.glDisable(GL.GL_LINE_SMOOTH)
     8755        GL.glDisable(GL.GL_BLEND)
     8756        GL.glDisable(GL.GL_COLOR_MATERIAL)
     8757        GL.glLightfv(GL.GL_LIGHT0,GL.GL_AMBIENT,[.2,.2,.2,1])
     8758
    87108759       
    87118760    def RenderPlane(plane,color):
     
    92999348                RenderBonds(x,y,z,rbBonds[ind],0.03,Gr)
    93009349                RenderLabel(x,y,z,name,0.2,wxOrange,matRot)
     9350            RenderRBtriplet(testRBObj['rbObj']['Orig'][0],
     9351                            testRBObj['rbObj']['Orient'][0],
     9352                            Bmat)
    93019353        if len(mcsaModels) > 1 and pageName == 'MC/SA':             #skip the default MD entry
    93029354            for ind,[x,y,z] in enumerate(mcsaXYZ):
Note: See TracChangeset for help on using the changeset viewer.