@@ -1086,155 +1086,3 @@ QgsSymbolV2::OutputUnit QgsMarkerLineSymbolLayerV2::outputUnit() const
10861086 }
10871087 return unit;
10881088}
1089-
1090- // ///////////
1091-
1092- QgsLineDecorationSymbolLayerV2::QgsLineDecorationSymbolLayerV2 ( QColor color, double width )
1093- {
1094- mColor = color;
1095- mWidth = width;
1096- }
1097-
1098- QgsLineDecorationSymbolLayerV2::~QgsLineDecorationSymbolLayerV2 ()
1099- {
1100- }
1101-
1102- QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2::create ( const QgsStringMap& props )
1103- {
1104- QColor color = DEFAULT_LINEDECORATION_COLOR;
1105- double width = DEFAULT_LINEDECORATION_WIDTH;
1106-
1107- if ( props.contains ( " color" ) )
1108- color = QgsSymbolLayerV2Utils::decodeColor ( props[" color" ] );
1109- if ( props.contains ( " width" ) )
1110- width = props[" width" ].toDouble ();
1111-
1112-
1113- QgsLineDecorationSymbolLayerV2* layer = new QgsLineDecorationSymbolLayerV2 ( color, width );
1114- if ( props.contains ( " width_unit" ) )
1115- {
1116- layer->setWidthUnit ( QgsSymbolLayerV2Utils::decodeOutputUnit ( props[" width_unit" ] ) );
1117- }
1118- return layer;
1119- }
1120-
1121- QString QgsLineDecorationSymbolLayerV2::layerType () const
1122- {
1123- return " LineDecoration" ;
1124- }
1125-
1126- void QgsLineDecorationSymbolLayerV2::startRender ( QgsSymbolV2RenderContext& context )
1127- {
1128- QColor penColor = mColor ;
1129- penColor.setAlphaF ( mColor .alphaF () * context.alpha () );
1130-
1131- double width = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mWidthUnit );
1132- mPen .setWidth ( width );
1133- mPen .setColor ( penColor );
1134- QColor selColor = context.renderContext ().selectionColor ();
1135- if ( ! selectionIsOpaque )
1136- selColor.setAlphaF ( context.alpha () );
1137- mSelPen .setWidth ( width ); // context.outputLineWidth( width ) );
1138- mSelPen .setColor ( selColor );
1139- }
1140-
1141- void QgsLineDecorationSymbolLayerV2::stopRender ( QgsSymbolV2RenderContext& context )
1142- {
1143- Q_UNUSED ( context );
1144- }
1145-
1146- void QgsLineDecorationSymbolLayerV2::renderPolyline ( const QPolygonF& points, QgsSymbolV2RenderContext& context )
1147- {
1148- // draw arrow at the end of line
1149-
1150- QPainter* p = context.renderContext ().painter ();
1151- if ( !p )
1152- {
1153- return ;
1154- }
1155-
1156- int cnt = points.count ();
1157- if ( cnt < 2 )
1158- {
1159- return ;
1160- }
1161- QPointF p2 = points.at ( --cnt );
1162- QPointF p1 = points.at ( --cnt );
1163- while ( p2 == p1 && cnt )
1164- p1 = points.at ( --cnt );
1165- if ( p1 == p2 )
1166- {
1167- // this is a collapsed line... don't bother drawing an arrow
1168- // with arbitrary orientation
1169- return ;
1170- }
1171-
1172- double angle = atan2 ( p2.y () - p1.y (), p2.x () - p1.x () );
1173- double size = ( mWidth * 8 ) * QgsSymbolLayerV2Utils::lineWidthScaleFactor ( context.renderContext (), mWidthUnit );
1174- double angle1 = angle + M_PI / 6 ;
1175- double angle2 = angle - M_PI / 6 ;
1176-
1177- QPointF p2_1 = p2 - QPointF ( size * cos ( angle1 ), size * sin ( angle1 ) );
1178- QPointF p2_2 = p2 - QPointF ( size * cos ( angle2 ), size * sin ( angle2 ) );
1179-
1180- p->setPen ( context.selected () ? mSelPen : mPen );
1181- p->drawLine ( p2, p2_1 );
1182- p->drawLine ( p2, p2_2 );
1183- }
1184-
1185- QgsStringMap QgsLineDecorationSymbolLayerV2::properties () const
1186- {
1187- QgsStringMap map;
1188- map[" color" ] = QgsSymbolLayerV2Utils::encodeColor ( mColor );
1189- map[" width" ] = QString::number ( mWidth );
1190- map[" width_unit" ] = QgsSymbolLayerV2Utils::encodeOutputUnit ( mWidthUnit );
1191- return map;
1192- }
1193-
1194- QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2::clone () const
1195- {
1196- QgsLineDecorationSymbolLayerV2* layer = new QgsLineDecorationSymbolLayerV2 ( mColor , mWidth );
1197- layer->setWidthUnit ( mWidthUnit );
1198- return layer;
1199- }
1200-
1201- void QgsLineDecorationSymbolLayerV2::toSld ( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
1202- {
1203- QDomElement symbolizerElem = doc.createElement ( " se:LineSymbolizer" );
1204- if ( !props.value ( " uom" , " " ).isEmpty () )
1205- symbolizerElem.setAttribute ( " uom" , props.value ( " uom" , " " ) );
1206- element.appendChild ( symbolizerElem );
1207-
1208- QgsSymbolLayerV2Utils::createGeometryElement ( doc, symbolizerElem, props.value ( " geom" , " " ) );
1209-
1210- // <Stroke>
1211- QDomElement strokeElem = doc.createElement ( " se:Stroke" );
1212- symbolizerElem.appendChild ( strokeElem );
1213-
1214- // <GraphicStroke>
1215- QDomElement graphicStrokeElem = doc.createElement ( " se:GraphicStroke" );
1216- strokeElem.appendChild ( graphicStrokeElem );
1217-
1218- // <Graphic>
1219- QDomElement graphicElem = doc.createElement ( " se:Graphic" );
1220- graphicStrokeElem.appendChild ( graphicElem );
1221-
1222- // <Mark>
1223- QgsSymbolLayerV2Utils::wellKnownMarkerToSld ( doc, graphicElem, " arrowhead" , QColor (), mColor , mWidth , mWidth *8 );
1224-
1225- // <Rotation>
1226- QgsSymbolLayerV2Utils::createRotationElement ( doc, graphicElem, props.value ( " angle" , " " ) );
1227-
1228- // use <VendorOption> to draw the decoration at end of the line
1229- symbolizerElem.appendChild ( QgsSymbolLayerV2Utils::createVendorOptionElement ( doc, " placement" , " lastPoint" ) );
1230- }
1231-
1232- void QgsLineDecorationSymbolLayerV2::setOutputUnit ( QgsSymbolV2::OutputUnit unit )
1233- {
1234- mWidthUnit = unit;
1235- }
1236-
1237- QgsSymbolV2::OutputUnit QgsLineDecorationSymbolLayerV2::outputUnit () const
1238- {
1239- return mWidthUnit ;
1240- }
0 commit comments