Skip to content

Commit f98ecf7

Browse files
committedOct 31, 2013
Dxf color palette
1 parent 523f1e1 commit f98ecf7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎src/core/qgsdxfexport.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
QgsDxfExport::QgsDxfExport(): mSymbologyScaleDenominator( 1.0 ), mSymbologyExport( NoSymbology )
2727
{
28+
initColorPalette();
2829
}
2930

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

368369

369-
return 5; //todo...
370+
return 1; //todo...
370371
}
371372

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

405406
return abs( r1 - r2 ) + abs( g1 - g2 ) + abs( b1 - b2 ) + abs( a1 - a2 );
406407
}
408+
409+
void QgsDxfExport::initColorPalette()
410+
{
411+
mDxfColorPalette.resize( 256 );
412+
mDxfColorPalette[1] = qRgb( 255, 0, 0 );
413+
mDxfColorPalette[2] = qRgb( 255, 255, 0 );
414+
mDxfColorPalette[3] = qRgb( 0, 255, 0 );
415+
mDxfColorPalette[4] = qRgb( 0, 255, 255 );
416+
mDxfColorPalette[5] = qRgb( 0, 0, 255 );
417+
mDxfColorPalette[6] = qRgb( 255, 0, 255 );
418+
mDxfColorPalette[7] = qRgb( 255, 255, 255 );
419+
mDxfColorPalette[8] = qRgb( 255, 255, 255 );
420+
mDxfColorPalette[9] = qRgb( 255, 255, 255 );
421+
}

‎src/core/qgsdxfexport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class QgsDxfExport
5858
double mSymbologyScaleDenominator;
5959
SymbologyExport mSymbologyExport;
6060

61+
QVector<QRgb> mDxfColorPalette;
62+
6163
void writeHeader( QTextStream& stream );
6264
void writeTables( QTextStream& stream );
6365
void writeEntities( QTextStream& stream );
@@ -81,6 +83,7 @@ class QgsDxfExport
8183
double widthFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer );
8284

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

0 commit comments

Comments
 (0)
Please sign in to comment.