QGIS API Documentation
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 ( dynamic_cast<const QgsRuleBasedLabeling*>( labeling ) )
967  {
968  const QgsRuleBasedLabeling *rbl = dynamic_cast<const QgsRuleBasedLabeling*>( labeling );
969  rblp = new QgsDxfRuleBasedLabelProvider( *rbl, vl, this );
970  rblp->reinit( vl );
971  engine.addProvider( rblp );
972 
973  if ( !rblp->prepare( ctx, attributes ) )
974  {
975  engine.removeProvider( rblp );
976  rblp = nullptr;
977  }
978  }
979  else
980  {
981  lp = new QgsDxfLabelProvider( vl, QString(), this, nullptr );
982  engine.addProvider( lp );
983 
984  if ( !lp->prepare( ctx, attributes ) )
985  {
986  engine.removeProvider( lp );
987  lp = nullptr;
988  }
989  }
990 
991  if ( mSymbologyExport == QgsDxfExport::SymbolLayerSymbology &&
993  renderer->usingSymbolLevels() )
994  {
995  writeEntitiesSymbolLevels( vl );
996  renderer->stopRender( ctx );
997  continue;
998  }
999 
1000  QgsFeatureRequest freq = QgsFeatureRequest().setSubsetOfAttributes( attributes, vl->fields() ).setExpressionContext( ctx.expressionContext() );
1001  if ( !mExtent.isEmpty() )
1002  {
1003  freq.setFilterRect( mExtent );
1004  }
1005 
1006  QgsFeatureIterator featureIt = vl->getFeatures( freq );
1007  QgsFeature fet;
1008  while ( featureIt.nextFeature( fet ) )
1009  {
1010  ctx.expressionContext().setFeature( fet );
1011  QString lName( dxfLayerName( layerIt->second == -1 ? layerName( vl ) : fet.attribute( layerIt->second ).toString() ) );
1012 
1013  sctx.setFeature( &fet );
1014  if ( mSymbologyExport == NoSymbology )
1015  {
1016  addFeature( sctx, lName, nullptr, nullptr ); // no symbology at all
1017  }
1018  else
1019  {
1020  QgsSymbolV2List symbolList = renderer->symbolsForFeature( fet, ctx );
1021  if ( symbolList.size() < 1 )
1022  {
1023  continue;
1024  }
1025 
1026  if ( mSymbologyExport == QgsDxfExport::SymbolLayerSymbology ) // symbol layer symbology, but layer does not use symbol levels
1027  {
1028  QgsSymbolV2List::iterator symbolIt = symbolList.begin();
1029  for ( ; symbolIt != symbolList.end(); ++symbolIt )
1030  {
1031  int nSymbolLayers = ( *symbolIt )->symbolLayerCount();
1032  for ( int i = 0; i < nSymbolLayers; ++i )
1033  {
1034  addFeature( sctx, lName, ( *symbolIt )->symbolLayer( i ), *symbolIt );
1035  }
1036  }
1037  }
1038  else
1039  {
1040  // take first symbollayer from first symbol
1041  QgsSymbolV2* s = symbolList.first();
1042  if ( !s || s->symbolLayerCount() < 1 )
1043  {
1044  continue;
1045  }
1046  addFeature( sctx, lName, s->symbolLayer( 0 ), s );
1047  }
1048 
1049  if ( lp )
1050  {
1051  lp->registerDxfFeature( fet, ctx, lName );
1052  }
1053  else if ( rblp )
1054  {
1055  rblp->registerDxfFeature( fet, ctx, lName );
1056  }
1057  }
1058  }
1059 
1060  renderer->stopRender( ctx );
1061  }
1062 
1063  engine.run( ctx );
1064 
1065  endSection();
1066 }
1067 
1068 void QgsDxfExport::writeEntitiesSymbolLevels( QgsVectorLayer* layer )
1069 {
1070  if ( !layer )
1071  {
1072  return;
1073  }
1074 
1075  QgsFeatureRendererV2* renderer = layer->rendererV2();
1076  if ( !renderer )
1077  {
1078  // TODO return error
1079  return;
1080  }
1082 
1083  QgsRenderContext ctx = renderContext();
1087  QgsSymbolV2RenderContext sctx( ctx, QgsSymbolV2::MM, 1.0, false, 0, nullptr );
1088  renderer->startRender( ctx, layer->fields() );
1089 
1090  // get iterator
1091  QgsFeatureRequest req;
1092  if ( layer->wkbType() == QGis::WKBNoGeometry )
1093  {
1095  }
1096  req.setSubsetOfAttributes( QStringList( renderer->usedAttributes() ), layer->fields() );
1097  if ( !mExtent.isEmpty() )
1098  {
1099  req.setFilterRect( mExtent );
1100  }
1101  QgsFeatureIterator fit = layer->getFeatures( req );
1102 
1103  // fetch features
1104  QgsFeature fet;
1105  QgsSymbolV2* featureSymbol = nullptr;
1106  while ( fit.nextFeature( fet ) )
1107  {
1108  ctx.expressionContext().setFeature( fet );
1109  featureSymbol = renderer->symbolForFeature( fet, ctx );
1110  if ( !featureSymbol )
1111  {
1112  continue;
1113  }
1114 
1115  QHash< QgsSymbolV2*, QList<QgsFeature> >::iterator it = features.find( featureSymbol );
1116  if ( it == features.end() )
1117  {
1118  it = features.insert( featureSymbol, QList<QgsFeature>() );
1119  }
1120  it.value().append( fet );
1121  }
1122 
1123  // find out order
1124  QgsSymbolV2LevelOrder levels;
1125  QgsSymbolV2List symbols = renderer->symbols( ctx );
1126  for ( int i = 0; i < symbols.count(); i++ )
1127  {
1128  QgsSymbolV2* sym = symbols[i];
1129  for ( int j = 0; j < sym->symbolLayerCount(); j++ )
1130  {
1131  int level = sym->symbolLayer( j )->renderingPass();
1132  if ( level < 0 || level >= 1000 ) // ignore invalid levels
1133  continue;
1134  QgsSymbolV2LevelItem item( sym, j );
1135  while ( level >= levels.count() ) // append new empty levels
1136  levels.append( QgsSymbolV2Level() );
1137  levels[level].append( item );
1138  }
1139  }
1140 
1141  // export symbol layers and symbology
1142  for ( int l = 0; l < levels.count(); l++ )
1143  {
1144  QgsSymbolV2Level& level = levels[l];
1145  for ( int i = 0; i < level.count(); i++ )
1146  {
1147  QgsSymbolV2LevelItem& item = level[i];
1148  QHash< QgsSymbolV2*, QList<QgsFeature> >::iterator levelIt = features.find( item.symbol() );
1149  if ( levelIt == features.end() )
1150  {
1151  QgsDebugMsg( QString( "No feature found for symbol on %1 %2.%3" ).arg( layer->id() ).arg( l ).arg( i ) );
1152  continue;
1153  }
1154 
1155  int llayer = item.layer();
1156  QList<QgsFeature>& featureList = levelIt.value();
1157  QList<QgsFeature>::iterator featureIt = featureList.begin();
1158  for ( ; featureIt != featureList.end(); ++featureIt )
1159  {
1160  sctx.setFeature( &*featureIt );
1161  addFeature( sctx, layer->name(), levelIt.key()->symbolLayer( llayer ), levelIt.key() );
1162  }
1163  }
1164  }
1165  renderer->stopRender( ctx );
1166 }
1167 
1168 void QgsDxfExport::writeEndFile()
1169 {
1170  // From GDAL trailer.dxf
1171  mTextStream << "\
1172  0\n\
1173 SECTION\n\
1174  2\n\
1175 OBJECTS\n\
1176  0\n\
1177 DICTIONARY\n\
1178  5\n\
1179 C\n\
1180 330\n\
1181 0\n\
1182 100\n\
1183 AcDbDictionary\n\
1184 281\n\
1185  1\n\
1186  3\n\
1187 ACAD_GROUP\n\
1188 350\n\
1189 D\n\
1190  3\n\
1191 ACAD_LAYOUT\n\
1192 350\n\
1193 1A\n\
1194  3\n\
1195 ACAD_MLEADERSTYLE\n\
1196 350\n\
1197 43\n\
1198  3\n\
1199 ACAD_MLINESTYLE\n\
1200 350\n\
1201 17\n\
1202  3\n\
1203 ACAD_PLOTSETTINGS\n\
1204 350\n\
1205 19\n\
1206  3\n\
1207 ACAD_PLOTSTYLENAME\n\
1208 350\n\
1209 E\n\
1210  3\n\
1211 ACAD_TABLESTYLE\n\
1212 350\n\
1213 42\n\
1214  3\n\
1215 ACAD_VISUALSTYLE\n\
1216 350\n\
1217 2A\n\
1218  0\n\
1219 DICTIONARY\n\
1220  5\n\
1221 D\n\
1222 102\n\
1223 {ACAD_REACTORS\n\
1224 330\n\
1225 C\n\
1226 102\n\
1227 }\n\
1228 330\n\
1229 C\n\
1230 100\n\
1231 AcDbDictionary\n\
1232 281\n\
1233  1\n\
1234  0\n\
1235 DICTIONARY\n\
1236  5\n\
1237 1A\n\
1238 102\n\
1239 {ACAD_REACTORS\n\
1240 330\n\
1241 C\n\
1242 102\n\
1243 }\n\
1244 330\n\
1245 C\n\
1246 100\n\
1247 AcDbDictionary\n\
1248 281\n\
1249  1\n\
1250  3\n\
1251 Layout1\n\
1252 350\n\
1253 1E\n\
1254  3\n\
1255 Layout2\n\
1256 350\n\
1257 26\n\
1258  3\n\
1259 Model\n\
1260 350\n\
1261 22\n\
1262  0\n\
1263 DICTIONARY\n\
1264  5\n\
1265 43\n\
1266 102\n\
1267 {ACAD_REACTORS\n\
1268 330\n\
1269 C\n\
1270 102\n\
1271 }\n\
1272 330\n\
1273 C\n\
1274 100\n\
1275 AcDbDictionary\n\
1276 281\n\
1277  1\n\
1278  0\n\
1279 DICTIONARY\n\
1280  5\n\
1281 17\n\
1282 102\n\
1283 {ACAD_REACTORS\n\
1284 330\n\
1285 C\n\
1286 102\n\
1287 }\n\
1288 330\n\
1289 C\n\
1290 100\n\
1291 AcDbDictionary\n\
1292 281\n\
1293  1\n\
1294  3\n\
1295 Standard\n\
1296 350\n\
1297 18\n\
1298  0\n\
1299 DICTIONARY\n\
1300  5\n\
1301 19\n\
1302 102\n\
1303 {ACAD_REACTORS\n\
1304 330\n\
1305 C\n\
1306 102\n\
1307 }\n\
1308 330\n\
1309 C\n\
1310 100\n\
1311 AcDbDictionary\n\
1312 281\n\
1313  1\n\
1314  0\n\
1315 ACDBDICTIONARYWDFLT\n\
1316  5\n\
1317 E\n\
1318 102\n\
1319 {ACAD_REACTORS\n\
1320 330\n\
1321 C\n\
1322 102\n\
1323 }\n\
1324 330\n\
1325 C\n\
1326 100\n\
1327 AcDbDictionary\n\
1328 281\n\
1329  1\n\
1330  3\n\
1331 Normal\n\
1332 350\n\
1333 F\n\
1334 100\n\
1335 AcDbDictionaryWithDefault\n\
1336 340\n\
1337 F\n\
1338  0\n\
1339 DICTIONARY\n\
1340  5\n\
1341 42\n\
1342 102\n\
1343 {ACAD_REACTORS\n\
1344 330\n\
1345 C\n\
1346 102\n\
1347 }\n\
1348 330\n\
1349 C\n\
1350 100\n\
1351 AcDbDictionary\n\
1352 281\n\
1353  1\n\
1354  0\n\
1355 DICTIONARY\n\
1356  5\n\
1357 2A\n\
1358 102\n\
1359 {ACAD_REACTORS\n\
1360 330\n\
1361 C\n\
1362 102\n\
1363 }\n\
1364 330\n\
1365 C\n\
1366 100\n\
1367 AcDbDictionary\n\
1368 281\n\
1369  1\n\
1370  3\n\
1371 2dWireframe\n\
1372 350\n\
1373 2F\n\
1374  3\n\
1375 3D Hidden\n\
1376 350\n\
1377 31\n\
1378  3\n\
1379 3dWireframe\n\
1380 350\n\
1381 30\n\
1382  3\n\
1383 Basic\n\
1384 350\n\
1385 32\n\
1386  3\n\
1387 Brighten\n\
1388 350\n\
1389 36\n\
1390  3\n\
1391 ColorChange\n\
1392 350\n\
1393 3A\n\
1394  3\n\
1395 Conceptual\n\
1396 350\n\
1397 34\n\
1398  3\n\
1399 Dim\n\
1400 350\n\
1401 35\n\
1402  3\n\
1403 Facepattern\n\
1404 350\n\
1405 39\n\
1406  3\n\
1407 Flat\n\
1408 350\n\
1409 2B\n\
1410  3\n\
1411 FlatWithEdges\n\
1412 350\n\
1413 2C\n\
1414  3\n\
1415 Gouraud\n\
1416 350\n\
1417 2D\n\
1418  3\n\
1419 GouraudWithEdges\n\
1420 350\n\
1421 2E\n\
1422  3\n\
1423 Linepattern\n\
1424 350\n\
1425 38\n\
1426  3\n\
1427 Realistic\n\
1428 350\n\
1429 33\n\
1430  3\n\
1431 Thicken\n\
1432 350\n\
1433 37\n\
1434  0\n\
1435 LAYOUT\n\
1436  5\n\
1437 1E\n\
1438 102\n\
1439 {ACAD_REACTORS\n\
1440 330\n\
1441 1A\n\
1442 102\n\
1443 }\n\
1444 330\n\
1445 1A\n\
1446 100\n\
1447 AcDbPlotSettings\n\
1448  1\n\
1449 \n\
1450  2\n\
1451 none_device\n\
1452  4\n\
1453 \n\
1454  6\n\
1455 \n\
1456  40\n\
1457 0.0\n\
1458  41\n\
1459 0.0\n\
1460  42\n\
1461 0.0\n\
1462  43\n\
1463 0.0\n\
1464  44\n\
1465 0.0\n\
1466  45\n\
1467 0.0\n\
1468  46\n\
1469 0.0\n\
1470  47\n\
1471 0.0\n\
1472  48\n\
1473 0.0\n\
1474  49\n\
1475 0.0\n\
1476 140\n\
1477 0.0\n\
1478 141\n\
1479 0.0\n\
1480 142\n\
1481 1.0\n\
1482 143\n\
1483 1.0\n\
1484  70\n\
1485  688\n\
1486  72\n\
1487  0\n\
1488  73\n\
1489  0\n\
1490  74\n\
1491  5\n\
1492  7\n\
1493 \n\
1494  75\n\
1495  16\n\
1496  76\n\
1497  0\n\
1498  77\n\
1499  2\n\
1500  78\n\
1501  300\n\
1502 147\n\
1503 1.0\n\
1504 148\n\
1505 0.0\n\
1506 149\n\
1507 0.0\n\
1508 100\n\
1509 AcDbLayout\n\
1510  1\n\
1511 Layout1\n\
1512  70\n\
1513  1\n\
1514  71\n\
1515  1\n\
1516  10\n\
1517 0.0\n\
1518  20\n\
1519 0.0\n\
1520  11\n\
1521 12.0\n\
1522  21\n\
1523 9.0\n\
1524  12\n\
1525 0.0\n\
1526  22\n\
1527 0.0\n\
1528  32\n\
1529 0.0\n\
1530  14\n\
1531 1.000000000000000E+20\n\
1532  24\n\
1533 1.000000000000000E+20\n\
1534  34\n\
1535 1.000000000000000E+20\n\
1536  15\n\
1537 -1.000000000000000E+20\n\
1538  25\n\
1539 -1.000000000000000E+20\n\
1540  35\n\
1541 -1.000000000000000E+20\n\
1542 146\n\
1543 0.0\n\
1544  13\n\
1545 0.0\n\
1546  23\n\
1547 0.0\n\
1548  33\n\
1549 0.0\n\
1550  16\n\
1551 1.0\n\
1552  26\n\
1553 0.0\n\
1554  36\n\
1555 0.0\n\
1556  17\n\
1557 0.0\n\
1558  27\n\
1559 1.0\n\
1560  37\n\
1561 0.0\n\
1562  76\n\
1563  0\n\
1564 330\n\
1565 1B\n\
1566  0\n\
1567 LAYOUT\n\
1568  5\n\
1569 26\n\
1570 102\n\
1571 {ACAD_REACTORS\n\
1572 330\n\
1573 1A\n\
1574 102\n\
1575 }\n\
1576 330\n\
1577 1A\n\
1578 100\n\
1579 AcDbPlotSettings\n\
1580  1\n\
1581 \n\
1582  2\n\
1583 none_device\n\
1584  4\n\
1585 \n\
1586  6\n\
1587 \n\
1588  40\n\
1589 0.0\n\
1590  41\n\
1591 0.0\n\
1592  42\n\
1593 0.0\n\
1594  43\n\
1595 0.0\n\
1596  44\n\
1597 0.0\n\
1598  45\n\
1599 0.0\n\
1600  46\n\
1601 0.0\n\
1602  47\n\
1603 0.0\n\
1604  48\n\
1605 0.0\n\
1606  49\n\
1607 0.0\n\
1608 140\n\
1609 0.0\n\
1610 141\n\
1611 0.0\n\
1612 142\n\
1613 1.0\n\
1614 143\n\
1615 1.0\n\
1616  70\n\
1617  688\n\
1618  72\n\
1619  0\n\
1620  73\n\
1621  0\n\
1622  74\n\
1623  5\n\
1624  7\n\
1625 \n\
1626  75\n\
1627  16\n\
1628  76\n\
1629  0\n\
1630  77\n\
1631  2\n\
1632  78\n\
1633  300\n\
1634 147\n\
1635 1.0\n\
1636 148\n\
1637 0.0\n\
1638 149\n\
1639 0.0\n\
1640 100\n\
1641 AcDbLayout\n\
1642  1\n\
1643 Layout2\n\
1644  70\n\
1645  1\n\
1646  71\n\
1647  2\n\
1648  10\n\
1649 0.0\n\
1650  20\n\
1651 0.0\n\
1652  11\n\
1653 0.0\n\
1654  21\n\
1655 0.0\n\
1656  12\n\
1657 0.0\n\
1658  22\n\
1659 0.0\n\
1660  32\n\
1661 0.0\n\
1662  14\n\
1663 0.0\n\
1664  24\n\
1665 0.0\n\
1666  34\n\
1667 0.0\n\
1668  15\n\
1669 0.0\n\
1670  25\n\
1671 0.0\n\
1672  35\n\
1673 0.0\n\
1674 146\n\
1675 0.0\n\
1676  13\n\
1677 0.0\n\
1678  23\n\
1679 0.0\n\
1680  33\n\
1681 0.0\n\
1682  16\n\
1683 1.0\n\
1684  26\n\
1685 0.0\n\
1686  36\n\
1687 0.0\n\
1688  17\n\
1689 0.0\n\
1690  27\n\
1691 1.0\n\
1692  37\n\
1693 0.0\n\
1694  76\n\
1695  0\n\
1696 330\n\
1697 23\n\
1698  0\n\
1699 LAYOUT\n\
1700  5\n\
1701 22\n\
1702 102\n\
1703 {ACAD_REACTORS\n\
1704 330\n\
1705 1A\n\
1706 102\n\
1707 }\n\
1708 330\n\
1709 1A\n\
1710 100\n\
1711 AcDbPlotSettings\n\
1712  1\n\
1713 \n\
1714  2\n\
1715 none_device\n\
1716  4\n\
1717 \n\
1718  6\n\
1719 \n\
1720  40\n\
1721 0.0\n\
1722  41\n\
1723 0.0\n\
1724  42\n\
1725 0.0\n\
1726  43\n\
1727 0.0\n\
1728  44\n\
1729 0.0\n\
1730  45\n\
1731 0.0\n\
1732  46\n\
1733 0.0\n\
1734  47\n\
1735 0.0\n\
1736  48\n\
1737 0.0\n\
1738  49\n\
1739 0.0\n\
1740 140\n\
1741 0.0\n\
1742 141\n\
1743 0.0\n\
1744 142\n\
1745 1.0\n\
1746 143\n\
1747 1.0\n\
1748  70\n\
1749  1712\n\
1750  72\n\
1751  0\n\
1752  73\n\
1753  0\n\
1754  74\n\
1755  0\n\
1756  7\n\
1757 \n\
1758  75\n\
1759  0\n\
1760  76\n\
1761  0\n\
1762  77\n\
1763  2\n\
1764  78\n\
1765  300\n\
1766 147\n\
1767 1.0\n\
1768 148\n\
1769 0.0\n\
1770 149\n\
1771 0.0\n\
1772 100\n\
1773 AcDbLayout\n\
1774  1\n\
1775 Model\n\
1776  70\n\
1777  1\n\
1778  71\n\
1779  0\n\
1780  10\n\
1781 0.0\n\
1782  20\n\
1783 0.0\n\
1784  11\n\
1785 12.0\n\
1786  21\n\
1787 9.0\n\
1788  12\n\
1789 0.0\n\
1790  22\n\
1791 0.0\n\
1792  32\n\
1793 0.0\n\
1794  14\n\
1795 30.0\n\
1796  24\n\
1797 49.75\n\
1798  34\n\
1799 0.0\n\
1800  15\n\
1801 130.5\n\
1802  25\n\
1803 163.1318914119703\n\
1804  35\n\
1805 0.0\n\
1806 146\n\
1807 0.0\n\
1808  13\n\
1809 0.0\n\
1810  23\n\
1811 0.0\n\
1812  33\n\
1813 0.0\n\
1814  16\n\
1815 1.0\n\
1816  26\n\
1817 0.0\n\
1818  36\n\
1819 0.0\n\
1820  17\n\
1821 0.0\n\
1822  27\n\
1823 1.0\n\
1824  37\n\
1825 0.0\n\
1826  76\n\
1827  0\n\
1828 330\n\
1829 1F\n\
1830 331\n\
1831 29\n\
1832  0\n\
1833 MLINESTYLE\n\
1834  5\n\
1835 18\n\
1836 102\n\
1837 {ACAD_REACTORS\n\
1838 330\n\
1839 17\n\
1840 102\n\
1841 }\n\
1842 330\n\
1843 17\n\
1844 100\n\
1845 AcDbMlineStyle\n\
1846  2\n\
1847 Standard\n\
1848  70\n\
1849  0\n\
1850  3\n\
1851 \n\
1852  62\n\
1853  256\n\
1854  51\n\
1855 90.0\n\
1856  52\n\
1857 90.0\n\
1858  71\n\
1859  2\n\
1860  49\n\
1861 0.5\n\
1862  62\n\
1863  256\n\
1864  6\n\
1865 BYLAYER\n\
1866  49\n\
1867 -0.5\n\
1868  62\n\
1869  256\n\
1870  6\n\
1871 BYLAYER\n\
1872  0\n\
1873 ACDBPLACEHOLDER\n\
1874  5\n\
1875 F\n\
1876 102\n\
1877 {ACAD_REACTORS\n\
1878 330\n\
1879 E\n\
1880 102\n\
1881 }\n\
1882 330\n\
1883 E\n\
1884  0\n\
1885 VISUALSTYLE\n\
1886  5\n\
1887 2F\n\
1888 102\n\
1889 {ACAD_REACTORS\n\
1890 330\n\
1891 2A\n\
1892 102\n\
1893 }\n\
1894 330\n\
1895 2A\n\
1896 100\n\
1897 AcDbVisualStyle\n\
1898  2\n\
1899 2dWireframe\n\
1900  70\n\
1901  4\n\
1902  71\n\
1903  0\n\
1904  72\n\
1905  2\n\
1906  73\n\
1907  0\n\
1908  90\n\
1909  0\n\
1910  40\n\
1911 -0.6\n\
1912  41\n\
1913 -30.0\n\
1914  62\n\
1915  5\n\
1916  63\n\
1917  7\n\
1918 421\n\
1919  16777215\n\
1920  74\n\
1921  1\n\
1922  91\n\
1923  4\n\
1924  64\n\
1925  7\n\
1926  65\n\
1927  257\n\
1928  75\n\
1929  1\n\
1930 175\n\
1931  1\n\
1932  42\n\
1933 1.0\n\
1934  92\n\
1935  0\n\
1936  66\n\
1937  257\n\
1938  43\n\
1939 1.0\n\
1940  76\n\
1941  1\n\
1942  77\n\
1943  6\n\
1944  78\n\
1945  2\n\
1946  67\n\
1947  7\n\
1948  79\n\
1949  5\n\
1950 170\n\
1951  0\n\
1952 171\n\
1953  0\n\
1954 290\n\
1955  0\n\
1956 174\n\
1957  0\n\
1958  93\n\
1959  1\n\
1960  44\n\
1961 0.0\n\
1962 173\n\
1963  0\n\
1964 291\n\
1965  0\n\
1966  45\n\
1967 0.0\n\
1968 1001\n\
1969 ACAD\n\
1970 1000\n\
1971 AcDbSavedByObjectVersion\n\
1972 1070\n\
1973  0\n\
1974  0\n\
1975 VISUALSTYLE\n\
1976  5\n\
1977 31\n\
1978 102\n\
1979 {ACAD_REACTORS\n\
1980 330\n\
1981 2A\n\
1982 102\n\
1983 }\n\
1984 330\n\
1985 2A\n\
1986 100\n\
1987 AcDbVisualStyle\n\
1988  2\n\
1989 3D Hidden\n\
1990  70\n\
1991  6\n\
1992  71\n\
1993  1\n\
1994  72\n\
1995  2\n\
1996  73\n\
1997  2\n\
1998  90\n\
1999  0\n\
2000  40\n\
2001 -0.6\n\
2002  41\n\
2003 -30.0\n\
2004  62\n\
2005  5\n\
2006  63\n\
2007  7\n\
2008 421\n\
2009  16777215\n\
2010  74\n\
2011  2\n\
2012  91\n\
2013  2\n\
2014  64\n\
2015  7\n\
2016  65\n\
2017  257\n\
2018  75\n\
2019  2\n\
2020 175\n\
2021  1\n\
2022  42\n\
2023 40.0\n\
2024  92\n\
2025  0\n\
2026  66\n\
2027  257\n\
2028  43\n\
2029 1.0\n\
2030  76\n\
2031  1\n\
2032  77\n\
2033  6\n\
2034  78\n\
2035  2\n\
2036  67\n\
2037  7\n\
2038  79\n\
2039  3\n\
2040 170\n\
2041  0\n\
2042 171\n\
2043  0\n\
2044 290\n\
2045  0\n\
2046 174\n\
2047  0\n\
2048  93\n\
2049  1\n\
2050  44\n\
2051 0.0\n\
2052 173\n\
2053  0\n\
2054 291\n\
2055  0\n\
2056  45\n\
2057 0.0\n\
2058 1001\n\
2059 ACAD\n\
2060 1000\n\
2061 AcDbSavedByObjectVersion\n\
2062 1070\n\
2063  0\n\
2064  0\n\
2065 VISUALSTYLE\n\
2066  5\n\
2067 30\n\
2068 102\n\
2069 {ACAD_REACTORS\n\
2070 330\n\
2071 2A\n\
2072 102\n\
2073 }\n\
2074 330\n\
2075 2A\n\
2076 100\n\
2077 AcDbVisualStyle\n\
2078  2\n\
2079 3dWireframe\n\
2080  70\n\
2081  5\n\
2082  71\n\
2083  0\n\
2084  72\n\
2085  2\n\
2086  73\n\
2087  0\n\
2088  90\n\
2089  0\n\
2090  40\n\
2091 -0.6\n\
2092  41\n\
2093 -30.0\n\
2094  62\n\
2095  5\n\
2096  63\n\
2097  7\n\
2098 421\n\
2099  16777215\n\
2100  74\n\
2101  1\n\
2102  91\n\
2103  4\n\
2104  64\n\
2105  7\n\
2106  65\n\
2107  257\n\
2108  75\n\
2109  1\n\
2110 175\n\
2111  1\n\
2112  42\n\
2113 1.0\n\
2114  92\n\
2115  0\n\
2116  66\n\
2117  257\n\
2118  43\n\
2119 1.0\n\
2120  76\n\
2121  1\n\
2122  77\n\
2123  6\n\
2124  78\n\
2125  2\n\
2126  67\n\
2127  7\n\
2128  79\n\
2129  5\n\
2130 170\n\
2131  0\n\
2132 171\n\
2133  0\n\
2134 290\n\
2135  0\n\
2136 174\n\
2137  0\n\
2138  93\n\
2139  1\n\
2140  44\n\
2141 0.0\n\
2142 173\n\
2143  0\n\
2144 291\n\
2145  0\n\
2146  45\n\
2147 0.0\n\
2148 1001\n\
2149 ACAD\n\
2150 1000\n\
2151 AcDbSavedByObjectVersion\n\
2152 1070\n\
2153  0\n\
2154  0\n\
2155 VISUALSTYLE\n\
2156  5\n\
2157 32\n\
2158 102\n\
2159 {ACAD_REACTORS\n\
2160 330\n\
2161 2A\n\
2162 102\n\
2163 }\n\
2164 330\n\
2165 2A\n\
2166 100\n\
2167 AcDbVisualStyle\n\
2168  2\n\
2169 Basic\n\
2170  70\n\
2171  7\n\
2172  71\n\
2173  1\n\
2174  72\n\
2175  0\n\
2176  73\n\
2177  1\n\
2178  90\n\
2179  0\n\
2180  40\n\
2181 -0.6\n\
2182  41\n\
2183 -30.0\n\
2184  62\n\
2185  5\n\
2186  63\n\
2187  7\n\
2188 421\n\
2189  16777215\n\
2190  74\n\
2191  0\n\
2192  91\n\
2193  4\n\
2194  64\n\
2195  7\n\
2196  65\n\
2197  257\n\
2198  75\n\
2199  1\n\
2200 175\n\
2201  1\n\
2202  42\n\
2203 1.0\n\
2204  92\n\
2205  8\n\
2206  66\n\
2207  7\n\
2208  43\n\
2209 1.0\n\
2210  76\n\
2211  1\n\
2212  77\n\
2213  6\n\
2214  78\n\
2215  2\n\
2216  67\n\
2217  7\n\
2218  79\n\
2219  5\n\
2220 170\n\
2221  0\n\
2222 171\n\
2223  0\n\
2224 290\n\
2225  0\n\
2226 174\n\
2227  0\n\
2228  93\n\
2229  1\n\
2230  44\n\
2231 0.0\n\
2232 173\n\
2233  0\n\
2234 291\n\
2235  1\n\
2236  45\n\
2237 0.0\n\
2238 1001\n\
2239 ACAD\n\
2240 1000\n\
2241 AcDbSavedByObjectVersion\n\
2242 1070\n\
2243  0\n\
2244  0\n\
2245 VISUALSTYLE\n\
2246  5\n\
2247 36\n\
2248 102\n\
2249 {ACAD_REACTORS\n\
2250 330\n\
2251 2A\n\
2252 102\n\
2253 }\n\
2254 330\n\
2255 2A\n\
2256 100\n\
2257 AcDbVisualStyle\n\
2258  2\n\
2259 Brighten\n\
2260  70\n\
2261  12\n\
2262  71\n\
2263  2\n\
2264  72\n\
2265  2\n\
2266  73\n\
2267  0\n\
2268  90\n\
2269  0\n\
2270  40\n\
2271 -0.6\n\
2272  41\n\
2273 -30.0\n\
2274  62\n\
2275  5\n\
2276  63\n\
2277  7\n\
2278 421\n\
2279  16777215\n\
2280  74\n\
2281  1\n\
2282  91\n\
2283  4\n\
2284  64\n\
2285  7\n\
2286  65\n\
2287  257\n\
2288  75\n\
2289  1\n\
2290 175\n\
2291  1\n\
2292  42\n\
2293 1.0\n\
2294  92\n\
2295  8\n\
2296  66\n\
2297  7\n\
2298  43\n\
2299 1.0\n\
2300  76\n\
2301  1\n\
2302  77\n\
2303  6\n\
2304  78\n\
2305  2\n\
2306  67\n\
2307  7\n\
2308  79\n\
2309  5\n\
2310 170\n\
2311  0\n\
2312 171\n\
2313  0\n\
2314 290\n\
2315  0\n\
2316 174\n\
2317  0\n\
2318  93\n\
2319  1\n\
2320  44\n\
2321 50.0\n\
2322 173\n\
2323  0\n\
2324 291\n\
2325  1\n\
2326  45\n\
2327 0.0\n\
2328 1001\n\
2329 ACAD\n\
2330 1000\n\
2331 AcDbSavedByObjectVersion\n\
2332 1070\n\
2333  0\n\
2334  0\n\
2335 VISUALSTYLE\n\
2336  5\n\
2337 3A\n\
2338 102\n\
2339 {ACAD_REACTORS\n\
2340 330\n\
2341 2A\n\
2342 102\n\
2343 }\n\
2344 330\n\
2345 2A\n\
2346 100\n\
2347 AcDbVisualStyle\n\
2348  2\n\
2349 ColorChange\n\
2350  70\n\
2351  16\n\
2352  71\n\
2353  2\n\
2354  72\n\
2355  2\n\
2356  73\n\
2357  3\n\
2358  90\n\
2359  0\n\
2360  40\n\
2361 -0.6\n\
2362  41\n\
2363 -30.0\n\
2364  62\n\
2365  5\n\
2366  63\n\
2367  8\n\
2368 421\n\
2369  8421504\n\
2370  74\n\
2371  1\n\
2372  91\n\
2373  4\n\
2374  64\n\
2375  7\n\
2376  65\n\
2377  257\n\
2378  75\n\
2379  1\n\
2380 175\n\
2381  1\n\
2382  42\n\
2383 1.0\n\
2384  92\n\
2385  8\n\
2386  66\n\
2387  8\n\
2388 424\n\
2389  8421504\n\
2390  43\n\
2391 1.0\n\
2392  76\n\
2393  1\n\
2394  77\n\
2395  6\n\
2396  78\n\
2397  2\n\
2398  67\n\
2399  7\n\
2400  79\n\
2401  5\n\
2402 170\n\
2403  0\n\
2404 171\n\
2405  0\n\
2406 290\n\
2407  0\n\
2408 174\n\
2409  0\n\
2410  93\n\
2411  1\n\
2412  44\n\
2413 0.0\n\
2414 173\n\
2415  0\n\
2416 291\n\
2417  1\n\
2418  45\n\
2419 0.0\n\
2420 1001\n\
2421 ACAD\n\
2422 1000\n\
2423 AcDbSavedByObjectVersion\n\
2424 1070\n\
2425  0\n\
2426  0\n\
2427 VISUALSTYLE\n\
2428  5\n\
2429 34\n\
2430 102\n\
2431 {ACAD_REACTORS\n\
2432 330\n\
2433 2A\n\
2434 102\n\
2435 }\n\
2436 330\n\
2437 2A\n\
2438 100\n\
2439 AcDbVisualStyle\n\
2440  2\n\
2441 Conceptual\n\
2442  70\n\
2443  9\n\
2444  71\n\
2445  3\n\
2446  72\n\
2447  2\n\
2448  73\n\
2449  0\n\
2450  90\n\
2451  0\n\
2452  40\n\
2453 -0.6\n\
2454  41\n\
2455 -30.0\n\
2456  62\n\
2457  5\n\
2458  63\n\
2459  7\n\
2460 421\n\
2461  16777215\n\
2462  74\n\
2463  2\n\
2464  91\n\
2465  2\n\
2466  64\n\
2467  7\n\
2468  65\n\
2469  257\n\
2470  75\n\
2471  1\n\
2472 175\n\
2473  1\n\
2474  42\n\
2475 40.0\n\
2476  92\n\
2477  8\n\
2478  66\n\
2479  7\n\
2480  43\n\
2481 1.0\n\
2482  76\n\
2483  1\n\
2484  77\n\
2485  6\n\
2486  78\n\
2487  2\n\
2488  67\n\
2489  7\n\
2490  79\n\
2491  3\n\
2492 170\n\
2493  0\n\
2494 171\n\
2495  0\n\
2496 290\n\
2497  0\n\
2498 174\n\
2499  0\n\
2500  93\n\
2501  1\n\
2502  44\n\
2503 0.0\n\
2504 173\n\
2505  0\n\
2506 291\n\
2507  0\n\
2508  45\n\
2509 0.0\n\
2510 1001\n\
2511 ACAD\n\
2512 1000\n\
2513 AcDbSavedByObjectVersion\n\
2514 1070\n\
2515  0\n\
2516  0\n\
2517 VISUALSTYLE\n\
2518  5\n\
2519 35\n\
2520 102\n\
2521 {ACAD_REACTORS\n\
2522 330\n\
2523 2A\n\
2524 102\n\
2525 }\n\
2526 330\n\
2527 2A\n\
2528 100\n\
2529 AcDbVisualStyle\n\
2530  2\n\
2531 Dim\n\
2532  70\n\
2533  11\n\
2534  71\n\
2535  2\n\
2536  72\n\
2537  2\n\
2538  73\n\
2539  0\n\
2540  90\n\
2541  0\n\
2542  40\n\
2543 -0.6\n\
2544  41\n\
2545 -30.0\n\
2546  62\n\
2547  5\n\
2548  63\n\
2549  7\n\
2550 421\n\
2551  16777215\n\
2552  74\n\
2553  1\n\
2554  91\n\
2555  4\n\
2556  64\n\
2557  7\n\
2558  65\n\
2559  257\n\
2560  75\n\
2561  1\n\
2562 175\n\
2563  1\n\
2564  42\n\
2565 1.0\n\
2566  92\n\
2567  8\n\
2568  66\n\
2569  7\n\
2570  43\n\
2571 1.0\n\
2572  76\n\
2573  1\n\
2574  77\n\
2575  6\n\
2576  78\n\
2577  2\n\
2578  67\n\
2579  7\n\
2580  79\n\
2581  5\n\
2582 170\n\
2583  0\n\
2584 171\n\
2585  0\n\
2586 290\n\
2587  0\n\
2588 174\n\
2589  0\n\
2590  93\n\
2591  1\n\
2592  44\n\
2593 -50.0\n\
2594 173\n\
2595  0\n\
2596 291\n\
2597  1\n\
2598  45\n\
2599 0.0\n\
2600 1001\n\
2601 ACAD\n\
2602 1000\n\
2603 AcDbSavedByObjectVersion\n\
2604 1070\n\
2605  0\n\
2606  0\n\
2607 VISUALSTYLE\n\
2608  5\n\
2609 39\n\
2610 102\n\
2611 {ACAD_REACTORS\n\
2612 330\n\
2613 2A\n\
2614 102\n\
2615 }\n\
2616 330\n\
2617 2A\n\
2618 100\n\
2619 AcDbVisualStyle\n\
2620  2\n\
2621 Facepattern\n\
2622  70\n\
2623  15\n\
2624  71\n\
2625  2\n\
2626  72\n\
2627  2\n\
2628  73\n\
2629  0\n\
2630  90\n\
2631  0\n\
2632  40\n\
2633 -0.6\n\
2634  41\n\
2635 -30.0\n\
2636  62\n\
2637  5\n\
2638  63\n\
2639  7\n\
2640 421\n\
2641  16777215\n\
2642  74\n\
2643  1\n\
2644  91\n\
2645  4\n\
2646  64\n\
2647  7\n\
2648  65\n\
2649  257\n\
2650  75\n\
2651  1\n\
2652 175\n\
2653  1\n\
2654  42\n\
2655 1.0\n\
2656  92\n\
2657  8\n\
2658  66\n\
2659  7\n\
2660  43\n\
2661 1.0\n\
2662  76\n\
2663  1\n\
2664  77\n\
2665  6\n\
2666  78\n\
2667  2\n\
2668  67\n\
2669  7\n\
2670  79\n\
2671  5\n\
2672 170\n\
2673  0\n\
2674 171\n\
2675  0\n\
2676 290\n\
2677  0\n\
2678 174\n\
2679  0\n\
2680  93\n\
2681  1\n\
2682  44\n\
2683 0.0\n\
2684 173\n\
2685  0\n\
2686 291\n\
2687  1\n\
2688  45\n\
2689 0.0\n\
2690 1001\n\
2691 ACAD\n\
2692 1000\n\
2693 AcDbSavedByObjectVersion\n\
2694 1070\n\
2695  0\n\
2696  0\n\
2697 VISUALSTYLE\n\
2698  5\n\
2699 2B\n\
2700 102\n\
2701 {ACAD_REACTORS\n\
2702 330\n\
2703 2A\n\
2704 102\n\
2705 }\n\
2706 330\n\
2707 2A\n\
2708 100\n\
2709 AcDbVisualStyle\n\
2710  2\n\
2711 Flat\n\
2712  70\n\
2713  0\n\
2714  71\n\
2715  2\n\
2716  72\n\
2717  1\n\
2718  73\n\
2719  1\n\
2720  90\n\
2721  2\n\
2722  40\n\
2723 -0.6\n\
2724  41\n\
2725 30.0\n\
2726  62\n\
2727  5\n\
2728  63\n\
2729  7\n\
2730 421\n\
2731  16777215\n\
2732  74\n\
2733  0\n\
2734  91\n\
2735  4\n\
2736  64\n\
2737  7\n\
2738  65\n\
2739  257\n\
2740  75\n\
2741  1\n\
2742 175\n\
2743  1\n\
2744  42\n\
2745 1.0\n\
2746  92\n\
2747  8\n\
2748  66\n\
2749  7\n\
2750  43\n\
2751 1.0\n\
2752  76\n\
2753  1\n\
2754  77\n\
2755  6\n\
2756  78\n\
2757  2\n\
2758  67\n\
2759  7\n\
2760  79\n\
2761  5\n\
2762 170\n\
2763  0\n\
2764 171\n\
2765  0\n\
2766 290\n\
2767  0\n\
2768 174\n\
2769  0\n\
2770  93\n\
2771  13\n\
2772  44\n\
2773 0.0\n\
2774 173\n\
2775  0\n\
2776 291\n\
2777  1\n\
2778  45\n\
2779 0.0\n\
2780 1001\n\
2781 ACAD\n\
2782 1000\n\
2783 AcDbSavedByObjectVersion\n\
2784 1070\n\
2785  0\n\
2786  0\n\
2787 VISUALSTYLE\n\
2788  5\n\
2789 2C\n\
2790 102\n\
2791 {ACAD_REACTORS\n\
2792 330\n\
2793 2A\n\
2794 102\n\
2795 }\n\
2796 330\n\
2797 2A\n\
2798 100\n\
2799 AcDbVisualStyle\n\
2800  2\n\
2801 FlatWithEdges\n\
2802  70\n\
2803  1\n\
2804  71\n\
2805  2\n\
2806  72\n\
2807  1\n\
2808  73\n\
2809  1\n\
2810  90\n\
2811  2\n\
2812  40\n\
2813 -0.6\n\
2814  41\n\
2815 30.0\n\
2816  62\n\
2817  5\n\
2818  63\n\
2819  7\n\
2820 421\n\
2821  16777215\n\
2822  74\n\
2823  1\n\
2824  91\n\
2825  4\n\
2826  64\n\
2827  7\n\
2828  65\n\
2829  257\n\
2830  75\n\
2831  1\n\
2832 175\n\
2833  1\n\
2834  42\n\
2835 1.0\n\
2836  92\n\
2837  0\n\
2838  66\n\
2839  257\n\
2840  43\n\
2841 1.0\n\
2842  76\n\
2843  1\n\
2844  77\n\
2845  6\n\
2846  78\n\
2847  2\n\
2848  67\n\
2849  7\n\
2850  79\n\
2851  5\n\
2852 170\n\
2853  0\n\
2854 171\n\
2855  0\n\
2856 290\n\
2857  0\n\
2858 174\n\
2859  0\n\
2860  93\n\
2861  13\n\
2862  44\n\
2863 0.0\n\
2864 173\n\
2865  0\n\
2866 291\n\
2867  1\n\
2868  45\n\
2869 0.0\n\
2870 1001\n\
2871 ACAD\n\
2872 1000\n\
2873 AcDbSavedByObjectVersion\n\
2874 1070\n\
2875  0\n\
2876  0\n\
2877 VISUALSTYLE\n\
2878  5\n\
2879 2D\n\
2880 102\n\
2881 {ACAD_REACTORS\n\
2882 330\n\
2883 2A\n\
2884 102\n\
2885 }\n\
2886 330\n\
2887 2A\n\
2888 100\n\
2889 AcDbVisualStyle\n\
2890  2\n\
2891 Gouraud\n\
2892  70\n\
2893  2\n\
2894  71\n\
2895  2\n\
2896  72\n\
2897  2\n\
2898  73\n\
2899  1\n\
2900  90\n\
2901  2\n\
2902  40\n\
2903 -0.6\n\
2904  41\n\
2905 30.0\n\
2906  62\n\
2907  5\n\
2908  63\n\
2909  7\n\
2910 421\n\
2911  16777215\n\
2912  74\n\
2913  0\n\
2914  91\n\
2915  4\n\
2916  64\n\
2917  7\n\
2918  65\n\
2919  257\n\
2920  75\n\
2921  1\n\
2922 175\n\
2923  1\n\
2924  42\n\
2925 1.0\n\
2926  92\n\
2927  0\n\
2928  66\n\
2929  7\n\
2930  43\n\
2931 1.0\n\
2932  76\n\
2933  1\n\
2934  77\n\
2935  6\n\
2936  78\n\
2937  2\n\
2938  67\n\
2939  7\n\
2940  79\n\
2941  5\n\
2942 170\n\
2943  0\n\
2944 171\n\
2945  0\n\
2946 290\n\
2947  0\n\
2948 174\n\
2949  0\n\
2950  93\n\
2951  13\n\
2952  44\n\
2953 0.0\n\
2954 173\n\
2955  0\n\
2956 291\n\
2957  1\n\
2958  45\n\
2959 0.0\n\
2960 1001\n\
2961 ACAD\n\
2962 1000\n\
2963 AcDbSavedByObjectVersion\n\
2964 1070\n\
2965  0\n\
2966  0\n\
2967 VISUALSTYLE\n\
2968  5\n\
2969 2E\n\
2970 102\n\
2971 {ACAD_REACTORS\n\
2972 330\n\
2973 2A\n\
2974 102\n\
2975 }\n\
2976 330\n\
2977 2A\n\
2978 100\n\
2979 AcDbVisualStyle\n\
2980  2\n\
2981 GouraudWithEdges\n\
2982  70\n\
2983  3\n\
2984  71\n\
2985  2\n\
2986  72\n\
2987  2\n\
2988  73\n\
2989  1\n\
2990  90\n\
2991  2\n\
2992  40\n\
2993 -0.6\n\
2994  41\n\
2995 30.0\n\
2996  62\n\
2997  5\n\
2998  63\n\
2999  7\n\
3000 421\n\
3001  16777215\n\
3002  74\n\
3003  1\n\
3004  91\n\
3005  4\n\
3006  64\n\
3007  7\n\
3008  65\n\
3009  257\n\
3010  75\n\
3011  1\n\
3012 175\n\
3013  1\n\
3014  42\n\
3015 1.0\n\
3016  92\n\
3017  0\n\
3018  66\n\
3019  257\n\
3020  43\n\
3021 1.0\n\
3022  76\n\
3023  1\n\
3024  77\n\
3025  6\n\
3026  78\n\
3027  2\n\
3028  67\n\
3029  7\n\
3030  79\n\
3031  5\n\
3032 170\n\
3033  0\n\
3034 171\n\
3035  0\n\
3036 290\n\
3037  0\n\
3038 174\n\
3039  0\n\
3040  93\n\
3041  13\n\
3042  44\n\
3043 0.0\n\
3044 173\n\
3045  0\n\
3046 291\n\
3047  1\n\
3048  45\n\
3049 0.0\n\
3050 1001\n\
3051 ACAD\n\
3052 1000\n\
3053 AcDbSavedByObjectVersion\n\
3054 1070\n\
3055  0\n\
3056  0\n\
3057 VISUALSTYLE\n\
3058  5\n\
3059 38\n\
3060 102\n\
3061 {ACAD_REACTORS\n\
3062 330\n\
3063 2A\n\
3064 102\n\
3065 }\n\
3066 330\n\
3067 2A\n\
3068 100\n\
3069 AcDbVisualStyle\n\
3070  2\n\
3071 Linepattern\n\
3072  70\n\
3073  14\n\
3074  71\n\
3075  2\n\
3076  72\n\
3077  2\n\
3078  73\n\
3079  0\n\
3080  90\n\
3081  0\n\
3082  40\n\
3083 -0.6\n\
3084  41\n\
3085 -30.0\n\
3086  62\n\
3087  5\n\
3088  63\n\
3089  7\n\
3090 421\n\
3091  16777215\n\
3092  74\n\
3093  1\n\
3094  91\n\
3095  4\n\
3096  64\n\
3097  7\n\
3098  65\n\
3099  257\n\
3100  75\n\
3101  7\n\
3102 175\n\
3103  7\n\
3104  42\n\
3105 1.0\n\
3106  92\n\
3107  8\n\
3108  66\n\
3109  7\n\
3110  43\n\
3111 1.0\n\
3112  76\n\
3113  1\n\
3114  77\n\
3115  6\n\
3116  78\n\
3117  2\n\
3118  67\n\
3119  7\n\
3120  79\n\
3121  5\n\
3122 170\n\
3123  0\n\
3124 171\n\
3125  0\n\
3126 290\n\
3127  0\n\
3128 174\n\
3129  0\n\
3130  93\n\
3131  1\n\
3132  44\n\
3133 0.0\n\
3134 173\n\
3135  0\n\
3136 291\n\
3137  1\n\
3138  45\n\
3139 0.0\n\
3140 1001\n\
3141 ACAD\n\
3142 1000\n\
3143 AcDbSavedByObjectVersion\n\
3144 1070\n\
3145  0\n\
3146  0\n\
3147 VISUALSTYLE\n\
3148  5\n\
3149 33\n\
3150 102\n\
3151 {ACAD_REACTORS\n\
3152 330\n\
3153 2A\n\
3154 102\n\
3155 }\n\
3156 330\n\
3157 2A\n\
3158 100\n\
3159 AcDbVisualStyle\n\
3160  2\n\
3161 Realistic\n\
3162  70\n\
3163  8\n\
3164  71\n\
3165  2\n\
3166  72\n\
3167  2\n\
3168  73\n\
3169  0\n\
3170  90\n\
3171  0\n\
3172  40\n\
3173 -0.6\n\
3174  41\n\
3175 -30.0\n\
3176  62\n\
3177  5\n\
3178  63\n\
3179  7\n\
3180 421\n\
3181  16777215\n\
3182  74\n\
3183  1\n\
3184  91\n\
3185  0\n\
3186  64\n\
3187  7\n\
3188  65\n\
3189  257\n\
3190  75\n\
3191  1\n\
3192 175\n\
3193  1\n\
3194  42\n\
3195 1.0\n\
3196  92\n\
3197  8\n\
3198  66\n\
3199  8\n\
3200 424\n\
3201  7895160\n\
3202  43\n\
3203 1.0\n\
3204  76\n\
3205  1\n\
3206  77\n\
3207  6\n\
3208  78\n\
3209  2\n\
3210  67\n\
3211  7\n\
3212  79\n\
3213  5\n\
3214 170\n\
3215  0\n\
3216 171\n\
3217  0\n\
3218 290\n\
3219  0\n\
3220 174\n\
3221  0\n\
3222  93\n\
3223  13\n\
3224  44\n\
3225 0.0\n\
3226 173\n\
3227  0\n\
3228 291\n\
3229  0\n\
3230  45\n\
3231 0.0\n\
3232 1001\n\
3233 ACAD\n\
3234 1000\n\
3235 AcDbSavedByObjectVersion\n\
3236 1070\n\
3237  0\n\
3238  0\n\
3239 VISUALSTYLE\n\
3240  5\n\
3241 37\n\
3242 102\n\
3243 {ACAD_REACTORS\n\
3244 330\n\
3245 2A\n\
3246 102\n\
3247 }\n\
3248 330\n\
3249 2A\n\
3250 100\n\
3251 AcDbVisualStyle\n\
3252  2\n\
3253 Thicken\n\
3254  70\n\
3255  13\n\
3256  71\n\
3257  2\n\
3258  72\n\
3259  2\n\
3260  73\n\
3261  0\n\
3262  90\n\
3263  0\n\
3264  40\n\
3265 -0.6\n\
3266  41\n\
3267 -30.0\n\
3268  62\n\
3269  5\n\
3270  63\n\
3271  7\n\
3272 421\n\
3273  16777215\n\
3274  74\n\
3275  1\n\
3276  91\n\
3277  4\n\
3278  64\n\
3279  7\n\
3280  65\n\
3281  257\n\
3282  75\n\
3283  1\n\
3284 175\n\
3285  1\n\
3286  42\n\
3287 1.0\n\
3288  92\n\
3289  12\n\
3290  66\n\
3291  7\n\
3292  43\n\
3293 1.0\n\
3294  76\n\
3295  1\n\
3296  77\n\
3297  6\n\
3298  78\n\
3299  2\n\
3300  67\n\
3301  7\n\
3302  79\n\
3303  5\n\
3304 170\n\
3305  0\n\
3306 171\n\
3307  0\n\
3308 290\n\
3309  0\n\
3310 174\n\
3311  0\n\
3312  93\n\
3313  1\n\
3314  44\n\
3315 0.0\n\
3316 173\n\
3317  0\n\
3318 291\n\
3319  1\n\
3320  45\n\
3321 0.0\n\
3322 1001\n\
3323 ACAD\n\
3324 1000\n\
3325 AcDbSavedByObjectVersion\n\
3326 1070\n\
3327  0\n\
3328  0\n\
3329 ENDSEC\n\
3330 ";
3331 
3332  writeGroup( 0, "EOF" );
3333 }
3334 
3335 void QgsDxfExport::startSection()
3336 {
3337  writeGroup( 0, "SECTION" );
3338 }
3339 
3340 void QgsDxfExport::endSection()
3341 {
3342  writeGroup( 0, "ENDSEC" );
3343 }
3344 
3345 void QgsDxfExport::writePoint( const QgsPointV2 &pt, const QString& layer, const QColor& color, QgsSymbolV2RenderContext &ctx, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol, double angle )
3346 {
3347 #if 0
3348  // debug: draw rectangle for debugging
3349  const QgsMarkerSymbolLayerV2* msl = dynamic_cast< const QgsMarkerSymbolLayerV2* >( symbolLayer );
3350  if ( msl )
3351  {
3352  double halfSize = msl->size() * mapUnitScaleFactor( mSymbologyScaleDenominator,
3353  msl->sizeUnit(), mMapUnits ) / 2.0;
3354  writeGroup( 0, "SOLID" );
3355  writeGroup( 8, layer );
3356  writeGroup( 62, 1 );
3357  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ, pt.x() - halfSize, pt.y() - halfSize ) );
3358  writeGroup( 1, QgsPointV2( QgsWKBTypes::PointZ, pt.x() + halfSize, pt.y() - halfSize ) );
3359  writeGroup( 2, QgsPointV2( QgsWKBTypes::PointZ, pt.x() - halfSize, pt.y() + halfSize ) );
3360  writeGroup( 3, QgsPointV2( QgsWKBTypes::PointZ, pt.x() + halfSize, pt.y() + halfSize ) );
3361  }
3362 #endif // 0
3363 
3364  // insert block or write point directly?
3365  QHash< const QgsSymbolLayerV2*, QString >::const_iterator blockIt = mPointSymbolBlocks.constFind( symbolLayer );
3366  if ( !symbolLayer || blockIt == mPointSymbolBlocks.constEnd() )
3367  {
3368  // write symbol directly here
3369  const QgsMarkerSymbolLayerV2* msl = dynamic_cast< const QgsMarkerSymbolLayerV2* >( symbolLayer );
3370  if ( msl && symbol )
3371  {
3372  if ( symbolLayer->writeDxf( *this, mapUnitScaleFactor( mSymbologyScaleDenominator, msl->sizeUnit(), mMapUnits ), layer, ctx, QPointF( pt.x(), pt.y() ) ) )
3373  {
3374  return;
3375  }
3376  }
3377  writePoint( layer, color, pt ); // write default point symbol
3378  }
3379  else
3380  {
3381  // insert block reference
3382  writeGroup( 0, "INSERT" );
3383  writeHandle();
3384  writeGroup( 100, "AcDbEntity" );
3385  writeGroup( 100, "AcDbBlockReference" );
3386  writeGroup( 8, layer );
3387  writeGroup( 2, blockIt.value() ); // Block name
3388  writeGroup( 50, angle ); // angle
3389  writeGroup( 0, pt ); // Insertion point (in OCS)
3390  }
3391 }
3392 
3393 void QgsDxfExport::writePolyline( const QgsPolyline &line, const QString& layer, const QString& lineStyleName, const QColor& color, double width )
3394 {
3396  Q_FOREACH ( const QgsPoint p, line )
3397  s << QgsPointV2( p );
3398  writePolyline( s, layer, lineStyleName, color, width );
3399 }
3400 
3401 void QgsDxfExport::writePolyline( const QgsPointSequenceV2 &line, const QString& layer, const QString& lineStyleName, const QColor& color, double width )
3402 {
3403  int n = line.size();
3404  if ( n == 0 )
3405  {
3406  QgsDebugMsg( QString( "writePolyline: empty line layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3407  return;
3408  }
3409 
3410  bool polygon = line[0] == line[ line.size() - 1 ];
3411  if ( polygon )
3412  --n;
3413  if ( n < 2 )
3414  {
3415  QgsDebugMsg( QString( "writePolyline: line too short layer=%1 lineStyleName=%2" ).arg( layer, lineStyleName ) );
3416  return;
3417  }
3418 
3419  if ( !line.at( 0 ).is3D() )
3420  {
3421  writeGroup( 0, "LWPOLYLINE" );
3422  writeHandle();
3423  writeGroup( 8, layer );
3424  writeGroup( 100, "AcDbEntity" );
3425  writeGroup( 100, "AcDbPolyline" );
3426  writeGroup( 6, lineStyleName );
3427  writeGroup( color );
3428 
3429  writeGroup( 90, n );
3430  writeGroup( 70, polygon ? 1 : 0 );
3431  writeGroup( 43, width );
3432 
3433  for ( int i = 0; i < n; i++ )
3434  writeGroup( 0, line[i] );
3435  }
3436  else
3437  {
3438  writeGroup( 0, "POLYLINE" );
3439  writeHandle();
3440  writeGroup( 8, layer );
3441  writeGroup( 100, "AcDbEntity" );
3442  writeGroup( 100, "AcDb3dPolyline" );
3443  writeGroup( 6, lineStyleName );
3445  writeGroup( color );
3446  writeGroup( 70, 8 );
3447 
3448  for ( int i = 0; i < n; i++ )
3449  {
3450  writeGroup( 0, "VERTEX" );
3451  writeHandle();
3452  writeGroup( 8, layer );
3453  writeGroup( 100, "AcDbEntity" );
3454  writeGroup( 100, "AcDbVertex" );
3455  writeGroup( 100, "AcDb3dPolylineVertex" );
3456  writeGroup( 0, line[i] );
3457  writeGroup( 70, 32 );
3458  }
3459 
3460  writeGroup( 0, "SEQEND" );
3461  writeHandle();
3462  writeGroup( 8, layer );
3463  writeGroup( 100, "AcDbEntity" );
3464  }
3465 }
3466 
3467 void QgsDxfExport::writePolygon( const QgsPolygon &polygon, const QString& layer, const QString& hatchPattern, const QColor& color )
3468 {
3470 
3471  Q_FOREACH ( const QgsPolyline l, polygon )
3472  {
3474  Q_FOREACH ( const QgsPoint p, l )
3475  s << QgsPointV2( p );
3476  r << s;
3477  }
3478 
3479  writePolygon( r, layer, hatchPattern, color );
3480 }
3481 
3482 
3483 void QgsDxfExport::writePolygon( const QgsRingSequenceV2 &polygon, const QString& layer, const QString& hatchPattern, const QColor& color )
3484 {
3485  writeGroup( 0, "HATCH" ); // Entity type
3486  writeHandle();
3487  writeGroup( 330, mBlockHandle );
3488  writeGroup( 100, "AcDbEntity" );
3489  writeGroup( 8, layer ); // Layer name
3490  writeGroup( color ); // Color
3491  writeGroup( 100, "AcDbHatch" );
3492 
3493  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ ) ); // Elevation point (in OCS)
3494  writeGroup( 200, QgsPointV2( QgsWKBTypes::PointZ, 0.0, 0.0, 1.0 ) );
3495 
3496  writeGroup( 2, hatchPattern ); // Hatch pattern name
3497  writeGroup( 70, hatchPattern == "SOLID" ); // Solid fill flag (solid fill = 1; pattern fill = 0)
3498  writeGroup( 71, 0 ); // Associativity flag (associative = 1; non-associative = 0)
3499 
3500  writeGroup( 91, polygon.size() ); // Number of boundary paths (loops)
3501  for ( int i = 0; i < polygon.size(); ++i )
3502  {
3503  writeGroup( 92, 2 ); // Boundary path type flag (bit coded): 0 = Default; 1 = External; 2 = Polyline 4 = Derived; 8 = Textbox; 16 = Outermost
3504  writeGroup( 72, 0 ); // Has bulge flag
3505  writeGroup( 73, 1 ); // Is closed flag
3506  writeGroup( 93, polygon[i].size() ); // Number of edges in this boundary path (only if boundary is not a polyline
3507 
3508  for ( int j = 0; j < polygon[i].size(); ++j )
3509  {
3510  writeGroup( 0, polygon[i][j] ); // Vertex location (in OCS)
3511  }
3512 
3513  writeGroup( 97, 0 ); // Number of source boundary objects
3514  }
3515 
3516  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)
3517  writeGroup( 76, 1 ); // Hatch pattern type: 0 = User-defined; 1 = Predefined; 2 = Custom
3518 
3519  writeGroup( 98, 0 ); // Number of seed points
3520 }
3521 
3522 void QgsDxfExport::writeLine( const QgsPoint& pt1, const QgsPoint& pt2, const QString& layer, const QString& lineStyleName, const QColor& color, double width )
3523 {
3524  writeLine( QgsPointV2( pt1 ), QgsPointV2( pt2 ), layer, lineStyleName, color, width );
3525 }
3526 
3527 void QgsDxfExport::writeLine( const QgsPointV2& pt1, const QgsPointV2& pt2, const QString& layer, const QString& lineStyleName, const QColor& color, double width )
3528 {
3529  writePolyline( QgsPointSequenceV2() << pt1 << pt2, layer, lineStyleName, color, width );
3530 }
3531 
3532 void QgsDxfExport::writePoint( const QString &layer, const QColor &color, const QgsPoint &pt )
3533 {
3534  writePoint( layer, color, QgsPointV2( pt ) );
3535 }
3536 
3537 void QgsDxfExport::writePoint( const QString& layer, const QColor& color, const QgsPointV2 &pt )
3538 {
3539  writeGroup( 0, "POINT" );
3540  writeHandle();
3541  writeGroup( 100, "AcDbEntity" );
3542  writeGroup( 100, "AcDbPoint" );
3543  writeGroup( 8, layer );
3544  writeGroup( color );
3545  writeGroup( 0, pt );
3546 }
3547 
3548 void QgsDxfExport::writeFilledCircle( const QString &layer, const QColor& color, const QgsPoint &pt, double radius )
3549 {
3550  writeFilledCircle( layer, color, QgsPointV2( pt ), radius );
3551 }
3552 
3553 void QgsDxfExport::writeFilledCircle( const QString &layer, const QColor& color, const QgsPointV2 &pt, double radius )
3554 {
3555  writeGroup( 0, "HATCH" ); // Entity type
3556  writeHandle();
3557  writeGroup( 330, mBlockHandle );
3558  writeGroup( 100, "AcDbEntity" );
3559  writeGroup( 8, layer ); // Layer name
3560  writeGroup( color ); // Color (0 by block, 256 by layer)
3561  writeGroup( 100, "AcDbHatch" );
3562 
3563  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ ) ); // Elevation point (in OCS)
3564  writeGroup( 200, QgsPointV2( QgsWKBTypes::PointZ, 0.0, 0.0, 1.0 ) );
3565 
3566  writeGroup( 2, "SOLID" ); // Hatch pattern name
3567  writeGroup( 70, 1 ); // Solid fill flag (solid fill = 1; pattern fill = 0)
3568  writeGroup( 71, 0 ); // Associativity flag (associative = 1; non-associative = 0)
3569 
3570 
3571  writeGroup( 91, 1 ); // Number of boundary paths (loops)
3572 
3573  writeGroup( 92, 7 ); // Boundary path type flag (bit coded): 0 = Default; 1 = External; 2 = Polyline 4 = Derived; 8 = Textbox; 16 = Outermost
3574  writeGroup( 72, 2 );
3575  writeGroup( 73, 1 ); // Is closed flag
3576  writeGroup( 93, 2 ); // Number of polyline vertices
3577 
3578  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ, pt.x() - radius, pt.y() ) );
3579  writeGroup( 42, 1.0 );
3580 
3581  writeGroup( 0, QgsPointV2( QgsWKBTypes::PointZ, pt.x() + radius, pt.y() ) );
3582  writeGroup( 42, 1.0 );
3583 
3584  writeGroup( 97, 0 ); // Number of source boundary objects
3585 
3586  writeGroup( 75, 1 ); // Hatch style: 0 = Hatch "odd parity" area (Normal style), 1 = Hatch outermost area only (Outer style), 2 = Hatch through entire area (Ignore style)
3587  writeGroup( 76, 1 ); // Hatch pattern type: 0 = User-defined; 1 = Predefined; 2 = Custom
3588  writeGroup( 47, 0.0059696789328105 ); // Pixel size
3589 
3590  writeGroup( 98, 0 ); // Number of seed points
3591 }
3592 
3593 void QgsDxfExport::writeCircle( const QString& layer, const QColor& color, const QgsPoint &pt, double radius, const QString &lineStyleName, double width )
3594 {
3595  writeCircle( layer, color, QgsPointV2( pt ), radius, lineStyleName, width );
3596 }
3597 
3598 void QgsDxfExport::writeCircle( const QString& layer, const QColor& color, const QgsPointV2 &pt, double radius, const QString &lineStyleName, double width )
3599 {
3600  writeGroup( 0, "LWPOLYLINE" );
3601  writeHandle();
3602  writeGroup( 330, mBlockHandle );
3603  writeGroup( 8, layer );
3604  writeGroup( 100, "AcDbEntity" );
3605  writeGroup( 100, "AcDbPolyline" );
3606  writeGroup( 6, lineStyleName );
3607  writeGroup( color );
3608 
3609  writeGroup( 90, 2 );
3610 
3611  writeGroup( 70, 1 );
3612  writeGroup( 43, width );
3613 
3614  writeGroup( 0, QgsPointV2( pt.x() - radius, pt.y() ) );
3615  writeGroup( 42, 1.0 );
3616  writeGroup( 0, QgsPointV2( pt.x() + radius, pt.y() ) );
3617  writeGroup( 42, 1.0 );
3618 }
3619 
3620 void QgsDxfExport::writeText( const QString& layer, const QString& text, const QgsPoint &pt, double size, double angle, const QColor& color )
3621 {
3622  writeText( layer, text, QgsPointV2( pt ), size, angle, color );
3623 }
3624 
3625 void QgsDxfExport::writeText( const QString& layer, const QString& text, const QgsPointV2 &pt, double size, double angle, const QColor& color )
3626 {
3627  writeGroup( 0, "TEXT" );
3628  writeHandle();
3629  writeGroup( 100, "AcDbEntity" );
3630  writeGroup( 100, "AcDbText" );
3631  writeGroup( 8, layer );
3632  writeGroup( color );
3633  writeGroup( 0, pt );
3634  writeGroup( 40, size );
3635  writeGroup( 1, text );
3636  writeGroup( 50, angle );
3637  writeGroup( 7, "STANDARD" ); // so far only support for standard font
3638 }
3639 
3640 void QgsDxfExport::writeMText( const QString& layer, const QString& text, const QgsPoint &pt, double width, double angle, const QColor& color )
3641 {
3642  writeMText( layer, text, QgsPointV2( pt ), width, angle, color );
3643 }
3644 
3645 void QgsDxfExport::writeMText( const QString& layer, const QString& text, const QgsPointV2 &pt, double width, double angle, const QColor& color )
3646 {
3647  if ( !mTextStream.codec()->canEncode( text ) )
3648  {
3649  // TODO return error
3650  return;
3651  }
3652 
3653  writeGroup( 0, "MTEXT" );
3654  writeHandle();
3655  writeGroup( 100, "AcDbEntity" );
3656  writeGroup( 100, "AcDbMText" );
3657  writeGroup( 8, layer );
3658  writeGroup( color );
3659 
3660  writeGroup( 0, pt );
3661 
3662  QString t( text );
3663  while ( t.length() > 250 )
3664  {
3665  writeGroup( 3, t.left( 250 ) );
3666  t = t.mid( 250 );
3667  }
3668  writeGroup( 1, text );
3669 
3670  writeGroup( 50, angle ); // Rotation angle in radians
3671  writeGroup( 41, width * 1.1 ); // Reference rectangle width
3672 
3673  // Attachment point:
3674  // 1 2 3
3675  // 4 5 6
3676  // 7 8 9
3677  writeGroup( 71, 7 );
3678 
3679  writeGroup( 7, "STANDARD" ); // so far only support for standard font
3680 }
3681 
3682 void QgsDxfExport::writeSolid( const QString& layer, const QColor& color, const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, const QgsPoint &pt4 )
3683 {
3684  // pt1 pt2
3685  // pt3 pt4
3687  p << QgsPointV2( pt1 ) << QgsPointV2( pt2 ) << QgsPointV2( pt4 );
3688  if ( pt3 != pt4 )
3689  p << QgsPointV2( pt3 );
3690  p << QgsPointV2( pt1 );
3691  writePolygon( QgsRingSequenceV2() << p, layer, "SOLID", color );
3692 }
3693 
3694 QgsRectangle QgsDxfExport::dxfExtent() const
3695 {
3697  QList< QPair<QgsVectorLayer*, int> >::const_iterator layerIt = mLayers.constBegin();
3698  for ( ; layerIt != mLayers.constEnd(); ++layerIt )
3699  {
3700  if ( layerIt->first )
3701  {
3702  if ( extent.isEmpty() )
3703  {
3704  extent = layerIt->first->extent();
3705  }
3706  else
3707  {
3708  QgsRectangle layerExtent = layerIt->first->extent();
3709  extent.combineExtentWith( &layerExtent );
3710  }
3711  }
3712  }
3713  return extent;
3714 }
3715 
3716 void QgsDxfExport::addFeature( QgsSymbolV2RenderContext& ctx, const QString& layer, const QgsSymbolLayerV2* symbolLayer, const QgsSymbolV2* symbol )
3717 {
3718  const QgsFeature* fet = ctx.feature();
3719  if ( !fet )
3720  return;
3721 
3722  if ( !fet->constGeometry() )
3723  return;
3724 
3725  const QgsAbstractGeometryV2 *geom = fet->constGeometry()->geometry();
3726 
3727  QgsWKBTypes::Type geometryType = geom->wkbType();
3728 
3729  QColor penColor;
3730  QColor brushColor;
3731  if ( mSymbologyExport != NoSymbology )
3732  {
3733  penColor = colorFromSymbolLayer( symbolLayer, ctx );
3734  brushColor = symbolLayer->dxfBrushColor( ctx );
3735  }
3736 
3737  Qt::PenStyle penStyle( Qt::SolidLine );
3738  Qt::BrushStyle brushStyle( Qt::NoBrush );
3739  double width = -1;
3740  double offset = 0.0;
3741  double angle = 0.0;
3742  if ( mSymbologyExport != NoSymbology && symbolLayer )
3743  {
3744  width = symbolLayer->dxfWidth( *this, ctx );
3745  offset = symbolLayer->dxfOffset( *this, ctx );
3746  angle = symbolLayer->dxfAngle( ctx );
3747  penStyle = symbolLayer->dxfPenStyle();
3748  brushStyle = symbolLayer->dxfBrushStyle();
3749 
3750  if ( qgsDoubleNear( offset, 0.0 ) )
3751  offset = 0.0;
3752  }
3753 
3754  QString lineStyleName = "CONTINUOUS";
3755  if ( mSymbologyExport != NoSymbology )
3756  {
3757  lineStyleName = lineStyleFromSymbolLayer( symbolLayer );
3758  }
3759 
3760  // single point
3761  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::Point )
3762  {
3763  writePoint( geom->coordinateSequence().at( 0 ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol, angle );
3764  return;
3765  }
3766 
3767  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::MultiPoint )
3768  {
3769  const QgsCoordinateSequenceV2 &cs = geom->coordinateSequence();
3770  for ( int i = 0; i < cs.size(); i++ )
3771  {
3772  writePoint( cs.at( i ).at( 0 ).at( 0 ), layer, penColor, ctx, symbolLayer, symbol, angle );
3773  }
3774  return;
3775  }
3776 
3777  if ( penStyle != Qt::NoPen )
3778  {
3779  // single line
3780  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::LineString )
3781  {
3782  const QgsAbstractGeometryV2 *offsetGeom = geom;
3783  if ( !qgsDoubleNear( offset, 0.0 ) )
3784  {
3785  QgsGeos geos( geom );
3786  offsetGeom = geos.offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
3787  if ( offsetGeom )
3788  offsetGeom = geom;
3789  }
3790 
3791  writePolyline( offsetGeom->coordinateSequence().at( 0 ).at( 0 ), layer, lineStyleName, penColor, width );
3792 
3793  if ( offsetGeom != geom )
3794  delete offsetGeom;
3795  }
3796 
3797  // multiline
3798  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::MultiLineString )
3799  {
3800  const QgsAbstractGeometryV2 *offsetGeom = geom;
3801 
3802  if ( !qgsDoubleNear( offset, 0.0 ) )
3803  {
3804  QgsGeos geos( geom );
3805  offsetGeom = geos.offsetCurve( offset, 0, GEOSBUF_JOIN_MITRE, 2.0 );
3806  if ( !offsetGeom )
3807  offsetGeom = geom;
3808  }
3809 
3810  const QgsCoordinateSequenceV2 &cs = offsetGeom->coordinateSequence();
3811  for ( int i = 0; i < cs.size(); i++ )
3812  {
3813  writePolyline( cs.at( i ).at( 0 ), layer, lineStyleName, penColor, width );
3814  }
3815 
3816  if ( offsetGeom != geom )
3817  delete offsetGeom;
3818  }
3819 
3820  // polygon
3821  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::Polygon )
3822  {
3823  const QgsAbstractGeometryV2 *bufferGeom = geom;
3824 
3825  if ( !qgsDoubleNear( offset, 0.0 ) )
3826  {
3827  QgsGeos geos( geom );
3828  bufferGeom = geos.buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3829  if ( !bufferGeom )
3830  bufferGeom = geom;
3831  }
3832 
3833  const QgsCoordinateSequenceV2 &cs = bufferGeom->coordinateSequence();
3834  for ( int i = 0; i < cs.at( 0 ).size(); i++ )
3835  {
3836  writePolyline( cs.at( 0 ).at( i ), layer, lineStyleName, penColor, width );
3837  }
3838 
3839  if ( bufferGeom != geom )
3840  delete bufferGeom;
3841  }
3842 
3843  // multipolygon or polygon
3844  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::MultiPolygon )
3845  {
3846  const QgsAbstractGeometryV2 *bufferGeom = geom;
3847 
3848  if ( !qgsDoubleNear( offset, 0.0 ) )
3849  {
3850  QgsGeos geos( geom );
3851  bufferGeom = geos.buffer( offset, 0, GEOSBUF_CAP_FLAT, GEOSBUF_JOIN_MITRE, 2.0 );
3852  if ( !bufferGeom )
3853  bufferGeom = geom;
3854  }
3855 
3856  const QgsCoordinateSequenceV2 &cs = bufferGeom->coordinateSequence();
3857  for ( int i = 0; i < cs.size(); i++ )
3858  for ( int j = 0; j < cs.at( i ).size(); j++ )
3859  writePolyline( cs.at( i ).at( j ), layer, lineStyleName, penColor, width );
3860 
3861  if ( bufferGeom != geom )
3862  delete bufferGeom;
3863  }
3864  }
3865 
3866  if ( brushStyle != Qt::NoBrush )
3867  {
3868  // polygon
3869  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::Polygon )
3870  {
3871  writePolygon( geom->coordinateSequence().at( 0 ), layer, "SOLID", brushColor );
3872  }
3873 
3874  // multipolygon or polygon
3875  if ( QgsWKBTypes::flatType( geometryType ) == QgsWKBTypes::MultiPolygon )
3876  {
3877  const QgsCoordinateSequenceV2 &cs = geom->coordinateSequence();
3878  for ( int i = 0; i < cs.size(); i++ )
3879  {
3880  writePolygon( cs.at( i ), layer, "SOLID", brushColor );
3881  }
3882  }
3883  }
3884 }
3885 
3886 QColor QgsDxfExport::colorFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer, QgsSymbolV2RenderContext &ctx )
3887 {
3888  if ( !symbolLayer )
3889  return QColor();
3890 
3891  return symbolLayer->dxfColor( ctx );
3892 }
3893 
3894 QString QgsDxfExport::lineStyleFromSymbolLayer( const QgsSymbolLayerV2* symbolLayer )
3895 {
3896  QString lineStyleName = "CONTINUOUS";
3897  if ( !symbolLayer )
3898  {
3899  return lineStyleName;
3900  }
3901 
3902  QHash< const QgsSymbolLayerV2*, QString >::const_iterator lineTypeIt = mLineStyles.constFind( symbolLayer );
3903  if ( lineTypeIt != mLineStyles.constEnd() )
3904  {
3905  lineStyleName = lineTypeIt.value();
3906  return lineStyleName;
3907  }
3908  else
3909  {
3910  return lineNameFromPenStyle( symbolLayer->dxfPenStyle() );
3911  }
3912 }
3913 
3915 {
3916  int idx = 0;
3917  int current_distance = INT_MAX;
3918  for ( int i = 1; i < static_cast< int >( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ); ++i )
3919  {
3920  int dist = color_distance( pixel, i );
3921  if ( dist < current_distance )
3922  {
3923  current_distance = dist;
3924  idx = i;
3925  if ( dist == 0 )
3926  break;
3927  }
3928  }
3929  return idx;
3930 }
3931 
3932 int QgsDxfExport::color_distance( QRgb p1, int index )
3933 {
3934  if ( index > 255 || index < 0 )
3935  {
3936  return 0;
3937  }
3938 
3939  double redDiff = qRed( p1 ) - mDxfColors[index][0];
3940  double greenDiff = qGreen( p1 ) - mDxfColors[index][1];
3941  double blueDiff = qBlue( p1 ) - mDxfColors[index][2];
3942 #if 0
3943  QgsDebugMsg( QString( "color_distance( r:%1 g:%2 b:%3 <=> i:%4 r:%5 g:%6 b:%7 ) => %8" )
3944  .arg( qRed( p1 ) ).arg( qGreen( p1 ) ).arg( qBlue( p1 ) )
3945  .arg( index )
3946  .arg( mDxfColors[index][0] )
3947  .arg( mDxfColors[index][1] )
3948  .arg( mDxfColors[index][2] )
3949  .arg( redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff ) );
3950 #endif
3951  return redDiff * redDiff + greenDiff * greenDiff + blueDiff * blueDiff;
3952 }
3953 
3954 QRgb QgsDxfExport::createRgbEntry( qreal r, qreal g, qreal b )
3955 {
3956  return QColor::fromRgbF( r, g, b ).rgb();
3957 }
3958 
3959 QgsRenderContext QgsDxfExport::renderContext() const
3960 {
3961  QgsRenderContext context;
3962  context.setRendererScale( mSymbologyScaleDenominator );
3963  return context;
3964 }
3965 
3967 {
3968  if ( symbolUnits == QgsSymbolV2::MapUnit )
3969  {
3970  return 1.0;
3971  }
3972  // MM symbol unit
3973  return scaleDenominator * QgsUnitTypes::fromUnitToUnitFactor( QGis::Meters, mapUnits ) / 1000.0;
3974 }
3975 
3976 QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > > QgsDxfExport::symbolLayers( QgsRenderContext &context )
3977 {
3979 
3980  QList< QPair< QgsVectorLayer*, int> >::const_iterator lIt = mLayers.constBegin();
3981  for ( ; lIt != mLayers.constEnd(); ++lIt )
3982  {
3983  // cast to vector layer
3984  QgsVectorLayer* vl = lIt->first;
3985  if ( !vl )
3986  {
3987  continue;
3988  }
3989 
3990  // get rendererv2
3991  QgsFeatureRendererV2* r = vl->rendererV2();
3992  if ( !r )
3993  {
3994  continue;
3995  }
3996 
3997  // get all symbols
3998  QgsSymbolV2List symbols = r->symbols( context );
3999  QgsSymbolV2List::iterator symbolIt = symbols.begin();
4000  for ( ; symbolIt != symbols.end(); ++symbolIt )
4001  {
4002  int maxSymbolLayers = ( *symbolIt )->symbolLayerCount();
4003  if ( mSymbologyExport != SymbolLayerSymbology )
4004  {
4005  maxSymbolLayers = 1;
4006  }
4007  for ( int i = 0; i < maxSymbolLayers; ++i )
4008  {
4009  symbolLayers.append( qMakePair(( *symbolIt )->symbolLayer( i ), *symbolIt ) );
4010  }
4011  }
4012  }
4013 
4014  return symbolLayers;
4015 }
4016 
4017 void QgsDxfExport::writeDefaultLinetypes()
4018 {
4019  // continuous (Qt solid line)
4020  Q_FOREACH ( const QString& ltype, QStringList() << "ByLayer" << "ByBlock" << "CONTINUOUS" )
4021  {
4022  writeGroup( 0, "LTYPE" );
4023  writeHandle();
4024  writeGroup( 100, "AcDbSymbolTableRecord" );
4025  writeGroup( 100, "AcDbLinetypeTableRecord" );
4026  writeGroup( 2, ltype );
4027  writeGroup( 70, 64 );
4028  writeGroup( 3, "Defaultstyle" );
4029  writeGroup( 72, 65 );
4030  writeGroup( 73, 0 );
4031  writeGroup( 40, 0.0 );
4032  }
4033 
4034  double das = dashSize();
4035  double dss = dashSeparatorSize();
4036  double dos = dotSize();
4037 
4038  QVector<qreal> dashVector( 2 );
4039  dashVector[0] = das;
4040  dashVector[1] = dss;
4041  writeLinetype( "DASH", dashVector, QgsSymbolV2::MapUnit );
4042 
4043  QVector<qreal> dotVector( 2 );
4044  dotVector[0] = dos;
4045  dotVector[1] = dss;
4046  writeLinetype( "DOT", dotVector, QgsSymbolV2::MapUnit );
4047 
4048  QVector<qreal> dashDotVector( 4 );
4049  dashDotVector[0] = das;
4050  dashDotVector[1] = dss;
4051  dashDotVector[2] = dos;
4052  dashDotVector[3] = dss;
4053  writeLinetype( "DASHDOT", dashDotVector, QgsSymbolV2::MapUnit );
4054 
4055  QVector<qreal> dashDotDotVector( 6 );
4056  dashDotDotVector[0] = das;
4057  dashDotDotVector[1] = dss;
4058  dashDotDotVector[2] = dos;
4059  dashDotDotVector[3] = dss;
4060  dashDotDotVector[4] = dos;
4061  dashDotDotVector[5] = dss;
4062  writeLinetype( "DASHDOTDOT", dashDotDotVector, QgsSymbolV2::MapUnit );
4063 }
4064 
4065 void QgsDxfExport::writeSymbolLayerLinetype( const QgsSymbolLayerV2* symbolLayer )
4066 {
4067  if ( !symbolLayer )
4068  {
4069  return;
4070  }
4071 
4073  QVector<qreal> customLinestyle = symbolLayer->dxfCustomDashPattern( unit );
4074  if ( !customLinestyle.isEmpty() )
4075  {
4076  QString name = QString( "symbolLayer%1" ).arg( mSymbolLayerCounter++ );
4077  writeLinetype( name, customLinestyle, unit );
4078  mLineStyles.insert( symbolLayer, name );
4079  }
4080 }
4081 
4082 int QgsDxfExport::nLineTypes( const QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2* > >& symbolLayers )
4083 {
4084  int nLineTypes = 0;
4085  QList< QPair< QgsSymbolLayerV2*, QgsSymbolV2*> >::const_iterator slIt = symbolLayers.constBegin();
4086  for ( ; slIt != symbolLayers.constEnd(); ++slIt )
4087  {
4088  const QgsSimpleLineSymbolLayerV2* simpleLine = dynamic_cast< const QgsSimpleLineSymbolLayerV2* >( slIt->first );
4089  if ( simpleLine )
4090  {
4091  if ( simpleLine->useCustomDashPattern() )
4092  {
4093  ++nLineTypes;
4094  }
4095  }
4096  }
4097  return nLineTypes;
4098 }
4099 
4100 void QgsDxfExport::writeLinetype( const QString& styleName, const QVector<qreal>& pattern, QgsSymbolV2::OutputUnit u )
4101 {
4102  double length = 0;
4103  QVector<qreal>::const_iterator dashIt = pattern.constBegin();
4104  for ( ; dashIt != pattern.constEnd(); ++dashIt )
4105  {
4106  length += ( *dashIt * mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits ) );
4107  }
4108 
4109  writeGroup( 0, "LTYPE" );
4110  writeHandle();
4111  // 330 5
4112  writeGroup( 100, "AcDbSymbolTableRecord" );
4113  writeGroup( 100, "AcDbLinetypeTableRecord" );
4114  writeGroup( 2, styleName );
4115  writeGroup( 70, 64 ); // 0?
4116  writeGroup( 3, "" );
4117  writeGroup( 72, 65 );
4118  writeGroup( 73, pattern.size() );
4119  writeGroup( 40, length );
4120 
4121  dashIt = pattern.constBegin();
4122  bool isGap = false;
4123  for ( ; dashIt != pattern.constEnd(); ++dashIt )
4124  {
4125  // map units or mm?
4126  double segmentLength = ( isGap ? -*dashIt : *dashIt );
4127  segmentLength *= mapUnitScaleFactor( mSymbologyScaleDenominator, u, mMapUnits );
4128  writeGroup( 49, segmentLength );
4129  writeGroup( 74, 0 );
4130  isGap = !isGap;
4131  }
4132 }
4133 
4134 bool QgsDxfExport::hasDataDefinedProperties( const QgsSymbolLayerV2* sl, const QgsSymbolV2* symbol )
4135 {
4136  if ( !sl || !symbol )
4137  {
4138  return false;
4139  }
4140 
4143  {
4144  return true;
4145  }
4146 
4147  return sl->hasDataDefinedProperties();
4148 }
4149 
4150 double QgsDxfExport::dashSize() const
4151 {
4152  double size = mSymbologyScaleDenominator * 0.002;
4153  return sizeToMapUnits( size );
4154 }
4155 
4156 double QgsDxfExport::dotSize() const
4157 {
4158  double size = mSymbologyScaleDenominator * 0.0006;
4159  return sizeToMapUnits( size );
4160 }
4161 
4162 double QgsDxfExport::dashSeparatorSize() const
4163 {
4164  double size = mSymbologyScaleDenominator * 0.0006;
4165  return sizeToMapUnits( size );
4166 }
4167 
4168 double QgsDxfExport::sizeToMapUnits( double s ) const
4169 {
4170  double size = s * QgsUnitTypes::fromUnitToUnitFactor( QGis::Meters, mMapUnits );
4171  return size;
4172 }
4173 
4174 QString QgsDxfExport::lineNameFromPenStyle( Qt::PenStyle style )
4175 {
4176  switch ( style )
4177  {
4178  case Qt::DashLine:
4179  return "DASH";
4180  case Qt::DotLine:
4181  return "DOT";
4182  case Qt::DashDotLine:
4183  return "DASHDOT";
4184  case Qt::DashDotDotLine:
4185  return "DASHDOTDOT";
4186  case Qt::SolidLine:
4187  default:
4188  return "CONTINUOUS";
4189  }
4190 }
4191 
4193 {
4194  if ( name.isEmpty() )
4195  return "0";
4196 
4197  // dxf layers can be max 255 characters long
4198  QString layerName = name.left( 255 );
4199 
4200  // replaced restricted characters with underscore
4201  // < > / \ " : ; ? * | = '
4202  // See http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-7345.htm,topicNumber=d0e41665
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  layerName.replace( '*', '_' );
4212  layerName.replace( '|', '_' );
4213  layerName.replace( '=', '_' );
4214  layerName.replace( '\'', '_' );
4215 
4216  return layerName.trimmed();
4217 }
4218 
4219 bool QgsDxfExport::layerIsScaleBasedVisible( const QgsMapLayer* layer ) const
4220 {
4221  if ( !layer )
4222  return false;
4223 
4224  if ( mSymbologyExport == QgsDxfExport::NoSymbology )
4225  return true;
4226 
4227  return layer->isInScaleRange( mSymbologyScaleDenominator );
4228 }
4229 
4231 {
4232  QList< QPair<QgsVectorLayer*, int> >::const_iterator layerIt = mLayers.constBegin();
4233  for ( ; layerIt != mLayers.constEnd(); ++layerIt )
4234  {
4235  if ( layerIt->first && layerIt->first->id() == id )
4236  {
4237  return dxfLayerName( layerIt->second < 0 ? layerName( layerIt->first ) : f.attribute( layerIt->second ).toString() );
4238  }
4239  }
4240 
4241  return "0";
4242 }
4243 
4245 {
4246  Q_FOREACH ( const QByteArray& codec, QTextCodec::availableCodecs() )
4247  {
4248  if ( name != codec )
4249  continue;
4250 
4251  int i;
4252  for ( i = 0; i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && name != mDxfEncodings[i][1]; ++i )
4253  ;
4254 
4255  if ( i == static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
4256  continue;
4257 
4258  return mDxfEncodings[i][0];
4259  }
4260 
4261  return QString::null;
4262 }
4263 
4265 {
4267  Q_FOREACH ( QByteArray codec, QTextCodec::availableCodecs() )
4268  {
4269  int i;
4270  for ( i = 0; i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) && strcmp( codec.data(), mDxfEncodings[i][1] ) != 0; ++i )
4271  ;
4272 
4273  if ( i < static_cast< int >( sizeof( mDxfEncodings ) / sizeof( *mDxfEncodings ) ) )
4274  encodings << codec.data();
4275  }
4276  return encodings;
4277 }
4278 
4280 {
4281  Q_ASSERT( vl );
4282  return mLayerTitleAsName && !vl->title().isEmpty() ? vl->title() : vl->name();
4283 }
4284 
4286 {
4287  Q_UNUSED( context );
4288 
4289  if ( !settings.drawLabels )
4290  return;
4291 
4292  QgsTextLabelFeature* lf = dynamic_cast<QgsTextLabelFeature*>( label->getFeaturePart()->feature() );
4293 
4294  // Copy to temp, editable layer settings
4295  // these settings will be changed by any data defined values, then used for rendering label components
4296  // settings may be adjusted during rendering of components
4297  QgsPalLayerSettings tmpLyr( settings );
4298 
4299  // apply any previously applied data defined settings for the label
4301 
4302  //font
4303  QFont dFont = lf->definedFont();
4304  QgsDebugMsgLevel( QString( "PAL font tmpLyr: %1, Style: %2" ).arg( tmpLyr.textFont.toString(), tmpLyr.textFont.styleName() ), 4 );
4305  QgsDebugMsgLevel( QString( "PAL font definedFont: %1, Style: %2" ).arg( dFont.toString(), dFont.styleName() ), 4 );
4306  tmpLyr.textFont = dFont;
4307 
4309  {
4310  //calculate font alignment based on label quadrant
4311  switch ( label->getQuadrant() )
4312  {
4317  break;
4322  break;
4327  break;
4328  }
4329  }
4330 
4331  // update tmpLyr with any data defined text style values
4332  QgsPalLabeling::dataDefinedTextStyle( tmpLyr, ddValues );
4333 
4334  // update tmpLyr with any data defined text buffer values
4335  QgsPalLabeling::dataDefinedTextBuffer( tmpLyr, ddValues );
4336 
4337  // update tmpLyr with any data defined text formatting values
4338  QgsPalLabeling::dataDefinedTextFormatting( tmpLyr, ddValues );
4339 
4340  // add to the results
4341  QString txt = label->getFeaturePart()->feature()->labelText();
4342 
4343  QgsFeatureId fid = label->getFeaturePart()->featureId();
4344  QString dxfLayer = mDxfLayerNames[layerId][fid];
4345 
4346  QString wrapchr = tmpLyr.wrapChar.isEmpty() ? "\n" : tmpLyr.wrapChar;
4347 
4348  //add the direction symbol if needed
4349  if ( !txt.isEmpty() && tmpLyr.placement == QgsPalLayerSettings::Line && tmpLyr.addDirectionSymbol )
4350  {
4351  bool prependSymb = false;
4352  QString symb = tmpLyr.rightDirectionSymbol;
4353 
4354  if ( label->getReversed() )
4355  {
4356  prependSymb = true;
4357  symb = tmpLyr.leftDirectionSymbol;
4358  }
4359 
4360  if ( tmpLyr.reverseDirectionSymbol )
4361  {
4362  if ( symb == tmpLyr.rightDirectionSymbol )
4363  {
4364  prependSymb = true;
4365  symb = tmpLyr.leftDirectionSymbol;
4366  }
4367  else
4368  {
4369  prependSymb = false;
4370  symb = tmpLyr.rightDirectionSymbol;
4371  }
4372  }
4373 
4375  {
4376  prependSymb = true;
4377  symb = symb + wrapchr;
4378  }
4380  {
4381  prependSymb = false;
4382  symb = wrapchr + symb;
4383  }
4384 
4385  if ( prependSymb )
4386  {
4387  txt.prepend( symb );
4388  }
4389  else
4390  {
4391  txt.append( symb );
4392  }
4393  }
4394 
4395  txt = txt.replace( wrapchr, "\\P" );
4396 
4397  if ( tmpLyr.textFont.underline() )
4398  {
4399  txt.prepend( "\\L" ).append( "\\l" );
4400  }
4401 
4402  if ( tmpLyr.textFont.overline() )
4403  {
4404  txt.prepend( "\\O" ).append( "\\o" );
4405  }
4406 
4407  if ( tmpLyr.textFont.strikeOut() )
4408  {
4409  txt.prepend( "\\K" ).append( "\\k" );
4410  }
4411 
4412  txt.prepend( QString( "\\f%1|i%2|b%3;\\H%4;\\W0.75;" )
4413  .arg( tmpLyr.textFont.family() )
4414  .arg( tmpLyr.textFont.italic() ? 1 : 0 )
4415  .arg( tmpLyr.textFont.bold() ? 1 : 0 )
4416  .arg( label->getHeight() / ( 1 + txt.count( "\\P" ) ) * 0.75 ) );
4417 
4418  writeMText( dxfLayer, txt, QgsPointV2( label->getX(), label->getY() ), label->getWidth(), label->getAlpha() * 180.0 / M_PI, tmpLyr.textColor );
4419 }
4420 
4421 
4423 {
4424  if ( !mDxfLayerNames.contains( layerId ) )
4425  mDxfLayerNames[ layerId ] = QMap<QgsFeatureId, QString>();
4426 
4427  mDxfLayerNames[layerId][fid] = layerName;
4428 }
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)
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:62
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.
QString name() const
Get the display name of the layer.
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames) override
Prepare for registration of features.
QgsLabelFeature * feature()
Returns the parent feature.
Definition: feature.h:109
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.
void setOutputDpi(int dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
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:93
const_iterator constEnd() const
void setRendererScale(double scale)
const T & at(int i) const
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:474
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:115
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
MultiLineAlign multilineAlign
The QGis class provides global constants for use throughout the application.
Definition: qgis.h:36
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:348
double x() const
Get the x value of the point.
Definition: qgspoint.h:180
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:119
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:64
int count(const T &value) const
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
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:374
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:336
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:65
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:131
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:372
virtual double dxfAngle(QgsSymbolV2RenderContext &context) const
get angle
Does vector analysis using the geos library and handles import, export, exception handling*...
Definition: qgsgeos.h:31
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)
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
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:475
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:58
bool usingSymbolLevels() const
void setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
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:50
bool canEncode(QChar ch) const
UnitType
Map units that qgis supports.
Definition: qgis.h:155
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:188
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
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:1652
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:1263
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:205
static void dataDefinedTextFormatting(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)