Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion src/sas/qtgui/Calculators/DataOperationUtilityPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ def updatePlot(self, graph, layout, data):
plotter2D.x_label = ''
plotter2D.plot(data=data, show_colorbar=False)
plotter2D.show()

elif isinstance(data, Data1D):
# plot 1D data
plotter = PlotterWidget(self, quickplot=True)
Expand Down
34 changes: 32 additions & 2 deletions src/sas/qtgui/MainWindow/DataExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def __init__(self, parent=None, guimanager=None, manager=None):
self.communicator.changeDataExplorerTabSignal.connect(self.changeTabs)
self.communicator.forcePlotDisplaySignal.connect(self.displayData)
self.communicator.updateModelFromPerspectiveSignal.connect(self.updateModelFromPerspective)
self.communicator.freezeDataNameSignal.connect(self.freezeFromName)

# fixing silly naming clash in other managers
self.communicate = self.communicator
Expand Down Expand Up @@ -813,12 +814,41 @@ def onDataReplaced(self):
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
_ = msgbox.exec_()

def freezeFromName(self, search_name = None):
def findName(model, target_name: str, column: int=0)-> tuple:
for row in range(model.rowCount()):
if model.item(row, column).text() == target_name:
return row, -1
for row2 in range(model.item(row, column).rowCount()):
tmp = model.item(row, column).child(row2, column)
if tmp.text() == target_name:
return row, row2
return -1, -1

model = self.model
row_index_parent, row_index_child = findName(model, search_name)
new_item = model.item(row_index_parent)
if row_index_child != -1:
data = new_item.child(row_index_child)
new_item = self.cloneTheory(data)
#new_item.setText(search_name)
#new_item.child(0).data().id = search_name
model.beginResetModel()
model.appendRow(new_item)
model.endResetModel()
self.sendData([new_item])

def sendData(self, event=None):
"""
Send selected item data to the current perspective and set the relevant notifiers
"""
selected_items = self.selectedItems()
if len(selected_items) < 1:

if type(event) == bool:
selected_items = self.selectedItems()
else:
selected_items = event

if len(selected_items) <1:
return

# Check that only one item is selected when sending to perspectives that don't support batch mode
Expand Down
1 change: 1 addition & 0 deletions src/sas/qtgui/Plotting/Plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self, parent=None, manager=None, quickplot=False):
self.toolbar._actions['forward'].triggered.connect(self._forward)
self.toolbar._actions['pan'].triggered.connect(self._pan)
self.toolbar._actions['zoom'].triggered.connect(self._zoom)
self.toolbar._actions['fitting'].setVisible(True)

self.legendVisible = True

Expand Down
32 changes: 31 additions & 1 deletion src/sas/qtgui/Plotting/PlotterBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,35 @@

DEFAULT_CMAP = mpl.cm.jet

class CustomToolbar(NavigationToolbar):
def __init__(self, canvas, parent=None):
super().__init__(canvas, parent)
self.parent = parent
self.add_custom_button()

def add_custom_button(self):
# I have been told that a Button is better
# But all NavitaionToolbar interactions are Actions
# This way all can be called with:
# self._actions['xxx']
custom_icon = QtGui.QIcon() # You can load an icon here if you want e.g., QtGui.QIcon("path/to/icon.png")
custom_action = QtGui.QAction(custom_icon, "Send to Fitting", self)
custom_action.setToolTip("Send all data to Fitting in seperate tabs")
custom_action.triggered.connect(self.sendToFitting)
self.insertAction(self.actions()[-1], custom_action)
#self.addAction(custom_action)
self._actions['fitting'] = custom_action
self._actions['fitting'].setVisible(False)

def sendToFitting(self):
search_name = self.parent.data
for item in search_name:
self.parent.manager.communicator.freezeDataNameSignal.emit(item.name)
self._actions["fitting"].setEnabled(False)

# Re-enable after 3 seconds
QtCore.QTimer.singleShot(3000, lambda: self._actions["fitting"].setEnabled(True))

class PlotterBase(QtWidgets.QWidget):
#TODO: Describe what this class is

Expand Down Expand Up @@ -109,7 +138,8 @@ def __init__(self, parent=None, manager=None, quickplot=False):
self.canvas.mpl_connect('scroll_event', self.onMplWheel)

self.contextMenu = QtWidgets.QMenu(self)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar = CustomToolbar(self.canvas, self)

self.canvas.mpl_connect('resize_event', self.onResize)
self.canvas.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.canvas.customContextMenuRequested.connect(self.showContextMenu)
Expand Down
2 changes: 2 additions & 0 deletions src/sas/qtgui/Utilities/GuiUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class Communicate(QtCore.QObject):
# Global close to help kill active threads
closeSignal = QtCore.Signal()

# Notify about a data name to be frozen and send to fitting perspective
freezeDataNameSignal = QtCore.Signal(str)

communicate = Communicate()

Expand Down