Skip to content

Commit

Permalink
adds dx0 and dfwhm settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Crackvignoule committed Feb 26, 2025
1 parent e6f9b15 commit f1809a9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
2 changes: 2 additions & 0 deletions fitspy/apps/pyside/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
'ncpus': 'Auto',
'outliers_coef': 1.5,
'click_mode': 'highlight',
'dx0': 20,
'dfwhm': 200,
'peaks_cmap': 'tab10',
'map_cmap': 'viridis',
'figure_options': {'title': 'DEFAULT_TITLE (edit in toolbar)'},
Expand Down
2 changes: 1 addition & 1 deletion fitspy/apps/pyside/components/plot/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def add_peak_point(self, ax, model, x, y):
if dist < dist_min:
dist_min, ind_min = dist, ind

first_spectrum.add_peak_model(model, x0=x_sp[ind_min])
first_spectrum.add_peak_model(model, x0=x_sp[ind_min], dx0=DEFAULTS['dx0'], dfwhm=DEFAULTS['dfwhm'])
self.PeaksChanged.emit(first_spectrum)
self.refreshPlot.emit()

Expand Down
4 changes: 4 additions & 0 deletions fitspy/apps/pyside/components/settings/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ def setup_connections(self):
lambda cmap: self.settingChanged.emit("peaks_cmap", cmap.name.split(":")[1]))
self.other_settings.map_cmap.currentColormapChanged.connect(
lambda cmap: self.settingChanged.emit("map_cmap", cmap.name.split(":")[1]))
self.other_settings.dx0.valueChanged.connect(
lambda value: self.settingChanged.emit("dx0", value))
self.other_settings.dfwhm.valueChanged.connect(
lambda value: self.settingChanged.emit("dfwhm", value))

def load_default_models(self):
HOME = Path.home()
Expand Down
20 changes: 17 additions & 3 deletions fitspy/apps/pyside/components/settings/more_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from superqt.cmap import CmapCatalogComboBox

from fitspy import FIT_METHODS, FIT_PARAMS

from fitspy.apps.pyside import DEFAULTS
from fitspy.apps.pyside.components.settings.custom_spinbox import SpinBox, DoubleSpinBox


Expand Down Expand Up @@ -135,7 +135,6 @@ def initUI(self):

# Peaks Colormap Selection
hbox = QHBoxLayout()

hbox.addWidget(QLabel("Peaks Colormap:"))
# https://pyapp-kit.github.io/superqt/widgets/colormap_catalog/
# https://cmap-docs.readthedocs.io/en/stable/catalog/#colormaps-by-category
Expand All @@ -145,12 +144,27 @@ def initUI(self):

# 2D Map Colormap Selection
hbox = QHBoxLayout()

hbox.addWidget(QLabel("2D Map Colormap:"))
self.map_cmap = CmapCatalogComboBox()
hbox.addWidget(self.map_cmap)
vbox.addLayout(hbox)

# dx0
hbox = QHBoxLayout()
hbox.addWidget(QLabel("X0 Bounds (±):"))
self.dx0 = DoubleSpinBox()
self.dx0.setValue(DEFAULTS["dx0"])
hbox.addWidget(self.dx0)
vbox.addLayout(hbox)

# dfwhm
hbox = QHBoxLayout()
hbox.addWidget(QLabel("FWHM Max (0/+):"))
self.dfwhm = DoubleSpinBox()
self.dfwhm.setValue(DEFAULTS["dfwhm"])
hbox.addWidget(self.dfwhm)
vbox.addLayout(hbox)

self.setLayout(vbox)


Expand Down
4 changes: 4 additions & 0 deletions fitspy/apps/pyside/main_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def setup_connections(self):
self.model.defaultsRestored.connect(self.apply_settings)
self.model.peaksCmapChanged.connect(self.update_peaks_cmap)
self.model.mapCmapChanged.connect(self.update_map_cmap)
self.model.dx0Changed.connect(lambda: DEFAULTS.update({"dx0": self.model.dx0}))
self.model.dfwhmChanged.connect(lambda: DEFAULTS.update({"dfwhm": self.model.dfwhm}))

self.files_controller.showToast.connect(self.show_toast)
self.files_controller.askConfirmation.connect(self.show_confirmation_dialog)
Expand Down Expand Up @@ -123,6 +125,8 @@ def apply_settings(self):
self.view.more_settings.other_settings.outliers_coef.setValue(self.model.outliers_coef)
self.view.more_settings.other_settings.peaks_cmap.setCurrentText(self.model.peaks_cmap)
self.view.more_settings.other_settings.map_cmap.setCurrentText(self.model.map_cmap)
self.view.more_settings.other_settings.dx0.setValue(self.model.dx0)
self.view.more_settings.other_settings.dfwhm.setValue(self.model.dfwhm)

radio_button = getattr(self.view.toolbar, f"{self.model.click_mode}_radio")
radio_button.setChecked(True)
Expand Down
4 changes: 4 additions & 0 deletions fitspy/apps/pyside/main_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class MainModel(QObject):
peaksCmapChanged = Signal()
mapCmapChanged = Signal()
defaultsRestored = Signal()
dx0Changed = Signal()
dfwhmChanged = Signal()

def __init__(self):
super().__init__()
Expand All @@ -32,6 +34,8 @@ def _initialize_settings(self):
"theme": self.themeChanged,
"peaks_cmap": self.peaksCmapChanged,
"map_cmap": self.mapCmapChanged,
"dx0": self.dx0Changed,
"dfwhm": self.dfwhmChanged,
}

def create_setting(default, type, signal=None):
Expand Down

0 comments on commit f1809a9

Please sign in to comment.