本文整理汇总了C++中QgsVectorLayer::opacity方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsVectorLayer::opacity方法的具体用法?C++ QgsVectorLayer::opacity怎么用?C++ QgsVectorLayer::opacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QgsVectorLayer
的用法示例。
在下文中一共展示了QgsVectorLayer::opacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mLayer
QgsLayerTreeOpacityWidget::QgsLayerTreeOpacityWidget( QgsMapLayer *layer )
: mLayer( layer )
{
setAutoFillBackground( true ); // override the content from model
QLabel *l = new QLabel( QStringLiteral( "Opacity" ), this );
mSlider = new QSlider( Qt::Horizontal, this );
mSlider->setRange( 0, 1000 );
QHBoxLayout *lay = new QHBoxLayout();
lay->addWidget( l );
lay->addWidget( mSlider );
setLayout( lay );
// timer for delayed transparency update - for more responsive GUI
mTimer = new QTimer( this );
mTimer->setSingleShot( true );
mTimer->setInterval( 100 );
connect( mTimer, &QTimer::timeout, this, &QgsLayerTreeOpacityWidget::updateOpacityFromSlider );
connect( mSlider, &QAbstractSlider::valueChanged, this, &QgsLayerTreeOpacityWidget::sliderValueChanged );
// init from layer
if ( mLayer->type() == QgsMapLayer::VectorLayer )
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mLayer );
mSlider->setValue( vl->opacity() * 1000.0 );
connect( vl, &QgsVectorLayer::opacityChanged, this, &QgsLayerTreeOpacityWidget::layerTrChanged );
}
else if ( mLayer->type() == QgsMapLayer::RasterLayer )
{
mSlider->setValue( 1000 - qobject_cast<QgsRasterLayer *>( mLayer )->renderer()->opacity() * 1000 );
// TODO: there is no signal for raster layers
}
}
示例2: switch
QgsLayerRestorer::QgsLayerRestorer( const QList<QgsMapLayer *> &layers )
{
for ( QgsMapLayer *layer : layers )
{
QgsLayerSettings settings;
settings.name = layer->name();
QString style = layer->styleManager()->currentStyle();
settings.mNamedStyle = layer->styleManager()->currentStyle();
// set a custom property allowing to keep in memory if a SLD file has
// been loaded for rendering
layer->setCustomProperty( "readSLD", false );
QString errMsg;
QDomDocument sldDoc;
layer->exportSldStyle( sldDoc, errMsg );
( void )settings.mSldStyle.setContent( sldDoc.toString(), true ); // for namespace processing
switch ( layer->type() )
{
case QgsMapLayer::VectorLayer:
{
QgsVectorLayer *vLayer = qobject_cast<QgsVectorLayer *>( layer );
if ( vLayer )
{
settings.mOpacity = vLayer->opacity();
settings.mSelectedFeatureIds = vLayer->selectedFeatureIds();
settings.mFilter = vLayer->subsetString();
}
break;
}
case QgsMapLayer::LayerType::RasterLayer:
{
QgsRasterLayer *rLayer = qobject_cast<QgsRasterLayer *>( layer );
if ( rLayer )
{
settings.mOpacity = rLayer->renderer()->opacity();
}
break;
}
case QgsMapLayer::MeshLayer:
case QgsMapLayer::PluginLayer:
break;
}
mLayerSettings[layer] = settings;
}
}