WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   vhil module (https://forum.worldviz.com/showthread.php?t=282)

vadrian 01-26-2005 08:04 PM

vhil module
 
so i want to make a "vhil" module that works in much the same way as the "viz" module. that is, make generic calls like vhil.add, vhil.get, vhil.callback, etc., but it does some added functionality not built into vizard, but necessary for our projects.

Basically, people at our lab are reinventing the wheel a lot, and i want to make a generic library that makes common calls to the viz library.

so my questions so far are:

1) if I call viz.callback(viz.TIMER_EVENT, ...) or for any callback type, will my module overwrite any callbacks set by the user? or will it just add another callback?

2) if the user starts a timer with the same number as one of my timers, and both their script and my module have timer-event callbacks, will we both get eachother's timer events, or do the two viz.callback(...) calls set up independent timer/callback systems.

i hope this makes sense, as the rest of my questions depend on the answers for these two. thanks

adrian

farshizzo 01-27-2005 09:42 AM

Hi,

1) Yes, your callback will overwrite any callback set by the user

2) Well, if you register a timer callback then it will overwrite the users timer callback, so they won't get any timer events.

Using an Event Class is the proper way to handle events in separate modules. For example, if you wanted your module to handle timer and keydown events you would do the following:
Code:

import viz

#Create class that inherits from viz.EventClass
class _VHILEvent(viz.EventClass):
        def __init__(self):
                viz.EventClass.__init__(self)
               
                #Register callback for this class instance
                self.callback(viz.TIMER_EVENT,self.mytimer)
                self.callback(viz.KEYDOWN_EVENT,self.mykeydown)
               
                #Start a timer that belongs to this instance
                self.starttimer(0,0.1,viz.FOREVER)
               
        def mytimer(self,num):
                pass
               
        def mykeydown(self,key):
                pass
               
#Create an instance of _VHILEvent class
_VE = _VHILEvent()


vadrian 01-27-2005 11:52 AM

eeexxcellent....


All times are GMT -7. The time now is 10:11 AM.

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