mirror of
https://github.com/nqrduck/nqrduck-pulseprogrammer.git
synced 2024-11-09 11:20:01 +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.
|
path (str): The path to the file.
|
||||||
"""
|
"""
|
||||||
logger.debug("Saving pulse sequence to %s", path)
|
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()
|
sequence = self.module.model.pulse_sequence.to_json()
|
||||||
with open(path, "w") as file:
|
with open(path, "w") as file:
|
||||||
file.write(json.dumps(sequence, cls=DecimalEncoder))
|
file.write(json.dumps(sequence, cls=DecimalEncoder))
|
||||||
|
|
|
@ -9,6 +9,7 @@ logger = logging.getLogger(__name__)
|
||||||
class PulseProgrammerModel(ModuleModel):
|
class PulseProgrammerModel(ModuleModel):
|
||||||
pulse_parameter_options_changed = pyqtSignal()
|
pulse_parameter_options_changed = pyqtSignal()
|
||||||
events_changed = pyqtSignal()
|
events_changed = pyqtSignal()
|
||||||
|
pulse_sequence_changed = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, module):
|
def __init__(self, module):
|
||||||
super().__init__(module)
|
super().__init__(module)
|
||||||
|
@ -37,3 +38,12 @@ class PulseProgrammerModel(ModuleModel):
|
||||||
self._pulse_parameter_options = value
|
self._pulse_parameter_options = value
|
||||||
logger.debug("Pulse parameter options changed - emitting signal")
|
logger.debug("Pulse parameter options changed - emitting signal")
|
||||||
self.pulse_parameter_options_changed.emit()
|
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")
|
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)
|
self.module.model.pulse_parameter_options_changed.connect(self.on_pulse_parameter_options_changed)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def setup_variabletables(self) -> None:
|
def setup_variabletables(self) -> None:
|
||||||
"""Setup the table for the variables.
|
"""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
|
"""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
|
# 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
|
# Make title bold
|
||||||
font = title.font()
|
font = self.title.font()
|
||||||
font.setBold(True)
|
font.setBold(True)
|
||||||
title.setFont(font)
|
self.title.setFont(font)
|
||||||
|
|
||||||
# Table setup
|
# Table setup
|
||||||
self.pulse_table = QTableWidget(self)
|
self.pulse_table = QTableWidget(self)
|
||||||
|
@ -79,10 +81,11 @@ class PulseProgrammerView(ModuleView):
|
||||||
|
|
||||||
# Connect signals
|
# Connect signals
|
||||||
self.module.model.events_changed.connect(self.on_events_changed)
|
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)
|
button_layout.addStretch(1)
|
||||||
layout.addWidget(title)
|
layout.addWidget(self.title)
|
||||||
layout.addLayout(button_layout)
|
layout.addLayout(button_layout)
|
||||||
layout.addLayout(table_layout)
|
layout.addLayout(table_layout)
|
||||||
layout.addStretch(1)
|
layout.addStretch(1)
|
||||||
|
@ -96,6 +99,13 @@ class PulseProgrammerView(ModuleView):
|
||||||
self.on_events_changed()
|
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()
|
@pyqtSlot()
|
||||||
def on_pulse_parameter_options_changed(self) -> None:
|
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.
|
"""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:
|
else:
|
||||||
self.accept()
|
self.accept()
|
||||||
|
|
||||||
|
# This class should be refactored in the module view so it can be used by all modules
|
||||||
class QFileManager:
|
class QFileManager:
|
||||||
"""This class provides methods for opening and saving files."""
|
"""This class provides methods for opening and saving files."""
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
|
Loading…
Reference in a new issue