Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoPolyLineScreenDrawer.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Thibaut Andrieu (Jan 2011)
22**=======================================================================*/
23
24#if !defined _SO_POLY_LINE_SCREEN_DRAWER_H_
25#define _SO_POLY_LINE_SCREEN_DRAWER_H_
26
27#include <Inventor/drawers/SoScreenDrawer.h>
28#include <Inventor/fields/SoSFInt32.h>
29#include <Inventor/fields/SoSFUShort.h>
30#include <Inventor/fields/SoSFUInt32.h>
31#include <Inventor/fields/SoSFColor.h>
32#include <Inventor/fields/SoMFVec2f.h>
33#include <Inventor/fields/SoSFBool.h>
34#include <Inventor/fields/SoSFFloat.h>
35#include <Inventor/SbEventHandler.h>
36#include <Inventor/SbEventArg.h>
37
214{
215 SO_NODE_HEADER( SoPolyLineScreenDrawer );
216
217public:
220
226
236
239
242
249
262
269
279
285 struct EventArg : public SbEventArg
286 {
289 : m_action( action ), m_drawer( drawer )
290 {}
291
294
296 SoHandleEventAction* getAction() const { return m_action; }
297
299 SoPolyLineScreenDrawer* getSource() const { return m_drawer; }
300
301 private:
303 SoHandleEventAction* m_action;
304
306 SoPolyLineScreenDrawer* m_drawer;
307 };
308
317
326
335
337 virtual void clear() { point.deleteValues(0); }
338
345 virtual void reset();
346
347private:
348
350 static void initClass();
351
353 static void exitClass();
354
356 void addPoint( const SbVec2f& point );
357
362 void removePoint( unsigned id );
363
368 void setPoint( unsigned id, const SbVec2f& newPoint);
369
374 void finalize( SoHandleEventAction* action );
375
376private:
377
379 virtual ~SoPolyLineScreenDrawer();
380
381private:
382
384 static void simplify( std::vector<SbVec2f>& polyline, float epsilon );
385
387 static bool isCCW( const std::vector<SbVec2f>& polyline );
388
390 static void makeCCW( std::vector<SbVec2f>& polyline );
391
392private:
393
395 SoSeparator* m_lineRoot;
396
397 // Engine used to convert from MFVec2 to MFVec3. it is used only internally by
398 // this class to draw line in screen space and should not be used by everyone
399 // else, so it is defined in in SoPolyLineScreenDrawer.cxx file.
400
402 class MFVec2ToMFVec3;
404 MFVec2ToMFVec3* m_vec2ToVec3;
405};
406
407
408#endif // _SO_POLY_LINE_SCREEN_DRAWER_H_
409
410
Base class for all event arguments.
Definition SbEventArg.h:41
Class representing an event.
2D vector class.
Definition SbVec.h:76
Allows nodes in a graph to receive input events.
Multiple-value field containing any number of two-dimensional vectors.
Definition SoMFVec2f.h:89
virtual void deleteValues(int start, int num=-1)
Deletes num values beginning at index start (index start through start + num -1 will be del...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Interactively dr...
SbEventHandler< const EventArg & > onStart
Event raised when starting to draw a polyline.
virtual void clear()
Convenience method to clear the points in the line.
SbEventHandler< EventArg & > onFinish
Event raised when the line is finished.
SoSFUShort linePattern
Stipple pattern.
SbEventHandler< const EventArg & > onMove
Event raised during polyline drawing.
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).
SoSFInt32 linePatternScaleFactor
Stipple pattern scale factor.
SoSFFloat lineWidth
Width of lines.
SoPolyLineScreenDrawer()
Constructor.
SoSFUInt32 simplificationThreshold
Threshold (in pixels) used to simplify line when it is finished.
virtual void reset()
Clears the points in the line and resets internal state to initial values.
SoMFVec2f point
Points of line.
Field containing a single Boolean value.
Definition SoSFBool.h:79
Field containing an RGB color.
Definition SoSFColor.h:82
Field containing a floating-point value.
Definition SoSFFloat.h:78
Field containing a int32_t integer.
Definition SoSFInt32.h:80
Field containing an unsigned int32_t integer.
Definition SoSFUInt32.h:80
Field containing an unsigned short integer.
Definition SoSFUShort.h:79
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Base class to dr...
Group node that saves and restores traversal state.
Structure given to callback when an event is raised.
EventArg(SoHandleEventAction *action, SoPolyLineScreenDrawer *drawer)
Default constructor.
SoHandleEventAction * getAction() const
Returns the handle event action related to the drawing.
SoPolyLineScreenDrawer * getSource() const
Returns the drawer.