Changeset e8c96f5 in sasview
- Timestamp:
- Dec 15, 2008 7:07:21 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:
- cd84dca
- Parents:
- d250f7d
- Location:
- guiframe
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_loader.py
r768656e re8c96f5 94 94 #print "data_loader",output 95 95 else: 96 print "output.dx, output.dy",output.dx, output.dy96 #print "output.dx, output.dy",output.dx, output.dy 97 97 if output.dy ==None: 98 print "went here theory1D"98 #print "went here theory1D" 99 99 new_plot = Theory1D(output.x,output.y, dxl, dxw) 100 100 else: -
guiframe/local_perspectives/plotting/Arc.py
rb98db8c re8c96f5 29 29 self.theta1=theta1 30 30 self.theta2=theta2 31 31 self.radius= r 32 32 [self.inner_circle] = self.axes.plot([],[], 33 33 linestyle='-', marker='', … … 58 58 return radius 59 59 60 def update(self,theta1=None,theta2=None ):60 def update(self,theta1=None,theta2=None, nbins=None, r=None): 61 61 """ 62 62 Draw the new roughness on the graph. … … 69 69 if theta2 !=None: 70 70 self.theta2= theta2 71 71 72 print "ring update theta1 theta2", math.degrees(self.theta1), math.degrees(self.theta2) 72 73 while self.theta2 < self.theta1: self.theta2 += 2*math.pi 73 npts = int((self.theta2 - self.theta1)/(math.pi/120))74 74 75 75 76 76 77 77 78 if nbins!=None: 79 self.npts =nbins 80 else: 81 npts = int((self.theta2 - self.theta1)/(math.pi/120)) 78 82 for i in range(self.npts): 79 83 80 84 phi =(self.theta2-self.theta1)/(self.npts-1)*i +self.theta1 81 85 #delta= phi1-phi 82 r= math.sqrt(math.pow(self._inner_mouse_x, 2)+math.pow(self._inner_mouse_y, 2)) 83 xval = 1.0*r*math.cos(phi) 84 yval = 1.0*r*math.sin(phi) 85 #xval = 1.0*self._inner_mouse_x*math.cos(phi) 86 #yval = 1.0*self._inner_mouse_x*math.sin(phi) 87 88 86 if r ==None: 87 self.radius= math.sqrt(math.pow(self._inner_mouse_x, 2)+math.pow(self._inner_mouse_y, 2)) 88 else: 89 self.radius= r 90 91 xval = 1.0*self.radius*math.cos(phi) 92 yval = 1.0*self.radius*math.sin(phi) 93 89 94 x.append(xval) 90 95 y.append(yval) … … 93 98 self.inner_circle.set_data(x, y) 94 99 95 """ 96 r= math.sqrt(math.pow(self._inner_mouse_x, 2)+math.pow(self._inner_mouse_y, 2)) 97 x1= r*math.cos(self.theta1) 98 y1= r*math.sin(self.theta1) 99 """ 100 #x1= self._inner_mouse_x*math.cos(self.theta1) 101 #y1= self._inner_mouse_x*math.sin(self.theta1) 102 #x2= r2*math.cos(self.theta1) 103 #y2= r2*math.sin(self.theta1) 104 105 100 106 101 def save(self, ev): 107 102 """ … … 109 104 can restore on Esc. 110 105 """ 111 #self._inner_save_x = self._inner_mouse_x112 #self._inner_save_y = self._inner_mouse_y113 self._inner_save_x = ev.xdata114 self._inner_save_y = ev.ydata115 print "save value",self._inner_save_x ,self._inner_save_y106 self._inner_save_x = self._inner_mouse_x 107 self._inner_save_y = self._inner_mouse_y 108 #self._inner_save_x = ev.xdata 109 #self._inner_save_y = ev.ydata 110 116 111 self.base.freeze_axes() 117 112 118 113 def moveend(self, ev): 119 114 self.has_move= False 115 116 event = SlicerParameters.SlicerParameterEvent() 117 event.type = self.__class__.__name__ 118 event.params = self.get_params() 119 print "in arc moveend params",self.get_params() 120 #wx.PostEvent(self.base.base.parent, event) 121 120 122 self.base.moveend(ev) 121 123 … … 131 133 Process move to a new position, making sure that the move is allowed. 132 134 """ 133 print "ring move x, y", x,y135 #print "ring move x, y", x,y 134 136 self._inner_mouse_x = x 135 137 self._inner_mouse_y = y … … 137 139 self.base.base.update() 138 140 139 def set_cursor(self, x, y): 140 self.move(x, y, None) 141 self.update() 141 def set_cursor(self,radius, phi_min, phi_max,nbins): 142 143 self.theta1= phi_min 144 self.theta2= phi_max 145 self.update(nbins=nbins, r=radius) 142 146 143 147 144 148 def get_params(self): 145 149 params = {} 146 params["radius"] = self._inner_mouse_x 150 params["radius"] = self.radius 151 params["theta1"] = self.theta1 152 params["theta2"] = self.theta2 147 153 return params 148 154 -
guiframe/local_perspectives/plotting/DataPanel.py
r356aea78 re8c96f5 28 28 DEFAULT_QSTEP = 0.001 29 29 DEFAULT_BEAM = 0.005 30 30 BIN_WIDTH =1 31 31 import pylab 32 32 … … 482 482 483 483 id = wx.NewId() 484 slicerpop.Append(id, '&Edit Parameters')485 wx.EVT_MENU(self, id, self._onEdit Detector)484 slicerpop.Append(id, '&Edit Slicer Parameters') 485 wx.EVT_MENU(self, id, self._onEditSlicer) 486 486 487 487 slicerpop.AppendSeparator() … … 580 580 581 581 from DataLoader.manipulations import CircularAverage 582 Circle = CircularAverage( r_min= -self.qmax, r_max= self.qmax, bin_width=0.001) 582 #Circle = CircularAverage( r_min= -self.qmax, r_max= self.qmax, bin_width=BIN_WIDTH ) 583 Circle = CircularAverage( r_min= -1, r_max= 1, bin_width=0.001 ) 583 584 circ = Circle(self.data2D) 584 585 from sans.guiframe.dataFitting import Data1D … … 608 609 609 610 611 def _onEditSlicer(self, event): 612 if self.slicer !=None: 613 from SlicerParameters import SlicerParameterPanel 614 dialog = SlicerParameterPanel(self.parent, -1, "Slicer Parameters") 615 dialog.set_slicer(self.slicer.__class__.__name__, 616 self.slicer.get_params()) 617 if dialog.ShowModal() == wx.ID_OK: 618 dialog.Destroy() 610 619 611 620 def onSectorQ(self, event): -
guiframe/local_perspectives/plotting/Edge.py
rb98db8c re8c96f5 64 64 65 65 66 def get_ radius(self):66 def get_angle(self): 67 67 return self.theta 68 68 69 def update(self,r1=None, r2=None, theta _right=None, theta_left=None):69 def update(self,r1=None, r2=None, theta=None): 70 70 """ 71 71 Draw the new roughness on the graph. … … 75 75 if r2!=None: 76 76 self.r2=r2 77 """ 78 self.theta_left=theta_left 79 self.theta_right=theta_right 80 if r1 !=None: 81 self.r1=r1 82 if r2!=None: 83 self.r2=r2 84 if theta_right!=None: 85 if theta_right < self.theta: 86 self.move_stop=True 87 else: 88 self.move_stop=False 89 if theta_left !=None: 90 if theta_left > self.theta: 91 self.move_stop=True 92 else: 93 self.move_stop=False 94 if theta_left ==None and theta_right==None: 95 self.move_stop=True 96 """ 97 #print "in the edge theta_right theta_left",theta_right,theta_left,self.theta 77 if theta !=None: 78 self.theta= theta 79 80 print "in the edge r1, r2",self.r1,self.r2,math.degrees(self.theta) 98 81 x1= self.r1*math.cos(self.theta) 99 82 y1= self.r1*math.sin(self.theta) … … 109 92 can restore on Esc. 110 93 """ 111 self.save_theta= self.theta 94 self.save_theta= math.atan2(ev.y,ev.x) 95 #self.save_theta= self.theta 112 96 self.base.freeze_axes() 113 97 … … 126 110 Process move to a new position, making sure that the move is allowed. 127 111 """ 128 #print "on move theta left , theta right",self.theta_left,self.theta_right 129 theta= math.atan2(y,x) 130 """print "on move theta left , theta right",self.theta_left,self.theta_right,theta 131 if self.theta_left !=None: 132 if self.theta_left >= theta: 133 print "went hier" 134 self.move_stop= True 135 if self.theta_right !=None: 136 if self.theta_right <= theta: 137 self.move_stop= True 138 139 self.move_stop= True 140 if self.move_stop: 141 """ 112 142 113 self.theta= math.atan2(y,x) 143 114 self.has_move= True … … 145 116 self.base.base.update() 146 117 147 def set_cursor(self, x, y): 148 self.move(x, y, None) 118 def set_cursor(self,r_min, r_max, theta): 119 self.theta= theta 120 self.r1= r_min 121 self.r2=r_max 149 122 self.update() 150 123 … … 154 127 params["radius1"] = self.r1 155 128 params["radius2"] = self.r2 129 params["theta"] = self.theta 156 130 return params 157 131 158 132 def set_params(self, params): 133 print "when here set curcor arc" 159 134 160 135 x1 = params["radius1"] 161 136 x2 = params["radius2"] 162 self.set_cursor(x, self._inner_mouse_y) 137 theta= params["theta"] 138 self.set_cursor(x1, x2, theta) 163 139 164 140 -
guiframe/local_perspectives/plotting/SectorSlicer.py
rb98db8c re8c96f5 48 48 #self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 49 49 from Edge import RadiusInteractor 50 self. inner_radius= RadiusInteractor(self, self.base.subplot, zorder=zorder+1,50 self.right_edge= RadiusInteractor(self, self.base.subplot, zorder=zorder+1, 51 51 arc1=self.inner_circle, 52 52 arc2=self.outer_circle, 53 53 theta=theta1) 54 self. outer_radius= RadiusInteractor(self, self.base.subplot, zorder=zorder+1,54 self.left_edge= RadiusInteractor(self, self.base.subplot, zorder=zorder+1, 55 55 arc1=self.inner_circle, 56 56 arc2=self.outer_circle, … … 59 59 self._post_data() 60 60 # Bind to slice parameter events 61 #self.base.parent.Bind(SlicerParameters.EVT_SLICER_PARS, self._onEVT_SLICER_PARS)61 self.base.parent.Bind(SlicerParameters.EVT_SLICER_PARS, self._onEVT_SLICER_PARS) 62 62 63 63 … … 93 93 self.outer_circle.clear() 94 94 self.inner_circle.clear() 95 self. inner_radius.clear()96 self. outer_radius.clear()95 self.right_edge.clear() 96 self.left_edge.clear() 97 97 #self.base.connect.disconnect() 98 #self.base.parent.Unbind(SlicerParameters.EVT_SLICER_PARS)98 self.base.parent.Unbind(SlicerParameters.EVT_SLICER_PARS) 99 99 100 100 def update(self): … … 109 109 r1=self.inner_circle.get_radius() 110 110 r2=self.outer_circle.get_radius() 111 self. inner_radius.update(r1,r2)112 self. outer_radius.update(r1,r2)111 self.right_edge.update(r1,r2) 112 self.left_edge.update(r1,r2) 113 113 if self.outer_circle.has_move: 114 114 print "outer circle has moved" … … 116 116 r1=self.inner_circle.get_radius() 117 117 r2=self.outer_circle.get_radius() 118 self. inner_radius.update(r1,r2)119 self. outer_radius.update(r1,r2)120 if self. inner_radius.has_move:121 print " inner radiushas moved"122 self. inner_radius.update(theta_left=self.outer_radius.get_radius())123 self.inner_circle.update(theta1=self. inner_radius.get_radius(), theta2=None)124 self.outer_circle.update(theta1=self. inner_radius.get_radius(), theta2=None)125 if self. outer_radius.has_move:126 print "outer radiushas moved"127 self.outer_radius.update(theta_right=self.inner_radius.get_radius())128 self.inner_circle.update(theta1=None, theta2=self.outer_radius.get_radius())129 self.outer_circle.update(theta1=None, theta2=self.outer_radius.get_radius())118 self.left_edge.update(r1,r2) 119 self.right_edge.update(r1,r2) 120 if self.right_edge.has_move: 121 print "right edge has moved" 122 self.right_edge.update() 123 self.inner_circle.update(theta1=self.right_edge.get_angle(), theta2=None) 124 self.outer_circle.update(theta1=self.right_edge.get_angle(), theta2=None) 125 if self.left_edge.has_move: 126 print "left Edge has moved" 127 self.left_edge.update() 128 self.inner_circle.update(theta1=None, theta2=self.left_edge.get_angle()) 129 self.outer_circle.update(theta1=None, theta2=self.left_edge.get_angle()) 130 130 131 131 … … 138 138 self.inner_circle.save(ev) 139 139 self.outer_circle.save(ev) 140 self.right_edge.save(ev) 141 self.left_edge.save(ev) 142 140 143 def _post_data(self): 141 144 pass 145 142 146 def post_data(self,new_sector ): 143 147 """ post data averaging in Q""" … … 148 152 rmin=self.outer_circle.get_radius() 149 153 rmax=self.inner_circle.get_radius() 150 if self. inner_radius.get_radius() < self.outer_radius.get_radius():151 phimin=self. inner_radius.get_radius()152 phimax=self. outer_radius.get_radius()153 else: 154 phimin=self. outer_radius.get_radius()155 phimax=self. inner_radius.get_radius()154 if self.right_edge.get_angle() < self.left_edge.get_angle(): 155 phimin=self.right_edge.get_angle() 156 phimax=self.left_edge.get_angle() 157 else: 158 phimin=self.left_edge.get_angle() 159 phimax=self.right_edge.get_angle() 156 160 157 161 print "phimin, phimax, rmin ,rmax",math.degrees(phimin), math.degrees(phimax), rmin ,rmax … … 190 194 191 195 def moveend(self, ev): 192 self.base.thaw_axes()193 194 # Post paramters196 #self.base.thaw_axes() 197 198 # Post paramters 195 199 event = SlicerParameters.SlicerParameterEvent() 196 200 event.type = self.__class__.__name__ 197 201 event.params = self.get_params() 202 print "main moveend ", event.params 198 203 wx.PostEvent(self.base.parent, event) 199 200 204 self._post_data() 201 205 … … 205 209 """ 206 210 self.inner_circle.restore() 207 #self.outer_circle.restore() 211 self.outer_circle.restore() 212 self.right_edge.restore() 213 self.left_edge.restore() 208 214 209 215 def move(self, x, y, ev): … … 218 224 def get_params(self): 219 225 params = {} 220 params[" inner_radius"] = self.inner_circle._inner_mouse_x221 params[" outer_radius"] = self.outer_circle._inner_mouse_x222 params["phi_min"] = self. inner_radius.get_radius()223 params["phi_max"] = self. inner_radius.get_radius()226 params["r_min"] = self.inner_circle.get_radius() 227 params["r_max"] = self.outer_circle.get_radius() 228 params["phi_min"] = self.right_edge.get_angle() 229 params["phi_max"] = self.left_edge.get_angle() 224 230 params["nbins"] = self.nbins 225 231 return params 226 232 227 233 def set_params(self, params): 228 229 inner = params[" inner_radius"]230 outer = params[" outer_radius"]234 print "setparams on main slicer ",params 235 inner = params["r_min"] 236 outer = params["r_max"] 231 237 phi_min= params["phi_min"] 232 phi_m in=params["phi_max"]238 phi_max=params["phi_max"] 233 239 self.nbins = int(params["nbins"]) 234 240 235 241 236 self.inner_circle.set_cursor(inner, self.inner_circle._inner_mouse_y)237 self.outer_circle.set_cursor(outer, self.outer_circle._inner_mouse_y)238 self. inner_radius.set_cursor(inner, self.inner_circle._inner_mouse_y)239 self. outer_radius.set_cursor(outer, self.outer_circle._inner_mouse_y)242 self.inner_circle.set_cursor(inner, phi_min, phi_max,self.nbins) 243 self.outer_circle.set_cursor(outer, phi_min, phi_max, self.nbins) 244 self.right_edge.set_cursor(inner, outer, phi_min) 245 self.left_edge.set_cursor(inner, outer, phi_max) 240 246 self._post_data() 241 247 -
guiframe/local_perspectives/plotting/SlicerParameters.py
rb06ef8c re8c96f5 10 10 (SlicerParameterEvent, EVT_SLICER_PARS) = wx.lib.newevent.NewEvent() 11 11 12 class SlicerParameterPanel(wx.Panel): 12 def format_number(value, high=False): 13 """ 14 Return a float in a standardized, human-readable formatted string 15 """ 16 try: 17 value = float(value) 18 except: 19 return "NaN" 20 21 if high: 22 return "%-6.4g" % value 23 else: 24 return "%-5.3g" % value 25 class SlicerParameterPanel(wx.Dialog): 13 26 #TODO: show units 14 27 #TODO: order parameters properly 15 28 16 def __init__(self, parent, *args, **kwargs):17 wx. Panel.__init__(self, parent, *args, **kwargs)29 def __init__(self, parent, id, title): 30 wx.Dialog.__init__(self, parent, id, title, size=(400, 350)) 18 31 self.params = {} 19 32 self.parent = parent … … 30 43 self.parent.Bind(EVT_SLICER, self.onEVT_SLICER) 31 44 self.parent.Bind(EVT_SLICER_PARS, self.onParamChange) 45 46 32 47 33 48 def onEVT_SLICER(self, event): … … 39 54 """ 40 55 event.Skip() 56 print "on event slicer parameters" 41 57 if event.obj_class==None: 42 58 self.set_slicer(None, None) … … 48 64 Rebuild the panel 49 65 """ 66 50 67 self.bck.Clear(True) 51 68 self.type = type … … 74 91 75 92 76 ctl.SetValue( str(params[item]))93 ctl.SetValue(format_number(str(params[item]))) 77 94 self.Bind(wx.EVT_TEXT_ENTER, self.onTextEnter) 78 95 ctl.Bind(wx.EVT_KILL_FOCUS, self.onTextEnter) … … 113 130 event = SlicerParameterEvent(type=self.type, params=params) 114 131 wx.PostEvent(self.parent, event) 132 133 134 135 115 136
Note: See TracChangeset
for help on using the changeset viewer.