@@ -418,7 +418,6 @@ void QgsDxfExport::writeGroup( int code, const QgsPoint &p, double z, bool skipz
418
418
419
419
void QgsDxfExport::writeGroup ( QColor color, int exactMatchCode, int rgbCode, int transparencyCode )
420
420
{
421
- #if 0
422
421
int minDistAt = -1 ;
423
422
int minDist = INT_MAX;
424
423
@@ -432,13 +431,12 @@ void QgsDxfExport::writeGroup( QColor color, int exactMatchCode, int rgbCode, in
432
431
minDist = dist;
433
432
}
434
433
435
- writeGroup( exactMatchCode, minDistAt );
436
- if ( minDist == 0 && color.alpha() == 255 )
434
+ if ( minDist == 0 && color.alpha () == 255 && minDistAt != 7 )
437
435
{
438
- // exact full opaque match
436
+ // exact full opaque match, not black/white
437
+ writeGroup ( exactMatchCode, minDistAt );
439
438
return ;
440
439
}
441
- #endif
442
440
443
441
int c = ( color.red () & 0xff ) * 0x10000 + ( color.green () & 0xff ) * 0x100 + ( color.blue () & 0xff );
444
442
writeGroup ( rgbCode, c );
@@ -482,10 +480,8 @@ int QgsDxfExport::writeToFile( QIODevice* d, QString encoding )
482
480
}
483
481
484
482
mTextStream .setDevice ( d );
485
- QgsDebugMsg ( " encoding:" + encoding );
486
483
mTextStream .setCodec ( encoding.toLocal8Bit () );
487
484
488
- QgsDebugMsg ( " dxfEncoding:" + dxfEncoding ( encoding ) );
489
485
writeHeader ( dxfEncoding ( encoding ) );
490
486
writeTables ();
491
487
writeBlocks ();
@@ -506,7 +502,7 @@ void QgsDxfExport::writeHeader( QString codepage )
506
502
writeGroup ( 9 , " $ACADVER" );
507
503
writeGroup ( 1 , " AC1015" );
508
504
509
- QgsRectangle ext = dxfExtent ();
505
+ QgsRectangle ext ( mExtent . isEmpty () ? dxfExtent () : mExtent );
510
506
if ( !ext.isEmpty () )
511
507
{
512
508
// EXTMIN
@@ -666,46 +662,44 @@ void QgsDxfExport::writeTables()
666
662
writeHandle ();
667
663
writeGroup ( 100 , " AcDbSymbolTable" );
668
664
669
- #if 0
670
- QgsRectangle ext( dxfExtent() );
665
+ QgsRectangle ext ( mExtent .isEmpty () ? dxfExtent () : mExtent );
671
666
672
667
writeGroup ( 0 , " VPORT" );
673
668
writeHandle ();
674
669
writeGroup ( 100 , " AcDbSymbolTableRecord" );
675
670
writeGroup ( 100 , " AcDbViewportTableRecord" );
676
671
writeGroup ( 2 , " *ACTIVE" );
677
672
writeGroup ( 70 , 0 ); // flags
678
- writeGroup( 0, QgsPoint( ext.xMinimum(), ext.yMinimum() ) ); // lower-left corner
679
- writeGroup( 1, QgsPoint( ext.xMaximum(), ext.yMaximum() ) ); // upper right corner
680
- writeGroup( 2, ext.center() ); // view center point
681
- writeGroup( 3, QgsPoint( 0.0, 0.0 ) ); // snap base point
682
- writeGroup( 4, QgsPoint( 0.5, 0.5 ) ); // snap spacing x/y
683
- writeGroup( 5, QgsPoint( 0.5, 0.5 ) ); // grid spacing x/y
684
- writeGroup( 6, QgsPoint( 0.0, 0.0 ), 1.0, false ); // view direction from target point
685
- writeGroup( 7, QgsPoint( 0.0, 0.0 ), 0.0, false ); // view target point
686
- writeGroup( 40, 10.0 ); // ?
687
- writeGroup( 42, 50.0 ); // lens length
688
- writeGroup( 43, 0.0 ); // front clipping plan
689
- writeGroup( 44, 0.0 ); // back clipping plan
690
- writeGroup( 50, 0.0 ); // snap rotation angle
691
- writeGroup( 51, 0.0 ); // view twist angle
692
- writeGroup( 71, 0 ); // view mode
693
- writeGroup( 72, 1000 ); // circle sides
694
- writeGroup( 73, 1 ); // ?
695
- writeGroup( 74, 3 ); // UCSICON setting
696
- writeGroup( 75, 0 ); // ?
697
- writeGroup( 76, 0 ); // ?
698
- writeGroup( 77, 0 ); // ?
699
- writeGroup( 78, 0 ); // ?
700
- writeGroup( 281, 0 ); // Render mode (2D)
701
- writeGroup( 100, QgsPoint( 0.0, 0.0 ), 0.0, false ); // UCS origin
702
- writeGroup( 101, QgsPoint( 1.0, 0.0 ), 0.0, false ); // UCS x axis
703
- writeGroup( 102, QgsPoint( 0.0, 1.0 ), 0.0, false ); // UCS y axis
704
- writeGroup( 79, 0 ); // Orthographic type of UCS (not orthographic)
705
- writeGroup( 146, 0.0 ); // elevation
706
- writeGroup( 60, 3 ); // ?
707
- writeGroup( 61, 5 ); // major grid line
708
- #endif
673
+ writeGroup ( 0 , QgsPoint ( 0.0 , 0.0 ), 0.0 , true ); // lower left
674
+ writeGroup ( 1 , QgsPoint ( 1.0 , 1.0 ), 0.0 , true ); // upper right
675
+ writeGroup ( 2 , QgsPoint ( 0.0 , 0.0 ), 0.0 , true ); // view center point
676
+ writeGroup ( 3 , QgsPoint ( 0.0 , 0.0 ), 0.0 , true ); // snap base point
677
+ writeGroup ( 4 , QgsPoint ( 1.0 , 1.0 ), 0.0 , true ); // snap spacing
678
+ writeGroup ( 5 , QgsPoint ( 1.0 , 1.0 ), 0.0 , true ); // grid spacing
679
+ writeGroup ( 6 , QgsPoint ( 0.0 , 0.0 ), 1.0 ); // view direction from target point
680
+ writeGroup ( 7 , ext.center (), 0.0 , true ); // view target point
681
+ writeGroup ( 40 , ext.height () ); // view height
682
+ writeGroup ( 41 , ext.width () / ext.height () ); // view aspect ratio
683
+ writeGroup ( 42 , 50.0 ); // lens length
684
+ writeGroup ( 43 , 0.0 ); // front clipping plane
685
+ writeGroup ( 44 , 0.0 ); // back clipping plane
686
+ writeGroup ( 50 , 0.0 ); // snap rotation
687
+ writeGroup ( 51 , 0.0 ); // view twist angle
688
+ writeGroup ( 71 , 0 ); // view mode (0 = deactivates)
689
+ writeGroup ( 72 , 100 ); // circle zoom percent
690
+ writeGroup ( 73 , 1 ); // fast zoom setting
691
+ writeGroup ( 74 , 1 ); // UCSICON setting
692
+ writeGroup ( 75 , 0 ); // snapping off
693
+ writeGroup ( 76 , 0 ); // grid off
694
+ writeGroup ( 77 , 0 ); // snap style
695
+ writeGroup ( 78 , 0 ); // snap isopair
696
+ writeGroup ( 281 , 0 ); // render mode (0 = 2D optimized)
697
+ writeGroup ( 65 , 1 ); // value of UCSVP for this viewport
698
+ writeGroup ( 100 , QgsPoint ( 0.0 , 0.0 ) ); // UCS origin
699
+ writeGroup ( 101 , QgsPoint ( 1.0 , 0.0 ) ); // UCS x axis
700
+ writeGroup ( 102 , QgsPoint ( 0.0 , 1.0 ) ); // UCS y axis
701
+ writeGroup ( 79 , 0 ); // Orthographic type of UCS (0 = UCS is not orthographic)
702
+ writeGroup ( 146 , 0.0 ); // Elevation
709
703
710
704
writeGroup ( 70 , 0 );
711
705
writeGroup ( 0 , " ENDTAB" );
@@ -3369,22 +3363,21 @@ void QgsDxfExport::writePolyline( const QgsPolyline& line, const QString& layer,
3369
3363
3370
3364
void QgsDxfExport::writePolygon ( const QgsPolygon& polygon, const QString& layer, const QString& hatchPattern, QColor color )
3371
3365
{
3372
- writeGroup ( 0 , " HATCH" ); // Entity type
3366
+ writeGroup ( 0 , " HATCH" ); // Entity type
3373
3367
writeHandle ();
3374
3368
writeGroup ( 330 , mModelSpaceBR );
3375
3369
writeGroup ( 100 , " AcDbEntity" );
3370
+ writeGroup ( 8 , layer ); // Layer name
3371
+ writeGroup ( color ); // Color
3376
3372
writeGroup ( 100 , " AcDbHatch" );
3377
3373
3378
- writeGroup ( 8 , layer ); // Layer name
3379
- writeGroup ( 0 , QgsPoint ( 0 , 0 ) ); // Elevation point (in OCS)
3374
+ writeGroup ( 0 , QgsPoint ( 0 , 0 ) ); // Elevation point (in OCS)
3380
3375
writeGroup ( 200 , QgsPoint ( 0 , 0 ), 1.0 );
3381
3376
3382
3377
writeGroup ( 2 , hatchPattern ); // Hatch pattern name
3383
3378
writeGroup ( 70 , hatchPattern == " SOLID" ); // Solid fill flag (solid fill = 1; pattern fill = 0)
3384
3379
writeGroup ( 71 , 0 ); // Associativity flag (associative = 1; non-associative = 0)
3385
3380
3386
- writeGroup ( color ); // Color (0 by block, 256 by layer)
3387
-
3388
3381
writeGroup ( 91 , polygon.size () ); // Number of boundary paths (loops)
3389
3382
for ( int i = 0 ; i < polygon.size (); ++i )
3390
3383
{
@@ -3520,10 +3513,6 @@ void QgsDxfExport::writeMText( const QString& layer, const QString& text, const
3520
3513
3521
3514
writeGroup ( 0 , pt );
3522
3515
3523
- QgsDebugMsg ( QString ( " text:%1" ).arg ( text ) );
3524
- QgsDebugMsg ( QString ( " canEncode:%1" ).arg ( mTextStream .codec ()->canEncode ( text ) ? " yes" : " no" ) );
3525
- QgsDebugMsg ( QString ( " fromUnicode:%1" ).arg ( mTextStream .codec ()->fromUnicode ( text ).constData () ) );
3526
-
3527
3516
QString t ( text );
3528
3517
while ( t.length () > 250 )
3529
3518
{
0 commit comments