Changeset 82d88d5 in sasview for src/sas/sasgui/guiframe/local_perspectives
- Timestamp:
- Mar 6, 2019 6:18:09 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
- Children:
- f923967
- Parents:
- cb64d86 (diff), f205d3a (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:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
r5251ec6 r82d88d5 205 205 except NoKnownLoaderException as e: 206 206 exception_occurred = True 207 error_message = "Loading data failed! " + e.message207 error_message = "Loading data failed!\n" + e.message 208 208 file_errors[basename] = [error_message] 209 209 except Exception as e: … … 224 224 for message in error_array: 225 225 error_message += message + "\n" 226 error_message = error_message[:-1] 226 227 self.load_complete(output=output, 227 228 message=error_message, … … 231 232 self.load_complete(output=output, message="Loading data complete!", 232 233 info="info") 233 else:234 self.load_complete(output=None, message=error_message, info="error")235 234 236 235 def load_update(self, message="", info="warning"): -
src/sas/sasgui/guiframe/local_perspectives/data_loader/load_thread.py
r959eb01 r5251ec6 72 72 if self.updatefn is not None: 73 73 self.updatefn(output=output, message=message) 74 except :74 except Exception as exc: 75 75 error_message = "Error while loading: %s\n" % str(path) 76 error_message += str( sys.exc_value) + "\n"76 error_message += str(exc) + "\n" 77 77 self.updatefn(output=output, message=error_message) 78 78 -
src/sas/sasgui/guiframe/local_perspectives/plotting/AnnulusSlicer.py
r7432acb r5251ec6 7 7 8 8 import math 9 # from copy import deepcopy 10 9 11 import wx 10 # from copy import deepcopy 11 # Debug printout 12 12 13 from sas.sasgui.guiframe.events import NewPlotEvent 13 14 from sas.sasgui.guiframe.events import StatusEvent 14 15 from sas.sasgui.guiframe.events import SlicerParameterEvent 15 16 from sas.sasgui.guiframe.events import EVT_SLICER_PARS 16 from BaseInteractor import _BaseInteractor17 17 from sas.sasgui.guiframe.dataFitting import Data1D 18 19 from .BaseInteractor import _BaseInteractor 18 20 19 21 class AnnulusInteractor(_BaseInteractor): -
src/sas/sasgui/guiframe/local_perspectives/plotting/Arc.py
r7432acb r5251ec6 4 4 import math 5 5 6 from BaseInteractor import _BaseInteractor7 6 from sas.sasgui.guiframe.events import SlicerParameterEvent 7 8 from .BaseInteractor import _BaseInteractor 8 9 9 10 class ArcInteractor(_BaseInteractor): -
src/sas/sasgui/guiframe/local_perspectives/plotting/AzimutSlicer.py
rd85c194 r5251ec6 5 5 # 6 6 import math 7 7 8 import wx 8 from BaseInteractor import _BaseInteractor 9 9 10 from sas.sasgui.guiframe.events import NewPlotEvent 10 11 from sas.sasgui.guiframe.events import EVT_SLICER_PARS 12 13 from .BaseInteractor import _BaseInteractor 11 14 12 15 class SectorInteractor(_BaseInteractor): … … 29 32 30 33 # Inner circle 31 from Arc import ArcInteractor34 from .Arc import ArcInteractor 32 35 self.inner_circle = ArcInteractor(self, self.base.subplot, 33 36 zorder=zorder, … … 43 46 self.outer_circle.qmax = self.qmax * 1.2 44 47 # self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 45 from Edge import RadiusInteractor48 from .Edge import RadiusInteractor 46 49 self.right_edge = RadiusInteractor(self, self.base.subplot, 47 50 zorder=zorder + 1, -
src/sas/sasgui/guiframe/local_perspectives/plotting/Edge.py
r7432acb r5251ec6 1 1 import math 2 from BaseInteractor import _BaseInteractor 2 3 from .BaseInteractor import _BaseInteractor 3 4 4 5 -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py
r2469df7 r5251ec6 11 11 12 12 13 import wx14 13 import sys 15 14 import math 15 import logging 16 17 import wx 16 18 import numpy as np 17 import logging 19 18 20 from sas.sasgui.plottools.PlotPanel import PlotPanel 19 21 from sas.sasgui.guiframe.events import StatusEvent … … 22 24 from sas.sasgui.guiframe.panel_base import PanelBase 23 25 from sas.sasgui.guiframe.gui_style import GUIFRAME_ICON 24 from appearanceDialog import appearanceDialog 25 from graphAppearance import graphAppearance 26 27 from .appearanceDialog import appearanceDialog 28 from .graphAppearance import graphAppearance 26 29 27 30 logger = logging.getLogger(__name__) … … 36 39 def find_key(dic, val): 37 40 """return the key of dictionary dic given the value""" 38 return [k for k, v in dic.ite ritems() if v == val][0]41 return [k for k, v in dic.items() if v == val][0] 39 42 40 43 class ModelPanel1D(PlotPanel, PanelBase): … … 220 223 if hasattr(event, 'is_corfunc'): 221 224 self.is_corfunc = event.is_corfunc 222 if event.id in self.plots .keys():225 if event.id in self.plots: 223 226 ctrl = event.ctrl 224 227 self.cursor_id = event.id … … 243 246 if position is not None and not self.is_corfunc: 244 247 wx.PostEvent(self.parent, StatusEvent(status=position)) 245 except :246 logger.error( sys.exc_value)248 except Exception as exc: 249 logger.error(exc) 247 250 if not event.leftdown: 248 251 # text event … … 256 259 if is_moved: 257 260 self.canvas.draw() 258 except :259 logger.error( sys.exc_value)261 except Exception as exc: 262 logger.error(exc) 260 263 event.Skip() 261 264 return … … 410 413 self.canvas.draw() 411 414 self.q_ctrl[vl_ind].SetValue(str(pos_x)) 412 except :413 logger.error( sys.exc_value)415 except Exception as exc: 416 logger.error(exc) 414 417 415 418 def set_resizing(self, resizing=False): … … 431 434 Remove data from plot 432 435 """ 433 if id in self.plots .keys():436 if id in self.plots: 434 437 data = self.plots[id] 435 438 self.graph.delete(data) … … 437 440 data_list, theory_list = data_manager.get_by_id(id_list=[id]) 438 441 439 if id in data_list .keys():442 if id in data_list: 440 443 data = data_list[id] 441 if id in theory_list .keys():444 if id in theory_list: 442 445 data = theory_list[id] 443 446 … … 457 460 if data.__class__.__name__ == 'Data2D': 458 461 return 459 plot_keys = self.plots.keys()462 plot_keys = list(self.plots.keys()) 460 463 if data.id in plot_keys: 461 464 # Recover panel prop.s … … 476 479 try: 477 480 self._onEVT_FUNC_PROPERTY() 478 except Exception ,exc:481 except Exception as exc: 479 482 wx.PostEvent(self.parent, 480 483 StatusEvent(status="Plotting Error: %s" % str(exc), info="error")) … … 493 496 # MAC: forcing to plot 2D avg 494 497 self.canvas._onDrawIdle() 495 except Exception ,exc:498 except Exception as exc: 496 499 wx.PostEvent(self.parent, StatusEvent(status=\ 497 500 "Plotting Error: %s" % str(exc), info="error")) … … 567 570 self.set_selected_from_menu(menu, event_id) 568 571 ## Check if there is a selected graph to remove 569 if self.graph.selected_plottable in self.plots .keys():572 if self.graph.selected_plottable in self.plots: 570 573 graph_id = self.graph.selected_plottable 571 574 self.remove_data_by_id(graph_id) … … 603 606 plot_menu = wx.Menu() 604 607 if self.graph.selected_plottable: 605 if not self.graph.selected_plottable in self.plots .keys():608 if not self.graph.selected_plottable in self.plots: 606 609 continue 607 610 if plot != self.plots[self.graph.selected_plottable]: … … 623 626 plot_menu.Append(wx_id, item[0], name) 624 627 wx.EVT_MENU(self, wx_id, item[2]) 625 except :628 except Exception as exc: 626 629 msg = "ModelPanel1D.onContextMenu: " 627 msg += "bad menu item %s" % sys.exc_value630 msg += "bad menu item %s" % exc 628 631 wx.PostEvent(self.parent, StatusEvent(status=msg)) 629 632 plot_menu.AppendSeparator() -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py
r3e5648b r5251ec6 11 11 12 12 13 import wx14 13 import sys 15 14 import math 15 import logging 16 17 import wx 16 18 import numpy as np 17 import logging 19 from matplotlib.font_manager import FontProperties 20 18 21 from sas.sasgui.plottools.PlotPanel import PlotPanel 19 22 from sas.sasgui.plottools.plottables import Graph … … 24 27 from sas.sasgui.guiframe.events import SlicerEvent 25 28 from sas.sasgui.guiframe.utils import PanelMenu 26 from sas.sasgui.guiframe.local_perspectives.plotting.binder import BindArtist 27 from Plotter1D import ModelPanel1D 29 from sas.sasgui.guiframe.local_perspectives.plotting.binder import BindArtist 28 30 from sas.sasgui.plottools.toolbar import NavigationToolBar 29 from matplotlib.font_manager import FontProperties 30 from graphAppearance import graphAppearance 31 32 from .Plotter1D import ModelPanel1D 33 from .graphAppearance import graphAppearance 34 31 35 (InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() 32 36 … … 41 45 def find_key(dic, val): 42 46 """return the key of dictionary dic given the value""" 43 return [k for k, v in dic.ite ritems() if v == val][0]47 return [k for k, v in dic.items() if v == val][0] 44 48 45 49 … … 200 204 ## Update self.data2d with the current plot 201 205 self.data2D = data 202 if data.id in self.plots .keys():206 if data.id in self.plots: 203 207 #replace 204 208 xlo, xhi = self.subplot.get_xlim() … … 326 330 slicerpop.Append(wx_id, item[0], item[1]) 327 331 wx.EVT_MENU(self, wx_id, item[2]) 328 except :332 except Exception as exc: 329 333 msg = "ModelPanel1D.onContextMenu: " 330 msg += "bad menu item %s" % sys.exc_value334 msg += "bad menu item %s" % exc 331 335 wx.PostEvent(self.parent, StatusEvent(status=msg)) 332 336 slicerpop.AppendSeparator() … … 447 451 448 452 """ 449 import detector_dialog453 from . import detector_dialog 450 454 dialog = detector_dialog.DetectorDialog(self, -1, base=self.parent, 451 455 reset_zmin_ctl=self.default_zmin_ctl, … … 630 634 """ 631 635 if self.slicer is not None: 632 from parameters_panel_slicer import SlicerParameterPanel636 from .parameters_panel_slicer import SlicerParameterPanel 633 637 dialog = SlicerParameterPanel(self, -1, "Slicer Parameters") 634 638 dialog.set_slicer(self.slicer.__class__.__name__, … … 641 645 Perform sector averaging on Q and draw sector slicer 642 646 """ 643 from SectorSlicer import SectorInteractor647 from .SectorSlicer import SectorInteractor 644 648 self.onClearSlicer(event) 645 649 wx.PostEvent(self, InternalEvent(slicer=SectorInteractor)) … … 649 653 Perform sector averaging on Phi and draw annulus slicer 650 654 """ 651 from AnnulusSlicer import AnnulusInteractor655 from .AnnulusSlicer import AnnulusInteractor 652 656 self.onClearSlicer(event) 653 657 wx.PostEvent(self, InternalEvent(slicer=AnnulusInteractor)) … … 657 661 """ 658 662 from sas.sasgui.guiframe.gui_manager import MDIFrame 659 from boxSum import BoxSum663 from .boxSum import BoxSum 660 664 self.onClearSlicer(event) 661 665 self.slicer_z += 1 … … 668 672 params = self.slicer.get_params() 669 673 ## Create a new panel to display results of summation of Data2D 670 from parameters_panel_boxsum import SlicerPanel674 from .parameters_panel_boxsum import SlicerPanel 671 675 win = MDIFrame(self.parent, None, 'None', (100, 200)) 672 676 new_panel = SlicerPanel(parent=win, id=-1, … … 699 703 :param event: wx.menu event 700 704 """ 701 from boxSlicer import BoxInteractorX705 from .boxSlicer import BoxInteractorX 702 706 self.onClearSlicer(event) 703 707 wx.PostEvent(self, InternalEvent(slicer=BoxInteractorX)) … … 711 715 712 716 """ 713 from boxSlicer import BoxInteractorY717 from .boxSlicer import BoxInteractorY 714 718 self.onClearSlicer(event) 715 719 wx.PostEvent(self, InternalEvent(slicer=BoxInteractorY)) -
src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py
r8de66b6 r5251ec6 3 3 """ 4 4 import math 5 5 6 import wx 6 from BaseInteractor import _BaseInteractor 7 7 8 from sas.sasgui.guiframe.events import NewPlotEvent 8 9 from sas.sasgui.guiframe.events import StatusEvent … … 10 11 from sas.sasgui.guiframe.events import EVT_SLICER_PARS 11 12 from sas.sasgui.guiframe.dataFitting import Data1D 13 14 from .BaseInteractor import _BaseInteractor 12 15 13 16 … … 238 241 msg = "Phi left and phi right are different" 239 242 msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 240 raise ValueError , msg243 raise ValueError(msg) 241 244 params["Phi [deg]"] = self.main_line.theta * 180 / math.pi 242 245 params["Delta_Phi [deg]"] = math.fabs(self.left_line.phi * 180 / math.pi) -
src/sas/sasgui/guiframe/local_perspectives/plotting/appearanceDialog.py
rd85c194 r5251ec6 153 153 Populate Symbols 154 154 """ 155 self.sorted_symbo_labels = sorted(self.symbo_labels.ite ritems(),155 self.sorted_symbo_labels = sorted(self.symbo_labels.items(), 156 156 key=operator.itemgetter(1)) 157 157 self.sorted_sym_dic = {} … … 166 166 Populate Colors 167 167 """ 168 sortedcolor_labels = sorted(self.color_labels.ite ritems(),168 sortedcolor_labels = sorted(self.color_labels.items(), 169 169 key=operator.itemgetter(1)) 170 170 for color in sortedcolor_labels: … … 197 197 Find key 198 198 """ 199 return [k for k, v in dic.ite ritems() if v == val][0]199 return [k for k, v in dic.items() if v == val][0] 200 200 201 201 def get_current_values(self): -
src/sas/sasgui/guiframe/local_perspectives/plotting/binder.py
r20fa5fe r5251ec6 2 2 Extension to MPL to support the binding of artists to key/mouse events. 3 3 """ 4 from __future__ import print_function 5 6 import sys 4 7 import logging 5 import sys6 8 7 9 logger = logging.getLogger(__name__) … … 16 18 artist = None 17 19 prop = {} 20 18 21 def __init__(self, artist=None, prop={}): 19 22 self.artist, self.prop = artist, self.prop … … 25 28 return self.artist is not other.artist 26 29 27 def __ nonzero__(self):30 def __bool__(self): 28 31 return self.artist is not None 32 33 __nonzero__ = __bool__ 34 29 35 30 36 class BindArtist(object): 31 37 """ 32 Track keyboard modifiers for events. 33 TODO: Move keyboard modifier support into the backend. We cannot 34 TODO: properly support it from outside the windowing system since there 35 TODO: is no way to recognized whether shift is held down when the mouse 36 TODO: first clicks on the the application window. 38 Track keyboard modifiers for events. 37 39 """ 40 # TODO: Move keyboard modifier support into the backend. We cannot 41 # TODO: properly support it from outside the windowing system since there 42 # TODO: is no way to recognized whether shift is held down when the mouse 43 # TODO: first clicks on the the application window. 38 44 control, shift, alt, meta = False, False, False, False 39 45 … … 46 52 'scroll', 'key', 'keyup'] 47 53 # TODO: Need our own event structure 54 48 55 def __init__(self, figure): 49 56 canvas = figure.canvas 57 50 58 # Link to keyboard/mouse 51 59 try: … … 59 67 ] 60 68 except: 61 # print "bypassing scroll_event: wrong matplotlib version"69 logger.warn("bypassing scroll_event: wrong matplotlib version") 62 70 self._connections = [ 63 71 canvas.mpl_connect('motion_notify_event', self._onMotion), … … 67 75 canvas.mpl_connect('key_release_event', self._onKeyRelease), 68 76 ] 77 69 78 # Turn off picker if it hasn't already been done 70 79 try: 71 80 canvas.mpl_disconnect(canvas.button_pick_id) 72 81 canvas.mpl_disconnect(canvas.scroll_pick_id) 73 except: 74 logger.error(sys.exc_value) 82 except Exception as exc: 83 logger.error(exc) 84 85 self._current = None 86 self._actions = {} 75 87 self.canvas = canvas 76 88 self.figure = figure … … 83 95 84 96 Use clearall() to reset all connections. 85 86 97 """ 87 98 for h in artists: … … 108 119 for action in self.events: 109 120 self._actions[action] = {} 121 110 122 # Need activity state 111 123 self._artists = [] … … 121 133 for cid in self._connections: 122 134 self.canvas.mpl_disconnect(cid) 123 except :124 pass135 except Exception as exc: 136 logger.error("Error disconnection canvas: %s" % exc) 125 137 self._connections = [] 126 138 … … 169 181 sure it applies. E.g., the callback for 'press' might be: 170 182 if event.button == 1 and event.shift: process Shift-click 171 172 :TODO: Only receive events with the correct modifiers (e.g., S-click, 173 :TODO: or *-click for any modifiers). 174 :TODO: Only receive button events for the correct button (e.g., click1 175 :TODO: release3, or dclick* for any button) 176 :TODO: Support virtual artist, so that and artist can be flagged as 177 :TODO: having a tag list and receive the correct events 178 :TODO: Support virtual events for binding to button-3 vs shift button-1 179 :TODO: without changing callback code 180 :TODO: Attach multiple callbacks to the same event? 181 :TODO: Clean up interaction with toolbar modes 182 :TODO: push/pushclear/pop context so that binding changes 183 for the duration 184 :TODO: e.g., to support ? context sensitive help 185 186 """ 183 """ 184 #TODO: Only receive events with the correct modifiers (e.g., S-click, 185 #TODO: or *-click for any modifiers). 186 #TODO: Only receive button events for the correct button (e.g., click1 187 #TODO: release3, or dclick* for any button) 188 #TODO: Support virtual artist, so that and artist can be flagged as 189 #TODO: having a tag list and receive the correct events 190 #TODO: Support virtual events for binding to button-3 vs shift button-1 191 #TODO: without changing callback code 192 #TODO: Attach multiple callbacks to the same event? 193 #TODO: Clean up interaction with toolbar modes 194 #TODO: push/pushclear/pop context so that binding changes for the duration 195 #TODO: e.g., to support ? context sensitive help 196 187 197 # Check that the trigger is valid 188 198 if trigger not in self._actions: 189 raise ValueError, "%s invalid --- valid triggers are %s" \ 190 % (trigger, ", ".join(self.events)) 199 raise ValueError("%s invalid --- valid triggers are %s" 200 % (trigger, ", ".join(self.events))) 201 191 202 # Register the trigger callback 192 203 self._actions[trigger][artist] = action 193 # print "==> added",artist,[artist],"to",trigger,":", 194 # self._actions[trigger].keys() 204 195 205 # Maintain a list of all artists 196 206 if artist not in self._artists: … … 203 213 """ 204 214 if action not in self.events: 205 raise ValueError, "Trigger expects " + ", ".join(self.events) 215 raise ValueError("Trigger expects " + ", ".join(self.events)) 216 206 217 # Tag the event with modifiers 207 218 for mod in ('alt', 'control', 'shift', 'meta'): … … 210 221 setattr(ev, 'action', action) 211 222 setattr(ev, 'prop', {}) 223 212 224 # Fallback scheme. If the event does not return false, pass to parent. 213 225 processed = False … … 233 245 """ 234 246 # TODO: sort by zorder of axes then by zorder within axes 235 self._artists.sort(cmp=lambda x, y: cmp(y.zorder, x.zorder)) 236 # print "search"," ".join([str(h) for h in self._artists]) 247 self._artists.sort(key=lambda x: x.zorder, reverse=True) 237 248 found = Selection() 238 # print "searching in",self._artists239 249 for artist in self._artists: 240 250 # TODO: should contains() return false if invisible? … … 250 260 found.artist, found.prop = artist, prop 251 261 break 252 # print "found",found.artist253 262 254 263 # TODO: how to check if prop is equal? … … 257 266 self.trigger(found, 'enter', event) 258 267 self._current = found 268 259 269 return found 260 270 … … 274 284 275 285 transform = self._hasclick.artist.get_transform() 276 # 286 #x,y = event.xdata,event.ydata 277 287 x, y = event.x, event.y 278 288 try: 279 289 x, y = transform.inverted().transform_point((x, y)) 280 281 except: 290 except: # CRUFT: matplotlib-0.91 support 282 291 x, y = transform.inverse_xy_tup((x, y)) 292 283 293 event.xdata, event.ydata = x, y 284 294 self.trigger(self._hasclick, 'drag', event) 285 295 else: 286 296 found = self._find_current(event) 287 # print "found",found.artist288 297 self.trigger(found, 'motion', event) 289 298 … … 296 305 # Check for double-click 297 306 event_time = time.time() 298 # print event_time,self._last_time,self.dclick_threshhold299 # print (event_time > self._last_time + self.dclick_threshhold)300 # print event.button,self._last_button301 307 if (event.button != self._last_button) or \ 302 308 (event_time > self._last_time + self.dclick_threshhold): … … 381 387 setattr(self, event.key, False) 382 388 return 389 383 390 if self._haskey: 384 391 self.trigger(self._haskey, 'keyup', event) … … 391 398 found = self._find_current(event) 392 399 self.trigger(found, 'scroll', event) 393 -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxMask.py
r7432acb r5251ec6 1 1 import math 2 from BaseInteractor import _BaseInteractor3 from boxSum import PointInteractor4 from boxSum import VerticalDoubleLine5 from boxSum import HorizontalDoubleLine2 from .BaseInteractor import _BaseInteractor 3 from .boxSum import PointInteractor 4 from .boxSum import VerticalDoubleLine 5 from .boxSum import HorizontalDoubleLine 6 6 7 7 -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxSlicer.py
r20fa5fe r5251ec6 1 import math 2 1 3 import wx 2 import math3 4 import numpy as np 5 4 6 from sas.sasgui.guiframe.events import NewPlotEvent 5 7 from sas.sasgui.guiframe.events import StatusEvent 6 8 from sas.sasgui.guiframe.events import SlicerParameterEvent 7 9 from sas.sasgui.guiframe.events import EVT_SLICER_PARS 8 from BaseInteractor import _BaseInteractor9 10 from sas.sasgui.guiframe.dataFitting import Data1D 11 12 from .BaseInteractor import _BaseInteractor 10 13 11 14 … … 152 155 if new_slab is None: 153 156 msg = "post data:cannot average , averager is empty" 154 raise ValueError , msg157 raise ValueError(msg) 155 158 self.averager = new_slab 156 159 if self.direction == "X": … … 168 171 else: 169 172 msg = "post data:no Box Average direction was supplied" 170 raise ValueError , msg173 raise ValueError(msg) 171 174 # # Average data2D given Qx or Qy 172 175 box = self.averager(x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxSum.py
r7432acb r5251ec6 4 4 """ 5 5 import math 6 6 7 import wx 7 from BaseInteractor import _BaseInteractor 8 8 9 from sas.sasgui.guiframe.events import SlicerParamUpdateEvent 9 10 from sas.sasgui.guiframe.events import EVT_SLICER_PARS 10 11 from sas.sasgui.guiframe.events import StatusEvent 12 13 from .BaseInteractor import _BaseInteractor 11 14 12 15 -
src/sas/sasgui/guiframe/local_perspectives/plotting/detector_dialog.py
r7432acb r5251ec6 99 99 self.cmap_selector.SetStringSelection("jet") 100 100 self._on_select_cmap(event=None) 101 except :102 msg = "error occurs while resetting Detector: %s" % sys.exc_value101 except Exception as exc: 102 msg = "error occurs while resetting Detector: %s" % exc 103 103 wx.PostEvent(self.parent, StatusEvent(status=msg)) 104 104 -
src/sas/sasgui/guiframe/local_perspectives/plotting/masking.py
r20fa5fe r5251ec6 18 18 19 19 # #Todo: cleaning up, improving the maskplotpanel initialization, and testing. 20 import wx21 20 import sys 22 21 import time 23 import matplotlib.cm as cm24 22 import math 25 23 import copy 24 from functools import partial 25 26 import wx 26 27 import numpy as np 28 import matplotlib.cm as cm 29 27 30 from sas.sasgui.plottools.PlotPanel import PlotPanel 28 31 from sas.sasgui.plottools.plottables import Graph 29 from binder import BindArtist30 32 from sas.sasgui.guiframe.dataFitting import Data1D, Data2D 31 from boxMask import BoxMask32 from sector_mask import SectorMask33 from AnnulusSlicer import CircularMask34 35 33 from sas.sasgui.guiframe.events import SlicerEvent 36 34 from sas.sasgui.guiframe.events import StatusEvent 37 from functools import partial 35 36 from .binder import BindArtist 37 from .boxMask import BoxMask 38 from .sector_mask import SectorMask 39 from .AnnulusSlicer import CircularMask 40 38 41 39 42 (InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() -
src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_boxsum.py
r37d461c r5251ec6 1 1 import wx 2 2 import wx.lib.newevent 3 from parameters_panel_slicer import SlicerParameterPanel 3 4 4 from sas.sasgui.guiframe.utils import format_number 5 5 from sas.sasgui.guiframe.panel_base import PanelBase … … 7 7 EVT_SLICER) 8 8 9 from .parameters_panel_slicer import SlicerParameterPanel 9 10 10 11 class SlicerPanel(wx.Panel, PanelBase): … … 64 65 n = 1 65 66 self.parameters = [] 66 keys = params.keys() 67 keys.sort() 67 keys = list(sorted(params.keys())) 68 68 for item in keys: 69 69 if not item.lower() in ["num_points", "avg", "avg_error", "sum", -
src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py
ra20a255 r5251ec6 2 2 3 3 import os 4 4 5 import wx 5 6 import wx.lib.newevent 7 6 8 from sas.sascalc.dataloader.readers.cansas_reader import Reader 7 9 from sas.sasgui.guiframe.utils import format_number 8 10 from sas.sasgui.guiframe.events import EVT_SLICER_PARS, EVT_SLICER 9 11 from sas.sasgui.guiframe.events import SlicerParameterEvent, StatusEvent 10 from Plotter2D import ModelPanel2D 12 13 from .Plotter2D import ModelPanel2D 14 11 15 apply_params, EVT_APPLY_PARAMS = wx.lib.newevent.NewEvent() 12 16 save_files, EVT_AUTO_SAVE = wx.lib.newevent.NewEvent() … … 100 104 iy = 1 101 105 self.parameters = [] 102 keys = params.keys() 103 keys.sort() 106 keys = list(sorted(params.keys())) 104 107 for item in keys: 105 108 ix = 0 … … 127 130 self.bck.Add(text, (iy, ix), (1, 1), 128 131 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 129 options = BINNING_OPTIONS.keys()132 options = list(BINNING_OPTIONS.keys()) 130 133 self.bin_ctl = wx.ComboBox(parent=self, choices=options) 131 134 hint_msg = "Modify the value of %s to change" % item … … 325 328 326 329 # Find desired 2D data panels 327 for key, mgr in spp.plot_panels.ite ritems():330 for key, mgr in spp.plot_panels.items(): 328 331 if mgr.graph.prop['title'] in self.data_list.CheckedStrings: 329 332 apply_to_list.append(mgr) … … 377 380 self.loaded_data = [] 378 381 # Iterate over the loaded plots and find all 2D panels 379 for key, value in self.main_window.plot_panels.ite ritems():382 for key, value in self.main_window.plot_panels.items(): 380 383 if isinstance(value, ModelPanel2D): 381 384 self.loaded_data.append(value.data2D.name) … … 453 456 454 457 # Find the correct plots to save 455 for key, plot in self.main_window.plot_panels.ite ritems():458 for key, plot in self.main_window.plot_panels.items(): 456 459 if not hasattr(plot, "data2D"): 457 460 for item in plot.plots: … … 461 464 462 465 # Save files as Text 463 for item, data1d in data_dic.ite ritems():466 for item, data1d in data_dic.items(): 464 467 base = '.'.join(item.split('.')[:-1]) 465 468 file_name = base + append + ".txt" -
src/sas/sasgui/guiframe/local_perspectives/plotting/plotting.py
r2d9526d r5251ec6 12 12 ################################################################################ 13 13 14 import wx15 14 import sys 16 15 from copy import deepcopy 16 17 import wx 18 17 19 from sas.sasgui.guiframe.events import EVT_NEW_PLOT 18 20 from sas.sasgui.guiframe.events import EVT_PLOT_QRANGE … … 23 25 from sas.sasgui.guiframe.dataFitting import Data2D 24 26 from sas.sasgui.guiframe.gui_manager import MDIFrame 27 25 28 DEFAULT_MENU_ITEM_LABEL = "No graph available" 26 29 DEFAULT_MENU_ITEM_ID = wx.NewId() … … 91 94 if event is None: 92 95 return 93 if event.id in self.plot_panels .keys():96 if event.id in self.plot_panels: 94 97 panel = self.plot_panels[event.id] 95 elif event.group_id in self.plot_panels .keys():98 elif event.group_id in self.plot_panels: 96 99 panel = self.plot_panels[event.group_id] 97 100 else: … … 102 105 if event is None: 103 106 return 104 if event.id in self.plot_panels .keys():107 if event.id in self.plot_panels: 105 108 panel = self.plot_panels[event.id] 106 elif event.group_id in self.plot_panels .keys():109 elif event.group_id in self.plot_panels: 107 110 panel = self.plot_panels[event.group_id] 108 111 else: … … 123 126 """ 124 127 125 if group_id in self.plot_panels .keys():128 if group_id in self.plot_panels: 126 129 panel = self.plot_panels[group_id] 127 130 panel.remove_data_by_id(id=id) … … 134 137 Clear and Hide all plot panels, and remove them from menu 135 138 """ 136 for group_id in self.plot_panels .keys():139 for group_id in self.plot_panels: 137 140 self.clear_panel_by_id(group_id) 138 141 self.plot_panels = {} … … 142 145 clear the graph 143 146 """ 144 if group_id in self.plot_panels .keys():147 if group_id in self.plot_panels: 145 148 panel = self.plot_panels[group_id] 146 149 for plottable in panel.graph.plottables.keys(): … … 184 187 # Create a new plot panel if none was available 185 188 if issubclass(data.__class__, Data1D): 186 from Plotter1D import ModelPanel1D189 from .Plotter1D import ModelPanel1D 187 190 ## get the data representation label of the data to plot 188 191 ## when even the user select "change scale" … … 200 203 201 204 msg = "1D Panel of group ID %s could not be created" % str(group_id) 202 raise ValueError , msg205 raise ValueError(msg) 203 206 204 207 def create_2d_panel(self, data, group_id): … … 207 210 if issubclass(data.__class__, Data2D): 208 211 ##Create a new plotpanel for 2D data 209 from Plotter2D import ModelPanel2D212 from .Plotter2D import ModelPanel2D 210 213 scale = data.scale 211 214 win = MDIFrame(self.parent, None, 'None', (200, 150)) … … 218 221 return new_panel 219 222 msg = "2D Panel of group ID %s could not be created" % str(group_id) 220 raise ValueError , msg223 raise ValueError(msg) 221 224 222 225 def update_panel(self, data, panel): … … 238 241 msg += " to panel %s\n" % str(panel.window_caption) 239 242 msg += "Please edit %s's units, labels" % str(data.name) 240 raise ValueError , msg243 raise ValueError(msg) 241 244 else: 242 245 if panel.group_id not in data.list_group_id: … … 247 250 """ 248 251 """ 249 if group_id in self.plot_panels .keys():252 if group_id in self.plot_panels: 250 253 panel = self.plot_panels[group_id] 251 254 uid = panel.uid … … 254 257 caption=panel.window_caption)) 255 258 del self.plot_panels[group_id] 256 if uid in self.parent.plot_panels .keys():259 if uid in self.parent.plot_panels: 257 260 del self.parent.plot_panels[uid] 258 261 panel.frame.Destroy() … … 280 283 for data in event.plots: 281 284 for panel in self.plot_panels.values(): 282 if data.id in panel.plots .keys():285 if data.id in panel.plots: 283 286 plot_exists = True 284 287 # Pass each panel it's own copy of the data … … 310 313 data = event.plot 311 314 group_id = data.group_id 312 if group_id in self.plot_panels .keys():315 if group_id in self.plot_panels: 313 316 if action_check: 314 317 # Check if the plot already exist. if it does, do nothing. 315 if data.id in self.plot_panels[group_id].plots .keys():318 if data.id in self.plot_panels[group_id].plots: 316 319 return 317 320 #update a panel graph … … 327 330 for p_group_id in self.plot_panels.keys(): 328 331 p_plot = self.plot_panels[p_group_id] 329 if data.id in p_plot.plots .keys():332 if data.id in p_plot.plots: 330 333 p_plot.plots[data.id] = data 331 334 self.plot_panels[group_id] = p_plot -
src/sas/sasgui/guiframe/local_perspectives/plotting/sector_mask.py
r7432acb r5251ec6 3 3 """ 4 4 import math 5 5 6 import wx 6 #from copy import deepcopy 7 from BaseInteractor import _BaseInteractor 8 from SectorSlicer import SideInteractor 9 from SectorSlicer import LineInteractor 7 10 8 from sas.sasgui.guiframe.events import SlicerParameterEvent 9 10 from .BaseInteractor import _BaseInteractor 11 from .SectorSlicer import SideInteractor 12 from .SectorSlicer import LineInteractor 11 13 12 14 class SectorMask(_BaseInteractor): … … 175 177 msg += "different %f, %f" % (self.left_line.phi, 176 178 self.right_line.phi) 177 raise ValueError , msg179 raise ValueError(msg) 178 180 params["Phi"] = self.main_line.theta 179 181 params["Delta_Phi"] = math.fabs(self.left_line.phi)
Note: See TracChangeset
for help on using the changeset viewer.