Skip to content

Commit 4d72d72

Browse files
committedOct 13, 2014
dxf export: use half width texts and support transparent colors
1 parent f3cf09f commit 4d72d72

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed
 

‎src/core/dxf/qgsdxfexport.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void QgsDxfExport::writeGroup( int code, const QgsPoint &p, double z, bool skipz
366366
writeGroup( code + 30, z );
367367
}
368368

369-
void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode )
369+
void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode, int transparencyCode )
370370
{
371371
int minDistAt = -1;
372372
int minDist = INT_MAX;
@@ -390,6 +390,8 @@ void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode )
390390
writeGroup( exactMatchCode, minDistAt );
391391
int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
392392
writeGroup( rgbCode, c );
393+
if( transparencyCode != -1 && color.alpha() < 255 )
394+
writeGroup( transparencyCode, 0x2000000 | color.alpha() );
393395
}
394396

395397
void QgsDxfExport::writeGroupCode( int code )
@@ -606,6 +608,7 @@ void QgsDxfExport::writeTables()
606608
writeGroup( 2, "VPORT" );
607609
writeHandle();
608610
writeGroup( 100, "AcDbSymbolTable" );
611+
609612
writeGroup( 70, 0 );
610613
writeGroup( 0, "ENDTAB" );
611614

‎src/core/dxf/qgsdxfexport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class CORE_EXPORT QgsDxfExport
7474
void writeDouble( double d );
7575
void writeString( const QString& s );
7676
void writeGroup( int code, const QgsPoint &p, double z = 0.0, bool skipz = false );
77-
void writeGroup( QColor color, int exactMatch = 62, int rgb = 420 );
77+
void writeGroup( QColor color, int exactMatch = 62, int rgbCode = 420, int tranparencyCode = 440 );
7878

7979
int writeHandle( int code = 5, int handle = 0 );
8080

‎src/core/dxf/qgsdxfpallabeling.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ void QgsDxfPalLabeling::drawLabel( pal::LabelPosition* label, QgsRenderContext&
8989
{
9090
line.append( QgsPoint( label->getX( i ), label->getY( i ) ) );
9191
}
92-
mDxfExport->writePolyline( line, mLayerName, "CONTINUOUS", 1, 0.01, true );
92+
mDxfExport->writePolyline( line, g->dxfLayer(), "CONTINUOUS", 1, 0.01, true );
9393
#endif
9494
text = text.replace( tmpLyr.wrapChar.isEmpty() ? "\n" : tmpLyr.wrapChar, "\\P" );
9595

96-
text.prepend( QString( "\\f%1|i%2|b%3;\\H%4;" )
96+
text.prepend( QString( "\\f%1|i%2|b%3;\\H%4;\\W0.5;" )
9797
.arg( tmpLyr.textFont.family() )
9898
.arg( tmpLyr.textFont.italic() ? 1 : 0 )
9999
.arg( tmpLyr.textFont.bold() ? 1 : 0 )
100-
.arg( label->getHeight() / ( 1 + text.count( "\\P" ) ) ) );
100+
.arg( label->getHeight() / ( 1 + text.count( "\\P" ) ) * 0.75 ) );
101101

102-
mDxfExport->writeMText( g->dxfLayer(), text, QgsPoint( label->getX(), label->getY() ), label->getWidth(), angle, tmpLyr.textColor );
102+
mDxfExport->writeMText( g->dxfLayer(), text, QgsPoint( label->getX(), label->getY() ), label->getWidth() * 1.1, angle, tmpLyr.textColor );
103103
}
104104
}

0 commit comments

Comments
 (0)
Please sign in to comment.