Changeset e20870bc in sasview for src/sas/qtgui/Plotting/Slicers/AnnulusSlicer.py
- Timestamp:
- Jun 27, 2018 3:33:52 AM (6 years ago)
- Branches:
- ESS_GUI, 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
- Children:
- b1a7a81
- Parents:
- c5e0d84
- git-author:
- Piotr Rozyczko <rozyczko@…> (05/31/18 05:15:47)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (06/27/18 03:33:52)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Plotting/Slicers/AnnulusSlicer.py
r4992ff2 re20870bc 382 382 self.set_cursor(x, self._inner_mouse_y) 383 383 384 class CircularMask(BaseInteractor): 385 """ 386 Draw a ring Given a radius 387 """ 388 def __init__(self, base, axes, color='grey', zorder=3, side=None): 389 """ 390 :param: the color of the line that defined the ring 391 :param r: the radius of the ring 392 :param sign: the direction of motion the the marker 393 """ 394 BaseInteractor.__init__(self, base, axes, color=color) 395 self.markers = [] 396 self.axes = axes 397 self.base = base 398 self.is_inside = side 399 self.qmax = min(numpy.fabs(self.base.data.xmax), 400 numpy.fabs(self.base.data.xmin)) # must be positive 401 self.connect = self.base.connect 402 403 # Cursor position of Rings (Left(-1) or Right(1)) 404 self.xmaxd = self.base.data.xmax 405 self.xmind = self.base.data.xmin 406 407 if (self.xmaxd + self.xmind) > 0: 408 self.sign = 1 409 else: 410 self.sign = -1 411 # Inner circle 412 self.outer_circle = RingInteractor(self, self.axes, 'blue', 413 zorder=zorder + 1, r=self.qmax / 1.8, 414 sign=self.sign) 415 self.outer_circle.qmax = self.qmax * 1.2 416 self.update() 417 self._post_data() 418 419 def set_layer(self, n): 420 """ 421 Allow adding plot to the same panel 422 :param n: the number of layer 423 """ 424 self.layernum = n 425 self.update() 426 427 def clear(self): 428 """ 429 Clear the slicer and all connected events related to this slicer 430 """ 431 self.clear_markers() 432 self.outer_circle.clear() 433 self.base.connect.clearall() 434 435 def update(self): 436 """ 437 Respond to changes in the model by recalculating the profiles and 438 resetting the widgets. 439 """ 440 # Update locations 441 self.outer_circle.update() 442 self._post_data() 443 out = self._post_data() 444 return out 445 446 def save(self, ev): 447 """ 448 Remember the roughness for this layer and the next so that we 449 can restore on Esc. 450 """ 451 self.outer_circle.save(ev) 452 453 def _post_data(self): 454 """ 455 Uses annulus parameters to plot averaged data into 1D data. 456 457 :param nbins: the number of points to plot 458 459 """ 460 # Data to average 461 data = self.base.data 462 463 # If we have no data, just return 464 if data is None: 465 return 466 mask = data.mask 467 from sas.sascalc.dataloader.manipulations import Ringcut 468 469 rmin = 0 470 rmax = numpy.fabs(self.outer_circle.get_radius()) 471 472 # Create the data1D Q average of data2D 473 mask = Ringcut(r_min=rmin, r_max=rmax) 474 475 if self.is_inside: 476 out = (mask(data) == False) 477 else: 478 out = (mask(data)) 479 return out 480 481 482 def moveend(self, ev): 483 """ 484 Called when any dragging motion ends. 485 Post an event (type =SlicerParameterEvent) 486 to plotter 2D with a copy slicer parameters 487 Call _post_data method 488 """ 489 self.base.thaw_axes() 490 # create a 1D data plot 491 self._post_data() 492 493 def restore(self): 494 """ 495 Restore the roughness for this layer. 496 """ 497 self.outer_circle.restore() 498 499 def move(self, x, y, ev): 500 """ 501 Process move to a new position, making sure that the move is allowed. 502 """ 503 pass 504 505 def set_cursor(self, x, y): 506 pass 507 508 def getParams(self): 509 """ 510 Store a copy of values of parameters of the slicer into a dictionary. 511 512 :return params: the dictionary created 513 514 """ 515 params = {} 516 params["outer_radius"] = numpy.fabs(self.outer_circle._inner_mouse_x) 517 return params 518 519 def setParams(self, params): 520 """ 521 Receive a dictionary and reset the slicer with values contained 522 in the values of the dictionary. 523 524 :param params: a dictionary containing name of slicer parameters and 525 values the user assigned to the slicer. 526 """ 527 outer = numpy.fabs(params["outer_radius"]) 528 # Update the picture 529 self.outer_circle.set_cursor(outer, self.outer_circle._inner_mouse_y) 530 # Post the data given the nbins entered by the user 531 self._post_data() 532 533 def draw(self): 534 self.base.update() 535 384
Note: See TracChangeset
for help on using the changeset viewer.