Skip to content

Commit

Permalink
Write dxf circle
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Dec 6, 2013
1 parent ebbb976 commit 668403a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/core/dxf/qgsdxfexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,17 @@ void QgsDxfExport::writePoint( const QString& layer, int color, const QgsPoint&
writeGroup( 30, 0.0 );
}

void QgsDxfExport::writeCircle( const QString& layer, int color, const QgsPoint& pt, double radius )
{
writeGroup( 0, "CIRCLE" );
writeGroup( 8, layer );
writeGroup( 62, color );
writeGroup( 10, pt.x() );
writeGroup( 20, pt.y() );
writeGroup( 30, 0 );
writeGroup( 40, radius );
}

void QgsDxfExport::writeSolid( const QString& layer, int color, const QgsPoint& pt1, const QgsPoint& pt2, const QgsPoint& pt3, const QgsPoint& pt4 )
{
writeGroup( 0, "SOLID" );
Expand Down
4 changes: 3 additions & 1 deletion src/core/dxf/qgsdxfexport.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class QgsPoint;
class QgsSymbolLayerV2;
class QIODevice;

class QgsDxfExport
class CORE_EXPORT QgsDxfExport
{
public:
enum SymbologyExport
Expand Down Expand Up @@ -78,6 +78,8 @@ class QgsDxfExport

void writePoint( const QString& layer, int color, const QgsPoint& pt );

void writeCircle( const QString& layer, int color, const QgsPoint& pt, double radius );

private:

QList< QgsMapLayer* > mLayers;
Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfpaintdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class QPaintEngine;

/**A paint device for drawing into dxf files*/

class QgsDxfPaintDevice: public QPaintDevice
class CORE_EXPORT QgsDxfPaintDevice: public QPaintDevice
{
public:
QgsDxfPaintDevice( QgsDxfExport* dxf );
Expand Down
8 changes: 7 additions & 1 deletion src/core/dxf/qgsdxfpaintengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ void QgsDxfPaintEngine::drawRects( const QRectF* rects, int rectCount )

void QgsDxfPaintEngine::drawEllipse( const QRectF& rect )
{
//map to circle in case of square?
QPoint midPoint(( rect.left() + rect.right() ) / 2.0, ( rect.top() + rect.bottom() ) / 2.0 );

//a circle
if ( qgsDoubleNear( rect.width(), rect.height() ) )
{
mDxf->writeCircle( mLayer, currentPenColor(), toDxfCoordinates( midPoint ), rect.width() / 2.0 );
}

//todo: create polyline for real ellises
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfpaintengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class QgsDxfExport;
class QgsDxfPaintDevice;
class QgsPoint;

class QgsDxfPaintEngine: public QPaintEngine
class CORE_EXPORT QgsDxfPaintEngine: public QPaintEngine
{
public:
QgsDxfPaintEngine( const QgsDxfPaintDevice* dxfDevice, QgsDxfExport* dxf );
Expand Down

0 comments on commit 668403a

Please sign in to comment.