LuciadCPillar 2023.1.04
luciad::PolylineRingCreator Class Referencefinal

This class can create (2D) polyline ring instances. More...

#include <luciad/create/geometries/PolylineRingCreator.h>

Inheritance diagram for luciad::PolylineRingCreator:
luciad::IGeometryCreator

Public Member Functions

 PolylineRingCreator (std::shared_ptr< CoordinateReference > reference)
 Creates a new polyline ring creator instance. More...
 
 ~PolylineRingCreator () override
 
std::shared_ptr< IPolylineRingConstraintgetConstraint () const
 
LineCreationMode getLineCreationMode () const
 
LineInterpolationType getLineInterpolationType ()
 
size_t getMaxPointCount () const
 
size_t getMinPointCount () const
 
EventResult onEvent (const std::shared_ptr< IInputEvent > &inputEvent, const std::shared_ptr< FeatureCreateContext > &context) override
 Handles the given event, and returns if the event was handled or not. More...
 
void setConstraint (std::shared_ptr< IPolylineRingConstraint > constraint)
 Sets the constraint to use during creation. More...
 
void setLineCreationMode (LineCreationMode mode)
 
void setLineInterpolationType (LineInterpolationType lineInterpolationType)
 Sets the line interpolation that is used for the geometry. More...
 
void setMaxPointCount (size_t maxPointCount)
 Sets the maximum amount of points a polyline ring can have. More...
 
void setMinPointCount (size_t minPointCount)
 Sets the minimum amount of points a polyline ring can have. More...
 
void start (std::shared_ptr< IGeometryCreateCallback > callback, const std::shared_ptr< FeatureCreateContext > &context) override
 This method is called to start creation. More...
 
- Public Member Functions inherited from luciad::IGeometryCreator
virtual ~IGeometryCreator ()=default
 
virtual EventResult onEvent (const std::shared_ptr< IInputEvent > &inputEvent, const std::shared_ptr< FeatureCreateContext > &context)=0
 Handles the given event, and returns if the event was handled or not. More...
 
virtual void start (std::shared_ptr< IGeometryCreateCallback > callback, const std::shared_ptr< FeatureCreateContext > &context)=0
 This method is called to start creation. More...
 

Detailed Description

This class can create (2D) polyline ring instances.

It reacts on input events to create polyline rings. The event handling behavior can be restricted based on the currently set line creation mode.

The events handled in Click mode are:

The events handled in Freehand mode are:

  • Drag events to continuously add points. Creation starts, with points being added as long as the drag event is ongoing, and creation is finished when dragging stops. Points are not added on every Drag event, indeed a heuristic is used to only add a point when the distance to the previous point or the curvature is high enough.
  • This results in changes that are luciad::ChangeStatus::InProgressKeyPoint if a new point is added, luciad::ChangeStatus::InProgress if the drag move does not trigger a new point (i.e. the wannabee point is too close to the previous one), or luciad::ChangeStatus::Finished when the drag ends.

In Automatic mode (the default creation mode), the first event since creation is started determines how polyline points are added. If the first event is a mouse click or touch tap, events are added in Click mode. If a drag event is initiated, points are added in Freehand mode.

It is possible to constrain polyline creation using:

This class does not allow you to interactively choose the elevation of the points. The elevation will by default be set to 0.

Since
2020.1

Constructor & Destructor Documentation

◆ PolylineRingCreator()

luciad::PolylineRingCreator::PolylineRingCreator ( std::shared_ptr< CoordinateReference reference)
explicit

Creates a new polyline ring creator instance.

Parameters
referencethe reference of the created polyline ring

◆ ~PolylineRingCreator()

luciad::PolylineRingCreator::~PolylineRingCreator ( )
override

Member Function Documentation

◆ getConstraint()

std::shared_ptr< IPolylineRingConstraint > luciad::PolylineRingCreator::getConstraint ( ) const
Returns
the constraint that is used during creation. Can be nullptr.
See also
setConstraint

◆ getLineCreationMode()

LineCreationMode luciad::PolylineRingCreator::getLineCreationMode ( ) const
Returns
the creation mode that is used.
See also
LineCreationMode

◆ getLineInterpolationType()

LineInterpolationType luciad::PolylineRingCreator::getLineInterpolationType ( )
Returns
the line interpolation that is used for the geometry

◆ getMaxPointCount()

size_t luciad::PolylineRingCreator::getMaxPointCount ( ) const
Returns
the maximum amount of points a polyline ring can have.
See also
setMaxPointCount

◆ getMinPointCount()

size_t luciad::PolylineRingCreator::getMinPointCount ( ) const
Returns
the minimum amount of points a polyline ring can have.
See also
setMinPointCount

◆ onEvent()

EventResult luciad::PolylineRingCreator::onEvent ( const std::shared_ptr< IInputEvent > &  inputEvent,
const std::shared_ptr< FeatureCreateContext > &  context 
)
overridevirtual

Handles the given event, and returns if the event was handled or not.

Parameters
contextthe context, cannot be nullptr
inputEventan event, cannot be nullptr
Returns
if the event was consumed or not
Exceptions
NullArgumentExceptionwhen nullptr is passed.

Implements luciad::IGeometryCreator.

◆ setConstraint()

void luciad::PolylineRingCreator::setConstraint ( std::shared_ptr< IPolylineRingConstraint constraint)

Sets the constraint to use during creation.

The default is no constraint.

The constraint behavior is as follows:

  • Initially the first 3 points are added and positioned. This results in calls to the constraint without a PolylineChange.
  • After positioning the first 3 points, additional points are inserted and positioned, until creation is ended. This results in calls to the constraint with a change containing 1 point insert.

Constraints are not allowed to change the point count during creation. Doing this will result in an exception.

Parameters
constraintthe constraint. Can be nullptr.

◆ setLineCreationMode()

void luciad::PolylineRingCreator::setLineCreationMode ( LineCreationMode  mode)
Parameters
modethe creation mode that is used.

The line creation mode is Automatic by default.

See also
LineCreationMode

◆ setLineInterpolationType()

void luciad::PolylineRingCreator::setLineInterpolationType ( LineInterpolationType  lineInterpolationType)

Sets the line interpolation that is used for the geometry.

The default is LineInterpolationType::Geodesic.

Parameters
lineInterpolationTypethe line interpolation to use

◆ setMaxPointCount()

void luciad::PolylineRingCreator::setMaxPointCount ( size_t  maxPointCount)

Sets the maximum amount of points a polyline ring can have.

The creator automatically finishes creation when the polyline ring reaches this maximum point count. By default, this value is the maximum value of size_t, which realistically corresponds to "no maximum".

Parameters
maxPointCountthe maximum number of points allowed.
Exceptions
InvalidArgumentExceptionif maxPointCount is lower than the current min point count.

◆ setMinPointCount()

void luciad::PolylineRingCreator::setMinPointCount ( size_t  minPointCount)

Sets the minimum amount of points a polyline ring can have.

The creator cannot finish creation before the created polyline ring has at least this minimum point count. By default, this value is 3.

If the creation mode is LineCreationMode::Freehand, the feature creation is always finished when when the final DragEvent is received. If not enough point were generated prior to it, the created polylinering is filled with the needed amount of points at the last received location.

Parameters
minPointCountthe minimum number of points allowed.
Exceptions
InvalidArgumentExceptionif minPointCount is lower than 3, or higher than the current max point count.

◆ start()

void luciad::PolylineRingCreator::start ( std::shared_ptr< IGeometryCreateCallback callback,
const std::shared_ptr< FeatureCreateContext > &  context 
)
overridevirtual

This method is called to start creation.

After this call, IGeometryCreator::onEvent can be called.

When a IGeometryCreator was started, it can not be started again until it has finished. Implementations of this method are encouraged to throw an exception in that case to signal a programming error by the caller of this method.

Parameters
contextthe context, cannot be nullptr
callbackthe callback to signal geometry changes, and whether creation for the geometry has finished, cannot be nullptr.
Exceptions
NullArgumentExceptionwhen nullptr is passed.

Implements luciad::IGeometryCreator.