QgsGrassEditRenderer::QgsGrassEditRenderer() : QgsFeatureRendererV2( "grassEdit" ) , mLineRenderer( 0 ) , mMarkerRenderer( 0 ) { QHash<int, QColor> colors; //colors.insert( QgsGrassVectorMap::TopoUndefined, QColor( 125, 125, 125 ) ); colors.insert( QgsGrassVectorMap::TopoLine, QColor( Qt::black ) ); colors.insert( QgsGrassVectorMap::TopoBoundaryError, QColor( Qt::red ) ); colors.insert( QgsGrassVectorMap::TopoBoundaryErrorLeft, QColor( 255, 125, 0 ) ); colors.insert( QgsGrassVectorMap::TopoBoundaryErrorRight, QColor( 255, 125, 0 ) ); colors.insert( QgsGrassVectorMap::TopoBoundaryOk, QColor( Qt::green ) ); QHash<int, QString> labels; //labels.insert( QgsGrassVectorMap::TopoUndefined, "Unknown type" ); labels.insert( QgsGrassVectorMap::TopoLine, "Line" ); labels.insert( QgsGrassVectorMap::TopoBoundaryError, "Boundary (topological error on both sides)" ); labels.insert( QgsGrassVectorMap::TopoBoundaryErrorLeft, "Boundary (topological error on the left side)" ); labels.insert( QgsGrassVectorMap::TopoBoundaryErrorRight, "Boundary (topological error on the right side)" ); labels.insert( QgsGrassVectorMap::TopoBoundaryOk, "Boundary (correct)" ); QgsCategoryList categoryList; // first/last vertex marker to distinguish vertices from nodes QgsMarkerLineSymbolLayerV2 * firstVertexMarkerLine = new QgsMarkerLineSymbolLayerV2( false ); QgsSimpleMarkerSymbolLayerV2 *markerSymbolLayer = new QgsSimpleMarkerSymbolLayerV2( QgsSimpleMarkerSymbolLayerBase::Cross2, 2 ); markerSymbolLayer->setColor( QColor( 255, 0, 0 ) ); markerSymbolLayer->setBorderColor( QColor( 255, 0, 0 ) ); markerSymbolLayer->setOutlineWidth( 0.5 ); QgsSymbolLayerV2List markerLayers; markerLayers << markerSymbolLayer; QgsMarkerSymbolV2 * markerSymbol = new QgsMarkerSymbolV2( markerLayers ); firstVertexMarkerLine->setSubSymbol( markerSymbol ); firstVertexMarkerLine->setPlacement( QgsMarkerLineSymbolLayerV2::FirstVertex ); QgsMarkerLineSymbolLayerV2 * lastVertexMarkerLine = static_cast<QgsMarkerLineSymbolLayerV2 *>( firstVertexMarkerLine->clone() ); lastVertexMarkerLine->setPlacement( QgsMarkerLineSymbolLayerV2::LastVertex ); Q_FOREACH ( int value, colors.keys() ) { QgsSymbolV2 * symbol = QgsSymbolV2::defaultSymbol( QGis::Line ); symbol->setColor( colors.value( value ) ); symbol->appendSymbolLayer( firstVertexMarkerLine->clone() ); symbol->appendSymbolLayer( lastVertexMarkerLine->clone() ); categoryList << QgsRendererCategoryV2( QVariant( value ), symbol, labels.value( value ) ); } delete firstVertexMarkerLine; delete lastVertexMarkerLine; mLineRenderer = new QgsCategorizedSymbolRendererV2( "topo_symbol", categoryList ); colors.clear(); labels.clear(); colors.insert( QgsGrassVectorMap::TopoPoint, QColor( 0, 255, 255 ) ); colors.insert( QgsGrassVectorMap::TopoCentroidIn, QColor( 0, 255, 0 ) ); colors.insert( QgsGrassVectorMap::TopoCentroidOut, QColor( 255, 0, 0 ) ); colors.insert( QgsGrassVectorMap::TopoCentroidDupl, QColor( 255, 0, 255 ) ); labels.insert( QgsGrassVectorMap::TopoPoint, "Point" ); labels.insert( QgsGrassVectorMap::TopoCentroidIn, "Centroid in area" ); labels.insert( QgsGrassVectorMap::TopoCentroidOut, "Centroid outside area" ); labels.insert( QgsGrassVectorMap::TopoCentroidDupl, "Duplicate centroid" ); categoryList.clear(); Q_FOREACH ( int value, colors.keys() ) { QgsSymbolV2 * symbol = QgsSymbolV2::defaultSymbol( QGis::Point ); symbol->setColor( colors.value( value ) ); categoryList << QgsRendererCategoryV2( QVariant( value ), symbol, labels.value( value ) ); } mMarkerRenderer = new QgsCategorizedSymbolRendererV2( "topo_symbol", categoryList ); }