def __init__(self): QtGui.QWidget.__init__(self) plotLayout = QtGui.QHBoxLayout() self.plot = PlotView() parameterLayout = QtGui.QVBoxLayout() self.plotList = QtGui.QListWidget(self) self.plotList.setMaximumWidth(150) self.plotList.setMinimumWidth(150) self.plotDataPanel = PlotParameterConfigurationPanel(self, 150) parameterLayout.addWidget(self.plotList) parameterLayout.addWidget(self.plotDataPanel) self.connect(self.plotList, QtCore.SIGNAL('currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.select) ContentModel.modelConnect('initialized()', self.updateList) #todo: listen to ensemble changes! self.plotDataFetcher = PlotDataFetcher() self.connect(self.plotDataFetcher, QtCore.SIGNAL('dataChanged()'), self.drawPlot) self.plotContextDataFetcher = PlotContextDataFetcher() plot_view_layout = QtGui.QGridLayout() plot_view_layout.addWidget(self.plot, 0, 0, 1, 1) self.h_zoom_slider = ZoomSlider() self.connect(self.h_zoom_slider, QtCore.SIGNAL('zoomValueChanged(float, float)'), self.plot.setXZoomFactors) self.v_zoom_slider = ZoomSlider(horizontal=False) self.connect(self.v_zoom_slider, QtCore.SIGNAL('zoomValueChanged(float, float)'), self.plot.setYZoomFactors) plot_view_layout.addWidget(self.h_zoom_slider, 1, 0, 1, 1) plot_view_layout.addWidget(self.v_zoom_slider, 0, 1, 1, 1) plotLayout.addLayout(parameterLayout) plotLayout.addLayout(plot_view_layout) self.plotViewSettings = PlotViewSettingsPanel(plotView=self.plot, width=250) self.connect(self.plotViewSettings, QtCore.SIGNAL('comparisonCaseSelected(String)'), self.plotDataFetcher.updateComparisonFS) plotLayout.addWidget(self.plotViewSettings) self.setLayout(plotLayout) self.connect(self.plot.plot_settings, QtCore.SIGNAL('plotSettingsChanged(PlotSettings)'), self.fetchSettings) ContentModel.modelConnect('casesUpdated()', self.updateList)
class PlotPanel(QtGui.QWidget): def __init__(self): QtGui.QWidget.__init__(self) plotLayout = QtGui.QHBoxLayout() self.plot = PlotView() parameterLayout = QtGui.QVBoxLayout() self.plotList = QtGui.QListWidget(self) self.plotList.setMaximumWidth(150) self.plotList.setMinimumWidth(150) self.plotDataPanel = PlotParameterConfigurationPanel(self, 150) parameterLayout.addWidget(self.plotList) parameterLayout.addWidget(self.plotDataPanel) self.connect(self.plotList, QtCore.SIGNAL('currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.select) ContentModel.modelConnect('initialized()', self.updateList) #todo: listen to ensemble changes! self.plotDataFetcher = PlotDataFetcher() self.connect(self.plotDataFetcher, QtCore.SIGNAL('dataChanged()'), self.drawPlot) self.plotContextDataFetcher = PlotContextDataFetcher() plot_view_layout = QtGui.QGridLayout() plot_view_layout.addWidget(self.plot, 0, 0, 1, 1) self.h_zoom_slider = ZoomSlider() self.connect(self.h_zoom_slider, QtCore.SIGNAL('zoomValueChanged(float, float)'), self.plot.setXZoomFactors) self.v_zoom_slider = ZoomSlider(horizontal=False) self.connect(self.v_zoom_slider, QtCore.SIGNAL('zoomValueChanged(float, float)'), self.plot.setYZoomFactors) plot_view_layout.addWidget(self.h_zoom_slider, 1, 0, 1, 1) plot_view_layout.addWidget(self.v_zoom_slider, 0, 1, 1, 1) plotLayout.addLayout(parameterLayout) plotLayout.addLayout(plot_view_layout) self.plotViewSettings = PlotViewSettingsPanel(plotView=self.plot, width=250) self.connect(self.plotViewSettings, QtCore.SIGNAL('comparisonCaseSelected(String)'), self.plotDataFetcher.updateComparisonFS) plotLayout.addWidget(self.plotViewSettings) self.setLayout(plotLayout) self.connect(self.plot.plot_settings, QtCore.SIGNAL('plotSettingsChanged(PlotSettings)'), self.fetchSettings) ContentModel.modelConnect('casesUpdated()', self.updateList) def drawPlot(self): self.plot.setData(self.plotDataFetcher.data) def fetchSettings(self, plot_settings): if self.plotDataFetcher.data: data = self.plotDataFetcher.data x_min = plot_settings.getMinXLimit(data.x_min, data.getXDataType()) x_max = plot_settings.getMaxXLimit(data.x_max, data.getXDataType()) y_min = plot_settings.getMinYLimit(data.y_min, data.getYDataType()) y_max = plot_settings.getMaxYLimit(data.y_max, data.getYDataType()) state = self.h_zoom_slider.blockSignals(True) self.h_zoom_slider.setMinValue(plot_settings.getMinXZoom()) self.h_zoom_slider.setMaxValue(plot_settings.getMaxXZoom()) self.h_zoom_slider.blockSignals(state) state = self.v_zoom_slider.blockSignals(True) self.v_zoom_slider.setMinValue(plot_settings.getMinYZoom()) self.v_zoom_slider.setMaxValue(plot_settings.getMaxYZoom()) self.v_zoom_slider.blockSignals(state) if isinstance(x_min, erttypes.time_t): x_min = x_min.value if isinstance(x_max, erttypes.time_t): x_max = x_max.value #todo: time data on y-axis state = plot_settings.blockSignals(True) self.plotViewSettings.setDataTypes(data.getXDataType(), data.getYDataType()) self.plotViewSettings.setLimits(x_min, x_max, y_min, y_max) self.plotViewSettings.setLimitStates(*plot_settings.getLimitStates()) self.plotViewSettings.plotSelectionChanged(plot_settings.getSelectedMembers()) plot_settings.blockSignals(state) self.plot.drawPlot() @ert_gui.widgets.util.may_take_a_long_time def select(self, current, previous): if current: self.plotDataFetcher.setParameter(current, self.plotContextDataFetcher.data) cw = self.plotDataFetcher.getConfigurationWidget(self.plotContextDataFetcher.data) self.plotDataPanel.setConfigurationWidget(cw) self.plotDataFetcher.fetchContent() self.drawPlot() def updateList(self): self.plotContextDataFetcher.fetchContent() self.plotList.clear() for parameter in self.plotContextDataFetcher.data.parameters: self.plotList.addItem(parameter) self.plotList.sortItems() self.plot.setPlotPath(self.plotContextDataFetcher.data.plot_path) self.plot.setPlotConfigPath(self.plotContextDataFetcher.data.plot_config_path) self.plotViewSettings.setCases(self.plotContextDataFetcher.data.getComparableCases())