本文整理汇总了C++中TextSymbol::fill方法的典型用法代码示例。如果您正苦于以下问题:C++ TextSymbol::fill方法的具体用法?C++ TextSymbol::fill怎么用?C++ TextSymbol::fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextSymbol
的用法示例。
在下文中一共展示了TextSymbol::fill方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: options
void
MGRSGraticule::setUpDefaultStyles()
{
if (!options().gzdStyle().isSet())
{
LineSymbol* line = options().gzdStyle()->getOrCreate<LineSymbol>();
line->stroke()->color() = Color::Gray;
line->stroke()->width() = 1.0;
line->tessellation() = 20;
TextSymbol* text = options().gzdStyle()->getOrCreate<TextSymbol>();
text->fill()->color() = Color(Color::White, 0.3f);
text->halo()->color() = Color(Color::Black, 0.2f);
text->alignment() = TextSymbol::ALIGN_CENTER_CENTER;
}
if (!options().sqidStyle().isSet())
{
LineSymbol* line = options().sqidStyle()->getOrCreate<LineSymbol>();
line->stroke()->color() = Color(Color::White, 0.5f);
line->stroke()->stipplePattern() = 0x1111;
TextSymbol* text = options().sqidStyle()->getOrCreate<TextSymbol>();
text->fill()->color() = Color(Color::White, 0.3f);
text->halo()->color() = Color(Color::Black, 0.1f);
text->alignment() = TextSymbol::ALIGN_CENTER_CENTER;
}
}
示例2: TextSymbol
/**
* Creates a field schema that we'll later use as a labeling template for
* TrackNode instances.
*/
void
createFieldSchema( TrackNodeFieldSchema& schema )
{
// draw the track name above the icon:
TextSymbol* nameSymbol = new TextSymbol();
nameSymbol->pixelOffset()->set( 0, 2+ICON_SIZE/2 );
nameSymbol->alignment() = TextSymbol::ALIGN_CENTER_BOTTOM;
nameSymbol->halo()->color() = Color::Black;
nameSymbol->size() = nameSymbol->size()->eval() + 2.0f;
schema[FIELD_NAME] = TrackNodeField(nameSymbol, false); // false => static label (won't change after set)
// draw the track coordinates below the icon:
TextSymbol* posSymbol = new TextSymbol();
posSymbol->pixelOffset()->set( 0, -2-ICON_SIZE/2 );
posSymbol->alignment() = TextSymbol::ALIGN_CENTER_TOP;
posSymbol->fill()->color() = Color::Yellow;
posSymbol->size() = posSymbol->size()->eval() - 2.0f;
schema[FIELD_POSITION] = TrackNodeField(posSymbol, true); // true => may change at runtime
// draw some other field to the left:
TextSymbol* numberSymbol = new TextSymbol();
numberSymbol->pixelOffset()->set( -2-ICON_SIZE/2, 0 );
numberSymbol->alignment() = TextSymbol::ALIGN_RIGHT_CENTER;
schema[FIELD_NUMBER] = TrackNodeField(numberSymbol, false);
}
示例3: UTMGraticule
MGRSGraticule::MGRSGraticule( MapNode* mapNode ) :
UTMGraticule( 0L )
{
_mapNode = mapNode;
init();
if ( !_options->secondaryStyle().isSet() )
{
LineSymbol* line = _options->secondaryStyle()->getOrCreate<LineSymbol>();
line->stroke()->color() = Color(Color::White, 0.5f);
line->stroke()->stipple() = 0x1111;
TextSymbol* text = _options->secondaryStyle()->getOrCreate<TextSymbol>();
text->fill()->color() = Color(Color::White, 0.3f);
text->halo()->color() = Color(Color::Black, 0.1f);
text->alignment() = TextSymbol::ALIGN_CENTER_CENTER;
}
_minDepthOffset = DepthOffsetUtils::createMinOffsetUniform();
_minDepthOffset->set( 11000.0f );
}
示例4: if
bool
SLDReader::readStyleFromCSSParams( const Config& conf, Style& sc )
{
sc.setName( conf.key() );
LineSymbol* line = 0L;
PolygonSymbol* polygon = 0L;
PointSymbol* point = 0L;
TextSymbol* text = 0L;
ExtrusionSymbol* extrusion = 0L;
MarkerSymbol* marker = 0L;
AltitudeSymbol* altitude = 0L;
for(Properties::const_iterator p = conf.attrs().begin(); p != conf.attrs().end(); p++ )
{
if ( p->first == CSS_STROKE )
{
if (!line) line = sc.getOrCreateSymbol<LineSymbol>();
line->stroke()->color() = htmlColorToVec4f( p->second );
}
else if ( p->first == CSS_STROKE_OPACITY )
{
if (!line) line = sc.getOrCreateSymbol<LineSymbol>();
line->stroke()->color().a() = as<float>( p->second, 1.0f );
}
else if ( p->first == CSS_STROKE_WIDTH )
{
if (!line) line = sc.getOrCreateSymbol<LineSymbol>();
line->stroke()->width() = as<float>( p->second, 1.0f );
}
else if ( p->first == CSS_STROKE_LINECAP )
{
if (!line) line = sc.getOrCreateSymbol<LineSymbol>();
parseLineCap( p->second, line->stroke()->lineCap() );
}
else if ( p->first == CSS_FILL )
{
if (!polygon) polygon = sc.getOrCreateSymbol<PolygonSymbol>();
polygon->fill()->color() = htmlColorToVec4f( p->second );
if ( !point ) point = sc.getOrCreateSymbol<PointSymbol>();
point->fill()->color() = htmlColorToVec4f( p->second );
if ( !text ) text = new TextSymbol();
text->fill()->color() = htmlColorToVec4f( p->second );
}
else if ( p->first == CSS_FILL_OPACITY )
{
if (!polygon) polygon = sc.getOrCreateSymbol<PolygonSymbol>();
polygon->fill()->color().a() = as<float>( p->second, 1.0f );
if (!polygon) polygon = sc.getOrCreateSymbol<PolygonSymbol>();
point->fill()->color().a() = as<float>( p->second, 1.0f );
if (!text) text = sc.getOrCreateSymbol<TextSymbol>();
text->fill()->color().a() = as<float>( p->second, 1.0f );
}
else if (p->first == CSS_POINT_SIZE)
{
if ( !point ) point = sc.getOrCreateSymbol<PointSymbol>();
point->size() = as<float>(p->second, 1.0f);
}
else if (p->first == CSS_TEXT_SIZE)
{
if (!text) text = sc.getOrCreateSymbol<TextSymbol>();
text->size() = as<float>(p->second, 32.0f);
}
else if (p->first == CSS_TEXT_FONT)
{
if (!text) text = sc.getOrCreateSymbol<TextSymbol>();
text->font() = p->second;
}
else if (p->first == CSS_TEXT_HALO)
{
if (!text) text = sc.getOrCreateSymbol<TextSymbol>();
text->halo()->color() = htmlColorToVec4f( p->second );
}
//else if (p->first == CSS_TEXT_ATTRIBUTE)
//{
// if (!text) text = sc.getOrCreateSymbol<TextSymbol>();
// text->attribute() = p->second;
//}
else if (p->first == CSS_TEXT_ROTATE_TO_SCREEN)
{
if (!text) text = sc.getOrCreateSymbol<TextSymbol>();
if (p->second == "true") text->rotateToScreen() = true;
else if (p->second == "false") text->rotateToScreen() = false;
}
else if (p->first == CSS_TEXT_SIZE_MODE)
{
if (!text) text = sc.getOrCreateSymbol<TextSymbol>();
if (p->second == "screen") text->sizeMode() = TextSymbol::SIZEMODE_SCREEN;
else if (p->second == "object") text->sizeMode() = TextSymbol::SIZEMODE_OBJECT;
}
else if (p->first == CSS_TEXT_REMOVE_DUPLICATE_LABELS)
{
if (!text) text = sc.getOrCreateSymbol<TextSymbol>();
if (p->second == "true") text->removeDuplicateLabels() = true;
else if (p->second == "false") text->removeDuplicateLabels() = false;
}
//.........这里部分代码省略.........
示例5: FeatureProfile
void
UTMGraticule::rebuild()
{
if (_root.valid() == false)
return;
osg::ref_ptr<const Map> map;
if (!_map.lock(map))
return;
// clear everything out
_root->removeChildren( 0, _root->getNumChildren() );
// requires a geocentric map
if ( !map->isGeocentric() )
{
OE_WARN << LC << "Projected map mode is not yet supported" << std::endl;
return;
}
const Profile* mapProfile = map->getProfile();
_profile = Profile::create(
mapProfile->getSRS(),
mapProfile->getExtent().xMin(),
mapProfile->getExtent().yMin(),
mapProfile->getExtent().xMax(),
mapProfile->getExtent().yMax(),
8, 4 );
_featureProfile = new FeatureProfile(_profile->getSRS());
//todo: do this right..
osg::StateSet* set = this->getOrCreateStateSet();
GLUtils::setLighting(set, 0);
set->setMode( GL_BLEND, 1 );
set->setMode( GL_CLIP_DISTANCE0, 1 );
// set up default options if the caller did not supply them
if ( !options().gzdStyle().isSet() )
{
options().gzdStyle() = Style();
LineSymbol* line = options().gzdStyle()->getOrCreate<LineSymbol>();
line->stroke()->color() = Color::Gray;
line->stroke()->width() = 1.0;
line->tessellation() = 20;
TextSymbol* text = options().gzdStyle()->getOrCreate<TextSymbol>();
text->fill()->color() = Color(Color::White, 0.3f);
text->halo()->color() = Color(Color::Black, 0.2f);
text->alignment() = TextSymbol::ALIGN_CENTER_CENTER;
}
// initialize the UTM sector tables for this profile.
_utmData.rebuild(_profile.get());
// now build the lateral tiles for the GZD level.
for( UTMData::SectorTable::iterator i = _utmData.sectorTable().begin(); i != _utmData.sectorTable().end(); ++i )
{
osg::Node* tile = _utmData.buildGZDTile(i->first, i->second, options().gzdStyle().get(), _featureProfile.get(), map.get());
if ( tile )
_root->addChild( tile );
}
}
示例6: lock
void
UTMGraticule::init()
{
if ( !_mapNode.valid() )
{
OE_WARN << LC << "Illegal NULL map node" << std::endl;
return;
}
if ( !_mapNode->isGeocentric() )
{
OE_WARN << LC << "Projected map mode is not yet supported" << std::endl;
return;
}
// safely generate a unique ID for this graticule:
_id = Registry::instance()->createUID();
{
Threading::ScopedMutexLock lock( s_graticuleMutex );
s_graticuleRegistry[_id] = this;
}
const Profile* mapProfile = _mapNode->getMap()->getProfile();
_profile = Profile::create(
mapProfile->getSRS(),
mapProfile->getExtent().xMin(),
mapProfile->getExtent().yMin(),
mapProfile->getExtent().xMax(),
mapProfile->getExtent().yMax(),
8, 4 );
_featureProfile = new FeatureProfile(_profile->getSRS());
//todo: do this right..
osg::StateSet* set = this->getOrCreateStateSet();
set->setMode( GL_LIGHTING, 0 );
set->setMode( GL_BLEND, 1 );
// set up default options if the caller did not supply them
if ( !_options.isSet() )
{
_options->primaryStyle()= Style();
LineSymbol* line = _options->primaryStyle()->getOrCreate<LineSymbol>();
line->stroke()->color() = Color::Gray;
line->stroke()->width() = 1.0;
line->tessellation() = 20;
AltitudeSymbol* alt = _options->primaryStyle()->getOrCreate<AltitudeSymbol>();
//alt->verticalOffset() = NumericExpression(4900.0);
TextSymbol* text = _options->primaryStyle()->getOrCreate<TextSymbol>();
text->fill()->color() = Color(Color::White, 0.3f);
text->halo()->color() = Color(Color::Black, 0.2f);
text->alignment() = TextSymbol::ALIGN_CENTER_CENTER;
}
// make the shared depth attr:
_depthAttribute = new osg::Depth(osg::Depth::LEQUAL,0,1,false);
// this will intialize the graph.
rebuild();
}
示例7: main
//.........这里部分代码省略.........
featureOptions.url() = "../data/world.shp";
}
else
{
// the --mem options tells us to just make an in-memory geometry:
Ring* line = new Ring();
line->push_back( osg::Vec3d(-60, 20, 0) );
line->push_back( osg::Vec3d(-120, 20, 0) );
line->push_back( osg::Vec3d(-120, 60, 0) );
line->push_back( osg::Vec3d(-60, 60, 0) );
featureOptions.geometry() = line;
}
// Define a style for the feature data. Since we are going to render the
// vectors as lines, configure the line symbolizer:
Style style;
LineSymbol* ls = style.getOrCreateSymbol<LineSymbol>();
ls->stroke()->color() = Color::Yellow;
ls->stroke()->width() = 2.0f;
// That's it, the map is ready; now create a MapNode to render the Map:
MapNodeOptions mapNodeOptions;
mapNodeOptions.enableLighting() = false;
MapNode* mapNode = new MapNode( map, mapNodeOptions );
osg::Group* root = new osg::Group();
root->addChild( mapNode );
viewer.setSceneData( root );
viewer.setCameraManipulator( new EarthManipulator() );
// Process cmdline args
MapNodeHelper().parse(mapNode, arguments, &viewer, root, new LabelControl("Features Demo"));
if (useStencil)
{
FeatureStencilModelOptions stencilOptions;
stencilOptions.featureOptions() = featureOptions;
stencilOptions.styles() = new StyleSheet();
stencilOptions.styles()->addStyle( style );
stencilOptions.enableLighting() = false;
stencilOptions.depthTestEnabled() = false;
ls->stroke()->width() = 0.1f;
map->addModelLayer( new ModelLayer("my features", stencilOptions) );
}
else if (useRaster)
{
AGGLiteOptions rasterOptions;
rasterOptions.featureOptions() = featureOptions;
rasterOptions.styles() = new StyleSheet();
rasterOptions.styles()->addStyle( style );
map->addImageLayer( new ImageLayer("my features", rasterOptions) );
}
else //if (useGeom || useOverlay)
{
FeatureGeomModelOptions geomOptions;
geomOptions.featureOptions() = featureOptions;
geomOptions.styles() = new StyleSheet();
geomOptions.styles()->addStyle( style );
geomOptions.enableLighting() = false;
ModelLayerOptions layerOptions( "my features", geomOptions );
map->addModelLayer( new ModelLayer(layerOptions) );
}
if ( useLabels )
{
// set up symbology for drawing labels. We're pulling the label
// text from the name attribute, and its draw priority from the
// population attribute.
Style labelStyle;
TextSymbol* text = labelStyle.getOrCreateSymbol<TextSymbol>();
text->content() = StringExpression( "[cntry_name]" );
text->priority() = NumericExpression( "[pop_cntry]" );
text->removeDuplicateLabels() = true;
text->size() = 16.0f;
text->alignment() = TextSymbol::ALIGN_CENTER_CENTER;
text->fill()->color() = Color::White;
text->halo()->color() = Color::DarkGray;
// and configure a model layer:
FeatureGeomModelOptions geomOptions;
geomOptions.featureOptions() = featureOptions;
geomOptions.styles() = new StyleSheet();
geomOptions.styles()->addStyle( labelStyle );
map->addModelLayer( new ModelLayer("labels", geomOptions) );
}
if ( !useStencil )
viewer.getCamera()->addCullCallback( new osgEarth::Util::AutoClipPlaneCullCallback(mapNode) );
// add some stock OSG handlers:
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
return viewer.run();
}
示例8: main
//
// NOTE: run this sample from the repo/tests directory.
//
int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
bool useRaster = arguments.read("--rasterize");
bool useOverlay = arguments.read("--overlay");
bool useStencil = arguments.read("--stencil");
bool useMem = arguments.read("--mem");
bool useLabels = arguments.read("--labels");
osgViewer::Viewer viewer(arguments);
// Start by creating the map:
Map* map = new Map();
// Start with a basemap imagery layer; we'll be using the GDAL driver
// to load a local GeoTIFF file:
GDALOptions basemapOpt;
basemapOpt.url() = "../data/world.tif";
map->addImageLayer( new ImageLayer( ImageLayerOptions("basemap", basemapOpt) ) );
// Next we add a feature layer. First configure a feature driver to
// load the vectors from a shapefile:
OGRFeatureOptions featureOpt;
if ( !useMem )
{
featureOpt.url() = "../data/usa.shp";
}
else
{
Ring* line = new Ring();
line->push_back( osg::Vec3d(-60, 20, 0) );
line->push_back( osg::Vec3d(-120, 20, 0) );
line->push_back( osg::Vec3d(-120, 60, 0) );
line->push_back( osg::Vec3d(-60, 60, 0) );
featureOpt.geometry() = line;
}
// Define a style for the feature data. Since we are going to render the
// vectors as lines, configure the line symbolizer:
Style style;
LineSymbol* ls = style.getOrCreateSymbol<LineSymbol>();
ls->stroke()->color() = osg::Vec4f( 1,1,0,1 ); // yellow
ls->stroke()->width() = 2.0f;
// Add some text labels.
if ( useLabels )
{
TextSymbol* text = style.getOrCreateSymbol<TextSymbol>();
text->provider() = "overlay";
text->content() = StringExpression( "[name]" );
text->priority() = NumericExpression( "[area]" );
text->removeDuplicateLabels() = true;
text->size() = 16.0f;
text->fill()->color() = Color::White;
text->halo()->color() = Color::DarkGray;
}
// That's it, the map is ready; now create a MapNode to render the Map:
MapNodeOptions mapNodeOptions;
mapNodeOptions.enableLighting() = false;
MapNode* mapNode = new MapNode( map, mapNodeOptions );
// Now we'll choose the AGG-Lite driver to render the features. By the way, the
// feature data is actually polygons, so we override that to treat it as lines.
// We apply the feature driver and set the style as well.
if (useStencil)
{
FeatureStencilModelOptions worldOpt;
worldOpt.featureOptions() = featureOpt;
worldOpt.geometryTypeOverride() = Geometry::TYPE_LINESTRING;
worldOpt.styles() = new StyleSheet();
worldOpt.styles()->addStyle( style );
worldOpt.enableLighting() = false;
worldOpt.depthTestEnabled() = false;
map->addModelLayer( new ModelLayer( "my features", worldOpt ) );
}
else if (useRaster)
{
AGGLiteOptions worldOpt;
worldOpt.featureOptions() = featureOpt;
worldOpt.geometryTypeOverride() = Geometry::TYPE_LINESTRING;
worldOpt.styles() = new StyleSheet();
worldOpt.styles()->addStyle( style );
map->addImageLayer( new ImageLayer( ImageLayerOptions("world", worldOpt) ) );
}
else //if (useGeom || useOverlay)
{
FeatureGeomModelOptions worldOpt;
worldOpt.featureOptions() = featureOpt;
worldOpt.geometryTypeOverride() = Geometry::TYPE_LINESTRING;
worldOpt.styles() = new StyleSheet();
worldOpt.styles()->addStyle( style );
worldOpt.enableLighting() = false;
worldOpt.depthTestEnabled() = false;
//.........这里部分代码省略.........
示例9: cellExtent
void
UTMGraticule::rebuild()
{
// clear everything out
this->removeChildren( 0, this->getNumChildren() );
// requires a map node
if ( !getMapNode() )
{
return;
}
// requires a geocentric map
if ( !getMapNode()->isGeocentric() )
{
OE_WARN << LC << "Projected map mode is not yet supported" << std::endl;
return;
}
const Profile* mapProfile = getMapNode()->getMap()->getProfile();
_profile = Profile::create(
mapProfile->getSRS(),
mapProfile->getExtent().xMin(),
mapProfile->getExtent().yMin(),
mapProfile->getExtent().xMax(),
mapProfile->getExtent().yMax(),
8, 4 );
_featureProfile = new FeatureProfile(_profile->getSRS());
//todo: do this right..
osg::StateSet* set = this->getOrCreateStateSet();
set->setMode( GL_LIGHTING, 0 );
set->setMode( GL_BLEND, 1 );
// set up default options if the caller did not supply them
if ( !_options.isSet() )
{
_options->primaryStyle() = Style();
LineSymbol* line = _options->primaryStyle()->getOrCreate<LineSymbol>();
line->stroke()->color() = Color::Gray;
line->stroke()->width() = 1.0;
line->tessellation() = 20;
AltitudeSymbol* alt = _options->primaryStyle()->getOrCreate<AltitudeSymbol>();
TextSymbol* text = _options->primaryStyle()->getOrCreate<TextSymbol>();
text->fill()->color() = Color(Color::White, 0.3f);
text->halo()->color() = Color(Color::Black, 0.2f);
text->alignment() = TextSymbol::ALIGN_CENTER_CENTER;
}
// rebuild the graph:
_root = new DrapeableNode( getMapNode(), false );
this->addChild( _root );
#if 0
// set up depth offsetting.
osg::StateSet* s = _root->getOrCreateStateSet();
s->setAttributeAndModes( DepthOffsetUtils::getOrCreateProgram(), 1 );
s->addUniform( DepthOffsetUtils::getIsNotTextUniform() );
osg::Uniform* u = DepthOffsetUtils::createMinOffsetUniform();
u->set( 10000.0f );
s->addUniform( u );
#endif
// build the base Grid Zone Designator (GZD) loolup table. This is a table
// that maps the GZD string to its extent.
static std::string s_gzdRows( "CDEFGHJKLMNPQRSTUVWX" );
const SpatialReference* geosrs = _profile->getSRS()->getGeographicSRS();
// build the lateral zones:
for( unsigned zone = 0; zone < 60; ++zone )
{
for( unsigned row = 0; row < s_gzdRows.size(); ++row )
{
double yMaxExtra = row == s_gzdRows.size()-1 ? 4.0 : 0.0; // extra 4 deg for row X
GeoExtent cellExtent(
geosrs,
-180.0 + double(zone)*6.0,
-80.0 + row*8.0,
-180.0 + double(zone+1)*6.0,
-80.0 + double(row+1)*8.0 + yMaxExtra );
_gzd[ Stringify() << (zone+1) << s_gzdRows[row] ] = cellExtent;
}
}
// the polar zones (UPS):
_gzd["1Y"] = GeoExtent( geosrs, -180.0, 84.0, 0.0, 90.0 );
_gzd["1Z"] = GeoExtent( geosrs, 0.0, 84.0, 180.0, 90.0 );
_gzd["1A"] = GeoExtent( geosrs, -180.0, -90.0, 0.0, -80.0 );
_gzd["1B"] = GeoExtent( geosrs, 0.0, -90.0, 180.0, -80.0 );
// replace the "exception" zones in Norway and Svalbard
_gzd["31V"] = GeoExtent( geosrs, 0.0, 56.0, 3.0, 64.0 );
//.........这里部分代码省略.........