/* -*-c++-*- */
/* osgEarth - Geospatial SDK for OpenSceneGraph
* Copyright 2020 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see
*/
#pragma once
#include
#include
#include
#include
#include
namespace osgEarth
{
/**
* Symbol that describes how to render text labels.
*/
class OSGEARTH_EXPORT TextSymbol : public Symbol
{
public:
enum Encoding {
ENCODING_ASCII,
ENCODING_UTF8,
ENCODING_UTF16,
ENCODING_UTF32
};
// note: these are identical to the values in osgText::Text::AlignmentType
enum Alignment {
ALIGN_LEFT_TOP,
ALIGN_LEFT_CENTER,
ALIGN_LEFT_BOTTOM,
ALIGN_CENTER_TOP,
ALIGN_CENTER_CENTER,
ALIGN_CENTER_BOTTOM,
ALIGN_RIGHT_TOP,
ALIGN_RIGHT_CENTER,
ALIGN_RIGHT_BOTTOM,
ALIGN_LEFT_BASE_LINE,
ALIGN_CENTER_BASE_LINE,
ALIGN_RIGHT_BASE_LINE,
ALIGN_LEFT_BOTTOM_BASE_LINE,
ALIGN_CENTER_BOTTOM_BASE_LINE,
ALIGN_RIGHT_BOTTOM_BASE_LINE,
ALIGN_BASE_LINE = ALIGN_LEFT_BASE_LINE /// default.
};
enum Layout {
LAYOUT_LEFT_TO_RIGHT,
LAYOUT_RIGHT_TO_LEFT,
LAYOUT_VERTICAL
};
META_Object(osgEarth, TextSymbol);
TextSymbol(const TextSymbol& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
TextSymbol( const Config& conf =Config() );
/** dtor */
virtual ~TextSymbol() { }
/** Text fill color. */
optional& fill() { return _fill; }
const optional& fill() const { return _fill; }
/** Text outline color. */
optional& halo() { return _halo; }
const optional& halo() const { return _halo; }
/** Text outline offset */
optional& haloOffset() { return _haloOffset; }
const optional& haloOffset() const { return _haloOffset; }
/** Halo backdrop type */
optional& haloBackdropType() { return _haloBackdropType; }
const optional& haloBackdropType() const { return _haloBackdropType; }
/** Halo backdrop implementation */
optional& haloImplementation() { return _haloImplementation; }
const optional& haloImplementation() const { return _haloImplementation; }
/** Name of text font. */
optional& font() { return _font; }
const optional& font() const { return _font; }
/** Actual text to render (if applicable) */
optional& content() { return _content; }
const optional& content() const { return _content; }
/** Priority of the label (applicable when the renderer sorts labels) */
optional& priority() { return _priority; }
const optional& priority() const { return _priority; }
/** Font size. */
optional& size() { return _size; }
const optional& size() const { return _size; }
/** Pixel offset from the center point. */
optional& pixelOffset() { return _pixelOffset; }
const optional& pixelOffset() const { return _pixelOffset; }
/** On screen rotation **/
optional& onScreenRotation() { return _onScreenRotation; }
const optional& onScreenRotation() const { return _onScreenRotation; }
/** Label orientation for following a fixed course on the map. */
optional& geographicCourse() { return _geographicCourse; }
const optional& geographicCourse() const { return _geographicCourse; }
/** Alignment of the label relative to (0,0) pixels */
optional& alignment() { return _alignment; }
const optional& alignment() const { return _alignment; }
/** Layout of the label*/
optional& layout() { return _layout; }
const optional& layout() const { return _layout; }
/** Whether to enable decluttering on the text, if applicable */
optional& declutter() { return _declutter; }
const optional& declutter() const { return _declutter; }
/** Whether to enable occlusion culling on the text */
optional& occlusionCull() { return _occlusionCull; }
const optional& occlusionCull() const { return _occlusionCull; }
/** The viewer altitude at which to start occlusion culling the text */
optional& occlusionCullAltitude() { return _occlusionCullAltitude; }
const optional& occlusionCullAltitude() const { return _occlusionCullAltitude; }
/** Label generation provider to use */
optional& provider() { return _provider; }
const optional& provider() const { return _provider; }
/** text encoding */
optional& encoding() { return _encoding; }
const optional& encoding() const { return _encoding; }
/** text encoding */
optional& unique() { return _unique; }
const optional& unique() const { return _unique; }
public:
virtual Config getConfig() const;
virtual void mergeConfig( const Config& conf );
static void parseSLD(const Config& c, class Style& style);
protected:
optional _fill;
optional _halo;
optional _haloOffset;
optional _haloBackdropType;
optional _haloImplementation;
optional _font;
optional _size;
optional _content;
optional _priority;
optional _pixelOffset;
optional _onScreenRotation;
optional _geographicCourse;
optional _provider;
optional _encoding;
optional _alignment;
optional _layout;
optional _declutter;
optional _occlusionCull;
optional _occlusionCullAltitude;
optional _unique;
};
} // namespace osgEarth