QgsCoordinateSequence QgsCurve::coordinateSequence() const { QgsCoordinateSequence sequence; sequence.append( QgsRingSequence() ); sequence.back().append( QgsPointSequence() ); points( sequence.back().back() ); return sequence; }
QgsCoordinateSequence QgsCurve::coordinateSequence() const { if ( !mCoordinateSequence.isEmpty() ) return mCoordinateSequence; mCoordinateSequence.append( QgsRingSequence() ); mCoordinateSequence.back().append( QgsPointSequence() ); points( mCoordinateSequence.back().back() ); return mCoordinateSequence; }
QgsCoordinateSequence QgsCurvePolygon::coordinateSequence() const { QgsCoordinateSequence sequence; sequence.append( QgsRingSequence() ); if ( mExteriorRing ) { sequence.back().append( QgsPointSequence() ); mExteriorRing->points( sequence.back().back() ); } for ( const QgsCurve *ring : mInteriorRings ) { sequence.back().append( QgsPointSequence() ); ring->points( sequence.back().back() ); } return sequence; }
bool QgsEllipseSymbolLayer::writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift ) const { //width double symbolWidth = mSymbolWidth; if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyWidth ) ) //1. priority: data defined setting on symbol layer le { context.setOriginalValueVariable( mSymbolWidth ); symbolWidth = mDataDefinedProperties.valueAsDouble( QgsSymbolLayer::PropertyWidth, context.renderContext().expressionContext(), mSymbolWidth ); } if ( mSymbolWidthUnit == QgsUnitTypes::RenderMillimeters ) { symbolWidth *= mmMapUnitScaleFactor; } //height double symbolHeight = mSymbolHeight; if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyHeight ) ) //1. priority: data defined setting on symbol layer level { context.setOriginalValueVariable( mSymbolHeight ); symbolWidth = mDataDefinedProperties.valueAsDouble( QgsSymbolLayer::PropertyHeight, context.renderContext().expressionContext(), mSymbolHeight ); } if ( mSymbolHeightUnit == QgsUnitTypes::RenderMillimeters ) { symbolHeight *= mmMapUnitScaleFactor; } //stroke width double strokeWidth = mStrokeWidth; if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyStrokeWidth ) ) { context.setOriginalValueVariable( mStrokeWidth ); strokeWidth = mDataDefinedProperties.valueAsDouble( QgsSymbolLayer::PropertyStrokeWidth, context.renderContext().expressionContext(), mStrokeWidth ); } if ( mStrokeWidthUnit == QgsUnitTypes::RenderMillimeters ) { strokeWidth *= strokeWidth; } //fill color QColor fc = mColor; if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyFillColor ) ) { context.setOriginalValueVariable( QgsSymbolLayerUtils::encodeColor( mColor ) ); fc = mDataDefinedProperties.valueAsColor( QgsSymbolLayer::PropertyFillColor, context.renderContext().expressionContext(), mColor ); } //stroke color QColor oc = mStrokeColor; if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyStrokeColor ) ) { context.setOriginalValueVariable( QgsSymbolLayerUtils::encodeColor( mStrokeColor ) ); oc = mDataDefinedProperties.valueAsColor( QgsSymbolLayer::PropertyStrokeColor, context.renderContext().expressionContext(), mStrokeColor ); } //symbol name QString symbolName = mSymbolName; if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyName ) ) { context.setOriginalValueVariable( mSymbolName ); symbolName = mDataDefinedProperties.valueAsString( QgsSymbolLayer::PropertyName, context.renderContext().expressionContext(), mSymbolName ); } //offset double offsetX = 0; double offsetY = 0; markerOffset( context, offsetX, offsetY ); QPointF off( offsetX, offsetY ); //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle) double rotation = 0.0; if ( mDataDefinedProperties.isActive( QgsSymbolLayer::PropertyAngle ) ) { context.setOriginalValueVariable( mAngle ); rotation = mDataDefinedProperties.valueAsDouble( QgsSymbolLayer::PropertyAngle, context.renderContext().expressionContext(), mAngle ) + mLineAngle; } else if ( !qgsDoubleNear( mAngle + mLineAngle, 0.0 ) ) { rotation = mAngle + mLineAngle; } rotation = -rotation; //rotation in Qt is counterclockwise if ( rotation ) off = _rotatedOffset( off, rotation ); QTransform t; t.translate( shift.x() + offsetX, shift.y() + offsetY ); if ( !qgsDoubleNear( rotation, 0.0 ) ) t.rotate( rotation ); double halfWidth = symbolWidth / 2.0; double halfHeight = symbolHeight / 2.0; if ( symbolName == QLatin1String( "circle" ) ) { if ( qgsDoubleNear( halfWidth, halfHeight ) ) { QgsPoint pt( t.map( QPointF( 0, 0 ) ) ); e.writeFilledCircle( layerName, oc, pt, halfWidth ); } else { QgsPointSequence line; double stepsize = 2 * M_PI / 40; for ( int i = 0; i < 39; ++i ) { double angle = stepsize * i; double x = halfWidth * std::cos( angle ); double y = halfHeight * std::sin( angle ); line << QgsPoint( t.map( QPointF( x, y ) ) ); } //close ellipse with first point line << line.at( 0 ); if ( mBrush.style() != Qt::NoBrush ) e.writePolygon( QgsRingSequence() << line, layerName, QStringLiteral( "SOLID" ), fc ); if ( mPen.style() != Qt::NoPen ) e.writePolyline( line, layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth ); } } else if ( symbolName == QLatin1String( "rectangle" ) ) { QgsPointSequence p; p << QgsPoint( t.map( QPointF( -halfWidth, -halfHeight ) ) ) << QgsPoint( t.map( QPointF( halfWidth, -halfHeight ) ) ) << QgsPoint( t.map( QPointF( halfWidth, halfHeight ) ) ) << QgsPoint( t.map( QPointF( -halfWidth, halfHeight ) ) ); p << p[0]; if ( mBrush.style() != Qt::NoBrush ) e.writePolygon( QgsRingSequence() << p, layerName, QStringLiteral( "SOLID" ), fc ); if ( mPen.style() != Qt::NoPen ) e.writePolyline( p, layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth ); return true; } else if ( symbolName == QLatin1String( "cross" ) && mPen.style() != Qt::NoPen ) { e.writePolyline( QgsPointSequence() << QgsPoint( t.map( QPointF( -halfWidth, 0 ) ) ) << QgsPoint( t.map( QPointF( halfWidth, 0 ) ) ), layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth ); e.writePolyline( QgsPointSequence() << QgsPoint( t.map( QPointF( 0, halfHeight ) ) ) << QgsPoint( t.map( QPointF( 0, -halfHeight ) ) ), layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth ); return true; } else if ( symbolName == QLatin1String( "triangle" ) ) { QgsPointSequence p; p << QgsPoint( t.map( QPointF( -halfWidth, -halfHeight ) ) ) << QgsPoint( t.map( QPointF( halfWidth, -halfHeight ) ) ) << QgsPoint( t.map( QPointF( 0, halfHeight ) ) ); p << p[0]; if ( mBrush.style() != Qt::NoBrush ) e.writePolygon( QgsRingSequence() << p, layerName, QStringLiteral( "SOLID" ), fc ); if ( mPen.style() != Qt::NoPen ) e.writePolyline( p, layerName, QStringLiteral( "CONTINUOUS" ), oc, strokeWidth ); return true; } return false; //soon... }