convert removes agr controls
This commit is contained in:
parent
b6136bc8ce
commit
141e9f810a
@ -4,6 +4,7 @@ from nmreval.lib.lines import LineStyle
|
||||
from nmreval.lib.symbols import SymbolStyle
|
||||
from nmreval.data.points import Points
|
||||
from nmreval.io.graceeditor import GraceEditor
|
||||
from nmreval.utils.text import convert
|
||||
|
||||
from ..Qt import QtCore, QtWidgets, QtGui
|
||||
from .._py.gracereader import Ui_Dialog
|
||||
@ -55,7 +56,7 @@ class QGraceReader(QtWidgets.QDialog, Ui_Dialog):
|
||||
if ds is None:
|
||||
continue
|
||||
|
||||
item_2 = QtWidgets.QTreeWidgetItem([f'Set {gset.idx} (Label: {gset.get_property("legend")}, '
|
||||
item_2 = QtWidgets.QTreeWidgetItem([f'Set {gset.idx} (Label: {convert(gset.get_property("legend"), old="agr", new="str")}, '
|
||||
f'shape: {ds.shape})'])
|
||||
item_2.setCheckState(0, QtCore.Qt.Checked)
|
||||
item_2.setData(0, QtCore.Qt.UserRole, (graphs.idx, gset.idx))
|
||||
@ -94,6 +95,7 @@ class QGraceReader(QtWidgets.QDialog, Ui_Dialog):
|
||||
label = ''
|
||||
else:
|
||||
label = label.replace('"', '')
|
||||
label = convert(label, old='agr', new='str')
|
||||
sd = s.data
|
||||
sd = np.atleast_2d(sd)
|
||||
if s.type == 'xydy':
|
||||
|
@ -80,6 +80,10 @@ def _replace_delims(text, src, dest):
|
||||
return text
|
||||
|
||||
|
||||
def _replace_agr_controls(text: str):
|
||||
return re.sub(r'\\[hvzfx]\{(\d*.?\d+.?)?\}', '', text)
|
||||
|
||||
|
||||
def convert(text: str, old: str = 'tex', new: str = 'html', brackets: bool = True):
|
||||
t = {'latex': 0, 'tex': 0, 'html': 1,
|
||||
'agr': 2, 'plain': 3, 'str': 3}
|
||||
@ -101,5 +105,8 @@ def convert(text: str, old: str = 'tex', new: str = 'html', brackets: bool = Tru
|
||||
if idx_out == 3 and not brackets:
|
||||
text = text.replace('{', '').replace('}', '')
|
||||
|
||||
if idx_in == 2:
|
||||
text = _replace_agr_controls(text)
|
||||
|
||||
return text
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user