Changeset b94889a in sasview


Ignore:
Timestamp:
Dec 2, 2016 6:50:17 AM (7 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:
6d05e1d
Parents:
ef01be4 (diff), 040529d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI_249' into ESS_GUI

Location:
src/sas/qtgui
Files:
6 added
8 edited

Legend:

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

    r31c5b58 r363fbfa  
    2525from sas.qtgui.SldPanel import SldPanel 
    2626from sas.qtgui.DensityPanel import DensityPanel 
     27from sas.qtgui.KiessigPanel import KiessigPanel 
    2728 
    2829# Perspectives 
     
    137138        self.SLDCalculator = SldPanel(self) 
    138139        self.DVCalculator = DensityPanel(self) 
    139  
     140        #self.KIESSIGCalculator = DensityPanel(self)#KiessigPanel(self) 
     141        self.KIESSIGCalculator =  KiessigPanel(self) 
    140142    def statusBarSetup(self): 
    141143        """ 
     
    353355        self._workspace.actionSLD_Calculator.triggered.connect(self.actionSLD_Calculator) 
    354356        self._workspace.actionDensity_Volume_Calculator.triggered.connect(self.actionDensity_Volume_Calculator) 
     357        self._workspace.actionKeissig_Calculator.triggered.connect(self.actionKiessig_Calculator) 
     358        #self._workspace.actionKIESSING_Calculator.triggered.connect(self.actionKIESSING_Calculator) 
    355359        self._workspace.actionSlit_Size_Calculator.triggered.connect(self.actionSlit_Size_Calculator) 
    356360        self._workspace.actionSAS_Resolution_Estimator.triggered.connect(self.actionSAS_Resolution_Estimator) 
     
    526530        self.DVCalculator.show() 
    527531 
     532    def actionKiessig_Calculator(self): 
     533        """ 
     534        """ 
     535        #self.DVCalculator.show() 
     536        self.KIESSIGCalculator.show() 
     537 
    528538    def actionSlit_Size_Calculator(self): 
    529539        """ 
  • src/sas/qtgui/UI/MainWindowUI.ui

    r0cd8612 r363fbfa  
    2525     <y>0</y> 
    2626     <width>915</width> 
    27      <height>21</height> 
     27     <height>25</height> 
    2828    </rect> 
    2929   </property> 
     
    8282    </property> 
    8383    <addaction name="actionData_Operation"/> 
     84    <addaction name="separator"/> 
    8485    <addaction name="actionSLD_Calculator"/> 
    8586    <addaction name="actionDensity_Volume_Calculator"/> 
    8687    <addaction name="actionSlit_Size_Calculator"/> 
     88    <addaction name="actionKeissig_Calculator"/> 
    8789    <addaction name="actionSAS_Resolution_Estimator"/> 
    8890    <addaction name="actionGeneric_Scattering_Calculator"/> 
     
    489491   </property> 
    490492  </action> 
     493  <action name="actionKeissig_Calculator"> 
     494   <property name="text"> 
     495    <string>Kiessig Thickness Calculator</string> 
     496   </property> 
     497  </action> 
    491498 </widget> 
    492499 <resources> 
  • src/sas/qtgui/run_tests.bat

    rf51ed67 r363fbfa  
    1111python -m UnitTesting.SasviewLoggerTest 
    1212python -m UnitTesting.PlotHelperTest 
     13python -m UnitTesting.KiessigCalculatorTest 
  • src/sas/qtgui/run_tests.sh

    r9968d6a r363fbfa  
    1010python -m UnitTesting.SasviewLoggerTest 
    1111python -m UnitTesting.DensityCalculatorTest 
     12python -m UnitTesting.KiessigCalculatorTest 
  • src/sas/qtgui/DataExplorer.py

    r8548d739 ref01be4  
    410410                raise AttributeError, msg 
    411411 
    412  
    413412        if plots and \ 
    414413           hasattr(new_plot, 'data') and \ 
     
    765764        data = GuiUtils.dataFromItem(model_item) 
    766765 
    767         dimension = 1 if isinstance(data, Data1D) else 2 
     766        method_name = 'Plotter' 
     767        if isinstance(data, Data2D): 
     768            method_name='Plotter2D' 
    768769 
    769770        # TODO: Replace this with the proper MaskPlotPanel from plottools 
    770         new_plot = Plotter(self) 
    771         new_plot.data(data) 
     771        new_plot = globals()[method_name](self, quickplot=True) 
     772        new_plot.data = data 
    772773        new_plot.plot(marker='o', linestyle='') 
    773774 
  • src/sas/qtgui/PlotHelper.py

    • Property mode changed from 100755 to 100644
    r8cb6cd6 ref01be4  
    2828    Deletes an existing plot from the dictionary 
    2929    """ 
    30     assert plot_id in this._plots 
    31     del this._plots[plot_id] 
     30    if plot_id in this._plots: 
     31        del this._plots[plot_id] 
    3232 
    3333def currentPlots(): 
     
    4141    Returns the plot referenced by the ID 
    4242    """ 
    43     assert plot_id in this._plots 
    44  
    45     return this._plots[plot_id] 
     43    return this._plots[plot_id] if plot_id in this._plots else None 
    4644 
    4745def idOfPlot(plot): 
  • src/sas/qtgui/Plotter.py

    r31c5b58 ref01be4  
    1010from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar 
    1111import matplotlib.pyplot as plt 
     12import matplotlib as mpl 
    1213 
    1314import sas.qtgui.PlotHelper as PlotHelper 
     15from sas.qtgui.PlotterBase import PlotterBase 
    1416 
    15 class Plotter(QtGui.QDialog): 
    16     def __init__(self, parent=None): 
    17         super(Plotter, self).__init__(parent) 
    18  
    19         # Required for the communicator 
    20         self.parent = parent 
    21  
    22         # a figure instance to plot on 
    23         self.figure = plt.figure() 
    24  
    25         # this is the Canvas Widget that displays the `figure` 
    26         # it takes the `figure` instance as a parameter to __init__ 
    27         self.canvas = FigureCanvas(self.figure) 
    28  
    29         # this is the Navigation widget 
    30         # it takes the Canvas widget and a parent 
    31         self.toolbar = NavigationToolbar(self.canvas, self) 
    32  
    33         # set the layout 
    34         layout = QtGui.QVBoxLayout() 
    35         layout.addWidget(self.canvas) 
    36         layout.addWidget(self.toolbar) 
    37         self.setLayout(layout) 
    38  
    39         # defaults 
    40         self._current_plot = 111 
    41         self._data = [] 
    42         self._title = "Plot" 
    43         self._id = "" 
    44         self._xlabel = "X" 
    45         self._ylabel = "Y" 
    46         self._ax = self.figure.add_subplot(self._current_plot) 
    47  
    48         # Notify the helper 
    49         PlotHelper.addPlot(self) 
    50         # Notify the listeners 
    51         self.parent.communicator.activeGraphsSignal.emit(PlotHelper.currentPlots()) 
     17class Plotter(PlotterBase): 
     18    def __init__(self, parent=None, quickplot=False): 
     19        super(Plotter, self).__init__(parent, quickplot=quickplot) 
    5220 
    5321    @property 
    5422    def data(self): 
    55         """ data getter """ 
    5623        return self._data 
    5724 
     
    6027        """ data setter """ 
    6128        self._data = value 
    62  
    63     def title(self, title=""): 
    64         """ title setter """ 
    65         self._title = title 
    66  
    67     def id(self, id=""): 
    68         """ id setter """ 
    69         self._id = id 
    70  
    71     def x_label(self, xlabel=""): 
    72         """ x-label setter """ 
    73         self._xlabel = xlabel 
    74  
    75     def y_label(self, ylabel=""): 
    76         """ y-label setter """ 
    77         self._ylabel = ylabel 
    78  
    79     def clean(self): 
    80         """ 
    81         Redraw the graph 
    82         """ 
    83         self.figure.delaxes(self._ax) 
    84         self._ax = self.figure.add_subplot(self._current_plot) 
     29        self.label=value.name 
     30        self.xLabel(xlabel="%s(%s)"%(value._xaxis, value._xunit)) 
     31        self.yLabel(ylabel="%s(%s)"%(value._yaxis, value._yunit)) 
     32        self.title(title=value.title) 
    8533 
    8634    def plot(self, marker=None, linestyle=None): 
     
    8937        """ 
    9038        # create an axis 
    91         ax = self._ax 
     39        ax = self.ax 
    9240 
    9341        if marker == None: 
     
    9846 
    9947        # plot data with legend 
    100         ax.plot(self._data.x, self._data.y, marker=marker, linestyle=linestyle, label=self._title) 
     48        ax.plot(self._data.x, self._data.y, marker=marker, linestyle=linestyle, label=self.title) 
    10149 
    10250        # Now add the legend with some customizations. 
    103         legend = ax.legend(loc='lower left', shadow=True) 
     51        legend = ax.legend(loc='upper right', shadow=True) 
    10452 
    105         ax.set_ylabel(self._ylabel) 
    106         ax.set_xlabel(self._xlabel) 
     53        ax.set_ylabel(self.y_label) 
     54        ax.set_xlabel(self.x_label) 
     55        # Title only for regular charts 
     56        if not self.quickplot: 
     57            ax.set_title(label=self.title) 
    10758 
    10859        ax.set_yscale('log') 
     
    11263        self.canvas.draw() 
    11364 
    114     def closeEvent(self, event): 
    115         """ 
    116         Overwrite the close event adding helper notification 
    117         """ 
    118         # Please remove me from your database. 
    119         PlotHelper.deletePlot(PlotHelper.idOfPlot(self)) 
    120         # Notify the listeners 
    121         self.parent.communicator.activeGraphsSignal.emit(PlotHelper.currentPlots()) 
    122         event.accept() 
    123  
  • src/sas/qtgui/Plotter2D.py

    r31c5b58 ref01be4  
    1818import sas.qtgui.PlotUtilities as PlotUtilities 
    1919import sas.qtgui.PlotHelper as PlotHelper 
     20from sas.qtgui.PlotterBase import PlotterBase 
    2021 
    21 class Plotter2D(QtGui.QDialog): 
    22     def __init__(self, parent=None): 
    23         super(Plotter2D, self).__init__(parent) 
    24  
    25         # Required for the communicator 
    26         self.parent = parent 
    27  
    28         # a figure instance to plot on 
    29         self.figure = plt.figure() 
    30  
    31         # this is the Canvas Widget that displays the `figure` 
    32         # it takes the `figure` instance as a parameter to __init__ 
    33         self.canvas = FigureCanvas(self.figure) 
    34  
    35         # this is the Navigation widget 
    36         # it takes the Canvas widget and a parent 
    37         self.toolbar = NavigationToolbar(self.canvas, self) 
    38  
    39         # set the layout 
    40         layout = QtGui.QVBoxLayout() 
    41         layout.addWidget(self.canvas) 
    42         layout.addWidget(self.toolbar) 
    43         self.setLayout(layout) 
    44  
    45         # defaults 
    46         self._current_plot = 111 
    47         self._data = [] 
    48         self._qx_data = [] 
    49         self._qy_data = [] 
    50         self._color=0 
    51         self._symbol=0 
    52         self._scale = 'linear' 
    53  
    54         # default color map 
    55         self._cmap = DEFAULT_CMAP 
    56  
    57         self._ax = self.figure.add_subplot(self._current_plot) 
    58  
    59         # Notify the helper 
    60         PlotHelper.addPlot(self) 
    61         # Notify the listeners 
    62         self.parent.communicator.activeGraphsSignal.emit(PlotHelper.currentPlots()) 
     22class Plotter2D(PlotterBase): 
     23    def __init__(self, parent=None, quickplot=False): 
     24        super(Plotter2D, self).__init__(parent, quickplot=quickplot) 
    6325 
    6426    @property 
     
    7032        """ data setter """ 
    7133        self._data = data 
    72         self._qx_data=data.qx_data 
    73         self._qy_data=data.qy_data 
    74         self._xmin=data.xmin 
    75         self._xmax=data.xmax 
    76         self._ymin=data.ymin 
    77         self._ymax=data.ymax 
    78         self._zmin=data.zmin 
    79         self._zmax=data.zmax 
    80         self._label=data.name 
    81         self.x_label(xlabel=data._xaxis + data._xunit) 
    82         self.y_label(ylabel=data._yaxis + data._yunit) 
     34        self.qx_data=data.qx_data 
     35        self.qy_data=data.qy_data 
     36        self.xmin=data.xmin 
     37        self.xmax=data.xmax 
     38        self.ymin=data.ymin 
     39        self.ymax=data.ymax 
     40        self.zmin=data.zmin 
     41        self.zmax=data.zmax 
     42        self.label=data.name 
     43        self.xLabel(xlabel="%s(%s)"%(data._xaxis, data._xunit)) 
     44        self.yLabel(ylabel="%s(%s)"%(data._yaxis, data._yunit)) 
    8345        self.title(title=data.title) 
    84  
    85     def title(self, title=""): 
    86         """ title setter """ 
    87         self._title = title 
    88  
    89     def id(self, id=""): 
    90         """ id setter """ 
    91         self._id = id 
    92  
    93     def x_label(self, xlabel=""): 
    94         """ x-label setter """ 
    95         self._xlabel = r'$%s$'% xlabel 
    96  
    97     def y_label(self, ylabel=""): 
    98         """ y-label setter """ 
    99         self._ylabel = r'$%s$'% ylabel 
    100  
    101     def clean(self): 
    102         """ 
    103         Redraw the graph 
    104         """ 
    105         self.figure.delaxes(self._ax) 
    106         self._ax = self.figure.add_subplot(self._current_plot) 
    10746 
    10847    def plot(self, marker=None, linestyle=None): 
     
    11049        Plot 2D self._data 
    11150        """ 
    112         # create an axis 
    113         ax = self._ax 
     51        # create an axis object 
     52        ax = self.ax 
    11453 
    11554        # graph properties 
    116         ax.set_xlabel(self._xlabel) 
    117         ax.set_ylabel(self._ylabel) 
    118         ax.set_title(label=self._title) 
     55        ax.set_xlabel(self.x_label) 
     56        ax.set_ylabel(self.y_label) 
     57        # Title only for regular charts 
     58        if not self.quickplot: 
     59            ax.set_title(label=self.title) 
    11960 
    12061        # Re-adjust colorbar 
    121         # self.figure.subplots_adjust(left=0.2, right=.8, bottom=.2) 
     62        self.figure.subplots_adjust(left=0.2, right=.8, bottom=.2) 
    12263 
    123         output = PlotUtilities.build_matrix(self._data.data, self._qx_data, self._qy_data) 
     64        output = PlotUtilities.build_matrix(self._data.data, self.qx_data, self.qy_data) 
    12465 
    12566        im = ax.imshow(output, 
    12667                       interpolation='nearest', 
    12768                       origin='lower', 
    128                        vmin=self._zmin, vmax=self._zmax, 
    129                        cmap=self._cmap, 
    130                        extent=(self._xmin, self._xmax, 
    131                                self._ymin, self._ymax)) 
     69                       vmin=self.zmin, vmax=self.zmax, 
     70                       cmap=self.cmap, 
     71                       extent=(self.xmin, self.xmax, 
     72                               self.ymin, self.ymax)) 
    13273 
    13374        cbax = self.figure.add_axes([0.84, 0.2, 0.02, 0.7]) 
     
    13879        # Schedule the draw for the next time the event loop is idle. 
    13980        self.canvas.draw_idle() 
    140  
    141     def closeEvent(self, event): 
    142         """ 
    143         Overwrite the close event adding helper notification 
    144         """ 
    145         # Please remove me from your database. 
    146         PlotHelper.deletePlot(PlotHelper.idOfPlot(self)) 
    147         # Notify the listeners 
    148         self.parent.communicator.activeGraphsSignal.emit(PlotHelper.currentPlots()) 
    149         event.accept() 
    150  
Note: See TracChangeset for help on using the changeset viewer.