diff --git a/docs/source/_static/widgets/curve_editor/curve_editor.gif b/docs/source/_static/widgets/curve_editor/curve_editor.gif new file mode 100644 index 000000000..86166e75f Binary files /dev/null and b/docs/source/_static/widgets/curve_editor/curve_editor.gif differ diff --git a/docs/source/widgets/curve_editor.rst b/docs/source/widgets/curve_editor.rst new file mode 100644 index 000000000..29e562986 --- /dev/null +++ b/docs/source/widgets/curve_editor.rst @@ -0,0 +1,26 @@ +####################### +Plot Curve Editor +####################### + +PyDM plot widgets keep the inventory of curves in the ``curves`` property which +is a list of JSON strings containing the definition of parameters for each of +the curves in a plot. + +Since editing a list of JSON strings via Qt Designer is very unfriendly and +error prone, PyDM offers the Plot Curve Editor extension which can be invoked +via a Right-click and selecting the "Edit Curves..." item in the context menu +that pops-up. + +.. figure:: /_static/widgets/curve_editor/curve_editor.gif + :scale: 100 % + :align: center + :alt: Curve Editor in Action + + This animation demonstrates how to use the Curve Editor that is common to + all the PyDM plot widgets. + + +.. Note:: + This is not applicable for users interacting with widgets via Python code. + In this case you will need to serialize the list of JSON strings and use the + ``setCurves`` property to configure the plot properly. diff --git a/docs/source/widgets/index.rst b/docs/source/widgets/index.rst index 9dac7c0bc..fcb0eb0cb 100644 --- a/docs/source/widgets/index.rst +++ b/docs/source/widgets/index.rst @@ -37,6 +37,7 @@ Plot Widgets .. toctree:: :maxdepth: 1 + curve_editor.rst scatterplot.rst timeplot.rst waveformplot.rst diff --git a/pydm/widgets/baseplot.py b/pydm/widgets/baseplot.py index a4652cbac..f6c1ecd76 100644 --- a/pydm/widgets/baseplot.py +++ b/pydm/widgets/baseplot.py @@ -1,6 +1,7 @@ import functools from qtpy.QtGui import QColor, QBrush -from qtpy.QtCore import Signal, Slot, Property, QTimer, Qt +from qtpy.QtCore import Signal, Slot, Property, QTimer, Qt, QEvent, QRect +from qtpy.QtWidgets import QToolTip from .. import utilities from pyqtgraph import PlotWidget, PlotDataItem, mkPen, ViewBox, InfiniteLine, SignalProxy, CurvePoint, TextItem from collections import OrderedDict @@ -295,6 +296,21 @@ def __init__(self, parent=None, background='default', axisItems=None): self.vertical_crosshair_line = None self.horizontal_crosshair_line = None self.crosshair_movement_proxy = None + if utilities.is_qt_designer(): + self.installEventFilter(self) + + def eventFilter(self, obj, event): + ret = super(BasePlot, self).eventFilter(obj, event) + if utilities.is_qt_designer(): + if event.type() == QEvent.Enter: + QToolTip.showText( + self.mapToGlobal(self.rect().center()), + 'Edit plot curves via Right-Click and select "Edit Curves..."', + self, + QRect(0, 0, 200, 100), + 4000) + return ret + def addCurve(self, plot_item, curve_color=None): if curve_color is None: diff --git a/pydm/widgets/scatterplot.py b/pydm/widgets/scatterplot.py index 0ee9131ec..be602cdb7 100644 --- a/pydm/widgets/scatterplot.py +++ b/pydm/widgets/scatterplot.py @@ -439,7 +439,7 @@ def setCurves(self, new_list): redraw_mode=d.get('redraw_mode'), buffer_size=d.get('buffer_size')) - curves = Property("QStringList", getCurves, setCurves) + curves = Property("QStringList", getCurves, setCurves, designable=False) def channels(self): """ diff --git a/pydm/widgets/timeplot.py b/pydm/widgets/timeplot.py index e31484303..564ee54a2 100644 --- a/pydm/widgets/timeplot.py +++ b/pydm/widgets/timeplot.py @@ -557,7 +557,7 @@ def setCurves(self, new_list): symbol=d.get('symbol'), symbolSize=d.get('symbolSize')) - curves = Property("QStringList", getCurves, setCurves) + curves = Property("QStringList", getCurves, setCurves, designable=False) def findCurve(self, pv_name): """ diff --git a/pydm/widgets/waveformplot.py b/pydm/widgets/waveformplot.py index df0c0bc82..d726a7247 100644 --- a/pydm/widgets/waveformplot.py +++ b/pydm/widgets/waveformplot.py @@ -463,7 +463,7 @@ def setCurves(self, new_list): symbolSize=d.get('symbolSize'), redraw_mode=d.get('redraw_mode')) - curves = Property("QStringList", getCurves, setCurves) + curves = Property("QStringList", getCurves, setCurves, designable=False) def channels(self): """