1/* -*-c++-*- */ 2/* osgEarth - Geospatial SDK for OpenSceneGraph 3 * Copyright 2019 Pelican Mapping 4 * http://osgearth.org 5 * 6 * osgEarth is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/> 18 */ 19 20#ifndef OSGEARTHSYMBOLOGY_ICON_SYMBOL_H 21#define OSGEARTHSYMBOLOGY_ICON_SYMBOL_H 1 22 23#include <osgEarth/Common> 24#include <osgEarthSymbology/InstanceSymbol> 25 26namespace osgEarth { namespace Symbology 27{ 28 class Style; 29 class InstanceResource; 30 31 /** 32 * Represents a 2D icon for instancing 33 */ 34 class OSGEARTHSYMBOLOGY_EXPORT IconSymbol : public InstanceSymbol 35 { 36 public: 37 // note: these are similar to the values in osgText::Text::AlignmentType 38 enum Alignment { 39 ALIGN_LEFT_TOP, 40 ALIGN_LEFT_CENTER, 41 ALIGN_LEFT_BOTTOM, 42 43 ALIGN_CENTER_TOP, 44 ALIGN_CENTER_CENTER, 45 ALIGN_CENTER_BOTTOM, 46 47 ALIGN_RIGHT_TOP, 48 ALIGN_RIGHT_CENTER, 49 ALIGN_RIGHT_BOTTOM, 50 }; 51 52 public: 53 META_Object(osgEarthSymbology, IconSymbol); 54 55 IconSymbol(const IconSymbol& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY); 56 57 IconSymbol( const Config& conf =Config() ); 58 59 /** dtor */ 60 virtual ~IconSymbol() { } 61 62 /** Alignment of the marker relative to center pixels */ 63 optional<Alignment>& alignment() { return _alignment; } 64 const optional<Alignment>& alignment() const { return _alignment; } 65 66 /** Heading. Semantically this differs from an model's heading */ 67 optional<NumericExpression>& heading() { return _heading; } 68 const optional<NumericExpression>& heading() const { return _heading; } 69 70 /** Decluttering */ 71 optional<bool>& declutter() { return _declutter; } 72 const optional<bool>& declutter() const { return _declutter; } 73 74 /** Whether to enable occlusion culling on the icon, if applicable */ 75 optional<bool>& occlusionCull() { return _occlusionCull; } 76 const optional<bool>& occlusionCull() const { return _occlusionCull; } 77 78 /** The camera altitude at which to start occlusion culling the icon */ 79 optional<double>& occlusionCullAltitude() { return _occlusionCullAltitude; } 80 const optional<double>& occlusionCullAltitude() const { return _occlusionCullAltitude; } 81 82 public: // non-serialized properties (for programmatic use only) 83 84 /** Explicit image to use for 2D icon placemet */ 85 void setImage( osg::Image* image ) { _image = image; } 86 osg::Image* getImage( unsigned maxSize =INT_MAX ) const; 87 88 public: 89 virtual Config getConfig() const; 90 virtual void mergeConfig( const Config& conf ); 91 static void parseSLD(const Config& c, class Style& style); 92 93 public: // InstanceSymbol 94 virtual InstanceResource* createResource() const; 95 96 protected: 97 optional<Alignment> _alignment; 98 optional<NumericExpression> _heading; 99 optional<bool> _declutter; 100 mutable osg::ref_ptr<osg::Image> _image; 101 optional<bool> _occlusionCull; 102 optional<double> _occlusionCullAltitude; 103 }; 104 105} } // namespace osgEarth::Symbology 106 107#endif 108