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.
|
SoNode.RenderModes
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).
|
SoSFUShort |
linePattern
Stipple pattern.
|
SoSFInt32 |
linePatternScaleFactor
Stipple pattern scale factor.
|
SoSFFloat |
lineWidth
Width of lines.
|
SbEventHandler<SoPolyLineScreenDrawer.EventArg> |
onFinish
Event raised when the line is finished.
|
SbEventHandler<SoPolyLineScreenDrawer.EventArg> |
onMove
Event raised during polyline drawing.
|
SbEventHandler<SoPolyLineScreenDrawer.EventArg> |
onStart
Event raised when starting to draw a polyline.
|
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.
|
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, 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, getName, isDisposable, isSynchronizable, setName, setSynchronizable
getNativeResourceHandle
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 SoSFUShort linePattern
The line pattern can be stretched using the linePatternScaleFactor
field.
public final SoSFInt32 linePatternScaleFactor
linePattern
) by multiplying each subseries of consecutive 1s and 0s. Scale factors are clamped to lie between 1 and 255. Default is 1.public final SoSFFloat lineWidth
SbViewportRegion
) is also 72. So effectively line width is specified in pixels unless the application sets a different pixels-per-inch value.public final SbEventHandler<SoPolyLineScreenDrawer.EventArg> onStart
SbEventHandler
for methods to set a callback to be notified when this event is raised. The callback will be called with an EventArg
from which it can query the current action and drawer objects. public final SbEventHandler<SoPolyLineScreenDrawer.EventArg> onMove
SbEventHandler
for methods to set a callback to be notified when this event is raised. The callback will be called with an EventArg
from which it can query the current action and drawer objects. Note that the callback parameter must be declared
const .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. Note that the callback parameter in this case is
not const.Generated on July 31, 2019, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com