本文整理汇总了C++中QgsVectorLayer::rendererV2方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsVectorLayer::rendererV2方法的具体用法?C++ QgsVectorLayer::rendererV2怎么用?C++ QgsVectorLayer::rendererV2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsVectorLayer
的用法示例。
在下文中一共展示了QgsVectorLayer::rendererV2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
QVariant QgsSymbolV2LegendNode::data( int role ) const
{
if ( role == Qt::DisplayRole )
{
return mLabel;
}
else if ( role == Qt::EditRole )
{
return mUserLabel.isEmpty() ? mItem.label() : mUserLabel;
}
else if ( role == Qt::DecorationRole )
{
QSize iconSize( 16, 16 ); // TODO: configurable
const int indentSize = 20;
if ( mPixmap.isNull() )
{
QPixmap pix;
if ( mItem.symbol() )
pix = QgsSymbolLayerV2Utils::symbolPreviewPixmap( mItem.symbol(), iconSize );
else
{
pix = QPixmap( iconSize );
pix.fill( Qt::transparent );
}
if ( mItem.level() == 0 )
mPixmap = pix;
else
{
// ident the symbol icon to make it look like a tree structure
QPixmap pix2( pix.width() + mItem.level() * indentSize, pix.height() );
pix2.fill( Qt::transparent );
QPainter p( &pix2 );
p.drawPixmap( mItem.level() * indentSize, 0, pix );
p.end();
mPixmap = pix2;
}
}
return mPixmap;
}
else if ( role == Qt::CheckStateRole )
{
if ( !mItem.isCheckable() )
return QVariant();
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( mLayerNode->layer() );
if ( !vlayer || !vlayer->rendererV2() )
return QVariant();
return vlayer->rendererV2()->legendSymbolItemChecked( mItem.ruleKey() ) ? Qt::Checked : Qt::Unchecked;
}
else if ( role == RuleKeyRole )
{
return mItem.ruleKey();
}
return QVariant();
}
示例2:
void QgsSymbolV2LegendNode::checkAll( bool state )
{
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( mLayerNode->layer() );
if ( !vlayer || !vlayer->rendererV2() )
return;
QgsLegendSymbolListV2 symbolList = vlayer->rendererV2()->legendSymbolItemsV2();
Q_FOREACH ( const QgsLegendSymbolItemV2& item, symbolList )
{
vlayer->rendererV2()->checkLegendSymbolItem( item.ruleKey(), state );
}
示例3: dataChanged
void QgsSymbolV2LegendNode::setSymbol( QgsSymbolV2* symbol )
{
if ( !symbol )
return;
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( mLayerNode->layer() );
if ( !vlayer || !vlayer->rendererV2() )
return;
mItem.setSymbol( symbol );
vlayer->rendererV2()->setLegendSymbolItem( mItem.ruleKey(), symbol->clone() );
mPixmap = QPixmap();
emit dataChanged();
vlayer->triggerRepaint();
}
示例4: if
void QgsLegendModel::updateSymbolV2ItemText( QStandardItem* symbolItem )
{
QgsComposerSymbolV2Item* sv2Item = dynamic_cast<QgsComposerSymbolV2Item*>( symbolItem );
if ( !sv2Item ) return;
QgsComposerLayerItem* lItem = dynamic_cast<QgsComposerLayerItem*>( sv2Item->parent() );
if ( !lItem ) return;
QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance()->mapLayer( lItem->layerID() );
if ( !mapLayer ) return;
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
if ( !vLayer ) return;
QgsFeatureRendererV2* renderer = vLayer->rendererV2();
if ( !renderer ) return;
if ( lItem->showFeatureCount() ) vLayer->countSymbolFeatures();
QgsLegendSymbolList symbolList = renderer->legendSymbolItems();
QPair<QString, QgsSymbolV2*> symbol = symbolList.value( symbolItem->row() );
QString label = sv2Item->userText().isEmpty() ? symbol.first : sv2Item->userText();
if ( renderer->type() == "singleSymbol" )
{
if ( !sv2Item->userText().isEmpty() )
{
label = sv2Item->userText();
}
else if ( !lItem->userText().isEmpty() )
{
label = lItem->userText();
}
else if ( !vLayer->title().isEmpty() )
{
label = vLayer->title();
}
else
{
label = vLayer->name();
}
}
if ( lItem->showFeatureCount() )
{
// Add counts to multi symbols layers only or labeled single symbols,
// so that single symbol layers are still drawn on single line
if ( symbolList.size() > 1 || !label.isEmpty() )
{
label += QString( " [%1]" ).arg( vLayer->featureCount( symbol.second ) );
}
}
symbolItem->setText( label );
}
示例5: dataChanged
bool QgsSymbolV2LegendNode::setData( const QVariant& value, int role )
{
if ( role != Qt::CheckStateRole )
return false;
if ( !mItem.isCheckable() )
return false;
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( mLayerNode->layer() );
if ( !vlayer || !vlayer->rendererV2() )
return false;
vlayer->rendererV2()->checkLegendSymbolItem( mItem.ruleKey(), value == Qt::Checked );
emit dataChanged();
vlayer->triggerRepaint();
return true;
}
示例6: needTemporaryImage
bool QgsMapRendererJob::needTemporaryImage( QgsMapLayer* ml )
{
if ( ml->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( ml );
if ( vl->rendererV2() && vl->rendererV2()->forceRasterRender() )
{
//raster rendering is forced for this layer
return true;
}
if ( mSettings.testFlag( QgsMapSettings::UseAdvancedEffects ) &&
(( vl->blendMode() != QPainter::CompositionMode_SourceOver )
|| ( vl->featureBlendMode() != QPainter::CompositionMode_SourceOver )
|| ( vl->layerTransparency() != 0 ) ) )
{
//layer properties require rasterisation
return true;
}
}
return false;
}
示例7: qMakePair
QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > QgsDxfExport::symbolLayers()
{
QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > symbolLayers;
QList< QgsMapLayer* >::iterator lIt = mLayers.begin();
for ( ; lIt != mLayers.end(); ++lIt )
{
//cast to vector layer
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( *lIt );
if ( !vl )
{
continue;
}
//get rendererv2
QgsFeatureRendererV2* r = vl->rendererV2();
if ( !r )
{
continue;
}
//get all symbols
QgsSymbolV2List symbols = r->symbols();
QgsSymbolV2List::iterator symbolIt = symbols.begin();
for ( ; symbolIt != symbols.end(); ++symbolIt )
{
int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
if ( mSymbologyExport != SymbolLayerSymbology )
{
maxSymbolLayers = 1;
}
for ( int i = 0; i < maxSymbolLayers; ++i )
{
symbolLayers.append( qMakePair(( *symbolIt )->symbolLayer( i ), *symbolIt ) ) ;
}
}
}
return symbolLayers;
}
示例8: setDefaultStyle
void QgsComposerLayerItem::setDefaultStyle( double scaleDenominator, const QString& rule )
{
// set default style according to number of symbols
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerID() ) );
if ( vLayer )
{
QgsFeatureRendererV2* renderer = vLayer->rendererV2();
if ( renderer )
{
QPair<QString, QgsSymbolV2*> symbolItem = renderer->legendSymbolItems( scaleDenominator, rule ).value( 0 );
if ( renderer->legendSymbolItems( scaleDenominator, rule ).size() > 1 || !symbolItem.first.isEmpty() )
{
setStyle( QgsComposerLegendStyle::Subgroup );
}
else
{
// Hide title by default for single symbol
setStyle( QgsComposerLegendStyle::Hidden );
}
}
}
}
示例9: run
void QgsMapHitTest::run()
{
// TODO: do we need this temp image?
QImage tmpImage( mSettings.outputSize(), mSettings.outputImageFormat() );
tmpImage.setDotsPerMeterX( mSettings.outputDpi() * 25.4 );
tmpImage.setDotsPerMeterY( mSettings.outputDpi() * 25.4 );
QPainter painter( &tmpImage );
QgsRenderContext context = QgsRenderContext::fromMapSettings( mSettings );
context.setPainter( &painter ); // we are not going to draw anything, but we still need a working painter
Q_FOREACH ( const QString& layerID, mSettings.layers() )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerID ) );
if ( !vl || !vl->rendererV2() )
continue;
if ( vl->hasScaleBasedVisibility() && ( mSettings.scale() < vl->minimumScale() || mSettings.scale() > vl->maximumScale() ) )
{
mHitTest[vl] = SymbolV2Set(); // no symbols -> will not be shown
continue;
}
if ( mSettings.hasCrsTransformEnabled() )
{
context.setCoordinateTransform( mSettings.layerTransform( vl ) );
context.setExtent( mSettings.outputExtentToLayerExtent( vl, mSettings.visibleExtent() ) );
}
context.expressionContext() << QgsExpressionContextUtils::layerScope( vl );
SymbolV2Set& usedSymbols = mHitTest[vl];
runHitTestLayer( vl, usedSymbols, context );
}
painter.end();
}
示例10: if
QVariant QgsSymbolV2LegendNode::data( int role ) const
{
if ( role == Qt::DisplayRole )
{
return mLabel;
}
else if ( role == Qt::EditRole )
{
return mUserLabel.isEmpty() ? mItem.label() : mUserLabel;
}
else if ( role == Qt::DecorationRole )
{
if ( mPixmap.isNull() || mPixmap.size() != mIconSize )
{
QPixmap pix;
if ( mItem.symbol() )
{
QScopedPointer<QgsRenderContext> context( createTemporaryRenderContext() );
pix = QgsSymbolLayerV2Utils::symbolPreviewPixmap( mItem.symbol(), mIconSize, context.data() );
}
else
{
pix = QPixmap( mIconSize );
pix.fill( Qt::transparent );
}
if ( mItem.level() == 0 || ( model() && model()->testFlag( QgsLayerTreeModel::ShowLegendAsTree ) ) )
mPixmap = pix;
else
{
// ident the symbol icon to make it look like a tree structure
QPixmap pix2( pix.width() + mItem.level() * indentSize, pix.height() );
pix2.fill( Qt::transparent );
QPainter p( &pix2 );
p.drawPixmap( mItem.level() * indentSize, 0, pix );
p.end();
mPixmap = pix2;
}
}
return mPixmap;
}
else if ( role == Qt::CheckStateRole )
{
if ( !mItem.isCheckable() )
return QVariant();
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( mLayerNode->layer() );
if ( !vlayer || !vlayer->rendererV2() )
return QVariant();
return vlayer->rendererV2()->legendSymbolItemChecked( mItem.ruleKey() ) ? Qt::Checked : Qt::Unchecked;
}
else if ( role == RuleKeyRole )
{
return mItem.ruleKey();
}
else if ( role == SymbolV2LegacyRuleKeyRole )
{
return QVariant::fromValue<void*>( mItem.legacyRuleKey() );
}
else if ( role == ParentRuleKeyRole )
{
return mItem.parentRuleKey();
}
return QVariant();
}
示例11: setSelectFeatures
void QgsMapToolSelectUtils::setSelectFeatures( QgsMapCanvas* canvas,
QgsGeometry* selectGeometry,
bool doContains,
bool doDifference,
bool singleSelect )
{
if ( selectGeometry->type() != QGis::Polygon )
{
return;
}
QgsVectorLayer* vlayer = QgsMapToolSelectUtils::getCurrentVectorLayer( canvas );
if ( vlayer == nullptr )
{
return;
}
// toLayerCoordinates will throw an exception for any 'invalid' points in
// the rubber band.
// For example, if you project a world map onto a globe using EPSG 2163
// and then click somewhere off the globe, an exception will be thrown.
//QgsGeometry selectGeomTrans( *selectGeometry );
//if ( canvas->mapSettings().hasCrsTransformEnabled() )
//{
// try
// {
// QgsCoordinateTransform ct( canvas->mapSettings().destinationCrs(), vlayer->crs() );
// selectGeomTrans.transform( ct );
// }
// catch ( QgsCsException &cse )
// {
// Q_UNUSED( cse );
// // catch exception for 'invalid' point and leave existing selection unchanged
// QgsLogger::warning( "Caught CRS exception " + QString( __FILE__ ) + ": " + QString::number( __LINE__ ) );
// LOG_INFO( "CRS Exception\nSelection extends beyond layer's coordinate system" );
// return;
// }
//}
QgsGeometry selectGeomTrans;
try{
selectGeomTrans = toLayerCoordinates( canvas, selectGeometry, vlayer );
}
catch ( QgsCsException & )
{
return;
}
QApplication::setOverrideCursor( Qt::WaitCursor );
QgsDebugMsg( "Selection layer: " + vlayer->name() );
QgsDebugMsg( "Selection polygon: " + selectGeomTrans.exportToWkt() );
QgsDebugMsg( "doContains: " + QString( doContains ? "T" : "F" ) );
QgsDebugMsg( "doDifference: " + QString( doDifference ? "T" : "F" ) );
QgsRenderContext context = QgsRenderContext::fromMapSettings( canvas->mapSettings() );
QgsFeatureRendererV2* r = vlayer->rendererV2();
if ( r )
r->startRender( context, vlayer->pendingFields() );
QgsFeatureRequest request;
request.setFilterRect( selectGeomTrans.boundingBox() );
request.setFlags( QgsFeatureRequest::ExactIntersect );
if ( r )
request.setSubsetOfAttributes( r->usedAttributes(), vlayer->pendingFields() );
else
request.setSubsetOfAttributes( QgsAttributeList() );
QgsFeatureIterator fit = vlayer->getFeatures( request );
QgsFeatureIds newSelectedFeatures;
QgsFeature f;
QgsFeatureId closestFeatureId = 0;
bool foundSingleFeature = false;
double closestFeatureDist = std::numeric_limits<double>::max();
while ( fit.nextFeature( f ) )
{
#if (VERSION_INT >= 21601)
context.expressionContext().setFeature( f ); //taken from QGIS 2.16.1
// make sure to only use features that are visible
if ( r && !r->willRenderFeature( f, context ) )
#else
if ( r && !r->willRenderFeature( f ) )
#endif
continue;
QgsGeometry* g = f.geometry();
if ( doContains )
{
if ( !selectGeomTrans.contains( g ) )
continue;
}
else
{
if ( !selectGeomTrans.intersects( g ) )
continue;
}
if ( singleSelect )
{
foundSingleFeature = true;
double distance = g->distance( selectGeomTrans );
//.........这里部分代码省略.........
示例12: createContextMenu
//.........这里部分代码省略.........
menu->addAction( tr( "Save As Layer Definition File..." ), QgisApp::instance(), SLOT( saveAsLayerDefinition() ) );
menu->addAction( actions->actionAddGroup( menu ) );
}
else if ( QgsLayerTree::isLayer( node ) )
{
QgsMapLayer *layer = QgsLayerTree::toLayer( node )->layer();
QgsRasterLayer *rlayer = qobject_cast<QgsRasterLayer *>( layer );
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( layer );
menu->addAction( actions->actionZoomToLayer( mCanvas, menu ) );
menu->addAction( actions->actionShowInOverview( menu ) );
if ( rlayer )
{
menu->addAction( QgsApplication::getThemeIcon( "/mActionZoomActual.svg" ), tr( "&Zoom to Native Resolution (100%)" ), QgisApp::instance(), SLOT( legendLayerZoomNative() ) );
if ( rlayer->rasterType() != QgsRasterLayer::Palette )
menu->addAction( tr( "&Stretch Using Current Extent" ), QgisApp::instance(), SLOT( legendLayerStretchUsingCurrentExtent() ) );
}
menu->addAction( QgsApplication::getThemeIcon( "/mActionRemoveLayer.svg" ), tr( "&Remove" ), QgisApp::instance(), SLOT( removeLayer() ) );
// duplicate layer
QAction* duplicateLayersAction = menu->addAction( QgsApplication::getThemeIcon( "/mActionDuplicateLayer.svg" ), tr( "&Duplicate" ), QgisApp::instance(), SLOT( duplicateLayers() ) );
if ( layer && layer->isSpatial() )
{
// set layer scale visibility
menu->addAction( tr( "&Set Layer Scale Visibility" ), QgisApp::instance(), SLOT( setLayerScaleVisibility() ) );
if ( !layer->isInScaleRange( mCanvas->scale() ) )
menu->addAction( tr( "Zoom to &Visible Scale" ), QgisApp::instance(), SLOT( zoomToLayerScale() ) );
// set layer crs
menu->addAction( QgsApplication::getThemeIcon( "/mActionSetCRS.png" ), tr( "Set Layer CRS" ), QgisApp::instance(), SLOT( setLayerCRS() ) );
// assign layer crs to project
menu->addAction( QgsApplication::getThemeIcon( "/mActionSetProjectCRS.png" ), tr( "Set &Project CRS from Layer" ), QgisApp::instance(), SLOT( setProjectCRSFromLayer() ) );
}
// style-related actions
if ( layer && mView->selectedLayerNodes().count() == 1 )
{
QMenu *menuStyleManager = new QMenu( tr( "Styles" ), menu );
QgisApp *app = QgisApp::instance();
menuStyleManager->addAction( tr( "Copy Style" ), app, SLOT( copyStyle() ) );
if ( app->clipboard()->hasFormat( QGSCLIPBOARD_STYLE_MIME ) )
{
menuStyleManager->addAction( tr( "Paste Style" ), app, SLOT( pasteStyle() ) );
}
menuStyleManager->addSeparator();
QgsMapLayerStyleGuiUtils::instance()->addStyleManagerActions( menuStyleManager, layer );
if ( vlayer )
{
const QgsSingleSymbolRendererV2* singleRenderer = dynamic_cast< const QgsSingleSymbolRendererV2* >( vlayer->rendererV2() );
if ( !singleRenderer && vlayer->rendererV2()->embeddedRenderer() )
{
singleRenderer = dynamic_cast< const QgsSingleSymbolRendererV2* >( vlayer->rendererV2()->embeddedRenderer() );
}
if ( singleRenderer && singleRenderer->symbol() )
{
//single symbol renderer, so add set color/edit symbol actions
menuStyleManager->addSeparator();
QgsColorWheel* colorWheel = new QgsColorWheel( menuStyleManager );
colorWheel->setColor( singleRenderer->symbol()->color() );
QgsColorWidgetAction* colorAction = new QgsColorWidgetAction( colorWheel, menuStyleManager, menuStyleManager );
colorAction->setDismissOnColorSelection( false );
connect( colorAction, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setVectorSymbolColor( const QColor& ) ) );
//store the layer id in action, so we can later retrieve the corresponding layer
colorAction->setProperty( "layerId", vlayer->id() );
menuStyleManager->addAction( colorAction );
//add recent colors action
QList<QgsRecentColorScheme *> recentSchemes;
QgsColorSchemeRegistry::instance()->schemes( recentSchemes );
if ( !recentSchemes.isEmpty() )
{
QgsColorSwatchGridAction* recentColorAction = new QgsColorSwatchGridAction( recentSchemes.at( 0 ), menuStyleManager, "symbology", menuStyleManager );
recentColorAction->setProperty( "layerId", vlayer->id() );
recentColorAction->setDismissOnColorSelection( false );
menuStyleManager->addAction( recentColorAction );
connect( recentColorAction, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setVectorSymbolColor( const QColor& ) ) );
}
menuStyleManager->addSeparator();
QAction* editSymbolAction = new QAction( tr( "Edit Symbol..." ), menuStyleManager );
//store the layer id in action, so we can later retrieve the corresponding layer
editSymbolAction->setProperty( "layerId", vlayer->id() );
connect( editSymbolAction, SIGNAL( triggered() ), this, SLOT( editVectorSymbol() ) );
menuStyleManager->addAction( editSymbolAction );
}
}
menu->addMenu( menuStyleManager );
}
示例13: apply
void QgsMapStylingWidget::apply()
{
if ( mStackedWidget->currentIndex() == mVectorPage )
{
QString undoName = "Style Change";
int currentPage = mMapStyleTabs->currentIndex();
if ( currentPage == mLabelTabIndex )
{
mLabelingWidget->apply();
emit styleChanged( mCurrentLayer );
undoName = "Label Change";
}
else if ( currentPage == mStyleTabIndex )
{
mVectorStyleWidget->apply();
QgsProject::instance()->setDirty( true );
mMapCanvas->clearCache();
mMapCanvas->refresh();
emit styleChanged( mCurrentLayer );
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( mCurrentLayer );
QgsRendererV2AbstractMetadata* m = QgsRendererV2Registry::instance()->rendererMetadata( layer->rendererV2()->type() );
undoName = QString( "Style Change - %1" ).arg( m->visibleName() );
}
QString errorMsg;
QDomDocument doc( "style" );
QDomElement rootNode = doc.createElement( "qgis" );
doc.appendChild( rootNode );
mCurrentLayer->writeStyle( rootNode, doc, errorMsg );
mCurrentLayer->undoStackStyles()->beginMacro( undoName );
mCurrentLayer->undoStackStyles()->push( new QgsMapLayerStyleCommand( mCurrentLayer, rootNode, mLastStyleXml ) );
mCurrentLayer->undoStackStyles()->endMacro();
// Override the last style on the stack
mLastStyleXml = rootNode.cloneNode();
}
}
示例14: writeEntities
void QgsDxfExport::writeEntities()
{
startSection();
writeGroup( 2, "ENTITIES" );
//label engine
QgsDxfPalLabeling labelEngine( this, mExtent.isEmpty() ? dxfExtent() : mExtent, mSymbologyScaleDenominator, mMapUnits );
QgsRenderContext& ctx = labelEngine.renderContext();
//iterate through the maplayers
QList< QgsMapLayer* >::iterator layerIt = mLayers.begin();
for ( ; layerIt != mLayers.end(); ++layerIt )
{
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( *layerIt );
if ( !vl || !layerIsScaleBasedVisible( vl ) )
{
continue;
}
QgsSymbolV2RenderContext sctx( ctx, QgsSymbolV2::MM , 1.0, false, 0, 0 );
QgsFeatureRendererV2* renderer = vl->rendererV2();
renderer->startRender( ctx, vl->pendingFields() );
QStringList attributes = renderer->usedAttributes();
bool labelLayer = ( labelEngine.prepareLayer( vl, attributes, ctx ) != 0 );
if ( mSymbologyExport == QgsDxfExport::SymbolLayerSymbology && ( renderer->capabilities() & QgsFeatureRendererV2::SymbolLevels ) &&
renderer->usingSymbolLevels() )
{
writeEntitiesSymbolLevels( vl );
renderer->stopRender( ctx );
continue;
}
QgsFeatureRequest freq = QgsFeatureRequest().setSubsetOfAttributes(
attributes, vl->pendingFields() );
if ( !mExtent.isEmpty() )
{
freq.setFilterRect( mExtent );
}
QgsFeatureIterator featureIt = vl->getFeatures( freq );
QgsFeature fet;
while ( featureIt.nextFeature( fet ) )
{
sctx.setFeature( &fet );
if ( mSymbologyExport == NoSymbology )
{
addFeature( sctx, dxfLayerName( vl->name() ), 0, 0 ); //no symbology at all
}
else
{
if ( !renderer )
{
continue;
}
QgsSymbolV2List symbolList = renderer->symbolsForFeature( fet );
if ( symbolList.size() < 1 )
{
continue;
}
if ( mSymbologyExport == QgsDxfExport::SymbolLayerSymbology ) //symbol layer symbology, but layer does not use symbol levels
{
QgsSymbolV2List::iterator symbolIt = symbolList.begin();
for ( ; symbolIt != symbolList.end(); ++symbolIt )
{
int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
for ( int i = 0; i < nSymbolLayers; ++i )
{
addFeature( sctx, dxfLayerName( vl->name() ), ( *symbolIt )->symbolLayer( i ), *symbolIt );
}
}
}
else
{
//take first symbollayer from first symbol
QgsSymbolV2* s = symbolList.first();
if ( !s || s->symbolLayerCount() < 1 )
{
continue;
}
addFeature( sctx, dxfLayerName( vl->name() ), s->symbolLayer( 0 ), s );
}
if ( labelLayer )
{
labelEngine.registerFeature( vl->id(), fet, ctx );
}
}
}
renderer->stopRender( ctx );
}
labelEngine.drawLabeling( ctx );
endSection();
}
示例15: apply
void QgsLayerStylingWidget::apply()
{
if ( !mCurrentLayer )
return;
disconnect( mCurrentLayer, SIGNAL( styleChanged() ), this, SLOT( updateCurrentWidgetLayer() ) );
QString undoName = "Style Change";
QWidget* current = mWidgetStack->mainWidget();
bool styleWasChanged = false;
if ( QgsLabelingWidget* widget = qobject_cast<QgsLabelingWidget*>( current ) )
{
widget->apply();
styleWasChanged = true;
undoName = "Label Change";
}
if ( QgsPanelWidgetWrapper* wrapper = qobject_cast<QgsPanelWidgetWrapper*>( current ) )
{
if ( QgsRendererV2PropertiesDialog* widget = qobject_cast<QgsRendererV2PropertiesDialog*>( wrapper->widget() ) )
{
widget->apply();
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( mCurrentLayer );
QgsRendererV2AbstractMetadata* m = QgsRendererV2Registry::instance()->rendererMetadata( layer->rendererV2()->type() );
undoName = QString( "Style Change - %1" ).arg( m->visibleName() );
styleWasChanged = true;
}
}
else if ( QgsRasterTransparencyWidget* widget = qobject_cast<QgsRasterTransparencyWidget*>( current ) )
{
widget->apply();
styleWasChanged = true;
}
else if ( qobject_cast<QgsRasterHistogramWidget*>( current ) )
{
mRasterStyleWidget->apply();
styleWasChanged = true;
}
else if ( QgsLayerStylingPanel* widget = qobject_cast<QgsLayerStylingPanel*>( current ) )
{
widget->apply();
styleWasChanged = true;
}
pushUndoItem( undoName );
if ( styleWasChanged )
{
emit styleChanged( mCurrentLayer );
QgsProject::instance()->setDirty( true );
mMapCanvas->clearCache();
mMapCanvas->refresh();
}
connect( mCurrentLayer, SIGNAL( styleChanged() ), this, SLOT( updateCurrentWidgetLayer() ) );
}