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 () |
Static Public Member Functions | |
static SoType | getClassTypeId () |
Public Attributes | |
SoSFUInt32 | simplificationThreshold |
SoSFBool | doCCW |
SoSFColor | color |
SoMFVec2f | point |
SoSFBool | isClosed |
SbEventHandler< EventArg & > | onFinish |
Deprecated | |
| |
typedef SbBool | LineDrawerEventCallback (SoHandleEventAction *action, SoPolyLineScreenDrawer *drawer, void *userData) |
virtual SoDEPRECATED void | setFinishCallback (LineDrawerEventCallback *callback, void *userData=NULL) |
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
typedef SbBool SoPolyLineScreenDrawer::LineDrawerEventCallback(SoHandleEventAction *action, SoPolyLineScreenDrawer *drawer, void *userData) |
This is the declaration to use for mouse event callback functions.
Note: These callbacks are called just after the event occurs.
action | Action that generate the event. | |
drawer | The ScreenDrawer node that called the function. | |
userData | Optional pointer specified when the callback was set. |
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 SoDEPRECATED void SoPolyLineScreenDrawer::setFinishCallback | ( | LineDrawerEventCallback * | callback, | |
void * | userData = NULL | |||
) | [virtual] |
Specifies a callback to call when the line is finished.
callback | The callback method. | |
userData | Parameter that will be given to callback. Basically, when the line is finished, this drawer will call:
callback ( action, this, userData );
|
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).
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.
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.