Skip to content

Commit

Permalink
flagtext fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed May 8, 2022
1 parent e56c51f commit b340375
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 34 deletions.
3 changes: 1 addition & 2 deletions vedo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def __init__(self):
self.cell_locator = None

self.scalarbar = None
self.flagText = None


def address(self):
Expand Down Expand Up @@ -676,8 +677,6 @@ def __init__(self):
Base3DProp.__init__(self)

self._mapper = None

self.flagText = None
self._caption = None
self.property = None

Expand Down
65 changes: 34 additions & 31 deletions vedo/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion vedo/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_version='2022.2.2'
_version='2022.2.3'

0 comments on commit b340375

Please sign in to comment.