WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Changes in vizdlg or vizact in Vizard 5? (https://forum.worldviz.com/showthread.php?t=5244)

mape2k 12-09-2014 08:30 AM

Changes in vizdlg or vizact in Vizard 5?
 
Hello,

I have a problem running most of my files in Vizard 5:

To display text, images, ... I build my own vizdlg.Dialog class to create a panel which I can use to display and hide messages very easily (I used a small tutorial that is somewhere in the Vizard documentation).

Since I upgrade to Vizard 5, the background of the panel won't hide anymore. To show you guys what I mean, I created a small example (with a simplified version of my vizdlg.Dialog class).

The code pasted below works fine with Vizard 4: the text 'Bla' is displayed for 2 seconds, then the screen goes black
However, in Vizard 5, the text will also go away after 2 seconds, but the grey background will stay without any error message.

Have there been any changes to the built-in librarys that could cause such a problem?

Cheers,
Johannes


EDIT: I fixed it by changing line 68 'self.panel.addAction(vizact.fadeTo(0,time=fade))' to 'self.panel.background.addAction(vizact.fadeTo(0,t ime=fade))'


Code:

import os
import sys

import viz
import vizdlg
import vizact
import viztask


# text panel class

class displayInfo(vizdlg.Dialog):

        def __init__(self,mode = 'fit',fontSize = 50,textAlignment = viz.ALIGN_CENTER,border = True,background = True, padding = 5,**kw):
               
                vizdlg.Dialog.__init__(self,**kw)
               
                self.fontSize = fontSize
                self.textAlignment = textAlignment
                self.textColor = (1,1,1)
                self.borderDesired = border
                self.bgDesired = background
                self._padding = padding
               
                # define own color theme
                blackTheme = viz.getTheme()
                blackTheme.backColor = (0.4,0.4,0.4,1)
                blackTheme.lightBackColor = (0.6,0.6,0.6,1)
                blackTheme.darkBackColor = (0.2,0.2,0.2,1)
                blackTheme.highBackColor = (0.2,0.2,0.2,1)
                blackTheme.textColor = (self.textColor)
               
                if mode == 'fullscreen':
                        self.panel = vizdlg.Panel(theme = blackTheme,align = vizdlg.ALIGN_CENTER,border = False, background = self.bgDesired) # add panel without border
                        self.panel.background.setScale(5000,5000,1) # if fullscreen is passed, scale the background so it covers fullscreen
                elif mode == 'fit':
                        self.panel = vizdlg.Panel(theme = blackTheme,align = vizdlg.ALIGN_CENTER, border = self.borderDesired, background = self.bgDesired, padding = self._padding) # add panel

                self.panel.background.alpha(1)                        # set background alpha
                viz.link(viz.CenterCenter,self.panel)        # link the panel to center of screen
       
                # switch variables to determine state of message panel
                self.textDisplayed = False
       
        # display message
        def message(self,text,fade = 0):
               
                # init text
                self.text = self.panel.addItem(viz.addText(text))        # if message should be displayed, add text item
               
                # set attributes
                self.text.fontSize(self.fontSize)
                self.text.alignment(self.textAlignment)
                self.text.color(self.textColor)
               
                # let the panel fade in
                self.panel.addAction(vizact.fadeTo(1,time=fade))
               
                # fade in of the text (if desired)
                self.text.addAction(vizact.fadeTo(1,time=fade))
       
        # hide text and panel
        def hide(self, fade = 0):
               
                for item in self.panel.getItems():
                        self.panel.removeItem(item)
               
                self.panel.addAction(vizact.fadeTo(0,time=fade))
       


# small example

textPanel = displayInfo(mode = 'fullscreen',fontSize = 30, textAlignment = viz.ALIGN_LEFT_CENTER)        # fullscreen text for introduction text

def main():
       
        textPanel.message('Bla')
       
        yield viztask.waitTime(2)
       
        textPanel.hide()
       
viztask.schedule(main())

viz.go()


farshizzo 12-09-2014 09:24 AM

Thanks for reporting the issue and providing a sample. This is a regression and will be fixed in the next update.

mape2k 12-10-2014 05:58 AM

Thank you for the quick reply!

While debugging, I also noticed that the background can be faded in and out (e.g. textPanel.message('Bla', fade = 2)), but for text items in a panel the 'addAction(vizact.fadeTo(x))' command does not seem to work. Is that as intended? I would really like the text to fade in and out as well as the background.

Cheers,
Johannes


All times are GMT -7. The time now is 12:09 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC