Exemple #1
0
QgsRubberBand* QgsMapToolEdit::createRubberBand( QGis::GeometryType geometryType, bool alternativeBand )
{
  QSettings settings;
  QgsRubberBand* rb = new QgsRubberBand( mCanvas, geometryType );
  rb->setWidth( settings.value( "/qgis/digitizing/line_width", 1 ).toInt() );
  QColor color(
    settings.value( "/qgis/digitizing/line_color_red", 255 ).toInt(),
    settings.value( "/qgis/digitizing/line_color_green", 0 ).toInt(),
    settings.value( "/qgis/digitizing/line_color_blue", 0 ).toInt() );
  double myAlpha = settings.value( "/qgis/digitizing/line_color_alpha", 200 ).toInt() / 255.0;
  if ( alternativeBand )
  {
    myAlpha = myAlpha * settings.value( "/qgis/digitizing/line_color_alpha_scale", 0.75 ).toDouble();
    rb->setLineStyle( Qt::DotLine );
  }
  if ( geometryType == QGis::Polygon )
  {
    color.setAlphaF( myAlpha );
  }
  color.setAlphaF( myAlpha );
  rb->setColor( color );

  QColor fillColor(
    settings.value( "/qgis/digitizing/fill_color_red", 255 ).toInt(),
    settings.value( "/qgis/digitizing/fill_color_green", 0 ).toInt(),
    settings.value( "/qgis/digitizing/fill_color_blue", 0 ).toInt() );
  myAlpha = settings.value( "/qgis/digitizing/fill_color_alpha", 30 ).toInt() / 255.0 ;
  fillColor.setAlphaF( myAlpha );
  rb->setFillColor( fillColor );

  rb->show();
  return rb;
}