From 0c9b4f9dfe8a4e7dd18d254d25f54ac55c01502e Mon Sep 17 00:00:00 2001 From: jh777916 Date: Fri, 29 Sep 2023 14:56:13 +0200 Subject: [PATCH] fix: double click on a curve while legend is None was not rendering as expected; feat: added the cpp interface of SetCurrentPlotSet(ps_id) in the cpp lib --- tools/CurvePlot/src/cpp/CurvePlot.cxx | 10 ++++++++++ tools/CurvePlot/src/cpp/CurvePlot.hxx | 2 ++ tools/CurvePlot/src/python/views/XYView.py | 5 +++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/CurvePlot/src/cpp/CurvePlot.cxx b/tools/CurvePlot/src/cpp/CurvePlot.cxx index e94eddff5..0a1f20ecb 100644 --- a/tools/CurvePlot/src/cpp/CurvePlot.cxx +++ b/tools/CurvePlot/src/cpp/CurvePlot.cxx @@ -477,6 +477,16 @@ namespace CURVEPLOT return PyLong_AsLong(ret); } + void CurvePlot::SetCurrentPlotSet(PlotID plot_set_id) + { + PyLockWrapper lock; + PyObject * cont = GetInstance()->_impl->_controller; + + PyObjWrapper ret( + PyObject_CallMethod(cont, (char *)"SetCurrentPlotSet", (char *)"i", plot_set_id)); + HandleAndPrintPyError("CurvePlot::SetCurrentPlotSet(): unexpected error!"); + } + bool CurvePlot::IsValidPlotSetID(PlotID plot_set_id) { PyLockWrapper lock; diff --git a/tools/CurvePlot/src/cpp/CurvePlot.hxx b/tools/CurvePlot/src/cpp/CurvePlot.hxx index 380ea469d..d59b9f961 100644 --- a/tools/CurvePlot/src/cpp/CurvePlot.hxx +++ b/tools/CurvePlot/src/cpp/CurvePlot.hxx @@ -126,6 +126,8 @@ namespace CURVEPLOT static PlotID GetCurrentPlotSetID(); + static void SetCurrentPlotSet(PlotID plot_set_id=-1); + static void ToggleCurveBrowser(bool with_curve_browser); static bool IsValidPlotSetID(PlotID plot_set_id=-1); diff --git a/tools/CurvePlot/src/python/views/XYView.py b/tools/CurvePlot/src/python/views/XYView.py index 8542983af..b90dda21a 100644 --- a/tools/CurvePlot/src/python/views/XYView.py +++ b/tools/CurvePlot/src/python/views/XYView.py @@ -377,7 +377,7 @@ class XYView(View): j = xM-xm if np.isfinite(xm) and np.isfinite(xM) and np.isfinite(ym) and np.isfinite(yM): self._mplAxes.axis([xm-j*self.AUTOFIT_MARGIN, xM+j*self.AUTOFIT_MARGIN, - ym-i*self.AUTOFIT_MARGIN, yM+i*self.AUTOFIT_MARGIN]) + ym-i*self.AUTOFIT_MARGIN, yM+i*self.AUTOFIT_MARGIN]) if repaint: self.repaint() @@ -516,7 +516,8 @@ class XYView(View): for crv_id, cv in list(self._curveViews.items()): if (crv_id != self._currCrv.getID()) : cv.setAlpha(0.05) - self.showHideLegend() # redo legend + self.repaint() + self.showHideLegend(repaint=False) # redo legend return def showHideLegend(self, actionChecked=None, repaint=True): -- 2.39.2