save fit parameter does not confirm overwrite; export graphics with try-catch around get_data_opts;
This commit is contained in:
parent
a746afadff
commit
091677991b
@ -2,7 +2,7 @@
|
||||
|
||||
import sys
|
||||
import pathlib
|
||||
sys.path.append(str(pathlib.Path(__file__).parent.parent / 'src'))
|
||||
sys.path.append(str(pathlib.Path(__file__).absolute().parent.parent / 'src'))
|
||||
|
||||
from nmreval.configs import check_for_config
|
||||
|
||||
|
@ -596,7 +596,12 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
legend_shown = True
|
||||
break
|
||||
in_legend.append(legend_shown)
|
||||
try:
|
||||
item_dic = plot_item.get_data_opts()
|
||||
except Exception as e:
|
||||
print(f'{item} could not exported because {e.args}')
|
||||
continue
|
||||
|
||||
if len(item) == 2:
|
||||
# plot can show errorbars
|
||||
item_dic['yerr'] = item[1].opts['topData']
|
||||
@ -607,9 +612,10 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
for item in self._external_items:
|
||||
try:
|
||||
dic['items'].append(item.get_data_opts())
|
||||
except AttributeError:
|
||||
print(f'{item} is missing "get_data_opts()"')
|
||||
except Exception as e:
|
||||
print(f'{item} could not be exported because {e.args}')
|
||||
continue
|
||||
|
||||
in_legend.append(False)
|
||||
|
||||
dic['in_legend'] = in_legend
|
||||
|
@ -22,9 +22,10 @@ pyqtgraph looks for function "setLogMode" for logarithmic axes, so needs to be i
|
||||
|
||||
class LogInfiniteLine(InfiniteLine):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.logmode = [False, False]
|
||||
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def setLogMode(self, xmode, ymode):
|
||||
"""
|
||||
Does only work for vertical and horizontal lines
|
||||
@ -33,13 +34,13 @@ class LogInfiniteLine(InfiniteLine):
|
||||
return
|
||||
|
||||
new_p = list(self.p[:])
|
||||
if (self.angle == 90) and (self.logmode[0] != xmode):
|
||||
if self.logmode[0] != xmode:
|
||||
if xmode:
|
||||
new_p[0] = np.log10(new_p[0]+np.finfo(float).eps)
|
||||
else:
|
||||
new_p[0] = 10**new_p[0]
|
||||
|
||||
if (self.angle == 0) and (self.logmode[1] != ymode):
|
||||
if self.logmode[1] != ymode:
|
||||
if ymode:
|
||||
new_p[1] = np.log10(new_p[1]+np.finfo(float).eps)
|
||||
else:
|
||||
|
@ -111,6 +111,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
|
||||
self.datawidget.management = self.management
|
||||
self.integralwidget.management = self.management
|
||||
# self.drawingswidget.graphs = self.management.graphs
|
||||
|
||||
self.ac_group = QtWidgets.QActionGroup(self)
|
||||
self.ac_group.addAction(self.action_lm_fit)
|
||||
@ -276,7 +277,8 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
@QtCore.pyqtSlot(list)
|
||||
def save_fit_parameter(self, fit_sets: list[str] = None):
|
||||
fname, _ = QtWidgets.QFileDialog.getSaveFileName(self, 'Save fit parameter', directory=str(self.path),
|
||||
filter='All files(*, *);;Text files(*.dat *.txt)')
|
||||
filter='All files(*, *);;Text files(*.dat *.txt)',
|
||||
options=QtWidgets.QFileDialog.DontConfirmOverwrite)
|
||||
|
||||
if fname:
|
||||
self.management.save_fit_parameter(fname, fit_sets=fit_sets)
|
||||
|
Loading…
Reference in New Issue
Block a user