This commit is contained in:
2023-04-17 23:36:47 +02:00
parent dee9cbb934
commit 2d11fe4ff9

View File

@ -2,7 +2,7 @@ from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtWidgets import QMainWindow, QSplitter from PyQt5.QtWidgets import QMainWindow, QSplitter
from . import assets from . import assets
from .descs import DESC_TYPES, Description, PlotDescription, ImageDescription from .descs import DESC_TYPES, Description, ImageDescription, PlotDescription
from .dictlist import DictList from .dictlist import DictList
from .exampledata import exampledata from .exampledata import exampledata
from .h5filedlg import open_h5_files_dialog, save_h5_file_dialog from .h5filedlg import open_h5_files_dialog, save_h5_file_dialog
@ -90,11 +90,11 @@ class MainWindow(QMainWindow):
if not offline: if not offline:
self.rst = rst = RPCServerThread(host, port, doc_title_suffix=title) self.rst = rst = RPCServerThread(host, port, doc_title_suffix=title)
rst.start() rst.start()
rst.server.register_function(self.new_image)
rst.server.register_function(self.new_plot) rst.server.register_function(self.new_plot)
rst.server.register_function(self.append_data) rst.server.register_function(self.append_data)
rst.server.register_function(self.extend_data) rst.server.register_function(self.extend_data)
rst.server.register_function(self.set_data) rst.server.register_function(self.set_data)
rst.server.register_function(self.new_image)
self.sig_make_new_subwin.connect(self.on_make_new_subwin) self.sig_make_new_subwin.connect(self.on_make_new_subwin)
@ -106,6 +106,20 @@ class MainWindow(QMainWindow):
# Remote API calls # Remote API calls
def new_image(self, name, cfg):
"""
Create a new image <name> using the configuration dict <cfg>.
The configuration is forwarded to the constructor of ImageDescription.
Allowed keys are: title, xlabel, ylabel, image.
"""
desc = self.add_new_desc_to_list(ImageDescription, name, cfg)
if self.menu_settings.checkboxes["Open new plots"].isChecked():
sub = self.mdi.findSubWindow(name)
if sub:
sub.pw.setImage(desc.data) #TODO lacks the list sync
else:
self.sig_make_new_subwin.emit(name, desc)
def new_plot(self, name, cfg): def new_plot(self, name, cfg):
""" """
Create a new plot <name> using the configuration dict <cfg>. Create a new plot <name> using the configuration dict <cfg>.
@ -147,20 +161,6 @@ class MainWindow(QMainWindow):
desc.data = data desc.data = data
self.sync_item_and_plots(item) self.sync_item_and_plots(item)
def new_image(self, name, cfg):
"""
Create a new image <name> using the configuration dict <cfg>.
The configuration is forwarded to the constructor of ImageDescription.
Allowed keys are: title, xlabel, ylabel, image.
"""
desc = self.add_new_desc_to_list(ImageDescription, name, cfg)
if self.menu_settings.checkboxes["Open new plots"].isChecked():
sub = self.mdi.findSubWindow(name)
if sub:
sub.pw.setImage(desc.data) #TODO lacks the list sync
else:
self.sig_make_new_subwin.emit(name, desc)
# Signal callbacks # Signal callbacks