LuciadCPillar 2023.1.04
luciad::TranslateEditHandle Class Referencefinal

This handle allows you to translate a feature by translating its geometry using ITranslateEditAction. More...

#include <luciad/edit/handles/TranslateEditHandle.h>

Inheritance diagram for luciad::TranslateEditHandle:
luciad::IEditHandle

Public Member Functions

 TranslateEditHandle (const TranslateEditHandle &other)=delete
 
 TranslateEditHandle (std::shared_ptr< CoordinateReference > reference, const std::shared_ptr< FeatureEditContext > &context)
 Creates a new translate handle that allows you to drag around a feature or geometry horizontally. More...
 
 ~TranslateEditHandle () override
 
void addEditStateObserver (std::shared_ptr< IInvalidationCallback > observer) override
 Adds an observer that is called when the edit state of this handle has changed. More...
 
EditActionBinderaddOnDragAction (std::shared_ptr< ITranslateEditAction > action)
 Adds an action that will be triggered when dragging. More...
 
EditHandleState getEditState () const override
 
std::optional< MouseCursorgetMouseCursor () const override
 
const std::optional< ComplexStrokeLineStyle > & getShadowComplexStrokeLineStyle () const
 Returns the complex stroke line style that is used for shadow lines. More...
 
const std::optional< FillStyle > & getShadowFillStyle () const
 
std::shared_ptr< GeometrygetShadowGeometry () const
 
std::shared_ptr< Observable< std::shared_ptr< Geometry > > > getShadowGeometryProvider () const
 
std::shared_ptr< IIcongetShadowIcon () const
 
const std::optional< LineStyle > & getShadowLineStyle () const
 Returns the line style that is used for shadow lines. More...
 
ZOrder getZOrder () const
 
EventResult onEvent (const std::shared_ptr< IInputEvent > &inputEvent, const std::shared_ptr< FeatureEditContext > &context) override
 Handles the given event, and returns if the event was consumed or not. More...
 
TranslateEditHandleoperator= (const TranslateEditHandle &other)=delete
 
void paint (FeatureCanvas &canvas, const std::shared_ptr< FeatureEditContext > &context) const override
 Paints this handle on the given canvas. More...
 
void removeEditStateObserver (const std::shared_ptr< IInvalidationCallback > &observer) override
 Removes the given observer. More...
 
void setInvalidationCallback (std::shared_ptr< IInvalidationCallback > invalidationCallback) override
 Sets the callback for the handle to call when its visual representation or cursor has changed. More...
 
void setShadowComplexStrokeLineStyle (std::optional< ComplexStrokeLineStyle > style)
 Sets the complex stroke line style that is used for shadow lines. More...
 
void setShadowFillStyle (std::optional< FillStyle > style)
 Fill style that is used when a shadow version of a geometry is painted. More...
 
void setShadowGeometryProvider (std::shared_ptr< Observable< std::shared_ptr< Geometry > > > shadowGeometryProvider)
 Sets the shadow geometry provider of this handle. More...
 
void setShadowIcon (std::shared_ptr< IIcon > icon)
 
void setShadowLineStyle (std::optional< LineStyle > style)
 Sets the line style that is used for shadow lines. More...
 
void setZOrder (ZOrder zOrder)
 Sets the Z-order that is used for this handle's paint calls to the FeatureCanvas. More...
 
- Public Member Functions inherited from luciad::IEditHandle
 IEditHandle ()
 Creates a new edit handle instance. More...
 
virtual ~IEditHandle ()=default
 
virtual void addEditStateObserver (std::shared_ptr< IInvalidationCallback > observer)=0
 Adds an observer that is called when the edit state of this handle has changed. More...
 
virtual EditHandleState getEditState () const =0
 
virtual std::optional< MouseCursorgetMouseCursor () const =0
 
virtual EventResult onEvent (const std::shared_ptr< IInputEvent > &inputEvent, const std::shared_ptr< FeatureEditContext > &context)=0
 Handles the given event, and returns if the event was consumed or not. More...
 
virtual void paint (FeatureCanvas &canvas, const std::shared_ptr< FeatureEditContext > &context) const =0
 Paints this handle on the given canvas. More...
 
virtual void removeEditStateObserver (const std::shared_ptr< IInvalidationCallback > &observer)=0
 Removes the given observer. More...
 
virtual void setInvalidationCallback (std::shared_ptr< IInvalidationCallback > invalidationCallback)=0
 Sets the callback for the handle to call when its visual representation or cursor has changed. More...
 

Detailed Description

This handle allows you to translate a feature by translating its geometry using ITranslateEditAction.

This handle can operate in 2 modes: 1) Feature mode: the handle is highlighted and can be interacted with when the feature is touched.

  • the handle does not paint anything. It depends on the original Feature being painted.
  • you can drag the feature
  • the EditHandleState and cursor are changed accordingly

2) Shadow geometry mode: this mode is enabled when a shadow geometry provider is configured that provides a non-nullptr shadow geometry. A shadow geometry is a draped version of a geometry. In that case the handle is highlighted and can be interacted with when that shadow geometry is touched.

  • the handle paints a shadow geometry
  • you can drag the shadow instead of the feature
  • the EditHandleState and cursor are changed accordingly

If the shadow geometry provider returns nullptr, Feature mode is enabled.

This handle uses drag events to call ITranslateEditAction::translate.

Since
2020.1

Constructor & Destructor Documentation

◆ TranslateEditHandle() [1/2]

luciad::TranslateEditHandle::TranslateEditHandle ( std::shared_ptr< CoordinateReference reference,
const std::shared_ptr< FeatureEditContext > &  context 
)

Creates a new translate handle that allows you to drag around a feature or geometry horizontally.

Parameters
referencethe coordinate reference in which the translation will occur, cannot be nullptr
contextthe context, cannot be nullptr

◆ TranslateEditHandle() [2/2]

luciad::TranslateEditHandle::TranslateEditHandle ( const TranslateEditHandle other)
delete

◆ ~TranslateEditHandle()

luciad::TranslateEditHandle::~TranslateEditHandle ( )
override

Member Function Documentation

◆ addEditStateObserver()

void luciad::TranslateEditHandle::addEditStateObserver ( std::shared_ptr< IInvalidationCallback observer)
overridevirtual

Adds an observer that is called when the edit state of this handle has changed.

Adding the same observer twice is forbidden, and will cause an exception to be thrown.

Parameters
observeran observer
Exceptions
InvalidArgumentExceptionwhen the observer was already added.
Since
2023.1

Implements luciad::IEditHandle.

◆ addOnDragAction()

EditActionBinder & luciad::TranslateEditHandle::addOnDragAction ( std::shared_ptr< ITranslateEditAction action)

Adds an action that will be triggered when dragging.

For every drag event, the following method call will be triggered:

Parameters
actionthe action to be performed on drag, cannot be nullptr.
Returns
an object on which you can specify more options or requirements regarding the given on-drag action, such as the mouse buttons that need to be pressed for the action to be executed.

◆ getEditState()

EditHandleState luciad::TranslateEditHandle::getEditState ( ) const
overridevirtual
Returns
the current state of this handle.

Implements luciad::IEditHandle.

◆ getMouseCursor()

std::optional< MouseCursor > luciad::TranslateEditHandle::getMouseCursor ( ) const
overridevirtual
Returns
the current mouse cursor that should be displayed for this handle. This method typically returns a value when this handle is highlighted or active. If not, std::nullopt can be returned.

Implements luciad::IEditHandle.

◆ getShadowComplexStrokeLineStyle()

const std::optional< ComplexStrokeLineStyle > & luciad::TranslateEditHandle::getShadowComplexStrokeLineStyle ( ) const

Returns the complex stroke line style that is used for shadow lines.

This method is linked to the getShadowLineStyle method:

  • if both of them return std::nullopt, no shadow line is painted
  • if one of them is not std::nullopt, that shadow line style is used
  • it's not possible for both methods to return a non std::nullopt value: they are mutually exclusive
Returns
the complex stroke line style that is used for shadow lines.
Since
2023.1

◆ getShadowFillStyle()

const std::optional< FillStyle > & luciad::TranslateEditHandle::getShadowFillStyle ( ) const
Returns
the fill style that is used when a shadow version of a geometry is painted

◆ getShadowGeometry()

std::shared_ptr< Geometry > luciad::TranslateEditHandle::getShadowGeometry ( ) const
Returns
the current shadow geometry of this handle, or nullptr.
See also
setShadowGeometryProvider

◆ getShadowGeometryProvider()

std::shared_ptr< Observable< std::shared_ptr< Geometry > > > luciad::TranslateEditHandle::getShadowGeometryProvider ( ) const
Returns
the shadow geometry provider of this handle, or nullptr.

◆ getShadowIcon()

std::shared_ptr< IIcon > luciad::TranslateEditHandle::getShadowIcon ( ) const
Returns
the icon that is used when a shadow version of a geometry is painted

◆ getShadowLineStyle()

const std::optional< LineStyle > & luciad::TranslateEditHandle::getShadowLineStyle ( ) const

Returns the line style that is used for shadow lines.

This method is linked to the getShadowComplexStrokeLineStyle method:

  • if both of them return std::nullopt, no shadow line is painted
  • if one of them is not std::nullopt, that shadow line style is used
  • it's not possible for both methods to return a non std::nullopt value: they are mutually exclusive
Returns
the line style that is used for shadow lines.

◆ getZOrder()

ZOrder luciad::TranslateEditHandle::getZOrder ( ) const
Returns
the Z-order that is used for this handle's paint calls to the FeatureCanvas.
See also
setZOrder.
FeatureCanvas draw commands. For example FeatureCanvas::IconDrawCommand::zOrder.

◆ onEvent()

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

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

While handling events, IEditHandles can mark themselves as highlighted or as Active. Related to event handling, the main effect of this is that highlighted or active handles get a higher priority compared to other handles: they get the chance to consume events first. See EditHandleState

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

Implements luciad::IEditHandle.

◆ operator=()

TranslateEditHandle & luciad::TranslateEditHandle::operator= ( const TranslateEditHandle other)
delete

◆ paint()

void luciad::TranslateEditHandle::paint ( FeatureCanvas canvas,
const std::shared_ptr< FeatureEditContext > &  context 
) const
overridevirtual

Paints this handle on the given canvas.

This method is called when

This method only gets called on the UI thread, so there is no need for additional synchronization.

Parameters
canvasthe canvas on which this handle gets painted.
contextthe context, cannot be nullptr

Implements luciad::IEditHandle.

◆ removeEditStateObserver()

void luciad::TranslateEditHandle::removeEditStateObserver ( const std::shared_ptr< IInvalidationCallback > &  observer)
overridevirtual

Removes the given observer.

If the given observer was never added, an exception is thrown.

Parameters
observeran observer
Exceptions
InvalidArgumentExceptionwhen the observer is not known.
Since
2023.1

Implements luciad::IEditHandle.

◆ setInvalidationCallback()

void luciad::TranslateEditHandle::setInvalidationCallback ( std::shared_ptr< IInvalidationCallback invalidationCallback)
overridevirtual

Sets the callback for the handle to call when its visual representation or cursor has changed.

Calling this callback triggers a new call to this handle's paint method.

Parameters
invalidationCallbackthe callback for the handle to call when its visual representation has changed

Implements luciad::IEditHandle.

◆ setShadowComplexStrokeLineStyle()

void luciad::TranslateEditHandle::setShadowComplexStrokeLineStyle ( std::optional< ComplexStrokeLineStyle style)

Sets the complex stroke line style that is used for shadow lines.

Only one shadow line style can be set, if this function is called with a non std::nullopt value when a ComplexStrokeLineStyle has already been set, it will be overwritten.

Parameters
stylethe complex stroke line style that is used for shadow lines.
Since
2023.1

◆ setShadowFillStyle()

void luciad::TranslateEditHandle::setShadowFillStyle ( std::optional< FillStyle style)

Fill style that is used when a shadow version of a geometry is painted.

Setting this to std::nullopt means the shadow version of the geometry won't have a fill style.

Parameters
stylefill style that is used when a shadow version of a geometry is painted.

◆ setShadowGeometryProvider()

void luciad::TranslateEditHandle::setShadowGeometryProvider ( std::shared_ptr< Observable< std::shared_ptr< Geometry > > >  shadowGeometryProvider)

Sets the shadow geometry provider of this handle.

When this provider (or the geometry it returned) is nullptr, Feature mode is enabled for this handle. See TranslateEditHandle for more information.

Parameters
shadowGeometryProviderthe shadow geometry provider that is used by this handle. Can be nullptr to disable the shadow geometry mode.

◆ setShadowIcon()

void luciad::TranslateEditHandle::setShadowIcon ( std::shared_ptr< IIcon icon)
Parameters
iconthe icon that is used when a shadow version of a geometry is painted

◆ setShadowLineStyle()

void luciad::TranslateEditHandle::setShadowLineStyle ( std::optional< LineStyle style)

Sets the line style that is used for shadow lines.

Only one shadow line style can be set, if this function is called with a non std::nullopt value when a ComplexStrokeLineStyle has already been set, it will be overwritten.

Parameters
stylethe line style that is used for shadow lines.

◆ setZOrder()

void luciad::TranslateEditHandle::setZOrder ( ZOrder  zOrder)

Sets the Z-order that is used for this handle's paint calls to the FeatureCanvas.

This Z-order determines which handles are painted on top, when multiple handles overlap. Edit handles with a higher Z-order are painted on top of handles with a lower Z-order. Note: Highlighted edit handles are always painted above regular handles, and active handles are always painted above highlighted handles. The default value is 0.

Parameters
zOrderthe Z-order that is used for this handle's paint calls to the FeatureCanvas. Must be between [-1000,1000].
See also
FeatureCanvas draw commands. For example FeatureCanvas::IconDrawCommand::zOrder.