本文整理汇总了C++中LayerVector类的典型用法代码示例。如果您正苦于以下问题:C++ LayerVector类的具体用法?C++ LayerVector怎么用?C++ LayerVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LayerVector类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc,argv);
osgViewer::Viewer viewer(arguments);
viewer.setCameraManipulator( new EarthManipulator(arguments) );
osg::Node* node = MapNodeHelper().load(arguments, &viewer);
if ( node )
{
MapNode* mapNode = MapNode::get(node);
if (!mapNode)
return -1;
MyCallback* myCallback = new MyCallback();
// Install a callback on each loaded layer.
LayerVector layers;
mapNode->getMap()->getLayers(layers);
for (LayerVector::iterator layer = layers.begin(); layer != layers.end(); ++layer)
{
layer->get()->getSceneGraphCallbacks()->add( myCallback );
}
viewer.setSceneData( node );
return viewer.run();
}
else
{
return usage(argv[0]);
}
return 0;
}
示例2:
void
ElevationQuery::reset()
{
// set read callback for IntersectionVisitor
_ivrc = new osgSim::DatabaseCacheReadCallback();
_terrainModelLayers.clear();
_elevationLayers.clear();
osg::ref_ptr<const Map> map;
if (_map.lock(map))
{
map->getLayers(_elevationLayers);
// cache a vector of terrain patch models.
LayerVector layers;
map->getLayers(layers);
for (LayerVector::const_iterator i = layers.begin(); i != layers.end(); ++i)
{
if (i->get()->options().terrainPatch() == true)
{
_terrainModelLayers.push_back(i->get());
}
}
// revisions are now in sync.
_mapRevision = map->getDataModelRevision();
}
// clear any active envelope
_envelope = 0L;
}
示例3: mapConf
Config
EarthFileSerializer2::serialize(const MapNode* input, const std::string& referrer) const
{
Config mapConf("map");
mapConf.set("version", "2");
if ( !input || !input->getMap() )
return mapConf;
const Map* map = input->getMap();
MapFrame mapf( map );
// the map and node options:
Config optionsConf = map->getInitialMapOptions().getConfig();
optionsConf.merge( input->getMapNodeOptions().getConfig() );
mapConf.add( "options", optionsConf );
// the layers
LayerVector layers;
mapf.getLayers(layers);
for (LayerVector::const_iterator i = layers.begin(); i != layers.end(); ++i)
{
const Layer* layer = i->get();
Config layerConf = layer->getConfig();
if (!layerConf.empty())
{
mapConf.add(layerConf);
}
}
typedef std::vector< osg::ref_ptr<Extension> > Extensions;
for(Extensions::const_iterator i = input->getExtensions().begin(); i != input->getExtensions().end(); ++i)
{
Extension* e = i->get();
Config conf = e->getConfigOptions().getConfig();
if ( !conf.key().empty() )
{
mapConf.add( conf );
}
}
Config ext = input->externalConfig();
if ( !ext.empty() )
{
ext.key() = "external";
mapConf.add( ext );
}
// Re-write pathnames in the Config so they are relative to the new referrer.
if ( _rewritePaths && !referrer.empty() )
{
RewritePaths rewritePaths( referrer );
rewritePaths.setRewriteAbsolutePaths( _rewriteAbsolutePaths );
rewritePaths.apply( mapConf );
}
return mapConf;
}
示例4: editor
LayerVector* LayerManager::createVectorLayer( const QString& strLayerName )
{
LayerVector* layer = editor()->object()->addNewVectorLayer();
layer->setName( strLayerName );
Q_EMIT layerCountChanged( count() );
return layer;
}
示例5: onBeginUpdate
void
MapCallback::invokeOnLayerRemoved(const Map* map)
{
LayerVector layers;
map->getLayers(layers);
unsigned index = 0;
if (layers.size() > 0)
{
onBeginUpdate();
for (LayerVector::iterator i = layers.begin(); i != layers.end(); ++i)
onLayerRemoved(i->get(), index++);
onEndUpdate();
}
}
示例6: QRect
//void Object::paintImage(QPainter &painter, int frameNumber, const QRectF &source, const QRectF &target, bool background, qreal curveOpacity, bool antialiasing, bool niceGradients) {
void Object::paintImage(QPainter& painter, int frameNumber, bool background, qreal curveOpacity, bool antialiasing, int gradients)
{
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
//painter.setWorldMatrix(matrix);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
// paints the background
if (background)
{
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::white);
painter.setWorldMatrixEnabled(false);
painter.drawRect( QRect(0,0, painter.device()->width(), painter.device()->height() ) );
painter.setWorldMatrixEnabled(true);
}
for(int i=0; i < getLayerCount(); i++)
{
Layer* layer = getLayer(i);
if (layer->visible)
{
painter.setOpacity(1.0);
// paints the bitmap images
if (layer->type == Layer::BITMAP)
{
LayerBitmap* layerBitmap = (LayerBitmap*)layer;
/*BitmapImage* bitmapImage = layerBitmap->getLastBitmapImageAtFrame(frameNumber, 0);
// TO BE FIXED
if (bitmapImage != NULL) {
if ( mirror) {
painter.drawImage(target, (*(bitmapImage->image)).mirrored(true, false), source);
} else {
painter.drawImage(target, *(bitmapImage->image), source);
}
}*/
layerBitmap->getLastBitmapImageAtFrame(frameNumber, 0)->paintImage(painter);
}
// paints the vector images
if (layer->type == Layer::VECTOR)
{
LayerVector* layerVector = (LayerVector*)layer;
layerVector->getLastVectorImageAtFrame(frameNumber, 0)->paintImage(painter, false, false, curveOpacity, antialiasing, gradients);
}
}
}
}
示例7: assert
/**
* @brief MoveTool::createVectorSelection
* In vector the selection rectangle is based on the bounding box of the curves
* We can therefore create a selection just by clicking near/on a curve
*/
void MoveTool::createVectorSelection(Qt::KeyboardModifiers keyMod, Layer* layer)
{
assert(layer->type() == Layer::VECTOR);
LayerVector* vecLayer = static_cast<LayerVector*>(layer);
VectorImage* vectorImage = vecLayer->getLastVectorImageAtFrame(mEditor->currentFrame(), 0);
if (!mScribbleArea->mClosestCurves.empty()) // the user clicks near a curve
{
setCurveSelected(vectorImage, keyMod);
}
else if (vectorImage->getLastAreaNumber(getLastPoint()) > -1)
{
setAreaSelected(vectorImage, keyMod);
}
mScribbleArea->update();
}
示例8: QRect
void Object::paintImage( QPainter& painter, int frameNumber,
bool background,
bool antialiasing )
{
painter.setRenderHint( QPainter::Antialiasing, true );
painter.setRenderHint( QPainter::SmoothPixmapTransform, true );
//painter.setTransform(matrix);
painter.setCompositionMode( QPainter::CompositionMode_SourceOver );
// paints the background
if ( background )
{
painter.setPen( Qt::NoPen );
painter.setBrush( Qt::white );
painter.setWorldMatrixEnabled( false );
painter.drawRect( QRect( 0, 0, painter.device()->width(), painter.device()->height() ) );
painter.setWorldMatrixEnabled( true );
}
for ( int i = 0; i < getLayerCount(); i++ )
{
Layer* layer = getLayer( i );
if ( layer->visible )
{
painter.setOpacity( 1.0 );
// paints the bitmap images
if ( layer->type() == Layer::BITMAP )
{
LayerBitmap* layerBitmap = ( LayerBitmap* )layer;
layerBitmap->getLastBitmapImageAtFrame( frameNumber, 0 )->paintImage( painter );
}
// paints the vector images
if ( layer->type() == Layer::VECTOR )
{
LayerVector* layerVector = ( LayerVector* )layer;
layerVector->getLastVectorImageAtFrame( frameNumber, 0 )->paintImage( painter,
false,
false,
antialiasing );
}
}
}
}
示例9: getLayer
bool Object::removeColour(int index) {
for(int i=0; i< getLayerCount(); i++) {
Layer* layer = getLayer(i);
if( layer->type == Layer::VECTOR) {
LayerVector *layerVector = ((LayerVector*)layer);
if(layerVector->usesColour(index)) return false;
}
}
for(int i=0; i< getLayerCount(); i++) {
Layer* layer = getLayer(i);
if( layer->type == Layer::VECTOR) {
LayerVector *layerVector = ((LayerVector*)layer);
layerVector->removeColour(index);
}
}
myPalette.removeAt(index);
return true;
// update the vector pictures using that colour !
}
示例10: updateControlPanel
void
updateControlPanel()
{
// erase all child controls and just rebuild them b/c we're lazy.
//Rebuild all the image layers
s_activeBox->clearControls();
int row = 0;
LabelControl* activeLabel = new LabelControl( "Map Layers", 20, osg::Vec4f(1,1,0,1) );
s_activeBox->setControl( 1, row++, activeLabel );
// the active map layers:
LayerVector layers;
s_activeMap->getLayers(layers);
for (int i = layers.size()-1; i >= 0; --i)
{
Layer* layer = layers[i].get();
addLayerItem(s_activeBox, i, layers.size(), layer, true);
if (layer->getStatus().isError())
{
OE_WARN << layer->getName() << " : " << layer->getStatus().toString() << "\n";
}
}
// inactive layers:
s_inactiveBox->clearControls();
if (!_inactive.empty())
{
s_inactiveBox->setControl(0, row++, new LabelControl("Removed:", 18, osg::Vec4f(1,1,0,1)));
for (InactiveLayers::const_iterator i = _inactive.begin(); i != _inactive.end(); ++i)
{
createInactiveLayerItem(s_inactiveBox, row++, i->first, i->second);
}
}
s_inactiveBox->setVisible(!_inactive.empty());
}
示例11: OE_START_TIMER
void
TerrainTileModelFactory::addColorLayers(TerrainTileModel* model,
const Map* map,
const TerrainEngineRequirements* reqs,
const TileKey& key,
const CreateTileModelFilter& filter,
ProgressCallback* progress)
{
OE_START_TIMER(fetch_image_layers);
int order = 0;
LayerVector layers;
map->getLayers(layers);
for (LayerVector::const_iterator i = layers.begin(); i != layers.end(); ++i)
{
Layer* layer = i->get();
if (layer->getRenderType() != layer->RENDERTYPE_TERRAIN_SURFACE)
continue;
if (!layer->getEnabled())
continue;
if (!filter.accept(layer))
continue;
ImageLayer* imageLayer = dynamic_cast<ImageLayer*>(layer);
if (imageLayer)
{
osg::Texture* tex = 0L;
osg::Matrixf textureMatrix;
if (imageLayer->isKeyInLegalRange(key) && imageLayer->mayHaveDataInExtent(key.getExtent()))
{
if (imageLayer->createTextureSupported())
{
tex = imageLayer->createTexture( key, progress, textureMatrix );
}
else
{
GeoImage geoImage = imageLayer->createImage( key, progress );
if ( geoImage.valid() )
{
if ( imageLayer->isCoverage() )
tex = createCoverageTexture(geoImage.getImage(), imageLayer);
else
tex = createImageTexture(geoImage.getImage(), imageLayer);
}
}
}
// if this is the first LOD, and the engine requires that the first LOD
// be populated, make an empty texture if we didn't get one.
if (tex == 0L &&
_options.firstLOD() == key.getLOD() &&
reqs && reqs->fullDataAtFirstLodRequired())
{
tex = _emptyTexture.get();
}
if (tex)
{
tex->setName(model->getKey().str());
TerrainTileImageLayerModel* layerModel = new TerrainTileImageLayerModel();
layerModel->setImageLayer(imageLayer);
layerModel->setTexture(tex);
layerModel->setMatrix(new osg::RefMatrixf(textureMatrix));
model->colorLayers().push_back(layerModel);
if (imageLayer->isShared())
{
model->sharedLayers().push_back(layerModel);
}
if (imageLayer->isDynamic())
{
model->setRequiresUpdateTraverse(true);
}
}
}
else // non-image kind of TILE layer:
{
TerrainTileColorLayerModel* colorModel = new TerrainTileColorLayerModel();
colorModel->setLayer(layer);
model->colorLayers().push_back(colorModel);
}
}
if (progress)
progress->stats()["fetch_imagery_time"] += OE_STOP_TIMER(fetch_image_layers);
}
示例12: DrawState
void
TerrainRenderData::setup(const Map* map,
const RenderBindings& bindings,
unsigned frameNum,
osgUtil::CullVisitor* cv)
{
_bindings = &bindings;
// Create a new State object to track sampler and uniform settings
_drawState = new DrawState();
_drawState->_frame = frameNum;
_drawState->_bindings = &bindings;
// Is this a depth camera? Because if it is, we don't need any color layers.
const osg::Camera* cam = cv->getCurrentCamera();
bool isDepthCamera = ClampableNode::isDepthCamera(cam);
// Make a drawable for each rendering pass (i.e. each render-able map layer).
LayerVector layers;
map->getLayers(layers);
for (LayerVector::const_iterator i = layers.begin(); i != layers.end(); ++i)
{
Layer* layer = i->get();
if (layer->getEnabled())
{
bool render =
(layer->getRenderType() == Layer::RENDERTYPE_TERRAIN_SURFACE) || // && !isDepthCamera) ||
(layer->getRenderType() == Layer::RENDERTYPE_TERRAIN_PATCH);
if ( render )
{
// If this is an image layer, check the enabled/visible states.
VisibleLayer* visLayer = dynamic_cast<VisibleLayer*>(layer);
if (visLayer)
{
render = visLayer->getVisible();
}
if (render)
{
if (layer->getRenderType() == Layer::RENDERTYPE_TERRAIN_SURFACE)
{
LayerDrawable* ld = addLayerDrawable(layer);
// If the current camera is depth-only, leave this layer in the set
// but mark it as no-draw. We keep it in the set so the culler doesn't
// inadvertently think it's an orphaned layer.
if (isDepthCamera)
{
ld->_draw = false;
}
}
else // if (layer->getRenderType() == Layer::RENDERTYPE_TERRAIN_PATCH)
{
PatchLayer* patchLayer = static_cast<PatchLayer*>(layer); // asumption!
if (patchLayer->getAcceptCallback() != 0L &&
patchLayer->getAcceptCallback()->acceptLayer(*cv, cv->getCurrentCamera()))
{
patchLayers().push_back(dynamic_cast<PatchLayer*>(layer));
addLayerDrawable(layer);
}
}
}
}
}
}
// Include a "blank" layer for missing data.
LayerDrawable* blank = addLayerDrawable(0L);
}
示例13: paintVectorFrame
void CanvasRenderer::paintVectorFrame( QPainter& painter,
int layerId,
int nFrame,
bool colorize,
bool useLastKeyFrame )
{
Layer* layer = mObject->getLayer( layerId );
if ( !layer->visible() )
{
return;
}
LayerVector* vectorLayer = dynamic_cast< LayerVector* >( layer );
if ( vectorLayer == nullptr )
{
Q_ASSERT( vectorLayer );
return;
}
qCDebug( mLog ) << "Paint Onion skin vector, Frame = " << nFrame;
VectorImage* vectorImage;
if (useLastKeyFrame)
{
vectorImage = vectorLayer->getLastVectorImageAtFrame( nFrame, 0 );
}
else
{
vectorImage = vectorLayer->getVectorImageAtFrame( nFrame );
}
if ( vectorImage == nullptr )
{
return;
}
QImage* pImage = new QImage( mCanvas->size(), QImage::Format_ARGB32_Premultiplied );
vectorImage->outputImage( pImage, mViewTransform, mOptions.bOutlines, mOptions.bThinLines, mOptions.bAntiAlias );
//painter.drawImage( QPoint( 0, 0 ), *pImage );
// Go through a Bitmap image to paint the onion skin colour
//
BitmapImage* tempBitmapImage = new BitmapImage();
tempBitmapImage->setImage(pImage);
if ( colorize )
{
QBrush colorBrush = QBrush(Qt::transparent); //no color for the current frame
if (nFrame < mFrameNumber)
{
colorBrush = QBrush(Qt::red);
}
else if (nFrame > mFrameNumber)
{
colorBrush = QBrush(Qt::blue);
}
tempBitmapImage->drawRect( pImage->rect(),
Qt::NoPen,
colorBrush,
QPainter::CompositionMode_SourceIn,
false);
}
painter.setWorldMatrixEnabled( false ); //Don't tranform the image here as we used the viewTransform in the image output
tempBitmapImage->paintImage( painter );
delete tempBitmapImage;
}