Skip to content
Permalink
Browse files

dxf export: use half width texts and support transparent colors

  • Loading branch information
jef-n committed Oct 13, 2014
1 parent f3cf09f commit 4d72d721e82882a27ffb90d30c286a08b83c6a6c
Showing with 9 additions and 6 deletions.
  1. +4 −1 src/core/dxf/qgsdxfexport.cpp
  2. +1 −1 src/core/dxf/qgsdxfexport.h
  3. +4 −4 src/core/dxf/qgsdxfpallabeling.cpp
@@ -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;
@@ -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 )
@@ -606,6 +608,7 @@ void QgsDxfExport::writeTables()
writeGroup( 2, "VPORT" );
writeHandle();
writeGroup( 100, "AcDbSymbolTable" );

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

@@ -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 );

@@ -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.
You can’t perform that action at this time.