Commit 26458223 authored by Valentin Valls's avatar Valentin Valls

Add min state to the GUI

parent 7df9f31a
......@@ -525,6 +525,46 @@ class CurvePlotWidget(ExtendedDockWidget):
yaxis=item.yAxis(),
)
plotItems.append((key, "marker"))
elif isinstance(item, plot_state_model.MinCurveItem):
legend = str(item) + "/" + str(scan)
result = item.reachResult(scan)
if item.isResultValid(result):
style = item.getStyle(scan)
height = result.max_y_value - result.min_location_y
xx = numpy.array([result.min_location_x, result.min_location_x])
text_location_y = result.min_location_y - height * 0.1
yy = numpy.array([result.min_location_y, text_location_y])
curveItem = Curve()
curveItem.setData(x=xx, y=yy, copy=False)
curveItem._setLegend(legend)
curveItem._setSelectable(False)
curveItem.setLineStyle(style.lineStyle)
curveItem.setColor(style.lineColor)
curveItem.setSymbol("")
curveItem.setYAxis(item.yAxis())
plot._add(curveItem)
plotItems.append((legend, "curve"))
key = plot.addMarker(
legend=legend + "_text",
x=result.min_location_x,
y=text_location_y,
symbol=",",
text="min",
color=style.lineColor,
yaxis=item.yAxis(),
)
plotItems.append((key, "marker"))
key = plot.addMarker(
legend=legend + "_pos",
x=result.min_location_x,
y=result.min_location_y,
symbol="x",
text="",
color=style.lineColor,
yaxis=item.yAxis(),
)
plotItems.append((key, "marker"))
elif isinstance(item, plot_item_model.MotorPositionMarker):
if item.isValid():
......
......@@ -242,6 +242,13 @@ class _AddItemAction(qt.QWidgetAction):
action.triggered.connect(self.__createMax)
menu.addAction(action)
action = qt.QAction(self)
action.setText("Min marker")
icon = icons.getQIcon("flint:icons/item-stats")
action.setIcon(icon)
action.triggered.connect(self.__createMin)
menu.addAction(action)
menu.addSection("Functions")
action = qt.QAction(self)
......@@ -290,6 +297,15 @@ class _AddItemAction(qt.QWidgetAction):
with plot.transaction():
plot.addItem(newItem)
def __createMin(self):
parentItem = self.__getSelectedPlotItem()
if parentItem is not None:
plot = parentItem.plot()
newItem = plot_state_model.MinCurveItem(plot)
newItem.setSource(parentItem)
with plot.transaction():
plot.addItem(newItem)
def __createDerivative(self):
parentItem = self.__getSelectedPlotItem()
if parentItem is not None:
......
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