save previews in graphics
This commit is contained in:
parent
8d148b639b
commit
0ba872571b
@ -413,7 +413,15 @@ class QFitDialog(QtWidgets.QWidget, Ui_FitDialog):
|
||||
parameters = model['parameter']
|
||||
color = model['color']
|
||||
|
||||
seen_parameter = []
|
||||
|
||||
for p, kwargs in parameters.values():
|
||||
if (p, kwargs) in seen_parameter:
|
||||
# plot only previews with different parameter
|
||||
continue
|
||||
|
||||
seen_parameter.append((p, kwargs))
|
||||
|
||||
if is_complex is not None:
|
||||
y = f.func(x, *p, complex_mode=is_complex, **kwargs)
|
||||
if np.iscomplexobj(y):
|
||||
|
@ -48,6 +48,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
self.error_plots = {}
|
||||
|
||||
self._special_needs = []
|
||||
self._external_items = []
|
||||
self.closable = True
|
||||
|
||||
self.log = [False, False]
|
||||
@ -109,7 +110,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
def __len__(self):
|
||||
return len(self.active)
|
||||
|
||||
def curves(self):
|
||||
def curves(self) -> tuple:
|
||||
for a in self.active:
|
||||
if self.real_button.isChecked():
|
||||
if self.error_plots[a] is not None:
|
||||
@ -318,6 +319,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
if not hasattr(item, 'setLogMode'):
|
||||
self._special_needs.append(item)
|
||||
|
||||
self._external_items.append(item)
|
||||
self.graphic.addItem(item)
|
||||
item.setZValue(1000)
|
||||
|
||||
@ -325,12 +327,15 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
|
||||
@QtCore.pyqtSlot(GraphicsObject)
|
||||
def remove_external(self, item):
|
||||
if item not in self.graphic.items():
|
||||
return False
|
||||
if item in self._external_items:
|
||||
self._external_items.remove(item)
|
||||
|
||||
if item in self._special_needs:
|
||||
self._special_needs.remove(item)
|
||||
|
||||
if item not in self.graphic.items():
|
||||
return False
|
||||
|
||||
self.graphic.removeItem(item)
|
||||
|
||||
return True
|
||||
@ -599,6 +604,10 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
if item_dic:
|
||||
dic['items'].append(item_dic)
|
||||
|
||||
for item in self._external_items:
|
||||
dic['items'].append(item.get_data_opts())
|
||||
in_legend.append(False)
|
||||
|
||||
dic['in_legend'] = in_legend
|
||||
|
||||
return dic
|
||||
|
@ -336,8 +336,8 @@ class PlotItem(PlotDataItem):
|
||||
opts = self.opts
|
||||
item_dic = {
|
||||
'x': x, 'y': y,
|
||||
'name': opts['name'],
|
||||
'symbolsize': opts['symbolSize']
|
||||
'name': opts.get('name', ''),
|
||||
'symbolsize': opts['symbolSize'],
|
||||
}
|
||||
|
||||
if opts['symbol'] is None:
|
||||
|
@ -144,6 +144,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
self.actionPick_position.triggered.connect(lambda: self._show_tab('pick'))
|
||||
self.actionIntegrate.triggered.connect(lambda: self._show_tab('integrate'))
|
||||
self.action_FitWidget.triggered.connect(lambda: self._show_tab('fit'))
|
||||
self.action_draw_object.triggered.connect(lambda: self._show_tab('drawing'))
|
||||
|
||||
self.action_new_set.triggered.connect(self.management.create_empty)
|
||||
|
||||
@ -455,6 +456,31 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
self.current_graph_widget.enable_picking(pick)
|
||||
self.current_graph_widget.closable = not block
|
||||
|
||||
def _show_tab(self, mode: str):
|
||||
widget, name = {
|
||||
't1_temp': (self.t1tauwidget, 'T1 mininmon'),
|
||||
'signal': (self.editsignalwidget, 'Signals'),
|
||||
'pick': (self.ptsselectwidget, 'Pick points'),
|
||||
'fit': (self.fit_dialog, 'Fit'),
|
||||
'drawing': (self.drawingswidget, 'Draw'),
|
||||
}[mode]
|
||||
|
||||
for idx in range(self.tabWidget.count()):
|
||||
if self.tabWidget.widget(idx) == widget:
|
||||
self.tabWidget.setCurrentIndex(idx)
|
||||
return
|
||||
|
||||
self.tabWidget.addTab(widget, name)
|
||||
self.tabWidget.setCurrentIndex(self.tabWidget.count()-1)
|
||||
|
||||
@QtCore.pyqtSlot(int, name='on_tabWidget_tabCloseRequested')
|
||||
def close_tab(self, idx: int):
|
||||
if idx == 0:
|
||||
pass
|
||||
else:
|
||||
self.tabWidget.setCurrentIndex(0)
|
||||
self.tabWidget.removeTab(idx)
|
||||
|
||||
@QtCore.pyqtSlot(int, name='on_tabWidget_currentChanged')
|
||||
def toggle_tabs(self, idx: int):
|
||||
widget = self.tabWidget.widget(idx)
|
||||
@ -493,30 +519,6 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
|
||||
|
||||
return pick_required, block_window
|
||||
|
||||
@QtCore.pyqtSlot(int, name='on_tabWidget_tabCloseRequested')
|
||||
def close_tab(self, idx: int):
|
||||
if idx == 0:
|
||||
pass
|
||||
else:
|
||||
self.tabWidget.setCurrentIndex(0)
|
||||
self.tabWidget.removeTab(idx)
|
||||
|
||||
def _show_tab(self, mode: str):
|
||||
widget, name = {
|
||||
't1_temp': (self.t1tauwidget, 'T1 mininmon'),
|
||||
'signal': (self.editsignalwidget, 'Signals'),
|
||||
'pick': (self.ptsselectwidget, 'Pick points'),
|
||||
'fit': (self.fit_dialog, 'Fit')
|
||||
}[mode]
|
||||
|
||||
for idx in range(self.tabWidget.count()):
|
||||
if self.tabWidget.widget(idx) == widget:
|
||||
self.tabWidget.setCurrentIndex(idx)
|
||||
return
|
||||
|
||||
self.tabWidget.addTab(widget, name)
|
||||
self.tabWidget.setCurrentIndex(self.tabWidget.count()-1)
|
||||
|
||||
def _select_valuewidget(self, onoff: bool):
|
||||
if onoff: # Values
|
||||
self.valuewidget(self.management.graphs.tree())
|
||||
|
@ -157,66 +157,66 @@ class BaseColor(enum.Enum):
|
||||
|
||||
|
||||
class TUColorsA(BaseColor):
|
||||
TuDa1a = (93, 133, 195)
|
||||
TuDa2a = (0, 156, 218)
|
||||
TuDa3a = (80, 182, 149)
|
||||
TuDa4a = (175, 204, 80)
|
||||
TuDa5a = (221, 223, 72)
|
||||
TuDa6a = (255, 224, 92)
|
||||
TuDa7a = (248, 186, 60)
|
||||
TuDa8a = (238, 122, 52)
|
||||
TuDa9a = (233, 80, 62)
|
||||
TuDa10a = (201, 48, 142)
|
||||
TuDa11a = (128, 69, 151)
|
||||
TUDa1a = (93, 133, 195)
|
||||
TUDa2a = (0, 156, 218)
|
||||
TUDa3a = (80, 182, 149)
|
||||
TUDa4a = (175, 204, 80)
|
||||
TUDa5a = (221, 223, 72)
|
||||
TUDa6a = (255, 224, 92)
|
||||
TUDa7a = (248, 186, 60)
|
||||
TUDa8a = (238, 122, 52)
|
||||
TUDa9a = (233, 80, 62)
|
||||
TUDa10a = (201, 48, 142)
|
||||
TUDa11a = (128, 69, 151)
|
||||
|
||||
|
||||
class TUColorsB(BaseColor):
|
||||
TuDa1b = (0, 90, 169)
|
||||
TuDa2b = (0, 131, 204)
|
||||
TuDa3b = (0, 157, 129)
|
||||
TuDa4b = (153, 192, 0)
|
||||
TuDa5b = (201, 212, 0)
|
||||
TuDa6b = (253, 202, 0)
|
||||
TuDa7b = (245, 163, 0)
|
||||
TuDa8b = (236, 101, 0)
|
||||
TuDa9b = (230, 0, 26)
|
||||
TuDa10b = (166, 0, 132)
|
||||
TuDa11b = (114, 16, 133)
|
||||
TUDa1b = (0, 90, 169)
|
||||
TUDa2b = (0, 131, 204)
|
||||
TUDa3b = (0, 157, 129)
|
||||
TUDa4b = (153, 192, 0)
|
||||
TUDa5b = (201, 212, 0)
|
||||
TUDa6b = (253, 202, 0)
|
||||
TUDa7b = (245, 163, 0)
|
||||
TUDa8b = (236, 101, 0)
|
||||
TUDa9b = (230, 0, 26)
|
||||
TUDa10b = (166, 0, 132)
|
||||
TUDa11b = (114, 16, 133)
|
||||
|
||||
|
||||
class TUColorsC(BaseColor):
|
||||
TuDa1c = (0, 78, 138)
|
||||
TuDa2c = (0, 104, 157)
|
||||
TuDa3c = (0, 136, 119)
|
||||
TuDa4c = (127, 171, 22)
|
||||
TuDa5c = (177, 189, 0)
|
||||
TuDa6c = (215, 172, 0)
|
||||
TuDa7c = (210, 135, 0)
|
||||
TuDa8c = (204, 76, 3)
|
||||
TuDa9c = (185, 15, 34)
|
||||
TuDa10c = (149, 17, 105)
|
||||
TuDa11c = (97, 28, 115)
|
||||
TUDa1c = (0, 78, 138)
|
||||
TUDa2c = (0, 104, 157)
|
||||
TUDa3c = (0, 136, 119)
|
||||
TUDa4c = (127, 171, 22)
|
||||
TUDa5c = (177, 189, 0)
|
||||
TUDa6c = (215, 172, 0)
|
||||
TUDa7c = (210, 135, 0)
|
||||
TUDa8c = (204, 76, 3)
|
||||
TUDa9c = (185, 15, 34)
|
||||
TUDa10c = (149, 17, 105)
|
||||
TUDa11c = (97, 28, 115)
|
||||
|
||||
|
||||
class TUColorsD(BaseColor):
|
||||
TuDa1d = (36, 53, 114)
|
||||
TuDa2d = (0, 78, 115)
|
||||
TuDa3d = (0, 113, 94)
|
||||
TuDa4d = (106, 139, 55)
|
||||
TuDa5d = (153, 166, 4)
|
||||
TuDa6d = (174, 142, 0)
|
||||
TuDa7d = (190, 111, 0)
|
||||
TuDa8d = (169, 73, 19)
|
||||
TuDa9d = (156, 28, 38)
|
||||
TuDa10d = (115, 32, 84)
|
||||
TuDa11d = (76, 34, 106)
|
||||
TUDa1d = (36, 53, 114)
|
||||
TUDa2d = (0, 78, 115)
|
||||
TUDa3d = (0, 113, 94)
|
||||
TUDa4d = (106, 139, 55)
|
||||
TUDa5d = (153, 166, 4)
|
||||
TUDa6d = (174, 142, 0)
|
||||
TUDa7d = (190, 111, 0)
|
||||
TUDa8d = (169, 73, 19)
|
||||
TUDa9d = (156, 28, 38)
|
||||
TUDa10d = (115, 32, 84)
|
||||
TUDa11d = (76, 34, 106)
|
||||
|
||||
|
||||
class TUGrays(BaseColor):
|
||||
TuDa0a = (220, 220, 220)
|
||||
TuDa0b = (181, 181, 181)
|
||||
TuDa0c = (137, 137, 137)
|
||||
TuDa0d = (83, 83, 83)
|
||||
TUDa0a = (220, 220, 220)
|
||||
TUDa0b = (181, 181, 181)
|
||||
TUDa0c = (137, 137, 137)
|
||||
TUDa0d = (83, 83, 83)
|
||||
White = (255, 255, 255)
|
||||
Black = (0, 0, 0)
|
||||
|
||||
@ -236,17 +236,16 @@ class RedBlue(BaseColor):
|
||||
|
||||
|
||||
class Tab10(BaseColor):
|
||||
TabBlue = (31, 119, 180)
|
||||
TabOrange = (255, 127, 14)
|
||||
TabGreen = (44, 160, 44)
|
||||
TabRed = (214, 39, 40)
|
||||
TabPurple = (148, 103, 189)
|
||||
TabBrown = (140, 86, 75)
|
||||
TabRose = (227, 119, 194)
|
||||
TabGrey = (220, 220, 220)
|
||||
TabChartreuse = (188, 189, 34)
|
||||
TabTurquoise = (23, 190, 207)
|
||||
|
||||
TabBlue = TUColorsB.TUDa2b.value
|
||||
TabOrange = TUColorsA.TUDa8a.value
|
||||
TabGreen = TUColorsD.TUDa4d.value
|
||||
TabRed = TUColorsB.TUDa9b.value
|
||||
TabPurple = TUColorsA.TUDa11a.value
|
||||
TabBrown = TUColorsD.TUDa8d.value
|
||||
TabRose = TUColorsA.TUDa10a.value
|
||||
TabGrey = TUGrays.TUDa0a.value
|
||||
TabChartreuse = TUColorsC.TUDa5c.value
|
||||
TabTurquoise = TUColorsA.TUDa2a.value
|
||||
|
||||
class Tab20(BaseColor):
|
||||
TabBlue = (31, 119, 180)
|
||||
@ -395,17 +394,17 @@ def ciede2000(c1: BaseColor, c2: BaseColor):
|
||||
|
||||
def get_palettes():
|
||||
palettes = {
|
||||
'TuDa': TUColors,
|
||||
'TuDa:a': TUColorsA,
|
||||
'TuDa:b': TUColorsB,
|
||||
'TuDa:c': TUColorsC,
|
||||
'TuDa:d': TUColorsD,
|
||||
'TuDa:gray': TUGrays,
|
||||
'TUDa': TUColors,
|
||||
'TUDa:a': TUColorsA,
|
||||
'TUDa:b': TUColorsB,
|
||||
'TUDa:c': TUColorsC,
|
||||
'TUDa:d': TUColorsD,
|
||||
'TUDa:gray': TUGrays,
|
||||
'Grace': GraceColors,
|
||||
'mpl': [Colors.TuDa2b, Colors.TuDa8a, Colors.TuDa4d, Colors.TuDa9b, Colors.TuDa11a,
|
||||
Colors.TuDa8d, Colors.TuDa10a, Colors.TuDa0a, Colors.TuDa5c, Colors.TuDa2a],
|
||||
'colorblind': [Colors.TuDa2c, Colors.TuDa8a, Colors.TuDa0b, Colors.TuDa0d, Colors.TuDa2a,
|
||||
Colors.TuDa8c, Colors.TuDa0c, Colors.TuDa2b, Colors.TuDa7a, Colors.TuDa0a],
|
||||
'mpl': [Colors.TUDa2b, Colors.TUDa8a, Colors.TUDa4d, Colors.TUDa9b, Colors.TUDa11a,
|
||||
Colors.TUDa8d, Colors.TUDa10a, Colors.TUDa0a, Colors.TUDa5c, Colors.TUDa2a],
|
||||
'colorblind': [Colors.TUDa2c, Colors.TUDa8a, Colors.TUDa0b, Colors.TUDa0d, Colors.TUDa2a,
|
||||
Colors.TUDa8c, Colors.TUDa0c, Colors.TUDa2b, Colors.TUDa7a, Colors.TUDa0a],
|
||||
}
|
||||
|
||||
user_colors = config_paths() / 'colors.cfg'
|
||||
|
@ -61,54 +61,54 @@
|
||||
@map font 13 to "ZapfDingbats", "ZapfDingbats"
|
||||
@map color 0 to (255, 255, 255), "white"
|
||||
@map color 1 to (0, 0, 0), "black"
|
||||
@map color 2 to (93, 133, 195), "TuDa1a"
|
||||
@map color 3 to (0, 156, 218), "TuDa2a"
|
||||
@map color 4 to (80, 182, 149), "TuDa3a"
|
||||
@map color 5 to (176, 204, 80), "TuDa4a"
|
||||
@map color 6 to (221, 223, 72), "TuDa5a"
|
||||
@map color 7 to (255, 224, 92), "TuDa6a"
|
||||
@map color 8 to (248, 186, 60), "TuDa7a"
|
||||
@map color 9 to (238, 122, 52), "TuDa8a"
|
||||
@map color 10 to (233, 80, 62), "TuDa9a"
|
||||
@map color 11 to (201, 48, 142), "TuDa10a"
|
||||
@map color 12 to (128, 69, 151), "TuDa11a"
|
||||
@map color 13 to (0, 90, 169), "TuDa1b"
|
||||
@map color 14 to (0, 130, 204), "TuDa2b"
|
||||
@map color 15 to (0, 157, 129), "TuDa3b"
|
||||
@map color 16 to (153, 192, 0), "TuDa4b"
|
||||
@map color 17 to (201, 212, 0), "TuDa5b"
|
||||
@map color 18 to (253, 202, 0), "TuDa6b"
|
||||
@map color 19 to (248, 163, 0), "TuDa7b"
|
||||
@map color 20 to (236, 101, 0), "TuDa8b"
|
||||
@map color 21 to (239, 0, 26), "TuDa9b"
|
||||
@map color 22 to (166, 0, 132), "TuDa10b"
|
||||
@map color 23 to (114, 16, 133), "TuDa11b"
|
||||
@map color 24 to (0, 78, 138), "TuDa1c"
|
||||
@map color 25 to (0, 104, 157), "TuDa2c"
|
||||
@map color 26 to (0, 136, 119), "TuDa3c"
|
||||
@map color 27 to (127, 171, 22), "TuDa4c"
|
||||
@map color 28 to (177, 189, 0), "TuDa5c"
|
||||
@map color 29 to (215, 172, 0), "TuDa6c"
|
||||
@map color 30 to (210, 135, 0), "TuDa7c"
|
||||
@map color 31 to (204, 76, 3), "TuDa8c"
|
||||
@map color 32 to (185, 15, 34), "TuDa9c"
|
||||
@map color 33 to (149, 17, 105), "TuDa10c"
|
||||
@map color 34 to (97, 28, 115), "TuDa11c"
|
||||
@map color 35 to (36, 53, 114), "TuDa1d"
|
||||
@map color 36 to (0, 78, 115), "TuDa2d"
|
||||
@map color 37 to (0, 113, 94), "TuDa3d"
|
||||
@map color 38 to (106, 139, 55), "TuDa4d"
|
||||
@map color 39 to (153, 166, 4), "TuDa5d"
|
||||
@map color 40 to (174, 142, 0), "TuDa6d"
|
||||
@map color 41 to (190, 111, 0), "TuDa7d"
|
||||
@map color 42 to (169, 73, 19), "TuDa8d"
|
||||
@map color 43 to (188, 28, 38), "TuDa9d"
|
||||
@map color 44 to (115, 32, 84), "TuDa10d"
|
||||
@map color 45 to (76, 34, 106), "TuDa11d"
|
||||
@map color 46 to (220, 220, 220), "TuDa0a"
|
||||
@map color 47 to (181, 181, 181), "TuDa0b"
|
||||
@map color 48 to (137, 137, 137), "TuDa0c"
|
||||
@map color 49 to (83, 83, 83), "TuDa0d"
|
||||
@map color 2 to (93, 133, 195), "TUDa1a"
|
||||
@map color 3 to (0, 156, 218), "TUDa2a"
|
||||
@map color 4 to (80, 182, 149), "TUDa3a"
|
||||
@map color 5 to (176, 204, 80), "TUDa4a"
|
||||
@map color 6 to (221, 223, 72), "TUDa5a"
|
||||
@map color 7 to (255, 224, 92), "TUDa6a"
|
||||
@map color 8 to (248, 186, 60), "TUDa7a"
|
||||
@map color 9 to (238, 122, 52), "TUDa8a"
|
||||
@map color 10 to (233, 80, 62), "TUDa9a"
|
||||
@map color 11 to (201, 48, 142), "TUDa10a"
|
||||
@map color 12 to (128, 69, 151), "TUDa11a"
|
||||
@map color 13 to (0, 90, 169), "TUDa1b"
|
||||
@map color 14 to (0, 131, 204), "TUDa2b"
|
||||
@map color 15 to (0, 157, 129), "TUDa3b"
|
||||
@map color 16 to (153, 192, 0), "TUDa4b"
|
||||
@map color 17 to (201, 212, 0), "TUDa5b"
|
||||
@map color 18 to (253, 202, 0), "TUDa6b"
|
||||
@map color 19 to (248, 163, 0), "TUDa7b"
|
||||
@map color 20 to (236, 101, 0), "TUDa8b"
|
||||
@map color 21 to (239, 0, 26), "TUDa9b"
|
||||
@map color 22 to (166, 0, 132), "TUDa10b"
|
||||
@map color 23 to (114, 16, 133), "TUDa11b"
|
||||
@map color 24 to (0, 78, 138), "TUDa1c"
|
||||
@map color 25 to (0, 104, 157), "TUDa2c"
|
||||
@map color 26 to (0, 136, 119), "TUDa3c"
|
||||
@map color 27 to (127, 171, 22), "TUDa4c"
|
||||
@map color 28 to (177, 189, 0), "TUDa5c"
|
||||
@map color 29 to (215, 172, 0), "TUDa6c"
|
||||
@map color 30 to (210, 135, 0), "TUDa7c"
|
||||
@map color 31 to (204, 76, 3), "TUDa8c"
|
||||
@map color 32 to (185, 15, 34), "TUDa9c"
|
||||
@map color 33 to (149, 17, 105), "TUDa10c"
|
||||
@map color 34 to (97, 28, 115), "TUDa11c"
|
||||
@map color 35 to (36, 53, 114), "TUDa1d"
|
||||
@map color 36 to (0, 78, 115), "TUDa2d"
|
||||
@map color 37 to (0, 113, 94), "TUDa3d"
|
||||
@map color 38 to (106, 139, 55), "TUDa4d"
|
||||
@map color 39 to (153, 166, 4), "TUDa5d"
|
||||
@map color 40 to (174, 142, 0), "TUDa6d"
|
||||
@map color 41 to (190, 111, 0), "TUDa7d"
|
||||
@map color 42 to (169, 73, 19), "TUDa8d"
|
||||
@map color 43 to (188, 28, 38), "TUDa9d"
|
||||
@map color 44 to (115, 32, 84), "TUDa10d"
|
||||
@map color 45 to (76, 34, 106), "TUDa11d"
|
||||
@map color 46 to (220, 220, 220), "TUDa0a"
|
||||
@map color 47 to (181, 181, 181), "TUDa0b"
|
||||
@map color 48 to (137, 137, 137), "TUDa0c"
|
||||
@map color 49 to (83, 83, 83), "TUDa0d"
|
||||
@map color 50 to (255, 0, 0), "red"
|
||||
@map color 51 to (0, 255, 0), "green"
|
||||
@map color 52 to (0, 0, 255), "blue"
|
||||
|
Loading…
Reference in New Issue
Block a user