forked from IPKM/nmreval
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 sys
|
||||||
import pathlib
|
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
|
from nmreval.configs import check_for_config
|
||||||
|
|
||||||
|
@ -596,7 +596,12 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
legend_shown = True
|
legend_shown = True
|
||||||
break
|
break
|
||||||
in_legend.append(legend_shown)
|
in_legend.append(legend_shown)
|
||||||
item_dic = plot_item.get_data_opts()
|
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:
|
if len(item) == 2:
|
||||||
# plot can show errorbars
|
# plot can show errorbars
|
||||||
item_dic['yerr'] = item[1].opts['topData']
|
item_dic['yerr'] = item[1].opts['topData']
|
||||||
@ -607,9 +612,10 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
|||||||
for item in self._external_items:
|
for item in self._external_items:
|
||||||
try:
|
try:
|
||||||
dic['items'].append(item.get_data_opts())
|
dic['items'].append(item.get_data_opts())
|
||||||
except AttributeError:
|
except Exception as e:
|
||||||
print(f'{item} is missing "get_data_opts()"')
|
print(f'{item} could not be exported because {e.args}')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
in_legend.append(False)
|
in_legend.append(False)
|
||||||
|
|
||||||
dic['in_legend'] = in_legend
|
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):
|
class LogInfiniteLine(InfiniteLine):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.logmode = [False, False]
|
self.logmode = [False, False]
|
||||||
|
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def setLogMode(self, xmode, ymode):
|
def setLogMode(self, xmode, ymode):
|
||||||
"""
|
"""
|
||||||
Does only work for vertical and horizontal lines
|
Does only work for vertical and horizontal lines
|
||||||
@ -33,13 +34,13 @@ class LogInfiniteLine(InfiniteLine):
|
|||||||
return
|
return
|
||||||
|
|
||||||
new_p = list(self.p[:])
|
new_p = list(self.p[:])
|
||||||
if (self.angle == 90) and (self.logmode[0] != xmode):
|
if self.logmode[0] != xmode:
|
||||||
if xmode:
|
if xmode:
|
||||||
new_p[0] = np.log10(new_p[0]+np.finfo(float).eps)
|
new_p[0] = np.log10(new_p[0]+np.finfo(float).eps)
|
||||||
else:
|
else:
|
||||||
new_p[0] = 10**new_p[0]
|
new_p[0] = 10**new_p[0]
|
||||||
|
|
||||||
if (self.angle == 0) and (self.logmode[1] != ymode):
|
if self.logmode[1] != ymode:
|
||||||
if ymode:
|
if ymode:
|
||||||
new_p[1] = np.log10(new_p[1]+np.finfo(float).eps)
|
new_p[1] = np.log10(new_p[1]+np.finfo(float).eps)
|
||||||
else:
|
else:
|
||||||
|
@ -111,6 +111,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
|
|
||||||
self.datawidget.management = self.management
|
self.datawidget.management = self.management
|
||||||
self.integralwidget.management = self.management
|
self.integralwidget.management = self.management
|
||||||
|
# self.drawingswidget.graphs = self.management.graphs
|
||||||
|
|
||||||
self.ac_group = QtWidgets.QActionGroup(self)
|
self.ac_group = QtWidgets.QActionGroup(self)
|
||||||
self.ac_group.addAction(self.action_lm_fit)
|
self.ac_group.addAction(self.action_lm_fit)
|
||||||
@ -276,7 +277,8 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
|||||||
@QtCore.pyqtSlot(list)
|
@QtCore.pyqtSlot(list)
|
||||||
def save_fit_parameter(self, fit_sets: list[str] = None):
|
def save_fit_parameter(self, fit_sets: list[str] = None):
|
||||||
fname, _ = QtWidgets.QFileDialog.getSaveFileName(self, 'Save fit parameter', directory=str(self.path),
|
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:
|
if fname:
|
||||||
self.management.save_fit_parameter(fname, fit_sets=fit_sets)
|
self.management.save_fit_parameter(fname, fit_sets=fit_sets)
|
||||||
|
Loading…
Reference in New Issue
Block a user