本文整理汇总了C++中ControlCanvas::setNodeMask方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlCanvas::setNodeMask方法的具体用法?C++ ControlCanvas::setNodeMask怎么用?C++ ControlCanvas::setNodeMask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlCanvas
的用法示例。
在下文中一共展示了ControlCanvas::setNodeMask方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: arguments
int
main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
osg::DisplaySettings::instance()->setMinimumNumStencilBits( 8 );
osgViewer::Viewer viewer(arguments);
// load the .earth file from the command line.
osg::Node* earthNode = MapNodeHelper().load( arguments, &viewer );
if (!earthNode)
{
OE_NOTICE << "Unable to load earth model." << std::endl;
return 1;
}
MapNode* mapNode = MapNode::findMapNode( earthNode );
if ( !mapNode )
{
OE_NOTICE << "Input file was not a .earth file" << std::endl;
return 1;
}
earthNode->setNodeMask( 0x1 );
osgEarth::Util::EarthManipulator* earthManip = new EarthManipulator();
viewer.setCameraManipulator( earthManip );
osg::Group* root = new osg::Group();
root->addChild( earthNode );
//Create the MeasureToolHandler
MeasureToolHandler* measureTool = new MeasureToolHandler(root, mapNode);
measureTool->setIntersectionMask( 0x1 );
viewer.addEventHandler( measureTool );
//Create some controls to interact with the measuretool
ControlCanvas* canvas = new ControlCanvas( &viewer );
root->addChild( canvas );
canvas->setNodeMask( 0x1 << 1 );
Grid* grid = new Grid();
grid->setBackColor(0,0,0,0.5);
grid->setMargin( 10 );
grid->setPadding( 10 );
grid->setChildSpacing( 10 );
grid->setChildVertAlign( Control::ALIGN_CENTER );
grid->setAbsorbEvents( true );
grid->setVertAlign( Control::ALIGN_BOTTOM );
canvas->addControl( grid );
//Add a label to display the distance
// Add a text label:
grid->setControl( 0, 0, new LabelControl("Distance:") );
LabelControl* label = new LabelControl();
label->setFont( osgEarth::Registry::instance()->getDefaultFont() );
label->setFontSize( 24.0f );
label->setHorizAlign( Control::ALIGN_LEFT );
label->setText("click to measure");
grid->setControl( 1, 0, label );
//Add a callback to update the label when the distance changes
measureTool->addEventHandler( new MyMeasureToolCallback(label) );
Style style = measureTool->getLineStyle();
style.getOrCreate<LineSymbol>()->stroke()->color() = Color::Red;
style.getOrCreate<LineSymbol>()->stroke()->width() = 4.0f;
measureTool->setLineStyle(style);
//Add a checkbox to control if we are doing path based measurement or just point to point
grid->setControl( 0, 1, new LabelControl("Path"));
CheckBoxControl* checkBox = new CheckBoxControl(false);
checkBox->setHorizAlign(Control::ALIGN_LEFT);
checkBox->addEventHandler( new TogglePathHandler(measureTool));
grid->setControl( 1, 1, checkBox);
//Add a toggle to set the mode of the measuring tool
grid->setControl( 0, 2, new LabelControl("Great Circle"));
CheckBoxControl* mode = new CheckBoxControl(true);
mode->setHorizAlign(Control::ALIGN_LEFT);
mode->addEventHandler( new ToggleModeHandler(measureTool));
grid->setControl( 1, 2, mode);
//Add a mouse coords readout:
LabelControl* mouseLabel = new LabelControl();
grid->setControl( 0, 3, new LabelControl("Mouse:"));
grid->setControl( 1, 3, mouseLabel );
viewer.addEventHandler(new MouseCoordsTool(mapNode, mouseLabel) );
viewer.setSceneData( root );
// add some stock OSG handlers:
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
viewer.addEventHandler(new osgViewer::ThreadingHandler());
viewer.addEventHandler(new osgViewer::LODScaleHandler());
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
//.........这里部分代码省略.........
示例2: 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 );
//.........这里部分代码省略.........
示例3: 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.
Style style = buildStyle( Color::Yellow, 2.0f );
//LineString* line = new LineString();
Geometry* geom = GeometryUtils::geometryFromWKT("POLYGON((191.026667 87.63333,114.75 78,89.5 77.333336,81.833336 75.333336,70.683334 74.5,70.916664 73.666664,68.666664 73.666664,66.291664 71.505,57.65 71.166664,58 73.9,48.616665 73,49.198334 71.43,49.5 70.5,43.266666 68.666664,32.083332 71.5,32.083332 74,35 74,35 81,32 81,32 90,191.026667 87.63333))");
OE_NOTICE << "Geometry " << GeometryUtils::geometryToWKT(geom) << std::endl;
Feature* feature = new Feature(geom, s_mapNode->getMapSRS(), Style(), s_fid++);
s_featureNode = new FeatureNode( s_mapNode, feature );
s_featureNode->setStyle( style );
s_editorsRoot = new osg::Group;
s_root = new osg::Group;
s_root->addChild( s_mapNode.get() );
s_root->addChild( s_featureNode.get() );
s_root->addChild( s_editorsRoot.get() );
//Setup the controls
ControlCanvas* canvas = ControlCanvas::getOrCreate( &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());
LabelControl* edit = new LabelControl("Edit");
toolbar->setControl(col++, 0, edit );
edit->addEventHandler(new EditModeHandler());
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 );
l->addEventHandler(new ChangeStyleHandler(buildStyle( color, widths[j] ) ));
l->setSize(w,5 * widths[j]);
styleBar->setControl(j, r, l);
}
}
viewer.setSceneData( s_root.get() );
viewer.setCameraManipulator( new EarthManipulator() );
if ( s_mapNode )
viewer.getCamera()->addCullCallback( new osgEarth::Util::AutoClipPlaneCullCallback(s_mapNode) );
// add some stock OSG handlers:
//.........这里部分代码省略.........