Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dxf export: use half width texts and support transparent colors
  • Loading branch information
jef-n committed Oct 13, 2014
1 parent f3cf09f commit 4d72d72
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/core/dxf/qgsdxfexport.cpp
Expand Up @@ -366,7 +366,7 @@ void QgsDxfExport::writeGroup( int code, const QgsPoint &p, double z, bool skipz
writeGroup( code + 30, z );
}

void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode )
void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode, int transparencyCode )
{
int minDistAt = -1;
int minDist = INT_MAX;
Expand All @@ -390,6 +390,8 @@ void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode )
writeGroup( exactMatchCode, minDistAt );
int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
writeGroup( rgbCode, c );
if( transparencyCode != -1 && color.alpha() < 255 )
writeGroup( transparencyCode, 0x2000000 | color.alpha() );
}

void QgsDxfExport::writeGroupCode( int code )
Expand Down Expand Up @@ -606,6 +608,7 @@ void QgsDxfExport::writeTables()
writeGroup( 2, "VPORT" );
writeHandle();
writeGroup( 100, "AcDbSymbolTable" );

writeGroup( 70, 0 );
writeGroup( 0, "ENDTAB" );

Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfexport.h
Expand Up @@ -74,7 +74,7 @@ class CORE_EXPORT QgsDxfExport
void writeDouble( double d );
void writeString( const QString& s );
void writeGroup( int code, const QgsPoint &p, double z = 0.0, bool skipz = false );
void writeGroup( QColor color, int exactMatch = 62, int rgb = 420 );
void writeGroup( QColor color, int exactMatch = 62, int rgbCode = 420, int tranparencyCode = 440 );

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

Expand Down
8 changes: 4 additions & 4 deletions src/core/dxf/qgsdxfpallabeling.cpp
Expand Up @@ -89,16 +89,16 @@ void QgsDxfPalLabeling::drawLabel( pal::LabelPosition* label, QgsRenderContext&
{
line.append( QgsPoint( label->getX( i ), label->getY( i ) ) );
}
mDxfExport->writePolyline( line, mLayerName, "CONTINUOUS", 1, 0.01, true );
mDxfExport->writePolyline( line, g->dxfLayer(), "CONTINUOUS", 1, 0.01, true );
#endif
text = text.replace( tmpLyr.wrapChar.isEmpty() ? "\n" : tmpLyr.wrapChar, "\\P" );

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

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

0 comments on commit 4d72d72

Please sign in to comment.