diff --git a/pydm/widgets/baseplot.py b/pydm/widgets/baseplot.py index 962e5b5e6..482b2f13a 100644 --- a/pydm/widgets/baseplot.py +++ b/pydm/widgets/baseplot.py @@ -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) diff --git a/pydm/widgets/timeplot.py b/pydm/widgets/timeplot.py index 31bb938cd..806763b48 100644 --- a/pydm/widgets/timeplot.py +++ b/pydm/widgets/timeplot.py @@ -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.