Changeset 3bdbfcc in sasview for src/sas/qtgui/PlotterBase.py
- Timestamp:
- Feb 2, 2017 6:29:07 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:
- 965fbd8
- Parents:
- 5d89f43
- git-author:
- Piotr Rozyczko <rozyczko@…> (01/23/17 07:21:03)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (02/02/17 06:29:07)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/PlotterBase.py
r092a3d9 r3bdbfcc 220 220 self.contextMenu.exec_(self.canvas.mapToGlobal(event_pos)) 221 221 222 def onMplMouseUp(self, event): 223 """ 224 Mouse button up callback 225 """ 226 pass 227 222 228 def onMplMouseDown(self, event): 223 229 """ 224 Left button down and ready to drag 225 """ 226 # Check that the LEFT button was pressed 227 if event.button == 1: 228 self.leftdown = True 229 ax = event.inaxes 230 for text in self.textList: 231 if text.contains(event)[0]: # If user has clicked on text 232 self.selectedText = text 233 return 234 235 if ax != None: 236 self.xInit, self.yInit = event.xdata, event.ydata 237 try: 238 self.x_click = float(event.xdata) # / size_x 239 self.y_click = float(event.ydata) # / size_y 240 except: 241 self.position = None 242 243 def onMplMouseUp(self, event): 244 """ 245 Set the data coordinates of the click 246 """ 247 self.x_click = event.xdata 248 self.y_click = event.ydata 249 250 # Check that the LEFT button was released 251 if event.button == 1: 252 self.leftdown = False 253 #self.leftup = True 254 self.selectedText = None 255 256 #release the legend 257 if self.gotLegend == 1: 258 self.gotLegend = 0 230 Mouse button down callback 231 """ 232 pass 259 233 260 234 def onMplMouseMotion(self, event): 261 235 """ 262 Check if the left button is press and the mouse in moving. 263 Compute delta for x and y coordinates and then perform the drag 264 """ 265 if self.gotLegend == 1 and self.leftdown: 266 self.onLegendMotion(event) 267 return 268 269 if self.leftdown and self.selectedText is not None: 270 # User has clicked on text and is dragging 271 ax = event.inaxes 272 if ax != None: 273 # Only move text if mouse is within axes 274 self.selectedText.set_position((event.xdata, event.ydata)) 275 self.canvas.draw_idle() 276 else: 277 # User has dragged outside of axes 278 self.selectedText = None 279 return 236 Mouse motion callback 237 """ 238 pass 280 239 281 240 def onMplPick(self, event): 282 241 """ 283 On pick legend 284 """ 285 legend = self.legend 286 if event.artist == legend: 287 # Get the box of the legend. 288 bbox = self.legend.get_window_extent() 289 # Get mouse coordinates at time of pick. 290 self.mouse_x = event.mouseevent.x 291 self.mouse_y = event.mouseevent.y 292 # Get legend coordinates at time of pick. 293 self.legend_x = bbox.xmin 294 self.legend_y = bbox.ymin 295 # Indicate we picked up the legend. 296 self.gotLegend = 1 297 298 #self.legend.legendPatch.set_alpha(0.5) 299 300 def onLegendMotion(self, event): 301 """ 302 On legend in motion 303 """ 304 ax = event.inaxes 305 if ax == None: 306 return 307 # Event occurred inside a plotting area 308 lo_x, hi_x = ax.get_xlim() 309 lo_y, hi_y = ax.get_ylim() 310 # How much the mouse moved. 311 x = mouse_diff_x = self.mouse_x - event.x 312 y = mouse_diff_y = self.mouse_y - event.y 313 # Put back inside 314 if x < lo_x: 315 x = lo_x 316 if x > hi_x: 317 x = hi_x 318 if y < lo_y: 319 y = lo_y 320 if y > hi_y: 321 y = hi_y 322 # Move the legend from its previous location by that same amount 323 loc_in_canvas = self.legend_x - mouse_diff_x, \ 324 self.legend_y - mouse_diff_y 325 # Transform into legend coordinate system 326 trans_axes = self.legend.parent.transAxes.inverted() 327 loc_in_norm_axes = trans_axes.transform_point(loc_in_canvas) 328 self.legend_pos_loc = tuple(loc_in_norm_axes) 329 self.legend._loc = self.legend_pos_loc 330 # self.canvas.draw() 331 self.canvas.draw_idle() 242 Mouse pick callback 243 """ 244 pass 332 245 333 246 def onMplWheel(self, event): 334 247 """ 335 Process mouse wheel as zoom events 336 """ 337 ax = event.inaxes 338 step = event.step 339 340 if ax != None: 341 # Event occurred inside a plotting area 342 lo, hi = ax.get_xlim() 343 lo, hi = PlotUtilities.rescale(lo, hi, step, 344 pt=event.xdata, scale=ax.get_xscale()) 345 if not self.xscale == 'log' or lo > 0: 346 self._scale_xlo = lo 347 self._scale_xhi = hi 348 ax.set_xlim((lo, hi)) 349 350 lo, hi = ax.get_ylim() 351 lo, hi = PlotUtilities.rescale(lo, hi, step, pt=event.ydata, 352 scale=ax.get_yscale()) 353 if not self.yscale == 'log' or lo > 0: 354 self._scale_ylo = lo 355 self._scale_yhi = hi 356 ax.set_ylim((lo, hi)) 357 else: 358 # Check if zoom happens in the axes 359 xdata, ydata = None, None 360 x, y = event.x, event.y 361 362 for ax in self.axes: 363 insidex, _ = ax.xaxis.contains(event) 364 if insidex: 365 xdata, _ = ax.transAxes.inverted().transform_point((x, y)) 366 insidey, _ = ax.yaxis.contains(event) 367 if insidey: 368 _, ydata = ax.transAxes.inverted().transform_point((x, y)) 369 if xdata is not None: 370 lo, hi = ax.get_xlim() 371 lo, hi = PlotUtilities.rescale(lo, hi, step, 372 bal=xdata, scale=ax.get_xscale()) 373 if not self.xscale == 'log' or lo > 0: 374 self._scale_xlo = lo 375 self._scale_xhi = hi 376 ax.set_xlim((lo, hi)) 377 if ydata is not None: 378 lo, hi = ax.get_ylim() 379 lo, hi = PlotUtilities.rescale(lo, hi, step, bal=ydata, 380 scale=ax.get_yscale()) 381 if not self.yscale == 'log' or lo > 0: 382 self._scale_ylo = lo 383 self._scale_yhi = hi 384 ax.set_ylim((lo, hi)) 385 self.canvas.draw_idle() 248 Mouse wheel scroll callback 249 """ 250 pass 386 251 387 252 def clean(self):
Note: See TracChangeset
for help on using the changeset viewer.