Changeset e20870bc in sasview for src/sas/qtgui/Plotting/Slicers
- Timestamp:
- Jun 27, 2018 5: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 07:15:47)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (06/27/18 05:33:52)
- Location:
- src/sas/qtgui/Plotting/Slicers
- Files:
-
- 1 added
- 6 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 -
src/sas/qtgui/Plotting/Slicers/Arc.py
- Property mode changed from 100755 to 100644
rd744767 re20870bc 2 2 Arc slicer for 2D data 3 3 """ 4 import math4 import numpy as np 5 5 6 from .BaseInteractor import BaseInteractor6 from sas.qtgui.Plotting.Slicers.BaseInteractor import BaseInteractor 7 7 8 8 class ArcInteractor(BaseInteractor): … … 11 11 """ 12 12 def __init__(self, base, axes, color='black', zorder=5, r=1.0, 13 theta1= math.pi / 8, theta2=math.pi / 4):13 theta1=np.pi / 8, theta2=np.pi / 4): 14 14 BaseInteractor.__init__(self, base, axes, color=color) 15 15 self.markers = [] … … 55 55 Return arc radius 56 56 """ 57 radius = math.sqrt(math.pow(self._mouse_x, 2) + \58 math.pow(self._mouse_y, 2))57 radius = np.sqrt(np.power(self._mouse_x, 2) + \ 58 np.power(self._mouse_y, 2)) 59 59 return radius 60 60 … … 75 75 self.theta2 = theta2 76 76 while self.theta2 < self.theta1: 77 self.theta2 += (2 * math.pi)78 while self.theta2 >= (self.theta1 + 2 * math.pi):79 self.theta2 -= (2 * math.pi)80 npts = int((self.theta2 - self.theta1) / ( math.pi / 120))77 self.theta2 += (2 * np.pi) 78 while self.theta2 >= (self.theta1 + 2 * np.pi): 79 self.theta2 -= (2 * np.pi) 80 npts = int((self.theta2 - self.theta1) / (np.pi / 120)) 81 81 82 82 if r is None: 83 self.radius = math.sqrt(math.pow(self._mouse_x, 2) + \84 math.pow(self._mouse_y, 2))83 self.radius = np.sqrt(np.power(self._mouse_x, 2) + \ 84 np.power(self._mouse_y, 2)) 85 85 else: 86 86 self.radius = r 87 87 for i in range(self.npts): 88 88 phi = (self.theta2 - self.theta1) / (self.npts - 1) * i + self.theta1 89 xval = 1.0 * self.radius * math.cos(phi)90 yval = 1.0 * self.radius * math.sin(phi)89 xval = 1.0 * self.radius * np.cos(phi) 90 yval = 1.0 * self.radius * np.sin(phi) 91 91 92 92 x.append(xval) -
src/sas/qtgui/Plotting/Slicers/AzimutSlicer.py
- Property mode changed from 100755 to 100644
rb3e8629 re20870bc 4 4 # TODO: NEED MAJOR REFACTOR 5 5 # 6 import math 7 from .BaseInteractor import BaseInteractor 6 import numpy as np 7 from sas.qtgui.Plotting.Slicers.Arc import ArcInteractor 8 from sas.qtgui.Plotting.Slicers.RadiusInteractor import RadiusInteractor 9 from sas.qtgui.Plotting.Slicers.BaseInteractor import BaseInteractor 8 10 9 11 class SectorInteractor(BaseInteractor): … … 22 24 # # Number of points on the plot 23 25 self.nbins = 20 24 theta1 = 2 * math.pi / 325 theta2 = -2 * math.pi / 326 theta1 = 2 * np.pi / 3 27 theta2 = -2 * np.pi / 3 26 28 27 29 # Inner circle 28 from .Arc import ArcInteractor29 30 self.inner_circle = ArcInteractor(self, self.base.subplot, 30 31 zorder=zorder, … … 40 41 self.outer_circle.qmax = self.qmax * 1.2 41 42 # self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 42 from Edge import RadiusInteractor43 43 self.right_edge = RadiusInteractor(self, self.base.subplot, 44 44 zorder=zorder + 1, … … 132 132 phimin = self.left_edge.get_angle() 133 133 phimax = self.right_edge.get_angle() 134 # print "phimin, phimax, rmin ,rmax",math.degrees(phimin),135 # math.degrees(phimax), rmin ,rmax136 # from sas.sascalc.dataloader.manipulations import SectorQ137 134 138 135 sect = new_sector(r_min=rmin, r_max=rmax, -
src/sas/qtgui/Plotting/Slicers/BoxSlicer.py
r4992ff2 re20870bc 1 1 import numpy 2 2 3 from .BaseInteractor import BaseInteractor3 from sas.qtgui.Plotting.Slicers.BaseInteractor import BaseInteractor 4 4 from sas.qtgui.Plotting.PlotterData import Data1D 5 5 import sas.qtgui.Utilities.GuiUtils as GuiUtils -
src/sas/qtgui/Plotting/Slicers/BoxSum.py
rfbfc488 re20870bc 8 8 from sas.qtgui.Utilities.GuiUtils import formatNumber, toDouble 9 9 10 from .BaseInteractor import BaseInteractor10 from sas.qtgui.Plotting.Slicers.BaseInteractor import BaseInteractor 11 11 from sas.sascalc.dataloader.manipulations import Boxavg 12 12 from sas.sascalc.dataloader.manipulations import Boxsum -
src/sas/qtgui/Plotting/Slicers/SectorSlicer.py
rd6b8a1d re20870bc 5 5 import logging 6 6 7 from .BaseInteractor import BaseInteractor7 from sas.qtgui.Plotting.Slicers.BaseInteractor import BaseInteractor 8 8 from sas.qtgui.Plotting.PlotterData import Data1D 9 9 import sas.qtgui.Utilities.GuiUtils as GuiUtils … … 283 283 self.markers = [] 284 284 self.axes = axes 285 self.color = color 285 286 # compute the value of the angle between the current line and 286 287 # the x-axis … … 438 439 if self.phi > numpy.pi: 439 440 self.phi = 2 * numpy.pi - numpy.fabs(self.theta2 - self.theta) 440 self.base.base.update() 441 #self.base.base.update() 442 self.base.update() 441 443 442 444 def set_cursor(self, x, y): … … 464 466 465 467 self.markers = [] 468 self.color = color 466 469 self.axes = axes 467 470 self.save_theta = theta … … 541 544 self.theta = numpy.arctan2(y, x) 542 545 self.has_move = True 543 self.base.base.update() 546 #self.base.base.update() 547 self.base.update() 544 548 545 549 def set_cursor(self, x, y):
Note: See TracChangeset
for help on using the changeset viewer.