Skip to content

Commit

Permalink
Merge pull request #575 from hhslepicka/plots_curve_docs
Browse files Browse the repository at this point in the history
DOC & ENH: Plot Curve Editor
  • Loading branch information
hhslepicka authored Nov 13, 2019
2 parents 41c3b35 + 0a16c65 commit 317b011
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions docs/source/widgets/curve_editor.rst
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions docs/source/widgets/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Plot Widgets
.. toctree::
:maxdepth: 1

curve_editor.rst
scatterplot.rst
timeplot.rst
waveformplot.rst
Expand Down
18 changes: 17 additions & 1 deletion pydm/widgets/baseplot.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pydm/widgets/scatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion pydm/widgets/timeplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion pydm/widgets/waveformplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 317b011

Please sign in to comment.