本文整理汇总了C++中QgsSymbolLayerV2List类的典型用法代码示例。如果您正苦于以下问题:C++ QgsSymbolLayerV2List类的具体用法?C++ QgsSymbolLayerV2List怎么用?C++ QgsSymbolLayerV2List使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsSymbolLayerV2List类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QgsDebugMsg
QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::createFromSld( QDomElement &element )
{
QgsDebugMsg( "Entered." );
QString name;
QColor fillColor, lineColor;
double size, lineWidth;
QDomElement fillElem = element.firstChildElement( "Fill" );
if ( fillElem.isNull() )
return NULL;
QDomElement graphicFillElem = fillElem.firstChildElement( "GraphicFill" );
if ( graphicFillElem.isNull() )
return NULL;
QDomElement graphicElem = graphicFillElem.firstChildElement( "Graphic" );
if ( graphicElem.isNull() )
return NULL;
if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, fillColor, lineColor, lineWidth, size ) )
return NULL;
if ( name != "horline" )
return NULL;
double angle = 0.0;
QString angleFunc;
if ( QgsSymbolLayerV2Utils::rotationFromSldElement( graphicElem, angleFunc ) )
{
bool ok;
double d = angleFunc.toDouble( &ok );
if ( ok )
angle = d;
}
double offset = 0.0;
QPointF vectOffset;
if ( QgsSymbolLayerV2Utils::displacementFromSldElement( graphicElem, vectOffset ) )
{
offset = sqrt( pow( vectOffset.x(), 2 ) + pow( vectOffset.y(), 2 ) );
}
QgsLinePatternFillSymbolLayer* sl = new QgsLinePatternFillSymbolLayer();
sl->setColor( lineColor );
sl->setLineWidth( lineWidth );
sl->setLineAngle( angle );
sl->setOffset( offset );
sl->setDistance( size );
// try to get the outline
QDomElement strokeElem = element.firstChildElement( "Stroke" );
if ( !strokeElem.isNull() )
{
QgsSymbolLayerV2 *l = QgsSymbolLayerV2Utils::createLineLayerFromSld( strokeElem );
if ( l )
{
QgsSymbolLayerV2List layers;
layers.append( l );
sl->setSubSymbol( new QgsLineSymbolV2( layers ) );
}
}
return sl;
}
示例2:
QgsFillSymbolV2* QgsFillSymbolV2::createSimple( const QgsStringMap& properties )
{
QgsSymbolLayerV2* sl = QgsSimpleFillSymbolLayerV2::create( properties );
if ( sl == NULL )
return NULL;
QgsSymbolLayerV2List layers;
layers.append( sl );
return new QgsFillSymbolV2( layers );
}
示例3: readOldSymbol
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;
}
}
示例4: switch
QgsSymbolV2* QgsSymbologyV2Conversion::symbolV1toV2( const QgsSymbol* s )
{
switch ( s->type() )
{
case QGis::Point:
{
QgsMarkerSymbolLayerV2* sl = NULL;
double size = s->pointSize();
double angle = 0; // rotation only from classification field
QString symbolName = s->pointSymbolName();
if ( symbolName.startsWith( "hard:" ) )
{
// simple symbol marker
QColor color = s->fillColor();
QColor borderColor = s->color();
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 = s->color();
double width = s->lineWidth();
Qt::PenStyle penStyle = s->pen().style();
QgsLineSymbolLayerV2* sl = new QgsSimpleLineSymbolLayerV2( color, width, penStyle );
QgsSymbolLayerV2List layers;
layers.append( sl );
return new QgsLineSymbolV2( layers );
}
case QGis::Polygon:
{
QColor color = s->fillColor();
QColor borderColor = s->color();
Qt::BrushStyle brushStyle = s->brush().style();
Qt::PenStyle borderStyle = s->pen().style();
double borderWidth = s->lineWidth();
QgsFillSymbolLayerV2* sl = new QgsSimpleFillSymbolLayerV2( color, brushStyle, borderColor, borderStyle, borderWidth );
QgsSymbolLayerV2List layers;
layers.append( sl );
return new QgsFillSymbolV2( layers );
}
default:
return NULL;
}
}
示例5: QgsDebugMsg
QgsSymbolLayerV2* QgsMarkerLineSymbolLayerV2::createFromSld( QDomElement &element )
{
QgsDebugMsg( "Entered." );
QDomElement strokeElem = element.firstChildElement( "Stroke" );
if ( strokeElem.isNull() )
return NULL;
QDomElement graphicStrokeElem = strokeElem.firstChildElement( "GraphicStroke" );
if ( graphicStrokeElem.isNull() )
return NULL;
// retrieve vendor options
bool rotateMarker = true;
Placement placement = Interval;
QgsStringMap vendorOptions = QgsSymbolLayerV2Utils::getVendorOptionList( element );
for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
{
if ( it.key() == "placement" )
{
if ( it.value() == "points" ) placement = Vertex;
else if ( it.value() == "firstPoint" ) placement = FirstVertex;
else if ( it.value() == "lastPoint" ) placement = LastVertex;
else if ( it.value() == "centralPoint" ) placement = CentralPoint;
}
else if ( it.value() == "rotateMarker" )
{
rotateMarker = it.value() == "0";
}
}
QgsMarkerSymbolV2 *marker = 0;
QgsSymbolLayerV2 *l = QgsSymbolLayerV2Utils::createMarkerLayerFromSld( graphicStrokeElem );
if ( l )
{
QgsSymbolLayerV2List layers;
layers.append( l );
marker = new QgsMarkerSymbolV2( layers );
}
if ( !marker )
return NULL;
double interval = 0.0;
QDomElement gapElem = graphicStrokeElem.firstChildElement( "Gap" );
if ( !gapElem.isNull() )
{
bool ok;
double d = gapElem.firstChild().nodeValue().toDouble( &ok );
if ( ok )
interval = d;
}
double offset = 0.0;
QDomElement perpOffsetElem = graphicStrokeElem.firstChildElement( "PerpendicularOffset" );
if ( !perpOffsetElem.isNull() )
{
bool ok;
double d = perpOffsetElem.firstChild().nodeValue().toDouble( &ok );
if ( ok )
offset = d;
}
QgsMarkerLineSymbolLayerV2* x = new QgsMarkerLineSymbolLayerV2( rotateMarker );
x->setPlacement( placement );
x->setInterval( interval );
x->setSubSymbol( marker );
x->setOffset( offset );
return x;
}
示例6: QgsDebugMsg
QgsFeatureRendererV2* QgsSingleSymbolRendererV2::createFromSld( QDomElement& element, Qgis::GeometryType geomType )
{
// XXX this renderer can handle only one Rule!
// get the first Rule element
QDomElement ruleElem = element.firstChildElement( "Rule" );
if ( ruleElem.isNull() )
{
QgsDebugMsg( "no Rule elements found!" );
return nullptr;
}
QString label, description;
QgsSymbolLayerV2List layers;
// retrieve the Rule element child nodes
QDomElement childElem = ruleElem.firstChildElement();
while ( !childElem.isNull() )
{
if ( childElem.localName() == "Name" )
{
// <se:Name> tag contains the rule identifier,
// so prefer title tag for the label property value
if ( label.isEmpty() )
label = childElem.firstChild().nodeValue();
}
else if ( childElem.localName() == "Description" )
{
// <se:Description> can contains a title and an abstract
QDomElement titleElem = childElem.firstChildElement( "Title" );
if ( !titleElem.isNull() )
{
label = titleElem.firstChild().nodeValue();
}
QDomElement abstractElem = childElem.firstChildElement( "Abstract" );
if ( !abstractElem.isNull() )
{
description = abstractElem.firstChild().nodeValue();
}
}
else if ( childElem.localName() == "Abstract" )
{
// <sld:Abstract> (v1.0)
description = childElem.firstChild().nodeValue();
}
else if ( childElem.localName() == "Title" )
{
// <sld:Title> (v1.0)
label = childElem.firstChild().nodeValue();
}
else if ( childElem.localName().endsWith( "Symbolizer" ) )
{
// create symbol layers for this symbolizer
QgsSymbolLayerV2Utils::createSymbolLayerV2ListFromSld( childElem, geomType, layers );
}
childElem = childElem.nextSiblingElement();
}
if ( layers.isEmpty() )
return nullptr;
// now create the symbol
QgsSymbolV2 *symbol;
switch ( geomType )
{
case Qgis::Line:
symbol = new QgsLineSymbolV2( layers );
break;
case Qgis::Polygon:
symbol = new QgsFillSymbolV2( layers );
break;
case Qgis::Point:
symbol = new QgsMarkerSymbolV2( layers );
break;
default:
QgsDebugMsg( QString( "invalid geometry type: found %1" ).arg( geomType ) );
return nullptr;
}
// and finally return the new renderer
return new QgsSingleSymbolRendererV2( symbol );
}
示例7: QgsDebugMsg
QgsFeatureRendererV2* QgsSingleSymbolRendererV2::createFromSld( QDomElement& element, QGis::GeometryType geomType )
{
// XXX this renderer can handle only one Rule!
// get the first Rule element
QDomElement ruleElem = element.firstChildElement( "Rule" );
if ( ruleElem.isNull() )
{
QgsDebugMsg( "no Rule elements found!" );
return NULL;
}
QString label, description;
QgsSymbolLayerV2List layers;
// retrieve the Rule element child nodes
QDomElement childElem = ruleElem.firstChildElement();
while ( !childElem.isNull() )
{
if ( childElem.localName() == "Name" )
{
label = childElem.firstChild().nodeValue();
}
else if ( childElem.localName() == "Description" || childElem.localName() == "Abstract" )
{
description = childElem.firstChild().nodeValue();
}
else if ( childElem.localName().endsWith( "Symbolizer" ) )
{
// create symbol layers for this symbolizer
QgsSymbolLayerV2Utils::createSymbolLayerV2ListFromSld( childElem, geomType, layers );
}
childElem = childElem.nextSiblingElement();
}
// now create the symbol
QgsSymbolV2 *symbol = 0;
if ( layers.size() > 0 )
{
switch ( geomType )
{
case QGis::Line:
symbol = new QgsLineSymbolV2( layers );
break;
case QGis::Polygon:
symbol = new QgsFillSymbolV2( layers );
break;
case QGis::Point:
symbol = new QgsMarkerSymbolV2( layers );
break;
default:
QgsDebugMsg( QString( "invalid geometry type: found %1" ).arg( geomType ) );
return NULL;
}
}
// and finally return the new renderer
return new QgsSingleSymbolRendererV2( symbol );
}