Changeset 31c5b58 in sasview for src/sas/qtgui/DataExplorer.py


Ignore:
Timestamp:
Nov 25, 2016 8:56:41 AM (8 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
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
Children:
3968752
Parents:
14d9c7b
Message:

Refactored to allow running with run.py.
Minor fixes to plotting.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/DataExplorer.py

    r14d9c7b r31c5b58  
    1818from sas.sasgui.guiframe.dataFitting import Data2D 
    1919 
    20 import GuiUtils 
    21 import PlotHelper 
    22 from Plotter import Plotter 
    23 from Plotter2D import Plotter2D 
    24 from DroppableDataLoadWidget import DroppableDataLoadWidget 
     20import sas.qtgui.GuiUtils as GuiUtils 
     21import sas.qtgui.PlotHelper as PlotHelper 
     22from sas.qtgui.Plotter import Plotter 
     23from sas.qtgui.Plotter2D import Plotter2D 
     24from sas.qtgui.DroppableDataLoadWidget import DroppableDataLoadWidget 
    2525 
    2626# This is how to get data1/2D from the model item 
     
    117117        Show the "Loading data" section of help 
    118118        """ 
    119         _TreeLocation = "html/user/sasgui/guiframe/data_explorer_help.html" 
    120         self._helpView.load(QtCore.QUrl(_TreeLocation)) 
     119        tree_location = self.parent.HELP_DIRECTORY_LOCATION +\ 
     120            "/user/sasgui/guiframe/data_explorer_help.html" 
     121        self._helpView.load(QtCore.QUrl(tree_location)) 
    121122        self._helpView.show() 
    122123 
     
    392393 
    393394        # Call show on requested plots 
     395        # All same-type charts in one plot 
     396        new_plot = Plotter(self) 
    394397        for plot_set in plots: 
    395             new_plot = None 
    396398            if isinstance(plot_set, Data1D): 
    397                 new_plot = Plotter(self) 
     399                new_plot.data = plot_set 
     400                new_plot.plot() 
    398401            elif isinstance(plot_set, Data2D): 
    399                 new_plot = Plotter2D(self) 
     402                # Separate 2D plot 
     403                plot2D = Plotter2D(self) 
     404                plot2D.data = plot_set 
     405                plot2D.plot() 
     406                self.plotAdd(plot2D) 
    400407            else: 
    401408                msg = "Incorrect data type passed to Plotting" 
    402409                raise AttributeError, msg 
    403410 
    404             new_plot.data(plot_set) 
    405             new_plot.plot() 
    406  
    407             # Update the global plot counter 
    408             title = "Graph"+str(PlotHelper.idOfPlot(new_plot)) 
    409             new_plot.setWindowTitle(title) 
    410  
    411             # Add the plot to the workspace 
    412             self.parent.workspace().addWindow(new_plot) 
    413  
    414             # Show the plot 
    415             new_plot.show() 
    416  
    417             # Update the active chart list 
    418             self.active_plots.append(title) 
     411        if plots and \ 
     412           hasattr(new_plot, 'data') and \ 
     413           len(new_plot.data.x) > 0: 
     414            self.plotAdd(new_plot) 
     415 
     416    def plotAdd(self, new_plot): 
     417        """ 
     418        Helper method for plot bookkeeping 
     419        """ 
     420        # Update the global plot counter 
     421        title = "Graph"+str(PlotHelper.idOfPlot(new_plot)) 
     422        new_plot.setWindowTitle(title) 
     423 
     424        # Add the plot to the workspace 
     425        self.parent.workspace().addWindow(new_plot) 
     426 
     427        # Show the plot 
     428        new_plot.show() 
     429 
     430        # Update the active chart list 
     431        self.active_plots.append(title) 
    419432 
    420433    def appendPlot(self): 
     
    438451        for plot_set in new_plots: 
    439452            if type(plot_set) is type(old_plot._data): 
    440                 old_plot.data(plot_set) 
     453                old_plot.data = plot_set 
    441454                old_plot.plot() 
    442455 
Note: See TracChangeset for help on using the changeset viewer.