当前位置: 首页>>代码示例>>C++>>正文


C++ QgsVectorLayer::styleManager方法代码示例

本文整理汇总了C++中QgsVectorLayer::styleManager方法的典型用法代码示例。如果您正苦于以下问题:C++ QgsVectorLayer::styleManager方法的具体用法?C++ QgsVectorLayer::styleManager怎么用?C++ QgsVectorLayer::styleManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QgsVectorLayer的用法示例。


在下文中一共展示了QgsVectorLayer::styleManager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onEditingStarted

void QgsGrassPlugin::onEditingStarted()
{
  QgsDebugMsg( "Entered" );
  QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( sender() );
  if ( !vectorLayer )
    return;
  QgsDebugMsg( "started editing of layer " + vectorLayer->name() );

  // Set editing renderer
  QgsGrassProvider* grassProvider = dynamic_cast<QgsGrassProvider*>( vectorLayer->dataProvider() );
  if ( !grassProvider )
    return;

  QgsRendererV2Registry::instance()->addRenderer( new QgsRendererV2Metadata( "grassEdit",
      QObject::tr( "GRASS Edit" ),
      QgsGrassEditRenderer::create,
      QIcon(),
      QgsGrassEditRendererWidget::create ) );

  QgsGrassEditRenderer *renderer = new QgsGrassEditRenderer();

  mOldStyles[vectorLayer] = vectorLayer->styleManager()->currentStyle();

  // Because the edit style may be stored to project:
  // - do not translate because it may be loaded in QGIS running with different language
  // - do not change the name until really necessary because it could not be found in project
  QString editStyleName = "GRASS Edit"; // should not be translated

  if ( vectorLayer->styleManager()->styles().contains( editStyleName ) )
  {
    QgsDebugMsg( editStyleName + " style exists -> set as current" );
    vectorLayer->styleManager()->setCurrentStyle( editStyleName );
  }
  else
  {
    QgsDebugMsg( "create and set style " + editStyleName );
    vectorLayer->styleManager()->addStyleFromLayer( editStyleName );

    //vectorLayer->styleManager()->addStyle( editStyleName, QgsMapLayerStyle() );
    vectorLayer->styleManager()->setCurrentStyle( editStyleName );
    vectorLayer->setRendererV2( renderer );
  }

  grassProvider->startEditing( vectorLayer );
  vectorLayer->updateFields();

  connect( vectorLayer, SIGNAL( editingStopped() ), SLOT( onEditingStopped() ) );

  resetEditActions();
}
开发者ID:yellow-sky,项目名称:QGIS,代码行数:50,代码来源:qgsgrassplugin.cpp

示例2: onEditingStopped

void QgsGrassPlugin::onEditingStopped()
{
  QgsDebugMsg( "entered" );
  QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( sender() );
  if ( vectorLayer )
  {
    QString style = mOldStyles.value( vectorLayer );
    if ( vectorLayer->styleManager()->currentStyle() == "GRASS Edit" ) // not changed by user
    {
      QgsDebugMsg( "reset style to " + style );
      vectorLayer->styleManager()->setCurrentStyle( style );
    }
  }
  resetEditActions();
}
开发者ID:yellow-sky,项目名称:QGIS,代码行数:15,代码来源:qgsgrassplugin.cpp


注:本文中的QgsVectorLayer::styleManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。