1
/***************************************************************************
2
*Copyright (C) 2008 Paolo L. Scala, Barbara Rita Barricelli, Marco Padula *
3
* CNR, Milan Unit (Information Technology), *
4
* Construction Technologies Institute.\n"; *
6
* email : Paolo L. Scala <scala@itc.cnr.it> *
8
* This is a plugin generated from the QGIS plugin template *
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
14
***************************************************************************/
15
#include "dxf2shpconvertergui.h"
16
#include "qgscontexthelp.h"
19
#include "getInsertions.h"
20
#include "dxflib/src/dl_dxf.h"
23
#include <qmessagebox.h>
25
#include <QFileDialog>
29
#include "qgslogger.h"
31
dxf2shpConverterGui::dxf2shpConverterGui( QWidget *parent, Qt::WFlags fl ):
37
dxf2shpConverterGui::~dxf2shpConverterGui()
41
void dxf2shpConverterGui::on_buttonBox_accepted()
43
QString inf = name->text();
44
QString outd = dirout->text();
48
int type = SHPT_POINT;
49
bool convtexts = convertTextCheck->checkState();
51
if ( polyline->isChecked() )
54
if ( polygon->isChecked() )
57
if ( point->isChecked() )
60
InsertRetrClass *insertRetr = new InsertRetrClass();
62
DL_Dxf *dxf_inserts = new DL_Dxf();
64
if ( !dxf_inserts->in( inf.toStdString(), insertRetr ) )
66
// if file open failed
67
QgsDebugMsg( "Aborting: The input file could not be opened." );
71
Builder *parser = new Builder(
74
insertRetr->XVals, insertRetr->YVals,
76
insertRetr->countInserts,
79
QgsDebugMsg( QString( "Finished getting insertions. Count: %1" ).arg( insertRetr->countInserts ) );
81
DL_Dxf *dxf_Main = new DL_Dxf();
83
if ( !dxf_Main->in( inf.toStdString(), parser ) )
85
// if file open failed
86
QgsDebugMsg( "Aborting: The input file could not be opened." );
94
parser->print_shpObjects();
96
emit createLayer( QString(( parser->outputShp() ).c_str() ), QString( "Data layer" ) );
98
if ( convtexts && parser->textObjectsSize() > 0 )
100
emit createLayer( QString(( parser->outputTShp() ).c_str() ), QString( "Text layer" ) );
107
QMessageBox::information( this, "Warning", "Please select a file to convert" );
114
void dxf2shpConverterGui::on_buttonBox_rejected()
119
void dxf2shpConverterGui::on_buttonBox_helpRequested()
121
QString s = tr( "Fields description:\n"
122
"* Input DXF file: path to the DXF file to be converted\n"
123
"* Output Shp file: desired name of the shape file to be created\n"
124
"* Shp output file type: specifies the type of the output shape file\n"
125
"* Export text labels checkbox: if checked, an additional shp points layer will be created, "
126
" and the associated dbf table will contain informations about the \"TEXT\" fields found"
127
" in the dxf file, and the text strings themselves\n\n"
129
"Developed by Paolo L. Scala, Barbara Rita Barricelli, Marco Padula\n"
130
"CNR, Milan Unit (Information Technology), Construction Technologies Institute.\n"
131
"For support send a mail to scala@itc.cnr.it\n" );
133
QMessageBox::information( this, "Help", s );
137
void dxf2shpConverterGui::on_btnBrowseForFile_clicked()
142
void dxf2shpConverterGui::on_btnBrowseOutputDir_clicked()
148
void dxf2shpConverterGui::getInputFileName()
152
QString s = QFileDialog::getOpenFileName( this,
153
tr( "Choose a DXF file to open" ),
154
settings.value( "/Plugin-DXF/text_path", "./" ).toString(),
155
"Files DXF (*.dxf)" );
160
void dxf2shpConverterGui::getOutputDir()
162
QString s = QFileDialog::getSaveFileName( this,
163
tr( "Choose a file name to save to" ),
165
"Shapefile (*.shp)" );
167
dirout->setText( s );