Changeset d955bf19 in sasview for guiframe/local_perspectives/plotting
- Timestamp:
- Jun 3, 2010 11:36:56 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:
- d7a39e5
- Parents:
- 83f4445
- Location:
- guiframe/local_perspectives/plotting
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/Edge.py
r0d9dae8 rd955bf19 12 12 class RadiusInteractor(_BaseInteractor): 13 13 """ 14 14 Select an annulus through a 2D plot 15 15 """ 16 16 def __init__(self,base,axes,color='black', zorder=5, arc1=None,arc2=None, … … 49 49 50 50 def set_layer(self, n): 51 """ 52 """ 51 53 self.layernum = n 52 54 self.update() 53 55 54 56 def clear(self): 57 """ 58 """ 55 59 self.clear_markers() 56 60 try: … … 61 65 for item in range(len(self.axes.lines)): 62 66 del self.axes.lines[0] 63 64 65 67 66 68 def get_angle(self): 69 """ 70 """ 67 71 return self.theta 68 72 … … 71 75 Draw the new roughness on the graph. 72 76 """ 73 if r1 != None:74 self.r1 =r175 if r2 !=None:76 self.r2 =r277 if r1 != None: 78 self.r1 = r1 79 if r2 != None: 80 self.r2 = r2 77 81 if theta !=None: 78 82 self.theta= theta 79 83 80 print "in the edge r1, r2",self.r1,self.r2,math.degrees(self.theta)84 #print "in the edge r1, r2",self.r1,self.r2,math.degrees(self.theta) 81 85 x1= self.r1*math.cos(self.theta) 82 86 y1= self.r1*math.sin(self.theta) … … 97 101 98 102 def moveend(self, ev): 103 """ 104 """ 99 105 self.has_move= False 100 106 self.base.moveend(ev) … … 110 116 Process move to a new position, making sure that the move is allowed. 111 117 """ 112 113 118 self.theta= math.atan2(y,x) 114 119 self.has_move= True 115 116 120 self.base.base.update() 117 121 118 122 def set_cursor(self,r_min, r_max, theta): 123 """ 124 """ 119 125 self.theta= theta 120 126 self.r1= r_min … … 122 128 self.update() 123 129 124 125 130 def get_params(self): 131 """ 132 """ 126 133 params = {} 127 134 params["radius1"] = self.r1 … … 131 138 132 139 def set_params(self, params): 133 print "when here set curcor arc" 134 140 """ 141 """ 142 #print "when here set curcor arc" 135 143 x1 = params["radius1"] 136 144 x2 = params["radius2"] -
guiframe/local_perspectives/plotting/Plotter1D.py
r0b57a57 rd955bf19 1 """ 2 This software was developed by the University of Tennessee as part of the 3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 4 project funded by the US National Science Foundation. 5 6 See the license text in license.txt 7 8 copyright 2008, University of Tennessee 9 """ 1 2 ################################################################################ 3 #This software was developed by the University of Tennessee as part of the 4 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 5 #project funded by the US National Science Foundation. 6 # 7 #See the license text in license.txt 8 # 9 #copyright 2008, University of Tennessee 10 ################################################################################ 10 11 11 12 … … 39 40 class ModelPanel1D(PlotPanel): 40 41 """ 41 42 Plot panel for use with the GUI manager 42 43 """ 43 44 … … 55 56 dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 56 57 """ 57 58 Initialize the panel 58 59 """ 59 60 PlotPanel.__init__(self, parent, id = id, style = style, **kwargs) … … 82 83 def _reset(self): 83 84 """ 84 85 Resets internal data and graph 85 86 """ 86 87 self.graph.reset() … … 90 91 def _onEVT_1DREPLOT(self, event): 91 92 """ 92 Data is ready to be displayed 93 @param event: data event 94 """ 95 93 Data is ready to be displayed 94 95 :param event: data event 96 97 """ 96 98 #TODO: Check for existence of plot attribute 97 99 # Check whether this is a replot. If we ask for a replot … … 159 161 def onLeftDown(self,event): 160 162 """ 161 162 163 left button down and ready to drag 164 Display the position of the mouse on the statusbar 163 165 """ 164 166 PlotPanel.onLeftDown(self, event) … … 173 175 def _onRemove(self, event): 174 176 """ 175 Remove a plottable from the graph and render the graph 176 @param event: Menu event 177 Remove a plottable from the graph and render the graph 178 179 :param event: Menu event 180 177 181 """ 178 182 ## Check if there is a selected graph to remove … … 190 194 self.subplot.figure.canvas.draw_idle() 191 195 192 193 194 196 def onContextMenu(self, event): 195 197 """ 196 1D plot context menu 197 @param event: wx context event 198 1D plot context menu 199 200 :param event: wx context event 201 198 202 """ 199 203 slicerpop = PanelMenu() … … 248 252 if self.graph.selected_plottable in self.plots: 249 253 selected_plot= self.plots[self.graph.selected_plottable] 250 #if self.plots[self.graph.selected_plottable].name in self.err_dy.iterkeys()\ 251 # and self.errors_hide: 252 """ 253 if selected_plot.__class__.__name__=="Data1D": 254 if numpy.all(selected_plot.dy==0): 255 id = wx.NewId() 256 slicerpop.Append(id, '&Show errors') 257 wx.EVT_MENU(self, id, self._on_add_errors) 258 elif selected_plot.dy !=None and selected_plot.dy != []: 259 id = wx.NewId() 260 slicerpop.Append(id, '&Hide Error bars') 261 wx.EVT_MENU(self, id, self._on_remove_errors) 262 """ 254 263 255 id = wx.NewId() 264 256 slicerpop.Append(id, '&Linear fit') … … 282 274 def _on_remove_errors(self, evt): 283 275 """ 284 Save name and dy of data in dictionary self.err_dy 285 Create a new data1D with the same x, y 286 vector and dy with zeros. 287 post self.err_dy as event (ErrorDataEvent) for any object 288 which wants to reconstruct the initial data. 289 @param evt: Menu event 276 Save name and dy of data in dictionary self.err_dy 277 Create a new data1D with the same x, y 278 vector and dy with zeros. 279 post self.err_dy as event (ErrorDataEvent) for any object 280 which wants to reconstruct the initial data. 281 282 :param evt: Menu event 283 290 284 """ 291 285 if not self.graph.selected_plottable == None: … … 296 290 ## Create a new dy for a new plottable 297 291 import numpy 298 dy = numpy.zeros(len(self.plots[self.graph.selected_plottable].y))299 selected_plot = self.plots[self.graph.selected_plottable]292 dy = numpy.zeros(len(self.plots[self.graph.selected_plottable].y)) 293 selected_plot = self.plots[self.graph.selected_plottable] 300 294 301 295 if selected_plot.__class__.__name__=="Data1D": … … 348 342 event = ErrorDataEvent(err_dy=self.err_dy) 349 343 wx.PostEvent(self.parent, event) 350 351 344 352 345 def _on_add_errors(self, evt): 353 346 """ 354 355 356 357 358 @param evt: Menu event359 """360 361 347 create a new data1D witht the errors saved in self.err_dy 348 to show errors of the plot. 349 Compute reasonable errors for a data set without 350 errors and transorm the plottable to a Data1D 351 352 :param evt: Menu event 353 354 """ 362 355 if not self.graph.selected_plottable == None \ 363 356 and self.graph.selected_plottable in self.plots.keys(): … … 434 427 def _onsaveTXT(self, path): 435 428 """ 436 Save file as txt 437 438 TODO: Refactor and remove this method. See TODO in _onSave. 429 Save file as txt 430 431 :TODO: Refactor and remove this method. See TODO in _onSave. 432 439 433 """ 440 434 data = self.plots[self.graph.selected_plottable] … … 477 471 def _onSave(self, evt): 478 472 """ 479 Save a data set to a text file 480 @param evt: Menu event 481 """ 482 473 Save a data set to a text file 474 475 :param evt: Menu event 476 477 """ 483 478 id = str(evt.GetId()) 484 479 if id in self.action_ids: … … 513 508 pass 514 509 dlg.Destroy() 515 516 517 518 519 520 521 522 523 -
guiframe/local_perspectives/plotting/Plotter2D.py
r88ca6db rd955bf19 1 """ 2 This software was developed by the University of Tennessee as part of the 3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 4 project funded by the US National Science Foundation. 5 6 See the license text in license.txt 7 8 copyright 2008, University of Tennessee 9 """ 1 2 ################################################################################ 3 #This software was developed by the University of Tennessee as part of the 4 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 5 #project funded by the US National Science Foundation. 6 # 7 #See the license text in license.txt 8 # 9 #copyright 2008, University of Tennessee 10 ################################################################################ 10 11 11 12 … … 34 35 BIN_WIDTH = 1.0 35 36 from danse.common.plottools.toolbar import NavigationToolBar 37 36 38 class NavigationToolBar2D(NavigationToolBar): 39 """ 40 """ 37 41 def __init__(self, canvas, parent=None): 38 42 NavigationToolBar.__init__(self, canvas=canvas, parent=parent) … … 40 44 def delete_option(self): 41 45 """ 42 46 remove default toolbar item 43 47 """ 44 48 #delete reset button … … 51 55 def add_option(self): 52 56 """ 53 57 add item to the toolbar 54 58 """ 55 59 #add print button … … 61 65 62 66 63 64 67 class ModelPanel2D(ModelPanel1D): 65 68 """ 66 69 Plot panel for use with the GUI manager 67 70 """ 68 71 … … 81 84 dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 82 85 """ 83 86 Initialize the panel 84 87 """ 85 88 ModelPanel1D.__init__(self, parent, id = id, style = style, **kwargs) … … 121 124 def add_toolbar(self): 122 125 """ 123 126 add toolbar 124 127 """ 125 128 self.enable_toolbar = True … … 141 144 def _onEVT_1DREPLOT(self, event): 142 145 """ 143 144 145 #TODO: this name should be changed to something more appropriate146 #Don't forget that changing this name will mean changing code147 #in plotting.py148 149 @param event: data event146 Data is ready to be displayed 147 148 :TODO: this name should be changed to something more appropriate 149 Don't forget that changing this name will mean changing code 150 in plotting.py 151 152 :param event: data event 150 153 """ 151 154 ## Update self.data2d with the current plot … … 224 227 def onContextMenu(self, event): 225 228 """ 226 2D plot context menu 227 @param event: wx context event 228 """ 229 229 2D plot context menu 230 231 :param event: wx context event 232 233 """ 230 234 slicerpop = PanelMenu() 231 235 slicerpop.set_plots(self.plots) … … 313 317 def _onEditDetector(self, event): 314 318 """ 315 Allow to view and edits detector parameters 316 @param event: wx.menu event 319 Allow to view and edits detector parameters 320 321 :param event: wx.menu event 322 317 323 """ 318 324 … … 359 365 360 366 def freeze_axes(self): 367 """ 368 """ 361 369 self.axes_frozen = True 362 370 363 371 def thaw_axes(self): 372 """ 373 """ 364 374 self.axes_frozen = False 365 375 366 376 def onMouseMotion(self,event): 377 """ 378 """ 367 379 pass 380 368 381 def onWheel(self, event): 382 """ 383 """ 369 384 pass 370 385 371 386 def update(self, draw=True): 372 387 """ 373 374 388 Respond to changes in the model by recalculating the 389 profiles and resetting the widgets. 375 390 """ 376 391 self.draw() 377 392 378 379 393 def _getEmptySlicerEvent(self): 380 394 """ 381 395 create an empty slicervent 382 396 """ 383 397 return SlicerEvent(type=None, 384 398 params=None, 385 399 obj_class=None) 400 386 401 def _onEVT_INTERNAL(self, event): 387 402 """ 388 Draw the slicer 389 @param event: wx.lib.newevent (SlicerEvent) containing slicer 403 Draw the slicer 404 405 :param event: wx.lib.newevent (SlicerEvent) containing slicer 390 406 parameter 407 391 408 """ 392 409 self._setSlicer(event.slicer) … … 394 411 def _setSlicer(self, slicer): 395 412 """ 396 Clear the previous slicer and create a new one.Post an internal 397 event. 398 @param slicer: slicer class to create 413 Clear the previous slicer and create a new one.Post an internal 414 event. 415 416 :param slicer: slicer class to create 417 399 418 """ 400 419 … … 423 442 def onCircular(self, event): 424 443 """ 425 perform circular averaging on Data2D 426 @param event: wx.menu event 444 perform circular averaging on Data2D 445 446 :param event: wx.menu event 447 427 448 """ 428 449 … … 462 483 new_plot.id = "Circ avg "+ self.data2D.name 463 484 new_plot.is_data= True 464 465 485 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=new_plot.name)) 466 486 467 468 487 def _onEditSlicer(self, event): 469 488 """ 470 Is available only when a slicer is drawn.Create a dialog 471 window where the user can enter value to reset slicer 472 parameters. 473 @param event: wx.menu event 489 Is available only when a slicer is drawn.Create a dialog 490 window where the user can enter value to reset slicer 491 parameters. 492 493 :param event: wx.menu event 494 474 495 """ 475 496 if self.slicer !=None: … … 481 502 dialog.Destroy() 482 503 483 484 504 def onSectorQ(self, event): 485 505 """ 486 506 Perform sector averaging on Q and draw sector slicer 487 507 """ 488 508 from SectorSlicer import SectorInteractor … … 492 512 def onSectorPhi(self, event): 493 513 """ 494 514 Perform sector averaging on Phi and draw annulus slicer 495 515 """ 496 516 from AnnulusSlicer import AnnulusInteractor … … 498 518 wx.PostEvent(self, InternalEvent(slicer= AnnulusInteractor)) 499 519 500 def onBoxSum(self,event): 520 def onBoxSum(self, event): 521 """ 522 """ 501 523 from boxSum import BoxSum 502 524 self.onClearSlicer(event) … … 530 552 main_panel =self)) 531 553 532 533 554 def onBoxavgX(self,event): 534 555 """ 535 Perform 2D data averaging on Qx 536 Create a new slicer . 537 @param event: wx.menu event 556 Perform 2D data averaging on Qx 557 Create a new slicer . 558 559 :param event: wx.menu event 538 560 """ 539 561 from boxSlicer import BoxInteractorX … … 541 563 wx.PostEvent(self, InternalEvent(slicer= BoxInteractorX)) 542 564 543 544 565 def onBoxavgY(self,event): 545 566 """ 546 Perform 2D data averaging on Qy 547 Create a new slicer . 548 @param event: wx.menu event 567 Perform 2D data averaging on Qy 568 Create a new slicer . 569 570 :param event: wx.menu event 571 549 572 """ 550 573 from boxSlicer import BoxInteractorY … … 552 575 wx.PostEvent(self, InternalEvent(slicer= BoxInteractorY)) 553 576 554 555 577 def onClearSlicer(self, event): 556 578 """ 557 579 Clear the slicer on the plot 558 580 """ 559 581 if not self.slicer==None: -
guiframe/local_perspectives/plotting/SectorSlicer.py
r08ece0b rd955bf19 1 #TODO: the line slicer should listen to all 2DREFRESH events, get the data and slice it 2 # before pushing a new 1D data update. 3 4 # 5 #TODO: NEED MAJOR REFACTOR 6 # 7 8 9 # Debug printout 1 10 2 import math 11 3 import wx … … 20 12 class SectorInteractor(_BaseInteractor): 21 13 """ 22 14 Draw a sector slicer.Allow to performQ averaging on data 2D 23 15 """ 24 16 def __init__(self,base,axes,color='black', zorder=3): … … 68 60 def _onEVT_SLICER_PARS(self, event): 69 61 """ 70 receive an event containing parameters values to reset the slicer 71 @param event: event of type SlicerParameterEvent with params as 72 attribute 62 receive an event containing parameters values to reset the slicer 63 64 :param event: event of type SlicerParameterEvent with params as 65 attribute 66 73 67 """ 74 68 wx.PostEvent(self.base.parent, StatusEvent(status="SectorSlicer._onEVT_SLICER_PARS")) … … 77 71 self.set_params(event.params) 78 72 self.base.update() 79 80 73 81 74 def set_layer(self, n): 82 75 """ 83 Allow adding plot to the same panel 84 @param n: the number of layer 76 Allow adding plot to the same panel 77 78 :param n: the number of layer 79 85 80 """ 86 81 self.layernum = n 87 82 self.update() 88 83 89 90 84 def clear(self): 91 85 """ 92 86 Clear the slicer and all connected events related to this slicer 93 87 """ 94 88 self.clear_markers() … … 99 93 self.base.Unbind(EVT_SLICER_PARS) 100 94 101 102 95 def update(self): 103 96 """ 104 105 97 Respond to changes in the model by recalculating the profiles and 98 resetting the widgets. 106 99 """ 107 100 # Update locations … … 128 121 self.left_line.update( phi=self.right_line.phi, delta=None, 129 122 mline=self.main_line, side=True, left=False ) 130 131 123 132 124 def save(self, ev): 133 125 """ … … 142 134 def _post_data(self, nbins=None): 143 135 """ 144 compute sector averaging of data2D into data1D 145 @param nbins: the number of point to plot for the average 1D data 136 compute sector averaging of data2D into data1D 137 138 :param nbins: the number of point to plot for the average 1D data 146 139 """ 147 140 ## get the data2D to average … … 190 183 new_plot.is_data= True 191 184 wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot, 192 title="SectorQ"+self.base.data2D.name )) 193 194 185 title="SectorQ"+self.base.data2D.name )) 195 186 196 187 def moveend(self, ev): 197 188 """ 198 189 Called a dragging motion ends.Get slicer event 199 190 """ 200 191 self.base.thaw_axes() … … 205 196 ## Send slicer paramers to plotter2D 206 197 wx.PostEvent(self.base, event) 207 #self._post_data() 208 209 198 210 199 def restore(self): 211 200 """ … … 222 211 pass 223 212 224 225 213 def set_cursor(self, x, y): 214 """ 215 """ 226 216 pass 227 217 228 229 218 def get_params(self): 230 219 """ 231 Store a copy of values of parameters of the slicer into a dictionary. 232 @return params: the dictionary created 220 Store a copy of values of parameters of the slicer into a dictionary. 221 222 :return params: the dictionary created 223 233 224 """ 234 225 params = {} … … 243 234 return params 244 235 245 246 236 def set_params(self, params): 247 237 """ 248 Receive a dictionary and reset the slicer with values contained 249 in the values of the dictionary. 250 @param params: a dictionary containing name of slicer parameters and 238 Receive a dictionary and reset the slicer with values contained 239 in the values of the dictionary. 240 241 :param params: a dictionary containing name of slicer parameters and 251 242 values the user assigned to the slicer. 252 243 """ … … 263 254 self._post_data(nbins=self.nbins) 264 255 265 266 256 def freeze_axes(self): 257 """ 258 """ 267 259 self.base.freeze_axes() 268 269 260 270 261 def thaw_axes(self): 262 """ 263 """ 271 264 self.base.thaw_axes() 272 265 273 274 266 def draw(self): 267 """ 268 """ 275 269 self.base.draw() 276 270 … … 278 272 class SideInteractor(_BaseInteractor): 279 273 """ 280 Draw an oblique line 281 @param phi: the phase between the middle line and one side line 282 @param theta2: the angle between the middle line and x- axis 274 Draw an oblique line 275 276 :param phi: the phase between the middle line and one side line 277 :param theta2: the angle between the middle line and x- axis 278 283 279 """ 284 280 def __init__(self,base,axes,color='black', zorder=5, r=1.0,phi=math.pi/4, theta2= math.pi/3): … … 335 331 self.connect_markers([self.inner_marker, self.line]) 336 332 337 338 333 def set_layer(self, n): 339 334 """ 340 Allow adding plot to the same panel 341 @param n: the number of layer 335 Allow adding plot to the same panel 336 337 :param n: the number of layer 338 342 339 """ 343 340 self.layernum = n … … 346 343 def clear(self): 347 344 """ 348 345 Clear the slicer and all connected events related to this slicer 349 346 """ 350 347 self.clear_markers() … … 356 353 for item in range(len(self.axes.lines)): 357 354 del self.axes.lines[0] 358 359 355 360 356 def update(self, phi=None, delta=None, mline=None, 361 357 side=False, left= False, right=False): 362 358 """ 363 Draw oblique line 364 @param phi: the phase between the middle line and the current line 365 @param delta: phi/2 applied only when the mline was moved 359 Draw oblique line 360 361 :param phi: the phase between the middle line and the current line 362 :param delta: phi/2 applied only when the mline was moved 363 366 364 """ 367 365 #print "update left or right ", self.has_move … … 372 370 if delta==None: 373 371 delta = 0 374 375 372 if right: 376 373 self.phi = -1*math.fabs(self.phi) … … 391 388 theta3=self.theta2+delta 392 389 393 394 390 x1= self.radius*math.cos(theta3) 395 391 y1= self.radius*math.sin(theta3) … … 400 396 self.line.set(xdata=[x1,x2], ydata=[y1,y2]) 401 397 402 403 404 405 398 def save(self, ev): 406 399 """ … … 412 405 413 406 def moveend(self, ev): 414 407 """ 408 """ 415 409 self.has_move=False 416 410 self.base.moveend(ev) … … 426 420 Process move to a new position, making sure that the move is allowed. 427 421 """ 428 429 422 self.theta= math.atan2(y,x) 430 423 self.has_move=True … … 470 463 if self.phi>math.pi: 471 464 self.phi= 2*math.pi-math.fabs(self.theta2 - self.theta) 472 473 #print "move , self.phi, self.theta,", self.theta*180/math.pi,self.theta2*180/math.pi,self.phi*180/math.pi 474 475 476 465 477 466 self.base.base.update() 478 467 479 468 def set_cursor(self, x, y): 469 """ 470 """ 480 471 self.move(x, y, None) 481 472 self.update() 482 483 473 484 474 def get_params(self): 475 """ 476 """ 485 477 params = {} 486 478 params["radius"] = self.radius … … 489 481 490 482 def set_params(self, params): 491 483 """ 484 """ 492 485 x = params["radius"] 493 486 self.set_cursor(x, self._inner_mouse_y) 494 487 495 496 488 497 489 class LineInteractor(_BaseInteractor): 498 490 """ 499 491 Select an annulus through a 2D plot 500 492 """ 501 493 def __init__(self,base,axes,color='black', zorder=5, r=1.0,theta=math.pi/4): 502 494 """ 495 """ 503 496 _BaseInteractor.__init__(self, base, axes, color=color) 497 504 498 self.markers = [] 505 499 self.axes = axes 506 507 500 self.save_theta = theta 508 501 self.theta= theta 509 510 502 self.radius = r 511 512 503 self.scale = 10.0 513 514 #raise "Version error", message515 516 504 # Inner circle 517 505 x1= self.radius*math.cos(self.theta) … … 536 524 message += "Get the SVN version that is at least as recent as June 1, 2007" 537 525 538 539 526 self.line = self.axes.plot([x1,x2],[y1,y2], 540 527 linestyle='-', marker='', 541 528 color=self.color, 542 529 visible=True)[0] 543 544 530 self.npts = 20 545 531 self.has_move=False … … 548 534 549 535 def set_layer(self, n): 536 """ 537 """ 550 538 self.layernum = n 551 539 self.update() 552 540 553 541 def clear(self): 542 """ 543 """ 554 544 self.clear_markers() 555 545 try: … … 561 551 del self.axes.lines[0] 562 552 563 564 553 def update(self, theta=None): 565 554 """ … … 576 565 self.inner_marker.set(xdata=[x1/2.5],ydata=[y1/2.5]) 577 566 self.line.set(xdata=[x1,x2], ydata=[y1,y2]) 578 579 580 567 581 568 def save(self, ev): 582 569 """ … … 588 575 589 576 def moveend(self, ev): 590 577 """ 578 """ 591 579 self.has_move=False 592 580 self.base.moveend(ev) … … 602 590 Process move to a new position, making sure that the move is allowed. 603 591 """ 604 605 592 self.theta= math.atan2(y,x) 606 #print "main_line previous theta --- next theta ",math.degrees(self.save_theta),math.degrees(self.theta)607 608 593 self.has_move=True 609 610 594 self.base.base.update() 611 595 612 596 def set_cursor(self, x, y): 597 """ 598 """ 613 599 self.move(x, y, None) 614 600 self.update() 615 601 616 617 602 def get_params(self): 603 """ 604 """ 618 605 params = {} 619 606 params["radius"] = self.radius … … 622 609 623 610 def set_params(self, params): 624 611 """ 612 """ 625 613 x = params["radius"] 626 614 self.set_cursor(x, self._inner_mouse_y) 627 628 629 615 -
guiframe/local_perspectives/plotting/SlicerParameters.py
r12aa9b5 rd955bf19 1 """ 2 Panel class to show the slicer parameters 3 """ 1 4 2 5 3 import wx … … 10 8 from sans.guicomm.events import EVT_SLICER,EVT_SLICER_PARS,SlicerParameterEvent 11 9 12 13 14 15 10 class SlicerParameterPanel(wx.Dialog): 11 """ 12 Panel class to show the slicer parameters 13 """ 16 14 #TODO: show units 17 15 #TODO: order parameters properly … … 20 18 wx.Dialog.__init__(self, parent, *args, **kwargs) 21 19 """ 22 23 20 Dialog window that allow to edit parameters slicer 21 by entering new values 24 22 """ 25 23 self.params = {} … … 40 38 def onEVT_SLICER(self, event): 41 39 """ 42 43 44 45 @param event: EVT_SLICER event40 Process EVT_SLICER events 41 When the slicer changes, update the panel 42 43 :param event: EVT_SLICER event 46 44 """ 47 45 event.Skip() … … 53 51 def set_slicer(self, type, params): 54 52 """ 55 53 Rebuild the panel 56 54 """ 57 55 self.bck.Clear(True) … … 106 104 def onParamChange(self, evt): 107 105 """ 108 109 106 receive an event end reset value text fields 107 inside self.parameters 110 108 """ 111 109 evt.Skip() … … 118 116 def onTextEnter(self, evt): 119 117 """ 120 118 Parameters have changed 121 119 """ 122 120 params = {} -
guiframe/local_perspectives/plotting/boxSlicer.py
r83f4445 rd955bf19 269 269 class HorizontalLines(_BaseInteractor): 270 270 """ 271 272 271 Draw 2 Horizontal lines centered on (0,0) that can move 272 on the x- direction and in opposite direction 273 273 """ 274 274 def __init__(self,base,axes,color='black', zorder=5,x=0.5, y=0.5): … … 332 332 self.update() 333 333 334 335 334 def clear(self): 336 335 """ … … 346 345 for item in range(len(self.axes.lines)): 347 346 del self.axes.lines[0] 348 349 347 350 348 def update(self,x=None,y=None): -
guiframe/local_perspectives/plotting/detector_dialog.py
r80a7f77 rd955bf19 20 20 21 21 DEFAULT_CMAP= pylab.cm.jet 22 22 23 class DetectorDialog(wx.Dialog): 23 24 """ 24 25 Dialog box to let the user edit detector settings 25 26 """ 26 27 27 28 def __init__(self,parent,id=1,base=None,dpi = None,cmap=DEFAULT_CMAP, 28 29 reset_zmin_ctl = None,reset_zmax_ctl = None, *args, **kwds): 29 30 """ 31 """ 30 32 kwds["style"] = wx.DEFAULT_DIALOG_STYLE 31 33 wx.Dialog.__init__(self,parent,id=1, *args, **kwds) … … 70 72 71 73 class Event: 74 """ 75 """ 72 76 xnpts = 0 73 77 ynpts = 0 … … 79 83 sym4 = False 80 84 81 82 83 85 def onSetFocus(self, event): 84 86 """ 85 87 Highlight the txtcrtl 86 88 """ 87 89 # Get a handle to the TextCtrl … … 93 95 def resetValues(self, event): 94 96 """ 95 97 reset detector info 96 98 """ 97 99 try: … … 114 116 def checkValues(self, event): 115 117 """ 116 117 118 Check the valitidity of zmin and zmax value 119 zmax should be a float and zmin less than zmax 118 120 """ 119 121 flag = True … … 154 156 def setContent(self, xnpts,ynpts, qmax, beam,zmin=None,zmax=None, sym=False): 155 157 """ 156 received value and displayed them 157 @param xnpts: the number of point of the x_bins of data 158 @param ynpts: the number of point of the y_bins of data 159 @param qmax: the maxmimum value of data pixel 160 @param beam : the radius of the beam 161 @param zmin: the value to get the minimum color 162 @param zmax: the value to get the maximum color 163 @param sym: 158 received value and displayed them 159 160 :param xnpts: the number of point of the x_bins of data 161 :param ynpts: the number of point of the y_bins of data 162 :param qmax: the maxmimum value of data pixel 163 :param beam: the radius of the beam 164 :param zmin: the value to get the minimum color 165 :param zmax: the value to get the maximum color 166 :param sym: 167 164 168 """ 165 169 self.xnpts_ctl.SetLabel(str(format_number(xnpts))) … … 167 171 self.qmax_ctl.SetLabel(str(format_number(qmax))) 168 172 self.beam_ctl.SetLabel(str(format_number(beam))) 169 170 171 173 172 174 if zmin !=None: 173 175 self.zmin_ctl.SetValue(str(format_number(zmin))) … … 177 179 def getContent(self): 178 180 """ 179 @return event containing value to reset the detector of a given data181 return event containing value to reset the detector of a given data 180 182 """ 181 183 event = self.Event() … … 206 208 def __set_properties(self): 207 209 """ 208 210 set proprieties of the dialog window 209 211 """ 210 212 self.SetTitle("Detector parameters") … … 214 216 def __do_layout(self): 215 217 """ 216 218 fill the dialog window . 217 219 """ 218 220 sizer_main = wx.BoxSizer(wx.VERTICAL) … … 222 224 sizer_selection= wx.BoxSizer(wx.HORIZONTAL) 223 225 224 225 226 iy = 0 226 227 sizer_params.Add(self.label_xnpts, (iy,0), (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) … … 243 244 iy += 1 244 245 245 246 247 246 self.fig = mpl.figure.Figure(dpi=self.dpi, figsize=(4,1)) 248 247 249 248 self.ax1 = self.fig.add_axes([0.05, 0.65, 0.9, 0.15]) 250 251 249 252 250 self.norm = mpl.colors.Normalize(vmin=0, vmax=100) 253 251 self.cb1 = mpl.colorbar.ColorbarBase(self.ax1, cmap=self.cmap, … … 276 274 sizer_main.Add(self.static_line_3, 0, wx.EXPAND, 0) 277 275 278 279 276 sizer_button.Add(self.button_reset,0, wx.LEFT|wx.ADJUST_MINSIZE, 100) 280 277 sizer_button.Add(self.button_OK, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10) 281 278 sizer_button.Add(self.button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 282 283 279 284 280 sizer_main.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 285 281 self.SetAutoLayout(True) … … 291 287 def _on_select_cmap(self, event): 292 288 """ 293 289 display a new cmap 294 290 """ 295 291 cmap_name= self.cmap_selector.GetCurrentSelection() -
guiframe/local_perspectives/plotting/masking.py
r54180f9 rd955bf19 1 """ 2 This software was developed by the University of Tennessee as part of the 3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 4 project funded by the US National Science Foundation. 5 6 If you use DANSE applications to do scientific research that leads to 7 publication, we ask that you acknowledge the use of the software with the 8 following sentence: 9 10 "This work benefited from DANSE software developed under NSF award DMR-0520547." 11 12 copyright 2008, University of Tennessee 13 """ 1 2 ################################################################################ 3 #This software was developed by the University of Tennessee as part of the 4 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 5 #project funded by the US National Science Foundation. 6 # 7 #If you use DANSE applications to do scientific research that leads to 8 #publication, we ask that you acknowledge the use of the software with the 9 #following sentence: 10 # 11 #"This work benefited from DANSE software developed under NSF award DMR-0520547." 12 # 13 #copyright 2008, University of Tennessee 14 ################################################################################ 15 16 14 17 ##Todo: cleaning up, improving the maskplotpanel initialization, and testing. 15 18 import wx … … 47 50 class MaskPanel(wx.Dialog): 48 51 """ 49 52 Provides the Mask Editor GUI. 50 53 """ 51 54 ## Internal nickname for the window, used by the AUI manager … … 57 60 def __init__(self, parent=None,base=None,data =None, id = -1, *args, **kwds): 58 61 kwds["style"] = wx.DEFAULT_DIALOG_STYLE 59 wx.Dialog.__init__(self, parent, id = id, size=wx.Size(_STATICBOX_WIDTH*2,PANEL_SIZE), *args, **kwds) 62 kwds["size"] = wx.Size(_STATICBOX_WIDTH*2,PANEL_SIZE) 63 wx.Dialog.__init__(self, parent, id = id, *args, **kwds) 60 64 if data != None: 61 65 … … 99 103 def ShowMessage(self, msg=''): 100 104 """ 101 105 Show error message when mask covers whole data area 102 106 """ 103 107 mssg = 'Erase, redraw or clear the mask. \n\r' … … 109 113 def _setup_layout(self): 110 114 """ 111 115 Set up the layout 112 116 """ 113 117 shape = "Select a Shape for Masking:" … … 195 199 def onInnerBoxMask(self,event=None): 196 200 """ 197 201 Call Draw Box Slicer and get mask inside of the box 198 202 """ 199 203 #get ready for next evt … … 214 218 def onOuterBoxMask(self,event=None): 215 219 """ 216 220 Call Draw Box Slicer and get mask outside of the box 217 221 """ 218 222 event.Skip() … … 232 236 def onInnerSectorMask(self,event=None): 233 237 """ 234 238 Call Draw Sector Slicer and get mask inside of the sector 235 239 """ 236 240 event.Skip() … … 250 254 def onOuterSectorMask(self,event=None): 251 255 """ 252 256 Call Draw Sector Slicer and get mask outside of the sector 253 257 """ 254 258 event.Skip() … … 268 272 def onInnerRingMask(self, event=None): 269 273 """ 270 274 Perform inner circular cut on Phi and draw circular slicer 271 275 """ 272 276 event.Skip() … … 286 290 def onOuterRingMask(self, event=None): 287 291 """ 288 292 Perform outer circular cut on Phi and draw circular slicer 289 293 """ 290 294 event.Skip() … … 302 306 def onAddMask(self, event): 303 307 """ 304 308 Add new mask to old mask 305 309 """ 306 310 if not self.slicer==None: … … 314 318 def _check_display_mask(self, mask, event): 315 319 """ 316 check if the mask valid and update the plot 317 @param mask: mask data 320 check if the mask valid and update the plot 321 322 :param mask: mask data 323 318 324 """ 319 325 ## Redraw the current image … … 322 328 def onEraseMask(self, event): 323 329 """ 324 330 Erase new mask from old mask 325 331 """ 326 332 if not self.slicer==None: … … 333 339 def onResetMask(self, event): 334 340 """ 335 Reset mask to the original mask 336 """ 337 341 Reset mask to the original mask 342 """ 338 343 self.slicer_z += 1 339 344 self.slicer = BoxMask(self, self.subplot, zorder=self.slicer_z, side=True) … … 349 354 def onClearMask(self, event): 350 355 """ 351 356 Clear mask 352 357 """ 353 358 self.slicer_z += 1 … … 365 370 def onClearSlicer(self, event): 366 371 """ 367 372 Clear the slicer on the plot 368 373 """ 369 374 if not self.slicer==None: … … 372 377 self.slicer = None 373 378 374 375 379 def _setSlicer(self): 376 380 """ 377 Clear the previous slicer and create a new one.Post an internal 378 event. 379 @param slicer: slicer class to create 380 """ 381 381 Clear the previous slicer and create a new one.Post an internal 382 event. 383 384 :param slicer: slicer class to create 385 386 """ 382 387 ## Clear current slicer 383 388 if not self.slicer == None: … … 403 408 def update(self, draw=True): 404 409 """ 405 406 410 Respond to changes in the model by recalculating the 411 profiles and resetting the widgets. 407 412 """ 408 413 self.plotpanel.draw() … … 410 415 def _set_mask(self, mask): 411 416 """ 412 Set mask"417 Set mask 413 418 """ 414 419 self.data.mask = mask … … 416 421 def _update_mask(self,mask): 417 422 """ 418 423 Respond to changes in masking 419 424 """ 420 425 # the case of liitle numbers of True points … … 482 487 def _getEmptySlicerEvent(self): 483 488 """ 484 489 create an empty slicervent 485 490 """ 486 491 self.innerbox_rb.SetValue(False) … … 497 502 def _draw_model(self,event): 498 503 """ 499 504 on_close, update the model2d plot 500 505 """ 501 506 pass 502 507 503 508 def freeze_axes(self): 509 """ 510 """ 504 511 self.plotpanel.axes_frozen = True 512 505 513 def thaw_axes(self): 506 self.plotpanel.axes_frozen = False 514 """ 515 """ 516 self.plotpanel.axes_frozen = False 517 507 518 def onMouseMotion(self,event): 519 """ 520 """ 508 521 pass 522 509 523 def onWheel(self, event): 524 """ 525 """ 510 526 pass 511 527 512 528 class Maskplotpanel(PlotPanel): 513 514 def __init__(self, parent, id = -1, color = None,\ 515 dpi = None, **kwargs): 529 """ 530 """ 531 def __init__(self, parent, id = -1, color = None, dpi = None, **kwargs): 532 """ 533 """ 516 534 PlotPanel.__init__(self, parent, id=id, color=color, dpi=dpi, **kwargs) 517 535 … … 525 543 def add_toolbar(self): 526 544 """ 527 545 Add toolbar 528 546 """ 529 547 # Not implemented … … 531 549 def on_set_focus(self, event): 532 550 """ 533 551 send to the parenet the current panel on focus 534 552 """ 535 553 #change the panel background … … 538 556 539 557 def add_image(self, plot): 558 """ 559 """ 540 560 self.plots[plot.name] = plot 541 561 #init graph … … 552 572 def onMouseMotion(self, event): 553 573 """ 554 574 Disable dragging 2D image 555 575 """ 556 576 pass … … 558 578 def onContextMenu(self, event): 559 579 """ 560 580 Default context menu for a plot panel 561 581 """ 562 582 # Slicer plot popup menu … … 576 596 class ViewerFrame(wx.Frame): 577 597 """ 578 598 Add comment 579 599 """ 580 600 def __init__(self, parent, id, title): 581 601 """ 582 583 @param parent: parent panel/container602 comment 603 :param parent: parent panel/container 584 604 """ 585 605 # Initialize the Frame object -
guiframe/local_perspectives/plotting/plotting.py
r2fc9243 rd955bf19 1 """2 This software was developed by the University of Tennessee as part of the3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE)4 project funded by the US National Science Foundation.5 1 6 See the license text in license.txt7 2 8 copyright 2008, University of Tennessee9 """10 3 4 ################################################################################ 5 #This software was developed by the University of Tennessee as part of the 6 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 7 #project funded by the US National Science Foundation. 8 # 9 #See the license text in license.txt 10 # 11 #copyright 2008, University of Tennessee 12 ################################################################################ 11 13 12 14 import wx … … 18 20 class Plugin: 19 21 """ 20 22 Plug-in class to be instantiated by the GUI manager 21 23 """ 22 24 23 25 def __init__(self): 24 26 """ 25 27 Initialize the plug-in 26 28 """ 27 29 ## Plug-in name … … 39 41 def populate_menu(self, id, parent): 40 42 """ 41 Create a 'Plot' menu to list the panels 42 available for displaying 43 @param id: next available unique ID for wx events 44 @param parent: parent window 43 Create a 'Plot' menu to list the panels 44 available for displaying 45 46 :param id: next available unique ID for wx events 47 :param parent: parent window 48 45 49 """ 46 50 self.menu = wx.Menu() … … 51 55 return [(id, self.menu, "Plot")] 52 56 53 54 57 def get_panels(self, parent): 55 58 """ 56 59 Create and return a list of panel objects 57 60 """ 58 61 ## Save a reference to the parent … … 61 64 self.parent.Bind(EVT_NEW_PLOT, self._on_plot_event) 62 65 # We have no initial panels for this plug-in 63 64 66 return [] 65 67 66 67 68 def get_perspective(self): 68 69 """ 69 70 Get the list of panel names for this perspective 70 71 """ 71 72 return self.perspective … … 82 83 def post_init(self): 83 84 """ 84 85 85 Post initialization call back to close the loose ends 86 [Somehow openGL needs this call] 86 87 """ 87 88 pass 88 89 89 90 90 def _on_show_panel(self, event): … … 95 95 def _on_plot_event(self, event): 96 96 """ 97 A new plottable is being shipped to the plotting plug-in. 98 Check whether we have a panel to put in on, or create 99 a new one 100 @param event: EVT_NEW_PLOT event 97 A new plottable is being shipped to the plotting plug-in. 98 Check whether we have a panel to put in on, or create 99 a new one 100 101 :param event: EVT_NEW_PLOT event 102 101 103 """ 102 104 # Check whether we already have a graph with the same units -
guiframe/local_perspectives/plotting/sectorMask.py
raef2cf2 rd955bf19 10 10 class SectorMask(_BaseInteractor): 11 11 """ 12 12 Draw a sector slicer.Allow to find the data 2D inside of the sector lines 13 13 """ 14 14 def __init__(self,base,axes,color='gray', zorder=3, side = False): … … 56 56 def clear(self): 57 57 """ 58 58 Clear the slicer and all connected events related to this slicer 59 59 """ 60 60 self.clear_markers() … … 68 68 def update(self): 69 69 """ 70 71 70 Respond to changes in the model by recalculating the profiles and 71 resetting the widgets. 72 72 """ 73 73 # Update locations … … 110 110 def _post_data(self): 111 111 """ 112 112 compute sector averaging of data into data1D 113 113 """ 114 114 ## get the data to average … … 136 136 def moveend(self, ev): 137 137 """ 138 138 Called a dragging motion ends.Get slicer event 139 139 """ 140 140 self.base.thaw_axes() … … 169 169 def get_params(self): 170 170 """ 171 Store a copy of values of parameters of the slicer into a dictionary. 172 @return params: the dictionary created 171 Store a copy of values of parameters of the slicer into a dictionary. 172 173 :return params: the dictionary created 174 173 175 """ 174 176 params = {} … … 182 184 return params 183 185 184 185 186 def set_params(self, params): 186 187 """ 187 Receive a dictionary and reset the slicer with values contained 188 in the values of the dictionary. 189 @param params: a dictionary containing name of slicer parameters and 188 Receive a dictionary and reset the slicer with values contained 189 in the values of the dictionary. 190 191 :param params: a dictionary containing name of slicer parameters and 190 192 values the user assigned to the slicer. 191 193 """ … … 202 204 self._post_data() 203 205 204 205 206 def freeze_axes(self): 207 """ 208 """ 206 209 self.base.freeze_axes() 207 210 208 209 211 def thaw_axes(self): 212 """ 213 """ 210 214 self.base.thaw_axes() 211 215 212 213 216 def draw(self): 217 """ 218 """ 214 219 self.base.update() 215 220 -
guiframe/local_perspectives/plotting/slicerpanel.py
rddd864e rd955bf19 1 """ 2 Panel class to show the slicer parameters 3 """ 1 4 2 5 3 import wx … … 13 11 14 12 class SlicerPanel(wx.Panel): 13 """ 14 Panel class to show the slicer parameters 15 """ 15 16 #TODO: show units 16 17 #TODO: order parameters properly … … 46 47 def onEVT_SLICER(self, event): 47 48 """ 48 Process EVT_SLICER events 49 When the slicer changes, update the panel 50 @param event: EVT_SLICER event 49 Process EVT_SLICER events 50 When the slicer changes, update the panel 51 52 :param event: EVT_SLICER event 53 51 54 """ 52 55 event.Skip() … … 56 59 self.set_slicer(event.type, event.params) 57 60 58 59 61 def set_slicer(self, type, params): 60 62 """ 61 63 Rebuild the panel 62 64 """ 63 65 self.bck.Clear(True) … … 106 108 def onSetFocus(self, evt): 107 109 """ 108 110 Hightlight the textcrtl 109 111 """ 110 112 # Get a handle to the TextCtrl … … 117 119 def onParamChange(self, evt): 118 120 """ 119 121 Receive and event and reset the text field contained in self.parameters 120 122 121 123 """ … … 126 128 item[1].Refresh() 127 129 128 129 130 def onTextEnter(self, evt): 130 131 """ 131 132 Parameters have changed 132 133 """ 133 134 params = {}
Note: See TracChangeset
for help on using the changeset viewer.