[1bf33c1] | 1 | |
---|
[d955bf19] | 2 | ################################################################################ |
---|
[090e07e] | 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. |
---|
[d955bf19] | 6 | # |
---|
[090e07e] | 7 | # See the license text in license.txt |
---|
[d955bf19] | 8 | # |
---|
[090e07e] | 9 | # copyright 2008, University of Tennessee |
---|
[d955bf19] | 10 | ################################################################################ |
---|
[1bf33c1] | 11 | |
---|
| 12 | |
---|
| 13 | import wx |
---|
[4ac8556] | 14 | import sys |
---|
| 15 | import math |
---|
| 16 | import numpy |
---|
[090e07e] | 17 | import logging |
---|
[d7bb526] | 18 | from sas.sasgui.plottools.PlotPanel import PlotPanel |
---|
[d85c194] | 19 | from sas.sasgui.guiframe.events import StatusEvent |
---|
| 20 | from sas.sasgui.guiframe.events import PanelOnFocusEvent |
---|
| 21 | from sas.sasgui.guiframe.utils import PanelMenu, IdList |
---|
| 22 | from sas.sasgui.guiframe.panel_base import PanelBase |
---|
| 23 | from sas.sasgui.guiframe.gui_style import GUIFRAME_ICON |
---|
[f8be87d] | 24 | from appearanceDialog import appearanceDialog |
---|
[8f59e95] | 25 | from graphAppearance import graphAppearance |
---|
[1bf33c1] | 26 | |
---|
[0d9dae8] | 27 | DEFAULT_QMAX = 0.05 |
---|
[1bf33c1] | 28 | DEFAULT_QSTEP = 0.001 |
---|
| 29 | DEFAULT_BEAM = 0.005 |
---|
[32c0841] | 30 | BIN_WIDTH = 1 |
---|
[940aca7] | 31 | IS_MAC = (sys.platform == 'darwin') |
---|
[0d9dae8] | 32 | |
---|
[8f59e95] | 33 | |
---|
| 34 | def find_key(dic, val): |
---|
| 35 | """return the key of dictionary dic given the value""" |
---|
| 36 | return [k for k, v in dic.iteritems() if v == val][0] |
---|
| 37 | |
---|
[691643c] | 38 | class ModelPanel1D(PlotPanel, PanelBase): |
---|
[1bf33c1] | 39 | """ |
---|
[d955bf19] | 40 | Plot panel for use with the GUI manager |
---|
[1bf33c1] | 41 | """ |
---|
[090e07e] | 42 | |
---|
[1bf33c1] | 43 | ## Internal name for the AUI manager |
---|
| 44 | window_name = "plotpanel" |
---|
| 45 | ## Title to appear on top of the window |
---|
[37c36d9] | 46 | window_caption = "Graph" |
---|
[1bf33c1] | 47 | ## Flag to tell the GUI manager that this panel is not |
---|
| 48 | # tied to any perspective |
---|
| 49 | ALWAYS_ON = True |
---|
| 50 | ## Group ID |
---|
| 51 | group_id = None |
---|
[6f16e25] | 52 | _menu_ids = IdList() |
---|
[090e07e] | 53 | |
---|
| 54 | def __init__(self, parent, id=-1, color=None, |
---|
[32c0841] | 55 | dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): |
---|
| 56 | PlotPanel.__init__(self, parent, id=id, style=style, **kwargs) |
---|
[a45037aa] | 57 | PanelBase.__init__(self, parent) |
---|
[1bf33c1] | 58 | ## Reference to the parent window |
---|
| 59 | self.parent = parent |
---|
[ae84427] | 60 | if hasattr(parent, "parent"): |
---|
| 61 | self.parent = self.parent.parent |
---|
[1bf33c1] | 62 | ## Plottables |
---|
| 63 | self.plots = {} |
---|
[ae84427] | 64 | self.frame = None |
---|
[090e07e] | 65 | # context menu |
---|
[52b8b74] | 66 | self._slicerpop = None |
---|
[090e07e] | 67 | |
---|
[52b8b74] | 68 | self._available_data = [] |
---|
[a07e72f] | 69 | self._symbol_labels = self.get_symbol_label() |
---|
[2636188] | 70 | self._color_labels = self.get_color_label() |
---|
| 71 | self.currColorIndex = "" |
---|
[36288ca] | 72 | self._is_changed_legend_label = False |
---|
[657e52c] | 73 | self.is_xtick = False |
---|
| 74 | self.is_ytick = False |
---|
[090e07e] | 75 | |
---|
[a07e72f] | 76 | self.hide_menu = None |
---|
[1bf33c1] | 77 | ## Unique ID (from gui_manager) |
---|
| 78 | self.uid = None |
---|
[66718a1] | 79 | self.x_size = None |
---|
[6063b16] | 80 | ## Default locations |
---|
[090e07e] | 81 | # self._default_save_location = os.getcwd() |
---|
| 82 | self.size = None |
---|
| 83 | self.vl_ind = 0 |
---|
| 84 | ## Graph |
---|
| 85 | # self.graph = Graph() |
---|
[1bf33c1] | 86 | self.graph.xaxis("\\rm{Q}", 'A^{-1}') |
---|
[32c0841] | 87 | self.graph.yaxis("\\rm{Intensity} ", "cm^{-1}") |
---|
[1bf33c1] | 88 | self.graph.render(self) |
---|
[3e001f9] | 89 | self.cursor_id = None |
---|
[090e07e] | 90 | |
---|
[6d727ae] | 91 | # In resizing event |
---|
| 92 | self.resizing = False |
---|
| 93 | self.canvas.set_resizing(self.resizing) |
---|
| 94 | self.Bind(wx.EVT_SIZE, self._OnReSize) |
---|
[6e75ed0] | 95 | self.parent.SetFocus() |
---|
[090e07e] | 96 | |
---|
| 97 | |
---|
[a07e72f] | 98 | def get_symbol_label(self): |
---|
[52b8b74] | 99 | """ |
---|
[a07e72f] | 100 | Associates label to symbol |
---|
[52b8b74] | 101 | """ |
---|
[a07e72f] | 102 | _labels = {} |
---|
| 103 | i = 0 |
---|
[6d727ae] | 104 | _labels['Circle'] = i |
---|
[a07e72f] | 105 | i += 1 |
---|
[6d727ae] | 106 | _labels['Cross X '] = i |
---|
[a07e72f] | 107 | i += 1 |
---|
| 108 | _labels['Triangle Down'] = i |
---|
| 109 | i += 1 |
---|
| 110 | _labels['Triangle Up'] = i |
---|
| 111 | i += 1 |
---|
| 112 | _labels['Triangle Left'] = i |
---|
| 113 | i += 1 |
---|
| 114 | _labels['Triangle Right'] = i |
---|
| 115 | i += 1 |
---|
[6d727ae] | 116 | _labels['Cross +'] = i |
---|
[a07e72f] | 117 | i += 1 |
---|
| 118 | _labels['Square'] = i |
---|
| 119 | i += 1 |
---|
[318b5bbb] | 120 | _labels['diamond'] = i |
---|
[a07e72f] | 121 | i += 1 |
---|
| 122 | _labels['Diamond'] = i |
---|
| 123 | i += 1 |
---|
| 124 | _labels['Hexagon1'] = i |
---|
| 125 | i += 1 |
---|
| 126 | _labels['Hexagon2'] = i |
---|
| 127 | i += 1 |
---|
| 128 | _labels['Pentagon'] = i |
---|
| 129 | i += 1 |
---|
[6d727ae] | 130 | _labels['Line'] = i |
---|
[6c4130a] | 131 | i += 1 |
---|
| 132 | _labels['Dash'] = i |
---|
| 133 | i += 1 |
---|
| 134 | _labels['Vline'] = i |
---|
| 135 | i += 1 |
---|
| 136 | _labels['Step'] = i |
---|
[a07e72f] | 137 | return _labels |
---|
[090e07e] | 138 | |
---|
[2636188] | 139 | def get_color_label(self): |
---|
| 140 | """ |
---|
| 141 | Associates label to a specific color |
---|
| 142 | """ |
---|
| 143 | _labels = {} |
---|
| 144 | i = 0 |
---|
| 145 | _labels['Blue'] = i |
---|
| 146 | i += 1 |
---|
| 147 | _labels['Green'] = i |
---|
| 148 | i += 1 |
---|
| 149 | _labels['Red'] = i |
---|
| 150 | i += 1 |
---|
| 151 | _labels['Cyan'] = i |
---|
| 152 | i += 1 |
---|
| 153 | _labels['Magenta'] = i |
---|
| 154 | i += 1 |
---|
| 155 | _labels['Yellow'] = i |
---|
[ad019b83] | 156 | i += 1 |
---|
| 157 | _labels['Black'] = i |
---|
[2636188] | 158 | return _labels |
---|
[a07e72f] | 159 | |
---|
[090e07e] | 160 | |
---|
[32c0841] | 161 | def set_data(self, list=None): |
---|
[3c44c66] | 162 | """ |
---|
| 163 | """ |
---|
| 164 | pass |
---|
[090e07e] | 165 | |
---|
[1bf33c1] | 166 | def _reset(self): |
---|
| 167 | """ |
---|
[d955bf19] | 168 | Resets internal data and graph |
---|
[090e07e] | 169 | """ |
---|
[1bf33c1] | 170 | self.graph.reset() |
---|
[090e07e] | 171 | self.plots = {} |
---|
[cafa75f] | 172 | self.is_zoomed = False |
---|
[090e07e] | 173 | |
---|
| 174 | def _OnReSize(self, event): |
---|
[6d727ae] | 175 | """ |
---|
| 176 | On response of the resize of a panel, set axes_visiable False |
---|
| 177 | """ |
---|
[66718a1] | 178 | # It was found that wx >= 2.9.3 sends an event even if no size changed. |
---|
[294efd5] | 179 | # So manually recode the size (=x_size) and compare here. |
---|
[940aca7] | 180 | # Massy code to work around:< |
---|
| 181 | if self.parent._mgr != None: |
---|
| 182 | max_panel = self.parent._mgr.GetPane(self) |
---|
| 183 | if max_panel.IsMaximized(): |
---|
| 184 | self.parent._mgr.RestorePane(max_panel) |
---|
| 185 | max_panel.Maximize() |
---|
[66718a1] | 186 | if self.x_size != None: |
---|
| 187 | if self.x_size == self.GetSize(): |
---|
[71fa9bb9] | 188 | self.resizing = False |
---|
| 189 | self.canvas.set_resizing(self.resizing) |
---|
[66718a1] | 190 | return |
---|
[294efd5] | 191 | self.x_size = self.GetSize() |
---|
| 192 | |
---|
[ad9e5e1] | 193 | # Ready for another event |
---|
[4520830] | 194 | # Do not remove this Skip. Otherwise it will get runtime error on wx>=2.9. |
---|
[090e07e] | 195 | event.Skip() |
---|
[6d727ae] | 196 | # set the resizing flag |
---|
| 197 | self.resizing = True |
---|
| 198 | self.canvas.set_resizing(self.resizing) |
---|
| 199 | self.parent.set_schedule(True) |
---|
[adf44c2] | 200 | pos_x, pos_y = self.GetPositionTuple() |
---|
| 201 | if pos_x != 0 and pos_y != 0: |
---|
[294efd5] | 202 | self.size, _ = self.GetClientSizeTuple() |
---|
[2b29bb4] | 203 | self.SetSizer(self.sizer) |
---|
[090e07e] | 204 | wx.CallAfter(self.parent.disable_app_menu, self) |
---|
| 205 | |
---|
[3e001f9] | 206 | def on_plot_qrange(self, event=None): |
---|
| 207 | """ |
---|
| 208 | On Qmin Qmax vertical line event |
---|
| 209 | """ |
---|
| 210 | if event == None: |
---|
| 211 | return |
---|
[090e07e] | 212 | event.Skip() |
---|
[3e001f9] | 213 | active_ctrl = event.active |
---|
| 214 | if active_ctrl == None: |
---|
| 215 | return |
---|
| 216 | if event.id in self.plots.keys(): |
---|
[b99a4552] | 217 | ctrl = event.ctrl |
---|
| 218 | self.cursor_id = event.id |
---|
[3e001f9] | 219 | # Set line position and color |
---|
| 220 | colors = ['red', 'purple'] |
---|
[b99a4552] | 221 | x_data = self.plots[self.cursor_id].x |
---|
| 222 | values = [max(x_data.min(), float(ctrl[0].GetValue())), |
---|
| 223 | min(x_data.max(), float(ctrl[1].GetValue()))] |
---|
[3901e7c] | 224 | if len(ctrl) == 3: |
---|
| 225 | colors.append('purple') |
---|
| 226 | values.append(min(x_data.max(), float(ctrl[2].GetValue()))) |
---|
[3e001f9] | 227 | if self.ly == None: |
---|
| 228 | self.ly = [] |
---|
[b99a4552] | 229 | for c, v in zip(colors, values): |
---|
| 230 | h = self.subplot.axvline(x=v, color=c, lw=2.5, alpha=0.7) |
---|
| 231 | h.set_rasterized(True) |
---|
| 232 | self.ly.append(h) |
---|
[3e001f9] | 233 | try: |
---|
| 234 | # Display x,y in the status bar if possible |
---|
| 235 | xval = float(active_ctrl.GetValue()) |
---|
| 236 | position = self.get_data_xy_vals(xval) |
---|
| 237 | if position != None: |
---|
| 238 | wx.PostEvent(self.parent, StatusEvent(status=position)) |
---|
| 239 | except: |
---|
[090e07e] | 240 | logging.error(sys.exc_value) |
---|
[3e001f9] | 241 | if not event.leftdown: |
---|
[090e07e] | 242 | # text event |
---|
[3e001f9] | 243 | try: |
---|
| 244 | is_moved = False |
---|
[b99a4552] | 245 | for h, v in zip(self.ly, values): |
---|
[3e001f9] | 246 | # check if vline moved |
---|
[b99a4552] | 247 | if h.get_xdata() != v: |
---|
| 248 | h.set_xdata(v) |
---|
[3e001f9] | 249 | is_moved = True |
---|
| 250 | if is_moved: |
---|
[090e07e] | 251 | self.canvas.draw() |
---|
[3e001f9] | 252 | except: |
---|
[090e07e] | 253 | logging.error(sys.exc_value) |
---|
| 254 | event.Skip() |
---|
[3e001f9] | 255 | return |
---|
| 256 | self.q_ctrl = ctrl |
---|
[b99a4552] | 257 | for h, c, v in zip(self.ly, colors, values): |
---|
| 258 | h.set_color(c) |
---|
| 259 | h.set_xdata(v) |
---|
[3e001f9] | 260 | self.canvas.draw() |
---|
| 261 | else: |
---|
| 262 | self.q_ctrl = None |
---|
[090e07e] | 263 | |
---|
[3e001f9] | 264 | def get_data_xy_vals(self, xval): |
---|
| 265 | """ |
---|
| 266 | Get x, y data values near x = x_val |
---|
| 267 | """ |
---|
| 268 | try: |
---|
| 269 | x_data = self.plots[self.cursor_id].x |
---|
| 270 | y_data = self.plots[self.cursor_id].y |
---|
| 271 | indx = self._find_nearest(x_data, xval) |
---|
| 272 | pos_x = x_data[indx] |
---|
| 273 | pos_y = y_data[indx] |
---|
| 274 | position = str(pos_x), str(pos_y) |
---|
| 275 | return position |
---|
| 276 | except: |
---|
| 277 | return None |
---|
[090e07e] | 278 | |
---|
[3e001f9] | 279 | def _find_nearest(self, array, value): |
---|
| 280 | """ |
---|
| 281 | Find and return the nearest value in array to the value. |
---|
| 282 | Used in cusor_line() |
---|
| 283 | :Param array: numpy array |
---|
| 284 | :Param value: float |
---|
| 285 | """ |
---|
| 286 | idx = (numpy.abs(array - value)).argmin() |
---|
[090e07e] | 287 | return int(idx) # array.flat[idx] |
---|
| 288 | |
---|
[3e001f9] | 289 | def _check_line_positions(self, pos_x=None, nop=None): |
---|
| 290 | """ |
---|
| 291 | Check vertical line positions |
---|
| 292 | :Param pos_x: position of the current line [float] |
---|
| 293 | :Param nop: number of plots [int] |
---|
| 294 | """ |
---|
| 295 | ly = self.ly |
---|
| 296 | ly0x = ly[0].get_xdata() |
---|
| 297 | ly1x = ly[1].get_xdata() |
---|
| 298 | self.q_ctrl[0].SetBackgroundColour('white') |
---|
| 299 | self.q_ctrl[1].SetBackgroundColour('white') |
---|
| 300 | if ly0x >= ly1x: |
---|
| 301 | if self.vl_ind == 0: |
---|
| 302 | ly[1].set_xdata(pos_x) |
---|
| 303 | ly[1].set_zorder(nop) |
---|
| 304 | self.q_ctrl[1].SetValue(str(pos_x)) |
---|
| 305 | self.q_ctrl[0].SetBackgroundColour('pink') |
---|
| 306 | elif self.vl_ind == 1: |
---|
| 307 | ly[0].set_xdata(pos_x) |
---|
| 308 | ly[0].set_zorder(nop) |
---|
| 309 | self.q_ctrl[0].SetValue(str(pos_x)) |
---|
| 310 | self.q_ctrl[1].SetBackgroundColour('pink') |
---|
[090e07e] | 311 | |
---|
[3e001f9] | 312 | def _get_cusor_lines(self, event): |
---|
| 313 | """ |
---|
| 314 | Revmove or switch cursor line if drawn |
---|
| 315 | :Param event: LeftClick mouse event |
---|
[090e07e] | 316 | """ |
---|
[3e001f9] | 317 | ax = event.inaxes |
---|
[ae84427] | 318 | if hasattr(event, "action"): |
---|
| 319 | dclick = event.action == 'dclick' |
---|
| 320 | if ax == None or dclick: |
---|
| 321 | # remove the vline |
---|
| 322 | self._check_zoom_plot() |
---|
| 323 | self.canvas.draw() |
---|
| 324 | self.q_ctrl = None |
---|
[090e07e] | 325 | return |
---|
[3e001f9] | 326 | if self.ly != None and event.xdata != None: |
---|
| 327 | # Selecting a new line if cursor lines are displayed already |
---|
| 328 | dqmin = math.fabs(event.xdata - self.ly[0].get_xdata()) |
---|
| 329 | dqmax = math.fabs(event.xdata - self.ly[1].get_xdata()) |
---|
| 330 | is_qmax = dqmin > dqmax |
---|
| 331 | if is_qmax: |
---|
| 332 | self.vl_ind = 1 |
---|
| 333 | else: |
---|
[090e07e] | 334 | self.vl_ind = 0 |
---|
| 335 | |
---|
[3e001f9] | 336 | def cusor_line(self, event): |
---|
| 337 | """ |
---|
| 338 | Move the cursor line to write Q range |
---|
| 339 | """ |
---|
| 340 | if self.q_ctrl == None: |
---|
| 341 | return |
---|
[090e07e] | 342 | # release a q range vline |
---|
[3e001f9] | 343 | if self.ly != None and not self.leftdown: |
---|
| 344 | for ly in self.ly: |
---|
| 345 | ly.set_alpha(0.7) |
---|
| 346 | self.canvas.draw() |
---|
| 347 | return |
---|
| 348 | ax = event.inaxes |
---|
| 349 | if ax == None or not hasattr(event, 'action'): |
---|
| 350 | return |
---|
| 351 | end_drag = event.action != 'drag' and event.xdata != None |
---|
| 352 | nop = len(self.plots) |
---|
[090e07e] | 353 | pos_x, _ = float(event.xdata), float(event.ydata) |
---|
[3e001f9] | 354 | try: |
---|
| 355 | ly = self.ly |
---|
| 356 | ly0x = ly[0].get_xdata() |
---|
| 357 | ly1x = ly[1].get_xdata() |
---|
| 358 | if ly0x == ly1x: |
---|
| 359 | if ly[0].get_zorder() > ly[1].get_zorder(): |
---|
| 360 | self.vl_ind = 0 |
---|
| 361 | else: |
---|
| 362 | self.vl_ind = 1 |
---|
| 363 | vl_ind = self.vl_ind |
---|
| 364 | x_data = self.plots[self.cursor_id].x |
---|
| 365 | xmin = x_data.min() |
---|
| 366 | xmax = x_data.max() |
---|
| 367 | indx = self._find_nearest(x_data, pos_x) |
---|
| 368 | # Need to hold LeftButton to drag |
---|
| 369 | if end_drag: |
---|
| 370 | if event.button: |
---|
| 371 | self._check_line_positions(pos_x, nop) |
---|
[090e07e] | 372 | return |
---|
[3e001f9] | 373 | if indx >= len(x_data): |
---|
| 374 | indx = len(x_data) - 1 |
---|
| 375 | pos_x = x_data[indx] |
---|
| 376 | if xmin == ly1x: |
---|
| 377 | vl_ind = 1 |
---|
| 378 | elif xmax == ly0x: |
---|
| 379 | vl_ind = 0 |
---|
| 380 | else: |
---|
| 381 | ly[vl_ind].set_xdata(pos_x) |
---|
| 382 | ly[vl_ind].set_zorder(nop + 1) |
---|
| 383 | self._check_line_positions(pos_x, nop) |
---|
| 384 | ly[vl_ind].set_xdata(pos_x) |
---|
| 385 | ly[vl_ind].set_alpha(1.0) |
---|
| 386 | ly[vl_ind].set_zorder(nop + 1) |
---|
| 387 | self.canvas.draw() |
---|
| 388 | self.q_ctrl[vl_ind].SetValue(str(pos_x)) |
---|
| 389 | except: |
---|
[090e07e] | 390 | logging.error(sys.exc_value) |
---|
| 391 | |
---|
[6d727ae] | 392 | def set_resizing(self, resizing=False): |
---|
| 393 | """ |
---|
| 394 | Set the resizing (True/False) |
---|
| 395 | """ |
---|
| 396 | self.resizing = resizing |
---|
[090e07e] | 397 | # self.canvas.set_resizing(resizing) |
---|
| 398 | |
---|
| 399 | def schedule_full_draw(self, func='append'): |
---|
[6d727ae] | 400 | """ |
---|
| 401 | Put self in schedule to full redraw list |
---|
| 402 | """ |
---|
| 403 | # append/del this panel in the schedule list |
---|
| 404 | self.parent.set_schedule_full_draw(self, func) |
---|
| 405 | |
---|
[a07e72f] | 406 | def remove_data_by_id(self, id): |
---|
[98816c43] | 407 | """ |
---|
| 408 | Remove data from plot |
---|
[a07e72f] | 409 | """ |
---|
| 410 | if id in self.plots.keys(): |
---|
[090e07e] | 411 | data = self.plots[id] |
---|
[a07e72f] | 412 | self.graph.delete(data) |
---|
| 413 | data_manager = self._manager.parent.get_data_manager() |
---|
[df22224] | 414 | data_list, theory_list = data_manager.get_by_id(id_list=[id]) |
---|
[090e07e] | 415 | |
---|
[df22224] | 416 | if id in data_list.keys(): |
---|
| 417 | data = data_list[id] |
---|
[248b918] | 418 | if id in theory_list.keys(): |
---|
[df22224] | 419 | data = theory_list[id] |
---|
[090e07e] | 420 | |
---|
[a07e72f] | 421 | del self.plots[id] |
---|
| 422 | self.graph.render(self) |
---|
[090e07e] | 423 | self.subplot.figure.canvas.draw_idle() |
---|
[a07e72f] | 424 | if len(self.graph.plottables) == 0: |
---|
[090e07e] | 425 | # onRemove: graph is empty must be the panel must be destroyed |
---|
[df22224] | 426 | self.parent.delete_panel(self.uid) |
---|
[090e07e] | 427 | |
---|
[a07e72f] | 428 | def plot_data(self, data): |
---|
[1bf33c1] | 429 | """ |
---|
[d955bf19] | 430 | Data is ready to be displayed |
---|
[090e07e] | 431 | |
---|
[d955bf19] | 432 | :param event: data event |
---|
[1bf33c1] | 433 | """ |
---|
[b837e1f] | 434 | if data.__class__.__name__ == 'Data2D': |
---|
| 435 | return |
---|
[6c4130a] | 436 | plot_keys = self.plots.keys() |
---|
| 437 | if data.id in plot_keys: |
---|
[090e07e] | 438 | # Recover panel prop.s |
---|
[e4a703a] | 439 | xlo, xhi = self.subplot.get_xlim() |
---|
| 440 | ylo, yhi = self.subplot.get_ylim() |
---|
[5eede4e] | 441 | old_data = self.plots[data.id] |
---|
[36288ca] | 442 | if self._is_changed_legend_label: |
---|
| 443 | data.label = old_data.label |
---|
[c9579e0] | 444 | if old_data.__class__.__name__ == 'Data1D': |
---|
| 445 | data.custom_color = old_data.custom_color |
---|
| 446 | data.symbol = old_data.symbol |
---|
| 447 | data.markersize = old_data.markersize |
---|
[6c4130a] | 448 | data.zorder = len(plot_keys) |
---|
[e4a703a] | 449 | # Replace data |
---|
[a07e72f] | 450 | self.graph.replace(data) |
---|
| 451 | self.plots[data.id] = data |
---|
[e4a703a] | 452 | ## Set the view scale for all plots |
---|
[a4964b8e] | 453 | try: |
---|
| 454 | self._onEVT_FUNC_PROPERTY() |
---|
[cafa75f] | 455 | except Exception, exc: |
---|
[090e07e] | 456 | wx.PostEvent(self.parent, |
---|
| 457 | StatusEvent(status="Plotting Error: %s" % str(exc), info="error")) |
---|
[cafa75f] | 458 | if self.is_zoomed: |
---|
[7022fdc] | 459 | # Recover the x,y limits |
---|
[090e07e] | 460 | self.subplot.set_xlim((xlo, xhi)) |
---|
| 461 | self.subplot.set_ylim((ylo, yhi)) |
---|
[a07e72f] | 462 | else: |
---|
| 463 | self.plots[data.id] = data |
---|
[090e07e] | 464 | self.graph.add(self.plots[data.id]) |
---|
[6c4130a] | 465 | data.zorder = len(plot_keys) |
---|
[e4a703a] | 466 | ## Set the view scale for all plots |
---|
[a4964b8e] | 467 | try: |
---|
| 468 | self._onEVT_FUNC_PROPERTY() |
---|
[940aca7] | 469 | if IS_MAC: |
---|
| 470 | # MAC: forcing to plot 2D avg |
---|
| 471 | self.canvas._onDrawIdle() |
---|
[090e07e] | 472 | except Exception, exc: |
---|
[4904062] | 473 | wx.PostEvent(self.parent, StatusEvent(status=\ |
---|
[090e07e] | 474 | "Plotting Error: %s" % str(exc), info="error")) |
---|
[fe48fcc] | 475 | self.toolbar.update() |
---|
[cafa75f] | 476 | self.is_zoomed = False |
---|
[090e07e] | 477 | |
---|
[6d727ae] | 478 | def draw_plot(self): |
---|
| 479 | """ |
---|
| 480 | Draw plot |
---|
| 481 | """ |
---|
[090e07e] | 482 | self.draw() |
---|
[6d727ae] | 483 | |
---|
[090e07e] | 484 | def onLeftDown(self, event): |
---|
| 485 | """ |
---|
[d955bf19] | 486 | left button down and ready to drag |
---|
| 487 | Display the position of the mouse on the statusbar |
---|
[6c0568b] | 488 | """ |
---|
[090e07e] | 489 | # self.parent.set_plot_unfocus() |
---|
[3e001f9] | 490 | self._get_cusor_lines(event) |
---|
[e85e2bc] | 491 | ax = event.inaxes |
---|
[3e001f9] | 492 | PlotPanel.onLeftDown(self, event) |
---|
[e85e2bc] | 493 | if ax != None: |
---|
[902f373] | 494 | try: |
---|
[090e07e] | 495 | pos_x = float(event.xdata) # / size_x |
---|
| 496 | pos_y = float(event.ydata) # / size_y |
---|
| 497 | pos_x = "%8.3g" % pos_x |
---|
| 498 | pos_y = "%8.3g" % pos_y |
---|
[902f373] | 499 | self.position = str(pos_x), str(pos_y) |
---|
| 500 | wx.PostEvent(self.parent, StatusEvent(status=self.position)) |
---|
| 501 | except: |
---|
[090e07e] | 502 | self.position = None |
---|
[0275276] | 503 | # unfocus all |
---|
[090e07e] | 504 | self.parent.set_plot_unfocus() |
---|
| 505 | # post nd event to notify guiframe that this panel is on focus |
---|
[a45037aa] | 506 | wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self)) |
---|
[df68da1] | 507 | |
---|
[090e07e] | 508 | |
---|
[a07e72f] | 509 | def _ontoggle_hide_error(self, event): |
---|
| 510 | """ |
---|
| 511 | Toggle error display to hide or show |
---|
| 512 | """ |
---|
[70ec588d] | 513 | menu = event.GetEventObject() |
---|
[090e07e] | 514 | event_id = event.GetId() |
---|
| 515 | self.set_selected_from_menu(menu, event_id) |
---|
[ebf422a] | 516 | # Check zoom |
---|
| 517 | xlo, xhi = self.subplot.get_xlim() |
---|
| 518 | ylo, yhi = self.subplot.get_ylim() |
---|
| 519 | |
---|
[a07e72f] | 520 | selected_plot = self.plots[self.graph.selected_plottable] |
---|
[5637362] | 521 | if self.hide_menu.GetText() == "Hide Error Bar": |
---|
[a07e72f] | 522 | selected_plot.hide_error = True |
---|
| 523 | else: |
---|
| 524 | selected_plot.hide_error = False |
---|
| 525 | ## increment graph color |
---|
| 526 | self.graph.render(self) |
---|
[090e07e] | 527 | self.subplot.figure.canvas.draw_idle() |
---|
[cafa75f] | 528 | if self.is_zoomed: |
---|
[ebf422a] | 529 | # Recover the x,y limits |
---|
[090e07e] | 530 | self.subplot.set_xlim((xlo, xhi)) |
---|
| 531 | self.subplot.set_ylim((ylo, yhi)) |
---|
| 532 | |
---|
[ebf422a] | 533 | |
---|
[1bf33c1] | 534 | def _onRemove(self, event): |
---|
| 535 | """ |
---|
[090e07e] | 536 | Remove a plottable from the graph and render the graph |
---|
| 537 | |
---|
[d955bf19] | 538 | :param event: Menu event |
---|
[090e07e] | 539 | |
---|
[1bf33c1] | 540 | """ |
---|
[70ec588d] | 541 | menu = event.GetEventObject() |
---|
[090e07e] | 542 | event_id = event.GetId() |
---|
| 543 | self.set_selected_from_menu(menu, event_id) |
---|
[6c0568b] | 544 | ## Check if there is a selected graph to remove |
---|
[a07e72f] | 545 | if self.graph.selected_plottable in self.plots.keys(): |
---|
[090e07e] | 546 | graph_id = self.graph.selected_plottable |
---|
| 547 | self.remove_data_by_id(graph_id) |
---|
| 548 | |
---|
[1bf33c1] | 549 | def onContextMenu(self, event): |
---|
| 550 | """ |
---|
[d955bf19] | 551 | 1D plot context menu |
---|
[090e07e] | 552 | |
---|
[d955bf19] | 553 | :param event: wx context event |
---|
[090e07e] | 554 | |
---|
[1bf33c1] | 555 | """ |
---|
[52b8b74] | 556 | self._slicerpop = PanelMenu() |
---|
| 557 | self._slicerpop.set_plots(self.plots) |
---|
[090e07e] | 558 | self._slicerpop.set_graph(self.graph) |
---|
[6f16e25] | 559 | ids = iter(self._menu_ids) |
---|
[090e07e] | 560 | if not self.graph.selected_plottable in self.plots: |
---|
[70ec588d] | 561 | # Various plot options |
---|
[6f16e25] | 562 | wx_id = ids.next() |
---|
[090e07e] | 563 | self._slicerpop.Append(wx_id, '&Save Image', 'Save image as PNG') |
---|
| 564 | wx.EVT_MENU(self, wx_id, self.onSaveImage) |
---|
[6f16e25] | 565 | wx_id = ids.next() |
---|
[090e07e] | 566 | self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') |
---|
| 567 | wx.EVT_MENU(self, wx_id, self.onPrint) |
---|
| 568 | |
---|
[6f16e25] | 569 | wx_id = ids.next() |
---|
[090e07e] | 570 | self._slicerpop.Append(wx_id, '&Copy to Clipboard', |
---|
[f866fb5] | 571 | 'Copy to the clipboard') |
---|
[090e07e] | 572 | wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) |
---|
| 573 | |
---|
[70ec588d] | 574 | self._slicerpop.AppendSeparator() |
---|
| 575 | |
---|
| 576 | for plot in self.plots.values(): |
---|
[090e07e] | 577 | # title = plot.title |
---|
[6d727ae] | 578 | name = plot.name |
---|
[70ec588d] | 579 | plot_menu = wx.Menu() |
---|
[242aff5] | 580 | if self.graph.selected_plottable: |
---|
[4a9bce1] | 581 | if not self.graph.selected_plottable in self.plots.keys(): |
---|
| 582 | continue |
---|
[242aff5] | 583 | if plot != self.plots[self.graph.selected_plottable]: |
---|
| 584 | continue |
---|
[090e07e] | 585 | |
---|
[6f16e25] | 586 | wx_id = ids.next() |
---|
[090e07e] | 587 | plot_menu.Append(wx_id, "&DataInfo", name) |
---|
| 588 | wx.EVT_MENU(self, wx_id, self. _onDataShow) |
---|
[6f16e25] | 589 | wx_id = ids.next() |
---|
[090e07e] | 590 | plot_menu.Append(wx_id, "&Save Points as a File", name) |
---|
| 591 | wx.EVT_MENU(self, wx_id, self._onSave) |
---|
[940aca7] | 592 | plot_menu.AppendSeparator() |
---|
[090e07e] | 593 | |
---|
| 594 | # add menu of other plugins |
---|
[940aca7] | 595 | item_list = self.parent.get_current_context_menu(self) |
---|
[70ec588d] | 596 | if (not item_list == None) and (not len(item_list) == 0): |
---|
[6f16e25] | 597 | # Note: reusing menu ids in submenu. This code works because |
---|
| 598 | # IdItems is set up as a lazy iterator returning each id in |
---|
| 599 | # sequence, creating new ids as needed so it never runs out. |
---|
| 600 | # zip() is set up to stop when any iterator is empty, so it |
---|
| 601 | # only asks for the number of ids in item_list. |
---|
| 602 | for item, wx_id in zip(item_list, self._menu_ids): |
---|
[242aff5] | 603 | |
---|
[70ec588d] | 604 | try: |
---|
[090e07e] | 605 | plot_menu.Append(wx_id, item[0], name) |
---|
| 606 | wx.EVT_MENU(self, wx_id, item[2]) |
---|
[70ec588d] | 607 | except: |
---|
| 608 | msg = "ModelPanel1D.onContextMenu: " |
---|
| 609 | msg += "bad menu item %s" % sys.exc_value |
---|
| 610 | wx.PostEvent(self.parent, StatusEvent(status=msg)) |
---|
| 611 | plot_menu.AppendSeparator() |
---|
[090e07e] | 612 | |
---|
| 613 | if self.parent.ClassName.count('wxDialog') == 0: |
---|
[6f16e25] | 614 | wx_id = ids.next() |
---|
[090e07e] | 615 | plot_menu.Append(wx_id, '&Linear Fit', name) |
---|
| 616 | wx.EVT_MENU(self, wx_id, self.onFitting) |
---|
[70ec588d] | 617 | plot_menu.AppendSeparator() |
---|
[090e07e] | 618 | |
---|
[6f16e25] | 619 | wx_id = ids.next() |
---|
[090e07e] | 620 | plot_menu.Append(wx_id, "Remove", name) |
---|
| 621 | wx.EVT_MENU(self, wx_id, self._onRemove) |
---|
[a436b2e] | 622 | if not plot.is_data: |
---|
[6f16e25] | 623 | wx_id = ids.next() |
---|
[090e07e] | 624 | plot_menu.Append(wx_id, '&Freeze', name) |
---|
| 625 | wx.EVT_MENU(self, wx_id, self.onFreeze) |
---|
| 626 | plot_menu.AppendSeparator() |
---|
| 627 | |
---|
[70ec588d] | 628 | if plot.is_data: |
---|
[6f16e25] | 629 | wx_id = ids.next() |
---|
[090e07e] | 630 | self.hide_menu = plot_menu.Append(wx_id, "Hide Error Bar", name) |
---|
| 631 | |
---|
[70ec588d] | 632 | if plot.dy is not None and plot.dy != []: |
---|
[090e07e] | 633 | if plot.hide_error: |
---|
[70ec588d] | 634 | self.hide_menu.SetText('Show Error Bar') |
---|
| 635 | else: |
---|
| 636 | self.hide_menu.SetText('Hide Error Bar') |
---|
[a436b2e] | 637 | else: |
---|
[70ec588d] | 638 | self.hide_menu.Enable(False) |
---|
[090e07e] | 639 | wx.EVT_MENU(self, wx_id, self._ontoggle_hide_error) |
---|
[f8be87d] | 640 | |
---|
[090e07e] | 641 | plot_menu.AppendSeparator() |
---|
[f8be87d] | 642 | |
---|
[6f16e25] | 643 | wx_id = ids.next() |
---|
[090e07e] | 644 | plot_menu.Append(wx_id, '&Modify Plot Property', name) |
---|
| 645 | wx.EVT_MENU(self, wx_id, self.createAppDialog) |
---|
[6f16e25] | 646 | wx_id = ids.next() |
---|
[090e07e] | 647 | # plot_menu.SetTitle(name) |
---|
| 648 | self._slicerpop.AppendMenu(wx_id, '&%s' % name, plot_menu) |
---|
[f866fb5] | 649 | # Option to hide |
---|
[090e07e] | 650 | # TODO: implement functionality to hide a plottable (legend click) |
---|
| 651 | if not self.graph.selected_plottable in self.plots: |
---|
[70ec588d] | 652 | self._slicerpop.AppendSeparator() |
---|
| 653 | loc_menu = wx.Menu() |
---|
| 654 | for label in self._loc_labels: |
---|
[6f16e25] | 655 | wx_id = ids.next() |
---|
[090e07e] | 656 | loc_menu.Append(wx_id, str(label), str(label)) |
---|
| 657 | wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) |
---|
| 658 | |
---|
[6f16e25] | 659 | wx_id = ids.next() |
---|
[090e07e] | 660 | self._slicerpop.Append(wx_id, '&Modify Graph Appearance', |
---|
[f866fb5] | 661 | 'Modify graph appearance') |
---|
[090e07e] | 662 | wx.EVT_MENU(self, wx_id, self.modifyGraphAppearance) |
---|
[70ec588d] | 663 | self._slicerpop.AppendSeparator() |
---|
[8f59e95] | 664 | |
---|
[090e07e] | 665 | |
---|
[70ec588d] | 666 | if self.position != None: |
---|
[6f16e25] | 667 | wx_id = ids.next() |
---|
[090e07e] | 668 | self._slicerpop.Append(wx_id, '&Add Text') |
---|
| 669 | wx.EVT_MENU(self, wx_id, self._on_addtext) |
---|
[6f16e25] | 670 | wx_id = ids.next() |
---|
[090e07e] | 671 | self._slicerpop.Append(wx_id, '&Remove Text') |
---|
| 672 | wx.EVT_MENU(self, wx_id, self._on_removetext) |
---|
[70ec588d] | 673 | self._slicerpop.AppendSeparator() |
---|
[6f16e25] | 674 | wx_id = ids.next() |
---|
[090e07e] | 675 | self._slicerpop.Append(wx_id, '&Change Scale') |
---|
| 676 | wx.EVT_MENU(self, wx_id, self._onProperties) |
---|
[857d00f] | 677 | self._slicerpop.AppendSeparator() |
---|
[6f16e25] | 678 | wx_id = ids.next() |
---|
[090e07e] | 679 | self._slicerpop.Append(wx_id, '&Reset Graph Range') |
---|
| 680 | wx.EVT_MENU(self, wx_id, self.onResetGraph) |
---|
| 681 | |
---|
| 682 | if self.parent.ClassName.count('wxDialog') == 0: |
---|
[70ec588d] | 683 | self._slicerpop.AppendSeparator() |
---|
[6f16e25] | 684 | wx_id = ids.next() |
---|
[090e07e] | 685 | self._slicerpop.Append(wx_id, '&Window Title') |
---|
| 686 | wx.EVT_MENU(self, wx_id, self.onChangeCaption) |
---|
[dc51a7f] | 687 | try: |
---|
| 688 | pos_evt = event.GetPosition() |
---|
| 689 | pos = self.ScreenToClient(pos_evt) |
---|
| 690 | except: |
---|
| 691 | pos_x, pos_y = self.toolbar.GetPositionTuple() |
---|
| 692 | pos = (pos_x, pos_y + 5) |
---|
[52b8b74] | 693 | self.PopupMenu(self._slicerpop, pos) |
---|
[090e07e] | 694 | |
---|
[e6a93df] | 695 | def onFreeze(self, event): |
---|
| 696 | """ |
---|
[f866fb5] | 697 | on Freeze data |
---|
[e6a93df] | 698 | """ |
---|
[70ec588d] | 699 | menu = event.GetEventObject() |
---|
[090e07e] | 700 | wx_id = event.GetId() |
---|
| 701 | self.set_selected_from_menu(menu, wx_id) |
---|
[e6a93df] | 702 | plot = self.plots[self.graph.selected_plottable] |
---|
| 703 | self.parent.onfreeze([plot.id]) |
---|
[090e07e] | 704 | |
---|
[1bf33c1] | 705 | def _onSave(self, evt): |
---|
| 706 | """ |
---|
[d955bf19] | 707 | Save a data set to a text file |
---|
[090e07e] | 708 | |
---|
[d955bf19] | 709 | :param evt: Menu event |
---|
[090e07e] | 710 | |
---|
[1bf33c1] | 711 | """ |
---|
[70ec588d] | 712 | menu = evt.GetEventObject() |
---|
[090e07e] | 713 | event_id = evt.GetId() |
---|
| 714 | self.set_selected_from_menu(menu, event_id) |
---|
[176fbf1] | 715 | data = self.plots[self.graph.selected_plottable] |
---|
| 716 | default_name = data.label |
---|
[c553b18] | 717 | if default_name.count('.') > 0: |
---|
| 718 | default_name = default_name.split('.')[0] |
---|
| 719 | default_name += "_out" |
---|
| 720 | if self.parent != None: |
---|
[176fbf1] | 721 | self.parent.save_data1d(data, default_name) |
---|
[c5a769e] | 722 | |
---|
[0aca693] | 723 | def _onDataShow(self, evt): |
---|
| 724 | """ |
---|
| 725 | Show the data set in text |
---|
[090e07e] | 726 | |
---|
[0aca693] | 727 | :param evt: Menu event |
---|
[090e07e] | 728 | |
---|
[0aca693] | 729 | """ |
---|
| 730 | menu = evt.GetEventObject() |
---|
[090e07e] | 731 | event_id = evt.GetId() |
---|
| 732 | self.set_selected_from_menu(menu, event_id) |
---|
[0aca693] | 733 | data = self.plots[self.graph.selected_plottable] |
---|
| 734 | default_name = data.label |
---|
| 735 | if default_name.count('.') > 0: |
---|
| 736 | default_name = default_name.split('.')[0] |
---|
[090e07e] | 737 | # default_name += "_out" |
---|
[0aca693] | 738 | if self.parent != None: |
---|
| 739 | self.parent.show_data1d(data, default_name) |
---|
[090e07e] | 740 | |
---|
[6e75ed0] | 741 | def _on_hide(self, event): |
---|
| 742 | """ |
---|
| 743 | Hides the plot when button is pressed |
---|
[090e07e] | 744 | """ |
---|
[c5a769e] | 745 | if self.parent is not None: |
---|
[6e75ed0] | 746 | self.parent.hide_panel(self.uid) |
---|
[f8be87d] | 747 | |
---|
[ae84427] | 748 | def on_close(self, event): |
---|
| 749 | """ |
---|
| 750 | On Close Event |
---|
| 751 | """ |
---|
| 752 | ID = self.uid |
---|
| 753 | self.parent.delete_panel(ID) |
---|
[090e07e] | 754 | |
---|
[f8be87d] | 755 | def createAppDialog(self, event): |
---|
| 756 | """ |
---|
| 757 | Create the custom dialog for fit appearance modification |
---|
| 758 | """ |
---|
| 759 | menu = event.GetEventObject() |
---|
[090e07e] | 760 | event_id = event.GetId() |
---|
| 761 | self.set_selected_from_menu(menu, event_id) |
---|
[f866fb5] | 762 | self.appearance_selected_plot = \ |
---|
| 763 | self.plots[self.graph.selected_plottable] |
---|
[f8be87d] | 764 | # find current properties |
---|
| 765 | curr_color = self.appearance_selected_plot.custom_color |
---|
| 766 | curr_symbol = self.appearance_selected_plot.symbol |
---|
| 767 | curr_size = self.appearance_selected_plot.markersize |
---|
| 768 | curr_label = self.appearance_selected_plot.label |
---|
| 769 | |
---|
| 770 | if curr_color == None: |
---|
| 771 | curr_color = self._color_labels['Blue'] |
---|
| 772 | curr_symbol = 13 |
---|
| 773 | |
---|
[9f51c2c] | 774 | self.appD = appearanceDialog(self, 'Modify Plot Property') |
---|
| 775 | icon = self.parent.GetIcon() |
---|
| 776 | self.appD.SetIcon(icon) |
---|
[090e07e] | 777 | self.appD.set_defaults(float(curr_size), int(curr_color), |
---|
| 778 | str(appearanceDialog.find_key(self.get_symbol_label(), |
---|
| 779 | int(curr_symbol))), curr_label) |
---|
| 780 | self.appD.Bind(wx.EVT_CLOSE, self.on_AppDialog_close) |
---|
[9f51c2c] | 781 | |
---|
[f866fb5] | 782 | def on_AppDialog_close(self, event): |
---|
| 783 | """ |
---|
| 784 | on_Modify Plot Property_close |
---|
| 785 | """ |
---|
[090e07e] | 786 | if self.appD.okay_clicked == True: |
---|
| 787 | info = self.appD.get_current_values() |
---|
[f866fb5] | 788 | self.appearance_selected_plot.custom_color = \ |
---|
| 789 | self._color_labels[info[1].encode('ascii', 'ignore')] |
---|
[9f51c2c] | 790 | |
---|
| 791 | self.appearance_selected_plot.markersize = float(info[0]) |
---|
[f866fb5] | 792 | self.appearance_selected_plot.symbol = \ |
---|
[090e07e] | 793 | self.get_symbol_label()[info[2]] |
---|
[9f51c2c] | 794 | self.appearance_selected_plot.label = str(info[3]) |
---|
[f8be87d] | 795 | self.appD.Destroy() |
---|
| 796 | self._check_zoom_plot() |
---|
[8f59e95] | 797 | |
---|
[f866fb5] | 798 | def modifyGraphAppearance(self, event): |
---|
| 799 | """ |
---|
[090e07e] | 800 | On Modify Graph Appearance |
---|
[f866fb5] | 801 | """ |
---|
| 802 | self.graphApp = graphAppearance(self, 'Modify Graph Appearance') |
---|
[9f51c2c] | 803 | icon = self.parent.GetIcon() |
---|
| 804 | self.graphApp.SetIcon(icon) |
---|
[090e07e] | 805 | self.graphApp.setDefaults(self.grid_on, self.legend_on, |
---|
| 806 | self.xaxis_label, self.yaxis_label, |
---|
| 807 | self.xaxis_unit, self.yaxis_unit, |
---|
| 808 | self.xaxis_font, self.yaxis_font, |
---|
| 809 | find_key(self.get_loc_label(), self.legendLoc), |
---|
| 810 | self.xcolor, self.ycolor, |
---|
[657e52c] | 811 | self.is_xtick, self.is_ytick) |
---|
[9f51c2c] | 812 | self.graphApp.Bind(wx.EVT_CLOSE, self.on_graphApp_close) |
---|
[8f59e95] | 813 | |
---|
[9f51c2c] | 814 | def on_graphApp_close(self, event): |
---|
[83d9120] | 815 | """ |
---|
| 816 | Gets values from graph appearance dialog and sends them off |
---|
| 817 | to modify the plot |
---|
| 818 | """ |
---|
| 819 | graph_app = self.graphApp |
---|
| 820 | toggle_grid = graph_app.get_togglegrid() |
---|
| 821 | legend_loc = graph_app.get_legend_loc() |
---|
| 822 | toggle_legend = graph_app.get_togglelegend() |
---|
[090e07e] | 823 | |
---|
| 824 | self.onGridOnOff(toggle_grid) |
---|
[83d9120] | 825 | self.ChangeLegendLoc(legend_loc) |
---|
| 826 | self.onLegend(toggle_legend) |
---|
[8a687cfd] | 827 | |
---|
[83d9120] | 828 | self.xaxis_label = graph_app.get_xlab() |
---|
| 829 | self.yaxis_label = graph_app.get_ylab() |
---|
| 830 | self.xaxis_unit = graph_app.get_xunit() |
---|
| 831 | self.yaxis_unit = graph_app.get_yunit() |
---|
[657e52c] | 832 | self.xaxis_font = graph_app.get_xfont() |
---|
| 833 | self.yaxis_font = graph_app.get_yfont() |
---|
[090e07e] | 834 | self.is_xtick = graph_app.get_xtick_check() |
---|
| 835 | self.is_ytick = graph_app.get_ytick_check() |
---|
[657e52c] | 836 | if self.is_xtick: |
---|
| 837 | self.xaxis_tick = self.xaxis_font |
---|
| 838 | if self.is_ytick: |
---|
| 839 | self.yaxis_tick = self.yaxis_font |
---|
[8a687cfd] | 840 | |
---|
[090e07e] | 841 | self.xaxis(self.xaxis_label, self.xaxis_unit, |
---|
| 842 | graph_app.get_xfont(), graph_app.get_xcolor(), |
---|
[657e52c] | 843 | self.xaxis_tick) |
---|
[090e07e] | 844 | self.yaxis(self.yaxis_label, self.yaxis_unit, |
---|
[657e52c] | 845 | graph_app.get_yfont(), graph_app.get_ycolor(), |
---|
| 846 | self.yaxis_tick) |
---|
[8f59e95] | 847 | |
---|
[83d9120] | 848 | graph_app.Destroy() |
---|