public class SoPolyLineScreenDrawer extends SoScreenDrawer
Applications will typically use one of the derived classes, for example, SoEllipseScreenDrawer
, SoRectangleScreenDrawer
, SoPolygonScreenDrawer
or SoLassoScreenDrawer
.
The line color is specified by the color
field (default is red).
SoPolyLineScreenDrawer
classes can automatically reduce the number of points in the shape drawn by the user. This is especially useful with SoLassoScreenDrawer
. See the simplificationThreshold
field.
Sub-classes can implement the onMouseDown, onMouseMove, etc... methods, to add and edit points.
Notes:
SoHandleEventAction
to get events. Therefore when using one of the Open Inventor viewer classes, screen drawers will only work when the viewer is in "selection" mode (arrow cursor). (In "viewing" mode, mouse events are handled by the viewer to control the camera.) SoEventCallback
or a dragger, may also handle this event.
SbEventHandler
for methods to set a callback to be notified when this event is raised. point
field. These points are in Open Inventor normalized device coordinates (-1 to 1), not pixel coordinates. SoHandleEventAction
's setHandled() method for the event that finished the polyline. The application can call setHandled() in this callback. SoRectangleScreenDrawer
stores four points even if the mouse down/up events are at the same location. clear()
is called or the user starts a new interaction. SoOrthographicCamera
node.) Be careful because other classes in Open Inventor use normalized screen coordinates ranging from 0 to 1. In particular the SbViewportRegion
normalize() methods and the SbViewVolume
methods that project from 3D to 2D and vice-versa.
SoScreenDrawer
derived node in the sceneGraph (to avoid conflicts in mouse events).
Create a screen drawer, set the callback and add it to the scene graph:
A finish callback that gets the number of points created by the screen drawer:SoRectangleScreenDrawer drawer = new SoRectangleScreenDrawer(); drawer.onFinish.addEventListener(new LineDrawerListener()); root.addChild( drawer );
class LineDrawerListener implements SbEventListener<EventArg> { @Override public void onEvent(EventArg eventArg) { SoPolyLineScreenDrawer drawer = eventArg.getSource(); SoHandleEventAction action = eventArg.getAction(); int numPoints = drawer.point.getNum(); if ( numPoints > 0 ) { // Use points SbVec2f point0 = drawer.point.getValueAt(0); } drawer.clear(); // Remove polyline from screen action.setHandled(); } }
See also:
SoEllipseScreenDrawer
, SoLassoScreenDrawer
, SoPolygonScreenDrawer
, SoRectangleScreenDrawer
, SoScreenDrawer
Modifier and Type | Class and Description |
---|---|
static class |
SoPolyLineScreenDrawer.EventArg
Structure given to callback when an event is raised.
|
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
SoSFColor |
color
Color of line.
|
SoSFBool |
doCCW
Make the line counter-clockwise when it is finalized.
|
SoSFBool |
isClosed
Close the line during display (connect last point to first point).
|
SbEventHandler<SoPolyLineScreenDrawer.EventArg> |
onFinish
Event raised when the line is finished.
|
SoMFVec2f |
point
Points of line.
|
SoSFUInt32 |
simplificationThreshold
Threshold (in pixels) used to simplify line when it is finished.
|
sceneGraph
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoPolyLineScreenDrawer()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Convenience method to clear the points in the line.
|
void |
setFinishCallback(SoPolyLineScreenDrawerCB callback)
Deprecated.
As of Open Inventor 9.8, use
onFinish event instead. |
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
dispose, getEXTERNPROTO, getName, getPROTO, isDisposable, isSynchronizable, setName, setSynchronizable
getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
public final SoSFUInt32 simplificationThreshold
public final SoSFBool doCCW
Note Some shapes (like "8") do not have a defined clockwiseness. In these cases, the result is undefined.
public final SoSFColor color
public final SoMFVec2f point
public final SoSFBool isClosed
Warning This only affects the display.
public final SbEventHandler<SoPolyLineScreenDrawer.EventArg> onFinish
SbEventHandler
for methods to set a callback to be notified when this event is raised. The callback will be called with a line drawer specific EventArg
from which you can query the current action and drawer objects.@Deprecated public void setFinishCallback(SoPolyLineScreenDrawerCB callback)
onFinish
event instead.public void clear()
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com