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