QgsFeatureRendererV2* QgsHeatmapRenderer::clone() const
{
  QgsHeatmapRenderer* newRenderer = new QgsHeatmapRenderer();
  if ( mGradientRamp )
  {
    newRenderer->setColorRamp( mGradientRamp->clone() );
  }
  newRenderer->setInvertRamp( mInvertRamp );
  newRenderer->setRadius( mRadius );
  newRenderer->setRadiusUnit( mRadiusUnit );
  newRenderer->setRadiusMapUnitScale( mRadiusMapUnitScale );
  newRenderer->setMaximumValue( mExplicitMax );
  newRenderer->setRenderQuality( mRenderQuality );
  newRenderer->setWeightExpression( mWeightExpressionString );
  copyPaintEffect( newRenderer );

  return newRenderer;
}
QgsFeatureRendererV2* QgsHeatmapRenderer::create( QDomElement& element )
{
  QgsHeatmapRenderer* r = new QgsHeatmapRenderer();
  r->setRadius( element.attribute( "radius", "50.0" ).toFloat() );
  r->setRadiusUnit(( QgsSymbolV2::OutputUnit )element.attribute( "radius_unit", "0" ).toInt() );
  r->setRadiusMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( element.attribute( "radius_map_unit_scale", QString() ) ) );
  r->setMaximumValue( element.attribute( "max_value", "0.0" ).toFloat() );
  r->setRenderQuality( element.attribute( "quality", "0" ).toInt() );
  r->setWeightExpression( element.attribute( "weight_expression" ) );

  QDomElement sourceColorRampElem = element.firstChildElement( "colorramp" );
  if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( "name" ) == "[source]" )
  {
    r->setColorRamp( QgsSymbolLayerV2Utils::loadColorRamp( sourceColorRampElem ) );
  }
  r->setInvertRamp( element.attribute( "invert_ramp", "0" ).toInt() );
  return r;
}
Esempio n. 3
0
QgsFeatureRenderer* QgsHeatmapRenderer::create( QDomElement& element )
{
  QgsHeatmapRenderer* r = new QgsHeatmapRenderer();
  r->setRadius( element.attribute( QStringLiteral( "radius" ), QStringLiteral( "50.0" ) ).toFloat() );
  r->setRadiusUnit( static_cast< QgsUnitTypes::RenderUnit >( element.attribute( QStringLiteral( "radius_unit" ), QStringLiteral( "0" ) ).toInt() ) );
  r->setRadiusMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( element.attribute( QStringLiteral( "radius_map_unit_scale" ), QString() ) ) );
  r->setMaximumValue( element.attribute( QStringLiteral( "max_value" ), QStringLiteral( "0.0" ) ).toFloat() );
  r->setRenderQuality( element.attribute( QStringLiteral( "quality" ), QStringLiteral( "0" ) ).toInt() );
  r->setWeightExpression( element.attribute( QStringLiteral( "weight_expression" ) ) );

  QDomElement sourceColorRampElem = element.firstChildElement( QStringLiteral( "colorramp" ) );
  if ( !sourceColorRampElem.isNull() && sourceColorRampElem.attribute( QStringLiteral( "name" ) ) == QLatin1String( "[source]" ) )
  {
    r->setColorRamp( QgsSymbolLayerUtils::loadColorRamp( sourceColorRampElem ) );
  }
  return r;
}