mirror of
https://github.com/nqrduck/nqrduck-pulseprogrammer.git
synced 2025-01-02 20:58:11 +00:00
Added pulse sequence name display.
This commit is contained in:
parent
37eb4f7882
commit
c98df42cf8
3 changed files with 31 additions and 5 deletions
|
@ -104,6 +104,12 @@ class PulseProgrammerController(ModuleController):
|
|||
path (str): The path to the file.
|
||||
"""
|
||||
logger.debug("Saving pulse sequence to %s", path)
|
||||
# Get the name of the file without the extension and without the path
|
||||
file_name = path.split("/")[-1].split(".")[0]
|
||||
self.module.model.pulse_sequence.name = file_name
|
||||
logger.debug("Pulse sequence name: %s", self.module.model.pulse_sequence.name)
|
||||
self.module.model.pulse_sequence_changed.emit()
|
||||
|
||||
sequence = self.module.model.pulse_sequence.to_json()
|
||||
with open(path, "w") as file:
|
||||
file.write(json.dumps(sequence, cls=DecimalEncoder))
|
||||
|
|
|
@ -9,6 +9,7 @@ logger = logging.getLogger(__name__)
|
|||
class PulseProgrammerModel(ModuleModel):
|
||||
pulse_parameter_options_changed = pyqtSignal()
|
||||
events_changed = pyqtSignal()
|
||||
pulse_sequence_changed = pyqtSignal()
|
||||
|
||||
def __init__(self, module):
|
||||
super().__init__(module)
|
||||
|
@ -37,3 +38,12 @@ class PulseProgrammerModel(ModuleModel):
|
|||
self._pulse_parameter_options = value
|
||||
logger.debug("Pulse parameter options changed - emitting signal")
|
||||
self.pulse_parameter_options_changed.emit()
|
||||
|
||||
@property
|
||||
def pulse_sequence(self):
|
||||
return self._pulse_sequence
|
||||
|
||||
@pulse_sequence.setter
|
||||
def pulse_sequence(self, value):
|
||||
self._pulse_sequence = value
|
||||
self.pulse_sequence_changed.emit()
|
||||
|
|
|
@ -25,6 +25,8 @@ class PulseProgrammerView(ModuleView):
|
|||
logger.debug("Connecting pulse parameter options changed signal to on_pulse_parameter_options_changed")
|
||||
self.module.model.pulse_parameter_options_changed.connect(self.on_pulse_parameter_options_changed)
|
||||
|
||||
|
||||
|
||||
def setup_variabletables(self) -> None:
|
||||
"""Setup the table for the variables.
|
||||
"""
|
||||
|
@ -34,11 +36,11 @@ class PulseProgrammerView(ModuleView):
|
|||
"""Setup the table for the pulse sequence. Also add buttons for saving and loading pulse sequences and editing and creation of events
|
||||
"""
|
||||
# Create pulse table
|
||||
title = QLabel("Pulse Sequence: %s" % self.module.model.pulse_sequence.name)
|
||||
self.title = QLabel("Pulse Sequence: %s" % self.module.model.pulse_sequence.name)
|
||||
# Make title bold
|
||||
font = title.font()
|
||||
font = self.title.font()
|
||||
font.setBold(True)
|
||||
title.setFont(font)
|
||||
self.title.setFont(font)
|
||||
|
||||
# Table setup
|
||||
self.pulse_table = QTableWidget(self)
|
||||
|
@ -79,10 +81,11 @@ class PulseProgrammerView(ModuleView):
|
|||
|
||||
# Connect signals
|
||||
self.module.model.events_changed.connect(self.on_events_changed)
|
||||
self.module.model.pulse_sequence_changed.connect(self.on_pulse_sequence_changed)
|
||||
|
||||
|
||||
button_layout.addStretch(1)
|
||||
layout.addWidget(title)
|
||||
layout.addWidget(self.title)
|
||||
layout.addLayout(button_layout)
|
||||
layout.addLayout(table_layout)
|
||||
layout.addStretch(1)
|
||||
|
@ -96,6 +99,13 @@ class PulseProgrammerView(ModuleView):
|
|||
self.on_events_changed()
|
||||
|
||||
|
||||
@pyqtSlot()
|
||||
def on_pulse_sequence_changed(self) -> None:
|
||||
"""This method is called whenever the pulse sequence changes. It updates the view to reflect the changes.
|
||||
"""
|
||||
logger.debug("Updating pulse sequence to %s", self.module.model.pulse_sequence.name)
|
||||
self.title.setText("Pulse Sequence: %s" % self.module.model.pulse_sequence.name)
|
||||
|
||||
@pyqtSlot()
|
||||
def on_pulse_parameter_options_changed(self) -> None:
|
||||
"""This method is called whenever the pulse parameter options change. It updates the view to reflect the changes.
|
||||
|
@ -675,7 +685,7 @@ class AddEventDialog(QDialog):
|
|||
else:
|
||||
self.accept()
|
||||
|
||||
|
||||
# This class should be refactored in the module view so it can be used by all modules
|
||||
class QFileManager:
|
||||
"""This class provides methods for opening and saving files."""
|
||||
def __init__(self, parent=None):
|
||||
|
|
Loading…
Reference in a new issue