Skip to content

Commit

Permalink
Merge pull request #1101 from aksharsarvesh/exportPlot
Browse files Browse the repository at this point in the history
ENH: Import/Export Plot Config
  • Loading branch information
jbellister-slac authored Sep 4, 2024
2 parents f735660 + aae838a commit c47529c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pydm/widgets/baseplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,24 @@ def __init__(
if utilities.is_qt_designer():
self.installEventFilter(self)

def to_dict(self) -> OrderedDict:
"""Converts this plot into a dict that can then be read to recreate
all of the configurations preferred for this plot"""

dic_ = OrderedDict(
[
("title", self.getPlotTitle()),
("xGrid", self.getShowXGrid()),
("yGrid", self.getShowYGrid()),
("opacity", self.getPlotItem().ctrl.gridAlphaSlider.value()),
("backgroundColor", self.getBackgroundColor().name()),
("legend", self.getShowLegend()),
("crosshair", self.vertical_crosshair_line),
("mouseMode", self.plotItem.getViewBox().state["mouseMode"]),
]
)
return dic_

def eventFilter(self, obj: QObject, event: QEvent) -> bool:
"""Display a tool tip upon mousing over the plot in Qt designer explaining how to edit curves on it"""
ret = super(BasePlot, self).eventFilter(obj, event)
Expand Down
7 changes: 7 additions & 0 deletions pydm/widgets/timeplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,13 @@ def __init__(
self.auto_scroll_timer = QTimer()
self.auto_scroll_timer.timeout.connect(self.auto_scroll)

def to_dict(self) -> OrderedDict:
"""Adds attribute specific to TimePlot to add onto BasePlot's to_dict.
This helps to recreate the Plot Config if we import a save file of it"""
dic_ = OrderedDict([("refreshInterval", self.auto_scroll_timer.interval() / 1000)])
dic_.update(super(PyDMTimePlot, self).to_dict())
return dic_

def initialize_for_designer(self):
# If we are in Qt Designer, don't update the plot continuously.
# This function gets called by PyDMTimePlot's designer plugin.
Expand Down

0 comments on commit c47529c

Please sign in to comment.