Changeset b6b1669 in sasview for guiframe/local_perspectives
- Timestamp:
- Jan 7, 2009 12:13:13 AM (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:
- c73d871
- Parents:
- 86c1832
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/boxSlicer.py
r78ed1ad rb6b1669 30 30 self.xmin= -1* x_min 31 31 self.ymin= -1* y_min 32 32 33 self.xmax= x_max 33 34 self.ymax= y_max 34 35 35 self.theta2= math.pi/ 236 self.theta2= math.pi/4 36 37 ## Number of points on the plot 37 38 self.nbins = 20 … … 44 45 self.left_line = VerticalLine(self, self.base.subplot,color='blue', zorder=zorder, 45 46 ymin= self.ymin, ymax= self.ymax, 46 x min= self.xmin,xmax=self.xmin,47 x=self.xmin, 47 48 theta2= self.theta2) 48 49 self.left_line.qmax = self.base.qmax … … 50 51 self.right_line= VerticalLine(self, self.base.subplot,color='black', zorder=zorder, 51 52 ymin= self.ymin, ymax= self.ymax, 52 x min=self.xmax,xmax=self.xmax,53 x=self.xmax, 53 54 theta2= self.theta2) 54 55 self.right_line.qmax = self.base.qmax … … 126 127 if self.left_line.has_move: 127 128 print "left has moved" 128 self.left_line.update(mline= self.main_line,translation=True) 129 self.right_line.update(x=-1*self.left_line.x,mline= self.main_line,translation=True) 130 #self.right_line.update(xmin= self.left_line.x ,xmax=-1*self.left_line.x) 131 self.top_line.update( xmin= self.left_line.x ,xmax= self.right_line.x, 132 mline= self.main_line,translation=True) 133 self.bottom_line.update(xmin= self.left_line.x ,xmax= self.right_line.x, 134 mline= self.main_line,translation=True) 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, 134 translation=True) 135 self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 136 translation=True) 137 self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 138 translation=True) 135 139 if self.right_line.has_move: 136 140 print "right has moved" 137 self.right_line.update(mline= self.main_line,translation=True) 138 self.left_line.update(x=-1*self.right_line.x,mline= self.main_line,translation=True) 139 #self.left_line.update(xmin= self.right_line.x ,xmax=-1*self.right_line.x) 140 self.top_line.update( xmin= self.left_line.x ,xmax= self.right_line.x, 141 mline= self.main_line,translation=True) 142 self.bottom_line.update(xmin= self.left_line.x ,xmax= self.right_line.x, 143 mline= self.main_line,translation=True) 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, 144 translation=True) 145 self.top_line.update( xmin= self.left_line.xmax ,xmax= self.right_line.xmax, 146 translation=True) 147 self.bottom_line.update(xmin= self.left_line.xmin ,xmax= self.right_line.xmin, 148 translation=True) 144 149 145 150 146 151 if self.bottom_line.has_move: 147 152 print "bottom has moved" 148 self.bottom_line.update(mline= self.main_line,translation=True) 149 self.top_line.update(y= -1*self.top_line.y,translation=True) 150 self.left_line.update( ymin= self.bottom_line.y ,ymax= self.top_line.y, 151 mline= self.main_line,translation=True) 152 self.right_line.update(ymin= self.bottom_line.y ,ymax= self.top_line.y, 153 mline= self.main_line,translation=True) 153 self.bottom_line.update(translation=True) 154 self.top_line.update(ymin= -1*self.bottom_line.ymin, 155 ymax =-1*self.bottom_line.ymax, 156 translation=True) 157 self.left_line.update( ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 158 translation=True) 159 self.right_line.update(ymin= self.bottom_line.ymin,ymax= self.top_line.ymax, 160 translation=True) 154 161 155 162 if self.top_line.has_move: 156 163 print "top has moved" 157 164 self.top_line.update(mline= self.main_line,translation=True) 158 #self.bottom_line.update()xmin=None, xmax=None,y=None, mline=None):159 self.bottom_line.update(y= -1*self.top_line.y,mline= self.main_line,165 self.bottom_line.update(ymin= -1*self.top_line.ymin, 166 ymax=-1*self.top_line.ymax, 160 167 translation=True ) 161 self.left_line.update(ymin= self.bottom_line.y ,ymax= self.top_line.y,162 mline= self.main_line,translation=True)163 self.right_line.update(ymin= self.bottom_line.y ,ymax= self.top_line.y,164 mline= self.main_line,translation=True)168 self.left_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 169 translation=True) 170 self.right_line.update(ymin= self.bottom_line.ymin ,ymax= self.top_line.ymax, 171 translation=True) 165 172 166 173 … … 273 280 274 281 self.theta2 = theta2 275 276 282 283 self.clickx=self.xmin 284 self.clicky=self.y 285 self.clickxf=self.xmin 286 self.clickyf=self.y 287 self.deltax=0 288 self.deltay=0 277 289 x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) 278 y1= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2)290 self.ymin= self.xmin*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 279 291 280 292 x2= self.xmax*math.cos(self.theta2)- self.y*math.sin(self.theta2) 281 y2= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2)282 print "x1, y1", x1, y1, x2,y2283 self.line = self.axes.plot([x1,x2],[ y1,y2],293 self.ymax= self.xmax*math.sin(self.theta2)+ self.y*math.sin(self.theta2) 294 #print "x1, y1", x1, y1, x2,y2 295 self.line = self.axes.plot([x1,x2],[self.ymin,self.ymax], 284 296 linestyle='-', marker='', 285 297 color=self.color, … … 305 317 for item in range(len(self.axes.lines)): 306 318 del self.axes.lines[0] 307 319 def onClick(self, ev): 320 """ 321 Prepare to move the artist. Calls save() to preserve the state for 322 later restore(). 323 """ 324 self.clickx,self.clicky = ev.xdata,ev.ydata 325 print "onclick",self.clickx,self.clicky 326 #self.save(ev) 327 return True 308 328 def get_radius(self): 309 329 310 330 return 0 311 331 312 def update(self,xmin=None, xmax=None,y =None, mline=None,translation=False):332 def update(self,xmin=None, xmax=None,ymin=None,ymax=None, mline=None,translation=False): 313 333 """ 314 334 Draw the new roughness on the graph. 315 335 """ 316 336 #print "update main line", self.has_move 317 if xmin !=None: 318 self.xmin=xmin 319 if xmax !=None: 320 self.xmax=xmax 321 if y !=None: 322 self.y = y 337 338 if translation : 339 self.deltax = self.clickxf- self.clickx 340 self.deltay = self.clickyf-self.clicky 341 342 self.xmin= self.xmin +self.deltax 343 self.xmax=self.xmax+self.deltax 344 self.ymin= self.ymin +self.deltay 345 self.ymax=self.ymax+self.deltay 346 347 if xmin !=None: 348 self.xmin=xmin 349 if xmax !=None: 350 self.xmax=xmax 351 if ymin !=None: 352 self.ymin = ymin 353 if ymax !=None: 354 self.ymax = ymax 355 self.line.set(xdata=[self.xmin, self.xmax], 356 ydata=[self.ymin, self.ymax]) 323 357 if mline !=None: 324 358 self.theta2= mline.theta 325 delta = mline.get_delta_angle()326 359 327 360 x1= self.xmin*math.cos(self.theta2)- self.y*math.sin(self.theta2) … … 332 365 333 366 self.line.set(xdata=[x1,x2], ydata=[y1,y2]) 334 print "Horizontal: update ",math.degrees(self.phi_left +delta),math.degrees(self.phi_right+delta)335 367 print x1,x2,y1,y2 336 368 … … 352 384 353 385 def moveend(self, ev): 354 386 self.clickxf,self.clickyf = ev.xdata,ev.ydata 387 print "move end ",self.clickxf,self.clickyf 355 388 self.has_move=False 356 389 self.base.moveend(ev) … … 367 400 Process move to a new position, making sure that the move is allowed. 368 401 """ 369 self.y=y370 371 402 372 403 self.has_move=True … … 397 428 """ 398 429 def __init__(self,base,axes,color='black', zorder=5, ymin=0.0, 399 ymax=0.5,x min= 0.5,xmax=0.5,430 ymax=0.5,x=0.5, 400 431 theta2= math.pi/3 ): 401 432 … … 404 435 self.axes = axes 405 436 # x coordinate of the vertical line 406 self.xmin = xmin 407 self.save_xmin = xmin 408 self.xmax = xmax 409 self.save_xmax = xmax 437 self.x= x 438 self.save_x = x 439 410 440 # minimum value of y coordinate of the vertical line 411 441 self.ymin = ymin … … 415 445 self.save_ymax=ymax 416 446 #insure rotation 417 self.radius1= math.sqrt(math.pow(self.xmin, 2)+ math.pow(self.ymin, 2))418 self.radius2= math.sqrt(math.pow(self.xmax, 2)+ math.pow(self.ymax, 2))419 420 421 self.theta_down = math.atan2(self.ymin, self.xmin)422 self.theta_up = math.atan2(self.ymax, self.xmax)423 447 self.theta2= theta2 424 448 425 self.phi_down= self.theta_down - self.theta2426 self.phi_up= self.theta_up - self.theta2427 print "phi up down", math.degrees(self.phi_up),math.degrees(self.phi_down)428 #print "theta up down ", math.degrees(self.theta_up),math.degrees(self.theta_down)429 449 # Draw vertical line 430 self.xmin= self.xmin* math.cos(self.theta2)-self.ymin *math.sin(self.theta2) 431 self.xmax= self.xmax* math.cos(self.theta2)-self.ymax *math.sin(self.theta2) 432 433 self.ymin= self.xmin* math.sin(self.theta2)+self.ymin *math.cos(self.theta2) 434 self.ymax= self.xmax* math.sin(self.theta2)+self.ymax *math.cos(self.theta2) 435 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 461 self.deltay=0 436 462 self.line = self.axes.plot([self.xmin,self.xmax],[self.ymin,self.ymax], 437 463 linestyle='-', marker='', … … 458 484 for item in range(len(self.axes.lines)): 459 485 del self.axes.lines[0] 460 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 461 496 def get_radius(self): 462 497 return 0 463 498 464 def update(self,x =None,ymin=None, ymax=None, mline=None,translation=False):499 def update(self,xmin=None,xmax=None,ymin=None, ymax=None, mline=None,translation=False): 465 500 """ 466 501 Draw the new roughness on the graph. 467 502 """ 468 if x!=None: 469 self.x = x 470 if ymin !=None: 471 self.ymin = ymin 472 if ymax !=None: 473 self.ymax = ymax 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]) 474 522 if mline !=None: 475 523 … … 478 526 if translation: 479 527 delta= 0 480 # rotation 481 x1 = self.radius1 * math.cos(self.phi_down + delta) 482 y1= self.radius1 * math.sin(self.phi_down + delta) 483 484 x2= -1*self.radius2 * math.cos( self.phi_up + delta) 485 y2= -1*self.radius2 * math.sin(self.phi_up + delta) 486 self.xmin= x1 487 self.xmax=x2 488 self.ymin= y1 489 self.ymax= y2 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 490 535 self.line.set(xdata=[self.xmin,self.xmax], ydata=[self.ymin,self.ymax]) 491 536 492 #else: 493 # self.line.set(xdata=[self.x,self.x], ydata=[self.ymin,self.ymax]) 494 495 537 496 538 497 539 def save(self, ev): … … 509 551 510 552 def moveend(self, ev): 511 553 self.clickxf,self.clickyf = ev.xdata,ev.ydata 554 print "move end ",self.clickxf,self.clickyf 512 555 self.has_move=False 513 556 self.base.moveend(ev) … … 527 570 Process move to a new position, making sure that the move is allowed. 528 571 """ 529 delta_xmin = x- self.save_xmin530 delta_xmax = x- self.save_xmax531 delta_ymin = y- self.save_ymin532 delta_ymax = y- self.save_ymax533 534 self.xmin= self.xmin + delta_xmin535 self.xmax= self.xmax + delta_xmax536 537 self.ymin= self.ymin +delta_ymin538 self.ymax= self.ymax +delta_ymax539 540 572 541 573 self.has_move=True
Note: See TracChangeset
for help on using the changeset viewer.