Changeset 70ec588d in sasview
- Timestamp:
- Jan 10, 2012 12:42:28 PM (13 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 592cb156
- Parents:
- cfe1feb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plottools/src/danse/common/plottools/PlotPanel.py
r0e553fd r70ec588d 265 265 # check if zoomed. 266 266 self.is_zoomed = False 267 # Plottables 268 self.plots = {} 267 269 268 270 # Default locations … … 640 642 """ 641 643 list = {} 644 menu = event.GetEventObject() 645 id = event.GetId() 646 self.set_selected_from_menu(menu, id) 642 647 plotlist = self.graph.returnPlottable() 643 648 if self.graph.selected_plottable is not None: … … 661 666 self.xmin, self.xmax) 662 667 dlg.ShowModal() 663 668 669 def set_selected_from_menu(self, menu, id): 670 """ 671 Set selected_plottable from context menu selection 672 673 :param menu: context menu item 674 :param id: menu item id 675 """ 676 if len(self.plots) < 1: 677 return 678 name = menu.GetHelpString(id) 679 for plot in self.plots.values(): 680 if plot.name == name: 681 self.graph.selected_plottable = plot.id 682 break 683 664 684 def linear_plottable_fit(self, plot): 665 685 """ … … 917 937 # reset postion 918 938 self.position = None 939 if self.graph.selected_plottable != None: 940 self.graph.selected_plottable = None 919 941 920 942 self.onContextMenu(event) -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter1D.py
r176fbf1 r70ec588d 318 318 Toggle error display to hide or show 319 319 """ 320 menu = event.GetEventObject() 321 id = event.GetId() 322 self.set_selected_from_menu(menu, id) 320 323 # Check zoom 321 324 xlo, xhi = self.subplot.get_xlim() … … 345 348 346 349 """ 350 menu = event.GetEventObject() 351 id = event.GetId() 352 self.set_selected_from_menu(menu, id) 347 353 ## Check if there is a selected graph to remove 348 354 if self.graph.selected_plottable in self.plots.keys(): … … 360 366 self._slicerpop = PanelMenu() 361 367 self._slicerpop.set_plots(self.plots) 362 self._slicerpop.set_graph(self.graph) 363 # Various plot options 364 id = wx.NewId() 365 self._slicerpop.Append(id, '&Save Image', 'Save image as PNG') 366 wx.EVT_MENU(self, id, self.onSaveImage) 367 id = wx.NewId() 368 self._slicerpop.Append(id, '&Print Image', 'Print image ') 369 wx.EVT_MENU(self, id, self.onPrint) 370 id = wx.NewId() 371 self._slicerpop.Append(id, '&Print Preview', 'Print preview') 372 wx.EVT_MENU(self, id, self.onPrinterPreview) 373 374 id = wx.NewId() 375 self._slicerpop.Append(id, '&Copy to Clipboard', 'Copy to the clipboard') 376 wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 377 378 self._slicerpop.AppendSeparator() 379 380 #add menu of other plugins 381 item_list = self.parent.get_context_menu(self) 382 383 if (not item_list == None) and (not len(item_list) == 0): 384 for item in item_list: 385 try: 386 id = wx.NewId() 387 self._slicerpop.Append(id, item[0], item[1]) 388 wx.EVT_MENU(self, id, item[2]) 389 except: 390 msg = "ModelPanel1D.onContextMenu: " 391 msg += "bad menu item %s" % sys.exc_value 392 wx.PostEvent(self.parent, StatusEvent(status=msg)) 393 pass 368 self._slicerpop.set_graph(self.graph) 369 if not self.graph.selected_plottable in self.plots: 370 # Various plot options 371 id = wx.NewId() 372 self._slicerpop.Append(id, '&Save Image', 'Save image as PNG') 373 wx.EVT_MENU(self, id, self.onSaveImage) 374 id = wx.NewId() 375 self._slicerpop.Append(id, '&Print Image', 'Print image ') 376 wx.EVT_MENU(self, id, self.onPrint) 377 id = wx.NewId() 378 self._slicerpop.Append(id, '&Print Preview', 'Print preview') 379 wx.EVT_MENU(self, id, self.onPrinterPreview) 380 381 id = wx.NewId() 382 self._slicerpop.Append(id, '&Copy to Clipboard', 'Copy to the clipboard') 383 wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 384 394 385 self._slicerpop.AppendSeparator() 395 #id = wx.NewId() 396 #self._slicerpop.Append(id, '&Print image', 'Print image') 397 if self.graph.selected_plottable in self.plots: 398 plot = self.plots[self.graph.selected_plottable] 399 400 id = wx.NewId() 386 387 for plot in self.plots.values(): 388 #title = plot.title 401 389 name = plot.name 402 self._slicerpop.Append(id, "&Save Points as a File") 390 plot_menu = wx.Menu() 391 #plot = self.plots[self.graph.selected_plottable] 392 #add menu of other plugins 393 item_list = self.parent.get_context_menu(self) 394 395 if (not item_list == None) and (not len(item_list) == 0): 396 for item in item_list: 397 try: 398 id = wx.NewId() 399 plot_menu.Append(id, item[0], name) 400 wx.EVT_MENU(self, id, item[2]) 401 except: 402 msg = "ModelPanel1D.onContextMenu: " 403 msg += "bad menu item %s" % sys.exc_value 404 wx.PostEvent(self.parent, StatusEvent(status=msg)) 405 pass 406 plot_menu.AppendSeparator() 407 408 id = wx.NewId() 409 plot_menu.Append(id, "&Save Points as a File", name) 403 410 wx.EVT_MENU(self, id, self._onSave) 404 self._slicerpop.AppendSeparator()411 plot_menu.AppendSeparator() 405 412 if self.parent.ClassName.count('wxDialog') == 0: 406 413 id = wx.NewId() 407 self._slicerpop.Append(id, '&Linear Fit')414 plot_menu.Append(id, '&Linear Fit', name) 408 415 wx.EVT_MENU(self, id, self.onFitting) 409 self._slicerpop.AppendSeparator()410 411 id = wx.NewId() 412 self._slicerpop.Append(id, "Remove %s Curve" %name)416 plot_menu.AppendSeparator() 417 418 id = wx.NewId() 419 plot_menu.Append(id, "Remove", name) 413 420 wx.EVT_MENU(self, id, self._onRemove) 414 421 if not plot.is_data: 415 422 id = wx.NewId() 416 self._slicerpop.Append(id, '&Freeze', 'Freeze')423 plot_menu.Append(id, '&Freeze', name) 417 424 wx.EVT_MENU(self, id, self.onFreeze) 418 self._slicerpop.AppendSeparator()425 plot_menu.AppendSeparator() 419 426 symbol_menu = wx.Menu() 420 427 for label in self._symbol_labels: 421 428 id = wx.NewId() 422 symbol_menu.Append(id, str(label), str(label))429 symbol_menu.Append(id, str(label), name) 423 430 wx.EVT_MENU(self, id, self.onChangeSymbol) 424 431 id = wx.NewId() 425 self._slicerpop.AppendMenu(id,'&Modify Symbol', symbol_menu)432 plot_menu.AppendMenu(id,'&Modify Symbol', symbol_menu, name) 426 433 427 434 color_menu = wx.Menu() 428 435 for label in self._color_labels: 429 436 id = wx.NewId() 430 color_menu.Append(id, str(label), str(label))437 color_menu.Append(id, str(label), name) 431 438 wx.EVT_MENU(self, id, self.onChangeColor) 432 439 id = wx.NewId() 433 self._slicerpop.AppendMenu(id, '&Modify Symbol Color', color_menu) 440 plot_menu.AppendMenu(id, '&Modify Symbol Color', 441 color_menu, name) 434 442 435 443 size_menu = wx.Menu() 436 444 for i in range(10): 437 445 id = wx.NewId() 438 size_menu.Append(id, str(i), str(i))446 size_menu.Append(id, str(i), name) 439 447 wx.EVT_MENU(self, id, self.onChangeSize) 440 448 id = wx.NewId() 441 size_menu.Append(id, '&Custom', 'Custom')449 size_menu.Append(id, '&Custom', name) 442 450 wx.EVT_MENU(self, id, self.onChangeSize) 443 451 id = wx.NewId() 444 self._slicerpop.AppendMenu(id, '&Modify Symbol Size', size_menu) 452 plot_menu.AppendMenu(id, '&Modify Symbol Size', 453 size_menu, name) 445 454 446 self.hide_menu = self._slicerpop.Append(id, "Hide Error Bar") 447 448 if plot.dy is not None and plot.dy != []: 449 if plot.hide_error : 450 self.hide_menu.SetText('Show Error Bar') 455 if plot.is_data: 456 self.hide_menu = plot_menu.Append(id, 457 "Hide Error Bar", name) 458 459 if plot.dy is not None and plot.dy != []: 460 if plot.hide_error : 461 self.hide_menu.SetText('Show Error Bar') 462 else: 463 self.hide_menu.SetText('Hide Error Bar') 451 464 else: 452 self.hide_menu.SetText('Hide Error Bar') 453 else: 454 self.hide_menu.Enable(False) 455 wx.EVT_MENU(self, id, self._ontoggle_hide_error) 465 self.hide_menu.Enable(False) 466 wx.EVT_MENU(self, id, self._ontoggle_hide_error) 456 467 457 self._slicerpop.AppendSeparator()458 id = wx.NewId() 459 self._slicerpop.Append(id, '&Edit Legend Label', 'Edit Legend Label')468 plot_menu.AppendSeparator() 469 id = wx.NewId() 470 plot_menu.Append(id, '&Edit Legend Label', name) 460 471 wx.EVT_MENU(self, id, self.onEditLabels) 472 id = wx.NewId() 473 #plot_menu.SetTitle(name) 474 self._slicerpop.AppendMenu(id, '&%s'% name, plot_menu) 461 475 # Option to hide 462 476 #TODO: implement functionality to hide a plottable (legend click) 463 464 loc_menu = wx.Menu() 465 for label in self._loc_labels: 466 id = wx.NewId() 467 loc_menu.Append(id, str(label), str(label)) 468 wx.EVT_MENU(self, id, self.onChangeLegendLoc) 469 id = wx.NewId() 470 self._slicerpop.AppendMenu(id, '&Modify Legend Location', loc_menu) 471 472 id = wx.NewId() 473 self._slicerpop.Append(id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 474 wx.EVT_MENU(self, id, self.onLegend) 475 self._slicerpop.AppendSeparator() 476 477 id = wx.NewId() 478 self._slicerpop.Append(id, '&Edit Y Axis Label') 479 wx.EVT_MENU(self, id, self._on_yaxis_label) 480 id = wx.NewId() 481 self._slicerpop.Append(id, '&Edit X Axis Label') 482 wx.EVT_MENU(self, id, self._on_xaxis_label) 483 484 id = wx.NewId() 485 self._slicerpop.Append(id, '&Toggle Grid On/Off', 'Toggle Grid On/Off') 486 wx.EVT_MENU(self, id, self.onGridOnOff) 487 self._slicerpop.AppendSeparator() 488 489 if self.position != None: 490 id = wx.NewId() 491 self._slicerpop.Append(id, '&Add Text') 492 wx.EVT_MENU(self, id, self._on_addtext) 493 id = wx.NewId() 494 self._slicerpop.Append(id, '&Remove Text') 495 wx.EVT_MENU(self, id, self._on_removetext) 477 if not self.graph.selected_plottable in self.plots: 496 478 self._slicerpop.AppendSeparator() 497 id = wx.NewId() 498 self._slicerpop.Append(id, '&Change Scale') 499 wx.EVT_MENU(self, id, self._onProperties) 500 self._slicerpop.AppendSeparator() 501 id = wx.NewId() 502 self._slicerpop.Append(id, '&Reset Graph Range') 503 wx.EVT_MENU(self, id, self.onResetGraph) 479 loc_menu = wx.Menu() 480 for label in self._loc_labels: 481 id = wx.NewId() 482 loc_menu.Append(id, str(label), str(label)) 483 wx.EVT_MENU(self, id, self.onChangeLegendLoc) 484 id = wx.NewId() 485 self._slicerpop.AppendMenu(id, '&Modify Legend Location', loc_menu) 486 487 id = wx.NewId() 488 self._slicerpop.Append(id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 489 wx.EVT_MENU(self, id, self.onLegend) 490 self._slicerpop.AppendSeparator() 491 492 id = wx.NewId() 493 self._slicerpop.Append(id, '&Edit Y Axis Label') 494 wx.EVT_MENU(self, id, self._on_yaxis_label) 495 id = wx.NewId() 496 self._slicerpop.Append(id, '&Edit X Axis Label') 497 wx.EVT_MENU(self, id, self._on_xaxis_label) 498 499 id = wx.NewId() 500 self._slicerpop.Append(id, '&Toggle Grid On/Off', 'Toggle Grid On/Off') 501 wx.EVT_MENU(self, id, self.onGridOnOff) 502 self._slicerpop.AppendSeparator() 503 504 if self.position != None: 505 id = wx.NewId() 506 self._slicerpop.Append(id, '&Add Text') 507 wx.EVT_MENU(self, id, self._on_addtext) 508 id = wx.NewId() 509 self._slicerpop.Append(id, '&Remove Text') 510 wx.EVT_MENU(self, id, self._on_removetext) 511 self._slicerpop.AppendSeparator() 512 id = wx.NewId() 513 self._slicerpop.Append(id, '&Change Scale') 514 wx.EVT_MENU(self, id, self._onProperties) 515 self._slicerpop.AppendSeparator() 516 id = wx.NewId() 517 self._slicerpop.Append(id, '&Reset Graph Range') 518 wx.EVT_MENU(self, id, self.onResetGraph) 519 520 if self.parent.ClassName.count('wxDialog') == 0: 521 self._slicerpop.AppendSeparator() 522 id = wx.NewId() 523 self._slicerpop.Append(id, '&Window Title') 524 wx.EVT_MENU(self, id, self.onChangeCaption) 504 525 try: 505 526 pos_evt = event.GetPosition() … … 508 529 pos_x, pos_y = self.toolbar.GetPositionTuple() 509 530 pos = (pos_x, pos_y + 5) 510 511 if self.parent.ClassName.count('wxDialog') == 0:512 self._slicerpop.AppendSeparator()513 id = wx.NewId()514 self._slicerpop.Append(id, '&Window Title')515 wx.EVT_MENU(self, id, self.onChangeCaption)516 517 531 self.PopupMenu(self._slicerpop, pos) 518 532 519 533 def onFreeze(self, event): 520 534 """ 521 535 """ 536 menu = event.GetEventObject() 537 id = event.GetId() 538 self.set_selected_from_menu(menu, id) 522 539 plot = self.plots[self.graph.selected_plottable] 523 540 self.parent.onfreeze([plot.id]) … … 527 544 Edit legend label 528 545 """ 546 menu = event.GetEventObject() 547 id = event.GetId() 548 self.set_selected_from_menu(menu, id) 529 549 selected_plot = self.plots[self.graph.selected_plottable] 530 550 label = selected_plot.label … … 557 577 menu = event.GetEventObject() 558 578 id = event.GetId() 579 self.set_selected_from_menu(menu, id) 559 580 label = menu.GetLabel(id) 560 581 selected_plot = self.plots[self.graph.selected_plottable] … … 568 589 569 590 def onChangeSize(self, event): 570 591 """ 592 On Change size menu 593 """ 571 594 menu = event.GetEventObject() 572 595 id = event.GetId() 596 self.set_selected_from_menu(menu, id) 573 597 label = menu.GetLabel(id) 574 598 selected_plot = self.plots[self.graph.selected_plottable] … … 599 623 menu = event.GetEventObject() 600 624 id = event.GetId() 625 self.set_selected_from_menu(menu, id) 601 626 label = menu.GetLabel(id) 602 627 selected_plot = self.plots[self.graph.selected_plottable] … … 616 641 617 642 """ 643 menu = evt.GetEventObject() 644 id = evt.GetId() 645 self.set_selected_from_menu(menu, id) 618 646 data = self.plots[self.graph.selected_plottable] 619 647 default_name = data.label
Note: See TracChangeset
for help on using the changeset viewer.