Changeset 57b7ee2 in sasview for src/sas/sasgui
- Timestamp:
- Feb 9, 2017 8:07:05 AM (8 years ago)
- Branches:
- 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
- Children:
- 9a05a8d5
- Parents:
- bda1faa7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py
r3bdbfcc r57b7ee2 2 2 Sector interactor 3 3 """ 4 import math4 import numpy 5 5 from PyQt4 import QtGui 6 6 from PyQt4 import QtCore … … 11 11 from sas.qtgui.SlicerModel import SlicerModel 12 12 13 MIN_PHI = 0.05 13 14 14 15 class SectorInteractor(_BaseInteractor, SlicerModel): … … 28 29 29 30 # Compute qmax limit to reset the graph 30 x = math.pow(max(self.base.data.xmax,31 math.fabs(self.base.data.xmin)), 2)32 y = math.pow(max(self.base.data.ymax,33 math.fabs(self.base.data.ymin)), 2)34 self.qmax = math.sqrt(x + y)31 x = numpy.power(max(self.base.data.xmax, 32 numpy.fabs(self.base.data.xmin)), 2) 33 y = numpy.power(max(self.base.data.ymax, 34 numpy.fabs(self.base.data.ymin)), 2) 35 self.qmax = numpy.sqrt(x + y) 35 36 # Number of points on the plot 36 37 self.nbins = 20 37 38 # Angle of the middle line 38 self.theta2 = math.pi / 339 self.theta2 = numpy.pi / 3 39 40 # Absolute value of the Angle between the middle line and any side line 40 self.phi = math.pi / 1241 self.phi = numpy.pi / 12 41 42 # Middle line 42 43 self.main_line = LineInteractor(self, self.axes, color='blue', … … 135 136 nbins = 20 136 137 sect = SectorQ(r_min=0.0, r_max=radius, 137 phi_min=phimin + math.pi,138 phi_max=phimax + math.pi, nbins=nbins)138 phi_min=phimin + numpy.pi, 139 phi_max=phimax + numpy.pi, nbins=nbins) 139 140 140 141 sector = sect(self.base.data) … … 209 210 # Always make sure that the left and the right line are at phi 210 211 # angle of the middle line 211 if math.fabs(self.left_line.phi) != math.fabs(self.right_line.phi):212 if numpy.fabs(self.left_line.phi) != numpy.fabs(self.right_line.phi): 212 213 msg = "Phi left and phi right are different" 213 214 msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 214 215 raise ValueError, msg 215 params["Phi [deg]"] = self.main_line.theta * 180 / math.pi216 params["Delta_Phi [deg]"] = math.fabs(self.left_line.phi * 180 / math.pi)216 params["Phi [deg]"] = self.main_line.theta * 180 / numpy.pi 217 params["Delta_Phi [deg]"] = numpy.fabs(self.left_line.phi * 180 / numpy.pi) 217 218 params["nbins"] = self.nbins 218 219 return params … … 226 227 values the user assigned to the slicer. 227 228 """ 228 main = params["Phi [deg]"] * math.pi / 180 229 phi = math.fabs(params["Delta_Phi [deg]"] * math.pi / 180) 229 main = params["Phi [deg]"] * numpy.pi / 180 230 phi = numpy.fabs(params["Delta_Phi [deg]"] * numpy.pi / 180) 231 232 # phi should not be too close. 233 if numpy.fabs(phi) < MIN_PHI: 234 phi = MIN_PHI 235 params["Delta_Phi [deg]"] = MIN_PHI 236 230 237 self.nbins = int(params["nbins"]) 231 238 self.main_line.theta = main … … 241 248 def draw(self): 242 249 """ 250 Redraw canvas 243 251 """ 244 252 self.base.draw() … … 254 262 """ 255 263 def __init__(self, base, axes, color='black', zorder=5, r=1.0, 256 phi= math.pi / 4, theta2=math.pi / 3):264 phi=numpy.pi / 4, theta2=numpy.pi / 3): 257 265 """ 258 266 """ … … 272 280 self.phi = phi 273 281 # End points polar coordinates 274 x1 = self.radius * math.cos(self.theta)275 y1 = self.radius * math.sin(self.theta)276 x2 = -1 * self.radius * math.cos(self.theta)277 y2 = -1 * self.radius * math.sin(self.theta)282 x1 = self.radius * numpy.cos(self.theta) 283 y1 = self.radius * numpy.sin(self.theta) 284 x2 = -1 * self.radius * numpy.cos(self.theta) 285 y2 = -1 * self.radius * numpy.sin(self.theta) 278 286 # Defining a new marker 279 287 self.inner_marker = self.axes.plot([x1 / 2.5], [y1 / 2.5], linestyle='', … … 331 339 delta = 0 332 340 if right: 333 self.phi = -1 * math.fabs(self.phi)341 self.phi = -1 * numpy.fabs(self.phi) 334 342 #delta=-delta 335 343 else: 336 self.phi = math.fabs(self.phi)344 self.phi = numpy.fabs(self.phi) 337 345 if side: 338 346 self.theta = mline.theta + self.phi … … 347 355 else: 348 356 theta3 = self.theta2 + delta 349 x1 = self.radius * math.cos(theta3)350 y1 = self.radius * math.sin(theta3)351 x2 = -1 * self.radius * math.cos(theta3)352 y2 = -1 * self.radius * math.sin(theta3)357 x1 = self.radius * numpy.cos(theta3) 358 y1 = self.radius * numpy.sin(theta3) 359 x2 = -1 * self.radius * numpy.cos(theta3) 360 y2 = -1 * self.radius * numpy.sin(theta3) 353 361 self.inner_marker.set(xdata=[x1 / 2.5], ydata=[y1 / 2.5]) 354 362 self.line.set(xdata=[x1, x2], ydata=[y1, y2]) … … 377 385 Process move to a new position, making sure that the move is allowed. 378 386 """ 379 self.theta = math.atan2(y, x)387 self.theta = numpy.arctan2(y, x) 380 388 self.has_move = True 381 389 if not self.left_moving: … … 388 396 return 389 397 elif self.theta2 < 0 and self.theta > 0 and \ 390 (self.theta2 + 2 * math.pi - self.theta) >= math.pi / 2:398 (self.theta2 + 2 * numpy.pi - self.theta) >= numpy.pi / 2: 391 399 self.restore() 392 400 return 393 401 elif self.theta2 < 0 and self.theta < 0 and \ 394 (self.theta2 - self.theta) >= math.pi / 2:395 self.restore() 396 return 397 elif self.theta2 > 0 and (self.theta2 - self.theta >= math.pi / 2 or \398 (self.theta2 - self.theta >= math.pi / 2)):402 (self.theta2 - self.theta) >= numpy.pi / 2: 403 self.restore() 404 return 405 elif self.theta2 > 0 and (self.theta2 - self.theta >= numpy.pi / 2 or \ 406 (self.theta2 - self.theta >= numpy.pi / 2)): 399 407 self.restore() 400 408 return 401 409 else: 402 if self.theta < 0 and (self.theta + math.pi * 2 - self.theta2) <= 0:410 if self.theta < 0 and (self.theta + numpy.pi * 2 - self.theta2) <= 0: 403 411 self.restore() 404 412 return … … 409 417 self.restore() 410 418 return 411 elif self.theta - self.theta2 >= math.pi / 2 or \412 ((self.theta + math.pi * 2 - self.theta2) >= math.pi / 2 and \419 elif self.theta - self.theta2 >= numpy.pi / 2 or \ 420 ((self.theta + numpy.pi * 2 - self.theta2) >= numpy.pi / 2 and \ 413 421 self.theta < 0 and self.theta2 > 0): 414 422 self.restore() 415 423 return 416 424 417 self.phi = math.fabs(self.theta2 - self.theta)418 if self.phi > math.pi:419 self.phi = 2 * math.pi - math.fabs(self.theta2 - self.theta)425 self.phi = numpy.fabs(self.theta2 - self.theta) 426 if self.phi > numpy.pi: 427 self.phi = 2 * numpy.pi - numpy.fabs(self.theta2 - self.theta) 420 428 self.base.base.update() 421 429 … … 446 454 """ 447 455 def __init__(self, base, axes, color='black', 448 zorder=5, r=1.0, theta= math.pi / 4):456 zorder=5, r=1.0, theta=numpy.pi / 4): 449 457 """ 450 458 """ … … 458 466 self.scale = 10.0 459 467 # Inner circle 460 x1 = self.radius * math.cos(self.theta)461 y1 = self.radius * math.sin(self.theta)462 x2 = -1 * self.radius * math.cos(self.theta)463 y2 = -1 * self.radius * math.sin(self.theta)468 x1 = self.radius * numpy.cos(self.theta) 469 y1 = self.radius * numpy.sin(self.theta) 470 x2 = -1 * self.radius * numpy.cos(self.theta) 471 y2 = -1 * self.radius * numpy.sin(self.theta) 464 472 # Inner circle marker 465 473 self.inner_marker = self.axes.plot([x1 / 2.5], [y1 / 2.5], linestyle='', … … 502 510 if theta != None: 503 511 self.theta = theta 504 x1 = self.radius * math.cos(self.theta)505 y1 = self.radius * math.sin(self.theta)506 x2 = -1 * self.radius * math.cos(self.theta)507 y2 = -1 * self.radius * math.sin(self.theta)512 x1 = self.radius * numpy.cos(self.theta) 513 y1 = self.radius * numpy.sin(self.theta) 514 x2 = -1 * self.radius * numpy.cos(self.theta) 515 y2 = -1 * self.radius * numpy.sin(self.theta) 508 516 509 517 self.inner_marker.set(xdata=[x1 / 2.5], ydata=[y1 / 2.5]) … … 533 541 Process move to a new position, making sure that the move is allowed. 534 542 """ 535 self.theta = math.atan2(y, x)543 self.theta = numpy.arctan2(y, x) 536 544 self.has_move = True 537 545 self.base.base.update()
Note: See TracChangeset
for help on using the changeset viewer.