Skip to content

Commit

Permalink
fix #1308
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15380 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 7, 2011
1 parent 4254fcc commit 6f45929
Showing 1 changed file with 52 additions and 48 deletions.
100 changes: 52 additions & 48 deletions src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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 );
}
Expand All @@ -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 6f45929

Please sign in to comment.