From e063abc712a611e238ffa806577dda8ea34f181f Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Thu, 23 Nov 2023 19:43:50 +0100 Subject: [PATCH] fix grace export bugs; closes #155 --- src/gui_qt/graphs/graphwindow.py | 1 + src/gui_qt/io/exporters.py | 39 ++++++++++++++++++++++---------- src/nmreval/utils/text.py | 4 ++-- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/gui_qt/graphs/graphwindow.py b/src/gui_qt/graphs/graphwindow.py index f25485d..7f8356a 100644 --- a/src/gui_qt/graphs/graphwindow.py +++ b/src/gui_qt/graphs/graphwindow.py @@ -690,6 +690,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow): 'plots': (self.real_button.isChecked(), self.imag_button.isChecked(), self.error_button.isChecked()), 'children': self.sets, 'active': self._active, + 'invert': (self.plotItem.vb.state['xInverted'], self.plotItem.vb.state['yInverted']), } in_legend = [] diff --git a/src/gui_qt/io/exporters.py b/src/gui_qt/io/exporters.py index 75b4a55..a394322 100644 --- a/src/gui_qt/io/exporters.py +++ b/src/gui_qt/io/exporters.py @@ -28,14 +28,19 @@ class GraceExporter: new_g.set_log(x=self.__opts['log'][0], y=self.__opts['log'][1]) new_g.set_onoff('legend', self.__opts['legend']) - new_g.set_property(**{'title': f'"{convert(self.__opts["labels"][2], old="html", new="agr")}"', - 'legend loctype': 'view', - 'legend': ', '.join(str(i) for i in new_g.world_to_view(self.__opts['legend_pos']))}) + new_g.set_property(**{ + 'title': f'"{convert(self.__opts["labels"][2], old="html", new="agr")}"', + 'legend loctype': 'view', + 'legend': ', '.join(str(i) for i in new_g.world_to_view(self.__opts['legend_pos'])) + }) for i, ax in enumerate('xy'): - new_g.set_axis_property(ax, **{'label': f'"{convert(self.__opts["labels"][i], old="html", new="agr")}"', - 'tick major': self.__opts['ticks'][i][0], - 'tick minor ticks': self.__opts['ticks'][i][1],}) + new_g.set_axis_property(ax, **{ + 'label': f'"{convert(self.__opts["labels"][i], old="html", new="agr")}"', + 'tick major': self.__opts['ticks'][i][0], + 'tick minor ticks': self.__opts['ticks'][i][1], + 'invert': 'on' if self.__opts['invert'][i] else 'off', + }) new_g.set_axis_onoff(ax, 'tick major grid', self.__opts['grid']) g_idx = new_g.idx else: @@ -59,8 +64,13 @@ class GraceExporter: colors[c_num] = (f'color{c_num}', sc) new_colors.append((c_num, f'color{c_num}', sc)) - new_s.set_symbol(**{'symbol': item['symbol'].value, 'size': item['symbolsize'] / 10., 'color': c_num, - 'fill color': c_num, 'fill pattern': 1}) + new_s.set_symbol(**{ + 'symbol': item['symbol'].value, + 'size': item['symbolsize'] / 10., + 'color': c_num, + 'fill color': c_num, + 'fill pattern': 1 + }) new_s.set_onoff('errorbar', self.__opts['plots'][2]) lc = item['linecolor'] @@ -74,12 +84,17 @@ class GraceExporter: colors[c_num + 1] = () new_colors.append((c_num, f'color{c_num + 1}', sc)) - new_s.set_line(**{'color': c_num, 'linewidth': item['linewidth'], - 'linestyle': item['linestyle'].to_agr()}) + new_s.set_line(**{ + 'color': c_num, + 'linewidth': item['linewidth'], + 'linestyle': item['linestyle'].to_agr() + }) if plot_label: - new_s.set_property(comment=f'"{item["name"]}"', - legend=f'"{convert(item["name"], old="tex", new="agr")}"') + new_s.set_property( + comment=f'"{item["name"]}"', + legend=f'"{convert(item["name"], old="tex", new="agr")}"' + ) else: new_s.set_property(comment=f'"{item["name"]}"') diff --git a/src/nmreval/utils/text.py b/src/nmreval/utils/text.py index 7a8e8ba..7f37403 100644 --- a/src/nmreval/utils/text.py +++ b/src/nmreval/utils/text.py @@ -33,9 +33,9 @@ big_greek = [ special_chars = [ r'\infty \int \sum \langle \rangle \pm \perp \para \leftarrow \rightarrow \leftrightarrow \cdot \hbar \n', '\u221e \u222b \u2211 \u27e8 \u27e9 \u00b1 \u27c2 \u2225 \u21d0 \u21d2 \u21d4 \u00b7 \u0127
', - r'\f{Symbol}¥\f{} \f{Symbol}ò\f{} \f{Symbol}å\f{} \f{Symbol}á\f{} \f{Symbol}ñ\f{} \f{Symbol}±\f{} \n' + r'\f{Symbol}¥\f{} \f{Symbol}ò\f{} \f{Symbol}å\f{} \f{Symbol}á\f{} \f{Symbol}ñ\f{} \f{Symbol}±\f{} ' r'\f{Symbol}^\f{} \f{Symbol}||\f{} \f{Symbol}¬\f{} \f{Symbol}®\f{} \f{Symbol}«\f{} \f{Symbol}×\f{Symbol} ' - r'h\h{-0.6}\v{0.3}-\v{-0.3}\h{0.3}', + r'h\h{-0.6}\v{0.3}-\v{-0.3}\h{0.3} \n', r'infty int sum < > \+- perp para <- -> <-> \* hbar \s', ] funcs = [