Files
MapLibreParticleLab/src/mbgl/annotation/fill_annotation_impl.cpp
Bart Louwers 71f6da2722 Add clang-format (#1086)
Co-authored-by: mwilsnd <mwilsnd@gmail.com>
2023-05-01 16:57:37 +02:00

37 lines
1.2 KiB
C++

#include <mbgl/annotation/fill_annotation_impl.hpp>
#include <mbgl/annotation/annotation_manager.hpp>
#include <mbgl/style/style_impl.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
namespace mbgl {
using namespace style;
FillAnnotationImpl::FillAnnotationImpl(AnnotationID id_, FillAnnotation annotation_)
: ShapeAnnotationImpl(id_),
annotation(ShapeAnnotationGeometry::visit(annotation_.geometry, CloseShapeAnnotation{}),
annotation_.opacity,
annotation_.color,
annotation_.outlineColor) {}
void FillAnnotationImpl::updateStyle(Style::Impl& style) const {
Layer* layer = style.getLayer(layerID);
if (!layer) {
auto newLayer = std::make_unique<FillLayer>(layerID, AnnotationManager::SourceID);
newLayer->setSourceLayer(layerID);
layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID);
}
auto* fillLayer = static_cast<FillLayer*>(layer);
fillLayer->setFillOpacity(annotation.opacity);
fillLayer->setFillColor(annotation.color);
fillLayer->setFillOutlineColor(annotation.outlineColor);
}
const ShapeAnnotationGeometry& FillAnnotationImpl::geometry() const {
return annotation.geometry;
}
} // namespace mbgl