LuciadCPillar 2023.1.03
luciad::Layer Class Referenceabstract

Common representation for layers that can be added to a map. More...

#include <luciad/layers/Layer.h>

Inheritance diagram for luciad::Layer:
luciad::FeatureLayer luciad::GridLayer luciad::RasterLayer luciad::TileSet3DLayer luciad::LonLatGridLayer luciad::MgrsGridLayer

Public Member Functions

 Layer ()
 Default constructor. More...
 
virtual ~Layer ()=default
 
virtual void addObserver (std::shared_ptr< ILayerObserver > layerObserver)=0
 Adds an observer that allows to receive change events from this layer. More...
 
virtual LayerId getId () const
 Returns the layer's unique id. More...
 
virtual const std::string & getTitle () const =0
 Returns the layer's title. More...
 
virtual bool isVisible () const =0
 Returns whether this layer is visible. More...
 
virtual void removeObserver (const std::shared_ptr< ILayerObserver > &layerObserver)=0
 Removes the given observer. More...
 
virtual void setTitle (std::string title)=0
 Sets the layer's title. More...
 
virtual void setVisible (bool visible)=0
 Sets whether this layer is visible. More...
 

Static Public Member Functions

static const std::string & propertyTitle ()
 Property name for the LayerEvent that is fired as a result of changing the layer's title. More...
 
static const std::string & propertyVisible ()
 Property name for the LayerEvent that is fired as a result of changing the layer's visible flag. More...
 

Detailed Description

Common representation for layers that can be added to a map.

A layer has a few properties that can be changed.

  • visibility
  • title

An observer can be attached to get notifications about layer changes.

Use one of the concrete classes extending this class.

Note that this class tracks on which thread it is constructed. This is done so that, in subsequent calls, it can verify that the same threads are used consistently. When an inconsistency is detected, an assertion is triggered. This means that all functions on Layer (and its subclasses) must be called on the thread on which the Map was constructed (the "UI" thread). The only exception is adding and removing observers. Related article: Threading rules for the Map

Constructor & Destructor Documentation

◆ Layer()

luciad::Layer::Layer ( )

Default constructor.

It's not the intent to extend from this class, nor is it the intent to directly instantiate this class, so this constructor must not be used.

◆ ~Layer()

virtual luciad::Layer::~Layer ( )
virtualdefault

Member Function Documentation

◆ addObserver()

virtual void luciad::Layer::addObserver ( std::shared_ptr< ILayerObserver layerObserver)
pure virtual

Adds an observer that allows to receive change events from this layer.

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

Parameters
layerObserveran observer.
Exceptions
luciad::InvalidArgumentExceptionwhen the observer was already added.
luciad::NullArgumentExceptionwhen the observer is nullptr.

Implemented in luciad::FeatureLayer, luciad::LonLatGridLayer, luciad::MgrsGridLayer, luciad::RasterLayer, and luciad::TileSet3DLayer.

◆ getId()

virtual LayerId luciad::Layer::getId ( ) const
virtual

Returns the layer's unique id.

Returns
the layer's unique id.

◆ getTitle()

virtual const std::string & luciad::Layer::getTitle ( ) const
pure virtual

Returns the layer's title.

Should be suitable for presenting to the user.

Returns
the layer's title, should be suitable for presenting to the user.

Implemented in luciad::FeatureLayer, luciad::LonLatGridLayer, luciad::MgrsGridLayer, luciad::RasterLayer, and luciad::TileSet3DLayer.

◆ isVisible()

virtual bool luciad::Layer::isVisible ( ) const
pure virtual

Returns whether this layer is visible.

Returns
whether this layer is visible.

Implemented in luciad::FeatureLayer, luciad::LonLatGridLayer, luciad::MgrsGridLayer, luciad::RasterLayer, and luciad::TileSet3DLayer.

◆ propertyTitle()

static const std::string & luciad::Layer::propertyTitle ( )
static

Property name for the LayerEvent that is fired as a result of changing the layer's title.

See also
setTitle

◆ propertyVisible()

static const std::string & luciad::Layer::propertyVisible ( )
static

Property name for the LayerEvent that is fired as a result of changing the layer's visible flag.

See also
setVisible

◆ removeObserver()

virtual void luciad::Layer::removeObserver ( const std::shared_ptr< ILayerObserver > &  layerObserver)
pure virtual

Removes the given observer.

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

Parameters
layerObserveran observer.
Exceptions
luciad::InvalidArgumentExceptionwhen the observer is not known.
luciad::NullArgumentExceptionwhen the observer is nullptr.

Implemented in luciad::FeatureLayer, luciad::LonLatGridLayer, luciad::MgrsGridLayer, luciad::RasterLayer, and luciad::TileSet3DLayer.

◆ setTitle()

virtual void luciad::Layer::setTitle ( std::string  title)
pure virtual

Sets the layer's title.

Should be suitable for presenting to the user.

If the new title is indeed different from the old one, a LayerEvent is delivered to the observers with the property name PropertyTitle.

Parameters
titlethe new title.

Implemented in luciad::FeatureLayer, luciad::LonLatGridLayer, luciad::MgrsGridLayer, luciad::RasterLayer, and luciad::TileSet3DLayer.

◆ setVisible()

virtual void luciad::Layer::setVisible ( bool  visible)
pure virtual

Sets whether this layer is visible.

Changes this layer's visibility. If the new visibility is different from the old one, a LayerEvent is delivered to the observers with the property name PropertyVisible.

Parameters
visiblethe new visibility.

Implemented in luciad::FeatureLayer, luciad::LonLatGridLayer, luciad::MgrsGridLayer, luciad::RasterLayer, and luciad::TileSet3DLayer.