本文整理汇总了C++中osg::ref_ptr::insertFeature方法的典型用法代码示例。如果您正苦于以下问题:C++ ref_ptr::insertFeature方法的具体用法?C++ ref_ptr::insertFeature怎么用?C++ ref_ptr::insertFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::ref_ptr
的用法示例。
在下文中一共展示了ref_ptr::insertFeature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//
// NOTE: run this sample from the repo/tests directory.
//
int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
osgViewer::Viewer viewer(arguments);
s_viewer = &viewer;
// Start by creating the map:
s_mapNode = MapNode::load(arguments);
if ( !s_mapNode )
{
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) ) );
// That's it, the map is ready; now create a MapNode to render the Map:
MapNodeOptions mapNodeOptions;
mapNodeOptions.enableLighting() = false;
s_mapNode = new MapNode( map, mapNodeOptions );
}
s_mapNode->setNodeMask( 0x01 );
// Define a style for the feature data. Since we are going to render the
// vectors as lines, configure the line symbolizer:
StyleSheet* styleSheet = buildStyleSheet( Color::Yellow, 2.0f );
s_source = new FeatureListSource();
LineString* line = new LineString();
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) );
Feature *feature = new Feature(line, s_mapNode->getMapSRS(), Style(), s_fid++);
s_source->insertFeature( feature );
s_activeFeature = feature;
s_root = new osg::Group;
s_root->addChild( s_mapNode.get() );
Session* session = new Session(s_mapNode->getMap(), styleSheet, s_source.get());
FeatureModelGraph* graph = new FeatureModelGraph(
session,
FeatureModelSourceOptions(),
new GeomFeatureNodeFactory() );
graph->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
graph->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
s_root->addChild( graph );
//Setup the controls
ControlCanvas* canvas = ControlCanvas::get( &viewer );
s_root->addChild( canvas );
Grid *toolbar = createToolBar( );
canvas->addControl( toolbar );
canvas->setNodeMask( 0x1 << 1 );
int col = 0;
LabelControl* addVerts = new LabelControl("Add Verts");
toolbar->setControl(col++, 0, addVerts );
addVerts->addEventHandler( new AddVertsModeHandler( graph ));
LabelControl* edit = new LabelControl("Edit");
toolbar->setControl(col++, 0, edit );
edit->addEventHandler(new EditModeHandler( graph ));
unsigned int row = 0;
Grid *styleBar = createToolBar( );
styleBar->setPosition(0, 50);
canvas->addControl( styleBar );
//Make a list of styles
styleBar->setControl(0, row++, new LabelControl("Styles") );
unsigned int numStyles = 8;
for (unsigned int i = 0; i < numStyles; ++i)
{
float w = 50;
osg::Vec4 color = randomColor();
float widths[3] = {2, 4, 8};
unsigned int r = row++;
for (unsigned int j = 0; j < 3; j++)
{
Control* l = new Control();
l->setBackColor( color );
//.........这里部分代码省略.........