Vizard 7 » Reference » Tools » Measuring Tape
7.7

Measuring Tape

This tool provides measuring tape functionality. Either individual buttons can be assigned for placement of the end points and clearing the measuring tape, or the cycle command can be used. The order of the cycle command is place the first point, place the second point, and the clear the line. When placing the first point the second point will automatically be placed directly orthogonal to/across from the first point. The measuring tape does not require that items be set and will work with any geometry in the scene. The ray from the measuring tape intersecting the scene comes along the positive z axis relative to the measuring tape node.

 

The following command creates a MeasuringTape object:

Command

measuring_tape.MeasuringTape()

The following methods are available on the MeasuringTape object:

Method

Description

<MeasuringTape>.setStartWall()

Draws a ray and sets the starting position of the measuring tape at the intersection point.

<MeasuringTape>.setEndWall()

Draws a ray and sets the ending position of the measuring tape at the intersection point.

<MeasuringTape>.clear()

Clears the measuring tape.

<MeasuringTape>.cycle()

Cycles through the setStartWall, setEndWall, and clear commands.

<MeasuringTape>.remove()

Removes the measuring tape.

<MeasuringTape>.setUpdateFunction(updateFunction)

Sets the update function that gets called every frame. The update function calls methods on the tool based on the state of input devices.

The following events are triggered when the start and end positions of the measuring tape are set:

Event

Description

measuring_tape.START_WALL_SET_EVENT

This event is generated when the starting position of the measuring tape is set. It provides a single event structure e with the following attributes:

e.intersection: A viz.Intersect object. See the table below for a list of fields contained in this object.

e.distance: The length of the measuring tape line.

measuring_tape.END_WALL_SET_EVENT

This event is generated when the ending position of the measuring tape is set. It provides a single event structure e with the following attributes:

e.intersection: A viz.Intersect object. See the table below for a list of fields contained in this object.

e.distance: The length of the measuring tape line.

The following is a list of fields of the viz.Intersect object:

Attribute

Description

valid

True if the line intersected, False if it didn't.

point

The point the line intersected with the object.

normal

The normal vector of the intersect point.

object

The geometry object the line intersected with.

name

The name of the subobject that the line intersected with.

Example

In the following example the left mouse button calls the cycle command and shows how a single input signal can control the measuring tape. The cycle command cycles through the start,end, and clear commands. The '1','2','3' keys call the same start, end, and clear commands with different input signals. The advantage of calling the commands individually is the start/end positions of the tape can be dragged into position. Try holding the '1' or '2' key as you move the arrow to see this:

""" 
Left mouse button calls the cycle 
command.'1','2','3' keys call the 
start, end, and clear commands. 
Mouse movements and arrow keys 
control the viewpoint. 
""" 

import viz
import vizact
import vizshape
import vizcam
import vizinfo
vizinfo.InfoPanel()

viz.setMultiSample(4)
viz.fov(60)
viz.go()

gallery = viz.add('gallery.osgb')
arrow = vizshape.addArrow(length=0.2, color = viz.ORANGE)

# initialization code for measuringtape which is a MeasuringTape
from tools import measuring_tape
tool = measuring_tape.MeasuringTape()

vizact.onmousedown(viz.MOUSEBUTTON_LEFT,tool.cycle)
vizact.onkeydown('1',tool.setStartWall)
vizact.onkeydown('2',tool.setEndWall)
vizact.onkeydown('3',tool.clear)

#Link the examiner tool to an arrow in order to
#visualize it's position
from vizconnect.util import virtual_trackers
mouseTracker = virtual_trackers.ScrollWheel(followMouse = True)
mouseTracker.distance = 1
arrowLink = viz.link(mouseTracker,arrow)
arrowLink.postMultLinkable(viz.MainView)
viz.link(arrowLink,tool)

import vizcam
cam = vizcam.FlyNavigate()

#Hide the mouse curser
viz.mouse.setVisible(viz.OFF)