Skip to content

Commit

Permalink
Merge pull request #1096 from zdomke/dev_base_curve_stepmode
Browse files Browse the repository at this point in the history
ENH: Add stepMode to BasePlotCurveItem
  • Loading branch information
nstelter-slac authored Jul 30, 2024
2 parents a6da4e3 + 4f4f4ad commit 760af07
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pydm/widgets/baseplot.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -388,6 +422,11 @@ def to_dict(self) -> OrderedDict:
]
)

@abstractmethod
def redrawCurve(self) -> None:
pass

@abstractmethod
def close(self) -> None:
pass

Expand Down

0 comments on commit 760af07

Please sign in to comment.