WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Set Size ViewPoint by Keyboard (https://forum.worldviz.com/showthread.php?t=5010)

Alex Miranda 04-10-2014 11:36 AM

Set Size ViewPoint by Keyboard
 
Firstly, i would like to thanks everyone that helped me, and I have more one question. How can I set the size of window using keyboard?

For example: I've defined "upLeftWindow.setSize(.436, .93)", but for using the correct size, i need to do many tests to find it. If i wanted use to any button to set it in real time, would be possible?

Erikvdb 04-11-2014 06:12 AM

Sure, .setSize() works during runtime as well, so for finding the right window size by tweaking it step-by-step you can have a little code like this:

Code:

x = 0.5 #initial size window X
y = 0.5 #initial size window Y

upLeftWindow = viz.addWindow()
upLeftWindow.setSize([x,y])
upLeftWindow.setPosition(0,1)
upLeftWindow.clearcolor(viz.WHITE)

def onKeyDown(key):
        global x, y
        if key == '-':
                x -= 0.05 #step size
                upLeftWindow.setSize([x,y])
        elif key == '=':
                x += 0.05 #step size
                upLeftWindow.setSize([x,y])
        print x, y

viz.go()

viz.callback(viz.KEYDOWN_EVENT,onKeyDown)

Pressing - or = will increase or decrease the X size of the window, you can map other keys for the Y size in a similar fashion.

Alex Miranda 04-15-2014 07:21 AM

Run!
 
Thank for help me! The code run!


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

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