Changeset 7434020 in sasview for sansguiframe/src
- Timestamp:
- Jan 17, 2012 3:07:33 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:
- 4e65505
- Parents:
- f706e09c
- Location:
- sansguiframe/src/sans/guiframe
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_panel.py
r98fdccd r7434020 387 387 import MaskPanel as MaskDialog 388 388 389 panel = MaskDialog(base=self, data=data, id=wx.NewId()) 389 panel = MaskDialog(parent=self.parent, base=self, 390 data=data, id=wx.NewId()) 390 391 #self.panel.Bind(wx.EVT_CLOSE, self._draw_masked_model) 391 392 panel.ShowModal() 393 394 def on_plot_3d(self, event): 395 """ 396 Frozen image of 3D 397 """ 398 data = self._get_data_selection(event) 399 from sans.guiframe.local_perspectives.plotting.masking \ 400 import FloatPanel as Float3dDialog 401 402 panel = Float3dDialog(base=self, data=data, 403 dimension=3, id=wx.NewId()) 404 panel.ShowModal() 405 406 def on_quick_plot(self, event): 407 """ 408 Frozen plot 409 """ 410 data = self._get_data_selection(event) 411 from sans.guiframe.local_perspectives.plotting.masking \ 412 import FloatPanel as QucikPlotDialog 413 if data.__class__.__name__ == "Data2D": 414 dimension = 2 415 else: 416 dimension = 1 417 panel = QucikPlotDialog(base=self, data=data, 418 dimension=dimension, id=wx.NewId()) 419 panel.ShowModal() 392 420 393 421 def on_save_as(self, event): … … 426 454 wx.EVT_MENU(self, id, self.on_save_as) 427 455 456 self.quickplot_id = wx.NewId() 457 name = "Quick Plot" 458 msg = "Plot the current Data" 459 self.data_menu.Append(self.quickplot_id, name, msg) 460 wx.EVT_MENU(self, self.quickplot_id, self.on_quick_plot) 461 462 self.plot3d_id = wx.NewId() 463 name = "Quick 3DPlot (Slow)" 464 msg = "Plot3D the current 2D Data" 465 self.data_menu.Append(self.plot3d_id, name, msg) 466 wx.EVT_MENU(self, self.plot3d_id, self.on_plot_3d) 467 428 468 self.editmask_id = wx.NewId() 429 469 name = "Edit Mask" … … 431 471 self.data_menu.Append(self.editmask_id, name, msg) 432 472 wx.EVT_MENU(self, self.editmask_id, self.on_edit_data) 433 473 434 474 tree_ctrl_theory_label = wx.StaticText(self, -1, "Theory") 435 475 tree_ctrl_theory_label.SetForegroundColour('blue') … … 474 514 return 475 515 if self.data_menu is not None: 476 menu_enable = (data_class_name == "Data2D" and is_data) 477 self.data_menu.Enable(self.editmask_id, menu_enable) 516 menu_enable = (data_class_name == "Data2D") 517 maskmenu_enable = (menu_enable and is_data) 518 self.data_menu.Enable(self.editmask_id, maskmenu_enable) 519 self.data_menu.Enable(self.plot3d_id, menu_enable) 478 520 self.PopupMenu(self.data_menu) 479 521 -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/masking.py
r02aff3d r7434020 25 25 from danse.common.plottools.plottables import Graph 26 26 from binder import BindArtist 27 from sans.guiframe.dataFitting import Data 2D27 from sans.guiframe.dataFitting import Data1D, Data2D 28 28 from boxMask import BoxMask 29 29 from sectorMask import SectorMask … … 57 57 data=None, id=-1, *args, **kwds): 58 58 kwds["style"] = wx.DEFAULT_DIALOG_STYLE 59 kwds["size"] = wx.Size(_STATICBOX_WIDTH * 2, PANEL_SIZE)59 kwds["size"] = wx.Size(_STATICBOX_WIDTH*0.8, PANEL_SIZE) 60 60 wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 61 61 … … 508 508 # when called by data panel 509 509 event.Skip() 510 pass 511 512 class FloatPanel(wx.Dialog): 513 """ 514 Provides the Mask Editor GUI. 515 """ 516 ## Internal nickname for the window, used by the AUI manager 517 window_name = "Plot" 518 ## Name to appear on the window title bar 519 window_caption = "Plot" 520 ## Flag to tell the AUI manager to put this panel in the center pane 521 CENTER_PANE = True 522 def __init__(self, parent=None, base=None, 523 data=None, dimension=1, id=-1, *args, **kwds): 524 kwds["style"] = wx.DEFAULT_DIALOG_STYLE 525 kwds["size"] = wx.Size(_STATICBOX_WIDTH*1.3, PANEL_SIZE*1.3) 526 wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 527 528 if data != None: 529 #Font size 530 kwds = [] 531 self.SetWindowVariant(variant=FONT_VARIANT) 532 self.SetTitle("Plot " + data.name) 533 self.parent = base 534 self.data = data 535 self.str = self.data.__str__() 536 ## when 2 data have the same id override the 1 st plotted 537 self.name = self.data.name 538 self.dimension = dimension 539 # Panel for 2D plot 540 self.plotpanel = Maskplotpanel(self, -1, dimension, 541 style=wx.TRANSPARENT_WINDOW) 542 543 self.cmap = DEFAULT_CMAP 544 ## Create Artist and bind it 545 self.subplot = self.plotpanel.subplot 546 self._setup_layout() 547 if self.dimension == 1: 548 self.newplot = Data1D(x=data.x, y=data.y, 549 dx=data.dx, dy=data.dy) 550 self.newplot.name = data.name 551 else: 552 self.newplot = Data2D(image=self.data.data) 553 self.newplot.setValues(self.data) 554 555 self.plotpanel.add_image(self.newplot) 556 self.Centre() 557 self.Layout() 558 559 560 def _setup_layout(self): 561 """ 562 Set up the layout 563 """ 564 # panel 565 sizer = wx.GridBagSizer(10, 10) 566 if self.dimension == 3: 567 note = "Note: I am very SLOW. Please be PATIENT...\n" 568 note_txt = wx.StaticText(self, -1, note) 569 note_txt.SetForegroundColour(wx.RED) 570 sizer.Add(note_txt, (0, 2), flag=wx.RIGHT|wx.BOTTOM, border=5) 571 572 sizer.Add(self.plotpanel, (1, 1), (9, 9), 573 wx.EXPAND|wx.ALL, 15) 574 575 sizer.AddGrowableCol(3) 576 sizer.AddGrowableRow(2) 577 578 self.SetSizerAndFit(sizer) 579 self.Centre() 580 self.Show(True) 581 582 def set_plot_unfocus(self): 583 """ 584 Not implemented 585 """ 586 pass 587 588 589 def _draw_model(self, event): 590 """ 591 on_close, update the model2d plot 592 """ 593 pass 594 595 def freeze_axes(self): 596 """ 597 freeze axes 598 """ 599 self.plotpanel.axes_frozen = True 600 601 def thaw_axes(self): 602 """ 603 thaw axes 604 """ 605 self.plotpanel.axes_frozen = False 606 607 def OnClose(self, event): 608 """ 609 """ 610 try: 611 self.plotpanel.subplot.figure.clf() 612 except: 613 # when called by data panel 614 event.Skip() 510 615 pass 511 616 617 512 618 class Maskplotpanel(PlotPanel): 513 619 """ 620 PlotPanel for Quick plot and masking plot 514 621 """ 515 def __init__(self, parent, id=-1, color=None, dpi=None, **kwargs): 622 def __init__(self, parent, id=-1, dimension=2, color=None, 623 dpi=None, **kwargs): 516 624 """ 517 625 """ … … 522 630 # Internal list of plottable names (because graph 523 631 # doesn't have a dictionary of handles for the plottables) 632 self.dimension = dimension 524 633 self.plots = {} 525 634 self.graph = Graph() 635 #add axis labels 636 if self.dimension == 1: 637 self.graph.xaxis('\\rm{x} ', '') 638 self.graph.yaxis('\\rm{y} ', '') 639 if self.dimension == 2: 640 self.graph.xaxis('\\rm{Q}_{x} ', 'A^{-1}') 641 self.graph.yaxis('\\rm{Q}_{y} ', 'A^{-1}') 526 642 527 643 def add_toolbar(self): … … 531 647 # Not implemented 532 648 pass 649 533 650 def on_set_focus(self, event): 534 651 """ 535 652 send to the parenet the current panel on focus 536 653 """ 537 #change the panel background 538 #self.SetColor((170, 202, 255)) 539 self.draw() 654 if self.dimension == 3: 655 pass 656 else: 657 self.draw() 540 658 541 659 def add_image(self, plot): … … 549 667 self.graph.add(plot) 550 668 #add axes 551 self.graph.xaxis('\\rm{Q}_{x} ', 'A^{-1}') 552 self.graph.yaxis('\\rm{Q}_{y} ', 'A^{-1}') 669 if self.dimension == 1: 670 self.xaxis_label = '\\rm{x} ' 671 self.xaxis_unit = '' 672 self.yaxis_label = '\\rm{y} ' 673 self.yaxis_unit = '' 553 674 #draw 675 # message 676 status_type = 'progress' 677 msg = 'Plotting...' 678 self._status_info(msg, status_type) 679 status_type = 'stop' 680 554 681 self.graph.render(self) 555 self.subplot.figure.canvas.draw_idle() 682 if self.dimension == 3: 683 pass 684 else: 685 self.subplot.figure.canvas.draw_idle() 686 msg = 'Plotting Completed.' 687 self._status_info(msg, status_type) 556 688 557 689 def onMouseMotion(self, event): … … 560 692 """ 561 693 pass 562 694 695 def onWheel(self, event): 696 """ 697 """ 698 pass 699 700 def onLeftDown(self, event): 701 """ 702 Disables LeftDown 703 """ 704 pass 705 706 def onPick(self, event): 707 """ 708 Disables OnPick 709 """ 710 pass 711 712 def draw(self): 713 """ 714 Draw 715 """ 716 # message 717 status_type = 'progress' 718 msg = 'Plotting...' 719 self._status_info(msg, status_type) 720 status_type = 'stop' 721 722 if self.dimension == 3: 723 pass 724 else: 725 self.subplot.figure.canvas.draw_idle() 726 727 msg = 'Plotting Completed.' 728 self._status_info(msg, status_type) 729 563 730 def onContextMenu(self, event): 564 731 """ 565 732 Default context menu for a plot panel 566 733 """ 567 # S licer plot popup menu734 # Selective Slicer plot popup menu 568 735 slicerpop = wx.Menu() 569 736 570 id_cm = wx.NewId() 571 slicerpop.Append(id_cm, '&Toggle Linear/Log scale') 572 wx.EVT_MENU(self, id_cm, self._onToggleScale) 737 id = wx.NewId() 738 slicerpop.Append(id,'&Print Image', 'Print image') 739 wx.EVT_MENU(self, id, self.onPrint) 740 741 id = wx.NewId() 742 slicerpop.Append(id, '&Copy to Clipboard', 'Copy to the clipboard') 743 wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 744 745 if self.dimension == 1: 746 id = wx.NewId() 747 slicerpop.Append(id, '&Change Scale') 748 wx.EVT_MENU(self, id, self._onProperties) 749 else: 750 slicerpop.AppendSeparator() 751 id_cm = wx.NewId() 752 slicerpop.Append(id_cm, '&Toggle Linear/Log scale') 753 wx.EVT_MENU(self, id_cm, self._onToggleScale) 573 754 574 755 pos = event.GetPosition() 575 756 pos = self.ScreenToClient(pos) 576 757 self.PopupMenu(slicerpop, pos) 758 759 def _status_info(self, msg = '', type = "update"): 760 """ 761 Status msg 762 """ 763 if type == "stop": 764 label = "Plotting..." 765 able = True 766 else: 767 label = "Wait..." 768 able = False 769 if self.parent.parent.parent != None: 770 wx.PostEvent(self.parent.parent.parent, 771 StatusEvent(status = msg, type = type )) 577 772 578 773 class ViewerFrame(wx.Frame):
Note: See TracChangeset
for help on using the changeset viewer.