Interactively draw a polyline in normalized screen space. More...
#include <Inventor/drawers/SoPolyLineScreenDrawer.h>
Classes | |
struct | EventArg |
Structure given to callback when an event is raised. More... | |
Public Member Functions | |
virtual SoType | getTypeId () const |
SoPolyLineScreenDrawer () | |
virtual void | clear () |
virtual void | reset () |
Static Public Member Functions | |
static SoType | getClassTypeId () |
Public Attributes | |
SoSFUInt32 | simplificationThreshold |
SoSFBool | doCCW |
SoSFColor | color |
SoMFVec2f | point |
SoSFBool | isClosed |
SoSFUShort | linePattern |
SoSFInt32 | linePatternScaleFactor |
SoSFFloat | lineWidth |
SbEventHandler< const EventArg & > | onStart |
SbEventHandler< const EventArg & > | onMove |
SbEventHandler< EventArg & > | onFinish |
This class is a base class used to allow the user to dynamically draw line-based shapes (lasso, circle, rectangle, ...) on screen. The geometry is defined in normalized screen space ([-1, 1]x[-1, 1]).
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:
SoRectangleScreenDrawer* drawer = new SoRectangleScreenDrawer(); drawer->onFinish.add( lineDrawerCallback ); root->addChild( drawer );
A finish callback that gets the number of points created by the screen drawer:
void lineDrawerCallback( SoPolyLineScreenDrawer::EventArg& eventArg ) { SoPolyLineScreenDrawer *drawer = eventArg.getSource(); SoHandleEventAction *action = eventArg.getAction(); int numPoints = drawer->point.getNum(); if (numPoints > 0) { // Use points SbVec2f pt = drawer->point[0]; } drawer->clear(); // Remove polyline from screen action->setHandled(); }
SoEllipseScreenDrawer, SoLassoScreenDrawer, SoPolygonScreenDrawer, SoRectangleScreenDrawer, SoScreenDrawer
SoPolyLineScreenDrawer::SoPolyLineScreenDrawer | ( | ) |
Constructor.
virtual void SoPolyLineScreenDrawer::clear | ( | ) | [inline, virtual] |
Convenience method to clear the points in the line.
Reimplemented in SoPolygonScreenDrawer.
static SoType SoPolyLineScreenDrawer::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoScreenDrawer.
Reimplemented in SoEllipseScreenDrawer, SoLassoScreenDrawer, SoPolygonScreenDrawer, and SoRectangleScreenDrawer.
virtual SoType SoPolyLineScreenDrawer::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoScreenDrawer.
Reimplemented in SoEllipseScreenDrawer, SoLassoScreenDrawer, SoPolygonScreenDrawer, and SoRectangleScreenDrawer.
virtual void SoPolyLineScreenDrawer::reset | ( | ) | [virtual] |
Clears the points in the line and resets internal state to initial values.
This cancels any current drawing.
Since Open Inventor 10.7.3Reimplemented from SoScreenDrawer.
Reimplemented in SoEllipseScreenDrawer, SoLassoScreenDrawer, and SoRectangleScreenDrawer.
Color of line.
Default value is red.
Make the line counter-clockwise when it is finalized.
This can change order of points. Default is TRUE.
Close the line during display (connect last point to first point).
Default is FALSE (but most sub-classes automatically set it to TRUE).
Stipple pattern.
This specifies how dashed or dotted lines will be drawn. The pattern is a 16-bit series of 0s and 1s and is repeated as necessary to stipple a given line. A 1 indicates that drawing occurs, and a 0 that it does not, on a pixel-by-pixel basis, starting with the low-order bits of the pattern. Values can range from 0 (invisible) to 0xffff (solid). Default is 0xffff.
The line pattern can be stretched using the linePatternScaleFactor field.
Stipple pattern scale factor.
It stretches the line pattern (see linePattern) by multiplying each subseries of consecutive 1s and 0s. Scale factors are clamped to lie between 1 and 255. Default is 1.
Width of lines.
The default line width is 0, meaning to use the default OpenGL value (1). Line widths greater than zero are considered to be specified in printer's points, where 1 inch = 72 printer's points. However the default pixels-per-inch value (managed by SbViewportRegion) is also 72. So effectively line width is specified in pixels unless the application sets a different pixels-per-inch value.
Event raised when the line is finished.
See 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.
Event raised during polyline drawing.
See 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 .
Event raised when starting to draw a polyline.
See 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 .
Points of line.
Default is empty.
Threshold (in pixels) used to simplify line when it is finished.
A value of 0 means no simplification. Default value is 5 pixels.