Changeset 7434020 in sasview for sansguiframe/src/sans/guiframe/local_perspectives
- Timestamp:
- Jan 17, 2012 1: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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.