Index: guiframe/local_perspectives/plotting/__init__.py
===================================================================
--- guiframe/local_perspectives/plotting/__init__.py	(revision 41d466f6e37304375ace192af8fba17283851239)
+++ guiframe/local_perspectives/plotting/__init__.py	(revision 41d466f6e37304375ace192af8fba17283851239)
@@ -0,0 +1,2 @@
+PLUGIN_ID = "Plotting plug-in 1.0"
+from plotting import *
Index: guiframe/local_perspectives/plotting/plotting.py
===================================================================
--- guiframe/local_perspectives/plotting/plotting.py	(revision 41d466f6e37304375ace192af8fba17283851239)
+++ guiframe/local_perspectives/plotting/plotting.py	(revision 41d466f6e37304375ace192af8fba17283851239)
@@ -0,0 +1,241 @@
+"""
+This software was developed by the University of Tennessee as part of the
+Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+project funded by the US National Science Foundation. 
+
+See the license text in license.txt
+
+copyright 2008, University of Tennessee
+"""
+
+
+import wx
+import sys
+from sans.guitools.PlotPanel import PlotPanel
+from sans.guitools.plottables import Graph
+from sans.guicomm.events import EVT_NEW_PLOT
+
+class PanelMenu(wx.Menu):
+    plots = None
+    
+    def set_plots(self, plots):
+        self.plots = plots
+    
+
+class View1DPanel(PlotPanel):
+    """
+        Plot panel for use with the GUI manager
+    """
+    
+    ## Internal name for the AUI manager
+    window_name = "plotpanel"
+    ## Title to appear on top of the window
+    window_caption = "Plot Panel"
+    ## Flag to tell the GUI manager that this panel is not
+    #  tied to any perspective
+    ALWAYS_ON = True
+    
+    def __init__(self, parent, id = -1, color = None,\
+        dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
+        """
+            Initialize the panel
+        """
+        PlotPanel.__init__(self, parent, id = id, style = style, **kwargs)
+        
+        ## Reference to the parent window
+        self.parent = parent
+        ## Plottables
+        self.plots = {}
+        
+        ## Unique ID (from gui_manager)
+        self.uid = None
+        
+        ## Graph        
+        self.graph = Graph()
+        self.graph.xaxis("\\rm{Q}", 'A^{-1}')
+        self.graph.yaxis("\\rm{Intensity} ","cm^{-1}")
+        self.graph.render(self)
+        
+    def _onEVT_1DREPLOT(self, event):
+        """
+            Data is ready to be displayed
+            @param event: data event
+        """
+        #TODO: Check for existence of plot attribute
+        
+        is_new = True
+        if event.plot.name in self.plots.keys():
+            is_new = False
+        
+        if is_new:
+            self.plots[event.plot.name] = event.plot
+            self.graph.add(self.plots[event.plot.name])
+        else:
+            self.plots[event.plot.name].x = event.plot.x    
+            self.plots[event.plot.name].y = event.plot.y    
+            self.plots[event.plot.name].dy = event.plot.dy  
+            if hasattr(event.plot, 'dx') and hasattr(self.plots[event.plot.name], 'dx'):
+                self.plots[event.plot.name].dx = event.plot.dx    
+ 
+        
+        # Check axis labels
+        #TODO: Should re-factor this
+        if event.plot._xunit != self.graph.prop["xunit"]:
+            self.graph.xaxis(event.plot._xaxis, event.plot._xunit)
+            
+        if event.plot._yunit != self.graph.prop["yunit"]:
+            self.graph.yaxis(event.plot._yaxis, event.plot._yunit)
+      
+        self.graph.render(self)
+        self.subplot.figure.canvas.draw_idle()
+
+    def onContextMenu(self, event):
+        """
+            1D plot context menu
+            @param event: wx context event
+        """
+        #slicerpop = wx.Menu()
+        slicerpop = PanelMenu()
+        slicerpop.set_plots(self.plots)
+                
+        # Various plot options
+        id = wx.NewId()
+        slicerpop.Append(id,'&Save image', 'Save image as PNG')
+        wx.EVT_MENU(self, id, self.onSaveImage)
+        
+        slicerpop.AppendSeparator()
+        item_list = self.parent.get_context_menu()
+        if not item_list==None:
+            for item in item_list:
+                try:
+                    id = wx.NewId()
+                    slicerpop.Append(id, item[0], item[1])
+                    wx.EVT_MENU(self, id, item[2])
+                except:
+                    print sys.exc_value
+                    print RuntimeError, "View1DPanel.onContextMenu: bad menu item"
+        
+        slicerpop.AppendSeparator()
+        
+        id = wx.NewId()
+        slicerpop.Append(id, '&Toggle Linear/Log scale')
+        wx.EVT_MENU(self, id, self._onToggleScale)
+
+        pos = event.GetPosition()
+        pos = self.ScreenToClient(pos)
+        self.PopupMenu(slicerpop, pos)
+    
+    def _onToggleScale(self, event):
+        if self.get_yscale() == 'log':
+            self.set_yscale('linear')
+        else:
+            self.set_yscale('log')
+        self.subplot.figure.canvas.draw_idle()    
+    
+class Plugin:
+    """
+        Plug-in class to be instantiated by the GUI manager
+    """
+    
+    def __init__(self):
+        """
+            Initialize the plug-in
+        """
+        ## Plug-in name
+        self.sub_menu = "Plotting"
+        
+        ## Reference to the parent window
+        self.parent = None
+        
+        ## List of panels for the simulation perspective (names)
+        self.perspective = []
+        
+        ## Plot panels
+        self.plot_panels = []
+        
+
+    def populate_menu(self, id, parent):
+        """
+            Create a 'Plot' menu to list the panels
+            available for displaying
+            @param id: next available unique ID for wx events
+            @param parent: parent window
+        """
+        self.menu = wx.Menu()
+        return [(id, self.menu, "Plot")]
+    
+        
+    def get_panels(self, parent):
+        """
+            Create and return a list of panel objects
+        """
+        ## Save a reference to the parent
+        self.parent = parent
+        # Connect to plotting events
+        self.parent.Bind(EVT_NEW_PLOT, self._on_plot_event)
+        
+        # We have no initial panels for this plug-in
+        return []
+    
+    def get_perspective(self):
+        """
+            Get the list of panel names for this perspective
+        """
+        return self.perspective
+    
+    def on_perspective(self, event):
+        """
+            Call back function for the perspective menu item.
+            We notify the parent window that the perspective
+            has changed.
+            @param event: menu event
+        """
+        self.parent.set_perspective(self.perspective)
+    
+    def post_init(self):
+        """
+            Post initialization call back to close the loose ends
+            [Somehow openGL needs this call]
+        """
+        pass
+    
+    def _on_show_panel(self, event):
+        print "_on_show_panel"
+    
+    def _on_plot_event(self, event):
+        """
+            A new plottable is being shipped to the plotting plug-in.
+            Check whether we have a panel to put in on, or create
+            a new one
+            @param event: EVT_NEW_PLOT event
+        """
+        # Check whether we already have a graph with the same units
+        # as the plottable we just received. 
+        is_available = False
+        for panel in self.plot_panels:
+            if event.plot._xunit == panel.graph.prop["xunit"] \
+            and event.plot._yunit == panel.graph.prop["yunit"]:
+                is_available = True
+                panel._onEVT_1DREPLOT(event)
+                self.parent.show_panel(panel.uid)
+        
+        # Create a new plot panel if none was available        
+        if not is_available:
+            new_panel = View1DPanel(self.parent, -1, style=wx.RAISED_BORDER)
+            if hasattr(event, "title"):
+                new_panel.window_caption = event.title
+                new_panel.window_name = event.title
+            
+            event_id = self.parent.popup_panel(new_panel)
+            self.menu.Append(event_id, new_panel.window_caption, 
+                             "Show %s plot panel" % new_panel.window_caption)
+            
+            # Set UID to allow us to reference the panel later
+            new_panel.uid = event_id
+            
+            # Ship the plottable to its panel
+            new_panel._onEVT_1DREPLOT(event)
+            self.plot_panels.append(new_panel)        
+            
+        return
+        
