From b34037590c82e8306987316b70aa407c2a50586c Mon Sep 17 00:00:00 2001 From: Marco Musy Date: Mon, 9 May 2022 01:39:54 +0200 Subject: [PATCH] flagtext fix --- vedo/base.py | 3 +-- vedo/plotter.py | 65 ++++++++++++++++++++++++++----------------------- vedo/version.py | 2 +- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/vedo/base.py b/vedo/base.py index d00786c8..3ab1c99d 100644 --- a/vedo/base.py +++ b/vedo/base.py @@ -150,6 +150,7 @@ def __init__(self): self.cell_locator = None self.scalarbar = None + self.flagText = None def address(self): @@ -676,8 +677,6 @@ def __init__(self): Base3DProp.__init__(self) self._mapper = None - - self.flagText = None self._caption = None self.property = None diff --git a/vedo/plotter.py b/vedo/plotter.py index 1306ebde..dc12aa09 100644 --- a/vedo/plotter.py +++ b/vedo/plotter.py @@ -2782,37 +2782,40 @@ def show(self, and not (vedo.vtk_version[0] == 9 and "Linux" in vedo.sys_platform) # Linux vtk9 is bugged ): #check balloons - if ia.flagText: - if not self.flagWidget: # Create widget on the fly - self._flagRep = vtk.vtkBalloonRepresentation() - self._flagRep.SetBalloonLayoutToImageRight() - breppr = self._flagRep.GetTextProperty() - breppr.SetFontFamily(vtk.VTK_FONT_FILE) - breppr.SetFontFile(utils.getFontPath(settings.flagFont)) - breppr.SetFontSize(settings.flagFontSize) - breppr.SetColor(vedo.getColor(settings.flagColor)) - breppr.SetBackgroundColor(vedo.getColor(settings.flagBackgroundColor)) - breppr.SetShadow(settings.flagShadow) - breppr.SetJustification(settings.flagJustification) - breppr.UseTightBoundingBoxOn() - if settings.flagAngle: - breppr.SetOrientation(settings.flagAngle) - breppr.SetBackgroundOpacity(0) - self.flagWidget = vtk.vtkBalloonWidget() - self.flagWidget.SetTimerDuration(settings.flagDelay) - self.flagWidget.ManagesCursorOff() - self.flagWidget.SetRepresentation(self._flagRep) - self.flagWidget.SetInteractor(self.interactor) - self.widgets.append(self.flagWidget) - bst = self.flagWidget.GetBalloonString(ia) - if bst: - if bst != ia.flagText: - self.flagWidget.UpdateBalloonString(ia, ia.flagText) - else: - self.flagWidget.AddBalloon(ia, ia.flagText) - - if ia.flagText is False and self.flagWidget: - self.flagWidget.RemoveBalloon(ia) + try: + if ia.flagText: + if not self.flagWidget: # Create widget on the fly + self._flagRep = vtk.vtkBalloonRepresentation() + self._flagRep.SetBalloonLayoutToImageRight() + breppr = self._flagRep.GetTextProperty() + breppr.SetFontFamily(vtk.VTK_FONT_FILE) + breppr.SetFontFile(utils.getFontPath(settings.flagFont)) + breppr.SetFontSize(settings.flagFontSize) + breppr.SetColor(vedo.getColor(settings.flagColor)) + breppr.SetBackgroundColor(vedo.getColor(settings.flagBackgroundColor)) + breppr.SetShadow(settings.flagShadow) + breppr.SetJustification(settings.flagJustification) + breppr.UseTightBoundingBoxOn() + if settings.flagAngle: + breppr.SetOrientation(settings.flagAngle) + breppr.SetBackgroundOpacity(0) + self.flagWidget = vtk.vtkBalloonWidget() + self.flagWidget.SetTimerDuration(settings.flagDelay) + self.flagWidget.ManagesCursorOff() + self.flagWidget.SetRepresentation(self._flagRep) + self.flagWidget.SetInteractor(self.interactor) + self.widgets.append(self.flagWidget) + bst = self.flagWidget.GetBalloonString(ia) + if bst: + if bst != ia.flagText: + self.flagWidget.UpdateBalloonString(ia, ia.flagText) + else: + self.flagWidget.AddBalloon(ia, ia.flagText) + + if ia.flagText is False and self.flagWidget: + self.flagWidget.RemoveBalloon(ia) + except: + pass if interactive is not None: self._interactive = interactive diff --git a/vedo/version.py b/vedo/version.py index 0ed3f7aa..d7379aec 100644 --- a/vedo/version.py +++ b/vedo/version.py @@ -1 +1 @@ -_version='2022.2.2' +_version='2022.2.3'