WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-16-2008, 05:34 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Modifying Vizinfo to Support Re-parenting Tip

Flexible graphical user interfaces (GUIs) components often have a common parent node for global positioning and scale. Vizard's vizinfo module does not allow setting of vizinfo menus' parent, so one cannot incorporate them into GUI components. The following article describes how to fix the issue by adding a setParent method to a subclass of vizinfo's Info class.

http://vizworkshop.com/articles/vizinfo_reparenting.html


Here is the module that adds a setParent method to the Info class:

Code:
import viz
import vizinfo

def add(text, textsize=1.0, **kw):
	return ParentableVizInfo(text, textsize, **kw)
	
class ParentableVizInfo(vizinfo.Info):
	def __init__(self, text, textsize, parent=viz.SCREEN, scene=viz.MainScene, **kw):
		vizinfo.Info.__init__(self, text, textsize, **kw)			
		self.setParent(newParent=parent, newScene=scene)
		if parent != viz.SCREEN:
			#remove initial offset so info in in center of parent node, not [.95, .95, 0]
			self.translate([0,0,0])
			
	def setParent(self, newParent=viz.SCREEN, newScene=viz.MainScene):
		self._group.parent(newParent, newScene)
		
		
if __name__ == '__main__':
	viz.go()
	SIM_SCENE = viz.Scene2
	viz.scene(SIM_SCENE)
	node = viz.addGroup(parent=viz.SCREEN, pos=[.5, .5, 0], scene=SIM_SCENE)
	add('test asdafasdf', parent=node, scene=SIM_SCENE)
__________________
Paul Elliott
WorldViz LLC
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 08:05 PM.


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