Skip to content
Permalink
Browse files

Dxf color palette

  • Loading branch information
mhugent committed Oct 31, 2013
1 parent 523f1e1 commit f98ecf753fca68d81cd389a5a96cf2c7c3fb2bcf
Showing with 19 additions and 1 deletion.
  1. +16 −1 src/core/qgsdxfexport.cpp
  2. +3 −0 src/core/qgsdxfexport.h
@@ -25,6 +25,7 @@

QgsDxfExport::QgsDxfExport(): mSymbologyScaleDenominator( 1.0 ), mSymbologyExport( NoSymbology )
{
initColorPalette();
}

QgsDxfExport::~QgsDxfExport()
@@ -366,7 +367,7 @@ int QgsDxfExport::colorFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer )
}


return 5; //todo...
return 1; //todo...
}

double QgsDxfExport::widthFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer )
@@ -404,3 +405,17 @@ int QgsDxfExport::pixel_distance( QRgb p1, QRgb p2 )

return abs( r1 - r2 ) + abs( g1 - g2 ) + abs( b1 - b2 ) + abs( a1 - a2 );
}

void QgsDxfExport::initColorPalette()
{
mDxfColorPalette.resize( 256 );
mDxfColorPalette[1] = qRgb( 255, 0, 0 );
mDxfColorPalette[2] = qRgb( 255, 255, 0 );
mDxfColorPalette[3] = qRgb( 0, 255, 0 );
mDxfColorPalette[4] = qRgb( 0, 255, 255 );
mDxfColorPalette[5] = qRgb( 0, 0, 255 );
mDxfColorPalette[6] = qRgb( 255, 0, 255 );
mDxfColorPalette[7] = qRgb( 255, 255, 255 );
mDxfColorPalette[8] = qRgb( 255, 255, 255 );
mDxfColorPalette[9] = qRgb( 255, 255, 255 );
}
@@ -58,6 +58,8 @@ class QgsDxfExport
double mSymbologyScaleDenominator;
SymbologyExport mSymbologyExport;

QVector<QRgb> mDxfColorPalette;

void writeHeader( QTextStream& stream );
void writeTables( QTextStream& stream );
void writeEntities( QTextStream& stream );
@@ -81,6 +83,7 @@ class QgsDxfExport
double widthFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer );

//functions for dxf palette
void initColorPalette();
static int closestMatch( QRgb pixel, const QVector<QRgb>& palette );
static int pixel_distance( QRgb p1, QRgb p2 );

0 comments on commit f98ecf7

Please sign in to comment.
You can’t perform that action at this time.