WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-26-2005, 08:04 PM
vadrian vadrian is offline
Member
 
Join Date: Sep 2004
Posts: 32
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
Reply With Quote
  #2  
Old 01-27-2005, 09:42 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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()
Reply With Quote
  #3  
Old 01-27-2005, 11:52 AM
vadrian vadrian is offline
Member
 
Join Date: Sep 2004
Posts: 32
eeexxcellent....
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:34 PM.


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