static QgsSymbolV2* readOldSymbol( const QDomNode& synode, QGis::GeometryType geomType )
{
  switch ( geomType )
  {
    case QGis::Point:
    {
      QgsMarkerSymbolLayerV2* sl = NULL;
      double size = readMarkerSymbolSize( synode );
      double angle = 0; // rotation only from classification field
      QString symbolName = readMarkerSymbolName( synode );
      if ( symbolName.startsWith( "hard:" ) )
      {
        // simple symbol marker
        QColor color = readSymbolColor( synode, true );
        QColor borderColor = readSymbolColor( synode, false );
        QString name = symbolName.mid( 5 );
        sl = new QgsSimpleMarkerSymbolLayerV2( name, color, borderColor, size, angle );
      }
      else
      {
        // svg symbol marker
        QString name = symbolName.mid( 4 );
        sl = new QgsSvgMarkerSymbolLayerV2( name, size, angle );
      }
      QgsSymbolLayerV2List layers;
      layers.append( sl );
      return new QgsMarkerSymbolV2( layers );
    }

    case QGis::Line:
    {
      QColor color = readSymbolColor( synode, false );
      double width = readOutlineWidth( synode );
      Qt::PenStyle penStyle = readOutlineStyle( synode );
      QgsLineSymbolLayerV2* sl = new QgsSimpleLineSymbolLayerV2( color, width, penStyle );

      QgsSymbolLayerV2List layers;
      layers.append( sl );
      return new QgsLineSymbolV2( layers );
    }

    case QGis::Polygon:
    {
      QColor color = readSymbolColor( synode, true );
      QColor borderColor = readSymbolColor( synode, false );
      Qt::BrushStyle brushStyle = readBrushStyle( synode );
      Qt::PenStyle borderStyle = readOutlineStyle( synode );
      double borderWidth = readOutlineWidth( synode );
      QgsFillSymbolLayerV2* sl = new QgsSimpleFillSymbolLayerV2( color, brushStyle, borderColor, borderStyle, borderWidth );

      QgsSymbolLayerV2List layers;
      layers.append( sl );
      return new QgsFillSymbolV2( layers );
    }

    default:
      return NULL;
  }
}
예제 #2
0
static QgsSymbol* readOldSymbol( const QDomNode& synode, QgsWkbTypes::GeometryType geomType )
{
  switch ( geomType )
  {
    case QgsWkbTypes::PointGeometry:
    {
      QgsMarkerSymbolLayer* sl = nullptr;
      double size = readMarkerSymbolSize( synode );
      double angle = 0; // rotation only from classification field
      QString symbolName = readMarkerSymbolName( synode );
      if ( symbolName.startsWith( "hard:" ) )
      {
        // simple symbol marker
        QColor color = readSymbolColor( synode, true );
        QColor borderColor = readSymbolColor( synode, false );
        QgsSimpleMarkerSymbolLayerBase::Shape shape = QgsSimpleMarkerSymbolLayerBase::decodeShape( symbolName.mid( 5 ) );
        sl = new QgsSimpleMarkerSymbolLayer( shape, size, angle );
        sl->setColor( color );
        sl->setOutlineColor( borderColor );
      }
      else
      {
        // svg symbol marker
        QString name = symbolName.mid( 4 );
        sl = new QgsSvgMarkerSymbolLayer( name, size, angle );
      }
      QgsSymbolLayerList layers;
      layers.append( sl );
      return new QgsMarkerSymbol( layers );
    }

    case QgsWkbTypes::LineGeometry:
    {
      QColor color = readSymbolColor( synode, false );
      double width = readOutlineWidth( synode );
      Qt::PenStyle penStyle = readOutlineStyle( synode );
      QgsLineSymbolLayer* sl = new QgsSimpleLineSymbolLayer( color, width, penStyle );

      QgsSymbolLayerList layers;
      layers.append( sl );
      return new QgsLineSymbol( layers );
    }

    case QgsWkbTypes::PolygonGeometry:
    {
      QColor color = readSymbolColor( synode, true );
      QColor borderColor = readSymbolColor( synode, false );
      Qt::BrushStyle brushStyle = readBrushStyle( synode );
      Qt::PenStyle borderStyle = readOutlineStyle( synode );
      double borderWidth = readOutlineWidth( synode );
      QgsFillSymbolLayer* sl = new QgsSimpleFillSymbolLayer( color, brushStyle, borderColor, borderStyle, borderWidth );

      QgsSymbolLayerList layers;
      layers.append( sl );
      return new QgsFillSymbol( layers );
    }

    default:
      return nullptr;
  }
}