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