Changeset 030873e in sasview
- Timestamp:
- Jan 7, 2009 5:30:29 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:
- 116da060
- Parents:
- d5a792a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/boxSlicer.py
rd5a792a r030873e 41 41 self.error=0 42 42 self.main_line = LineInteractor(self, self.base.subplot,color='orange', 43 zorder=zorder, r=self.qmax,43 zorder=zorder, ymin=y_min ,ymax=y_max, 44 44 theta= self.theta2) 45 45 self.main_line.qmax = self.base.qmax … … 64 64 theta2= self.theta2) 65 65 self.right_line.qmax = self.base.qmax 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 66 84 67 self.top_line= HorizontalLine(self, self.base.subplot,color='green', 85 68 zorder=zorder, 86 y= self.ymax, 87 xmin= self.xmin, xmax= self.xmax, 88 theta2= self.theta2) 89 self.top_line.qmax = self.base.qmax 90 91 self.bottom_line= HorizontalLine(self, self.base.subplot,color='red', 92 zorder=zorder, 93 y =self.ymin, 94 xmin= self.xmin, xmax= self.xmax, 95 theta2= self.theta2) 96 self.bottom_line.qmax = self.base.qmax 97 #self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 98 99 """ 69 mline= self.main_line, 70 xmin=self.right_line.x1, 71 xmax=self.left_line.x1, 72 ymin=self.right_line.y1, 73 ymax=self.left_line.y1) 74 self.top_line.qmax= self.base.qmax 75 76 self.bottom_line= HorizontalLine(self, self.base.subplot,color='grey', 77 zorder=zorder, 78 mline= self.main_line, 79 xmin=self.right_line.x2, 80 xmax=self.left_line.x2, 81 ymin=self.right_line.y2, 82 ymax=self.left_line.y2) 83 self.bottom_line.qmax= self.base.qmax 100 84 self.update() 101 85 #self._post_data() … … 134 118 self.left_line.clear() 135 119 self.right_line.clear() 136 #self.top_line.clear()137 #self.bottom_line.clear()120 self.top_line.clear() 121 self.bottom_line.clear() 138 122 self.main_line.clear() 139 123 #self.base.connect.disconnect() … … 161 145 ymax=self.ymax, 162 146 translation=True) 163 #self.top_line.update(mline= self.main_line) 164 #self.bottom_line.update(mline= self.main_line) 165 147 self.top_line.update(xmin= self.right_line.x1, 148 xmax= self.left_line.x1, 149 ymin= self.right_line.y1, 150 ymax= self.left_line.y1) 151 self.bottom_line.update(xmin= self.right_line.x2, 152 xmax= self.left_line.x2, 153 ymin= self.right_line.y2, 154 ymax= self.left_line.y2) 166 155 if self.left_line.has_move: 167 156 print "left has moved" 168 157 self.left_line.update() 169 158 self.right_line.update(opline= self.left_line ) 170 """ 171 self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 172 translation=True) 173 self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 174 translation=True) 175 """ 159 160 self.top_line.update(xmin= self.right_line.x2, 161 xmax= self.left_line.x1, 162 ymin= self.right_line.y2, 163 ymax= self.left_line.y1) 164 165 166 self.bottom_line.update(xmin= self.right_line.x1, 167 xmax= self.left_line.x2, 168 ymin= self.right_line.y1, 169 ymax= self.left_line.y2) 170 176 171 if self.right_line.has_move: 177 172 print "right has moved" 178 173 self.right_line.update() 179 174 self.left_line.update(opline= self.right_line ) 180 """ 181 self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 182 translation=True) 183 self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 184 translation=True) 185 """ 186 187 """ 188 if self.bottom_line.has_move: 189 print "bottom has moved" 190 self.bottom_line.update(translation=True) 191 self.top_line.update(ymin= -1*self.bottom_line.ymin, 192 ymax =-1*self.bottom_line.ymax, 193 translation=True) 194 self.left_line.update( ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 195 translation=True) 196 self.right_line.update(ymin= self.bottom_line.ymin,ymax= self.top_line.ymax, 197 translation=True) 198 175 176 self.top_line.update(xmin= self.right_line.x1, 177 xmax= self.left_line.x2, 178 ymin= self.right_line.y1, 179 ymax= self.left_line.y2) 180 181 self.bottom_line.update(xmin= self.right_line.x2, 182 xmax= self.left_line.x1, 183 ymin= self.right_line.y2, 184 ymax= self.left_line.y1) 199 185 if self.top_line.has_move: 200 print "top has moved" 201 self.top_line.update(mline= self.main_line,translation=True) 202 self.bottom_line.update(ymin= -1*self.top_line.ymin, 203 ymax=-1*self.top_line.ymax, 204 translation=True ) 205 self.left_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 206 translation=True) 207 self.right_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 208 translation=True) 209 """ 210 186 self.top_line.update(translation=True) 211 187 def save(self, ev): 212 188 """ … … 300 276 Select an annulus through a 2D plot 301 277 """ 302 def __init__(self,base,axes,color='black', zorder=5, y=0.5,278 def __init__(self,base,axes,color='black', zorder=5,mline=None,ymin=None, ymax=None, y=0.5, 303 279 xmin=0.0,xmax=0.5, 304 280 theta2= math.pi/3 ): … … 308 284 self.axes = axes 309 285 310 self.y= y 311 self.save_y = y 312 286 self.ymin= ymin 287 self.save_ymin = ymin 288 self.mline = mline 289 self.ymax= ymax 290 self.save_ymax = ymax 313 291 self.xmin = xmin 314 292 self.save_xmin = xmin 315 293 self.xmax = xmax 316 294 self.save_xmax = xmax 295 self.top_hight= self.ymax 317 296 318 297 self.theta2 = theta2 319 298 320 self.clickx=self.xmin 321 self.clicky=self.y 322 self.clickxf=self.xmin 323 self.clickyf=self.y 324 self.deltax=0 325 self.deltay=0 326 327 x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 328 self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 329 330 x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 331 self.ymax= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 332 #print "x1, y1", x1, y1, x2,y2 333 self.line = self.axes.plot([x1,x2],[self.ymin,self.ymax], 299 self.line = self.axes.plot([self.xmax,self.xmin], 300 [self.ymax,self.ymin], 334 301 linestyle='-', marker='', 335 302 color=self.color, … … 341 308 self.has_move=False 342 309 self.connect_markers([self.line]) 343 self.update() 310 self.update(xmin= self.xmin, 311 xmax= self.xmax, 312 ymin= self.ymin, 313 ymax= self.ymax) 344 314 345 315 def set_layer(self, n): … … 356 326 for item in range(len(self.axes.lines)): 357 327 del self.axes.lines[0] 358 def onClick(self, ev): 359 """ 360 Prepare to move the artist. Calls save() to preserve the state for 361 later restore(). 362 """ 363 self.clickx,self.clicky = ev.xdata,ev.ydata 364 print "onclick",self.clickx,self.clicky 365 366 367 #self.save(ev) 368 return True 328 369 329 def get_radius(self): 370 330 … … 375 335 Draw the new roughness on the graph. 376 336 """ 337 if translation : 338 print "translation ",self.top_hight 339 self.x1= self.xmax + self.top_hight*math.sin(math.pi/2 + self.mline.theta) 340 self.x2= self.xmin + self.top_hight*math.sin(math.pi/2 + self.mline.theta) 341 self.y1= self.ymin - self.top_hight*math.cos(math.pi/2 + self.mline.theta) 342 self.y2= self.ymax -self.top_hight*math.cos(math.pi/2 + self.mline.theta) 343 self.line.set(xdata=[self.x1,self.x2], 344 ydata=[self.y1,self.y2]) 345 return 377 346 #print "update main line", self.has_move 378 379 if translation : 380 self.deltax = self.clickxf- self.clickx 381 self.deltay = self.clickyf-self.clicky 382 383 self.xmin= self.xmin +self.deltax 384 self.xmax=self.xmax+self.deltax 385 self.ymin= self.ymin +self.deltay 386 self.ymax=self.ymax+self.deltay 387 388 if xmin !=None: 389 self.xmin=xmin 390 if xmax !=None: 391 self.xmax=xmax 392 if ymin !=None: 393 self.ymin = ymin 394 if ymax !=None: 395 self.ymax = ymax 396 self.line.set(xdata=[self.xmin, self.xmax], 397 ydata=[self.ymin, self.ymax]) 398 if mline !=None: 399 self.theta2= mline.theta 400 401 x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 402 y1= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 403 404 x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 405 y2= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 406 407 self.line.set(xdata=[x1,x2], ydata=[y1,y2]) 408 print x1,x2,y1,y2 409 410 #else: 411 # self.line.set(xdata=[self.xmin,self.xmax], ydata=[self.y,self.y]) 412 347 self.xmin=xmin 348 self.xmax=xmax 349 self.ymin=ymin 350 self.ymax=ymax 351 self.line.set(xdata=[self.xmin,self.xmax], 352 ydata=[self.ymin,self.ymax]) 353 413 354 414 355 … … 421 362 self.save_xmax= self.xmax 422 363 423 self.save_y= self.y 364 self.save_ymin= self.ymin 365 self.save_ymax= self.ymax 366 self.top_hight= self.ymax 424 367 self.base.freeze_axes() 425 368 426 369 def moveend(self, ev): 427 self.clickxf,self.clickyf = ev.xdata,ev.ydata 428 print "move end ",self.clickxf,self.clickyf 370 429 371 self.has_move=False 430 372 self.base.moveend(ev) … … 434 376 Restore the roughness for this layer. 435 377 """ 378 self.xmin = self.save_xmin 379 self.xmax = self.save_xmax 436 380 self.ymin = self.save_ymin 437 381 self.ymax = self.save_ymax … … 441 385 Process move to a new position, making sure that the move is allowed. 442 386 """ 443 """ 444 a=(1,1) 445 transform = self.base.connect._hasclick.artist.get_transform() 446 print "transform", self.base.connect.rotation_matrix(angle=math.pi/4, direction=(1, 0, 0), point=a) 447 """ 448 387 388 self.top_hight= y 449 389 self.has_move=True 450 390 self.base.base.update() … … 480 420 self.markers = [] 481 421 self.axes = axes 422 482 423 self.L_width=xmin 424 self.save_L_width=xmin 425 483 426 self.save_xmin= xmin 484 427 self.R_width=xmax … … 488 431 self.ymax=ymax 489 432 self.save_ymax= ymax 433 490 434 self.theta2= theta2 435 491 436 self.mline= mline 492 """ 493 x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 494 self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 495 496 x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 497 self.ymax= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 498 """ 437 499 438 self.detax=0 500 439 self.deltay=0 … … 533 472 del self.axes.lines[0] 534 473 535 #def onClick(self, ev):536 # """537 #Prepare to move the artist. Calls save() to preserve the state for538 #later restore().539 #"""540 # self.clickx,self.clicky = ev.xdata,ev.ydata541 # print "onclick",self.clickx,self.clicky542 # self.save(ev)543 # return True544 474 545 475 def get_radius(self): … … 551 481 """ 552 482 if opline !=None: 553 self.line.set(xdata=[-1*opline.x1,-1*opline.x2], 554 ydata=[-opline.y1,-opline.y2]) 483 self.x1= -1*opline.x1 484 self.x2= -1*opline.x2 485 self.y1= -1*opline.y1 486 self.y2= -1*opline.y2 487 self.line.set(xdata=[self.x1,self.x2], 488 ydata=[self.y1,self.y2]) 555 489 return 556 490 if xmin== None: … … 558 492 if xmax== None: 559 493 xmax= self.R_width 560 print "vertical line: xmin, xmax , ymin , ymax", xmin, self.mline.theta494 #print "vertical line: xmin, xmax , ymin , ymax", xmin, self.mline.theta 561 495 self.x1= self.mline.x1 + xmin*math.cos(math.pi/2 - self.mline.theta) 562 496 self.x2= self.mline.x2 + xmin*math.cos(math.pi/2 - self.mline.theta) 563 497 self.y1= self.mline.y1 - xmin*math.sin(math.pi/2 - self.mline.theta) 564 498 self.y2= self.mline.y2 - xmin*math.sin(math.pi/2 - self.mline.theta) 565 print "vertical line: main line value ", self.mline.x1, self.mline.x2, self.mline.y1,self.mline.y2566 print "vertical line: new value ", self.x1, self.x2, self.y1,self.y2499 #print "vertical line: main line value ", self.mline.x1, self.mline.x2, self.mline.y1,self.mline.y2 500 #print "vertical line: new value ", self.x1, self.x2, self.y1,self.y2 567 501 568 502 self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2]) … … 572 506 return 573 507 if translation: 574 #if xmin !=None: 575 # self.L_width=xmin 508 print "xmin L_width", xmin, self.L_width 576 509 self.x1= self.mline.x1 + self.L_width*math.cos(math.pi/2 - self.mline.theta) 577 510 self.x2= self.mline.x2 + self.L_width*math.cos(math.pi/2 - self.mline.theta) … … 581 514 print"translation x1, x2,y1,y2",self.x1, self.x2,self.y1,self.y2 582 515 self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2]) 516 517 583 518 def save(self, ev): 584 519 """ … … 586 521 can restore on Esc. 587 522 """ 588 #self.save_x= self.x523 self.save_L_width= self.L_width 589 524 self.save_xmin= self.x1 590 525 self.save_xmax= self.x2 … … 595 530 596 531 def moveend(self, ev): 597 self.clickxf,self.clickyf = ev.xdata,ev.ydata 598 print "move end ",self.clickxf,self.clickyf 532 599 533 self.has_move=False 600 534 self.base.moveend(ev) … … 608 542 self.ymin = self.save_ymin 609 543 self.ymax = self.save_ymax 610 544 self.L_width= self.save_L_width 611 545 612 546 def move(self, x, y, ev): … … 615 549 """ 616 550 self.has_move=True 617 self.L_width=x 618 619 551 self.L_width = x 552 print "move L_width", self.L_width 620 553 self.base.base.update() 621 554 … … 651 584 Select an annulus through a 2D plot 652 585 """ 653 def __init__(self,base,axes,color='black', zorder=5, r=1.0,theta=math.pi/4):586 def __init__(self,base,axes,color='black', zorder=5, ymin=1.0,ymax=1.0,theta=math.pi/4): 654 587 655 588 _BaseInteractor.__init__(self, base, axes, color=color) … … 660 593 self.theta= theta 661 594 662 self.radius = r663 595 self.radius1 = ymax 596 self.radius2 = ymin 664 597 self.scale = 10.0 665 598 666 599 # Inner circle 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)600 self.x1= self.radius1*math.cos(self.theta) 601 self.y1= self.radius1*math.sin(self.theta) 602 self.x2= -1*self.radius2*math.cos(self.theta) 603 self.y2= -1*self.radius2*math.sin(self.theta) 671 604 672 605 self.line = self.axes.plot([self.x1,self.x2],[self.y1,self.y2], … … 706 639 return self.theta - self.save_theta 707 640 708 def update(self, theta=None,radius =None):641 def update(self, theta=None,radius1=None,radius2=None): 709 642 """ 710 643 Draw a line given and angle relative to the x-axis and a radius … … 715 648 if theta !=None: 716 649 self.theta= theta 717 if radius !=None: 718 self.radius =radius 719 print "update main line", math.degrees(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) 650 if radius1 !=None: 651 self.radius1 =radius1 652 if radius2 !=None: 653 self.radius2 =radius2 654 print "update main line", math.degrees(self.theta),self.radius1, self.radius2 655 self.x1= self.radius1*math.cos(self.theta) 656 self.y1= self.radius1*math.sin(self.theta) 657 self.x2= -1*self.radius2*math.cos(self.theta) 658 self.y2= -1*self.radius2*math.sin(self.theta) 724 659 725 660 self.line.set(xdata=[self.x1,self.x2], ydata=[self.y1,self.y2]) … … 768 703 """ 769 704 params = {} 770 params["radius"] = self.radius 705 params["ymax"] = self.radius1 706 params["ymin"] = self.radius2 771 707 params["theta"] = self.theta 772 708 return params … … 777 713 @param params: dictionary containing name of parameters and their values 778 714 """ 779 radius = params["radius"] 715 radius1 = params["ymax"] 716 radius2 = params["ymin"] 780 717 theta = params["theta"] 781 self.update(x, theta= theta , radius = radius)782 783 784 785 786 718 self.update(x, theta= theta , radius1 = radius1 ,radius2 = radius2) 719 720 721 722 723
Note: See TracChangeset
for help on using the changeset viewer.