From: Bruce S. <ba...@an...> - 2001-10-31 21:45:06
|
At http://cil.andrew.cmu.edu/projects/visual there is new mouse machinery, currently available for Windows. As you may know, there is a problem with the current VPython mouse scheme, because left button down means "zoom". For that reason, dragging an object with the mouse is done with the mouse buttons up, which is inconsistent with dragging in other computer applications. As we announced some time ago, in late December we will change VPython so that the default will be that zooming is done with the "middle" button (left and right buttons or wheel down on a 3-button mouse, CTRL key pressed on a 1-button mouse). This will make it possible for the left button to be down during the dragging of an object. In order to try out the new scheme right now, with the new VPython you can execute scene.newzoom = 1 and get the new behavior. In last December this statement will become unnecessary. Here are extracts from the new documentation: scene.mouse.button Can be "none" (no buttons pressed), "left", "right", "middle" (left and right buttons pressed on a 2-button mouse, or CTRL key pressed with a 1-button mouse), or "wheel" (scroll wheel pressed on some Windows mouses). Example: scene.mouse.button == "left" is true if the left button is down. Here is a complete routine for dragging a sphere with the left button down. Note the statements for making the cursor invisible during the drag. from visual import * scene.newzoom = 1 # invoke new zooming with "middle" button scene.range = 10 # fixed size, no autoscaling ball = sphere(pos=(-5,0,0), radius=1., color=color.cyan) while 1: if scene.mouse.clicked: m1 = scene.mouse.getclick() # wait for left button down if m1.button == "left" and m1.pick == ball: offset = ball.pos - m1.pos scene.cursor.visible = 0 # make cursor invisible while 1: m2 = scene.mouse ball.pos = m2.pos + offset if m2.button == "none" and m2.clicked: # up event scene.cursor.visible = 1 # cursor visible scene.mouse.getclick() # discard up event break If during a drag the user performs a zoom or rotate operation, at the end of the operation an up event is generated, followed by a down event (if any mouse buttons are still down). In the new release of VPython, a few of the demo programs have had scene.newzoom = 1 added to them to permit dragging with the left button down: colorsliders, hanoi, planar, and tictac. An unusual aspect of the new mouse machinery is that just adding the newzoom statement was sufficient to make the dragging work with the left button down. The reason is that in the past the drag was started with a mouse up event and terminated with another mouse up event. Now a mouse down event initiates the drag, and a mouse up event terminates the drag. The new cvisual source code has been checked into SourceForge (sf.net, visualpython) and is also provided in the form of a zip file on the VPython site (in the "developers" section). If you able to do so, you could recompile for Linux or Unix. We welcome your comments and suggestions about the new machinery. Bruce Sherwood P.S. This release also fixes a bug. The documentation claimed that you could discard a queue of unprocessed mouse events by executing scene.mouse.clicked = 0. This didn't actually work, but now it does. |