Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/sas/qtgui/MainWindow/DataExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,14 +1099,14 @@ def displayDataByName(self, name=None, is_data=True, id=None):
# Residuals get their own plot
if plot.plot_role in [DataRole.ROLE_RESIDUAL, DataRole.ROLE_STAND_ALONE]:
plot.yscale = 'linear'
self.plotData([(item, plot)])
self.plotData([(item, plot)], id)
else:
new_plots.append((item, plot))

if new_plots:
self.plotData(new_plots)
self.plotData(new_plots, id)

def displayData(self, data_list, id=None):
def displayData(self, data_list, id):
"""
Forces display of charts for the given data set
"""
Expand All @@ -1132,7 +1132,7 @@ def displayData(self, data_list, id=None):
if self.isPlotShown(main_data):
self.active_plots[main_data.name].showNormal()
else:
self.plotData([(plot_item, main_data)])
self.plotData([(plot_item, main_data)], id)

append = False
plot_to_append_to = None
Expand All @@ -1158,7 +1158,7 @@ def displayData(self, data_list, id=None):
continue
elif role in stand_alone_types:
# Stand-alone plots should always be separate
self.plotData([(plot_item, plot_to_show)])
self.plotData([(plot_item, plot_to_show)], id)
elif append:
# Assume all other plots sent together should be on the same chart if a previous plot exists
if not plot_to_append_to:
Expand Down Expand Up @@ -1187,7 +1187,9 @@ def displayData(self, data_list, id=None):
new_plots = []

if new_plots:
self.plotData(new_plots)
self.plotData(new_plots, id)

self.parent.tabbedPlotWidget.show_or_activate()

def isPlotShown(self, plot):
"""
Expand Down Expand Up @@ -1223,16 +1225,23 @@ def addDataPlot2D(self, plot_set, item):
# sv.show()
# ============================================

def plotData(self, plots, transform=True):
def plotData(self, plots, tab_id, transform=True):
"""
Takes 1D/2D data and generates a single plot (1D) or multiple plots (2D)
"""
tab_index = self.parent.tabbedPlotWidget.tab_fitpage_dict[tab_id]
print("plotData")
# Call show on requested plots
# All same-type charts in one plot
for item, plot_set in plots:
if isinstance(plot_set, Data1D):
if 'new_plot' not in locals():
new_plot = PlotterWidget(manager=self, parent=self)
# Create only one PlotterWidget(QWidget) for a number of datasets that are supposed to be shown in
# the same Widget
self.parent.tabbedPlotWidget.widget(tab_index).add_more_axes()
tpw_ax = self.parent.tabbedPlotWidget.widget(tab_index).last_axes()

new_plot = PlotterWidget(manager=self, parent=self, tpw_ax=tpw_ax)
new_plot.item = item
# Ensure new plots use the default transform, not the transform of any previous plots the data were in
# TODO: The transform should be part of the PLOT, NOT the data
Expand All @@ -1258,6 +1267,7 @@ def plotData(self, plots, transform=True):
msg = "Incorrect data type passed to Plotting"
raise AttributeError(msg)


if 'new_plot' in locals() and \
hasattr(new_plot, 'data') and \
isinstance(new_plot.data[0], Data1D):
Expand Down Expand Up @@ -1332,6 +1342,7 @@ def appendPlot(self):
@staticmethod
def appendOrUpdatePlot(self, data, plot):
name = data.name
print("append or update plot")
if isinstance(plot, Plotter2DWidget) or name in plot.plot_dict.keys():
plot.replacePlot(name, data)
else:
Expand Down
3 changes: 3 additions & 0 deletions src/sas/qtgui/MainWindow/GuiManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from sas.qtgui.Perspectives.Inversion.InversionPerspective import InversionWindow
from sas.qtgui.Perspectives.perspective import Perspective
from sas.qtgui.Perspectives.SizeDistribution.SizeDistributionPerspective import SizeDistributionWindow
from sas.qtgui.Plotting.TabbedPlotWidget import TabbedPlotWidget
from sas.qtgui.Utilities.About.About import About

# from sas.qtgui.Utilities.DocViewWidget import DocViewWindow
Expand Down Expand Up @@ -195,6 +196,8 @@ def addWidgets(self):
self.FileConverter = FileConverterWidget(self)
self.WhatsNew = WhatsNew(self._parent)

self.tabbedPlotWidget = TabbedPlotWidget(self)

def loadAllPerspectives(self):
""" Load all the perspectives"""
# Close any existing perspectives to prevent multiple open instances
Expand Down
10 changes: 8 additions & 2 deletions src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, parent: QtWidgets.QWidget | None = None, data: Any | None = N
super(FittingWidget, self).__init__()

# Necessary globals
self.parent = parent
self.parent = parent
self.process = None # Default empty value

# Which tab is this widget displayed in?
Expand Down Expand Up @@ -2184,15 +2184,21 @@ def _requestPlots(self, item_name: str, item_model: Any) -> Any | None:
Emits plotRequestedSignal for all plots found in the given model under the provided item name.
"""
fitpage_name = self.logic.kernel_module.name

# send this information to the TabbedPlotWidget so that it can unpack and show the plots as well
self.parent.tabbedPlotWidget.add_tab(item_name, item_model, self.tab_id)
plots = GuiUtils.plotsFromDisplayName(item_name, item_model)
# Has the fitted data been shown?
data_shown = False
item = None
for item, plot in plots.items():
for i, item_plot in enumerate(plots.items()):
item, plot = item_plot
if plot.plot_role != DataRole.ROLE_DATA and fitpage_name in plot.name:
data_shown = True
self.communicate.plotRequestedSignal.emit([item, plot], self.tab_id)
# return the last data item seen, if nothing was plotted; supposed to be just data)
tab_index = self.parent.tabbedPlotWidget.tab_fitpage_dict[self.tab_id]
self.parent.tabbedPlotWidget.widget(tab_index).rearrange_plots()
return None if data_shown else item

def onOptionsUpdate(self) -> None:
Expand Down
Loading
Loading