/* -*-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 */ #ifndef OSGEARTHSYMBOLOGY_STROKE_H #define OSGEARTHSYMBOLOGY_STROKE_H 1 #include #include #include #include namespace osgEarth { /** * Drawing parameters for a line. */ class OSGEARTH_EXPORT Stroke { public: /** Style for rendering the end caps of a line string. */ enum LineCapStyle { LINECAP_FLAT, /** no endcap. the line ends at the terminal point. */ LINECAP_SQUARE, /** endcap extends width()/2 past the terminal point and is squared off. */ LINECAP_ROUND /** endcap extends width()/2 past the terminal point and is rounded off. */ }; /** Style for rendering the joins between line segments. */ enum LineJoinStyle { LINEJOIN_MITRE, /** outside joins form a sharp point. */ LINEJOIN_ROUND /** outside joins form an arc. */ }; public: Stroke(); Stroke(float r, float g, float b, float a ); Stroke(const Color& color ); Stroke(const Config& conf ); Stroke(const Stroke& rhs); virtual ~Stroke() { } /** Line color. */ Color& color() { return _color; } const Color& color() const { return _color; } /** Capping of line ends. */ optional& lineCap() { return _lineCap; } const optional& lineCap() const { return _lineCap; } /** How to render line joints in a LineString. */ optional& lineJoin() { return _lineJoin; } const optional& lineJoin() const { return _lineJoin; } /** Line rendering width. */ optional& width() { return _width; } const optional& width() const { return _width; } /** Units for the width property. (default = Units::PIXELS) */ optional& widthUnits() { return _widthUnits; } const optional& widthUnits() const { return _widthUnits; } /** Minimum with of a line in pixels (default = 0.0, no minimum). This typically only applies to lines with map unit width, and tells the renderer to maintain a minimum pixel width so that the geometry is always visible. */ optional& minPixels() { return _minPixels; } const optional& minPixels() const { return _minPixels; } /** Stippling pattern. Bitmask of pixels to draw. */ optional& stipplePattern() { return _stipplePattern; } const optional& stipplePattern() const { return _stipplePattern; } /** Stippling factor; number of times to repeat each bit in the stipplePattern. */ optional& stippleFactor() { return _stippleFactor; } const optional& stippleFactor() const { return _stippleFactor; } /** Backwards-compatibility only */ optional& stipple() { return _stipplePattern; } const optional& stipple() const { return _stipplePattern; } /** Smoothing/antialiasing */ optional& smooth() { return _smooth; } const optional& smooth() const { return _smooth; } /** Rounding ratio - when rounding corners/caps, this is the ratio of rounded-segment length to width(). The smaller this value, the more detailed the rounding will be. (Default is 0.4) */ optional& roundingRatio() { return _roundingRatio; } const optional& roundingRatio() const { return _roundingRatio; } //! Outline color OE_OPTION(Color, outlineColor); OE_OPTION(Distance, outlineWidth); public: virtual Config getConfig() const; virtual void mergeConfig( const Config& conf ); protected: Color _color; optional _lineCap; optional _lineJoin; optional _width; optional _widthUnits; optional _stippleFactor; optional _stipplePattern; optional _roundingRatio; optional _minPixels; optional _smooth; void init(); }; } // namespace osgEarth OSGEARTH_SPECIALIZE_CONFIG(osgEarth::Stroke); #endif // OSGEARTHSYMBOLOGY_STROKE_H