DYT/Tool/OpenSceneGraph-3.6.5/include/osgEarth/Stroke
2024-12-25 07:49:36 +08:00

138 lines
5.2 KiB
C++

/* -*-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 <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTHSYMBOLOGY_STROKE_H
#define OSGEARTHSYMBOLOGY_STROKE_H 1
#include <osgEarth/Common>
#include <osgEarth/Color>
#include <osgEarth/Config>
#include <osgEarth/Units>
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<LineCapStyle>& lineCap() { return _lineCap; }
const optional<LineCapStyle>& lineCap() const { return _lineCap; }
/** How to render line joints in a LineString. */
optional<LineJoinStyle>& lineJoin() { return _lineJoin; }
const optional<LineJoinStyle>& lineJoin() const { return _lineJoin; }
/** Line rendering width. */
optional<float>& width() { return _width; }
const optional<float>& width() const { return _width; }
/** Units for the width property. (default = Units::PIXELS) */
optional<UnitsType>& widthUnits() { return _widthUnits; }
const optional<UnitsType>& 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<float>& minPixels() { return _minPixels; }
const optional<float>& minPixels() const { return _minPixels; }
/** Stippling pattern. Bitmask of pixels to draw. */
optional<unsigned short>& stipplePattern() { return _stipplePattern; }
const optional<unsigned short>& stipplePattern() const { return _stipplePattern; }
/** Stippling factor; number of times to repeat each bit in the stipplePattern. */
optional<unsigned>& stippleFactor() { return _stippleFactor; }
const optional<unsigned>& stippleFactor() const { return _stippleFactor; }
/** Backwards-compatibility only */
optional<unsigned short>& stipple() { return _stipplePattern; }
const optional<unsigned short>& stipple() const { return _stipplePattern; }
/** Smoothing/antialiasing */
optional<bool>& smooth() { return _smooth; }
const optional<bool>& 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<float>& roundingRatio() { return _roundingRatio; }
const optional<float>& 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<LineCapStyle> _lineCap;
optional<LineJoinStyle> _lineJoin;
optional<float> _width;
optional<UnitsType> _widthUnits;
optional<unsigned> _stippleFactor;
optional<unsigned short> _stipplePattern;
optional<float> _roundingRatio;
optional<float> _minPixels;
optional<bool> _smooth;
void init();
};
} // namespace osgEarth
OSGEARTH_SPECIALIZE_CONFIG(osgEarth::Stroke);
#endif // OSGEARTHSYMBOLOGY_STROKE_H