Changeset 752


Ignore:
Timestamp:
Sep 6, 2012 12:05:03 PM (10 years ago)
Author:
vondreele
Message:

add peak distance, view point selection & distance options
allow modification of view direction

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r748 r752  
    4141[ wxID_FOURCALC, wxID_FOURSEARCH, wxID_FOURCLEAR, wxID_PEAKSMOVE, wxID_PEAKSCLEAR,
    4242    wxID_CHARGEFLIP, wxID_PEAKSUNIQUE, wxID_PEAKSDELETE, wxID_PEAKSDA,
    43 ] = [wx.NewId() for item in range(9)]
     43    wxID_PEAKSDISTVP, wxID_PEAKSVIEWPT,
     44] = [wx.NewId() for item in range(11)]
    4445
    4546[ wxID_PWDRADD, wxID_HKLFADD, wxID_DATADELETE,
     
    5455    wxID_DRAWVIEWPOINT, wxID_DRAWTRANSFORM, wxID_DRAWDELETE, wxID_DRAWFILLCELL,
    5556    wxID_DRAWADDEQUIV, wxID_DRAWFILLCOORD, wxID_DRAWDISAGLTOR,  wxID_DRAWPLANE,
    56 ] = [wx.NewId() for item in range(12)]
     57    wxID_DRAWDISTVP,
     58] = [wx.NewId() for item in range(13)]
    5759
    5860[ wxID_DRAWRESTRBOND, wxID_DRAWRESTRANGLE, wxID_DRAWRESTRPLANE, wxID_DRAWRESTRCHIRAL,
     
    576578        self.DrawAtomEdit.Append(id=wxID_DRAWDELETE, kind=wx.ITEM_NORMAL,text='Delete atoms',
    577579            help='Delete atoms from drawing set')
     580        self.DrawAtomCompute.Append(id=wxID_DRAWDISTVP, kind=wx.ITEM_NORMAL,text='View pt. dist.',
     581            help='Compute distance of selected atoms from view point')   
    578582        self.DrawAtomCompute.Append(id=wxID_DRAWDISAGLTOR, kind=wx.ITEM_NORMAL,text='Dist. Ang. Tors.',
    579583            help='Compute distance, angle or torsion for 2-4 selected atoms')   
     
    620624        self.MapPeaksEdit.Append(id=wxID_PEAKSMOVE, kind=wx.ITEM_NORMAL,text='Move peaks',
    621625            help='Move selected peaks to atom list')
     626        self.MapPeaksEdit.Append(id=wxID_PEAKSVIEWPT, kind=wx.ITEM_NORMAL,text='View point',
     627            help='View point is 1st peak selected')
     628        self.MapPeaksEdit.Append(id=wxID_PEAKSDISTVP, kind=wx.ITEM_NORMAL,text='View pt. dist.',
     629            help='Compute distance of selected peaks from view point')   
    622630        self.MapPeaksEdit.Append(id=wxID_PEAKSDA, kind=wx.ITEM_NORMAL,text='Calc dist/ang',
    623631            help='Calculate distance or angle for selection')
  • trunk/GSASIIphsGUI.py

    r751 r752  
    23692369        PlaneData['Cell'] = generalData['Cell'][1:] #+ volume
    23702370        G2str.BestPlane(PlaneData)
     2371       
     2372    def OnDrawDistVP(event):
     2373        # distance to view point
     2374        indx = drawAtoms.GetSelectedRows()
     2375        if not indx:
     2376            print '***** ERROR - no atoms selected'
     2377            return
     2378        generalData = data['General']
     2379        Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])           
     2380        drawingData = data['Drawing']
     2381        viewPt = np.array(drawingData['viewPoint'][0])
     2382        print ' Distance from view point at %.3f %.3f %.3f to:'%(viewPt[0],viewPt[1],viewPt[2])
     2383        atomDData = drawingData['Atoms']
     2384        colLabels = [drawAtoms.GetColLabelValue(c) for c in range(drawAtoms.GetNumberCols())]
     2385        cx = colLabels.index('x')
     2386        cn = colLabels.index('Name')
     2387        for i in indx:
     2388            atom = atomDData[i]
     2389            Dx = np.array(atom[cx:cx+3])-viewPt
     2390            dist = np.sqrt(np.sum(np.inner(Amat,Dx)**2,axis=0))
     2391            print 'Atom: %8s (%12s) distance = %.3f'%(atom[cn],atom[cx+3],dist)
    23712392   
    23722393    def OnDrawDAT(event):
     
    25572578                G2plt.PlotStructure(G2frame,data)
    25582579               
    2559                
     2580            def OnViewDir(event):
     2581                Obj = event.GetEventObject()
     2582                viewDir = Obj.GetValue().split()
     2583                try:
     2584                    VD = [float(viewDir[i]) for i in range(3)]
     2585                except (ValueError,IndexError):
     2586                    VD = drawingData['viewDir']
     2587                Obj.SetValue('%.3f %.3f %.3f'%(VD[0],VD[1],VD[2]))
     2588                drawingData['viewDir'] = VP
     2589                G2plt.PlotStructure(G2frame,data)
     2590                               
    25602591            showSizer = wx.BoxSizer(wx.VERTICAL)           
    25612592            lineSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    25672598            VD = drawingData['viewDir']
    25682599            viewDir = wx.TextCtrl(dataDisplay,value='%.3f %.3f %.3f'%(VD[0],VD[1],VD[2]),
    2569                 style=wx.TE_READONLY,size=wx.Size(140,20),name='viewDir')
    2570             viewDir.SetBackgroundColour(VERY_LIGHT_GREY)
     2600                style=wx.TE_PROCESS_ENTER,size=wx.Size(140,20),name='viewDir')
     2601            viewDir.Bind(wx.EVT_TEXT_ENTER,OnViewDir)
     2602            viewDir.Bind(wx.EVT_KILL_FOCUS,OnViewDir)
    25712603            lineSizer.Add(viewDir,0,wx.ALIGN_CENTER_VERTICAL)
    25722604            showSizer.Add(lineSizer)
     
    40564088                    wx.EndBusyCursor()
    40574089                G2plt.PlotStructure(G2frame,data)
     4090               
     4091    def OnPeaksViewPoint(event):
     4092        # set view point
     4093        indx = MapPeaks.GetSelectedRows()
     4094        if not indx:
     4095            print '***** ERROR - no peaks selected'
     4096            return
     4097        mapPeaks = data['Map Peaks']
     4098        drawingData = data['Drawing']
     4099        drawingData['viewPoint'][0] = mapPeaks[indx[0]][1:4]
     4100        G2plt.PlotStructure(G2frame,data)
    40584101   
     4102    def OnPeaksDistVP(event):
     4103        # distance to view point
     4104        indx = MapPeaks.GetSelectedRows()
     4105        if not indx:
     4106            print '***** ERROR - no peaks selected'
     4107            return
     4108        generalData = data['General']
     4109        Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])           
     4110        mapPeaks = data['Map Peaks']
     4111        drawingData = data['Drawing']
     4112        viewPt = np.array(drawingData['viewPoint'][0])
     4113        print ' Distance from view point at %.3f %.3f %.3f to:'%(viewPt[0],viewPt[1],viewPt[2])
     4114        colLabels = [MapPeaks.GetColLabelValue(c) for c in range(MapPeaks.GetNumberCols())]
     4115        cx = colLabels.index('x')
     4116        cm = colLabels.index('mag')
     4117        for i in indx:
     4118            peak = mapPeaks[i]
     4119            Dx = np.array(peak[cx:cx+3])-viewPt
     4120            dist = np.sqrt(np.sum(np.inner(Amat,Dx)**2,axis=0))
     4121            print 'Peak: %5d mag= %8.2f distance = %.3f'%(i,peak[cm],dist)
     4122
    40594123    def OnPeaksDA(event):
    40604124        #distance, angle
     
    40734137        else:
    40744138            print ' angle for atoms %s = %.2f'%(str(indx),G2mth.getRestAngle(xyz,Amat))
    4075                    
    4076                
     4139                                   
    40774140    def OnFourierMaps(event):
    40784141        generalData = data['General']
     
    42874350            G2frame.dataFrame.Bind(wx.EVT_MENU, FillUnitCell, id=G2gd.wxID_DRAWFILLCELL)
    42884351            G2frame.dataFrame.Bind(wx.EVT_MENU, DrawAtomsDelete, id=G2gd.wxID_DRAWDELETE)
     4352            G2frame.dataFrame.Bind(wx.EVT_MENU, OnDrawDistVP, id=G2gd.wxID_DRAWDISTVP)
    42894353            G2frame.dataFrame.Bind(wx.EVT_MENU, OnDrawDAT, id=G2gd.wxID_DRAWDISAGLTOR)
    42904354            G2frame.dataFrame.Bind(wx.EVT_MENU, OnDrawPlane, id=G2gd.wxID_DRAWPLANE)
     
    43114375            G2frame.dataFrame.SetMenuBar(G2frame.dataFrame.MapPeaksMenu)
    43124376            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksMove, id=G2gd.wxID_PEAKSMOVE)
     4377            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksViewPoint, id=G2gd.wxID_PEAKSVIEWPT)
     4378            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksDistVP, id=G2gd.wxID_PEAKSDISTVP)
    43134379            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksDA, id=G2gd.wxID_PEAKSDA)
    43144380            G2frame.dataFrame.Bind(wx.EVT_MENU, OnPeaksUnique, id=G2gd.wxID_PEAKSUNIQUE)
Note: See TracChangeset for help on using the changeset viewer.