Commit 2dff3afb authored by Yan's avatar Yan
Browse files

Legend can be hided

* view/legend settings added
parent f640b043
......@@ -13,7 +13,7 @@ from . import zcetools_help
from . import reactivitytools
__version__ = "0.0.35"
__version__ = "0.0.36"
__all__ = ['config', 'datatools', 'docks', 'drltools', 'drltoos_gui', 'filetools',
......
......@@ -233,6 +233,14 @@ def oddeven_changed(augCanvas, config, oddevenact):
update_spectrum(augCanvas, config)
def legendvis_changed(augCanvas, config, legendact):
config.setValue("view/legend",legendact.isChecked())
if augCanvas.chromplot.get_legend():
for ax in (augCanvas.spectplot, augCanvas.chromplot):
ax.get_legend().set_visible(config.value("view/legend", type=bool))
augCanvas.draw()
def paint_override(self, augCanvas):
self.plot.set_xlim(augCanvas.spectplot.get_xlim())
self.plot.set_ylim(augCanvas.spectplot.get_ylim())
......@@ -389,6 +397,11 @@ def main():
intensitiesact.triggered.connect(lambda: gt.ann_spec(
augCanvas.spectplot, augCanvas.ms))
intensitiesact.triggered.connect(lambda: augCanvas.draw())
legendact = QtWidgets.QAction(
"&Show legend", None, checkable=True,
checked=config.value("view/legend", type=bool))
legendact.triggered.connect(lambda: legendvis_changed(
augCanvas, config, legendact))
oddevenact = QtWidgets.QAction(
"&Odd / even", None, checkable=True,
checked=config.value("view/oddeven", type=bool))
......@@ -424,7 +437,7 @@ def main():
view_menu = QtWidgets.QMenu('&View', main_window)
[view_menu.addAction(i.action) for i in
(treedock, paramsdock, consoledock)]
[view_menu.addAction(i) for i in (autozoomy, intensitiesact)]
[view_menu.addAction(i) for i in (autozoomy, intensitiesact, legendact)]
view_menu.addSeparator()
view_menu.addAction(oddevenact)
main_window.menuBar().addMenu(view_menu)
......
......@@ -12,6 +12,7 @@ def settings():
("view/acqparvisible", True),
("view/intensities", False),
("view/oddeven", False),
("view/legend", True),
("print/msspec_xinch", 10),
("print/msspec_yinch", 4),
("print/msspec_dpi", 300),
......
......@@ -281,10 +281,11 @@ def plot_subtime(augCanvas):
if not cf.settings().value("view/autozoomy", type=bool):
augCanvas.spectplot.set_ylim(slims[1])
if not augCanvas.ms['headers'] == []:
augCanvas.spectplot.legend(loc=2)
augCanvas.spectplot.get_legend().set_in_layout(False)
augCanvas.chromplot.legend(loc=2)
augCanvas.chromplot.get_legend().set_in_layout(False)
for ax in (augCanvas.spectplot, augCanvas.chromplot):
ax.legend(loc=2)
ax.get_legend().set_in_layout(False)
ax.get_legend().set_visible(
cf.settings().value("view/legend", type=bool))
else:
autozoomy(augCanvas.spectplot)
ann_spec(augCanvas.spectplot, augCanvas.ms)
......@@ -514,6 +515,8 @@ def populate(augCanvas):
if not augCanvas.ms['headers'] == []:
ax.legend(loc=2)
ax.get_legend().set_in_layout(False)
ax.get_legend().set_visible(
cf.settings().value("view/legend", type=bool))
ax.autoscale(True)
ax.set_ylim(ax.get_ylim()[1]*-0.01, ax.get_ylim()[1]*1.1)
augCanvas.constrained_draw()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment