diff --git a/pydm/widgets/baseplot.py b/pydm/widgets/baseplot.py index b09c06248..6fcca979e 100644 --- a/pydm/widgets/baseplot.py +++ b/pydm/widgets/baseplot.py @@ -1,6 +1,7 @@ import functools import json import warnings +from abc import abstractmethod from qtpy.QtGui import QColor, QBrush, QMouseEvent from qtpy.QtCore import Signal, Slot, Property, QTimer, Qt, QEvent, QObject, QRect from qtpy.QtWidgets import QToolTip, QWidget @@ -234,6 +235,39 @@ def y_axis_name(self, axis_name: str) -> None: """ self._y_axis_name = axis_name + @property + def stepMode(self) -> str: + """ + Returns the stepMode of the curve. + + Returns + ------- + str + The stepMode for the curve, one of ["center", "left", "right", None] + """ + return self.opts.get("stepMode", None) + + @stepMode.setter + def stepMode(self, new_step: str) -> None: + """ + Set a new stepMode for the curve. Options are below: + - "" or None: Draw lines directly from y-value to y-value. + - "left" or "right": Draw the step with the associated y-value + to the left or right. Ensure that `len(x) == len(y)` + - "center": Draw the step with the associated y-value in the center + of the step. Ensure that `len(x) == len(y) + 1` + + Parameters + ---------- + new_step : str + The new stepMode for the curve, can be one of + ["center", "left", "right", None] + """ + if new_step == self.stepMode: + return + self.setData(stepMode=new_step) + self.redrawCurve() + @property def lineStyle(self) -> Qt.PenStyle: """ @@ -388,6 +422,11 @@ def to_dict(self) -> OrderedDict: ] ) + @abstractmethod + def redrawCurve(self) -> None: + pass + + @abstractmethod def close(self) -> None: pass