QGIS API Documentation  2.17.0-Master (8784312)
qgsdxfexport.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdxfexport.cpp
3  ----------------
4  begin : September 2013
5  copyright : (C) 2013 by Marco Hugentobler
6  email : marco at sourcepole dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 // Specs:
19 // AutoCAD 2000: http://www.autodesk.com/techpubs/autocad/acad2000/dxf/
20 // AutoCAD 2002: http://www.autodesk.com/techpubs/autocad/dxf/dxf2002.pdf
21 // AutoCAD 2004: http://atrey.karlin.mff.cuni.cz/projekty/vrr/doc/dxf14.pdf
22 // AutoCAD 2006: http://images.autodesk.com/adsk/files/dxf_format.pdf
23 // AutoCAD 2008: http://images.autodesk.com/adsk/files/acad_dxf0.pdf
24 // AutoCAD 2009: http://images.autodesk.com/adsk/files/acad_dxf.pdf
25 // AutoCAD 2011: http://images.autodesk.com/adsk/files/acad_dxf2.pdf
26 // AutoCAD 2012: http://images.autodesk.com/adsk/files/autocad_2012_pdf_dxf-reference_enu.pdf
27 // AutoCAD 2014: http://images.autodesk.com/adsk/files/autocad_2014_pdf_dxf_reference_enu.pdf
28 
29 #include "qgsdxfexport.h"
30 #include "qgsdxfpallabeling.h"
31 #include "qgsvectordataprovider.h"
32 #include "qgspoint.h"
33 #include "qgsrendererv2.h"
34 #include "qgssymbollayerv2.h"
35 #include "qgsfillsymbollayerv2.h"
36 #include "qgslinesymbollayerv2.h"
37 #include "qgsvectorlayer.h"
38 #include "qgsmaplayerregistry.h"
39 #include "qgsunittypes.h"
40 #include "qgstextlabelfeature.h"
41 
42 #include "qgswkbtypes.h"
43 #include "qgspointv2.h"
44 #include "qgsgeos.h"
45 
46 #include "pal/feature.h"
47 #include "pal/pointset.h"
48 #include "pal/labelposition.h"
49 
50 #include <QIODevice>
51 
52 #define DXF_HANDSEED 100
53 #define DXF_HANDMAX 9999999
54 #define DXF_HANDPLOTSTYLE 0xf
55 
56 // dxf color palette
57 int QgsDxfExport::mDxfColors[][3] =
58 {
59  { 255, 255, 255 },
60  { 255, 0, 0 },
61  { 255, 255, 0 },
62  { 0, 255, 0 },
63  { 0, 255, 255 },
64  { 0, 0, 255 },
65  { 255, 0, 255 },
66  { 0, 0, 0 },
67  { 128, 128, 128 },
68  { 192, 192, 192 },
69  { 255, 0, 0 },
70  { 255, 127, 127 },
71  { 204, 0, 0 },
72  { 204, 102, 102 },
73  { 153, 0, 0 },
74  { 153, 76, 76 },
75  { 127, 0, 0 },
76  { 127, 63, 63 },
77  { 76, 0, 0 },
78  { 76, 38, 38 },
79  { 255, 63, 0 },
80  { 255, 159, 127 },
81  { 204, 51, 0 },
82  { 204, 127, 102 },
83  { 153, 38, 0 },
84  { 153, 95, 76 },
85  { 127, 31, 0 },
86  { 127, 79, 63 },
87  { 76, 19, 0 },
88  { 76, 47, 38 },
89  { 255, 127, 0 },
90  { 255, 191, 127 },
91  { 204, 102, 0 },
92  { 204, 153, 102 },
93  { 153, 76, 0 },
94  { 153, 114, 76 },
95  { 127, 63, 0 },
96  { 127, 95, 63 },
97  { 76, 38, 0 },
98  { 76, 57, 38 },
99  { 255, 191, 0 },
100  { 255, 223, 127 },
101  { 204, 153, 0 },
102  { 204, 178, 102 },
103  { 153, 114, 0 },
104  { 153, 133, 76 },
105  { 127, 95, 0 },
106  { 127, 111, 63 },
107  { 76, 57, 0 },
108  { 76, 66, 38 },
109  { 255, 255, 0 },
110  { 255, 255, 127 },
111  { 204, 204, 0 },
112  { 204, 204, 102 },
113  { 153, 153, 0 },
114  { 153, 153, 76 },
115  { 127, 127, 0 },
116  { 127, 127, 63 },
117  { 76, 76, 0 },
118  { 76, 76, 38 },
119  { 191, 255, 0 },
120  { 223, 255, 127 },
121  { 153, 204, 0 },
122  { 178, 204, 102 },
123  { 114, 153, 0 },
124  { 133, 153, 76 },
125  { 95, 127, 0 },
126  { 111, 127, 63 },
127  { 57, 76, 0 },
128  { 66, 76, 38 },
129  { 127, 255, 0 },
130  { 191, 255, 127 },
131  { 102, 204, 0 },
132  { 153, 204, 102 },
133  { 76, 153, 0 },
134  { 114, 153, 76 },
135  { 63, 127, 0 },
136  { 95, 127, 63 },
137  { 38, 76, 0 },
138  { 57, 76, 38 },
139  { 63, 255, 0 },
140  { 159, 255, 127 },
141  { 51, 204, 0 },
142  { 127, 204, 102 },
143  { 38, 153, 0 },
144  { 95, 153, 76 },
145  { 31, 127, 0 },
146  { 79, 127, 63 },
147  { 19, 76, 0 },
148  { 47, 76, 38 },
149  { 0, 255, 0 },
150  { 127, 255, 127 },
151  { 0, 204, 0 },
152  { 102, 204, 102 },
153  { 0, 153, 0 },
154  { 76, 153, 76 },
155  { 0, 127, 0 },
156  { 63, 127, 63 },
157  { 0, 76, 0 },
158  { 38, 76, 38 },
159  { 0, 255, 63 },
160  { 127, 255, 159 },
161  { 0, 204, 51 },
162  { 102, 204, 127 },
163  { 0, 153, 38 },
164  { 76, 153, 95 },
165  { 0, 127, 31 },
166  { 63, 127, 79 },
167  { 0, 76, 19 },
168  { 38, 76, 47 },
169  { 0, 255, 127 },
170  { 127, 255, 191 },
171  { 0, 204, 102 },
172  { 102, 204, 153 },
173  { 0, 153, 76 },
174  { 76, 153, 114 },
175  { 0, 127, 63 },
176  { 63, 127, 95 },
177  { 0, 76, 38 },
178  { 38, 76, 57 },
179  { 0, 255, 191 },
180  { 127, 255, 223 },
181  { 0, 204, 153 },
182  { 102, 204, 178 },
183  { 0, 153, 114 },
184  { 76, 153, 133 },
185  { 0, 127, 95 },
186  { 63, 127, 111 },
187  { 0, 76, 57 },
188  { 38, 76, 66 },
189  { 0, 255, 255 },
190  { 127, 255, 255 },
191  { 0, 204, 204 },
192  { 102, 204, 204 },
193  { 0, 153, 153 },
194  { 76, 153, 153 },
195  { 0, 127, 127 },
196  { 63, 127, 127 },
197  { 0, 76, 76 },
198  { 38, 76, 76 },
199  { 0, 191, 255 },
200  { 127, 223, 255 },
201  { 0, 153, 204 },
202  { 102, 178, 204 },
203  { 0, 114, 153 },
204  { 76, 133, 153 },
205  { 0, 95, 127 },
206  { 63, 111, 127 },
207  { 0, 57, 76 },
208  { 38, 66, 76 },
209  { 0, 127, 255 },
210  { 127, 191, 255 },
211  { 0, 102, 204 },
212  { 102, 153, 204 },
213  { 0, 76, 153 },
214  { 76, 114, 153 },
215  { 0, 63, 127 },
216  { 63, 95, 127 },
217  { 0, 38, 76 },
218  { 38, 57, 76 },
219  { 0, 63, 255 },
220  { 127, 159, 255 },
221  { 0, 51, 204 },
222  { 102, 127, 204 },
223  { 0, 38, 153 },
224  { 76, 95, 153 },
225  { 0, 31, 127 },
226  { 63, 79, 127 },
227  { 0, 19, 76 },
228  { 38, 47, 76 },
229  { 0, 0, 255 },
230  { 127, 127, 255 },
231  { 0, 0, 204 },
232  { 102, 102, 204 },
233  { 0, 0, 153 },
234  { 76, 76, 153 },
235  { 0, 0, 127 },
236  { 63, 63, 127 },
237  { 0, 0, 76 },
238  { 38, 38, 76 },
239  { 63, 0, 255 },
240  { 159, 127, 255 },
241  { 51, 0, 204 },
242  { 127, 102, 204 },
243  { 38, 0, 153 },
244  { 95, 76, 153 },
245  { 31, 0, 127 },
246  { 79, 63, 127 },
247  { 19, 0, 76 },
248  { 47, 38, 76 },
249  { 127, 0, 255 },
250  { 191, 127, 255 },
251  { 102, 0, 204 },
252  { 153, 102, 204 },
253  { 76, 0, 153 },
254  { 114, 76, 153 },
255  { 63, 0, 127 },
256  { 95, 63, 127 },
257  { 38, 0, 76 },
258  { 57, 38, 76 },
259  { 191, 0, 255 },
260  { 223, 127, 255 },
261  { 153, 0, 204 },
262  { 178, 102, 204 },
263  { 114, 0, 153 },
264  { 133, 76, 153 },
265  { 95, 0, 127 },
266  { 111, 63, 127 },
267  { 57, 0, 76 },
268  { 66, 38, 76 },
269  { 255, 0, 255 },
270  { 255, 127, 255 },
271  { 204, 0, 204 },
272  { 204, 102, 204 },
273  { 153, 0, 153 },
274  { 153, 76, 153 },
275  { 127, 0, 127 },
276  { 127, 63, 127 },
277  { 76, 0, 76 },
278  { 76, 38, 76 },
279  { 255, 0, 191 },
280  { 255, 127, 223 },
281  { 204, 0, 153 },
282  { 204, 102, 178 },
283  { 153, 0, 114 },
284  { 153, 76, 133 },
285  { 127, 0, 95 },
286  { 127, 63, 111 },
287  { 76, 0, 57 },
288  { 76, 38, 66 },
289  { 255, 0, 127 },
290  { 255, 127, 191 },
291  { 204, 0, 102 },
292  { 204, 102, 153 },
293  { 153, 0, 76 },
294  { 153, 76, 114 },
295  { 127, 0, 63 },
296  { 127, 63, 95 },
297  { 76, 0, 38 },
298  { 76, 38, 57 },
299  { 255, 0, 63 },
300  { 255, 127, 159 },
301  { 204, 0, 51 },
302  { 204, 102, 127 },
303  { 153, 0, 38 },
304  { 153, 76, 95 },
305  { 127, 0, 31 },
306  { 127, 63, 79 },
307  { 76, 0, 19 },
308  { 76, 38, 47 },
309  { 51, 51, 51 },
310  { 91, 91, 91 },
311  { 132, 132, 132 },
312  { 173, 173, 173 },
313  { 214, 214, 214 },
314  { 255, 255, 255 },
315 };
316 
317 const char *QgsDxfExport::mDxfEncodings[][2] =
318 {
319  { "ASCII", "" },
320  { "8859_1", "ISO-8859-1" },
321  { "8859_2", "ISO-8859-2" },
322  { "8859_3", "ISO-8859-3" },
323  { "8859_4", "ISO-8859-4" },
324  { "8859_5", "ISO-8859-5" },
325  { "8859_6", "ISO-8859-6" },
326  { "8859_7", "ISO-8859-7" },
327  { "8859_8", "ISO-8859-8" },
328  { "8859_9", "ISO-8859-9" },
329 // { "DOS437", "" },
330  { "DOS850", "CP850" },
331 // { "DOS852", "" },
332 // { "DOS855", "" },
333 // { "DOS857", "" },
334 // { "DOS860", "" },
335 // { "DOS861", "" },
336 // { "DOS863", "" },
337 // { "DOS864", "" },
338 // { "DOS865", "" },
339 // { "DOS869", "" },
340 // { "DOS932", "" },
341  { "MACINTOSH", "MacRoman" },
342  { "BIG5", "Big5" },
343  { "KSC5601", "ksc5601.1987-0" },
344 // { "JOHAB", "" },
345  { "DOS866", "CP866" },
346  { "ANSI_1250", "CP1250" },
347  { "ANSI_1251", "CP1251" },
348  { "ANSI_1252", "CP1252" },
349  { "GB2312", "GB2312" },
350  { "ANSI_1253", "CP1253" },
351  { "ANSI_1254", "CP1254" },
352  { "ANSI_1255", "CP1255" },
353  { "ANSI_1256", "CP1256" },
354  { "ANSI_1257", "CP1257" },
355  { "ANSI_874", "CP874" },
356  { "ANSI_932", "Shift_JIS" },
357  { "ANSI_936", "CP936" },
358  { "ANSI_949", "cp949" },
359  { "ANSI_950", "CP950" },
360 // { "ANSI_1361", "" },
361 // { "ANSI_1200", "" },
362  { "ANSI_1258", "CP1258" },
363 };
364 
366  : mSymbologyScaleDenominator( 1.0 )
367  , mSymbologyExport( NoSymbology )
368  , mMapUnits( QGis::Meters )
369  , mLayerTitleAsName( false )
370  , mSymbolLayerCounter( 0 )
371  , mNextHandleId( DXF_HANDSEED )
372  , mBlockCounter( 0 )
373 {
374 }
375 
377 {
378  *this = dxfExport;
379 }
380 
382 {
383  mLayers = dxfExport.mLayers;
384  mSymbologyScaleDenominator = dxfExport.mSymbologyScaleDenominator;
385  mSymbologyExport = dxfExport.mSymbologyExport;
386  mMapUnits = dxfExport.mMapUnits;
387  mLayerTitleAsName = dxfExport.mLayerTitleAsName;
388  mSymbolLayerCounter = 0; // internal counter
389  mNextHandleId = 0;
390  mBlockCounter = 0;
391  return *this;
392 }
393 
395 {
396 }
397 
399 {
400  mLayers = layers;
401 }
402 
403 void QgsDxfExport::writeGroup( int code, int i )
404 {
405  writeGroupCode( code );
406  writeInt( i );
407 }
408 
409 void QgsDxfExport::writeGroup( int code, double d )
410 {
411  writeGroupCode( code );
412  writeDouble( d );
413 }
414 
415 void QgsDxfExport::writeGroup( int code, const QString& s )
416 {
417  writeGroupCode( code );
418  writeString( s );
419 }
420 
421 void QgsDxfExport::writeGroup( int code, const QgsPoint &p, double z, bool skipz )
422 {
423  writeGroup( code + 10, p.x() );
424  writeGroup( code + 20, p.y() );
425  if ( !skipz )
426  writeGroup( code + 30, z );
427 }
428 
429 void QgsDxfExport::writeGroup( int code, const QgsPointV2 &p )
430 {
431  writeGroup( code + 10, p.x() );
432  writeGroup( code + 20, p.y() );
433  if ( p.is3D() )
434  writeGroup( code + 30, p.z() );
435 }
436 
437 void QgsDxfExport::writeGroup( const QColor& color, int exactMatchCode, int rgbCode, int transparencyCode )
438 {
439  int minDistAt = -1;
440  int minDist = INT_MAX;
441 
442  for ( int i = 1; i < static_cast< int >( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ) && minDist > 0; ++i )
443  {
444  int dist = color_distance( color.rgba(), i );
445  if ( dist >= minDist )
446  continue;
447 
448  minDistAt = i;
449  minDist = dist;
450  }
451 
452  if ( minDist == 0 && color.alpha() == 255 && minDistAt != 7 )
453  {
454  // exact full opaque match, not black/white
455  writeGroup( exactMatchCode, minDistAt );
456  return;
457  }
458 
459  int c = ( color.red() & 0xff ) * 0x10000 + ( color.green() & 0xff ) * 0x100 + ( color.blue() & 0xff );
460  writeGroup( rgbCode, c );
461  if ( transparencyCode != -1 && color.alpha() < 255 )
462  writeGroup( transparencyCode, 0x2000000 | color.alpha() );
463 }
464 
466 {
467  mTextStream << QString( "%1\n" ).arg( code, 3, 10, QChar( ' ' ) );
468 }
469 
471 {
472  mTextStream << QString( "%1\n" ).arg( i, 6, 10, QChar( ' ' ) );
473 }
474 
476 {
477  QString s( qgsDoubleToString( d ) );
478  if ( !s.contains( '.' ) )
479  s += ".0";
480  mTextStream << s << '\n';
481 }
482 
484 {
485  mTextStream << s << '\n';
486 }
487 
488 int QgsDxfExport::writeToFile( QIODevice* d, const QString& encoding )
489 {
490  if ( !d )
491  {
492  return 1;
493  }
494 
495  if ( !d->isOpen() && !d->open( QIODevice::WriteOnly ) )
496  {
497  return 2;
498  }
499 
500  mTextStream.setDevice( d );
501  mTextStream.setCodec( encoding.toLocal8Bit() );
502 
503  writeHeader( dxfEncoding( encoding ) );
504  writeTables();
505  writeBlocks();
506  writeEntities();
507  writeEndFile();
508 
509  return 0;
510 }
511 
512 void QgsDxfExport::writeHeader( const QString& codepage )
513 {
514  writeGroup( 999, "DXF created from QGIS" );
515 
516  startSection();
517  writeGroup( 2, "HEADER" );
518 
519  // ACADVER
520  writeGroup( 9, "$ACADVER" );
521  writeGroup( 1, "AC1015" );
522 
523  QgsRectangle ext( mExtent.isEmpty() ? dxfExtent() : mExtent );
524  if ( !ext.isEmpty() )
525  {
526  // EXTMIN
527  writeGroup( 9, "$EXTMIN" );
528  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ, ext.xMinimum(), ext.yMinimum() ) );
529 
530  // EXTMAX
531  writeGroup( 9, "$EXTMAX" );
532  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ, ext.xMaximum(), ext.yMaximum() ) );
533  }
534 
535  // Global linetype scale
536  writeGroup( 9, "$LTSCALE" );
537  writeGroup( 40, 1.0 );
538 
539  // Point display mode (33 = circle)
540  writeGroup( 9, "$PDMODE" );
541  writeGroup( 70, 33 );
542 
543  // Point display size
544  writeGroup( 9, "$PDSIZE" );
545  writeGroup( 40, 1 );
546 
547  // Controls paper space linetype scaling (1 = No special linetype scaling, 0 = Viewport scaling governs linetype scaling)
548  writeGroup( 9, "$PSLTSCALE" );
549  writeGroup( 70, 0 );
550 
551  writeGroup( 9, "$HANDSEED" );
552  writeGroup( 5, DXF_HANDMAX );
553 
554  writeGroup( 9, "$DWGCODEPAGE" );
555  writeGroup( 3, codepage );
556 
557  endSection();
558 }
559 
560 int QgsDxfExport::writeHandle( int code, int handle )
561 {
562  if ( handle == 0 )
563  handle = mNextHandleId++;
564 
565  Q_ASSERT_X( handle < DXF_HANDMAX, "QgsDxfExport::writeHandle(int, int)", "DXF handle too large" );
566 
567  writeGroup( code, QString( "%1" ).arg( handle, 0, 16 ) );
568  return handle;
569 }
570 
571 void QgsDxfExport::writeTables()
572 {
573  startSection();
574  writeGroup( 2, "TABLES" );
575 
576  // Iterate through all layers and get symbol layer pointers
577  QgsRenderContext context = renderContext();
579  if ( mSymbologyExport != NoSymbology )
580  {
581  slList = symbolLayers( context );
582  }
583 
584  // Line types
585  mLineStyles.clear();
586  writeGroup( 0, "TABLE" );
587  writeGroup( 2, "LTYPE" );
588  writeHandle();
589  writeGroup( 100, "AcDbSymbolTable" );
590  writeGroup( 70, nLineTypes( slList ) + 5 );
591 
592  writeDefaultLinetypes();
593 
594  // Add custom linestyles
595  QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2*> >::const_iterator slIt = slList.constBegin();
596  for ( ; slIt != slList.constEnd(); ++slIt )
597  {
598  writeSymbolLayerLinetype( slIt->first );
599  }
600 
601  writeGroup( 0, "ENDTAB" );
602 
603  // BLOCK_RECORD
604  writeGroup( 0, "TABLE" );
605  writeGroup( 2, "BLOCK_RECORD" );
606  writeHandle();
607 
608  writeGroup( 100, "AcDbSymbolTable" );
609  writeGroup( 70, 0 );
610 
611  Q_FOREACH ( const QString& block, QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0" )
612  {
613  writeGroup( 0, "BLOCK_RECORD" );
614  mBlockHandles.insert( block, writeHandle() );
615  writeGroup( 100, "AcDbSymbolTableRecord" );
616  writeGroup( 100, "AcDbBlockTableRecord" );
617  writeGroup( 2, block );
618  }
619 
620  int i = 0;
621  slIt = slList.constBegin();
622  for ( ; slIt != slList.constEnd(); ++slIt )
623  {
624  QgsMarkerSymbolLayerV2 *ml = dynamic_cast< QgsMarkerSymbolLayerV2*>( slIt->first );
625  if ( !ml )
626  continue;
627 
628  if ( hasDataDefinedProperties( ml, slIt->second ) )
629  continue;
630 
631  QString name = QString( "symbolLayer%1" ).arg( i++ );
632  writeGroup( 0, "BLOCK_RECORD" );
633  mBlockHandles.insert( name, writeHandle() );
634  writeGroup( 100, "AcDbSymbolTableRecord" );
635  writeGroup( 100, "AcDbBlockTableRecord" );
636  writeGroup( 2, name );
637  }
638 
639  writeGroup( 0, "ENDTAB" );
640 
641  // APPID
642  writeGroup( 0, "TABLE" );
643  writeGroup( 2, "APPID" );
644  writeHandle();
645  writeGroup( 100, "AcDbSymbolTable" );
646  writeGroup( 70, 1 );
647  writeGroup( 0, "APPID" );
648  writeHandle();
649  writeGroup( 100, "AcDbSymbolTableRecord" );
650  writeGroup( 100, "AcDbRegAppTableRecord" );
651  writeGroup( 2, "ACAD" );
652  writeGroup( 70, 0 );
653  writeGroup( 0, "ENDTAB" );
654 
655  // VIEW
656  writeGroup( 0, "TABLE" );
657  writeGroup( 2, "VIEW" );
658  writeHandle();
659  writeGroup( 100, "AcDbSymbolTable" );
660  writeGroup( 70, 0 );
661  writeGroup( 0, "ENDTAB" );
662 
663  // UCS
664  writeGroup( 0, "TABLE" );
665  writeGroup( 2, "UCS" );
666  writeHandle();
667  writeGroup( 100, "AcDbSymbolTable" );
668  writeGroup( 70, 0 );
669  writeGroup( 0, "ENDTAB" );
670 
671  // VPORT
672  writeGroup( 0, "TABLE" );
673  writeGroup( 2, "VPORT" );
674  writeHandle();
675  writeGroup( 100, "AcDbSymbolTable" );
676 
677  QgsRectangle ext( mExtent.isEmpty() ? dxfExtent() : mExtent );
678 
679  writeGroup( 0, "VPORT" );
680  writeHandle();
681  writeGroup( 100, "AcDbSymbolTableRecord" );
682  writeGroup( 100, "AcDbViewportTableRecord" );
683  writeGroup( 2, "*ACTIVE" );
684  writeGroup( 70, 0 ); // flags
685  writeGroup( 0, QgsPointV2( 0.0, 0.0 ) ); // lower left
686  writeGroup( 1, QgsPointV2( 1.0, 1.0 ) ); // upper right
687  writeGroup( 2, QgsPointV2( 0.0, 0.0 ) ); // view center point
688  writeGroup( 3, QgsPointV2( 0.0, 0.0 ) ); // snap base point
689  writeGroup( 4, QgsPointV2( 1.0, 1.0 ) ); // snap spacing
690  writeGroup( 5, QgsPointV2( 1.0, 1.0 ) ); // grid spacing
691  writeGroup( 6, QgsPointV2( QgsWKBTypes::PointZ, 0.0, 0.0, 1.0 ) ); // view direction from target point
692  writeGroup( 7, QgsPointV2( ext.center() ) ); // view target point
693  writeGroup( 40, ext.height() ); // view height
694  writeGroup( 41, ext.width() / ext.height() ); // view aspect ratio
695  writeGroup( 42, 50.0 ); // lens length
696  writeGroup( 43, 0.0 ); // front clipping plane
697  writeGroup( 44, 0.0 ); // back clipping plane
698  writeGroup( 50, 0.0 ); // snap rotation
699  writeGroup( 51, 0.0 ); // view twist angle
700  writeGroup( 71, 0 ); // view mode (0 = deactivates)
701  writeGroup( 72, 100 ); // circle zoom percent
702  writeGroup( 73, 1 ); // fast zoom setting
703  writeGroup( 74, 1 ); // UCSICON setting
704  writeGroup( 75, 0 ); // snapping off
705  writeGroup( 76, 0 ); // grid off
706  writeGroup( 77, 0 ); // snap style
707  writeGroup( 78, 0 ); // snap isopair
708  writeGroup( 281, 0 ); // render mode (0 = 2D optimized)
709  writeGroup( 65, 1 ); // value of UCSVP for this viewport
710  writeGroup( 100, QgsPointV2( QgsWKBTypes::PointZ ) ); // UCS origin
711  writeGroup( 101, QgsPointV2( QgsWKBTypes::PointZ, 1.0 ) ); // UCS x axis
712  writeGroup( 102, QgsPointV2( QgsWKBTypes::PointZ, 0.0, 1.0 ) ); // UCS y axis
713  writeGroup( 79, 0 ); // Orthographic type of UCS (0 = UCS is not orthographic)
714  writeGroup( 146, 0.0 ); // Elevation
715 
716  writeGroup( 70, 0 );
717  writeGroup( 0, "ENDTAB" );
718 
719  // DIMSTYLE
720  writeGroup( 0, "TABLE" );
721  writeGroup( 2, "DIMSTYLE" );
722  writeHandle();
723  writeGroup( 100, "AcDbSymbolTable" );
724  writeGroup( 100, "AcDbDimStyleTable" );
725  writeGroup( 70, 0 );
726  writeGroup( 0, "ENDTAB" );
727 
728  QList< QPair<QgsVectorLayer*, int> >::const_iterator layerIt = mLayers.constBegin();
729  QSet<QString> layerNames;
730  for ( ; layerIt != mLayers.constEnd(); ++layerIt )
731  {
732  if ( !layerIsScaleBasedVisible( layerIt->first ) )
733  continue;
734 
735  if ( layerIt->first )
736  {
737  if ( layerIt->second < 0 )
738  {
739  layerNames << dxfLayerName( layerName( layerIt->first ) );
740  }
741  else
742  {
743  QList<QVariant> values;
744  layerIt->first->uniqueValues( layerIt->second, values );
745  Q_FOREACH ( const QVariant& v, values )
746  {
747  layerNames << dxfLayerName( v.toString() );
748  }
749  }
750  }
751  }
752 
753  // Layers
754  // TODO: iterate features of all layer to produce a data-defined layer list
755  writeGroup( 0, "TABLE" );
756  writeGroup( 2, "LAYER" );
757  writeHandle();
758  writeGroup( 100, "AcDbSymbolTable" );
759  writeGroup( 70, layerNames.size() + 1 );
760 
761  writeGroup( 0, "LAYER" );
762  writeHandle();
763  writeGroup( 100, "AcDbSymbolTableRecord" );
764  writeGroup( 100, "AcDbLayerTableRecord" );
765  writeGroup( 2, "0" );
766  writeGroup( 70, 64 );
767  writeGroup( 62, 1 );
768  writeGroup( 6, "CONTINUOUS" );
770 
771  Q_FOREACH ( const QString& layerName, layerNames )
772  {
773  writeGroup( 0, "LAYER" );
774  writeHandle();
775  writeGroup( 100, "AcDbSymbolTableRecord" );
776  writeGroup( 100, "AcDbLayerTableRecord" );
777  writeGroup( 2, layerName );
778  writeGroup( 70, 64 );
779  writeGroup( 62, 1 );
780  writeGroup( 6, "CONTINUOUS" );
782  }
783  writeGroup( 0, "ENDTAB" );
784 
785  // Text styles
786  writeGroup( 0, "TABLE" );
787  writeGroup( 2, "STYLE" );
788  writeHandle();
789  writeGroup( 100, "AcDbSymbolTable" );
790  writeGroup( 70, 1 );
791 
792  // Provide only standard font for the moment
793  writeGroup( 0, "STYLE" );
794  writeHandle();
795  writeGroup( 100, "AcDbSymbolTableRecord" );
796  writeGroup( 100, "AcDbTextStyleTableRecord" );
797  writeGroup( 2, "STANDARD" );
798  writeGroup( 70, 64 );
799  writeGroup( 40, 0.0 );
800  writeGroup( 41, 1.0 );
801  writeGroup( 50, 0.0 );
802  writeGroup( 71, 0 );
803  writeGroup( 42, 5.0 );
804  writeGroup( 3, "romans.shx" );
805  writeGroup( 4, "" );
806 
807  writeGroup( 0, "ENDTAB" );
808 
809  endSection();
810 }
811 
812 void QgsDxfExport::writeBlocks()
813 {
814  startSection();
815  writeGroup( 2, "BLOCKS" );
816 
817  Q_FOREACH ( const QString& block, QStringList() << "*Model_Space" << "*Paper_Space" << "*Paper_Space0" )
818  {
819  writeGroup( 0, "BLOCK" );
820  writeHandle();
821  writeGroup( 330, QString( "%1" ).arg( mBlockHandles[ block ], 0, 16 ) );
822  writeGroup( 100, "AcDbEntity" );
823  writeGroup( 8, "0" );
824  writeGroup( 100, "AcDbBlockBegin" );
825  writeGroup( 2, block );
826  writeGroup( 70, 0 );
828  writeGroup( 3, block );
829  writeGroup( 1, "" );
830  writeGroup( 0, "ENDBLK" );
831  writeHandle();
832  writeGroup( 100, "AcDbEntity" );
833  writeGroup( 8, "0" );
834  writeGroup( 100, "AcDbBlockEnd" );
835  }
836 
837  QgsRenderContext ct = renderContext();
838 
839  // Iterate through all layers and get symbol layer pointers
841  if ( mSymbologyExport != NoSymbology )
842  {
843  slList = symbolLayers( ct );
844  }
845 
846  QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > >::const_iterator slIt = slList.constBegin();
847  for ( ; slIt != slList.constEnd(); ++slIt )
848  {
849  QgsMarkerSymbolLayerV2 *ml = dynamic_cast< QgsMarkerSymbolLayerV2*>( slIt->first );
850  if ( !ml )
851  continue;
852 
853  // if point symbol layer and no data defined properties: write block
854  QgsSymbolV2RenderContext ctx( ct, QgsSymbolV2::MapUnit, slIt->second->alpha(), false, slIt->second->renderHints(), nullptr );
855  ml->startRender( ctx );
856 
857  // markers with data defined properties are inserted inline
858  if ( hasDataDefinedProperties( ml, slIt->second ) )
859  {
860  continue;
861  // ml->stopRender( ctx );
862  }
863 
864  QString block( QString( "symbolLayer%1" ).arg( mBlockCounter++ ) );
865  mBlockHandle = QString( "%1" ).arg( mBlockHandles[ block ], 0, 16 );
866 
867  writeGroup( 0, "BLOCK" );
868  writeHandle();
869  writeGroup( 330, mBlockHandle );
870  writeGroup( 100, "AcDbEntity" );
871  writeGroup( 8, "0" );
872  writeGroup( 100, "AcDbBlockBegin" );
873  writeGroup( 2, block );
874  writeGroup( 70, 0 );
875 
876  // x/y/z coordinates of reference point
877  // todo: consider anchor point
878  // double size = ml->size();
879  // size *= mapUnitScaleFactor( mSymbologyScaleDenominator, ml->sizeUnit(), mMapUnits );
881  writeGroup( 3, block );
882  writeGroup( 1, "" );
883 
884  // maplayer 0 -> block receives layer from INSERT statement
885  ml->writeDxf( *this, mapUnitScaleFactor( mSymbologyScaleDenominator, ml->sizeUnit(), mMapUnits ), "0", ctx );
886 
887  writeGroup( 0, "ENDBLK" );
888  writeHandle();
889  writeGroup( 100, "AcDbEntity" );
890  writeGroup( 8, "0" );
891  writeGroup( 100, "AcDbBlockEnd" );
892 
893  mPointSymbolBlocks.insert( ml, block );
894  ml->stopRender( ctx );
895  }
896  endSection();
897 }
898 
899 
900 void QgsDxfExport::writeEntities()
901 {
902  startSection();
903  writeGroup( 2, "ENTITIES" );
904 
905  mBlockHandle = QString( "%1" ).arg( mBlockHandles[ "*Model_Space" ], 0, 16 );
906 
907  QgsRectangle bbox = mExtent.isEmpty() ? dxfExtent() : mExtent;
908 
909  QgsMapSettings mapSettings;
910  mapSettings.setMapUnits( mMapUnits );
911  mapSettings.setExtent( bbox );
912 
913  int dpi = 96;
914  double factor = 1000 * dpi / mSymbologyScaleDenominator / 25.4 * QgsUnitTypes::fromUnitToUnitFactor( mMapUnits, QGis::Meters );
915  mapSettings.setOutputSize( QSize( bbox.width() * factor, bbox.height() * factor ) );
916  mapSettings.setOutputDpi( dpi );
917  mapSettings.setCrsTransformEnabled( false );
918 
919  QImage image( 10, 10, QImage::Format_ARGB32_Premultiplied );
920  image.setDotsPerMeterX( 96 / 25.4 * 1000 );
921  image.setDotsPerMeterY( 96 / 25.4 * 1000 );
922  QPainter painter( &image );
923  QgsRenderContext ctx;
924  ctx.setPainter( &painter );
925  ctx.setRendererScale( mSymbologyScaleDenominator );
926  ctx.setExtent( bbox );
927  ctx.setScaleFactor( 96.0 / 25.4 );
929  ctx.setMapToPixel( QgsMapToPixel( 1.0 / factor, bbox.xMinimum(), bbox.yMinimum(), bbox.height() * factor ) );
931 
932  // label engine
933  QgsLabelingEngineV2 engine;
934  engine.readSettingsFromProject();
935  engine.setMapSettings( mapSettings );
936 
937  // iterate through the maplayers
938  QList< QPair< QgsVectorLayer*, int > >::const_iterator layerIt = mLayers.constBegin();
939  for ( ; layerIt != mLayers.constEnd(); ++layerIt )
940  {
941  QgsVectorLayer* vl = layerIt->first;
942  if ( !vl || !layerIsScaleBasedVisible( vl ) )
943  {
944  continue;
945  }
946 
947  QgsSymbolV2RenderContext sctx( ctx, QgsSymbolV2::MM, 1.0, false, 0, nullptr );
948  QgsFeatureRendererV2* renderer = vl->rendererV2();
949  if ( !renderer )
950  {
951  continue;
952  }
953  renderer->startRender( ctx, vl->fields() );
954 
955  QStringList attributes = renderer->usedAttributes();
956  if ( vl->fields().exists( layerIt->second ) )
957  {
958  QString layerAttr = vl->fields().at( layerIt->second ).name();
959  if ( !attributes.contains( layerAttr ) )
960  attributes << layerAttr;
961  }
962 
963  const QgsAbstractVectorLayerLabeling *labeling = vl->labeling();
964  QgsDxfLabelProvider *lp = nullptr;
965  QgsDxfRuleBasedLabelProvider *rblp = nullptr;
966  if ( const QgsRuleBasedLabeling *rbl = dynamic_cast<const QgsRuleBasedLabeling*>( labeling ) )
967  {
968  rblp = new QgsDxfRuleBasedLabelProvider( *rbl, vl, this );
969  rblp->reinit( vl );
970  engine.addProvider( rblp );
971 
972  if ( !rblp->prepare( ctx, attributes ) )
973  {
974  engine.removeProvider( rblp );
975  rblp = nullptr;
976  }
977  }
978  else
979  {
980  lp = new QgsDxfLabelProvider( vl, QString(), this, nullptr );
981  engine.addProvider( lp );
982 
983  if ( !lp->prepare( ctx, attributes ) )
984  {
985  engine.removeProvider( lp );
986  lp = nullptr;
987  }
988  }
989 
990  if ( mSymbologyExport == QgsDxfExport::SymbolLayerSymbology &&
992  renderer->usingSymbolLevels() )
993  {
994  writeEntitiesSymbolLevels( vl );
995  renderer->stopRender( ctx );
996  continue;
997  }
998 
999  QgsFeatureRequest freq = QgsFeatureRequest().setSubsetOfAttributes( attributes, vl->fields() ).setExpressionContext( ctx.expressionContext() );
1000  if ( !mExtent.isEmpty() )
1001  {
1002  freq.setFilterRect( mExtent );
1003  }
1004 
1005  QgsFeatureIterator featureIt = vl->getFeatures( freq );
1006  QgsFeature fet;
1007  while ( featureIt.nextFeature( fet ) )
1008  {
1009  ctx.expressionContext().setFeature( fet );
1010  QString lName( dxfLayerName( layerIt->second == -1 ? layerName( vl ) : fet.attribute( layerIt->second ).toString() ) );
1011 
1012  sctx.setFeature( &fet );
1013  if ( mSymbologyExport == NoSymbology )
1014  {
1015  addFeature( sctx, lName, nullptr, nullptr ); // no symbology at all
1016  }
1017  else
1018  {
1019  QgsSymbolV2List symbolList = renderer->symbolsForFeature( fet, ctx );
1020  if ( symbolList.size() < 1 )
1021  {
1022  continue;
1023  }
1024 
1025  if ( mSymbologyExport == QgsDxfExport::SymbolLayerSymbology ) // symbol layer symbology, but layer does not use symbol levels
1026  {
1027  QgsSymbolV2List::iterator symbolIt = symbolList.begin();
1028  for ( ; symbolIt != symbolList.end(); ++symbolIt )
1029  {
1030  int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
1031  for ( int i = 0; i < nSymbolLayers; ++i )
1032  {
1033  addFeature( sctx, lName, ( *symbolIt )->symbolLayer( i ), *symbolIt );
1034  }
1035  }
1036  }
1037  else
1038  {
1039  // take first symbollayer from first symbol
1040  QgsSymbolV2* s = symbolList.first();
1041  if ( !s || s->symbolLayerCount() < 1 )
1042  {
1043  continue;
1044  }
1045  addFeature( sctx, lName, s->symbolLayer( 0 ), s );
1046  }
1047 
1048  if ( lp )
1049  {
1050  lp->registerDxfFeature( fet, ctx, lName );
1051  }
1052  else if ( rblp )
1053  {
1054  rblp->registerDxfFeature( fet, ctx, lName );
1055  }
1056  }
1057  }
1058 
1059  renderer->stopRender( ctx );
1060  }
1061 
1062  engine.run( ctx );
1063 
1064  endSection();
1065 }
1066 
1067 void QgsDxfExport::writeEntitiesSymbolLevels( QgsVectorLayer* layer )
1068 {
1069  if ( !layer )
1070  {
1071  return;
1072  }
1073 
1074  QgsFeatureRendererV2* renderer = layer->rendererV2();
1075  if ( !renderer )
1076  {
1077  // TODO return error
1078  return;
1079  }
1081 
1082  QgsRenderContext ctx = renderContext();
1086  QgsSymbolV2RenderContext sctx( ctx, QgsSymbolV2::MM, 1.0, false, 0, nullptr );
1087  renderer->startRender( ctx, layer->fields() );
1088 
1089  // get iterator
1090  QgsFeatureRequest req;
1091  if ( layer->wkbType() == QGis::WKBNoGeometry )
1092  {
1094  }
1095  req.setSubsetOfAttributes( QStringList( renderer->usedAttributes() ), layer->fields() );
1096  if ( !mExtent.isEmpty() )
1097  {
1098  req.setFilterRect( mExtent );
1099  }
1100  QgsFeatureIterator fit = layer->getFeatures( req );
1101 
1102  // fetch features
1103  QgsFeature fet;
1104  QgsSymbolV2* featureSymbol = nullptr;
1105  while ( fit.nextFeature( fet ) )
1106  {
1107  ctx.expressionContext().setFeature( fet );
1108  featureSymbol = renderer->symbolForFeature( fet, ctx );
1109  if ( !featureSymbol )
1110  {
1111  continue;
1112  }
1113 
1114  QHash< QgsSymbolV2*, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
1115  if ( it == features.end() )
1116  {
1117  it = features.insert( featureSymbol, QList<QgsFeature>() );
1118  }
1119  it.value().append( fet );
1120  }
1121 
1122  // find out order
1123  QgsSymbolV2LevelOrder levels;
1124  QgsSymbolV2List symbols = renderer->symbols( ctx );
1125  for ( int i = 0; i < symbols.count(); i++ )
1126  {
1127  QgsSymbolV2* sym = symbols[i];
1128  for ( int j = 0; j < sym->symbolLayerCount(); j++ )
1129  {
1130  int level = sym->symbolLayer( j )->renderingPass();
1131  if ( level < 0 || level >= 1000 ) // ignore invalid levels
1132  continue;
1133  QgsSymbolV2LevelItem item( sym, j );
1134  while ( level >= levels.count() ) // append new empty levels
1135  levels.append( QgsSymbolV2Level() );
1136  levels[level].append( item );
1137  }
1138  }
1139 
1140  // export symbol layers and symbology
1141  for ( int l = 0; l < levels.count(); l++ )
1142  {
1143  QgsSymbolV2Level& level = levels[l];
1144  for ( int i = 0; i < level.count(); i++ )
1145  {
1146  QgsSymbolV2LevelItem& item = level[i];
1147  QHash< QgsSymbolV2*, QList<QgsFeature> >::iterator levelIt = features.find( item.symbol() );
1148  if ( levelIt == features.end() )
1149  {
1150  QgsDebugMsg( QString( "No feature found for symbol on %1 %2.%3" ).arg( layer->id() ).arg( l ).arg( i ) );
1151  continue;
1152  }
1153 
1154  int llayer = item.layer();
1155  QList<QgsFeature>& featureList = levelIt.value();
1156  QList<QgsFeature>::iterator featureIt = featureList.begin();
1157  for ( ; featureIt != featureList.end(); ++featureIt )
1158  {
1159  sctx.setFeature( &*featureIt );
1160  addFeature( sctx, layer->name(), levelIt.key()->symbolLayer( llayer ), levelIt.key() );
1161  }
1162  }
1163  }
1164  renderer->stopRender( ctx );
1165 }
1166 
1167 void QgsDxfExport::writeEndFile()
1168 {
1169  // From GDAL trailer.dxf
1170  mTextStream << "\
1171  0\n\
1172 SECTION\n\
1173  2\n\
1174 OBJECTS\n\
1175  0\n\
1176 DICTIONARY\n\
1177  5\n\
1178 C\n\
1179 330\n\
1180 0\n\
1181 100\n\
1182 AcDbDictionary\n\
1183 281\n\
1184  1\n\
1185  3\n\
1186 ACAD_GROUP\n\
1187 350\n\
1188 D\n\
1189  3\n\
1190 ACAD_LAYOUT\n\
1191 350\n\
1192 1A\n\
1193  3\n\
1194 ACAD_MLEADERSTYLE\n\
1195 350\n\
1196 43\n\
1197  3\n\
1198 ACAD_MLINESTYLE\n\
1199 350\n\
1200 17\n\
1201  3\n\
1202 ACAD_PLOTSETTINGS\n\
1203 350\n\
1204 19\n\
1205  3\n\
1206 ACAD_PLOTSTYLENAME\n\
1207 350\n\
1208 E\n\
1209  3\n\
1210 ACAD_TABLESTYLE\n\
1211 350\n\
1212 42\n\
1213  3\n\
1214 ACAD_VISUALSTYLE\n\
1215 350\n\
1216 2A\n\
1217  0\n\
1218 DICTIONARY\n\
1219  5\n\
1220 D\n\
1221 102\n\
1222 {ACAD_REACTORS\n\
1223 330\n\
1224 C\n\
1225 102\n\
1226 }\n\
1227 330\n\
1228 C\n\
1229 100\n\
1230 AcDbDictionary\n\
1231 281\n\
1232  1\n\
1233  0\n\
1234 DICTIONARY\n\
1235  5\n\
1236 1A\n\
1237 102\n\
1238 {ACAD_REACTORS\n\
1239 330\n\
1240 C\n\
1241 102\n\
1242 }\n\
1243 330\n\
1244 C\n\
1245 100\n\
1246 AcDbDictionary\n\
1247 281\n\
1248  1\n\
1249  3\n\
1250 Layout1\n\
1251 350\n\
1252 1E\n\
1253  3\n\
1254 Layout2\n\
1255 350\n\
1256 26\n\
1257  3\n\
1258 Model\n\
1259 350\n\
1260 22\n\
1261  0\n\
1262 DICTIONARY\n\
1263  5\n\
1264 43\n\
1265 102\n\
1266 {ACAD_REACTORS\n\
1267 330\n\
1268 C\n\
1269 102\n\
1270 }\n\
1271 330\n\
1272 C\n\
1273 100\n\
1274 AcDbDictionary\n\
1275 281\n\
1276  1\n\
1277  0\n\
1278 DICTIONARY\n\
1279  5\n\
1280 17\n\
1281 102\n\
1282 {ACAD_REACTORS\n\
1283 330\n\
1284 C\n\
1285 102\n\
1286 }\n\
1287 330\n\
1288 C\n\
1289 100\n\
1290 AcDbDictionary\n\
1291 281\n\
1292  1\n\
1293  3\n\
1294 Standard\n\
1295 350\n\
1296 18\n\
1297  0\n\
1298 DICTIONARY\n\
1299  5\n\
1300 19\n\
1301 102\n\
1302 {ACAD_REACTORS\n\
1303 330\n\
1304 C\n\
1305 102\n\
1306 }\n\
1307 330\n\
1308 C\n\
1309 100\n\
1310 AcDbDictionary\n\
1311 281\n\
1312  1\n\
1313  0\n\
1314 ACDBDICTIONARYWDFLT\n\
1315  5\n\
1316 E\n\
1317 102\n\
1318 {ACAD_REACTORS\n\
1319 330\n\
1320 C\n\
1321 102\n\
1322 }\n\
1323 330\n\
1324 C\n\
1325 100\n\
1326 AcDbDictionary\n\
1327 281\n\
1328  1\n\
1329  3\n\
1330 Normal\n\
1331 350\n\
1332 F\n\
1333 100\n\
1334 AcDbDictionaryWithDefault\n\
1335 340\n\
1336 F\n\
1337  0\n\
1338 DICTIONARY\n\
1339  5\n\
1340 42\n\
1341 102\n\
1342 {ACAD_REACTORS\n\
1343 330\n\
1344 C\n\
1345 102\n\
1346 }\n\
1347 330\n\
1348 C\n\
1349 100\n\
1350 AcDbDictionary\n\
1351 281\n\
1352  1\n\
1353  0\n\
1354 DICTIONARY\n\
1355  5\n\
1356 2A\n\
1357 102\n\
1358 {ACAD_REACTORS\n\
1359 330\n\
1360 C\n\
1361 102\n\
1362 }\n\
1363 330\n\
1364 C\n\
1365 100\n\
1366 AcDbDictionary\n\
1367 281\n\
1368  1\n\
1369  3\n\
1370 2dWireframe\n\
1371 350\n\
1372 2F\n\
1373  3\n\
1374 3D Hidden\n\
1375 350\n\
1376 31\n\
1377  3\n\
1378 3dWireframe\n\
1379 350\n\
1380 30\n\
1381  3\n\
1382 Basic\n\
1383 350\n\
1384 32\n\
1385  3\n\
1386 Brighten\n\
1387 350\n\
1388 36\n\
1389  3\n\
1390 ColorChange\n\
1391 350\n\
1392 3A\n\
1393  3\n\
1394 Conceptual\n\
1395 350\n\
1396 34\n\
1397  3\n\
1398 Dim\n\
1399 350\n\
1400 35\n\
1401  3\n\
1402 Facepattern\n\
1403 350\n\
1404 39\n\
1405  3\n\
1406 Flat\n\
1407 350\n\
1408 2B\n\
1409  3\n\
1410 FlatWithEdges\n\
1411 350\n\
1412 2C\n\
1413  3\n\
1414 Gouraud\n\
1415 350\n\
1416 2D\n\
1417  3\n\
1418 GouraudWithEdges\n\
1419 350\n\
1420 2E\n\
1421  3\n\
1422 Linepattern\n\
1423 350\n\
1424 38\n\
1425  3\n\
1426 Realistic\n\
1427 350\n\
1428 33\n\
1429  3\n\
1430 Thicken\n\
1431 350\n\
1432 37\n\
1433  0\n\
1434 LAYOUT\n\
1435  5\n\
1436 1E\n\
1437 102\n\
1438 {ACAD_REACTORS\n\
1439 330\n\
1440 1A\n\
1441 102\n\
1442 }\n\
1443 330\n\
1444 1A\n\
1445 100\n\
1446 AcDbPlotSettings\n\
1447  1\n\
1448 \n\
1449  2\n\
1450 none_device\n\
1451  4\n\
1452 \n\
1453  6\n\
1454 \n\
1455  40\n\
1456 0.0\n\
1457  41\n\
1458 0.0\n\
1459  42\n\
1460 0.0\n\
1461  43\n\
1462 0.0\n\
1463  44\n\
1464 0.0\n\
1465  45\n\
1466 0.0\n\
1467  46\n\
1468 0.0\n\
1469  47\n\
1470 0.0\n\
1471  48\n\
1472 0.0\n\
1473  49\n\
1474 0.0\n\
1475 140\n\
1476 0.0\n\
1477 141\n\
1478 0.0\n\
1479 142\n\
1480 1.0\n\
1481 143\n\
1482 1.0\n\
1483  70\n\
1484  688\n\
1485  72\n\
1486  0\n\
1487  73\n\
1488  0\n\
1489  74\n\
1490  5\n\
1491  7\n\
1492 \n\
1493  75\n\
1494  16\n\
1495  76\n\
1496  0\n\
1497  77\n\
1498  2\n\
1499  78\n\
1500  300\n\
1501 147\n\
1502 1.0\n\
1503 148\n\
1504 0.0\n\
1505 149\n\
1506 0.0\n\
1507 100\n\
1508 AcDbLayout\n\
1509  1\n\
1510 Layout1\n\
1511  70\n\
1512  1\n\
1513  71\n\
1514  1\n\
1515  10\n\
1516 0.0\n\
1517  20\n\
1518 0.0\n\
1519  11\n\
1520 12.0\n\
1521  21\n\
1522 9.0\n\
1523  12\n\
1524 0.0\n\
1525  22\n\
1526 0.0\n\
1527  32\n\
1528 0.0\n\
1529  14\n\
1530 1.000000000000000E+20\n\
1531  24\n\
1532 1.000000000000000E+20\n\
1533  34\n\
1534 1.000000000000000E+20\n\
1535  15\n\
1536 -1.000000000000000E+20\n\
1537  25\n\
1538 -1.000000000000000E+20\n\
1539  35\n\
1540 -1.000000000000000E+20\n\
1541 146\n\
1542 0.0\n\
1543  13\n\
1544 0.0\n\
1545  23\n\
1546 0.0\n\
1547  33\n\
1548 0.0\n\
1549  16\n\
1550 1.0\n\
1551  26\n\
1552 0.0\n\
1553  36\n\
1554 0.0\n\
1555  17\n\
1556 0.0\n\
1557  27\n\
1558 1.0\n\
1559  37\n\
1560 0.0\n\
1561  76\n\
1562  0\n\
1563 330\n\
1564 1B\n\
1565  0\n\
1566 LAYOUT\n\
1567  5\n\
1568 26\n\
1569 102\n\
1570 {ACAD_REACTORS\n\
1571 330\n\
1572 1A\n\
1573 102\n\
1574 }\n\
1575 330\n\
1576 1A\n\
1577 100\n\
1578 AcDbPlotSettings\n\
1579  1\n\
1580 \n\
1581  2\n\
1582 none_device\n\
1583  4\n\
1584 \n\
1585  6\n\
1586 \n\
1587  40\n\
1588 0.0\n\
1589  41\n\
1590 0.0\n\
1591  42\n\
1592 0.0\n\
1593  43\n\
1594 0.0\n\
1595  44\n\
1596 0.0\n\
1597  45\n\
1598 0.0\n\
1599  46\n\
1600 0.0\n\
1601  47\n\
1602 0.0\n\
1603  48\n\
1604 0.0\n\
1605  49\n\
1606 0.0\n\
1607 140\n\
1608 0.0\n\
1609 141\n\
1610 0.0\n\
1611 142\n\
1612 1.0\n\
1613 143\n\
1614 1.0\n\
1615  70\n\
1616  688\n\
1617  72\n\
1618  0\n\
1619  73\n\
1620  0\n\
1621  74\n\
1622  5\n\
1623  7\n\
1624 \n\
1625  75\n\
1626  16\n\
1627  76\n\
1628  0\n\
1629  77\n\
1630  2\n\
1631  78\n\
1632  300\n\
1633 147\n\
1634 1.0\n\
1635 148\n\
1636 0.0\n\
1637 149\n\
1638 0.0\n\
1639 100\n\
1640 AcDbLayout\n\
1641  1\n\
1642 Layout2\n\
1643  70\n\
1644  1\n\
1645  71\n\
1646  2\n\
1647  10\n\
1648 0.0\n\
1649  20\n\
1650 0.0\n\
1651  11\n\
1652 0.0\n\
1653  21\n\
1654 0.0\n\
1655  12\n\
1656 0.0\n\
1657  22\n\
1658 0.0\n\
1659  32\n\
1660 0.0\n\
1661  14\n\
1662 0.0\n\
1663  24\n\
1664 0.0\n\
1665  34\n\
1666 0.0\n\
1667  15\n\
1668 0.0\n\
1669  25\n\
1670 0.0\n\
1671  35\n\
1672 0.0\n\
1673 146\n\
1674 0.0\n\
1675  13\n\
1676 0.0\n\
1677  23\n\
1678 0.0\n\
1679  33\n\
1680 0.0\n\
1681  16\n\
1682 1.0\n\
1683  26\n\
1684 0.0\n\
1685  36\n\
1686 0.0\n\
1687  17\n\
1688 0.0\n\
1689  27\n\
1690 1.0\n\
1691  37\n\
1692 0.0\n\
1693  76\n\
1694  0\n\
1695 330\n\
1696 23\n\
1697  0\n\
1698 LAYOUT\n\
1699  5\n\
1700 22\n\
1701 102\n\
1702 {ACAD_REACTORS\n\
1703 330\n\
1704 1A\n\
1705 102\n\
1706 }\n\
1707 330\n\
1708 1A\n\
1709 100\n\
1710 AcDbPlotSettings\n\
1711  1\n\
1712 \n\
1713  2\n\
1714 none_device\n\
1715  4\n\
1716 \n\
1717  6\n\
1718 \n\
1719  40\n\
1720 0.0\n\
1721  41\n\
1722 0.0\n\
1723  42\n\
1724 0.0\n\
1725  43\n\
1726 0.0\n\
1727  44\n\
1728 0.0\n\
1729  45\n\
1730 0.0\n\
1731  46\n\
1732 0.0\n\
1733  47\n\
1734 0.0\n\
1735  48\n\
1736 0.0\n\
1737  49\n\
1738 0.0\n\
1739 140\n\
1740 0.0\n\
1741 141\n\
1742 0.0\n\
1743 142\n\
1744 1.0\n\
1745 143\n\
1746 1.0\n\
1747  70\n\
1748  1712\n\
1749  72\n\
1750  0\n\
1751  73\n\
1752  0\n\
1753  74\n\
1754  0\n\
1755  7\n\
1756 \n\
1757  75\n\
1758  0\n\
1759  76\n\
1760  0\n\
1761  77\n\
1762  2\n\
1763  78\n\
1764  300\n\
1765 147\n\
1766 1.0\n\
1767 148\n\
1768 0.0\n\
1769 149\n\
1770 0.0\n\
1771 100\n\
1772 AcDbLayout\n\
1773  1\n\
1774 Model\n\
1775  70\n\
1776  1\n\
1777  71\n\
1778  0\n\
1779  10\n\
1780 0.0\n\
1781  20\n\
1782 0.0\n\
1783  11\n\
1784 12.0\n\
1785  21\n\
1786 9.0\n\
1787  12\n\
1788 0.0\n\
1789  22\n\
1790 0.0\n\
1791  32\n\
1792 0.0\n\
1793  14\n\
1794 30.0\n\
1795  24\n\
1796 49.75\n\
1797  34\n\
1798 0.0\n\
1799  15\n\
1800 130.5\n\
1801  25\n\
1802 163.1318914119703\n\
1803  35\n\
1804 0.0\n\
1805 146\n\
1806 0.0\n\
1807  13\n\
1808 0.0\n\
1809  23\n\
1810 0.0\n\
1811  33\n\
1812 0.0\n\
1813  16\n\
1814 1.0\n\
1815  26\n\
1816 0.0\n\
1817  36\n\
1818 0.0\n\
1819  17\n\
1820 0.0\n\
1821  27\n\
1822 1.0\n\
1823  37\n\
1824 0.0\n\
1825  76\n\
1826  0\n\
1827 330\n\
1828 1F\n\
1829 331\n\
1830 29\n\
1831  0\n\
1832 MLINESTYLE\n\
1833  5\n\
1834 18\n\
1835 102\n\
1836 {ACAD_REACTORS\n\
1837 330\n\
1838 17\n\
1839 102\n\
1840 }\n\
1841 330\n\
1842 17\n\
1843 100\n\
1844 AcDbMlineStyle\n\
1845  2\n\
1846 Standard\n\
1847  70\n\
1848  0\n\
1849  3\n\
1850 \n\
1851  62\n\
1852  256\n\
1853  51\n\
1854 90.0\n\
1855  52\n\
1856 90.0\n\
1857  71\n\
1858  2\n\
1859  49\n\
1860 0.5\n\
1861  62\n\
1862  256\n\
1863  6\n\
1864 BYLAYER\n\
1865  49\n\
1866 -0.5\n\
1867  62\n\
1868  256\n\
1869  6\n\
1870 BYLAYER\n\
1871  0\n\
1872 ACDBPLACEHOLDER\n\
1873  5\n\
1874 F\n\
1875 102\n\
1876 {ACAD_REACTORS\n\
1877 330\n\
1878 E\n\
1879 102\n\
1880 }\n\
1881 330\n\
1882 E\n\
1883  0\n\
1884 VISUALSTYLE\n\
1885  5\n\
1886 2F\n\
1887 102\n\
1888 {ACAD_REACTORS\n\
1889 330\n\
1890 2A\n\
1891 102\n\
1892 }\n\
1893 330\n\
1894 2A\n\
1895 100\n\
1896 AcDbVisualStyle\n\
1897  2\n\
1898 2dWireframe\n\
1899  70\n\
1900  4\n\
1901  71\n\
1902  0\n\
1903  72\n\
1904  2\n\
1905  73\n\
1906  0\n\
1907  90\n\
1908  0\n\
1909  40\n\
1910 -0.6\n\
1911  41\n\
1912 -30.0\n\
1913  62\n\
1914  5\n\
1915  63\n\
1916  7\n\
1917 421\n\
1918  16777215\n\
1919  74\n\
1920  1\n\
1921  91\n\
1922  4\n\
1923  64\n\
1924  7\n\
1925  65\n\
1926  257\n\
1927  75\n\
1928  1\n\
1929 175\n\
1930  1\n\
1931  42\n\
1932 1.0\n\
1933  92\n\
1934  0\n\
1935  66\n\
1936  257\n\
1937  43\n\
1938 1.0\n\
1939  76\n\
1940  1\n\
1941  77\n\
1942  6\n\
1943  78\n\
1944  2\n\
1945  67\n\
1946  7\n\
1947  79\n\
1948  5\n\
1949 170\n\
1950  0\n\
1951 171\n\
1952  0\n\
1953 290\n\
1954  0\n\
1955 174\n\
1956  0\n\
1957  93\n\
1958  1\n\
1959  44\n\
1960 0.0\n\
1961 173\n\
1962  0\n\
1963 291\n\
1964  0\n\
1965  45\n\
1966 0.0\n\
1967 1001\n\
1968 ACAD\n\
1969 1000\n\
1970 AcDbSavedByObjectVersion\n\
1971 1070\n\
1972  0\n\
1973  0\n\
1974 VISUALSTYLE\n\
1975  5\n\
1976 31\n\
1977 102\n\
1978 {ACAD_REACTORS\n\
1979 330\n\
1980 2A\n\
1981 102\n\
1982 }\n\
1983 330\n\
1984 2A\n\
1985 100\n\
1986 AcDbVisualStyle\n\
1987  2\n\
1988 3D Hidden\n\
1989  70\n\
1990  6\n\
1991  71\n\
1992  1\n\
1993  72\n\
1994  2\n\
1995  73\n\
1996  2\n\
1997  90\n\
1998  0\n\
1999  40\n\
2000 -0.6\n\
2001  41\n\
2002 -30.0\n\
2003  62\n\
2004  5\n\
2005  63\n\
2006  7\n\
2007 421\n\
2008  16777215\n\
2009  74\n\
2010  2\n\
2011  91\n\
2012  2\n\
2013  64\n\
2014  7\n\
2015  65\n\
2016  257\n\
2017  75\n\
2018  2\n\
2019 175\n\
2020  1\n\
2021  42\n\
2022 40.0\n\
2023  92\n\
2024  0\n\
2025  66\n\
2026  257\n\
2027  43\n\
2028 1.0\n\
2029  76\n\
2030  1\n\
2031  77\n\
2032  6\n\
2033  78\n\
2034  2\n\
2035  67\n\
2036  7\n\
2037  79\n\
2038  3\n\
2039 170\n\
2040  0\n\
2041 171\n\
2042  0\n\
2043 290\n\
2044  0\n\
2045 174\n\
2046  0\n\
2047  93\n\
2048  1\n\
2049  44\n\
2050 0.0\n\
2051 173\n\
2052  0\n\
2053 291\n\
2054  0\n\
2055  45\n\
2056 0.0\n\
2057 1001\n\
2058 ACAD\n\
2059 1000\n\
2060 AcDbSavedByObjectVersion\n\
2061 1070\n\
2062  0\n\
2063  0\n\
2064 VISUALSTYLE\n\
2065  5\n\
2066 30\n\
2067 102\n\
2068 {ACAD_REACTORS\n\
2069 330\n\
2070 2A\n\
2071 102\n\
2072 }\n\
2073 330\n\
2074 2A\n\
2075 100\n\
2076 AcDbVisualStyle\n\
2077  2\n\
2078 3dWireframe\n\
2079  70\n\
2080  5\n\
2081  71\n\
2082  0\n\
2083  72\n\
2084  2\n\
2085  73\n\
2086  0\n\
2087  90\n\
2088  0\n\
2089  40\n\
2090 -0.6\n\
2091  41\n\
2092 -30.0\n\
2093  62\n\
2094  5\n\
2095  63\n\
2096  7\n\
2097 421\n\
2098  16777215\n\
2099  74\n\
2100  1\n\
2101  91\n\
2102  4\n\
2103  64\n\
2104  7\n\
2105  65\n\
2106  257\n\
2107  75\n\
2108  1\n\
2109 175\n\
2110  1\n\
2111  42\n\
2112 1.0\n\
2113  92\n\
2114  0\n\
2115  66\n\
2116  257\n\
2117  43\n\
2118 1.0\n\
2119  76\n\
2120  1\n\
2121  77\n\
2122  6\n\
2123  78\n\
2124  2\n\
2125  67\n\
2126  7\n\
2127  79\n\
2128  5\n\
2129 170\n\
2130  0\n\
2131 171\n\
2132  0\n\
2133 290\n\
2134  0\n\
2135 174\n\
2136  0\n\
2137  93\n\
2138  1\n\
2139  44\n\
2140 0.0\n\
2141 173\n\
2142  0\n\
2143 291\n\
2144  0\n\
2145  45\n\
2146 0.0\n\
2147 1001\n\
2148 ACAD\n\
2149 1000\n\
2150 AcDbSavedByObjectVersion\n\
2151 1070\n\
2152  0\n\
2153  0\n\
2154 VISUALSTYLE\n\
2155  5\n\
2156 32\n\
2157 102\n\
2158 {ACAD_REACTORS\n\
2159 330\n\
2160 2A\n\
2161 102\n\
2162 }\n\
2163 330\n\
2164 2A\n\
2165 100\n\
2166 AcDbVisualStyle\n\
2167  2\n\
2168 Basic\n\
2169  70\n\
2170  7\n\
2171  71\n\
2172  1\n\
2173  72\n\
2174  0\n\
2175  73\n\
2176  1\n\
2177  90\n\
2178  0\n\
2179  40\n\
2180 -0.6\n\
2181  41\n\
2182 -30.0\n\
2183  62\n\
2184  5\n\
2185  63\n\
2186  7\n\
2187 421\n\
2188  16777215\n\
2189  74\n\
2190  0\n\
2191  91\n\
2192  4\n\
2193  64\n\
2194  7\n\
2195  65\n\
2196  257\n\
2197  75\n\
2198  1\n\
2199 175\n\
2200  1\n\
2201  42\n\
2202 1.0\n\
2203  92\n\
2204  8\n\
2205  66\n\
2206  7\n\
2207  43\n\
2208 1.0\n\
2209  76\n\
2210  1\n\
2211  77\n\
2212  6\n\
2213  78\n\
2214  2\n\
2215  67\n\
2216  7\n\
2217  79\n\
2218  5\n\
2219 170\n\
2220  0\n\
2221 171\n\
2222  0\n\
2223 290\n\
2224  0\n\
2225 174\n\
2226  0\n\
2227  93\n\
2228  1\n\
2229  44\n\
2230 0.0\n\
2231 173\n\
2232  0\n\
2233 291\n\
2234  1\n\
2235  45\n\
2236 0.0\n\
2237 1001\n\
2238 ACAD\n\
2239 1000\n\
2240 AcDbSavedByObjectVersion\n\
2241 1070\n\
2242  0\n\
2243  0\n\
2244 VISUALSTYLE\n\
2245  5\n\
2246 36\n\
2247 102\n\
2248 {ACAD_REACTORS\n\
2249 330\n\
2250 2A\n\
2251 102\n\
2252 }\n\
2253 330\n\
2254 2A\n\
2255 100\n\
2256 AcDbVisualStyle\n\
2257  2\n\
2258 Brighten\n\
2259  70\n\
2260  12\n\
2261  71\n\
2262  2\n\
2263  72\n\
2264  2\n\
2265  73\n\
2266  0\n\
2267  90\n\
2268  0\n\
2269  40\n\
2270 -0.6\n\
2271  41\n\
2272 -30.0\n\
2273  62\n\
2274  5\n\
2275  63\n\
2276  7\n\
2277 421\n\
2278  16777215\n\
2279  74\n\
2280  1\n\
2281  91\n\
2282  4\n\
2283  64\n\
2284  7\n\
2285  65\n\
2286  257\n\
2287  75\n\
2288  1\n\
2289 175\n\
2290  1\n\
2291  42\n\
2292 1.0\n\
2293  92\n\
2294  8\n\
2295  66\n\
2296  7\n\
2297  43\n\
2298 1.0\n\
2299  76\n\
2300  1\n\
2301  77\n\
2302  6\n\
2303  78\n\
2304  2\n\
2305  67\n\
2306  7\n\
2307  79\n\
2308  5\n\
2309 170\n\
2310  0\n\
2311 171\n\
2312  0\n\
2313 290\n\
2314  0\n\
2315 174\n\
2316  0\n\
2317  93\n\
2318  1\n\
2319  44\n\
2320 50.0\n\
2321 173\n\
2322  0\n\
2323 291\n\
2324  1\n\
2325  45\n\
2326 0.0\n\
2327 1001\n\
2328 ACAD\n\
2329 1000\n\
2330 AcDbSavedByObjectVersion\n\
2331 1070\n\
2332  0\n\
2333  0\n\
2334 VISUALSTYLE\n\
2335  5\n\
2336 3A\n\
2337 102\n\
2338 {ACAD_REACTORS\n\
2339 330\n\
2340 2A\n\
2341 102\n\
2342 }\n\
2343 330\n\
2344 2A\n\
2345 100\n\
2346 AcDbVisualStyle\n\
2347  2\n\
2348 ColorChange\n\
2349  70\n\
2350  16\n\
2351  71\n\
2352  2\n\
2353  72\n\
2354  2\n\
2355  73\n\
2356  3\n\
2357  90\n\
2358  0\n\
2359  40\n\
2360 -0.6\n\
2361  41\n\
2362 -30.0\n\
2363  62\n\
2364  5\n\
2365  63\n\
2366  8\n\
2367 421\n\
2368  8421504\n\
2369  74\n\
2370  1\n\
2371  91\n\
2372  4\n\
2373  64\n\
2374  7\n\
2375  65\n\
2376  257\n\
2377  75\n\
2378  1\n\
2379 175\n\
2380  1\n\
2381  42\n\
2382 1.0\n\
2383  92\n\
2384  8\n\
2385  66\n\
2386  8\n\
2387 424\n\
2388  8421504\n\
2389  43\n\
2390 1.0\n\
2391  76\n\
2392  1\n\
2393  77\n\
2394  6\n\
2395  78\n\
2396  2\n\
2397  67\n\
2398  7\n\
2399  79\n\
2400  5\n\
2401 170\n\
2402  0\n\
2403 171\n\
2404  0\n\
2405 290\n\
2406  0\n\
2407 174\n\
2408  0\n\
2409  93\n\
2410  1\n\
2411  44\n\
2412 0.0\n\
2413 173\n\
2414  0\n\
2415 291\n\
2416  1\n\
2417  45\n\
2418 0.0\n\
2419 1001\n\
2420 ACAD\n\
2421 1000\n\
2422 AcDbSavedByObjectVersion\n\
2423 1070\n\
2424  0\n\
2425  0\n\
2426 VISUALSTYLE\n\
2427  5\n\
2428 34\n\
2429 102\n\
2430 {ACAD_REACTORS\n\
2431 330\n\
2432 2A\n\
2433 102\n\
2434 }\n\
2435 330\n\
2436 2A\n\
2437 100\n\
2438 AcDbVisualStyle\n\
2439  2\n\
2440 Conceptual\n\
2441  70\n\
2442  9\n\
2443  71\n\
2444  3\n\
2445  72\n\
2446  2\n\
2447  73\n\
2448  0\n\
2449  90\n\
2450  0\n\
2451  40\n\
2452 -0.6\n\
2453  41\n\
2454 -30.0\n\
2455  62\n\
2456  5\n\
2457  63\n\
2458  7\n\
2459 421\n\
2460  16777215\n\
2461  74\n\
2462  2\n\
2463  91\n\
2464  2\n\
2465  64\n\
2466  7\n\
2467  65\n\
2468  257\n\
2469  75\n\
2470  1\n\
2471 175\n\
2472  1\n\
2473  42\n\
2474 40.0\n\
2475  92\n\
2476  8\n\
2477  66\n\
2478  7\n\
2479  43\n\
2480 1.0\n\
2481  76\n\
2482  1\n\
2483  77\n\
2484  6\n\
2485  78\n\
2486  2\n\
2487  67\n\
2488  7\n\
2489  79\n\
2490  3\n\
2491 170\n\
2492  0\n\
2493 171\n\
2494  0\n\
2495 290\n\
2496  0\n\
2497 174\n\
2498  0\n\
2499  93\n\
2500  1\n\
2501  44\n\
2502 0.0\n\
2503 173\n\
2504  0\n\
2505 291\n\
2506  0\n\
2507  45\n\
2508 0.0\n\
2509 1001\n\
2510 ACAD\n\
2511 1000\n\
2512 AcDbSavedByObjectVersion\n\
2513 1070\n\
2514  0\n\
2515  0\n\
2516 VISUALSTYLE\n\
2517  5\n\
2518 35\n\
2519 102\n\
2520 {ACAD_REACTORS\n\
2521 330\n\
2522 2A\n\
2523 102\n\
2524 }\n\
2525 330\n\
2526 2A\n\
2527 100\n\
2528 AcDbVisualStyle\n\
2529  2\n\
2530 Dim\n\
2531  70\n\
2532  11\n\
2533  71\n\
2534  2\n\
2535  72\n\
2536  2\n\
2537  73\n\
2538  0\n\
2539  90\n\
2540  0\n\
2541  40\n\
2542 -0.6\n\
2543  41\n\
2544 -30.0\n\
2545  62\n\
2546  5\n\
2547  63\n\
2548  7\n\
2549 421\n\
2550  16777215\n\
2551  74\n\
2552  1\n\
2553  91\n\
2554  4\n\
2555  64\n\
2556  7\n\
2557  65\n\
2558  257\n\
2559  75\n\
2560  1\n\
2561 175\n\
2562  1\n\
2563  42\n\
2564 1.0\n\
2565  92\n\
2566  8\n\
2567  66\n\
2568  7\n\
2569  43\n\
2570 1.0\n\
2571  76\n\
2572  1\n\
2573  77\n\
2574  6\n\
2575  78\n\
2576  2\n\
2577  67\n\
2578  7\n\
2579  79\n\
2580  5\n\
2581 170\n\
2582  0\n\
2583 171\n\
2584  0\n\
2585 290\n\
2586  0\n\
2587 174\n\
2588  0\n\
2589  93\n\
2590  1\n\
2591  44\n\
2592 -50.0\n\
2593 173\n\
2594  0\n\
2595 291\n\
2596  1\n\
2597  45\n\
2598 0.0\n\
2599 1001\n\
2600 ACAD\n\
2601 1000\n\
2602 AcDbSavedByObjectVersion\n\
2603 1070\n\
2604  0\n\
2605  0\n\
2606 VISUALSTYLE\n\
2607  5\n\
2608 39\n\
2609 102\n\
2610 {ACAD_REACTORS\n\
2611 330\n\
2612 2A\n\
2613 102\n\
2614 }\n\
2615 330\n\
2616 2A\n\
2617 100\n\
2618 AcDbVisualStyle\n\
2619  2\n\
2620 Facepattern\n\
2621  70\n\
2622  15\n\
2623  71\n\
2624  2\n\
2625  72\n\
2626  2\n\
2627  73\n\
2628  0\n\
2629  90\n\
2630  0\n\
2631  40\n\
2632 -0.6\n\
2633  41\n\
2634 -30.0\n\
2635  62\n\
2636  5\n\
2637  63\n\
2638  7\n\
2639 421\n\
2640  16777215\n\
2641  74\n\
2642  1\n\
2643  91\n\
2644  4\n\
2645  64\n\
2646  7\n\
2647  65\n\
2648  257\n\
2649  75\n\
2650  1\n\
2651 175\n\
2652  1\n\
2653  42\n\
2654 1.0\n\
2655  92\n\
2656  8\n\
2657  66\n\
2658  7\n\
2659  43\n\
2660 1.0\n\
2661  76\n\
2662  1\n\
2663  77\n\
2664  6\n\
2665  78\n\
2666  2\n\
2667  67\n\
2668  7\n\
2669  79\n\
2670  5\n\
2671 170\n\
2672  0\n\
2673 171\n\
2674  0\n\
2675 290\n\
2676  0\n\
2677 174\n\
2678  0\n\
2679  93\n\
2680  1\n\
2681  44\n\
2682 0.0\n\
2683 173\n\
2684  0\n\
2685 291\n\
2686  1\n\
2687  45\n\
2688 0.0\n\
2689 1001\n\
2690 ACAD\n\
2691 1000\n\
2692 AcDbSavedByObjectVersion\n\
2693 1070\n\
2694  0\n\
2695  0\n\
2696 VISUALSTYLE\n\
2697  5\n\
2698 2B\n\
2699 102\n\
2700 {ACAD_REACTORS\n\
2701 330\n\
2702 2A\n\
2703 102\n\
2704 }\n\
2705 330\n\
2706 2A\n\
2707 100\n\
2708 AcDbVisualStyle\n\
2709  2\n\
2710 Flat\n\
2711  70\n\
2712  0\n\
2713  71\n\
2714  2\n\
2715  72\n\
2716  1\n\
2717  73\n\
2718  1\n\
2719  90\n\
2720  2\n\
2721  40\n\
2722 -0.6\n\
2723  41\n\
2724 30.0\n\
2725  62\n\
2726  5\n\
2727  63\n\
2728  7\n\
2729 421\n\
2730  16777215\n\
2731  74\n\
2732  0\n\
2733  91\n\
2734  4\n\
2735  64\n\
2736  7\n\
2737  65\n\
2738  257\n\
2739  75\n\
2740  1\n\
2741 175\n\
2742  1\n\
2743  42\n\
2744 1.0\n\
2745  92\n\
2746  8\n\
2747  66\n\
2748  7\n\
2749  43\n\
2750 1.0\n\
2751  76\n\
2752  1\n\
2753  77\n\
2754  6\n\
2755  78\n\
2756  2\n\
2757  67\n\
2758  7\n\
2759  79\n\
2760  5\n\
2761 170\n\
2762  0\n\
2763 171\n\
2764  0\n\
2765 290\n\
2766  0\n\
2767 174\n\
2768  0\n\
2769  93\n\
2770  13\n\
2771  44\n\
2772 0.0\n\
2773 173\n\
2774  0\n\
2775 291\n\
2776  1\n\
2777  45\n\
2778 0.0\n\
2779 1001\n\
2780 ACAD\n\
2781 1000\n\
2782 AcDbSavedByObjectVersion\n\
2783 1070\n\
2784  0\n\
2785  0\n\
2786 VISUALSTYLE\n\
2787  5\n\
2788 2C\n\
2789 102\n\
2790 {ACAD_REACTORS\n\
2791 330\n\
2792 2A\n\
2793 102\n\
2794 }\n\
2795 330\n\
2796 2A\n\
2797 100\n\
2798 AcDbVisualStyle\n\
2799  2\n\
2800 FlatWithEdges\n\
2801  70\n\
2802  1\n\
2803  71\n\
2804  2\n\
2805  72\n\
2806  1\n\
2807  73\n\
2808  1\n\
2809  90\n\
2810  2\n\
2811  40\n\
2812 -0.6\n\
2813  41\n\
2814 30.0\n\
2815  62\n\
2816  5\n\
2817  63\n\
2818  7\n\
2819 421\n\
2820  16777215\n\
2821  74\n\
2822  1\n\
2823  91\n\
2824  4\n\
2825  64\n\
2826  7\n\
2827  65\n\
2828  257\n\
2829  75\n\
2830  1\n\
2831 175\n\
2832  1\n\
2833  42\n\
2834 1.0\n\
2835  92\n\
2836  0\n\
2837  66\n\
2838  257\n\
2839  43\n\
2840 1.0\n\
2841  76\n\
2842  1\n\
2843  77\n\
2844  6\n\
2845  78\n\
2846  2\n\
2847  67\n\
2848  7\n\
2849  79\n\
2850  5\n\
2851 170\n\
2852  0\n\
2853 171\n\
2854  0\n\
2855 290\n\
2856  0\n\
2857 174\n\
2858  0\n\
2859  93\n\
2860  13\n\
2861  44\n\
2862 0.0\n\
2863 173\n\
2864  0\n\
2865 291\n\
2866  1\n\
2867  45\n\
2868 0.0\n\
2869 1001\n\
2870 ACAD\n\
2871 1000\n\
2872 AcDbSavedByObjectVersion\n\
2873 1070\n\
2874  0\n\
2875  0\n\
2876 VISUALSTYLE\n\
2877  5\n\
2878 2D\n\
2879 102\n\
2880 {ACAD_REACTORS\n\
2881 330\n\
2882 2A\n\
2883 102\n\
2884 }\n\
2885 330\n\
2886 2A\n\
2887 100\n\
2888 AcDbVisualStyle\n\
2889  2\n\
2890 Gouraud\n\
2891  70\n\
2892  2\n\
2893  71\n\
2894  2\n\
2895  72\n\
2896  2\n\
2897  73\n\
2898  1\n\
2899  90\n\
2900  2\n\
2901  40\n\
2902 -0.6\n\
2903  41\n\
2904 30.0\n\
2905  62\n\
2906  5\n\
2907  63\n\
2908  7\n\
2909 421\n\
2910  16777215\n\
2911  74\n\
2912  0\n\
2913  91\n\
2914  4\n\
2915  64\n\
2916  7\n\
2917  65\n\
2918  257\n\
2919  75\n\
2920  1\n\
2921 175\n\
2922  1\n\
2923  42\n\
2924 1.0\n\
2925  92\n\
2926  0\n\
2927  66\n\
2928  7\n\
2929  43\n\
2930 1.0\n\
2931  76\n\
2932  1\n\
2933  77\n\
2934  6\n\
2935  78\n\
2936  2\n\
2937  67\n\
2938  7\n\
2939  79\n\
2940  5\n\
2941 170\n\
2942  0\n\
2943 171\n\
2944  0\n\
2945 290\n\
2946  0\n\
2947 174\n\
2948  0\n\
2949  93\n\
2950  13\n\
2951  44\n\
2952 0.0\n\
2953 173\n\
2954  0\n\
2955 291\n\
2956  1\n\
2957  45\n\
2958 0.0\n\
2959 1001\n\
2960 ACAD\n\
2961 1000\n\
2962 AcDbSavedByObjectVersion\n\
2963 1070\n\
2964  0\n\
2965  0\n\
2966 VISUALSTYLE\n\
2967  5\n\
2968 2E\n\
2969 102\n\
2970 {ACAD_REACTORS\n\
2971 330\n\
2972 2A\n\
2973 102\n\
2974 }\n\
2975 330\n\
2976 2A\n\
2977 100\n\
2978 AcDbVisualStyle\n\
2979  2\n\
2980 GouraudWithEdges\n\
2981  70\n\
2982  3\n\
2983  71\n\
2984  2\n\
2985  72\n\
2986  2\n\
2987  73\n\
2988  1\n\
2989  90\n\
2990  2\n\
2991  40\n\
2992 -0.6\n\
2993  41\n\
2994 30.0\n\
2995  62\n\
2996  5\n\
2997  63\n\
2998  7\n\
2999 421\n\
3000  16777215\n\
3001  74\n\
3002  1\n\
3003  91\n\
3004  4\n\
3005  64\n\
3006  7\n\
3007  65\n\
3008  257\n\
3009  75\n\
3010  1\n\
3011 175\n\
3012  1\n\
3013  42\n\
3014 1.0\n\
3015  92\n\
3016  0\n\
3017  66\n\
3018  257\n\
3019  43\n\
3020 1.0\n\
3021  76\n\
3022  1\n\
3023  77\n\
3024  6\n\
3025  78\n\
3026  2\n\
3027  67\n\
3028  7\n\
3029  79\n\
3030  5\n\
3031 170\n\
3032  0\n\
3033 171\n\
3034  0\n\
3035 290\n\
3036  0\n\
3037 174\n\
3038  0\n\
3039  93\n\
3040  13\n\
3041  44\n\
3042 0.0\n\
3043 173\n\
3044  0\n\
3045 291\n\
3046  1\n\
3047  45\n\
3048 0.0\n\
3049 1001\n\
3050 ACAD\n\
3051 1000\n\
3052 AcDbSavedByObjectVersion\n\
3053 1070\n\
3054  0\n\
3055  0\n\
3056 VISUALSTYLE\n\
3057  5\n\
3058 38\n\
3059 102\n\
3060 {ACAD_REACTORS\n\
3061 330\n\
3062 2A\n\
3063 102\n\
3064 }\n\
3065 330\n\
3066 2A\n\
3067 100\n\
3068 AcDbVisualStyle\n\
3069  2\n\
3070 Linepattern\n\
3071  70\n\
3072  14\n\
3073  71\n\
3074  2\n\
3075  72\n\
3076  2\n\
3077  73\n\
3078  0\n\
3079  90\n\
3080  0\n\
3081  40\n\
3082 -0.6\n\
3083  41\n\
3084 -30.0\n\
3085  62\n\
3086  5\n\
3087  63\n\
3088  7\n\
3089 421\n\
3090  16777215\n\
3091  74\n\
3092  1\n\
3093  91\n\
3094  4\n\
3095  64\n\
3096  7\n\
3097  65\n\
3098  257\n\
3099  75\n\
3100  7\n\
3101 175\n\
3102  7\n\
3103  42\n\
3104 1.0\n\
3105  92\n\
3106  8\n\
3107  66\n\
3108  7\n\
3109  43\n\
3110 1.0\n\
3111  76\n\
3112  1\n\
3113  77\n\
3114  6\n\
3115  78\n\
3116  2\n\
3117  67\n\
3118  7\n\
3119  79\n\
3120  5\n\
3121 170\n\
3122  0\n\
3123 171\n\
3124  0\n\
3125 290\n\
3126  0\n\
3127 174\n\
3128  0\n\
3129  93\n\
3130  1\n\
3131  44\n\
3132 0.0\n\
3133 173\n\
3134  0\n\
3135 291\n\
3136  1\n\
3137  45\n\
3138 0.0\n\
3139 1001\n\
3140 ACAD\n\
3141 1000\n\
3142 AcDbSavedByObjectVersion\n\
3143 1070\n\
3144  0\n\
3145  0\n\
3146 VISUALSTYLE\n\
3147  5\n\
3148 33\n\
3149 102\n\
3150 {ACAD_REACTORS\n\
3151 330\n\
3152 2A\n\
3153 102\n\
3154 }\n\
3155 330\n\
3156 2A\n\
3157 100\n\
3158 AcDbVisualStyle\n\
3159  2\n\
3160 Realistic\n\
3161  70\n\
3162  8\n\
3163  71\n\
3164  2\n\
3165  72\n\
3166  2\n\
3167  73\n\
3168  0\n\
3169  90\n\
3170  0\n\
3171  40\n\
3172 -0.6\n\
3173  41\n\
3174 -30.0\n\
3175  62\n\
3176  5\n\
3177  63\n\
3178  7\n\
3179 421\n\
3180  16777215\n\
3181  74\n\
3182  1\n\
3183  91\n\
3184  0\n\
3185  64\n\
3186  7\n\
3187  65\n\
3188  257\n\
3189  75\n\
3190  1\n\
3191 175\n\
3192  1\n\
3193  42\n\
3194 1.0\n\
3195  92\n\
3196  8\n\
3197  66\n\
3198  8\n\
3199 424\n\
3200  7895160\n\
3201  43\n\
3202 1.0\n\
3203  76\n\
3204  1\n\
3205  77\n\
3206  6\n\
3207  78\n\
3208  2\n\
3209  67\n\
3210  7\n\
3211  79\n\
3212  5\n\
3213 170\n\
3214  0\n\
3215 171\n\
3216  0\n\
3217 290\n\
3218  0\n\
3219 174\n\
3220  0\n\
3221  93\n\
3222  13\n\
3223  44\n\
3224 0.0\n\
3225 173\n\
3226  0\n\
3227 291\n\
3228  0\n\
3229  45\n\
3230 0.0\n\
3231 1001\n\
3232 ACAD\n\
3233 1000\n\
3234 AcDbSavedByObjectVersion\n\
3235 1070\n\
3236  0\n\
3237  0\n\
3238 VISUALSTYLE\n\
3239  5\n\
3240 37\n\
3241 102\n\
3242 {ACAD_REACTORS\n\
3243 330\n\
3244 2A\n\
3245 102\n\
3246 }\n\
3247 330\n\
3248 2A\n\
3249 100\n\
3250 AcDbVisualStyle\n\
3251  2\n\
3252 Thicken\n\
3253  70\n\
3254  13\n\
3255  71\n\
3256  2\n\
3257  72\n\
3258  2\n\
3259  73\n\
3260  0\n\
3261  90\n\
3262  0\n\
3263  40\n\
3264 -0.6\n\
3265  41\n\
3266 -30.0\n\
3267  62\n\
3268  5\n\
3269  63\n\
3270  7\n\
3271 421\n\
3272  16777215\n\
3273  74\n\
3274  1\n\
3275  91\n\
3276  4\n\
3277  64\n\
3278  7\n\
3279  65\n\
3280  257\n\
3281  75\n\
3282  1\n\
3283 175\n\
3284  1\n\
3285  42\n\
3286 1.0\n\
3287  92\n\
3288  12\n\
3289  66\n\
3290  7\n\
3291  43\n\
3292 1.0\n\
3293  76\n\
3294  1\n\
3295  77\n\
3296  6\n\
3297  78\n\
3298  2\n\
3299  67\n\
3300  7\n\
3301  79\n\
3302  5\n\
3303 170\n\
3304  0\n\
3305 171\n\
3306  0\n\
3307 290\n\
3308  0\n\
3309 174\n\
3310  0\n\
3311  93\n\
3312  1\n\
3313  44\n\
3314 0.0\n\
3315 173\n\
3316  0\n\
3317 291\n\
3318  1\n\
3319  45\n\
3320 0.0\n\
3321 1001\n\
3322 ACAD\n\
3323 1000\n\
3324 AcDbSavedByObjectVersion\n\
3325 1070\n\
3326  0\n\
3327  0\n\
3328 ENDSEC\n\
3329 ";
3330 
3331  writeGroup( 0, "EOF" );
3332 }
3333 
3334 void QgsDxfExport::startSection()
3335 {
3336  writeGroup( 0, "SECTION" );
3337 }
3338 
3339 void QgsDxfExport::endSection()
3340 {
3341  writeGroup( 0, "ENDSEC" );
3342 }
3343 
3344 void QgsDxfExport::writePoint( const QgsPointV2 &pt, const QString& layer, const QColor& color, QgsSymbolV2RenderContext &ctx, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol, double angle )
3345 {
3346 #if 0
3347  // debug: draw rectangle for debugging
3348  const QgsMarkerSymbolLayerV2* msl = dynamic_cast< const QgsMarkerSymbolLayerV2* >( symbolLayer );
3349  if ( msl )
3350  {
3351  double halfSize = msl->size() * mapUnitScaleFactor( mSymbologyScaleDenominator,
3352  msl->sizeUnit(), mMapUnits ) / 2.0;
3353  writeGroup( 0, "SOLID" );
3354  writeGroup( 8, layer );
3355  writeGroup( 62, 1 );
3356  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ, pt.x() - halfSize, pt.y() - halfSize ) );
3357  writeGroup( 1, QgsPointV2( QgsWKBTypes::PointZ, pt.x() + halfSize, pt.y() - halfSize ) );
3358  writeGroup( 2, QgsPointV2( QgsWKBTypes::PointZ, pt.x() - halfSize, pt.y() + halfSize ) );
3359  writeGroup( 3, QgsPointV2( QgsWKBTypes::PointZ, pt.x() + halfSize, pt.y() + halfSize ) );
3360  }
3361 #endif // 0
3362 
3363  // insert block or write point directly?
3364  QHash< const QgsSymbolLayerV2*, QString >::const_iterator blockIt = mPointSymbolBlocks.constFind( symbolLayer );
3365  if ( !symbolLayer || blockIt == mPointSymbolBlocks.constEnd() )
3366  {
3367  // write symbol directly here
3368  const QgsMarkerSymbolLayerV2* msl = dynamic_cast< const QgsMarkerSymbolLayerV2* >( symbolLayer );
3369  if ( msl && symbol )
3370  {
3371  if ( symbolLayer->writeDxf( *this, mapUnitScaleFactor( mSymbologyScaleDenominator, msl->sizeUnit(), mMapUnits ), layer, ctx, QPointF( pt.x(), pt.y() ) ) )
3372  {
3373  return;
3374  }
3375  }
3376  writePoint( layer, color, pt ); // write default point symbol
3377  }
3378  else
3379  {
3380  // insert block reference
3381  writeGroup( 0, "INSERT" );
3382  writeHandle();
3383  writeGroup( 100, "AcDbEntity" );
3384  writeGroup( 100, "AcDbBlockReference" );
3385  writeGroup( 8, layer );
3386  writeGroup( 2, blockIt.value() ); // Block name
3387  writeGroup( 50, angle ); // angle
3388  writeGroup( 0, pt ); // Insertion point (in OCS)
3389  }
3390 }
3391 
3392 void QgsDxfExport::writePolyline( const QgsPolyline &line, const QString& layer, const QString& lineStyleName, const QColor& color, double width )
3393 {
3395  Q_FOREACH ( const QgsPoint& p, line )
3396  s << QgsPointV2( p );
3397  writePolyline( s, layer, lineStyleName, color, width );
3398 }
3399 
3400 void QgsDxfExport::writePolyline( const QgsPointSequenceV2 &line, const QString& layer, const QString& lineStyleName, const QColor& color, double width )
3401 {
3402  int n = line.size();
3403  if ( n == 0 )
3404  {
3405  QgsDebugMsg( QString( "writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3406  return;
3407  }
3408 
3409  bool polygon = line[0] == line[ line.size() - 1 ];
3410  if ( polygon )
3411  --n;
3412  if ( n < 2 )
3413  {
3414  QgsDebugMsg( QString( "writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3415  return;
3416  }
3417 
3418  if ( !line.at( 0 ).is3D() )
3419  {
3420  writeGroup( 0, "LWPOLYLINE" );
3421  writeHandle();
3422  writeGroup( 8, layer );
3423  writeGroup( 100, "AcDbEntity" );
3424  writeGroup( 100, "AcDbPolyline" );
3425  writeGroup( 6, lineStyleName );
3426  writeGroup( color );
3427 
3428  writeGroup( 90, n );
3429  writeGroup( 70, polygon ? 1 : 0 );
3430  writeGroup( 43, width );
3431 
3432  for ( int i = 0; i < n; i++ )
3433  writeGroup( 0, line[i] );
3434  }
3435  else
3436  {
3437  writeGroup( 0, "POLYLINE" );
3438  writeHandle();
3439  writeGroup( 8, layer );
3440  writeGroup( 100, "AcDbEntity" );
3441  writeGroup( 100, "AcDb3dPolyline" );
3442  writeGroup( 6, lineStyleName );
3444  writeGroup( color );
3445  writeGroup( 70, 8 );
3446 
3447  for ( int i = 0; i < n; i++ )
3448  {
3449  writeGroup( 0, "VERTEX" );
3450  writeHandle();
3451  writeGroup( 8, layer );
3452  writeGroup( 100, "AcDbEntity" );
3453  writeGroup( 100, "AcDbVertex" );
3454  writeGroup( 100, "AcDb3dPolylineVertex" );
3455  writeGroup( 0, line[i] );
3456  writeGroup( 70, 32 );
3457  }
3458 
3459  writeGroup( 0, "SEQEND" );
3460  writeHandle();
3461  writeGroup( 8, layer );
3462  writeGroup( 100, "AcDbEntity" );
3463  }
3464 }
3465 
3466 void QgsDxfExport::writePolygon( const QgsPolygon &polygon, const QString& layer, const QString& hatchPattern, const QColor& color )
3467 {
3469 
3470  Q_FOREACH ( const QgsPolyline& l, polygon )
3471  {
3473  Q_FOREACH ( const QgsPoint& p, l )
3474  s << QgsPointV2( p );
3475  r << s;
3476  }
3477 
3478  writePolygon( r, layer, hatchPattern, color );
3479 }
3480 
3481 
3482 void QgsDxfExport::writePolygon( const QgsRingSequenceV2 &polygon, const QString& layer, const QString& hatchPattern, const QColor& color )
3483 {
3484  writeGroup( 0, "HATCH" ); // Entity type
3485  writeHandle();
3486  writeGroup( 330, mBlockHandle );
3487  writeGroup( 100, "AcDbEntity" );
3488  writeGroup( 8, layer ); // Layer name
3489  writeGroup( color ); // Color
3490  writeGroup( 100, "AcDbHatch" );
3491 
3492  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ ) ); // Elevation point (in OCS)
3493  writeGroup( 200, QgsPointV2( QgsWKBTypes::PointZ, 0.0, 0.0, 1.0 ) );
3494 
3495  writeGroup( 2, hatchPattern ); // Hatch pattern name
3496  writeGroup( 70, hatchPattern == "SOLID" ); // Solid fill flag (solid fill = 1; pattern fill = 0)
3497  writeGroup( 71, 0 ); // Associativity flag (associative = 1; non-associative = 0)
3498 
3499  writeGroup( 91, polygon.size() ); // Number of boundary paths (loops)
3500  for ( int i = 0; i < polygon.size(); ++i )
3501  {
3502  writeGroup( 92, 2 ); // Boundary path type flag (bit coded): 0 = Default; 1 = External; 2 = Polyline 4 = Derived; 8 = Textbox; 16 = Outermost
3503  writeGroup( 72, 0 ); // Has bulge flag
3504  writeGroup( 73, 1 ); // Is closed flag
3505  writeGroup( 93, polygon[i].size() ); // Number of edges in this boundary path (only if boundary is not a polyline
3506 
3507  for ( int j = 0; j < polygon[i].size(); ++j )
3508  {
3509  writeGroup( 0, polygon[i][j] ); // Vertex location (in OCS)
3510  }
3511 
3512  writeGroup( 97, 0 ); // Number of source boundary objects
3513  }
3514 
3515  writeGroup( 75, 0 ); // Hatch style: 0 = Hatch "odd parity" area (Normal style), 1 = Hatch outermost area only (Outer style), 2 = Hatch through entire area (Ignore style)
3516  writeGroup( 76, 1 ); // Hatch pattern type: 0 = User-defined; 1 = Predefined; 2 = Custom
3517 
3518  writeGroup( 98, 0 ); // Number of seed points
3519 }
3520 
3521 void QgsDxfExport::writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, const QColor& color, double width )
3522 {
3523  writeLine( QgsPointV2( pt1 ), QgsPointV2( pt2 ), layer, lineStyleName, color, width );
3524 }
3525 
3526 void QgsDxfExport::writeLine( const QgsPointV2& pt1, const QgsPointV2& pt2, const QString& layer, const QString& lineStyleName, const QColor& color, double width )
3527 {
3528  writePolyline( QgsPointSequenceV2() << pt1 << pt2, layer, lineStyleName, color, width );
3529 }
3530 
3531 void QgsDxfExport::writePoint( const QString &layer, const QColor &color, const QgsPoint &pt )
3532 {
3533  writePoint( layer, color, QgsPointV2( pt ) );
3534 }
3535 
3536 void QgsDxfExport::writePoint( const QString& layer, const QColor& color, const QgsPointV2 &pt )
3537 {
3538  writeGroup( 0, "POINT" );
3539  writeHandle();
3540  writeGroup( 100, "AcDbEntity" );
3541  writeGroup( 100, "AcDbPoint" );
3542  writeGroup( 8, layer );
3543  writeGroup( color );
3544  writeGroup( 0, pt );
3545 }
3546 
3547 void QgsDxfExport::writeFilledCircle( const QString &layer, const QColor& color, const QgsPoint &pt, double radius )
3548 {
3549  writeFilledCircle( layer, color, QgsPointV2( pt ), radius );
3550 }
3551 
3552 void QgsDxfExport::writeFilledCircle( const QString &layer, const QColor& color, const QgsPointV2 &pt, double radius )
3553 {
3554  writeGroup( 0, "HATCH" ); // Entity type
3555  writeHandle();
3556  writeGroup( 330, mBlockHandle );
3557  writeGroup( 100, "AcDbEntity" );
3558  writeGroup( 8, layer ); // Layer name
3559  writeGroup( color ); // Color (0 by block, 256 by layer)
3560  writeGroup( 100, "AcDbHatch" );
3561 
3562  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ ) ); // Elevation point (in OCS)
3563  writeGroup( 200, QgsPointV2( QgsWKBTypes::PointZ, 0.0, 0.0, 1.0 ) );
3564 
3565  writeGroup( 2, "SOLID" ); // Hatch pattern name
3566  writeGroup( 70, 1 ); // Solid fill flag (solid fill = 1; pattern fill = 0)
3567  writeGroup( 71, 0 ); // Associativity flag (associative = 1; non-associative = 0)
3568 
3569  writeGroup( 91, 1 ); // Number of boundary paths (loops)
3570 
3571  writeGroup( 92, 3 ); // Boundary path type flag (bit coded): 0 = Default; 1 = External; 2 = Polyline 4 = Derived; 8 = Textbox; 16 = Outermost
3572  writeGroup( 72, 1 );
3573  writeGroup( 73, 1 ); // Is closed flag
3574  writeGroup( 93, 2 ); // Number of polyline vertices
3575 
3576  writeGroup( 0, QgsPointV2( QgsWKBTypes::Point, pt.x() - radius, pt.y() ) );
3577  writeGroup( 42, 1.0 );
3578 
3579  writeGroup( 0, QgsPointV2( QgsWKBTypes::Point, pt.x() + radius, pt.y() ) );
3580  writeGroup( 42, 1.0 );
3581 
3582  writeGroup( 97, 0 ); // Number of source boundary objects
3583 
3584  writeGroup( 75, 0 ); // Hatch style: 0 = Hatch "odd parity" area (Normal style), 1 = Hatch outermost area only (Outer style), 2 = Hatch through entire area (Ignore style)
3585  writeGroup( 76, 1 ); // Hatch pattern type: 0 = User-defined; 1 = Predefined; 2 = Custom
3586  writeGroup( 98, 0 ); // Number of seed points
3587 }
3588 
3589 void QgsDxfExport::writeCircle( const QString& layer, const QColor& color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width )
3590 {
3591  writeCircle( layer, color, QgsPointV2( pt ), radius, lineStyleName, width );
3592 }
3593 
3594 void QgsDxfExport::writeCircle( const QString& layer, const QColor& color, const QgsPointV2 &pt, double radius, const QString &lineStyleName, double width )
3595 {
3596  writeGroup( 0, "LWPOLYLINE" );
3597  writeHandle();
3598  writeGroup( 330, mBlockHandle );
3599  writeGroup( 8, layer );
3600  writeGroup( 100, "AcDbEntity" );
3601  writeGroup( 100, "AcDbPolyline" );
3602  writeGroup( 6, lineStyleName );
3603  writeGroup( color );
3604 
3605  writeGroup( 90, 2 );
3606 
3607  writeGroup( 70, 1 );
3608  writeGroup( 43, width );
3609 
3610  writeGroup( 0, QgsPointV2( pt.x() - radius, pt.y() ) );
3611  writeGroup( 42, 1.0 );
3612  writeGroup( 0, QgsPointV2( pt.x() + radius, pt.y() ) );
3613  writeGroup( 42, 1.0 );
3614 }
3615 
3616 void QgsDxfExport::writeText( const QString& layer, const QString& text, const QgsPoint &pt, double size, double angle, const QColor& color )
3617 {
3618  writeText( layer, text, QgsPointV2( pt ), size, angle, color );
3619 }
3620 
3621 void QgsDxfExport::writeText( const QString& layer, const QString& text, const QgsPointV2 &pt, double size, double angle, const QColor& color )
3622 {
3623  writeGroup( 0, "TEXT" );
3624  writeHandle();
3625  writeGroup( 100, "AcDbEntity" );
3626  writeGroup( 100, "AcDbText" );
3627  writeGroup( 8, layer );
3628  writeGroup( color );
3629  writeGroup( 0, pt );
3630  writeGroup( 40, size );
3631  writeGroup( 1, text );
3632  writeGroup( 50, angle );
3633  writeGroup( 7, "STANDARD" ); // so far only support for standard font
3634 }
3635 
3636 void QgsDxfExport::writeMText( const QString& layer, const QString& text, const QgsPoint &pt, double width, double angle, const QColor& color )
3637 {
3638  writeMText( layer, text, QgsPointV2( pt ), width, angle, color );
3639 }
3640 
3641 void QgsDxfExport::writeMText( const QString& layer, const QString& text, const QgsPointV2 &pt, double width, double angle, const QColor& color )
3642 {
3643  if ( !mTextStream.codec()->canEncode( text ) )
3644  {
3645  // TODO return error
3646  return;
3647  }
3648 
3649  writeGroup( 0, "MTEXT" );
3650  writeHandle();
3651  writeGroup( 100, "AcDbEntity" );
3652  writeGroup( 100, "AcDbMText" );
3653  writeGroup( 8, layer );
3654  writeGroup( color );
3655 
3656  writeGroup( 0, pt );
3657 
3658  QString t( text );
3659  while ( t.length() > 250 )
3660  {
3661  writeGroup( 3, t.left( 250 ) );
3662  t = t.mid( 250 );
3663  }
3664  writeGroup( 1, text );
3665 
3666  writeGroup( 50, angle ); // Rotation angle in radians
3667  writeGroup( 41, width * 1.1 ); // Reference rectangle width
3668 
3669  // Attachment point:
3670  // 1 2 3
3671  // 4 5 6
3672  // 7 8 9
3673  writeGroup( 71, 7 );
3674 
3675  writeGroup( 7, "STANDARD" ); // so far only support for standard font
3676 }
3677 
3678 void QgsDxfExport::writeSolid( const QString& layer, const QColor& color, const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, const QgsPoint &pt4 )
3679 {
3680  // pt1 pt2
3681  // pt3 pt4
3683  p << QgsPointV2( pt1 ) << QgsPointV2( pt2 ) << QgsPointV2( pt4 );
3684  if ( pt3 != pt4 )
3685  p << QgsPointV2( pt3 );
3686  p << QgsPointV2( pt1 );
3687  writePolygon( QgsRingSequenceV2() << p, layer, "SOLID", color );
3688 }
3689 
3690 QgsRectangle QgsDxfExport::dxfExtent() const
3691 {
3693  QList< QPair<QgsVectorLayer*, int> >::const_iterator layerIt = mLayers.constBegin();
3694  for ( ; layerIt != mLayers.constEnd(); ++layerIt )
3695  {
3696  if ( layerIt->first )
3697  {
3698  if ( extent.isEmpty() )
3699  {
3700  extent = layerIt->first->extent();
3701  }
3702  else
3703  {
3704  QgsRectangle layerExtent = layerIt->first->extent();
3705  extent.combineExtentWith( layerExtent );
3706  }
3707  }
3708  }
3709  return extent;
3710 }
3711 
3712 void QgsDxfExport::addFeature( QgsSymbolV2RenderContext& ctx, const QString& layer, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol )
3713 {
3714  const QgsFeature* fet = ctx.feature();
3715  if ( !fet )
3716  return;
3717 
3718  if ( !fet->constGeometry() )
3719  return;
3720 
3721  const QgsAbstractGeometryV2 *geom = fet->constGeometry()->geometry();
3722 
3723  QgsWKBTypes::Type geometryType = geom->wkbType();
3724 
3725  QColor penColor;
3726  QColor brushColor;
3727  if ( mSymbologyExport != NoSymbology )
3728  {
3729  penColor = colorFromSymbolLayer( symbolLayer, ctx );
3730  brushColor = symbolLayer->dxfBrushColor( ctx );
3731  }
3732 
3733  Qt::PenStyle penStyle( Qt::SolidLine );
3734  Qt::BrushStyle brushStyle( Qt::NoBrush );
3735  double width = -1;
3736  double offset = 0.0;
3737  double angle = 0.0;
3738  if ( mSymbologyExport != NoSymbology && symbolLayer )
3739  {
3740  width = symbolLayer->dxfWidth( *this, ctx );
3741  offset = symbolLayer->dxfOffset( *this, ctx );
3742  angle = symbolLayer->dxfAngle( ctx );
3743  penStyle = symbolLayer->dxfPenStyle();
3744  brushStyle = symbolLayer->dxfBrushStyle();
3745 
3746  if ( qgsDoubleNear( offset, 0.0 ) )
3747  offset = 0.0;
3748  }
3749 
3750  QString lineStyleName = "CONTINUOUS";
3751  if ( mSymbologyExport != NoSymbology )
3752  {
3753  lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
3754  }
3755 
3756  // single point
3757  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::Point )
3758  {
3759  writePoint( geom->coordinateSequence().at( 0 ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol, angle );
3760  return;
3761  }
3762 
3763  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::MultiPoint )
3764  {
3765  const QgsCoordinateSequenceV2 &cs = geom->coordinateSequence();
3766  for ( int i = 0; i < cs.size(); i++ )
3767  {
3768  writePoint( cs.at( i ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol, angle );
3769  }
3770  return;
3771  }
3772 
3773  if ( penStyle != Qt::NoPen )
3774  {
3775  // single line
3776  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::LineString )
3777  {
3778  const QgsAbstractGeometryV2 *offsetGeom = geom;
3779  if ( !qgsDoubleNear( offset, 0.0 ) )
3780  {
3781  QgsGeos geos( geom );
3782  offsetGeom = geos.offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
3783  if ( !offsetGeom )
3784  offsetGeom = geom;
3785  }
3786 
3787  writePolyline( offsetGeom->coordinateSequence().at( 0 ).at( 0 ), layer, lineStyleName, penColor, width );
3788 
3789  if ( offsetGeom != geom )
3790  delete offsetGeom;
3791  }
3792 
3793  // multiline
3794  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::MultiLineString )
3795  {
3796  const QgsAbstractGeometryV2 *offsetGeom = geom;
3797 
3798  if ( !qgsDoubleNear( offset, 0.0 ) )
3799  {
3800  QgsGeos geos( geom );
3801  offsetGeom = geos.offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
3802  if ( !offsetGeom )
3803  offsetGeom = geom;
3804  }
3805 
3806  const QgsCoordinateSequenceV2 &cs = offsetGeom->coordinateSequence();
3807  for ( int i = 0; i < cs.size(); i++ )
3808  {
3809  writePolyline( cs.at( i ).at( 0 ), layer, lineStyleName, penColor, width );
3810  }
3811 
3812  if ( offsetGeom != geom )
3813  delete offsetGeom;
3814  }
3815 
3816  // polygon
3817  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::Polygon )
3818  {
3819  const QgsAbstractGeometryV2 *bufferGeom = geom;
3820 
3821  if ( !qgsDoubleNear( offset, 0.0 ) )
3822  {
3823  QgsGeos geos( geom );
3824  bufferGeom = geos.buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3825  if ( !bufferGeom )
3826  bufferGeom = geom;
3827  }
3828 
3829  const QgsCoordinateSequenceV2 &cs = bufferGeom->coordinateSequence();
3830  for ( int i = 0; i < cs.at( 0 ).size(); i++ )
3831  {
3832  writePolyline( cs.at( 0 ).at( i ), layer, lineStyleName, penColor, width );
3833  }
3834 
3835  if ( bufferGeom != geom )
3836  delete bufferGeom;
3837  }
3838 
3839  // multipolygon or polygon
3840  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::MultiPolygon )
3841  {
3842  const QgsAbstractGeometryV2 *bufferGeom = geom;
3843 
3844  if ( !qgsDoubleNear( offset, 0.0 ) )
3845  {
3846  QgsGeos geos( geom );
3847  bufferGeom = geos.buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3848  if ( !bufferGeom )
3849  bufferGeom = geom;
3850  }
3851 
3852  const QgsCoordinateSequenceV2 &cs = bufferGeom->coordinateSequence();
3853  for ( int i = 0; i < cs.size(); i++ )
3854  for ( int j = 0; j < cs.at( i ).size(); j++ )
3855  writePolyline( cs.at( i ).at( j ), layer, lineStyleName, penColor, width );
3856 
3857  if ( bufferGeom != geom )
3858  delete bufferGeom;
3859  }
3860  }
3861 
3862  if ( brushStyle != Qt::NoBrush )
3863  {
3864  // polygon
3865  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::Polygon )
3866  {
3867  writePolygon( geom->coordinateSequence().at( 0 ), layer, "SOLID", brushColor );
3868  }
3869 
3870  // multipolygon or polygon
3871  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::MultiPolygon )
3872  {
3873  const QgsCoordinateSequenceV2 &cs = geom->coordinateSequence();
3874  for ( int i = 0; i < cs.size(); i++ )
3875  {
3876  writePolygon( cs.at( i ), layer, "SOLID", brushColor );
3877  }
3878  }
3879  }
3880 }
3881 
3882 QColor QgsDxfExport::colorFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer, QgsSymbolV2RenderContext &ctx )
3883 {
3884  if ( !symbolLayer )
3885  return QColor();
3886 
3887  return symbolLayer->dxfColor( ctx );
3888 }
3889 
3890 QString QgsDxfExport::lineStyleFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer )
3891 {
3892  QString lineStyleName = "CONTINUOUS";
3893  if ( !symbolLayer )
3894  {
3895  return lineStyleName;
3896  }
3897 
3898  QHash< const QgsSymbolLayerV2*, QString >::const_iterator lineTypeIt = mLineStyles.constFind( symbolLayer );
3899  if ( lineTypeIt != mLineStyles.constEnd() )
3900  {
3901  lineStyleName = lineTypeIt.value();
3902  return lineStyleName;
3903  }
3904  else
3905  {
3906  return lineNameFromPenStyle( symbolLayer->dxfPenStyle() );
3907  }
3908 }
3909 
3911 {
3912  int idx = 0;
3913  int current_distance = INT_MAX;
3914  for ( int i = 1; i < static_cast< int >( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ); ++i )
3915  {
3916  int dist = color_distance( pixel, i );
3917  if ( dist < current_distance )
3918  {
3919  current_distance = dist;
3920  idx = i;
3921  if ( dist == 0 )
3922  break;
3923  }
3924  }
3925  return idx;
3926 }
3927 
3928 int QgsDxfExport::color_distance( QRgb p1, int index )
3929 {
3930  if ( index > 255 || index < 0 )
3931  {
3932  return 0;
3933  }
3934 
3935  double redDiff = qRed( p1 ) - mDxfColors[index][0];
3936  double greenDiff = qGreen( p1 ) - mDxfColors[index][1];
3937  double blueDiff = qBlue( p1 ) - mDxfColors[index][2];
3938 #if 0
3939  QgsDebugMsg( QString( "color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
3940  .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
3941  .arg( index )
3942  .arg( mDxfColors[index][0] )
3943  .arg( mDxfColors[index][1] )
3944  .arg( mDxfColors[index][2] )
3945  .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
3946 #endif
3947  return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
3948 }
3949 
3950 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
3951 {
3952  return QColor::fromRgbF( r, g, b ).rgb();
3953 }
3954 
3955 QgsRenderContext QgsDxfExport::renderContext() const
3956 {
3957  QgsRenderContext context;
3958  context.setRendererScale( mSymbologyScaleDenominator );
3959  return context;
3960 }
3961 
3963 {
3964  if ( symbolUnits == QgsSymbolV2::MapUnit )
3965  {
3966  return 1.0;
3967  }
3968  // MM symbol unit
3969  return scaleDenominator * QgsUnitTypes::fromUnitToUnitFactor( QGis::Meters, mapUnits ) / 1000.0;
3970 }
3971 
3972 QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > QgsDxfExport::symbolLayers( QgsRenderContext &context )
3973 {
3975 
3976  QList< QPair< QgsVectorLayer*, int> >::const_iterator lIt = mLayers.constBegin();
3977  for ( ; lIt != mLayers.constEnd(); ++lIt )
3978  {
3979  // cast to vector layer
3980  QgsVectorLayer* vl = lIt->first;
3981  if ( !vl )
3982  {
3983  continue;
3984  }
3985 
3986  // get rendererv2
3987  QgsFeatureRendererV2* r = vl->rendererV2();
3988  if ( !r )
3989  {
3990  continue;
3991  }
3992 
3993  // get all symbols
3994  QgsSymbolV2List symbols = r->symbols( context );
3995  QgsSymbolV2List::iterator symbolIt = symbols.begin();
3996  for ( ; symbolIt != symbols.end(); ++symbolIt )
3997  {
3998  int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
3999  if ( mSymbologyExport != SymbolLayerSymbology )
4000  {
4001  maxSymbolLayers = 1;
4002  }
4003  for ( int i = 0; i < maxSymbolLayers; ++i )
4004  {
4005  symbolLayers.append( qMakePair(( *symbolIt )->symbolLayer( i ), *symbolIt ) );
4006  }
4007  }
4008  }
4009 
4010  return symbolLayers;
4011 }
4012 
4013 void QgsDxfExport::writeDefaultLinetypes()
4014 {
4015  // continuous (Qt solid line)
4016  Q_FOREACH ( const QString& ltype, QStringList() << "ByLayer" << "ByBlock" << "CONTINUOUS" )
4017  {
4018  writeGroup( 0, "LTYPE" );
4019  writeHandle();
4020  writeGroup( 100, "AcDbSymbolTableRecord" );
4021  writeGroup( 100, "AcDbLinetypeTableRecord" );
4022  writeGroup( 2, ltype );
4023  writeGroup( 70, 64 );
4024  writeGroup( 3, "Defaultstyle" );
4025  writeGroup( 72, 65 );
4026  writeGroup( 73, 0 );
4027  writeGroup( 40, 0.0 );
4028  }
4029 
4030  double das = dashSize();
4031  double dss = dashSeparatorSize();
4032  double dos = dotSize();
4033 
4034  QVector<qreal> dashVector( 2 );
4035  dashVector[0] = das;
4036  dashVector[1] = dss;
4037  writeLinetype( "DASH", dashVector, QgsSymbolV2::MapUnit );
4038 
4039  QVector<qreal> dotVector( 2 );
4040  dotVector[0] = dos;
4041  dotVector[1] = dss;
4042  writeLinetype( "DOT", dotVector, QgsSymbolV2::MapUnit );
4043 
4044  QVector<qreal> dashDotVector( 4 );
4045  dashDotVector[0] = das;
4046  dashDotVector[1] = dss;
4047  dashDotVector[2] = dos;
4048  dashDotVector[3] = dss;
4049  writeLinetype( "DASHDOT", dashDotVector, QgsSymbolV2::MapUnit );
4050 
4051  QVector<qreal> dashDotDotVector( 6 );
4052  dashDotDotVector[0] = das;
4053  dashDotDotVector[1] = dss;
4054  dashDotDotVector[2] = dos;
4055  dashDotDotVector[3] = dss;
4056  dashDotDotVector[4] = dos;
4057  dashDotDotVector[5] = dss;
4058  writeLinetype( "DASHDOTDOT", dashDotDotVector, QgsSymbolV2::MapUnit );
4059 }
4060 
4061 void QgsDxfExport::writeSymbolLayerLinetype( const QgsSymbolLayerV2* symbolLayer )
4062 {
4063  if ( !symbolLayer )
4064  {
4065  return;
4066  }
4067 
4069  QVector<qreal> customLinestyle = symbolLayer->dxfCustomDashPattern( unit );
4070  if ( !customLinestyle.isEmpty() )
4071  {
4072  QString name = QString( "symbolLayer%1" ).arg( mSymbolLayerCounter++ );
4073  writeLinetype( name, customLinestyle, unit );
4074  mLineStyles.insert( symbolLayer, name );
4075  }
4076 }
4077 
4078 int QgsDxfExport::nLineTypes( const QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > >& symbolLayers )
4079 {
4080  int nLineTypes = 0;
4081  QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2*> >::const_iterator slIt = symbolLayers.constBegin();
4082  for ( ; slIt != symbolLayers.constEnd(); ++slIt )
4083  {
4084  const QgsSimpleLineSymbolLayerV2* simpleLine = dynamic_cast< const QgsSimpleLineSymbolLayerV2* >( slIt->first );
4085  if ( simpleLine )
4086  {
4087  if ( simpleLine->useCustomDashPattern() )
4088  {
4089  ++nLineTypes;
4090  }
4091  }
4092  }
4093  return nLineTypes;
4094 }
4095 
4096 void QgsDxfExport::writeLinetype( const QString& styleName, const QVector<qreal>& pattern, QgsSymbolV2::OutputUnit u )
4097 {
4098  double length = 0;
4099  QVector<qreal>::const_iterator dashIt = pattern.constBegin();
4100  for ( ; dashIt != pattern.constEnd(); ++dashIt )
4101  {
4102  length += ( *dashIt * mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits ) );
4103  }
4104 
4105  writeGroup( 0, "LTYPE" );
4106  writeHandle();
4107  // 330 5
4108  writeGroup( 100, "AcDbSymbolTableRecord" );
4109  writeGroup( 100, "AcDbLinetypeTableRecord" );
4110  writeGroup( 2, styleName );
4111  writeGroup( 70, 64 ); // 0?
4112  writeGroup( 3, "" );
4113  writeGroup( 72, 65 );
4114  writeGroup( 73, pattern.size() );
4115  writeGroup( 40, length );
4116 
4117  dashIt = pattern.constBegin();
4118  bool isGap = false;
4119  for ( ; dashIt != pattern.constEnd(); ++dashIt )
4120  {
4121  // map units or mm?
4122  double segmentLength = ( isGap ? -*dashIt : *dashIt );
4123  segmentLength *= mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits );
4124  writeGroup( 49, segmentLength );
4125  writeGroup( 74, 0 );
4126  isGap = !isGap;
4127  }
4128 }
4129 
4130 bool QgsDxfExport::hasDataDefinedProperties( const QgsSymbolLayerV2* sl, const QgsSymbolV2* symbol )
4131 {
4132  if ( !sl || !symbol )
4133  {
4134  return false;
4135  }
4136 
4139  {
4140  return true;
4141  }
4142 
4143  return sl->hasDataDefinedProperties();
4144 }
4145 
4146 double QgsDxfExport::dashSize() const
4147 {
4148  double size = mSymbologyScaleDenominator * 0.002;
4149  return sizeToMapUnits( size );
4150 }
4151 
4152 double QgsDxfExport::dotSize() const
4153 {
4154  double size = mSymbologyScaleDenominator * 0.0006;
4155  return sizeToMapUnits( size );
4156 }
4157 
4158 double QgsDxfExport::dashSeparatorSize() const
4159 {
4160  double size = mSymbologyScaleDenominator * 0.0006;
4161  return sizeToMapUnits( size );
4162 }
4163 
4164 double QgsDxfExport::sizeToMapUnits( double s ) const
4165 {
4166  double size = s * QgsUnitTypes::fromUnitToUnitFactor( QGis::Meters, mMapUnits );
4167  return size;
4168 }
4169 
4170 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
4171 {
4172  switch ( style )
4173  {
4174  case Qt::DashLine:
4175  return "DASH";
4176  case Qt::DotLine:
4177  return "DOT";
4178  case Qt::DashDotLine:
4179  return "DASHDOT";
4180  case Qt::DashDotDotLine:
4181  return "DASHDOTDOT";
4182  case Qt::SolidLine:
4183  default:
4184  return "CONTINUOUS";
4185  }
4186 }
4187 
4189 {
4190  if ( name.isEmpty() )
4191  return "0";
4192 
4193  // dxf layers can be max 255 characters long
4194  QString layerName = name.left( 255 );
4195 
4196  // replaced restricted characters with underscore
4197  // < > / \ " : ; ? * | = '
4198  // See http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-7345.htm,topicNumber=d0e41665
4199  layerName.replace( '<', '_' );
4200  layerName.replace( '>', '_' );
4201  layerName.replace( '/', '_' );
4202  layerName.replace( '\\', '_' );
4203  layerName.replace( '\"', '_' );
4204  layerName.replace( ':', '_' );
4205  layerName.replace( ';', '_' );
4206  layerName.replace( '?', '_' );
4207  layerName.replace( '*', '_' );
4208  layerName.replace( '|', '_' );
4209  layerName.replace( '=', '_' );
4210  layerName.replace( '\'', '_' );
4211 
4212  // also remove newline characters (#15067)
4213  layerName.replace( "\r\n", "_" );
4214  layerName.replace( '\r', '_' );
4215  layerName.replace( '\n', '_' );
4216 
4217  return layerName.trimmed();
4218 }
4219 
4220 bool QgsDxfExport::layerIsScaleBasedVisible( const QgsMapLayer* layer ) const
4221 {
4222  if ( !layer )
4223  return false;
4224 
4225  if ( mSymbologyExport == QgsDxfExport::NoSymbology )
4226  return true;
4227 
4228  return layer->isInScaleRange( mSymbologyScaleDenominator );
4229 }
4230 
4232 {
4233  QList< QPair<QgsVectorLayer*, int> >::const_iterator layerIt = mLayers.constBegin();
4234  for ( ; layerIt != mLayers.constEnd(); ++layerIt )
4235  {
4236  if ( layerIt->first && layerIt->first->id() == id )
4237  {
4238  return dxfLayerName( layerIt->second < 0 ? layerName( layerIt->first ) : f.attribute( layerIt->second ).toString() );
4239  }
4240  }
4241 
4242  return "0";
4243 }
4244 
4246 {
4247  Q_FOREACH ( const QByteArray& codec, QTextCodec::availableCodecs() )
4248  {
4249  if ( name != codec )
4250  continue;
4251 
4252  int i;
4253  for ( i = 0; i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
4254  ;
4255 
4256  if ( i == static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
4257  continue;
4258 
4259  return mDxfEncodings[i][0];
4260  }
4261 
4262  return QString::null;
4263 }
4264 
4266 {
4268  Q_FOREACH ( QByteArray codec, QTextCodec::availableCodecs() )
4269  {
4270  int i;
4271  for ( i = 0; i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && strcmp( codec.data(), mDxfEncodings[i][1] ) != 0; ++i )
4272  ;
4273 
4274  if ( i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
4275  encodings << codec.data();
4276  }
4277  return encodings;
4278 }
4279 
4281 {
4282  Q_ASSERT( vl );
4283  return mLayerTitleAsName && !vl->title().isEmpty() ? vl->title() : vl->name();
4284 }
4285 
4287 {
4288  Q_UNUSED( context );
4289 
4290  if ( !settings.drawLabels )
4291  return;
4292 
4293  QgsTextLabelFeature* lf = dynamic_cast<QgsTextLabelFeature*>( label->getFeaturePart()->feature() );
4294 
4295  // Copy to temp, editable layer settings
4296  // these settings will be changed by any data defined values, then used for rendering label components
4297  // settings may be adjusted during rendering of components
4298  QgsPalLayerSettings tmpLyr( settings );
4299 
4300  // apply any previously applied data defined settings for the label
4302 
4303  //font
4304  QFont dFont = lf->definedFont();
4305  QgsDebugMsgLevel( QString( "PAL font tmpLyr: %1, Style: %2" ).arg( tmpLyr.textFont.toString(), tmpLyr.textFont.styleName() ), 4 );
4306  QgsDebugMsgLevel( QString( "PAL font definedFont: %1, Style: %2" ).arg( dFont.toString(), dFont.styleName() ), 4 );
4307  tmpLyr.textFont = dFont;
4308 
4310  {
4311  //calculate font alignment based on label quadrant
4312  switch ( label->getQuadrant() )
4313  {
4318  break;
4323  break;
4328  break;
4329  }
4330  }
4331 
4332  // update tmpLyr with any data defined text style values
4333  QgsPalLabeling::dataDefinedTextStyle( tmpLyr, ddValues );
4334 
4335  // update tmpLyr with any data defined text buffer values
4336  QgsPalLabeling::dataDefinedTextBuffer( tmpLyr, ddValues );
4337 
4338  // update tmpLyr with any data defined text formatting values
4339  QgsPalLabeling::dataDefinedTextFormatting( tmpLyr, ddValues );
4340 
4341  // add to the results
4342  QString txt = label->getFeaturePart()->feature()->labelText();
4343 
4344  QgsFeatureId fid = label->getFeaturePart()->featureId();
4345  QString dxfLayer = mDxfLayerNames[layerId][fid];
4346 
4347  QString wrapchr = tmpLyr.wrapChar.isEmpty() ? "\n" : tmpLyr.wrapChar;
4348 
4349  //add the direction symbol if needed
4350  if ( !txt.isEmpty() && tmpLyr.placement == QgsPalLayerSettings::Line && tmpLyr.addDirectionSymbol )
4351  {
4352  bool prependSymb = false;
4353  QString symb = tmpLyr.rightDirectionSymbol;
4354 
4355  if ( label->getReversed() )
4356  {
4357  prependSymb = true;
4358  symb = tmpLyr.leftDirectionSymbol;
4359  }
4360 
4361  if ( tmpLyr.reverseDirectionSymbol )
4362  {
4363  if ( symb == tmpLyr.rightDirectionSymbol )
4364  {
4365  prependSymb = true;
4366  symb = tmpLyr.leftDirectionSymbol;
4367  }
4368  else
4369  {
4370  prependSymb = false;
4371  symb = tmpLyr.rightDirectionSymbol;
4372  }
4373  }
4374 
4376  {
4377  prependSymb = true;
4378  symb = symb + wrapchr;
4379  }
4381  {
4382  prependSymb = false;
4383  symb = wrapchr + symb;
4384  }
4385 
4386  if ( prependSymb )
4387  {
4388  txt.prepend( symb );
4389  }
4390  else
4391  {
4392  txt.append( symb );
4393  }
4394  }
4395 
4396  txt = txt.replace( wrapchr, "\\P" );
4397 
4398  if ( tmpLyr.textFont.underline() )
4399  {
4400  txt.prepend( "\\L" ).append( "\\l" );
4401  }
4402 
4403  if ( tmpLyr.textFont.overline() )
4404  {
4405  txt.prepend( "\\O" ).append( "\\o" );
4406  }
4407 
4408  if ( tmpLyr.textFont.strikeOut() )
4409  {
4410  txt.prepend( "\\K" ).append( "\\k" );
4411  }
4412 
4413  txt.prepend( QString( "\\f%1|i%2|b%3;\\H%4;\\W0.75;" )
4414  .arg( tmpLyr.textFont.family() )
4415  .arg( tmpLyr.textFont.italic() ? 1 : 0 )
4416  .arg( tmpLyr.textFont.bold() ? 1 : 0 )
4417  .arg( label->getHeight() / ( 1 + txt.count( "\\P" ) ) * 0.75 ) );
4418 
4419  writeMText( dxfLayer, txt, QgsPointV2( label->getX(), label->getY() ), label->getWidth(), label->getAlpha() * 180.0 / M_PI, tmpLyr.textColor );
4420 }
4421 
4422 
4424 {
4425  if ( !mDxfLayerNames.contains( layerId ) )
4426  mDxfLayerNames[ layerId ] = QMap<QgsFeatureId, QString>();
4427 
4428  mDxfLayerNames[layerId][fid] = layerName;
4429 }
static double mapUnitScaleFactor(double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits)
void setCodec(QTextCodec *codec)
Wrapper for iterator of features from vector data provider or vector layer.
Q_DECL_DEPRECATED void writeSolid(const QString &layer, const QColor &color, const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, const QgsPoint &pt4)
Draw dxf filled polygon (SOLID)
static unsigned index
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Base class for all map layer types.
Definition: qgsmaplayer.h:49
void setDotsPerMeterX(int x)
void setDotsPerMeterY(int y)
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
QString & append(QChar ch)
bool isEmpty() const
test if rectangle is empty.
iterator insert(const Key &key, const T &value)
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:65
Q_DECL_DEPRECATED void writeLine(const QgsPoint &pt1, const QgsPoint &pt2, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Write line (as a polyline)
virtual Qt::PenStyle dxfPenStyle() const
get pen style
static void dataDefinedTextStyle(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
bool contains(const Key &key) const
const Key key(const T &value) const
virtual QgsCoordinateSequenceV2 coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames) override
Prepare for registration of features.
QgsLabelFeature * feature()
Returns the parent feature.
Definition: feature.h:110
rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
double x() const
Returns the point&#39;s x-coordinate.
Definition: qgspointv2.h:68
double getWidth() const
void addLayers(const QList< QPair< QgsVectorLayer *, int > > &layers)
Add layers to export.
void writeGroup(int code, int i)
Write a tuple of group code and integer value.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
QgsFields fields() const
Returns the list of fields of this layer.
int size() const
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
QString & prepend(QChar ch)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
Implements a derived label provider for rule based labels internally used for DXF export...
QGis::UnitType mapUnits() const
Retrieve map units.
Definition: qgsdxfexport.h:96
const_iterator constEnd() const
void setRendererScale(double scale)
const T & at(int i) const
void setOutputDpi(double dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:515
bool contains(const QString &str, Qt::CaseSensitivity cs) const
static int closestColorMatch(QRgb color)
Get DXF palette index of nearest entry for given color.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QString title() const
Get the title of the layer used by QGIS Server in GetCapabilities request.
Definition: qgsmaplayer.h:126
Class that adds extra information to QgsLabelFeature for text labels.
static QStringList encodings()
return list of available DXF encodings
The QgsLabelingEngineV2 class provides map labeling functionality.
Abstract base class for all geometries.
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features.
bool drawLabels
Whether to draw labels for this layer.
const_iterator constFind(const Key &key) const
QgsSymbolV2::OutputUnit sizeUnit() const
Returns the units for the symbol&#39;s size.
MultiLineAlign multilineAlign
The QGis class provides global constants for use throughout the application.
Definition: qgis.h:40
virtual QList< QString > usedAttributes()=0
Returns a set of attributes required for this renderer.
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
void readSettingsFromProject()
Read configuration of the labeling engine from the current project file.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
get line width
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
void setExtent(const QgsRectangle &extent)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
Definition: qgis.h:353
double x() const
Get the x value of the point.
Definition: qgspoint.h:185
void writeInt(int i)
Write an integer value.
bool bold() const
int size() const
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
bool italic() const
QGis::WkbType wkbType() const
Returns the WKBType or WKBUnknown in case of error.
The QgsMapSettings class contains configuration for rendering of the map.
double y() const
Returns the point&#39;s y-coordinate.
Definition: qgspointv2.h:74
QString styleName() const
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
void writeString(const QString &s)
Write a string value.
void reinit(QgsVectorLayer *layer)
Reinitialize the subproviders with QgsDxfLabelProviders.
int writeToFile(QIODevice *d, const QString &codec)
Export to a dxf file in the given encoding.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
QgsRectangle extent() const
Get extent of area to export.
Definition: qgsdxfexport.h:122
Q_DECL_DEPRECATED void writePoint(const QString &layer, const QColor &color, const QgsPoint &pt)
Write point.
bool exists(int i) const
Return if a field index is valid.
Definition: qgsfield.cpp:375
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
#define DXF_HANDMAX
The output shall be in millimeters.
Definition: qgssymbolv2.h:67
int count(const T &value) const
virtual Q_DECL_DEPRECATED QgsSymbolV2 * symbolForFeature(QgsFeature &feature)
To be overridden.
void append(const T &value)
void drawLabel(QString layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
Output the label.
void setOutputSize(QSize size)
Set the size of the resulting map image.
static void dataDefinedTextBuffer(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
void setScaleFactor(double factor)
const QgsFeature * feature() const
Current feature being rendered - may be null.
Definition: qgssymbolv2.h:384
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
const_iterator constEnd() const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Definition: qgsrectangle.h:202
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
void setDevice(QIODevice *device)
virtual QVector< qreal > dxfCustomDashPattern(QgsSymbolV2::OutputUnit &unit) const
get dash pattern
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:34
double z() const
Returns the point&#39;s z-coordinate.
Definition: qgspointv2.h:80
QRgb rgb() const
int red() const
void setMapUnits(QGis::UnitType u)
Set units of map&#39;s geographical coordinates - used for scale calculation.
Quadrant getQuadrant() const
void writeGroupCode(int code)
Write a group code.
QString name() const
Gets the name of the field.
Definition: qgsfield.cpp:84
Point geometry type, with support for z-dimension and m-values.
Definition: qgspointv2.h:34
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition: qgis.h:341
bool isEmpty() const
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
Get data-defined values.
QString trimmed() const
double getY(int i=0) const
get the down-left y coordinate
#define M_PI
The output shall be in map unitx.
Definition: qgssymbolv2.h:68
This class wraps a request for features to a vector layer (or directly its vector data provider)...
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
Definition: qgssymbolv2.h:134
void setPainter(QPainter *p)
QString id() const
Get this layer&#39;s unique ID, this ID is used to access this layer from map layer registry.
Q_DECL_DEPRECATED void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
bool underline() const
bool isOpen() const
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
T & first()
#define DXF_HANDSEED
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbols()
For symbol levels.
void setFeature(const QgsFeature *f)
Definition: qgssymbolv2.h:382
virtual double dxfAngle(QgsSymbolV2RenderContext &context) const
get angle
Does vector analysis using the geos library and handles import, export, exception handling*...
Definition: qgsgeos.h:32
Q_DECL_DEPRECATED void writeText(const QString &layer, const QString &text, const QgsPoint &pt, double size, double angle, const QColor &color)
Write text (TEXT)
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
Definition: qgsfield.cpp:385
double getX(int i=0) const
get the down-left x coordinate
virtual bool hasDataDefinedProperties() const
Checks whether the layer has any associated data defined properties.
int alpha() const
QTextCodec * codec() const
A class to represent a point.
Definition: qgspoint.h:117
static QString dxfEncoding(const QString &name)
return DXF encoding for Qt encoding
QList< QgsPointSequenceV2 > QgsRingSequenceV2
Q_DECL_DEPRECATED void writePolyline(const QgsPolyline &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
double size() const
Returns the symbol size.
bool getReversed() const
static double fromUnitToUnitFactor(QGis::UnitType fromUnit, QGis::UnitType toUnit)
Returns the conversion factor between the specified distance units.
int green() const
void clear()
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
iterator end()
const T value(const Key &key) const
QByteArray toLocal8Bit() const
iterator find(const Key &key)
bool overline() const
bool contains(QChar ch, Qt::CaseSensitivity cs) const
QColor fromRgbF(qreal r, qreal g, qreal b, qreal a)
int renderingPass() const
QgsExpressionContext & expressionContext()
Gets the expression context.
double getAlpha() const
get alpha
void combineExtentWith(const QgsRectangle &rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:516
void startRender(QgsSymbolV2RenderContext &context) override
static QString dxfLayerName(const QString &name)
Return cleaned layer name for use in DXF.
QString & replace(int position, int n, QChar after)
int blue() const
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
const_iterator constBegin() const
QList< QByteArray > availableCodecs()
Contains information about the context of a rendering operation.
Q_DECL_DEPRECATED void writeCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width)
Write circle (as polyline)
QFont definedFont()
Font to be used for rendering.
virtual Qt::BrushStyle dxfBrushStyle() const
get brush/fill style
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
Definition: qgsfeature.cpp:271
QString mid(int position, int n) const
virtual QColor dxfBrushColor(QgsSymbolV2RenderContext &context) const
get brush/fill color
double getHeight() const
QString toString() const
virtual Q_DECL_DEPRECATED QgsSymbolV2List symbolsForFeature(QgsFeature &feat)
Returns list of symbols used for rendering the feature.
bool isEmpty() const
#define DXF_HANDPLOTSTYLE
int count() const
QString family() const
QgsSymbolV2 * symbol()
Definition: qgsrendererv2.h:64
bool usingSymbolLevels() const
void writeDouble(double d)
Write a floating point value.
virtual QColor dxfColor(QgsSymbolV2RenderContext &context) const
get color
void setMapToPixel(const QgsMapToPixel &mtp)
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
Definition: qgsfeature.cpp:82
Q_DECL_DEPRECATED void writePolygon(const QgsPolygon &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
int length() const
LabelPosition is a candidate feature label position.
Definition: labelposition.h:51
bool canEncode(QChar ch) const
UnitType
Map units that qgis supports.
Definition: qgis.h:159
char * data()
QString left(int n) const
qint64 QgsFeatureId
Definition: qgsfeature.h:31
double y() const
Get the y value of the point.
Definition: qgspoint.h:193
void registerDxfFeature(QgsFeature &feature, QgsRenderContext &context, const QString &dxfLayerName)
Registration method that keeps track of DXF layer names of individual features.
static Type flatType(Type type)
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:366
QString name
Read property of QString layerName.
Definition: qgsmaplayer.h:53
Abstract base class for marker symbol layers.
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const
get offset
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
iterator end()
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
const_iterator constEnd() const
virtual int capabilities()
returns bitwise OR-ed capabilities of the renderer
bool nextFeature(QgsFeature &f)
bool strikeOut() const
const_iterator constBegin() const
Implements a derived label provider internally used for DXF export.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
int writeHandle(int code=5, int handle=0)
Write a tuple of group code and a handle.
double width() const
Width of the rectangle.
Definition: qgsrectangle.h:207
int size() const
Represents a vector layer which manages a vector based data sets.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
double xMinimum() const
Get the x minimum value (left side of rectangle)
Definition: qgsrectangle.h:192
QString toString() const
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
QgsAbstractGeometryV2 * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit, QString *errorMsg=nullptr) const override
Definition: qgsgeos.cpp:1673
QString labelText() const
Text of the label.
Q_DECL_DEPRECATED void writeMText(const QString &layer, const QString &text, const QgsPoint &pt, double width, double angle, const QColor &color)
Write mtext (MTEXT)
iterator begin()
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
QString layerName(const QString &id, const QgsFeature &f) const
Get layer name for feature.
QgsDxfExport & operator=(const QgsDxfExport &dxfExport)
void registerDxfLayer(QString layerId, QgsFeatureId fid, QString layer)
Register name of layer for feature.
QRgb rgba() const
QgsAbstractGeometryV2 * buffer(double distance, int segments, QString *errorMsg=nullptr) const override
Definition: qgsgeos.cpp:1277
double height() const
Height of the rectangle.
Definition: qgsrectangle.h:212
QList< QgsPointV2 > QgsPointSequenceV2
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
QgsFeatureId featureId() const
Returns the unique ID of the feature.
Definition: feature.cpp:154
DirectionSymbols placeDirectionSymbol
int renderHints() const
Definition: qgssymbolv2.h:208
static void dataDefinedTextFormatting(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)