return ps
return None
- def setCurrentCurve(self, curveId, silent=False): # TAG CHECK : SILENT ajouté
- Logger.Debug("PlotManager::setCurrentCurve() --> CALL")
+ def setCurrentCurve(self, curveId, silent=False): # Added the "silent" arg
ps = self.getPlotSetContainingCurve(curveId)
if ps is None and curveId != -1:
raise ValueError("Invalid curve ID (%d)!" % curveId)
- Logger.Debug("PlotManager::setCurrentCurve() --> CALL clearAllCurrentCurve()")
self.clearAllCurrentCurve(silent=True) # silencing the CurrentCurveChange : 1 draw less
- Logger.Debug("PlotManager::setCurrentCurve() --> DONE clearAllCurrentCurve()")
if curveId == -1:
return -1
ps_id = ps.getID()
currPs = self.getCurrentPlotSet()
if currPs is None or currPs.getID() != ps_id:
self.setCurrentPlotSet(ps_id)
- Logger.Debug("PlotManager::setCurrentCurve() --> CALL ps.setCurrentCurve()")
ps.setCurrentCurve(curveId, silent=silent) # will actually notify CurrentCurveChange
- Logger.Debug("PlotManager::setCurrentCurve() --> DONE")
return ps_id
def getCurrentCurve(self):
def clearAllCurrentCurve(self, silent=False):
for psID in self._plotSets:
- self._plotSets[psID].setCurrentCurve(-1, silent=silent) # ajout du silent : 1 draw less
+ self._plotSets[psID].setCurrentCurve(-1, silent=silent) # passing the silent arg
if not silent:
self.notifyChange("CurrentCurveChange")
newC.setMPLAxes(self._mplAxes)
newC.draw()
newC.setMarker(self.getMarker(go_next=True))
- Logger.Debug(" ** > appendCurve() crvID = {}".format(curveID))
self._curveViews[curveID] = newC
def appendBarplot(self, curveID):
- Logger.Debug(" > Appending a bar model")
newB = BarView(self._controller, self)
newB.setModel(self._model._curves[curveID])
newB.setMPLAxes(self._mplAxes)
newB.draw()
- Logger.Debug(" ** > appendBarplot() crvID = {}".format(curveID))
self._curveViews[curveID] = newB
def appendStemplot(self, curveID):
- Logger.Debug(" > Appending a stem model")
newS = StemView(self._controller, self)
newS.setModel(self._model._curves[curveID])
newS.setMPLAxes(self._mplAxes)
newS.draw()
- Logger.Debug(" ** > appendStemplot() crvID = {}".format(curveID))
self._curveViews[curveID] = newS
def removeCurve(self, curveID):
def onPick(self, event):
""" MPL callback when picking
"""
- Logger.Debug(" > Event onPick : {} ---> START EVENT".format(event))
-
- if event.mouseevent.dblclick:
- Logger.Debug(" > > > Double click !")
+ Logger.Debug(" > Event onPick() ---> Start")
if (event.mouseevent.button == 1 and not event.mouseevent.dblclick):
selected_id = -1
break
# Checks if the plot symbol legend has been clicked
- for leg_idx,legHandler in enumerate(self._legend.legendHandles):
- if legHandler is a :
- # Gets the associated plot from the axes.legend handles
- selected_plot = h[leg_idx]
- # Gets the id from the curveViews
- for crv_id, cv in list(self._curveViews.items()):
- if selected_plot is cv._mplArtist:
- selected_id = crv_id
- break
-
- Logger.Debug("Legend {} selected".format(selected_id))
+ if selected_id == -1:
+ for leg_idx,legHandler in enumerate(self._legend.legendHandles):
+ if legHandler is a :
+ # Gets the associated plot from the axes.legend handles
+ selected_plot = h[leg_idx]
+ # Gets the id from the curveViews
+ for crv_id, cv in list(self._curveViews.items()):
+ if selected_plot is cv._mplArtist:
+ selected_id = crv_id
+ break
# Checks if an artist has been picked inside the plotting area
- for crv_id, cv in list(self._curveViews.items()):
- # Permits to get back to the intiial opacity of each Artists ... let's keep it in case we want that
- # self._curveViews[crv_id].setAlpha(self._curveViews[crv_id].getInitialAlpha())
-
+ if selected_id == -1:
+ for crv_id, cv in list(self._curveViews.items()):
# Checks if the picked artist is in the list of artists
- if a in flatten(cv._mplArtist):
- selected_id = crv_id
- Logger.Debug("Curve/Barplot/Stemplot {} selected".format(selected_id))
- break
+ if a in flatten(cv._mplArtist):
+ selected_id = crv_id
+ Logger.Debug("Curve/Barplot/Stemplot {} selected".format(selected_id))
+ break
# Use the plotmanager to set the current curve so that other plot sets get their current reset:
if self._currCrv is not None:
# Setting the current curve only if different
if event.mouseevent.dblclick:
# if double click (2nd onPick event on same artist) : set the _currCrv variable without notifying
- Logger.Debug(" onPick::setCurrentCurve() SILENT TRUE ...")
self._controller._plotManager.setCurrentCurve(selected_id, silent=True)
- Logger.Debug(" onPick::setCurrentCurve() SILENT TRUE : DONE")
else :
# if NOT double click : set the _currCrv variable and notifying (repaint)
- Logger.Debug(" onPick::setCurrentCurve() SILENT FALSE ...")
self._controller._plotManager.setCurrentCurve(selected_id, silent=False)
- Logger.Debug(" onPick::setCurrentCurve() SILENT FALSE : DONE")
else :
- Logger.Debug(" onPick::setCurrentCurve() SILENT FALSE ...")
self._controller._plotManager.setCurrentCurve(selected_id, silent=False)
- Logger.Debug(" onPick::setCurrentCurve() SILENT FALSE : DONE")
else : #if event.mouseevent.dblclick:
self.showOnlySelected()
- Logger.Debug(" > Event onPick : {} ---> END EVENT".format(event))
+ Logger.Debug(" > Event onPick() ---> End")
def createAndAddLocalAction(self, icon_file, short_name):
self._mplCanvas = FigureCanvasQTAgg(self._mplFigure)
self._mplCanvas.installEventFilter(self._eventHandler)
self._mplCanvas.mpl_connect('pick_event', self.onPick)
-
+
self._mplAxes = self._mplFigure.add_subplot(1, 1, 1)
self._plotWidget = PlotWidget()
self._toobarMPL = NavigationToolbar2QT(self._mplCanvas, None)
filters,
trQ("DUMP_VIEW_FILE"),
False )
- name = str(fileName[0]) # Modif portage
+ name = str(fileName[0]) # Correcting some bug here
Logger.Debug(f" >> Save fig filename : {name}")
if name != "":
self._mplAxes.figure.savefig(name)
pass
def onCurrentCurveChange(self):
- Logger.Debug("XYView::onCurrentCurveChange() : CALL")
curr_crv2 = self._model.getCurrentCurve()
-
- if self._currCrv is None :
- id_debug1 = "None"
- else :
- id_debug1 = self._currCrv.getID()
-
- if curr_crv2 is None :
- id_debug2 = "None"
- else :
- id_debug2 = curr_crv2.getID()
-
- Logger.Debug(f"XYView::onCurrentCurveChange() : Curr crv 1 ID : {id_debug1}")
- Logger.Debug(f"XYView::onCurrentCurveChange() : Curr crv 2 ID : {id_debug2}")
-
if curr_crv2 != self._currCrv:
- Logger.Debug("XYView::onCurrentCurveChange() : NEW CURVE SELECTED")
if self._currCrv is not None:
- Logger.Debug("XYView::onCurrentCurveChange() : Toggle -> False")
view = self._curveViews[self._currCrv.getID()]
view.toggleHighlight(False)
if not curr_crv2 is None:
- Logger.Debug("XYView::onCurrentCurveChange() : Toggle -> True")
view = self._curveViews[curr_crv2.getID()]
view.toggleHighlight(True)
self._currCrv = curr_crv2
self.showHideLegend(repaint=False) # redo legend
self.repaint()
- Logger.Debug("XYView::onCurrentCurveChange() : REPAINT")
- Logger.Debug("XYView::onCurrentCurveChange() : END")
def changeFormatAxis(self) :
if not self.__repaintOK():
set_mod = set(self._model._curves.keys())
set_view = set(self._curveViews.keys())
- # Logger.Debug(" --- List of models ID: {}".format(set_mod))
- # Logger.Debug(" --- List of views ID: {}".format(set_view))
-
# Deleted/Added curves:
dels = set_view - set_mod
added = set_mod - set_view
- # Logger.Debug(" --- List of dels ID: {}".format(dels))
- # Logger.Debug(" --- List of added ID: {}".format(added))
-
for d in dels:
self.removeCurve(d)
if not len(self._curveViews):
# Reset color cycle
- Logger.Debug(" ---- !! Resetting color cycle ...")
self._mplAxes.set_prop_cycle(None)
- for a in added:
+ # This would evolve if we introduce an intermediary class Model->"PlotModel"->BarModel/CurveModel/StemModel
+ for a in added:
if ( self._model._curves[a]._name == "CurveModel" ) :
self.appendCurve(a)
elif ( self._model._curves[a]._name == "BarModel" ) :