From: jh777916 Date: Thu, 23 May 2024 09:00:22 +0000 (+0200) Subject: Merge branch 'jha/CurvePlot_barplot_stemplot' into jha/CurvePlot_barplot_stemplot_9_12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=43b66e1cb78797ab6712e2cb1d8edbd8ed44bc24;p=modules%2Fgui.git Merge branch 'jha/CurvePlot_barplot_stemplot' into jha/CurvePlot_barplot_stemplot_9_12 --- 43b66e1cb78797ab6712e2cb1d8edbd8ed44bc24 diff --cc tools/CurvePlot/src/python/controller/PlotController.py index c69c7491d,c2a619fd7..9bb3bf2f6 --- a/tools/CurvePlot/src/python/controller/PlotController.py +++ b/tools/CurvePlot/src/python/controller/PlotController.py @@@ -727,3 -817,113 +817,113 @@@ class PlotController(object) self.setModelListener(cm, xyview) return cm.getID(),cps.getID() + + + def plotBarPlotFromTable(self, table, + x_col_index=0, height_col_index=1, width_col_index=2, + curve_label="", append=True): + """ + :returns: a tuple containing the unique curve ID and the plot set ID + """ + # Regardless of 'append', we must create a view if none there: + if self._plotManager.getCurrentPlotSet() is None or not append: + ps = self._plotManager.createXYPlotSet() + self.setModelListener(ps, self._curveBrowserView) + # For curve picking, controller must listen: + self.setModelListener(ps, self) + cps_title = table.getTitle() + else: + cps_title = None + + cps = self._plotManager.getCurrentPlotSet() + + bm = BarModel(self, table, height_col_index, width_col_index) + bm.setXAxisIndex(x_col_index) + + # X axis label + tix = table.getColumnTitle(x_col_index) + if tix != "": + cps.setXLabel(tix) + + # Curve label + if curve_label != "": + bm.setTitle(curve_label) + else: + ti = table.getColumnTitle(height_col_index) + if ti != "": + bm.setTitle(ti) + + # Plot set title + if cps_title != "" and cps_title is not None: + Logger.Debug("about to set title to: " + cps_title) + cps.setTitle(cps_title) + + cps.addCurve(bm) + + mp = self._curveTabsView.mapModId2ViewId() + xyview_id = mp[cps.getID()] + xyview = self._curveTabsView._XYViews[xyview_id] + + if cps_title is None: # no plot set was created above + self._plotManager.setCurrentPlotSet(cps.getID()) + + # Make CurveBrowser and CurveView depend on changes in the curve itself: + self.setModelListener(bm, self._curveBrowserView) + self.setModelListener(bm, xyview._curveViews[bm.getID()]) # TAG CHECK + # Upon change on the curve also update the full plot, notably for the auto-fit and the legend: + self.setModelListener(bm, xyview) + + return bm.getID(),cps.getID() + + def plotStemPlotFromTable(self, table, x_col_index=0, y_col_index=1, curve_label="", append=True): + """ + :returns: a tuple containing the unique curve ID and the plot set ID + """ + # Regardless of 'append', we must create a view if none there: + if self._plotManager.getCurrentPlotSet() is None or not append: + ps = self._plotManager.createXYPlotSet() + self.setModelListener(ps, self._curveBrowserView) + # For curve picking, controller must listen: + self.setModelListener(ps, self) + cps_title = table.getTitle() + else: + cps_title = None + + cps = self._plotManager.getCurrentPlotSet() + + sm = StemModel(self, table, y_col_index) + sm.setXAxisIndex(x_col_index) + + # X axis label + tix = table.getColumnTitle(x_col_index) + if tix != "": + cps.setXLabel(tix) + + # Curve label + if curve_label != "": + sm.setTitle(curve_label) + else: + ti = table.getColumnTitle(y_col_index) + if ti != "": + sm.setTitle(ti) + + # Plot set title + if cps_title != "" and cps_title is not None: + Logger.Debug("about to set title to: " + cps_title) + cps.setTitle(cps_title) + + cps.addCurve(sm) + mp = self._curveTabsView.mapModId2ViewId() + xyview_id = mp[cps.getID()] + xyview = self._curveTabsView._XYViews[xyview_id] + + if cps_title is None: # no plot set was created above + self._plotManager.setCurrentPlotSet(cps.getID()) + + # Make CurveBrowser and CurveView depend on changes in the curve itself: + self.setModelListener(sm, self._curveBrowserView) + self.setModelListener(sm, xyview._curveViews[sm.getID()]) + # Upon change on the curve also update the full plot, notably for the auto-fit and the legend: + self.setModelListener(sm, xyview) + - return sm.getID(),cps.getID() ++ return sm.getID(),cps.getID()