Changeset c73d871 in sasview
- Timestamp:
- Jan 7, 2009 2:14:06 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:
- d054809
- Parents:
- b6b1669
- Location:
- guiframe/local_perspectives/plotting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/Plotter2D.py
r7ab9241 rc73d871 317 317 self.radius= math.sqrt( math.pow(self.qmax,2)+math.pow(self.qmax,2)) 318 318 print "radius?",self.radius 319 Circle = CircularAverage( r_min=0, r_max=self.radius, bin_width=0.001) 320 #Circle = CircularAverage( r_min=0, r_max=13705.0, bin_width=BIN_WIDTH ) 321 #Circle = CircularAverage( r_min= -1, r_max= 1, bin_width=0.001 ) 322 #Circle = CircularAverage( r_min= -1*self.radius, r_max= self.radius, bin_width=0.001 ) 319 # bin_width = self.qmax -self.qmin/nbins 320 #nbins= 30 321 bin_width = (self.qmax +self.qmax)/30 322 323 Circle = CircularAverage( r_min=0, r_max=self.radius, bin_width=bin_width) 324 323 325 circ = Circle(self.data2D) 324 326 from sans.guiframe.dataFitting import Data1D -
guiframe/local_perspectives/plotting/boxSlicer.py
rb6b1669 rc73d871 21 21 Select an annulus through a 2D plot 22 22 """ 23 def __init__(self,base,axes,color='black', zorder=3, x_min=0.0025, x_max=0.0025, y_min=0.0025, y_max=0.0025): 23 def __init__(self,base,axes,color='black', zorder=3, 24 x_min=0.0025, x_max=0.0025, y_min=0.0025, y_max=0.0025): 24 25 25 26 _BaseInteractor.__init__(self, base, axes, color=color) … … 39 40 self.count=0 40 41 self.error=0 41 self.main_line = LineInteractor(self, self.base.subplot,color='orange', zorder=zorder, r=self.qmax, 42 self.main_line = LineInteractor(self, self.base.subplot,color='orange', 43 zorder=zorder, r=self.qmax, 42 44 theta= self.theta2) 43 45 self.main_line.qmax = self.base.qmax 44 46 45 self.left_line = VerticalLine(self, self.base.subplot,color='blue', zorder=zorder, 46 ymin= self.ymin, ymax= self.ymax, 47 x=self.xmin, 47 self.left_line = VerticalLine(self, self.base.subplot,color='blue', 48 zorder=zorder, 49 mline= self.main_line, 50 ymin= self.ymin , 51 ymax= self.ymax , 52 xmin=self.xmin, 53 xmax=self.xmin, 48 54 theta2= self.theta2) 49 55 self.left_line.qmax = self.base.qmax 50 56 51 self.right_line= VerticalLine(self, self.base.subplot,color='black', zorder=zorder, 52 ymin= self.ymin, ymax= self.ymax, 53 x=self.xmax, 54 theta2= self.theta2) 57 self.right_line= VerticalLine(self, self.base.subplot,color='black', 58 zorder=zorder, 59 mline= self.main_line, 60 ymin= self.ymin , 61 ymax= self.ymax, 62 xmin= self.xmax, 63 xmax= self.xmax, 64 theta2= self.theta2) 55 65 self.right_line.qmax = self.base.qmax 56 57 self.top_line= HorizontalLine(self, self.base.subplot,color='green', zorder=zorder, 66 """ 67 self.left_line = VerticalLine(self, self.base.subplot,color='blue', 68 zorder=zorder, 69 ymin= self.main_line.y2 , 70 ymax= self.main_line.y1 , 71 xmin=self.main_line.x2 +self.xmin, 72 xmax=self.main_line.x1 +self.xmin, 73 theta2= self.theta2) 74 self.left_line.qmax = self.base.qmax 75 76 self.right_line= VerticalLine(self, self.base.subplot,color='black', 77 zorder=zorder, 78 ymin= self.main_line.y2 , 79 ymax= self.main_line.y1 , 80 xmin=self.main_line.x2 +self.xmax, 81 xmax=self.main_line.x1 +self.xmax, 82 theta2= self.theta2) 83 self.right_line.qmax = self.base.qmax 84 self.top_line= HorizontalLine(self, self.base.subplot,color='green', 85 zorder=zorder, 58 86 y= self.ymax, 59 87 xmin= self.xmin, xmax= self.xmax, … … 61 89 self.top_line.qmax = self.base.qmax 62 90 63 self.bottom_line= HorizontalLine(self, self.base.subplot,color='red', zorder=zorder, 91 self.bottom_line= HorizontalLine(self, self.base.subplot,color='red', 92 zorder=zorder, 64 93 y =self.ymin, 65 94 xmin= self.xmin, xmax= self.xmax, … … 68 97 #self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 69 98 70 99 """ 71 100 self.update() 72 101 #self._post_data() … … 105 134 self.left_line.clear() 106 135 self.right_line.clear() 107 self.top_line.clear()108 self.bottom_line.clear()136 #self.top_line.clear() 137 #self.bottom_line.clear() 109 138 self.main_line.clear() 110 139 #self.base.connect.disconnect() … … 118 147 119 148 if self.main_line.has_move: 120 print "main has move"149 121 150 self.main_line.update() 122 self.left_line.update(mline= self.main_line) 123 self.right_line.update(mline= self.main_line) 124 self.top_line.update(mline= self.main_line) 125 self.bottom_line.update(mline= self.main_line) 151 self.left_line.update(mline= self.main_line, 152 xmin= self.xmin, 153 xmax= self.xmin, 154 ymin= self.ymin, 155 ymax=self.ymax, 156 translation=True) 157 self.right_line.update(mline= self.main_line, 158 xmin= self.xmax, 159 xmax= self.xmax, 160 ymin= self.ymin, 161 ymax=self.ymax, 162 translation=True) 163 #self.top_line.update(mline= self.main_line) 164 #self.bottom_line.update(mline= self.main_line) 126 165 127 166 if self.left_line.has_move: 128 167 print "left has moved" 129 self.left_line.update( translation=True)130 self.right_line.update(xmin=-1*self.left_line.xmin,131 xmax=-1*self.left_line.xmax,132 ymin=self.left_line.ymin,133 ymax=self.left_line.ymax,168 self.left_line.update(mline= self.main_line, 169 xmin= self.xmin, 170 translation=True) 171 self.right_line.update(mline= self.main_line, 172 xmin=-1*self.xmin, 134 173 translation=True) 174 """ 135 175 self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 136 176 translation=True) 137 177 self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 138 178 translation=True) 179 """ 139 180 if self.right_line.has_move: 140 181 print "right has moved" 141 self.right_line.update(translation=True) 142 self.left_line.update(xmin=-1*self.right_line.xmin, 143 xmax=-1*self.right_line.xmax, 182 self.right_line.update(mline= self.main_line, 183 xmin= self.xmax, 144 184 translation=True) 185 self.left_line.update(mline= self.main_line, 186 xmin=-1*self.xmax, 187 translation=True) 188 """ 145 189 self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 146 190 translation=True) 147 191 self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 148 192 translation=True) 149 150 193 """ 194 195 """ 151 196 if self.bottom_line.has_move: 152 197 print "bottom has moved" … … 170 215 self.right_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 171 216 translation=True) 172 217 """ 173 218 174 219 def save(self, ev): … … 186 231 from DataLoader.manipulations import Boxavg 187 232 radius = math.sqrt(math.pow(self.qmax,2)+math.pow(self.qmax,2)) 188 x_min= self.left_line.x 189 x_max= self.right_line.x 190 y_min= self.bottom_line.y191 y_max= self.top_line.y192 box = Boxavg (x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max)233 x_min= self.left_line.xmin 234 x_max= self.right_line.xmax 235 #y_min= self.bottom_line.y 236 #y_max= self.top_line.y 237 #box = Boxavg (x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max) 193 238 194 self.count, self.error= box(self.base.data2D)239 #self.count, self.error= box(self.base.data2D) 195 240 196 241 … … 226 271 def get_params(self): 227 272 params = {} 228 params["x_min"] = self.left_line. xmin229 params["x_max"] = self.right_line. xmax230 params["y_min"] = self.bottom_line.y231 params["y_max"] = self.top_line.y273 params["x_min"] = self.left_line.L_width 274 params["x_max"] = self.right_line.R_width 275 #params["y_min"] = self.bottom_line.y 276 #params["y_max"] = self.top_line.y 232 277 params["count"] = self.count 233 278 params["error"] = self.error … … 239 284 x_min = params["x_min"] 240 285 x_max = params["x_max"] 241 y_min = params["y_min"]242 y_max = params["y_max"]286 #y_min = params["y_min"] 287 #y_max = params["y_max"] 243 288 theta = params["theta"] 244 289 245 290 self.left_line.update(ymin= y_min ,ymax= y_max) 246 291 self.right_line.update(ymin= y_min ,ymax= y_max) 247 self.top_line.update( xmin= x_min ,xmax= xmax)248 self.bottom_line.update(xmin= xmin ,xmax= xmax)292 #self.top_line.update( xmin= x_min ,xmax= xmax) 293 #self.bottom_line.update(xmin= xmin ,xmax= xmax) 249 294 self.main_line.update(theta) 250 295 … … 287 332 self.deltax=0 288 333 self.deltay=0 334 289 335 x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 290 336 self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) … … 298 344 visible=True)[0] 299 345 300 346 347 301 348 self.npts = 20 302 349 self.has_move=False … … 324 371 self.clickx,self.clicky = ev.xdata,ev.ydata 325 372 print "onclick",self.clickx,self.clicky 373 374 326 375 #self.save(ev) 327 376 return True … … 400 449 Process move to a new position, making sure that the move is allowed. 401 450 """ 451 """ 452 a=(1,1) 453 transform = self.base.connect._hasclick.artist.get_transform() 454 print "transform", self.base.connect.rotation_matrix(angle=math.pi/4, direction=(1, 0, 0), point=a) 455 """ 402 456 403 457 self.has_move=True … … 427 481 Select an annulus through a 2D plot 428 482 """ 429 def __init__(self,base,axes,color='black', zorder=5, ymin=0.0,430 ymax=0.5,x =0.5,483 def __init__(self,base,axes,color='black', zorder=5, mline=None, ymin=0.0, 484 ymax=0.5,xmin=-0.5,xmax=0.5, 431 485 theta2= math.pi/3 ): 432 486 … … 434 488 self.markers = [] 435 489 self.axes = axes 436 # x coordinate of the vertical line 437 self.x= x 438 self.save_x = x 439 440 # minimum value of y coordinate of the vertical line 441 self.ymin = ymin 442 self.save_ymin = ymin 443 # maximum value of y coordinate of the vertical line 490 self.L_width=xmin 491 self.save_xmin= xmin 492 self.R_width=xmax 493 self.save_xmax=xmax 494 self.ymin=ymin 495 self.save_ymin= ymin 444 496 self.ymax=ymax 445 self.save_ymax=ymax 446 #insure rotation 497 self.save_ymax= ymax 447 498 self.theta2= theta2 448 449 # Draw vertical line 450 self.xmin= self.x* math.cos(self.theta2)-self.ymin *math.sin(self.theta2) 451 self.xmax= self.x* math.cos(self.theta2)-self.ymax *math.sin(self.theta2) 452 453 self.ymin= self.x* math.sin(self.theta2)+self.ymin *math.cos(self.theta2) 454 self.ymax= self.x* math.sin(self.theta2)+self.ymax *math.cos(self.theta2) 455 456 self.clickx=self.xmin 457 self.clicky=self.ymin 458 self.clickxf=self.xmin 459 self.clickyf=self.ymin 460 self.deltax=0 499 self.mline= mline 500 """ 501 x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 502 self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 503 504 x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 505 self.ymax= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 506 """ 507 self.detax=0 461 508 self.deltay=0 462 self.line = self.axes.plot([self.xmin,self.xmax],[self.ymin,self.ymax], 509 510 self.clickx=0 511 self.clicky=0 512 self.clickxf=0 513 self.clickyf=0 514 self.x1= mline.x1 + xmin*math.cos(math.pi/2 - self.theta2) 515 self.x2= mline.x2 + xmin*math.cos(math.pi/2 - self.theta2) 516 self.y1= mline.y1 - xmin*math.sin(math.pi/2 - self.theta2) 517 self.y2= mline.y2 - xmin*math.sin(math.pi/2 - self.theta2) 518 519 self.line = self.axes.plot([self.x1,self.x2],[self.y1,self.y2], 463 520 linestyle='-', marker='', 464 521 color=self.color, … … 484 541 for item in range(len(self.axes.lines)): 485 542 del self.axes.lines[0] 486 def onClick(self, ev): 487 """ 488 Prepare to move the artist. Calls save() to preserve the state for 489 later restore(). 490 """ 491 self.clickx,self.clicky = ev.xdata,ev.ydata 492 print "onclick",self.clickx,self.clicky 493 #self.save(ev) 494 return True 495 543 544 #def onClick(self, ev): 545 # """ 546 #Prepare to move the artist. Calls save() to preserve the state for 547 #later restore(). 548 #""" 549 # self.clickx,self.clicky = ev.xdata,ev.ydata 550 # print "onclick",self.clickx,self.clicky 551 # self.save(ev) 552 # return True 553 496 554 def get_radius(self): 497 555 return 0 … … 501 559 Draw the new roughness on the graph. 502 560 """ 503 if translation : 504 self.deltax = self.clickxf- self.clickx 505 self.deltay = self.clickyf-self.clicky 506 507 self.xmin= self.xmin + self.deltax 508 self.xmax=self.xmax + self.deltax 509 self.ymin= self.ymin + self.deltay 510 self.ymax=self.ymax + self.deltay 511 512 if xmin !=None: 513 self.xmin=xmin 514 if xmax !=None: 515 self.xmax=xmax 516 if ymin !=None: 517 self.ymin = ymin 518 if ymax !=None: 519 self.ymax = ymax 520 self.line.set(xdata=[self.xmin, self.xmax], 521 ydata=[self.ymin, self.ymax]) 522 if mline !=None: 523 524 self.theta2= mline.theta 525 delta = mline.get_delta_angle() 526 if translation: 527 delta= 0 528 self.xmin= self.x* math.cos(self.theta2)-self.ymin *math.sin(self.theta2) 529 self.xmax= self.x* math.cos(self.theta2)-self.ymax *math.sin(self.theta2) 530 531 self.ymin= self.x* math.sin(self.theta2)+self.ymin *math.cos(self.theta2) 532 self.ymax= self.x* math.sin(self.theta2)+self.ymax *math.cos(self.theta2) 533 534 535 self.line.set(xdata=[self.xmin,self.xmax], ydata=[self.ymin,self.ymax]) 561 562 if xmin== None: 563 xmin= self.L_width 564 if xmax== None: 565 xmax= self.R_width 566 print "vertical line: xmin, xmax , ymin , ymax", xmin, self.mline.theta 567 self.x1= self.mline.x1 + xmin*math.cos(math.pi/2 - self.mline.theta) 568 self.x2= self.mline.x2 + xmin*math.cos(math.pi/2 - self.mline.theta) 569 self.y1= self.mline.y1 - xmin*math.sin(math.pi/2 - self.mline.theta) 570 self.y2= self.mline.y2 - xmin*math.sin(math.pi/2 - self.mline.theta) 571 print "vertical line: main line value ", self.mline.x1, self.mline.x2, self.mline.y1,self.mline.y2 572 print "vertical line: new value ", self.x1, self.x2, self.y1,self.y2 573 574 self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2]) 536 575 537 538 576 if translation: 577 self.deltax= self.clickxf +self.clickx 578 self.deltay= self.clickyf +self.clicky 579 print"translation deltax deltay", self.deltax, self.deltay 580 self.x1=self.x1 +self.deltax 581 self.y1=self.y1+ self.deltay 582 self.x2=self.x2+ self.deltax 583 self.y2=self.y2+self.deltay 584 self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2]) 539 585 def save(self, ev): 540 586 """ … … 619 665 620 666 # Inner circle 621 x1= self.radius*math.cos(self.theta)622 y1= self.radius*math.sin(self.theta)623 x2= -1*self.radius*math.cos(self.theta)624 y2= -1*self.radius*math.sin(self.theta)667 self.x1= self.radius*math.cos(self.theta) 668 self.y1= self.radius*math.sin(self.theta) 669 self.x2= -1*self.radius*math.cos(self.theta) 670 self.y2= -1*self.radius*math.sin(self.theta) 625 671 626 self.line = self.axes.plot([ x1,x2],[y1,y2],672 self.line = self.axes.plot([self.x1,self.x2],[self.y1,self.y2], 627 673 linestyle='-', marker='', 628 674 color=self.color, … … 672 718 self.radius =radius 673 719 print "update main line", math.degrees(self.theta) 674 x1= self.radius*math.cos(self.theta)675 y1= self.radius*math.sin(self.theta)676 x2= -1*self.radius*math.cos(self.theta)677 y2= -1*self.radius*math.sin(self.theta)720 self.x1= self.radius*math.cos(self.theta) 721 self.y1= self.radius*math.sin(self.theta) 722 self.x2= -1*self.radius*math.cos(self.theta) 723 self.y2= -1*self.radius*math.sin(self.theta) 678 724 679 self.line.set(xdata=[ x1,x2], ydata=[y1,y2])725 self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2]) 680 726 681 727
Note: See TracChangeset
for help on using the changeset viewer.