10 #include <QSvgRenderer>
13 : mBrushStyle( style ), mBorderColor( borderColor ), mBorderStyle( borderStyle ), mBorderWidth( borderWidth )
28 if ( props.contains(
"color" ) )
30 if ( props.contains(
"style" ) )
32 if ( props.contains(
"color_border" ) )
34 if ( props.contains(
"style_border" ) )
36 if ( props.contains(
"width_border" ) )
37 borderWidth = props[
"width_border"].toDouble();
38 if ( props.contains(
"offset" ) )
59 if ( rasterScaleFactor != 1.0 )
61 mBrush.setMatrix( QMatrix().scale( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor ) );
128 mSvgData( svgData ), mOutline( 0 )
143 QFile svgFile( svgPath );
144 if ( svgFile.open( QFile::ReadOnly ) )
160 if ( properties.contains(
"width" ) )
162 width = properties[
"width"].toDouble();
164 if ( properties.contains(
"svgFile" ) )
166 QString svgName = properties[
"svgFile"];
168 svgFilePath = ( savePath.isEmpty() ? svgName : savePath );
170 if ( properties.contains(
"angle" ) )
172 angle = properties[
"angle"].toDouble();
175 if ( !svgFilePath.isEmpty() )
181 if ( properties.contains(
"data" ) )
183 data = QByteArray::fromHex( properties[
"data"].toLocal8Bit() );
206 QImage textureImage( pixelWidth, pixelHeight, QImage::Format_ARGB32_Premultiplied );
207 textureImage.fill( 0 );
210 QPainter p( &textureImage );
219 if ( context.
alpha() < 1.0 )
224 QTransform brushTransform;
226 mBrush.setTextureImage( textureImage );
227 mBrush.setTransform( brushTransform );
250 p->setPen( QPen( Qt::NoPen ) );
255 p->setBrush( QBrush( selColor ) );
265 QTransform t =
mBrush.transform();
267 QBrush rotatedBrush =
mBrush;
268 rotatedBrush.setTransform( t );
269 p->setBrush( rotatedBrush );
277 QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
278 for ( ; ringIt != rings->constEnd(); ++ringIt )
295 map.insert(
"data", QString(
mSvgData.toHex() ) );
299 map.insert(
"angle", QString::number(
mAngle ) );
380 return "CentroidFill";
405 double cx = 0, cy = 0;
406 double area, sum = 0;
407 for (
int i = points.count() - 1, j = 0; j < points.count(); i = j++ )
409 const QPointF& p1 = points[i];
410 const QPointF& p2 = points[j];
411 area = p1.x() * p2.y() - p1.y() * p2.x();
413 cx += ( p1.x() + p2.x() ) * area;
414 cy += ( p1.y() + p2.y() ) * area;