Changeset 2d107b8 in sasview
- Timestamp:
- Dec 11, 2008 6:04:28 PM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f39511b
- Parents:
- b2c3225
- Location:
- guiframe/local_perspectives/plotting
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/Arc.py
rb06ef8c r2d107b8 34 34 color=self.color) 35 35 self.npts = 20 36 36 self.has_move= False 37 37 self.connect_markers([self.inner_circle]) 38 38 self.update() … … 115 115 116 116 def moveend(self, ev): 117 self.has_move= False 117 118 self.base.moveend(ev) 118 119 … … 131 132 self._inner_mouse_x = x 132 133 self._inner_mouse_y = y 133 134 self.has_move= True 134 135 self.base.base.update() 135 136 -
guiframe/local_perspectives/plotting/DataPanel.py
r768656e r2d107b8 18 18 from sans.guicomm.events import StatusEvent ,NewPlotEvent 19 19 20 21 from SlicerParameters import SlicerEvent 20 22 from binder import BindArtist 23 (InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() 21 24 #from SlicerParameters import SlicerEvent 22 25 #(InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() … … 375 378 self.slicer_z = 5 376 379 self.slicer = None 377 #self.parent.Bind(EVT_INTERNAL, self._onEVT_INTERNAL)380 self.parent.Bind(EVT_INTERNAL, self._onEVT_INTERNAL) 378 381 self.axes_frozen = False 379 382 ## Graph … … 457 460 458 461 id = wx.NewId() 459 slicerpop.Append(id, '&Sector') 460 wx.EVT_MENU(self, id, self.onSector) 461 462 462 slicerpop.Append(id, '&Sector Q') 463 wx.EVT_MENU(self, id, self.onSectorQ) 464 465 id = wx.NewId() 466 slicerpop.Append(id, '&Sector Phi') 467 wx.EVT_MENU(self, id, self.onSectorPhi) 463 468 464 469 … … 524 529 #self.slicer.update() 525 530 self.draw() 531 532 533 def _getEmptySlicerEvent(self): 534 return SlicerEvent(type=None, 535 params=None, 536 obj_class=None) 537 def _onEVT_INTERNAL(self, event): 538 """ 539 I don't understand why Unbind followed by a Bind 540 using a modified self.slicer doesn't work. 541 For now, I post a clear event followed by 542 a new slicer event... 543 """ 544 self._setSlicer(event.slicer) 545 546 def _setSlicer(self, slicer): 547 # Clear current slicer 548 #printEVT("Plotter2D._setSlicer %s" % slicer) 549 550 if not self.slicer == None: 551 self.slicer.clear() 552 553 self.slicer_z += 1 554 self.slicer = slicer(self, self.subplot, zorder=self.slicer_z) 555 self.subplot.set_ylim(-self.qmax, self.qmax) 556 self.subplot.set_xlim(-self.qmax, self.qmax) 557 self.update() 558 self.slicer.update() 559 560 # Post slicer event 561 event = self._getEmptySlicerEvent() 562 event.type = self.slicer.__class__.__name__ 563 event.obj_class = self.slicer.__class__ 564 event.params = self.slicer.get_params() 565 wx.PostEvent(self.parent, event) 566 526 567 def onCircular(self, event): 527 568 """ 528 perform circular averaging 529 """ 569 perform circular averaging on Data2D 570 """ 571 530 572 from DataLoader.manipulations import CircularAverage 531 def onSector(self, event): 532 """ 533 Perform sector averaging 573 Circle = CircularAverage( r_min= -self.qmax, r_max= self.qmax, bin_width=0.001) 574 circ = Circle(self.data2D) 575 from sans.guiframe.dataFitting import Data1D 576 if hasattr(circ,"dxl"): 577 dxl= circ.dxl 578 else: 579 dxl= None 580 if hasattr(circ,"dxw"): 581 dxw= circ.dxw 582 else: 583 dxw= None 584 585 new_plot = Data1D(x=circ.x,y=circ.y,dy=circ.dy,dxl=dxl,dxw=dxw) 586 new_plot.name = "Circ avg "+ self.data2D.name 587 new_plot.source=self.data2D.source 588 new_plot.info=self.data2D.info 589 new_plot.interactive = True 590 #print "loader output.detector",output.source 591 new_plot.detector =self.data2D.detector 592 593 # If the data file does not tell us what the axes are, just assume... 594 new_plot.xaxis("\\rm{q}","A^{-1}") 595 new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 596 new_plot.group_id = "Circ avg "+ self.data2D.name 597 self.scale = 'log' 598 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=new_plot.name)) 599 600 601 602 def onSectorQ(self, event): 603 """ 604 Perform sector averaging on Q 605 """ 606 from SectorSlicer import SectorInteractorQ 607 608 self.slicer_z += 1 609 self.slicer = SectorInteractorQ(self, self.subplot, zorder=self.slicer_z) 610 self.subplot.set_ylim(-self.qmax, self.qmax) 611 self.subplot.set_xlim(-self.qmax, self.qmax) 612 self.update() 613 self.slicer.update() 614 615 616 def onSectorPhi(self, event): 617 """ 618 Perform sector averaging on Phi 534 619 """ 535 620 from SectorSlicer import SectorInteractor … … 544 629 545 630 def onClearSlicer(self, event): 546 print "on clear" 547 631 """ 632 Clear the slicer on the plot 633 """ 634 if not self.slicer==None: 635 self.slicer.clear() 636 self.subplot.figure.canvas.draw() 637 self.slicer = None 638 639 # Post slicer None event 640 event = self._getEmptySlicerEvent() 641 wx.PostEvent(self.parent, event) 548 642 549 643 def _onEditDetector(self, event): … … 553 647 def _onToggleScale(self, event): 554 648 """ 555 toggle axisand replot image649 toggle pixel scale and replot image 556 650 """ 557 651 if self.scale == 'log': … … 562 656 self.ymax_2D,self.zmin_2D ,self.zmax_2D ) 563 657 wx.PostEvent(self.parent, StatusEvent(status="Image is in %s scale"%self.scale)) 658 659 660 661 662 564 663 565 664 class View1DModelPanel2D( View1DPanel2D): -
guiframe/local_perspectives/plotting/Edge.py
rb06ef8c r2d107b8 41 41 42 42 self.npts = 20 43 43 self.has_move= False 44 44 self.connect_markers([self.line]) 45 45 self.update() … … 94 94 95 95 def moveend(self, ev): 96 self.has_move= False 96 97 self.base.moveend(ev) 97 98 … … 108 109 self.theta= math.atan2(y,x) 109 110 110 111 self.has_move= True 111 112 self.base.base.update() 112 113 -
guiframe/local_perspectives/plotting/SectorSlicer.py
r768656e r2d107b8 55 55 self.update() 56 56 self._post_data() 57 58 57 # Bind to slice parameter events 59 58 #self.base.parent.Bind(SlicerParameters.EVT_SLICER_PARS, self._onEVT_SLICER_PARS) … … 67 66 self.base.update() 68 67 69 68 """ 70 69 def update_and_post(self): 71 70 self.update() 72 71 self._post_data() 73 72 74 73 """ 75 74 def save_data(self, path, image, x, y): 76 75 output = open(path, 'w') … … 91 90 self.outer_circle.clear() 92 91 self.inner_circle.clear() 92 self.inner_radius.clear() 93 self.outer_radius.clear() 93 94 #self.base.connect.disconnect() 94 95 #self.base.parent.Unbind(SlicerParameters.EVT_SLICER_PARS) … … 99 100 resetting the widgets. 100 101 """ 101 # Update locations 102 self.inner_circle.update() 103 self.outer_circle.update() 104 r1=self.inner_circle.get_radius() 105 r2=self.outer_circle.get_radius() 106 #print"annulus update",r1, r2 107 if self.inner_radius.update(r1,r2)==1: 108 #print "went here" 102 # Update locations 103 if self.inner_circle.has_move: 104 print "inner circle has moved" 105 self.inner_circle.update() 106 r1=self.inner_circle.get_radius() 107 r2=self.outer_circle.get_radius() 108 self.inner_radius.update(r1,r2) 109 self.outer_radius.update(r1,r2) 110 if self.outer_circle.has_move: 111 print "outer circle has moved" 112 self.outer_circle.update() 113 r1=self.inner_circle.get_radius() 114 r2=self.outer_circle.get_radius() 115 self.inner_radius.update(r1,r2) 116 self.outer_radius.update(r1,r2) 117 if self.inner_radius.has_move: 118 print "inner radius has moved" 119 self.inner_radius.update() 109 120 self.inner_circle.update(theta1=self.inner_radius.get_radius(), theta2=None) 110 self.outer_circle.update(theta1=self.inner_radius.get_radius(),theta2=None) 111 112 if self.outer_radius.update(r1,r2)==1:#self.outer_circle.update(self.outer_radius.get_radius()) 121 self.outer_circle.update(theta1=self.inner_radius.get_radius(), theta2=None) 122 if self.outer_radius.has_move: 123 print "outer radius has moved" 124 self.outer_radius.update() 113 125 self.inner_circle.update(theta1=None, theta2=self.outer_radius.get_radius()) 114 self.outer_circle.update(theta1=None, theta2=self.outer_radius.get_radius())115 116 126 self.outer_circle.update(theta1=None, theta2=self.outer_radius.get_radius()) 127 128 117 129 def save(self, ev): 118 130 """ … … 123 135 self.inner_circle.save(ev) 124 136 self.outer_circle.save(ev) 125 126 137 def _post_data(self): 127 """ post data""" 138 pass 139 def post_data(self,new_sector ): 140 """ post data averaging in Q""" 128 141 rmin=self.inner_circle.get_radius() 129 142 rmax=self.outer_circle.get_radius() 130 143 phimin=self.inner_radius.get_radius() 131 144 phimax=self.outer_radius.get_radius() 132 from DataLoader.manipulations import SectorQ, SectorPhi 133 sectQ = SectorQ(r_min=rmin, r_max=rmax, phi_min=phimin, phi_max=phimax) 134 sectorQ = sectQ(self.base.data2D) 135 136 sectPhi = SectorPhi(r_min=rmin, r_max=rmax, phi_min=phimin, phi_max=phimax) 137 sectorPhi = sectPhi(self.base.data2D) 145 #from DataLoader.manipulations import SectorQ 146 sect = new_sector(r_min=rmin, r_max=rmax, phi_min=phimin, phi_max=phimax) 147 sector = sect(self.base.data2D) 148 138 149 from sans.guiframe.dataFitting import Data1D 139 if hasattr(sector Q,"dxl"):140 dxl= sector Q.dxl150 if hasattr(sector,"dxl"): 151 dxl= sector.dxl 141 152 else: 142 153 dxl= None 143 if hasattr(sector Q,"dxw"):144 dxw= sector Q.dxw154 if hasattr(sector,"dxw"): 155 dxw= sector.dxw 145 156 else: 146 157 dxw= None 147 158 148 new_plot1 = Data1D(x=sectorQ.x,y=sectorQ.y,dy=sectorQ.dy,dxl=dxl,dxw=dxw) 149 new_plot1.name = "SectorQ ("+ self.base.data2D.name+")" 150 if hasattr(sectorPhi,"dxl"): 151 dxl= sectorPhi.dxl 152 else: 153 dxl= None 154 if hasattr(sectorPhi,"dxw"): 155 dxw= sectorPhi.dxw 156 else: 157 dxw= None 158 new_plot2 = Data1D(x=sectorPhi.x,y=sectorPhi.y,dy=sectorPhi.dy,dxl=dxl,dxw=dxw) 159 new_plot2.name = "SectorPhi ("+ self.base.data2D.name+")" 160 self.plot_data( new_plot1) 161 self.plot_data( new_plot2) 162 163 164 def plot_data(self, new_plot): 165 """ 166 plot a new data 1D corresponding to the phi and Q sector average 167 """ 159 new_plot = Data1D(x=sector.x,y=sector.y,dy=sector.dy,dxl=dxl,dxw=dxw) 160 new_plot.name = str(new_sector.__name__) +"("+ self.base.data2D.name+")" 161 162 163 168 164 new_plot.source=self.base.data2D.source 169 165 new_plot.info=self.base.data2D.info … … 175 171 new_plot.yaxis(self.base.data2D._yaxis,self.base.data2D._yunit) 176 172 new_plot.group_id = "sector"+self.base.data2D.name 177 wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot, title=new_plot.name)) 173 wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot, 174 title=str(new_sector.__name__) )) 178 175 179 176 … … 209 206 params["inner_radius"] = self.inner_circle._inner_mouse_x 210 207 params["outer_radius"] = self.outer_circle._inner_mouse_x 211 params["phi_min"] = self.inner_radi ous.get_radious()212 params["phi_max"] = self.inner_radi ous.get_radious()208 params["phi_min"] = self.inner_radius.get_radius() 209 params["phi_max"] = self.inner_radius.get_radius() 213 210 params["nbins"] = self.nbins 214 211 return params … … 218 215 inner = params["inner_radius"] 219 216 outer = params["outer_radius"] 217 phi_min= params["phi_min"] 218 phi_min=params["phi_max"] 220 219 self.nbins = int(params["nbins"]) 220 221 221 222 self.inner_circle.set_cursor(inner, self.inner_circle._inner_mouse_y) 222 223 self.outer_circle.set_cursor(outer, self.outer_circle._inner_mouse_y) 224 self.inner_radius.set_cursor(inner, self.inner_circle._inner_mouse_y) 225 self.outer_radius.set_cursor(outer, self.outer_circle._inner_mouse_y) 223 226 self._post_data() 224 227 … … 232 235 self.base.draw() 233 236 234 237 class SectorInteractorQ(SectorInteractor): 238 def __init__(self,base,axes,color='black', zorder=3): 239 SectorInteractor.__init__(self, base, axes, color=color) 240 self.base=base 241 self._post_data() 242 def _post_data(self): 243 from DataLoader.manipulations import SectorQ 244 self.post_data(SectorQ )
Note: See TracChangeset
for help on using the changeset viewer.