Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/sas/qtgui/Calculators/DataOperationUtilityPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, parent=None):
super(DataOperationUtilityPanel, self).__init__()
self.setupUi(self)
self.manager = parent
self.communicator = self.manager.communicator()
self.communicator = GuiUtils.communicator

# To store input datafiles
self.filenames = None
Expand Down
4 changes: 2 additions & 2 deletions src/sas/qtgui/Calculators/GenericScatteringCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, parent=None):
self.setFixedSize(self.minimumSizeHint())

self.manager = parent
self.communicator = self.manager.communicator()
self.communicator = GuiUtils.communicator
self.model = sas_gen.GenSAS()
self.omf_reader = sas_gen.OMFReader()
self.sld_reader = sas_gen.SLDReader()
Expand Down Expand Up @@ -1541,7 +1541,7 @@ def complete(self, input, update=None):
model_str, model_path = gsc_model.generate_plugin(self.txtFileName.text(), self.data_to_plot, self.xValues,
self.fQ, self.rGMass)
TabbedModelEditor.writeFile(model_path, model_str)
self.manager.communicate.customModelDirectoryChanged.emit()
self.communicator.customModelDirectoryChanged.emit()

# Notify the user
msg = "Custom model " + str(model_path.absolute()) + " successfully created."
Expand Down
4 changes: 2 additions & 2 deletions src/sas/qtgui/Calculators/Shape2SAS/DesignWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from sas.qtgui.Calculators.Shape2SAS.ViewerModel import ViewerModel
from sas.qtgui.Perspectives.perspective import Perspective
from sas.qtgui.Plotting.PlotterData import Data1D
from sas.qtgui.Utilities.GuiUtils import createModelItemWithPlot
from sas.qtgui.Utilities.GuiUtils import communicator, createModelItemWithPlot

# Local SasView
from sas.qtgui.Utilities.ModelEditors.TabbedEditor.TabbedModelEditor import TabbedModelEditor
Expand Down Expand Up @@ -59,7 +59,7 @@ def __init__(self, parent=None):
self.parent = parent

self._manager = parent
self.communicator = self._manager.communicator()
self.communicator = communicator

############Building GUI##############
###create build model tab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from sas.qtgui.Calculators.DataOperationUtilityPanel import DataOperationUtilityPanel
from sas.qtgui.MainWindow.DataState import DataState
from sas.qtgui.Plotting.PlotterData import Data1D, Data2D
from sas.qtgui.Utilities.GuiUtils import Communicate
from sas.qtgui.Utilities.GuiUtils import communicator

BG_COLOR_ERR = 'background-color: rgb(244, 170, 164);'

Expand All @@ -18,7 +18,7 @@ def widget(self, qapp):
"""Create/Destroy the DataOperationUtilityPanel"""
class dummy_manager:
def communicator(widget):
return Communicate()
return communicator

w = DataOperationUtilityPanel(dummy_manager())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from sas.qtgui.Calculators.GenericScatteringCalculator import GenericScatteringCalculator, Plotter3D
from sas.qtgui.Plotting.PlotterBase import PlotHelper
from sas.qtgui.Utilities.GuiUtils import Communicate
from sas.qtgui.Utilities.GuiUtils import communicator
from sas.sascalc.calculator import sas_gen


Expand All @@ -24,7 +24,7 @@ def widget(self, qapp):
"""Create/Destroy the GenericScatteringCalculator"""
class dummy_manager:
def communicator(self):
return Communicate()
return communicator

w = GenericScatteringCalculator(dummy_manager())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from twisted.internet import threads

from sas.qtgui.Calculators.ResolutionCalculatorPanel import ResolutionCalculatorPanel
from sas.qtgui.Utilities.GuiUtils import Communicate
from sas.qtgui.Utilities.GuiUtils import communicator

BG_COLOR_ERR = 'background-color: rgb(244, 170, 164);'

Expand All @@ -26,7 +26,7 @@ def widget(self, qapp):
"""Create/Destroy the ResolutionCalculatorPanel"""
class dummy_manager:
def communicator(widget):
return Communicate()
return communicator

w = ResolutionCalculatorPanel(dummy_manager())

Expand Down
3 changes: 2 additions & 1 deletion src/sas/qtgui/MainWindow/CategoryManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sasmodels.sasview_model import load_standard_models

from sas.qtgui.Utilities.CategoryInstaller import CategoryInstaller
from sas.qtgui.Utilities.GuiUtils import communicator

from .UI.CategoryManagerUI import Ui_CategoryManagerUI
from .UI.ChangeCategoryUI import Ui_ChangeCategoryUI
Expand Down Expand Up @@ -134,7 +135,7 @@ def __init__(self, parent=None, manager=None):
super(CategoryManager, self).__init__(parent)
self.setupUi(self)

self.communicator = manager.communicator()
self.communicator = communicator

self.manager = manager

Expand Down
5 changes: 1 addition & 4 deletions src/sas/qtgui/MainWindow/DataExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __init__(self, parent=None, guimanager=None, manager=None):
self.cbSelect.activated.connect(self.selectData)

self.currentChanged.connect(self.onTabSwitch)
self.communicator = self.parent.communicator()
self.communicator = GuiUtils.communicator
self.communicator.fileTriggerSignal.connect(self.loadFromArbitraryPath)
self.communicator.fileReadSignal.connect(self.loadFromURL)
self.communicator.activeGraphsSignal.connect(self.updateGraphCount)
Expand All @@ -111,9 +111,6 @@ def __init__(self, parent=None, guimanager=None, manager=None):
self.communicator.updateModelFromPerspectiveSignal.connect(self.updateModelFromPerspective)
self.communicator.freezeDataNameSignal.connect(self.freezeFromName)

# fixing silly naming clash in other managers
self.communicate = self.communicator

self.cbgraph.editTextChanged.connect(self.enableGraphCombo)
self.cbgraph.currentIndexChanged.connect(self.enableGraphCombo)

Expand Down
3 changes: 2 additions & 1 deletion src/sas/qtgui/MainWindow/DroppableDataLoadWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# UI
from sas.qtgui.UI import main_resources_rc # noqa: F401
from sas.qtgui.Utilities.GuiUtils import communicator


class DroppableDataLoadWidget(QtWidgets.QTabWidget, Ui_DataLoadWidget):
Expand All @@ -20,7 +21,7 @@ def __init__(self, parent=None, guimanager=None):

# Enable file drag-drop on treeView
self.setAcceptDrops(True)
self.communicator = guimanager.communicator()
self.communicator = communicator
flags = QtCore.Qt.CustomizeWindowHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowSystemMenuHint
self.setWindowFlags(flags)

Expand Down
44 changes: 20 additions & 24 deletions src/sas/qtgui/MainWindow/GuiManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,6 @@ def updatePerspective(self, data):
msg = "No perspective is currently active."
logger.info(msg)

def communicator(self):
""" Accessor for the communicator """
return self.communicate

def perspective(self):
""" Accessor for the perspective """
return self._current_perspective
Expand Down Expand Up @@ -587,7 +583,7 @@ def quitApplication(self):

# save the paths etc.
self.saveCustomConfig()
self.communicate.closeSignal.emit()
self.communicator.closeSignal.emit()
reactor.callFromThread(reactor.stop)
return True

Expand Down Expand Up @@ -635,17 +631,17 @@ def processVersion(self, version_info: tuple[str, str, Version]):
webbrowser.open(version_info["download_url"])
else:
webbrowser.open(web.download_url)
self.communicate.statusBarUpdateSignal.emit(msg)
self.communicator.statusBarUpdateSignal.emit(msg)
else:
msg = "You have the latest version"
self.communicate.statusBarUpdateSignal.emit(msg)
self.communicator.statusBarUpdateSignal.emit(msg)
except:
msg = "guiframe: could not get latest application"
msg += " version number\n %s" % sys.exc_info()[1]
logger.error(msg)
msg = "Could not connect to the application server."
msg += " Please try again later."
self.communicate.statusBarUpdateSignal.emit(msg)
self.communicator.statusBarUpdateSignal.emit(msg)

def actionWelcome(self):
""" Show the Welcome panel """
Expand All @@ -669,18 +665,18 @@ def addCallbacks(self):
"""
Method defining all signal connections for the gui manager
"""
self.communicate = GuiUtils.communicate
self.communicate.fileDataReceivedSignal.connect(self.fileWasRead)
self.communicate.statusBarUpdateSignal.connect(self.updateStatusBar)
self.communicate.updatePerspectiveWithDataSignal.connect(self.updatePerspective)
self.communicate.progressBarUpdateSignal.connect(self.updateProgressBar)
self.communicate.perspectiveChangedSignal.connect(self.perspectiveChanged)
self.communicate.updateTheoryFromPerspectiveSignal.connect(self.updateTheoryFromPerspective)
self.communicate.deleteIntermediateTheoryPlotsSignal.connect(self.deleteIntermediateTheoryPlotsByTabId)
self.communicate.plotRequestedSignal.connect(self.showPlot)
self.communicate.plotFromNameSignal.connect(self.showPlotFromName)
self.communicate.updateModelFromDataOperationPanelSignal.connect(self.updateModelFromDataOperationPanel)
self.communicate.activeGraphsSignal.connect(self.updatePlotItems)
self.communicator = GuiUtils.communicator
self.communicator.fileDataReceivedSignal.connect(self.fileWasRead)
self.communicator.statusBarUpdateSignal.connect(self.updateStatusBar)
self.communicator.updatePerspectiveWithDataSignal.connect(self.updatePerspective)
self.communicator.progressBarUpdateSignal.connect(self.updateProgressBar)
self.communicator.perspectiveChangedSignal.connect(self.perspectiveChanged)
self.communicator.updateTheoryFromPerspectiveSignal.connect(self.updateTheoryFromPerspective)
self.communicator.deleteIntermediateTheoryPlotsSignal.connect(self.deleteIntermediateTheoryPlotsByTabId)
self.communicator.plotRequestedSignal.connect(self.showPlot)
self.communicator.plotFromNameSignal.connect(self.showPlotFromName)
self.communicator.updateModelFromDataOperationPanelSignal.connect(self.updateModelFromDataOperationPanel)
self.communicator.activeGraphsSignal.connect(self.updatePlotItems)


def addTriggers(self):
Expand Down Expand Up @@ -784,8 +780,8 @@ def addTriggers(self):
self._workspace.actionCheck_for_update.triggered.connect(self.actionCheck_for_update)
self._workspace.actionWhat_s_New.triggered.connect(self.actionWhatsNew)

self.communicate.sendDataToGridSignal.connect(self.showBatchOutput)
self.communicate.resultPlotUpdateSignal.connect(self.showFitResults)
self.communicator.sendDataToGridSignal.connect(self.showBatchOutput)
self.communicator.resultPlotUpdateSignal.connect(self.showFitResults)


#============ FILE =================
Expand Down Expand Up @@ -1008,7 +1004,7 @@ def actionData_Operation(self):
"""
"""
data, theory = self.filesWidget.getAllFlatData()
self.communicate.sendDataToPanelSignal.emit(dict(data, **theory))
self.communicator.sendDataToPanelSignal.emit(dict(data, **theory))

self.DataOperation.show()

Expand Down Expand Up @@ -1203,7 +1199,7 @@ def actionAddMult_Models(self):

def actionEditMask(self):

self.communicate.extMaskEditorSignal.emit()
self.communicator.extMaskEditorSignal.emit()

#============ ANALYSIS =================
def actionFitting(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sas/qtgui/MainWindow/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def run_sasview(file_list: list[str] | None = None):
# Trigger an event to pass the filepath(s) to the GUI without requiring an API change
if file_list:
for file in file_list:
mainwindow.guiManager.communicate.fileTriggerSignal.emit(file)
mainwindow.guiManager.communicator.fileTriggerSignal.emit(file)

timer = QTimer()
timer.timeout.connect(lambda: None)
Expand Down
2 changes: 1 addition & 1 deletion src/sas/qtgui/MainWindow/NameChanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, parent=None):
self.setModal(True)

self.parent = parent
self.communicator = self.parent.communicator
self.communicator = GuiUtils.communicator
self.communicator.dataDeletedSignal.connect(self.removeData)
self.manager = self.parent.manager

Expand Down
6 changes: 3 additions & 3 deletions src/sas/qtgui/MainWindow/UnitTesting/DataExplorerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Local
from sas.qtgui.Plotting.PlotterData import Data1D, Data2D, DataRole
from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy
from sas.qtgui.Utilities.GuiUtils import Communicate, HashableStandardItem
from sas.qtgui.Utilities.GuiUtils import HashableStandardItem, communicator
from sas.system.version import __version__ as SASVIEW_VERSION


Expand All @@ -27,7 +27,7 @@ def __init__(self):
self.name = "Dummy Perspective"

def communicator(self):
return Communicate()
return communicator

def allowBatch(self):
return True
Expand All @@ -50,7 +50,7 @@ def __init__(self):
self._perspective = MyPerspective()

def communicator(self):
return Communicate()
return communicator

def perspective(self):
return self._perspective
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sas.qtgui.MainWindow.DroppableDataLoadWidget import DroppableDataLoadWidget
from sas.qtgui.MainWindow.UnitTesting.DataExplorerTest import MyPerspective
from sas.qtgui.UnitTesting.TestUtils import QtSignalSpy
from sas.qtgui.Utilities.GuiUtils import Communicate
from sas.qtgui.Utilities.GuiUtils import communicator


class DroppableDataLoadWidgetTest:
Expand All @@ -16,7 +16,7 @@ def form(self, qapp):
'''Create/Destroy the DroppableDataLoadWidget'''
class dummy_manager:
def communicator(self):
return Communicate()
return communicator
def perspective(self):
return MyPerspective()

Expand Down
8 changes: 4 additions & 4 deletions src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def testProcessVersion(self, manager, mocker):
"""
# 1. version = 0.0.0
version_info = {"version": "0.0.0"}
spy_status_update = QtSignalSpy(manager, manager.communicate.statusBarUpdateSignal)
spy_status_update = QtSignalSpy(manager, manager.communicator.statusBarUpdateSignal)

manager.processVersion(version_info)

Expand All @@ -170,7 +170,7 @@ def testProcessVersion(self, manager, mocker):

# 2. version < config.__version__
version_info = {"version": "0.0.1"}
spy_status_update = QtSignalSpy(manager, manager.communicate.statusBarUpdateSignal)
spy_status_update = QtSignalSpy(manager, manager.communicator.statusBarUpdateSignal)

manager.processVersion(version_info)

Expand All @@ -180,7 +180,7 @@ def testProcessVersion(self, manager, mocker):

# 3. version > LocalConfig.__version__
version_info = {"version": "999.0.0"}
spy_status_update = QtSignalSpy(manager, manager.communicate.statusBarUpdateSignal)
spy_status_update = QtSignalSpy(manager, manager.communicator.statusBarUpdateSignal)
mocker.patch.object(webbrowser, "open")

manager.processVersion(version_info)
Expand All @@ -194,7 +194,7 @@ def testProcessVersion(self, manager, mocker):
# 4. couldn't load version
version_info = {}
mocker.patch.object(logger, "error")
spy_status_update = QtSignalSpy(manager, manager.communicate.statusBarUpdateSignal)
spy_status_update = QtSignalSpy(manager, manager.communicator.statusBarUpdateSignal)

manager.processVersion(version_info)

Expand Down
4 changes: 2 additions & 2 deletions src/sas/qtgui/Perspectives/Corfunc/CorfuncPerspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def __init__(self, parent=None):
self.mapper = None
self._path = ""
self.model = QtGui.QStandardItemModel(self)
self.communicate = self.parent.communicator()
self.communicate.dataDeletedSignal.connect(self.removeData)
self.communicator = GuiUtils.communicator
self.communicator.dataDeletedSignal.connect(self.removeData)

self._allow_close = False
self._model_item: QStandardItem | None = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ def __init__(self, widget):
self.filesWidget = MainWindow()

def communicator(self, widget):
return GuiUtils.Communicate()

def communicate(self, widget):
return GuiUtils.Communicate()
return GuiUtils.communicator

w = CorfuncWindow(dummy_manager())
reference_data1 = Data1D(x=[0.1, 0.2, 0.3, 0.4, 0.5], y=[1000, 1000, 100, 10, 1], dy=[0.0, 0.0, 0.0, 0.0, 0.0])
Expand Down
Loading