Changeset 914ba0a in sasview for src/sas/sasgui/guiframe/local_perspectives
- Timestamp:
- May 2, 2017 3:58:01 PM (8 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d66dbcc
- Parents:
- 74d9780 (diff), 658dd57 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/sasgui/guiframe/local_perspectives
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
refe730d r914ba0a 7 7 import wx 8 8 import logging 9 10 logger = logging.getLogger(__name__) 9 11 10 12 from sas.sascalc.dataloader.loader import Loader … … 58 60 path = None 59 61 self._default_save_location = self.parent._default_save_location 60 if self._default_save_location ==None:62 if self._default_save_location is None: 61 63 self._default_save_location = os.getcwd() 62 64 … … 75 77 if dlg.ShowModal() == wx.ID_OK: 76 78 file_list = dlg.GetPaths() 77 if len(file_list) >= 0 and not file_list[0] isNone:79 if len(file_list) >= 0 and file_list[0] is not None: 78 80 self._default_save_location = os.path.dirname(file_list[0]) 79 81 path = self._default_save_location … … 99 101 path = None 100 102 self._default_save_location = self.parent._default_save_location 101 if self._default_save_location ==None:103 if self._default_save_location is None: 102 104 self._default_save_location = os.getcwd() 103 105 dlg = wx.DirDialog(self.parent, "Choose a directory", … … 145 147 message += "\tError: {0}\n".format(error_data) 146 148 else: 147 logg ing.error("Loader returned an invalid object:\n %s" % str(item))149 logger.error("Loader returned an invalid object:\n %s" % str(item)) 148 150 data_error = True 149 151 150 152 data = self.parent.create_gui_data(item, p_file) 151 153 output[data.id] = data … … 155 157 """ 156 158 """ 157 message = "" 158 log_msg = '' 159 file_errors = {} 159 160 output = {} 160 any_error = False 161 data_error = False 162 error_message = "" 161 exception_occurred = False 162 163 163 for p_file in path: 164 info = "info"165 164 basename = os.path.basename(p_file) 166 165 _, extension = os.path.splitext(basename) 167 166 if extension.lower() in EXTENSIONS: 168 any_error = True169 167 log_msg = "Data Loader cannot " 170 log_msg += "load: %s\n" % str(p_file)171 log_msg += " ""Please try to open that file from "open project" """172 log_msg += " ""or "open analysis" menu\n"""173 error_message = log_msg + "\n"174 logging.info(log_msg)168 log_msg += "load: {}\n".format(str(p_file)) 169 log_msg += "Please try to open that file from \"open project\"" 170 log_msg += "or \"open analysis\" menu." 171 logger.info(log_msg) 172 file_errors[basename] = [log_msg] 175 173 continue 176 174 177 175 try: 178 message = "Loading Data... " + str(p_file) + "\n"179 self.load_update(output=output, message=message, info= info)176 message = "Loading {}...\n".format(p_file) 177 self.load_update(output=output, message=message, info="info") 180 178 temp = self.loader.load(p_file, format) 181 if temp.__class__.__name__ == "list": 182 for item in temp: 183 output, error_message, data_error = \ 184 self._process_data_and_errors(item, 185 p_file, 186 output, 187 error_message) 188 else: 179 if not isinstance(temp, list): 180 temp = [temp] 181 for item in temp: 182 error_message = "" 189 183 output, error_message, data_error = \ 190 self._process_data_and_errors(temp, 191 p_file, 192 output, 193 error_message) 184 self._process_data_and_errors(item, 185 p_file, 186 output, 187 error_message) 188 if data_error: 189 if basename in file_errors.keys(): 190 file_errors[basename] += [error_message] 191 else: 192 file_errors[basename] = [error_message] 193 self.load_update(output=output, 194 message=error_message, info="warning") 195 196 self.load_update(output=output, 197 message="Loaded {}\n".format(p_file), 198 info="info") 199 194 200 except: 195 logging.error(sys.exc_value) 196 any_error = True 197 if any_error or error_message != "": 198 if error_message == "": 199 error = "Error: " + str(sys.exc_info()[1]) + "\n" 200 error += "while loading Data: \n%s\n" % str(basename) 201 error_message += "The data file you selected could not be loaded.\n" 202 error_message += "Make sure the content of your file" 203 error_message += " is properly formatted.\n\n" 204 error_message += "When contacting the SasView team, mention the" 205 error_message += " following:\n%s" % str(error) 206 elif data_error: 207 base_message = "Errors occurred while loading " 208 base_message += "{0}\n".format(basename) 209 base_message += "The data file loaded but with errors.\n" 210 error_message = base_message + error_message 211 else: 212 error_message += "%s\n" % str(p_file) 213 info = "error" 214 215 if any_error or error_message: 216 self.load_update(output=output, message=error_message, info=info) 217 else: 218 message = "Loading Data Complete! " 219 message += log_msg 220 self.load_complete(output=output, error_message=error_message, 221 message=message, path=path, info='info') 201 logger.error(sys.exc_value) 202 203 error_message = "The Data file you selected could not be loaded.\n" 204 error_message += "Make sure the content of your file" 205 error_message += " is properly formatted.\n" 206 error_message += "When contacting the SasView team, mention the" 207 error_message += " following:\n" 208 error_message += "Error: " + str(sys.exc_info()[1]) 209 file_errors[basename] = [error_message] 210 self.load_update(output=output, message=error_message, info="warning") 211 212 if len(file_errors) > 0: 213 error_message = "" 214 for filename, error_array in file_errors.iteritems(): 215 error_message += "The following errors occured whilst " 216 error_message += "loading {}:\n".format(filename) 217 for message in error_array: 218 error_message += message + "\n" 219 error_message += "\n" 220 self.load_update(output=output, message=error_message, info="error") 221 222 self.load_complete(output=output, message="Loading data complete!", 223 info="info") 222 224 223 225 def load_update(self, output=None, message="", info="warning"): … … 239 241 # self.load_error(error_message) 240 242 self.parent.add_data(data_list=output) 241 242 243 -
src/sas/sasgui/guiframe/local_perspectives/plotting/AnnulusSlicer.py
rd85c194 r7432acb 122 122 data = self.base.data2D 123 123 # If we have no data, just return 124 if data ==None:124 if data is None: 125 125 return 126 126 … … 132 132 # if the user does not specify the numbers of points to plot 133 133 # the default number will be nbins= 36 134 if nbins ==None:134 if nbins is None: 135 135 self.nbins = 36 136 136 else: … … 498 498 # Update locations 499 499 self.outer_circle.update() 500 # if self.is_inside !=None:500 # if self.is_inside is not None: 501 501 out = self._post_data() 502 502 return out … … 521 521 522 522 # If we have no data, just return 523 if data ==None:523 if data is None: 524 524 return 525 525 mask = data.mask -
src/sas/sasgui/guiframe/local_perspectives/plotting/Arc.py
rd85c194 r7432acb 71 71 x = [] 72 72 y = [] 73 if theta1 !=None:73 if theta1 is not None: 74 74 self.theta1 = theta1 75 if theta2 !=None:75 if theta2 is not None: 76 76 self.theta2 = theta2 77 77 while self.theta2 < self.theta1: … … 81 81 npts = int((self.theta2 - self.theta1) / (math.pi / 120)) 82 82 83 if r ==None:83 if r is None: 84 84 self.radius = math.sqrt(math.pow(self._mouse_x, 2) + \ 85 85 math.pow(self._mouse_y, 2)) -
src/sas/sasgui/guiframe/local_perspectives/plotting/Edge.py
rd85c194 r7432acb 63 63 Draw the new roughness on the graph. 64 64 """ 65 if r1 !=None:65 if r1 is not None: 66 66 self.r1 = r1 67 if r2 !=None:67 if r2 is not None: 68 68 self.r2 = r2 69 if theta !=None:69 if theta is not None: 70 70 self.theta = theta 71 71 x1 = self.r1 * math.cos(self.theta) -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py
rd85c194 r7432acb 14 14 import sys 15 15 import math 16 import numpy 16 import numpy as np 17 17 import logging 18 18 from sas.sasgui.plottools.PlotPanel import PlotPanel … … 24 24 from appearanceDialog import appearanceDialog 25 25 from graphAppearance import graphAppearance 26 27 logger = logging.getLogger(__name__) 26 28 27 29 DEFAULT_QMAX = 0.05 … … 65 67 # context menu 66 68 self._slicerpop = None 67 68 69 self._available_data = [] 69 70 self._symbol_labels = self.get_symbol_label() … … 95 96 self.parent.SetFocus() 96 97 98 # If true, there are 3 qrange bars 99 self.is_corfunc = False 100 97 101 98 102 def get_symbol_label(self): … … 179 183 # So manually recode the size (=x_size) and compare here. 180 184 # Massy code to work around:< 181 if self.parent._mgr !=None:185 if self.parent._mgr is not None: 182 186 max_panel = self.parent._mgr.GetPane(self) 183 187 if max_panel.IsMaximized(): 184 188 self.parent._mgr.RestorePane(max_panel) 185 189 max_panel.Maximize() 186 if self.x_size !=None:190 if self.x_size is not None: 187 191 if self.x_size == self.GetSize(): 188 192 self.resizing = False … … 208 212 On Qmin Qmax vertical line event 209 213 """ 210 if event ==None:214 if event is None: 211 215 return 212 216 event.Skip() 213 217 active_ctrl = event.active 214 if active_ctrl ==None:218 if active_ctrl is None: 215 219 return 220 if hasattr(event, 'is_corfunc'): 221 self.is_corfunc = event.is_corfunc 216 222 if event.id in self.plots.keys(): 217 223 ctrl = event.ctrl … … 222 228 values = [max(x_data.min(), float(ctrl[0].GetValue())), 223 229 min(x_data.max(), float(ctrl[1].GetValue()))] 224 if self.ly == None: 230 if len(ctrl) == 3: 231 colors.append('purple') 232 values.append(min(x_data.max(), float(ctrl[2].GetValue()))) 233 if self.ly is None: 225 234 self.ly = [] 226 235 for c, v in zip(colors, values): … … 232 241 xval = float(active_ctrl.GetValue()) 233 242 position = self.get_data_xy_vals(xval) 234 if position != None:243 if position is not None and not self.is_corfunc: 235 244 wx.PostEvent(self.parent, StatusEvent(status=position)) 236 245 except: 237 logg ing.error(sys.exc_value)246 logger.error(sys.exc_value) 238 247 if not event.leftdown: 239 248 # text event … … 248 257 self.canvas.draw() 249 258 except: 250 logg ing.error(sys.exc_value)259 logger.error(sys.exc_value) 251 260 event.Skip() 252 261 return … … 281 290 :Param value: float 282 291 """ 283 idx = (n umpy.abs(array - value)).argmin()292 idx = (np.abs(array - value)).argmin() 284 293 return int(idx) # array.flat[idx] 285 294 … … 293 302 ly0x = ly[0].get_xdata() 294 303 ly1x = ly[1].get_xdata() 304 ly2x = None 305 if self.is_corfunc: ly2x = ly[2].get_xdata() 295 306 self.q_ctrl[0].SetBackgroundColour('white') 296 307 self.q_ctrl[1].SetBackgroundColour('white') … … 306 317 self.q_ctrl[0].SetValue(str(pos_x)) 307 318 self.q_ctrl[1].SetBackgroundColour('pink') 319 elif ly2x is not None and ly1x >= ly2x: 320 if self.vl_ind == 1: 321 ly[2].set_xdata(posx) 322 ly[2].set_zorder(nop) 323 self.q_ctrl[2].SetValue(str(pos_x)) 324 elif self.vl_ind == 2: 325 ly[1].set_xdata(posx) 326 ly[1].set_zorder(nop) 327 self.q_ctrl[1].SetValue(str(pos_x)) 328 308 329 309 330 def _get_cusor_lines(self, event): … … 315 336 if hasattr(event, "action"): 316 337 dclick = event.action == 'dclick' 317 if ax ==None or dclick:338 if ax is None or dclick: 318 339 # remove the vline 319 340 self._check_zoom_plot() … … 321 342 self.q_ctrl = None 322 343 return 323 if self.ly != None and event.xdata !=None:344 if self.ly is not None and event.xdata is not None: 324 345 # Selecting a new line if cursor lines are displayed already 325 346 dqmin = math.fabs(event.xdata - self.ly[0].get_xdata()) 326 347 dqmax = math.fabs(event.xdata - self.ly[1].get_xdata()) 327 is_qmax = dqmin > dqmax 328 if is_qmax: 329 self.vl_ind = 1 348 if not self.is_corfunc: 349 is_qmax = dqmin > dqmax 350 if is_qmax: 351 self.vl_ind = 1 352 else: 353 self.vl_ind = 0 330 354 else: 331 self.vl_ind = 0 355 dqmax2 = math.fabs(event.xdata - self.ly[2].get_xdata()) 356 closest = min(dqmin, dqmax, dqmax2) 357 self.vl_ind = { dqmin: 0, dqmax: 1, dqmax2: 2 }.get(closest) 332 358 333 359 def cusor_line(self, event): … … 335 361 Move the cursor line to write Q range 336 362 """ 337 if self.q_ctrl ==None:363 if self.q_ctrl is None: 338 364 return 339 365 # release a q range vline 340 if self.ly !=None and not self.leftdown:366 if self.ly is not None and not self.leftdown: 341 367 for ly in self.ly: 342 368 ly.set_alpha(0.7) … … 344 370 return 345 371 ax = event.inaxes 346 if ax ==None or not hasattr(event, 'action'):372 if ax is None or not hasattr(event, 'action'): 347 373 return 348 end_drag = event.action != 'drag' and event.xdata !=None374 end_drag = event.action != 'drag' and event.xdata is not None 349 375 nop = len(self.plots) 350 376 pos_x, _ = float(event.xdata), float(event.ydata) … … 385 411 self.q_ctrl[vl_ind].SetValue(str(pos_x)) 386 412 except: 387 logg ing.error(sys.exc_value)413 logger.error(sys.exc_value) 388 414 389 415 def set_resizing(self, resizing=False): … … 488 514 ax = event.inaxes 489 515 PlotPanel.onLeftDown(self, event) 490 if ax !=None:516 if ax is not None: 491 517 try: 492 518 pos_x = float(event.xdata) # / size_x … … 527 553 self.subplot.set_xlim((xlo, xhi)) 528 554 self.subplot.set_ylim((ylo, yhi)) 555 self.graph.selected_plottable = None 529 556 530 557 … … 555 582 self._slicerpop.set_graph(self.graph) 556 583 ids = iter(self._menu_ids) 557 if not self.graph.selected_plottable in self.plots: 558 559 560 561 562 563 564 565 566 567 568 569 570 571 584 585 # Various plot options 586 wx_id = ids.next() 587 self._slicerpop.Append(wx_id, '&Save Image', 'Save image as PNG') 588 wx.EVT_MENU(self, wx_id, self.onSaveImage) 589 wx_id = ids.next() 590 self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 591 wx.EVT_MENU(self, wx_id, self.onPrint) 592 593 wx_id = ids.next() 594 self._slicerpop.Append(wx_id, '&Copy to Clipboard', 595 'Copy to the clipboard') 596 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 597 598 self._slicerpop.AppendSeparator() 572 599 573 600 for plot in self.plots.values(): … … 591 618 # add menu of other plugins 592 619 item_list = self.parent.get_current_context_menu(self) 593 if (not item_list == None) and (not len(item_list) == 0): 594 # Note: reusing menu ids in submenu. This code works because 595 # IdItems is set up as a lazy iterator returning each id in 596 # sequence, creating new ids as needed so it never runs out. 597 # zip() is set up to stop when any iterator is empty, so it 598 # only asks for the number of ids in item_list. 599 for item, wx_id in zip(item_list, self._menu_ids): 600 620 if (item_list is not None) and (len(item_list)): 621 for item, wx_id in zip(item_list, [ids.next() for i in range(len(item_list))]): 601 622 try: 602 623 plot_menu.Append(wx_id, item[0], name) … … 609 630 610 631 if self.parent.ClassName.count('wxDialog') == 0: 611 wx_id = ids.next() 612 plot_menu.Append(wx_id, '&Linear Fit', name) 613 wx.EVT_MENU(self, wx_id, self.onFitting) 614 plot_menu.AppendSeparator() 632 if plot.id != 'fit': 633 wx_id = ids.next() 634 plot_menu.Append(wx_id, '&Linear Fit', name) 635 wx.EVT_MENU(self, wx_id, self.onFitting) 636 plot_menu.AppendSeparator() 615 637 616 638 wx_id = ids.next() … … 646 668 # Option to hide 647 669 # TODO: implement functionality to hide a plottable (legend click) 648 if not self.graph.selected_plottable in self.plots: 670 671 self._slicerpop.AppendSeparator() 672 loc_menu = wx.Menu() 673 for label in self._loc_labels: 674 wx_id = ids.next() 675 loc_menu.Append(wx_id, str(label), str(label)) 676 wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 677 678 wx_id = ids.next() 679 self._slicerpop.Append(wx_id, '&Modify Graph Appearance', 680 'Modify graph appearance') 681 wx.EVT_MENU(self, wx_id, self.modifyGraphAppearance) 682 self._slicerpop.AppendSeparator() 683 684 685 if self.position is not None: 686 wx_id = ids.next() 687 self._slicerpop.Append(wx_id, '&Add Text') 688 wx.EVT_MENU(self, wx_id, self._on_addtext) 689 wx_id = ids.next() 690 self._slicerpop.Append(wx_id, '&Remove Text') 691 wx.EVT_MENU(self, wx_id, self._on_removetext) 649 692 self._slicerpop.AppendSeparator() 650 loc_menu = wx.Menu() 651 for label in self._loc_labels: 652 wx_id = ids.next() 653 loc_menu.Append(wx_id, str(label), str(label)) 654 wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 655 656 wx_id = ids.next() 657 self._slicerpop.Append(wx_id, '&Modify Graph Appearance', 658 'Modify graph appearance') 659 wx.EVT_MENU(self, wx_id, self.modifyGraphAppearance) 660 self._slicerpop.AppendSeparator() 661 662 663 if self.position != None: 664 wx_id = ids.next() 665 self._slicerpop.Append(wx_id, '&Add Text') 666 wx.EVT_MENU(self, wx_id, self._on_addtext) 667 wx_id = ids.next() 668 self._slicerpop.Append(wx_id, '&Remove Text') 669 wx.EVT_MENU(self, wx_id, self._on_removetext) 670 self._slicerpop.AppendSeparator() 671 wx_id = ids.next() 672 self._slicerpop.Append(wx_id, '&Change Scale') 673 wx.EVT_MENU(self, wx_id, self._onProperties) 693 wx_id = ids.next() 694 self._slicerpop.Append(wx_id, '&Change Scale') 695 wx.EVT_MENU(self, wx_id, self._onProperties) 696 self._slicerpop.AppendSeparator() 697 wx_id = ids.next() 698 self._slicerpop.Append(wx_id, '&Set Graph Range') 699 wx.EVT_MENU(self, wx_id, self.onSetRange) 700 wx_id = ids.next() 701 self._slicerpop.Append(wx_id, '&Reset Graph Range') 702 wx.EVT_MENU(self, wx_id, self.onResetGraph) 703 704 if self.parent.ClassName.count('wxDialog') == 0: 674 705 self._slicerpop.AppendSeparator() 675 706 wx_id = ids.next() 676 self._slicerpop.Append(wx_id, '&Reset Graph Range') 677 wx.EVT_MENU(self, wx_id, self.onResetGraph) 678 679 if self.parent.ClassName.count('wxDialog') == 0: 680 self._slicerpop.AppendSeparator() 681 wx_id = ids.next() 682 self._slicerpop.Append(wx_id, '&Window Title') 683 wx.EVT_MENU(self, wx_id, self.onChangeCaption) 707 self._slicerpop.Append(wx_id, '&Window Title') 708 wx.EVT_MENU(self, wx_id, self.onChangeCaption) 684 709 try: 685 710 pos_evt = event.GetPosition() … … 689 714 pos = (pos_x, pos_y + 5) 690 715 self.PopupMenu(self._slicerpop, pos) 716 717 def onSetRange(self, event): 718 # Display dialog 719 # self.subplot.set_xlim((low, high)) 720 # self.subplot.set_ylim((low, high)) 721 from sas.sasgui.plottools.RangeDialog import RangeDialog 722 d = RangeDialog(self, -1) 723 xlim = self.subplot.get_xlim() 724 ylim = self.subplot.get_ylim() 725 d.SetXRange(xlim) 726 d.SetYRange(ylim) 727 if d.ShowModal() == wx.ID_OK: 728 x_range = d.GetXRange() 729 y_range = d.GetYRange() 730 if x_range is not None and y_range is not None: 731 self.subplot.set_xlim(x_range) 732 self.subplot.set_ylim(y_range) 733 self.subplot.figure.canvas.draw_idle() 734 self.is_zoomed = True 735 d.Destroy() 691 736 692 737 def onFreeze(self, event): … … 715 760 default_name = default_name.split('.')[0] 716 761 default_name += "_out" 717 if self.parent !=None:762 if self.parent is not None: 718 763 self.parent.save_data1d(data, default_name) 719 764 … … 733 778 default_name = default_name.split('.')[0] 734 779 # default_name += "_out" 735 if self.parent !=None:780 if self.parent is not None: 736 781 self.parent.show_data1d(data, default_name) 737 782 … … 765 810 curr_label = self.appearance_selected_plot.label 766 811 767 if curr_color ==None:812 if curr_color is None: 768 813 curr_color = self._color_labels['Blue'] 769 814 curr_symbol = 13 … … 776 821 int(curr_symbol))), curr_label) 777 822 self.appD.Bind(wx.EVT_CLOSE, self.on_AppDialog_close) 823 self.graph.selected_plottable = None 778 824 779 825 def on_AppDialog_close(self, event): -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py
rd85c194 r7432acb 14 14 import sys 15 15 import math 16 import numpy 16 import numpy as np 17 17 import logging 18 18 from sas.sasgui.plottools.PlotPanel import PlotPanel … … 30 30 from graphAppearance import graphAppearance 31 31 (InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() 32 33 logger = logging.getLogger(__name__) 32 34 33 35 DEFAULT_QMAX = 0.05 … … 142 144 """ 143 145 # Not implemented 144 if event ==None:146 if event is None: 145 147 return 146 148 event.Skip() … … 154 156 PlotPanel.onLeftDown(self, event) 155 157 ax = event.inaxes 156 if ax !=None:158 if ax is not None: 157 159 # data coordinate position 158 160 pos_x = "%8.3g" % event.xdata … … 225 227 if self._is_changed_legend_label: 226 228 data.label = self.title_label 227 if data.label ==None:229 if data.label is None: 228 230 data.label = data.name 229 231 if not self.title_font: … … 262 264 # control axis labels from the panel itself 263 265 yname, yunits = data.get_yaxis() 264 if self.yaxis_label !=None:266 if self.yaxis_label is not None: 265 267 yname = self.yaxis_label 266 268 yunits = self.yaxis_unit … … 269 271 self.yaxis_unit = yunits 270 272 xname, xunits = data.get_xaxis() 271 if self.xaxis_label !=None:273 if self.xaxis_label is not None: 272 274 xname = self.xaxis_label 273 275 xunits = self.xaxis_unit … … 293 295 294 296 wx_id = ids.next() 295 slicerpop.Append(wx_id, '&Save Image' )297 slicerpop.Append(wx_id, '&Save Image', 'Save image as png') 296 298 wx.EVT_MENU(self, wx_id, self.onSaveImage) 297 299 … … 316 318 317 319 slicerpop.AppendSeparator() 318 if len(self.data2D.detector) == 1:320 if len(self.data2D.detector) <= 1: 319 321 item_list = self.parent.get_current_context_menu(self) 320 if (not item_list == None) and (not len(item_list) == 0) and\ 321 self.data2D.name.split(" ")[0] != 'Residuals': 322 # The line above; Not for trunk 323 # Note: reusing menu ids for the sub-menus. See Plotter1D. 324 for item, wx_id in zip(item_list, self._menu_ids): 322 if ((item_list is not None) and len(item_list) and 323 self.data2D.name.split(" ")[0] != 'Residuals'): 324 for item, wx_id in zip(item_list, [ids.next() for i in range(len(item_list))]): 325 325 try: 326 326 slicerpop.Append(wx_id, item[0], item[1]) … … 355 355 slicerpop.Append(wx_id, '&Box Averaging in Qy') 356 356 wx.EVT_MENU(self, wx_id, self.onBoxavgY) 357 if self.slicer !=None:357 if self.slicer is not None: 358 358 wx_id = ids.next() 359 359 slicerpop.Append(wx_id, '&Clear Slicer') … … 434 434 except: 435 435 msg = "Add Text: Error. Check your property values..." 436 logg ing.error(msg)437 if self.parent !=None:436 logger.error(msg) 437 if self.parent is not None: 438 438 wx.PostEvent(self.parent, StatusEvent(status=msg)) 439 439 dial.Destroy() … … 533 533 """ 534 534 ## Clear current slicer 535 if not self.slicer ==None:535 if self.slicer is not None: 536 536 self.slicer.clear() 537 537 ## Create a new slicer … … 569 569 """ 570 570 # Find the best number of bins 571 npt = math.sqrt(len(self.data2D.data[n umpy.isfinite(self.data2D.data)]))571 npt = math.sqrt(len(self.data2D.data[np.isfinite(self.data2D.data)])) 572 572 npt = math.floor(npt) 573 573 from sas.sascalc.dataloader.manipulations import CircularAverage … … 629 629 630 630 """ 631 if self.slicer !=None:631 if self.slicer is not None: 632 632 from SlicerParameters import SlicerParameterPanel 633 633 dialog = SlicerParameterPanel(self, -1, "Slicer Parameters") … … 719 719 Clear the slicer on the plot 720 720 """ 721 if not self.slicer ==None:721 if self.slicer is not None: 722 722 self.slicer.clear() 723 723 self.subplot.figure.canvas.draw() … … 735 735 """ 736 736 event_id = str(evt.GetId()) 737 if self.parent !=None:737 if self.parent is not None: 738 738 self._default_save_location = self.parent._default_save_location 739 739 default_name = self.plots[self.graph.selected_plottable].label … … 759 759 default_name = default_name.split('.')[0] 760 760 #default_name += "_out" 761 if self.parent !=None:761 if self.parent is not None: 762 762 self.parent.show_data2d(data, default_name) 763 763 -
src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py
rd85c194 r7432acb 144 144 data = self.base.data2D 145 145 # If we have no data, just return 146 if data ==None:146 if data is None: 147 147 return 148 148 ## Averaging … … 151 151 phimin = -self.left_line.phi + self.main_line.theta 152 152 phimax = self.left_line.phi + self.main_line.theta 153 if nbins ==None:153 if nbins is None: 154 154 nbins = 20 155 155 sect = SectorQ(r_min=0.0, r_max=radius, … … 362 362 self.left_moving = left 363 363 theta3 = 0 364 if phi !=None:364 if phi is not None: 365 365 self.phi = phi 366 if delta ==None:366 if delta is None: 367 367 delta = 0 368 368 if right: … … 374 374 self.theta = mline.theta + self.phi 375 375 376 if mline !=None:376 if mline is not None: 377 377 if delta != 0: 378 378 self.theta2 = mline + delta … … 538 538 """ 539 539 540 if theta !=None:540 if theta is not None: 541 541 self.theta = theta 542 542 x1 = self.radius * math.cos(self.theta) -
src/sas/sasgui/guiframe/local_perspectives/plotting/SimplePlot.py
rd85c194 r7432acb 87 87 pos = (pos_x, pos_y + 5) 88 88 self.PopupMenu(slicerpop, pos) 89 if self.scale !=None:89 if self.scale is not None: 90 90 self.parent.scale2d = self.scale 91 91 … … 106 106 self.leftdown = True 107 107 ax = event.inaxes 108 if ax !=None:108 if ax is not None: 109 109 self.xInit, self.yInit = event.xdata, event.ydata 110 110 try: … … 123 123 """ 124 124 self.resizing = False 125 if self.x_size !=None:125 if self.x_size is not None: 126 126 if self.x_size == self.GetSize(): 127 127 self.canvas.set_resizing(self.resizing) … … 161 161 self.plots[plot.name] = plot 162 162 # Axis scales 163 if plot.xtransform !=None:163 if plot.xtransform is not None: 164 164 self.xLabel = plot.xtransform 165 if plot.ytransform !=None:165 if plot.ytransform is not None: 166 166 self.yLabel = plot.ytransform 167 167 # Init graph … … 188 188 """ 189 189 def __init__(self, parent, id, title, scale='log_{10}', 190 size=wx.Size(550, 470) ):190 size=wx.Size(550, 470), show_menu_icons=True): 191 191 """ 192 192 comment … … 202 202 self._default_save_location = None 203 203 self.scale = scale 204 self._show_menu_icons = show_menu_icons 204 205 self.plotpanel = SimplePlotPanel(self, -1) 205 206 self._build_menubar() … … 213 214 quit_bmp = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, tsize) 214 215 print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR, tsize) 215 preview_bmp = wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_TOOLBAR, tsize)216 216 copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR, tsize) 217 217 menu_bar = wx.MenuBar() … … 219 219 menu = wx.Menu() 220 220 id = wx.NewId() 221 item = wx.MenuItem(menu, id, "&Save Image") 222 item.SetBitmap(save_bmp) 223 menu.AppendItem(item) 221 save_item = wx.MenuItem(menu, id, "&Save Image") 222 menu.AppendItem(save_item) 224 223 wx.EVT_MENU(self, id, self.on_save_file) 225 224 226 225 id = wx.NewId() 227 item = wx.MenuItem(menu, id, "&Print Image") 228 item.SetBitmap(print_bmp) 229 menu.AppendItem(item) 226 print_item = wx.MenuItem(menu, id, "&Print Image") 227 menu.AppendItem(print_item) 230 228 wx.EVT_MENU(self, id, self.on_print_image) 231 229 232 230 menu.AppendSeparator() 233 231 id = wx.NewId() 234 item = wx.MenuItem(menu, id, "&Quit") 235 item.SetBitmap(quit_bmp) 236 menu.AppendItem(item) 232 quit_item = wx.MenuItem(menu, id, "&Quit") 233 menu.AppendItem(quit_item) 237 234 238 235 menu_bar.Append(menu, "&File") … … 241 238 menu_edit = wx.Menu() 242 239 id = wx.NewId() 243 item = wx.MenuItem(menu_edit, id, "&Copy") 244 item.SetBitmap(copy_bmp) 245 menu_edit.AppendItem(item) 240 copy_item = wx.MenuItem(menu_edit, id, "&Copy") 241 menu_edit.AppendItem(copy_item) 246 242 wx.EVT_MENU(self, id, self.on_copy_image) 243 244 if self._show_menu_icons: 245 save_item.SetBitmap(save_bmp) 246 print_item.SetBitmap(print_bmp) 247 quit_item.SetBitmap(quit_bmp) 248 copy_item.SetBitmap(copy_bmp) 247 249 248 250 menu_bar.Append(menu_edit, "&Edit") … … 324 326 except: 325 327 self.Destroy() 326 -
src/sas/sasgui/guiframe/local_perspectives/plotting/SlicerParameters.py
rd85c194 r235f514 46 46 """ 47 47 event.Skip() 48 if event.obj_class ==None:48 if event.obj_class is None: 49 49 self.set_slicer(None, None) 50 50 else: … … 57 57 self.bck.Clear(True) 58 58 self.type = type 59 if type ==None:59 if type is None: 60 60 label = "Right-click on 2D plot for slicer options" 61 61 title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) -
src/sas/sasgui/guiframe/local_perspectives/plotting/binder.py
rd85c194 r463e7ffc 4 4 import logging 5 5 import sys 6 7 logger = logging.getLogger(__name__) 6 8 7 9 class Selection(object): … … 70 72 canvas.mpl_disconnect(canvas.scroll_pick_id) 71 73 except: 72 logg ing.error(sys.exc_value)74 logger.error(sys.exc_value) 73 75 self.canvas = canvas 74 76 self.figure = figure -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxMask.py
rd85c194 r7432acb 123 123 x2=self.vertical_lines.x2, 124 124 width=self.vertical_lines.half_width) 125 # if self.is_inside !=None:125 # if self.is_inside is not None: 126 126 out = self._post_data() 127 127 return out -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxSlicer.py
rd85c194 r7432acb 1 1 import wx 2 2 import math 3 import numpy 3 import numpy as np 4 4 from sas.sasgui.guiframe.events import NewPlotEvent 5 5 from sas.sasgui.guiframe.events import StatusEvent … … 139 139 140 140 """ 141 if self.direction ==None:141 if self.direction is None: 142 142 self.direction = direction 143 143 … … 147 147 y_max = math.fabs(self.horizontal_lines.y) 148 148 149 if nbins !=None:149 if nbins is not None: 150 150 self.nbins = nbins 151 if self.averager ==None:152 if new_slab ==None:151 if self.averager is None: 152 if new_slab is None: 153 153 msg = "post data:cannot average , averager is empty" 154 154 raise ValueError, msg … … 357 357 """ 358 358 # # Reset x, y- coordinates if send as parameters 359 if x !=None:360 self.x = n umpy.sign(self.x) * math.fabs(x)361 if y !=None:362 self.y = n umpy.sign(self.y) * math.fabs(y)359 if x is not None: 360 self.x = np.sign(self.x) * math.fabs(x) 361 if y is not None: 362 self.y = np.sign(self.y) * math.fabs(y) 363 363 # # Draw lines and markers 364 364 self.inner_marker.set(xdata=[0], ydata=[self.y]) … … 464 464 """ 465 465 # # reset x, y -coordinates if given as parameters 466 if x !=None:467 self.x = n umpy.sign(self.x) * math.fabs(x)468 if y !=None:469 self.y = n umpy.sign(self.y) * math.fabs(y)466 if x is not None: 467 self.x = np.sign(self.x) * math.fabs(x) 468 if y is not None: 469 self.y = np.sign(self.y) * math.fabs(y) 470 470 # # draw lines and markers 471 471 self.inner_marker.set(xdata=[self.x], ydata=[0]) -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxSum.py
rd85c194 r7432acb 353 353 Draw the new roughness on the graph. 354 354 """ 355 if center_x !=None:355 if center_x is not None: 356 356 self.x = center_x 357 if center_y !=None:357 if center_y is not None: 358 358 self.y = center_y 359 359 self.center_marker.set(xdata=[self.x], ydata=[self.y]) … … 490 490 """ 491 491 # # save the new height, witdh of the rectangle if given as a param 492 if width !=None:492 if width is not None: 493 493 self.half_width = width 494 if height !=None:494 if height is not None: 495 495 self.half_height = height 496 496 # # If new center coordinates are given draw the rectangle 497 497 # #given these value 498 if center !=None:498 if center is not None: 499 499 self.center_x = center.x 500 500 self.center_y = center.y … … 511 511 return 512 512 # # if x1, y1, y2, y3 are given draw the rectangle with this value 513 if x1 !=None:513 if x1 is not None: 514 514 self.x1 = x1 515 if x2 !=None:515 if x2 is not None: 516 516 self.x2 = x2 517 if y1 !=None:517 if y1 is not None: 518 518 self.y1 = y1 519 if y2 !=None:519 if y2 is not None: 520 520 self.y2 = y2 521 521 # # Draw 2 vertical lines and a marker … … 657 657 """ 658 658 # # save the new height, witdh of the rectangle if given as a param 659 if width !=None:659 if width is not None: 660 660 self.half_width = width 661 if height !=None:661 if height is not None: 662 662 self.half_height = height 663 663 # # If new center coordinates are given draw the rectangle 664 664 # #given these value 665 if center !=None:665 if center is not None: 666 666 self.center_x = center.x 667 667 self.center_y = center.y … … 679 679 return 680 680 # # if x1, y1, y2, y3 are given draw the rectangle with this value 681 if x1 !=None:681 if x1 is not None: 682 682 self.x1 = x1 683 if x2 !=None:683 if x2 is not None: 684 684 self.x2 = x2 685 if y1 !=None:685 if y1 is not None: 686 686 self.y1 = y1 687 if y2 !=None:687 if y2 is not None: 688 688 self.y2 = y2 689 689 # # Draw 2 vertical lines and a marker -
src/sas/sasgui/guiframe/local_perspectives/plotting/detector_dialog.py
rd85c194 r7432acb 7 7 from sas.sasgui.guiframe.events import StatusEvent 8 8 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas 9 from matplotlib importmpl9 import matplotlib as mpl 10 10 from matplotlib import pylab 11 11 # FONT size … … 90 90 zmin = self.reset_zmin_ctl 91 91 zmax = self.reset_zmax_ctl 92 if zmin ==None:92 if zmin is None: 93 93 zmin = "" 94 if zmax ==None:94 if zmax is None: 95 95 zmax = "" 96 96 self.zmin_ctl.SetValue(str(zmin)) … … 155 155 self.qmax_ctl.SetLabel(str(format_number(qmax))) 156 156 self.beam_ctl.SetLabel(str(format_number(beam))) 157 if zmin !=None:157 if zmin is not None: 158 158 self.zmin_ctl.SetValue(str(format_number(zmin))) 159 if zmax !=None:159 if zmax is not None: 160 160 self.zmax_ctl.SetValue(str(format_number(zmax))) 161 161 -
src/sas/sasgui/guiframe/local_perspectives/plotting/masking.py
rd85c194 r45dffa69 24 24 import math 25 25 import copy 26 import numpy 26 import numpy as np 27 27 from sas.sasgui.plottools.PlotPanel import PlotPanel 28 28 from sas.sasgui.plottools.plottables import Graph … … 100 100 wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 101 101 102 if data !=None:102 if data is not None: 103 103 # Font size 104 104 kwds = [] … … 235 235 event.Skip() 236 236 # from boxMask import BoxMask 237 if event !=None:237 if event is not None: 238 238 self._on_clear_slicer(event) 239 239 self.slicer_z += 1 … … 249 249 Add new mask to old mask 250 250 """ 251 if not self.slicer ==None:251 if self.slicer is not None: 252 252 data = Data2D() 253 253 data = self.data … … 269 269 Erase new mask from old mask 270 270 """ 271 if not self.slicer ==None:271 if self.slicer is not None: 272 272 self.slicer_mask = self.slicer.update() 273 273 mask = self.data.mask … … 298 298 self.subplot.set_ylim(self.data.ymin, self.data.ymax) 299 299 self.subplot.set_xlim(self.data.xmin, self.data.xmax) 300 mask = n umpy.ones(len(self.data.mask), dtype=bool)300 mask = np.ones(len(self.data.mask), dtype=bool) 301 301 self.data.mask = mask 302 302 # update mask plot … … 307 307 Clear the slicer on the plot 308 308 """ 309 if not self.slicer ==None:309 if self.slicer is not None: 310 310 self.slicer.clear() 311 311 self.subplot.figure.canvas.draw() … … 336 336 """ 337 337 # the case of liitle numbers of True points 338 if len(mask[mask]) < 10 and self.data !=None:338 if len(mask[mask]) < 10 and self.data is not None: 339 339 self.ShowMessage() 340 340 mask = copy.deepcopy(self.mask) … … 343 343 self.mask = mask 344 344 # make temperary data to plot 345 temp_mask = n umpy.zeros(len(mask))345 temp_mask = np.zeros(len(mask)) 346 346 temp_data = copy.deepcopy(self.data) 347 347 # temp_data default is None … … 355 355 temp_data.data[mask == False] = temp_mask[mask == False] 356 356 self.plotpanel.clear() 357 if self.slicer !=None:357 if self.slicer is not None: 358 358 self.slicer.clear() 359 359 self.slicer = None … … 460 460 wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 461 461 462 if data !=None:462 if data is not None: 463 463 # Font size 464 464 kwds = [] … … 710 710 Status msg 711 711 """ 712 if self.parent.parent.parent !=None:712 if self.parent.parent.parent is not None: 713 713 wx.PostEvent(self.parent.parent.parent, 714 714 StatusEvent(status=msg, type=type)) -
src/sas/sasgui/guiframe/local_perspectives/plotting/plotting.py
rd85c194 r235f514 16 16 from sas.sasgui.guiframe.events import EVT_NEW_PLOT 17 17 from sas.sasgui.guiframe.events import EVT_PLOT_QRANGE 18 from sas.sasgui.guiframe.events import EVT_PLOT_LIM 18 19 from sas.sasgui.guiframe.events import DeletePlotPanelEvent 19 20 from sas.sasgui.guiframe.plugin_base import PluginBase … … 79 80 self.parent.Bind(EVT_NEW_PLOT, self._on_plot_event) 80 81 self.parent.Bind(EVT_PLOT_QRANGE, self._on_plot_qrange) 82 self.parent.Bind(EVT_PLOT_LIM, self._on_plot_lim) 81 83 # We have no initial panels for this plug-in 82 84 return [] … … 86 88 On Qmin Qmax vertical line event 87 89 """ 88 if event ==None:90 if event is None: 89 91 return 90 92 if event.id in self.plot_panels.keys(): … … 96 98 panel.on_plot_qrange(event) 97 99 100 def _on_plot_lim(self, event=None): 101 if event is None: 102 return 103 if event.id in self.plot_panels.keys(): 104 panel = self.plot_panels[event.id] 105 elif event.group_id in self.plot_panels.keys(): 106 panel = self.plot_panels[event.group_id] 107 else: 108 return 109 if hasattr(event, 'xlim'): 110 panel.subplot.set_xlim(event.xlim) 111 if hasattr(event, 'ylim'): 112 panel.subplot.set_ylim(event.ylim) 113 114 98 115 def _on_show_panel(self, event): 99 116 """show plug-in panel""" … … 117 134 """ 118 135 for group_id in self.plot_panels.keys(): 119 panel = self.plot_panels[group_id] 120 panel.graph.reset() 121 self.hide_panel(group_id) 136 self.clear_panel_by_id(group_id) 122 137 self.plot_panels = {} 123 138 … … 312 327 new_panel = self.create_2d_panel(data, group_id) 313 328 self.create_panel_helper(new_panel, data, group_id, title) 329 if hasattr(event, 'xlim'): 330 new_panel.subplot.set_xlim(event.xlim) 331 if hasattr(event, 'ylim'): 332 new_panel.subplot.set_ylim(event.ylim) 314 333 return -
src/sas/sasgui/guiframe/local_perspectives/plotting/profile_dialog.py
rd85c194 r7432acb 44 44 wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 45 45 46 if data !=None:46 if data is not None: 47 47 #Font size 48 48 kwds = [] … … 284 284 default_name = default_name.split('.')[0] 285 285 default_name += "_out" 286 if self.parent !=None:286 if self.parent is not None: 287 287 # What an ancestor! 288 288 fit_panel = self.parent.parent.parent -
src/sas/sasgui/guiframe/local_perspectives/plotting/sector_mask.py
rd85c194 r7432acb 96 96 self.left_line.update(phi=self.right_line.phi, delta=None, 97 97 mline=self.main_line, side=True, left=False) 98 #if self.is_inside !=None:98 #if self.is_inside is not None: 99 99 out = self._post_data() 100 100 return out … … 117 117 data = self.base.data 118 118 # If we have no data, just return 119 if data ==None:119 if data is None: 120 120 return 121 121 ## Averaging -
src/sas/sasgui/guiframe/local_perspectives/plotting/slicerpanel.py
rd85c194 r7432acb 37 37 self.bck = wx.GridBagSizer(5, 5) 38 38 self.SetSizer(self.bck) 39 if type == None and params ==None:39 if type is None and params is None: 40 40 label = "Right-click on 2D plot for slicer options" 41 41 title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) … … 57 57 """ 58 58 event.Skip() 59 if event.obj_class ==None:59 if event.obj_class is None: 60 60 self.set_slicer(None, None) 61 61 else: … … 68 68 self.bck.Clear(True) 69 69 self.type = type 70 if type ==None:70 if type is None: 71 71 label = "Right-click on 2D plot for slicer options" 72 72 title = wx.StaticText(self, -1, label, style=wx.ALIGN_LEFT) … … 114 114 self.Layout() 115 115 psizer = self.parent.GetSizer() 116 if psizer !=None:116 if psizer is not None: 117 117 psizer.Layout() 118 118
Note: See TracChangeset
for help on using the changeset viewer.