Changeset c5874f2 in sasview
- Timestamp:
- Apr 14, 2010 10:11:33 AM (15 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:
- 51a71a3
- Parents:
- f265927
- Location:
- guiframe/local_perspectives/plotting
- Files:
-
- 3 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/AnnulusSlicer.py
r78cae5a rc5874f2 395 395 self.set_cursor(x, self._inner_mouse_y) 396 396 397 397 class CircularMask(_BaseInteractor): 398 """ 399 Draw a ring Given a radius 400 @param: the color of the line that defined the ring 401 @param r: the radius of the ring 402 @param sign: the direction of motion the the marker 403 """ 404 def __init__(self,base,axes,color='black', zorder=3, side=None): 405 406 _BaseInteractor.__init__(self, base, axes, color=color) 407 self.markers = [] 408 self.axes = axes 409 self.base= base 410 self.is_inside = side 411 self.qmax = min(math.fabs(self.base.data.xmax),math.fabs(self.base.data.xmin)) #must be positive 412 self.connect = self.base.connect 413 414 #Cursor position of Rings (Left(-1) or Right(1)) 415 self.xmaxd=self.base.data.xmax 416 self.xmind=self.base.data.xmin 417 418 if (self.xmaxd+self.xmind)>0: 419 self.sign=1 420 else: 421 self.sign=-1 422 423 # Inner circle 424 self.outer_circle = RingInteractor(self, self.base.subplot, zorder=zorder+1, r=self.qmax/1.8,sign=self.sign) 425 self.outer_circle.qmax = self.qmax*1.2 426 427 self.update() 428 self._post_data() 429 430 # Bind to slice parameter events 431 #self.base.Bind(EVT_SLICER_PARS, self._onEVT_SLICER_PARS) 432 433 434 435 def _onEVT_SLICER_PARS(self, event): 436 """ 437 receive an event containing parameters values to reset the slicer 438 @param event: event of type SlicerParameterEvent with params as 439 attribute 440 """ 441 wx.PostEvent(self.base, StatusEvent(status="AnnulusSlicer._onEVT_SLICER_PARS")) 442 event.Skip() 443 if event.type == self.__class__.__name__: 444 self.set_params(event.params) 445 self.base.update() 446 447 def set_layer(self, n): 448 """ 449 Allow adding plot to the same panel 450 @param n: the number of layer 451 """ 452 self.layernum = n 453 self.update() 454 455 def clear(self): 456 """ 457 Clear the slicer and all connected events related to this slicer 458 """ 459 self.clear_markers() 460 self.outer_circle.clear() 461 self.base.connect.clearall() 462 #self.base.Unbind(EVT_SLICER_PARS) 463 464 465 def update(self): 466 """ 467 Respond to changes in the model by recalculating the profiles and 468 resetting the widgets. 469 """ 470 # Update locations 471 self.outer_circle.update() 472 #if self.is_inside != None: 473 out = self._post_data() 474 return out 475 476 def save(self, ev): 477 """ 478 Remember the roughness for this layer and the next so that we 479 can restore on Esc. 480 """ 481 self.base.freeze_axes() 482 self.outer_circle.save(ev) 483 484 def _post_data(self): 485 """ 486 Uses annulus parameters to plot averaged data into 1D data. 487 @param nbins: the number of points to plot 488 """ 489 #Data to average 490 data = self.base.data 491 492 # If we have no data, just return 493 if data == None: 494 return 495 mask = data.mask 496 from DataLoader.manipulations import Ringcut 497 498 rmin= 0 499 rmax = math.fabs(self.outer_circle.get_radius()) 500 501 ## create the data1D Q average of data2D 502 mask = Ringcut(r_min=rmin , r_max= rmax) 503 504 if self.is_inside: 505 out = (mask(data)==False) 506 else: 507 out = (mask(data)) 508 #self.base.data.mask=out 509 return out 510 511 512 def moveend(self, ev): 513 """ 514 Called when any dragging motion ends. 515 Post an event (type =SlicerParameterEvent) 516 to plotter 2D with a copy slicer parameters 517 Call _post_data method 518 """ 519 self.base.thaw_axes() 520 # create a 1D data plot 521 self._post_data() 522 523 def restore(self): 524 """ 525 Restore the roughness for this layer. 526 """ 527 self.outer_circle.restore() 528 529 def move(self, x, y, ev): 530 """ 531 Process move to a new position, making sure that the move is allowed. 532 """ 533 pass 534 535 def set_cursor(self, x, y): 536 pass 537 538 def get_params(self): 539 """ 540 Store a copy of values of parameters of the slicer into a dictionary. 541 @return params: the dictionary created 542 """ 543 params = {} 544 params["outer_radius"] = math.fabs(self.outer_circle._inner_mouse_x) 545 return params 546 547 def set_params(self, params): 548 """ 549 Receive a dictionary and reset the slicer with values contained 550 in the values of the dictionary. 551 @param params: a dictionary containing name of slicer parameters and 552 values the user assigned to the slicer. 553 """ 554 outer = math.fabs(params["outer_radius"] ) 555 ## Update the picture 556 self.outer_circle.set_cursor(outer, self.outer_circle._inner_mouse_y) 557 ## Post the data given the nbins entered by the user 558 self._post_data() 559 560 def freeze_axes(self): 561 self.base.freeze_axes() 562 563 def thaw_axes(self): 564 self.base.thaw_axes() 565 566 def draw(self): 567 self.base.update() 568
Note: See TracChangeset
for help on using the changeset viewer.