Skip to content
Permalink
Browse files

fix #1308

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15380 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Mar 7, 2011
1 parent bdd95a5 commit 852dd612967ca28c99543130f0f7859d80d77149
Showing with 52 additions and 48 deletions.
  1. +52 −48 src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp
@@ -43,71 +43,75 @@ void dxf2shpConverterGui::on_buttonBox_accepted()
QString inf = name->text();
QString outd = dirout->text();

if ( inf.size() > 1 )
if ( inf.isEmpty() )
{
int type = SHPT_POINT;
bool convtexts = convertTextCheck->checkState();
QMessageBox::information( this, tr( "Warning" ), tr( "Please specify a file to convert." ) );
return;
}

if ( polyline->isChecked() )
type = SHPT_ARC;
if ( outd.isEmpty() )
{
QMessageBox::information( this, tr( "Warning" ), tr( "Please specify an output file" ) );
return;
}

if ( polygon->isChecked() )
type = SHPT_POLYGON;
int type = SHPT_POINT;
bool convtexts = convertTextCheck->checkState();

if ( point->isChecked() )
type = SHPT_POINT;
if ( polyline->isChecked() )
type = SHPT_ARC;

InsertRetrClass *insertRetr = new InsertRetrClass();
if ( polygon->isChecked() )
type = SHPT_POLYGON;

DL_Dxf *dxf_inserts = new DL_Dxf();
if ( point->isChecked() )
type = SHPT_POINT;

if ( !dxf_inserts->in( inf.toStdString(), insertRetr ) )
{
// if file open failed
QgsDebugMsg( "Aborting: The input file could not be opened." );
return;
}
InsertRetrClass *insertRetr = new InsertRetrClass();

Builder *parser = new Builder(
outd.toStdString(),
type,
insertRetr->XVals, insertRetr->YVals,
insertRetr->Names,
insertRetr->countInserts,
convtexts );
DL_Dxf *dxf_inserts = new DL_Dxf();

QgsDebugMsg( QString( "Finished getting insertions. Count: %1" ).arg( insertRetr->countInserts ) );
if ( !dxf_inserts->in( inf.toStdString(), insertRetr ) )
{
// if file open failed
QgsDebugMsg( "Aborting: The input file could not be opened." );
return;
}

DL_Dxf *dxf_Main = new DL_Dxf();
Builder *parser = new Builder(
outd.toStdString(),
type,
insertRetr->XVals, insertRetr->YVals,
insertRetr->Names,
insertRetr->countInserts,
convtexts );

if ( !dxf_Main->in( inf.toStdString(), parser ) )
{
// if file open failed
QgsDebugMsg( "Aborting: The input file could not be opened." );
return;
}
QgsDebugMsg( QString( "Finished getting insertions. Count: %1" ).arg( insertRetr->countInserts ) );

delete insertRetr;
delete dxf_inserts;
delete dxf_Main;
DL_Dxf *dxf_Main = new DL_Dxf();

parser->print_shpObjects();
if ( !dxf_Main->in( inf.toStdString(), parser ) )
{
// if file open failed
QgsDebugMsg( "Aborting: The input file could not be opened." );
return;
}

emit createLayer( QString(( parser->outputShp() ).c_str() ), QString( "Data layer" ) );
delete insertRetr;
delete dxf_inserts;
delete dxf_Main;

if ( convtexts && parser->textObjectsSize() > 0 )
{
emit createLayer( QString(( parser->outputTShp() ).c_str() ), QString( "Text layer" ) );
}
parser->print_shpObjects();

delete parser;
}
else
emit createLayer( QString(( parser->outputShp() ).c_str() ), QString( "Data layer" ) );

if ( convtexts && parser->textObjectsSize() > 0 )
{
QMessageBox::information( this, "Warning", "Please select a file to convert" );
return;
emit createLayer( QString(( parser->outputTShp() ).c_str() ), QString( "Text layer" ) );
}

delete parser;

accept();
}

@@ -152,7 +156,7 @@ void dxf2shpConverterGui::getInputFileName()
QString s = QFileDialog::getOpenFileName( this,
tr( "Choose a DXF file to open" ),
settings.value( "/Plugin-DXF/text_path", "./" ).toString(),
"Files DXF (*.dxf)" );
tr( "Files DXF (*.dxf)" ) );

name->setText( s );
}
@@ -162,7 +166,7 @@ void dxf2shpConverterGui::getOutputDir()
QString s = QFileDialog::getSaveFileName( this,
tr( "Choose a file name to save to" ),
"output.shp",
"Shapefile (*.shp)" );
tr( "Shapefile (*.shp)" ) );

dirout->setText( s );
}

0 comments on commit 852dd61

Please sign in to comment.
You can’t perform that action at this time.