Skip to content

Commit 6dad30c

Browse files
committed
[FEATURE]: Start implementation of native dxf export
1 parent 040e9d5 commit 6dad30c

File tree

5 files changed

+130
-0
lines changed

5 files changed

+130
-0
lines changed

python/core/core.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
%Include qgsdatasourceuri.sip
2828
%Include qgsdbfilterproxymodel.sip
2929
%Include qgsdistancearea.sip
30+
%Include qgsdxfexport.sip
3031
%Include qgserror.sip
3132
%Include qgsexpression.sip
3233
%Include qgsfeature.sip

python/core/qgsdxfexport.sip

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/***************************************************************************
2+
qgsdxfexport.sip
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+
class QgsDxfExport
19+
{
20+
%TypeHeaderCode
21+
#include <qgsdxfexport.h>
22+
%End
23+
public:
24+
QgsDxfExport();
25+
~QgsDxfExport();
26+
27+
void addLayers( QList< QgsMapLayer* >& layers );
28+
int writeToFile( QIODevice* d );
29+
};

src/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ SET(QGIS_CORE_SRCS
6262
qgsdbfilterproxymodel.cpp
6363
qgsdiagramrendererv2.cpp
6464
qgsdistancearea.cpp
65+
qgsdxfexport.cpp
6566
qgserror.cpp
6667
qgsexpression.cpp
6768
qgsexpression_texts.cpp

src/core/qgsdxfexport.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
#include "qgsdxfexport.h"
19+
#include <QIODevice>
20+
#include <QTextStream>
21+
22+
QgsDxfExport::QgsDxfExport()
23+
{
24+
}
25+
26+
QgsDxfExport::~QgsDxfExport()
27+
{
28+
29+
}
30+
31+
int QgsDxfExport::writeToFile( QIODevice* d )
32+
{
33+
if ( !d )
34+
{
35+
return 1;
36+
}
37+
38+
if ( !d->open( QIODevice::WriteOnly ) )
39+
{
40+
return 2;
41+
}
42+
43+
QTextStream outStream( d );
44+
writeHeader( outStream );
45+
return 0;
46+
}
47+
48+
int QgsDxfExport::writeHeader( QTextStream& stream )
49+
{
50+
stream << "Hello, dxf!";
51+
return 0; //soon...
52+
}

src/core/qgsdxfexport.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/***************************************************************************
2+
qgsdxfexport.h
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+
#ifndef QGSDXFEXPORT_H
19+
#define QGSDXFEXPORT_H
20+
21+
#include <QList>
22+
23+
class QgsMapLayer;
24+
class QIODevice;
25+
class QTextStream;
26+
27+
class QgsDxfExport
28+
{
29+
public:
30+
QgsDxfExport();
31+
~QgsDxfExport();
32+
33+
void addLayers( QList< QgsMapLayer* >& layers ) { mLayers = layers; }
34+
int writeToFile( QIODevice* d ); //maybe add progress dialog? //other parameters (e.g. scale, dpi)?
35+
36+
private:
37+
38+
QList< QgsMapLayer* > mLayers;
39+
40+
int writeHeader( QTextStream& stream );
41+
//collect styles
42+
//writeEntities
43+
44+
//Option: export feature once / multiple export (considering symbol layers / symbol levels)
45+
};
46+
47+
#endif // QGSDXFEXPORT_H

0 commit comments

Comments
 (0)