Changeset 7434020 in sasview
- 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
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/model_editor.py
rb25caad r7434020 257 257 self.name_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1)) 258 258 self.name_tcl.Bind(wx.EVT_TEXT_ENTER, self.on_change_name) 259 self.name_tcl.SetValue(' untitled')259 self.name_tcl.SetValue('MyFunction') 260 260 self.name_tcl.SetFont(self.font) 261 261 hint_name = "Unique Model Function Name." -
plottools/src/danse/common/plottools/PlotPanel.py
rf80236f r7434020 21 21 from binder import BindArtist 22 22 from matplotlib.font_manager import FontProperties 23 24 from mpl_toolkits.mplot3d import Axes3D 25 #from matplotlib import cm 26 #from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter 23 27 24 28 DEBUG = False … … 119 123 wx.Panel.__init__(self, parent, id=id, **kwargs) 120 124 self.parent = parent 125 self.dimension = 1 121 126 self.gotLegend = 0 #to begin, legend is not picked. 122 127 self.legend_pos_loc = None … … 1427 1432 1428 1433 """ 1429 #Re-adjust colorbar1430 self.figure.subplots_adjust(left=0.2, right=.8, bottom=.2)1431 1434 self.data = data 1432 1435 self.qx_data = qx_data … … 1470 1473 zmin_temp = self.zmin_2D 1471 1474 self.cmap = cmap 1472 im = self.subplot.imshow(output, interpolation='nearest', 1473 origin='lower', 1474 vmin=zmin_temp, vmax=self.zmax_2D, 1475 cmap=self.cmap, 1476 extent=(self.xmin_2D, self.xmax_2D, 1477 self.ymin_2D, self.ymax_2D)) 1478 1479 #Add color bar and its label 1480 #TODO: make the size and location interactive to the image plot. 1481 cbax = self.subplot.figure.add_axes([0.84,0.2,0.02,0.7]) 1482 cb = self.subplot.figure.colorbar(im, cax=cbax) 1475 if self.dimension != 3: 1476 #Re-adjust colorbar 1477 self.subplot.figure.subplots_adjust(left=0.2, right=.8, bottom=.2) 1478 1479 im = self.subplot.imshow(output, interpolation='nearest', 1480 origin='lower', 1481 vmin=zmin_temp, vmax=self.zmax_2D, 1482 cmap=self.cmap, 1483 extent=(self.xmin_2D, self.xmax_2D, 1484 self.ymin_2D, self.ymax_2D)) 1485 cbax = self.subplot.figure.add_axes([0.84,0.2,0.02,0.7]) 1486 else: 1487 # clear the previous 2D from memory 1488 self.subplot.figure.clf() 1489 self.subplot.figure.subplots_adjust(left=0.1, right=.8, bottom=.1) 1490 try: 1491 # mpl >= 1.0.0 1492 ax = self.subplot.figure.gca(projection='3d') 1493 #ax.disable_mouse_rotation() 1494 cbax = self.subplot.figure.add_axes([0.84,0.1,0.02,0.8]) 1495 except: 1496 # mpl < 1.0.0 1497 ax = Axes3D(self.subplot.figure) 1498 cbax = None 1499 1500 X = self.x_bins[0:-1] 1501 Y = self.y_bins[0:-1] 1502 X, Y = numpy.meshgrid(X, Y) 1503 1504 im = ax.plot_surface(X, Y, output, rstride=1, cstride=1, cmap=cmap, 1505 linewidth=0, antialiased=False) 1506 #ax.set_zlim3d(zmin_temp, self.zmax_2D) 1507 #ax.set_frame_on(False) 1508 self.subplot.set_axis_off() 1509 1510 if cbax == None: 1511 cb =self.subplot.figure.colorbar(im, shrink=0.6, aspect=20) 1512 else: 1513 cb =self.subplot.figure.colorbar(im, cax=cbax) 1483 1514 cb.update_bruteforce(im) 1484 1515 cb.set_label(self.scale) 1485 self.subplot.figure.canvas.draw_idle() 1516 1517 #if self.dimension != 3: 1518 self.figure.canvas.draw_idle() 1486 1519 1487 1520 def _build_matrix(self): -
plottools/src/danse/common/plottools/canvas.py
r0e553fd r7434020 250 250 251 251 """ 252 if sys.platform == 'linux2' :252 if sys.platform == 'linux2' or self.panel.dimension == 3: 253 253 evt.Skip() 254 254 else: -
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.