Skip to content

Commit

Permalink
dxf import:
Browse files Browse the repository at this point in the history
* fix text positions and orientation when importing DXF (fixes #16000;
  cherry-picked from 567f920)
* disable DWG/DXF import with GDAL <2
  • Loading branch information
jef-n committed Jan 1, 2017
1 parent e1af071 commit 5a8e86b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/app/dwg/libdxfrw/drw_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,8 +1224,7 @@ void DRW_Insert::parseCode( int code, dxfReader *reader )
zscale = reader->getDouble();
break;
case 50:
angle = reader->getDouble();
angle = angle / ARAD; //convert to radian
angle = reader->getDouble() / ARAD;
break;
case 70:
colcount = reader->getInt32();
Expand Down Expand Up @@ -1590,7 +1589,7 @@ void DRW_Text::parseCode( int code, dxfReader *reader )
widthscale = reader->getDouble();
break;
case 50:
angle = reader->getDouble();
angle = reader->getDouble() / ARAD;
break;
case 51:
oblique = reader->getDouble();
Expand Down Expand Up @@ -1630,7 +1629,7 @@ bool DRW_Text::parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs )

QgsDebugMsg( "***************************** parsing text *********************************************" );

// DataFlags RC Used to determine presence of subsquent data, set to 0xFF for R14-
// DataFlags RC Used to determine presence of subsequent data, set to 0xFF for R14-
duint8 data_flags = 0x00;
if ( version > DRW::AC1014 ) //2000+
{
Expand Down
9 changes: 6 additions & 3 deletions src/app/dwg/qgsdwgimporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
if ( fi.suffix().toLower() == "dxf" )
{
//loads dxf
QSharedPointer<dxfRW> dxf( new dxfRW( drawing.toUtf8() ) );
QScopedPointer<dxfRW> dxf( new dxfRW( drawing.toUtf8() ) );
if ( !dxf->read( this, false ) )
{
result = DRW::BAD_UNKNOWN;
Expand All @@ -632,7 +632,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
else if ( fi.suffix().toLower() == "dwg" )
{
//loads dwg
QSharedPointer<dwgR> dwg( new dwgR( drawing.toUtf8() ) );
QScopedPointer<dwgR> dwg( new dwgR( drawing.toUtf8() ) );
if ( !dwg->read( this, false ) )
{
result = dwg->getError();
Expand Down Expand Up @@ -2209,7 +2209,10 @@ void QgsDwgImporter::addText( const DRW_Text &data )

setPoint( dfn, f, "ext", data.extPoint );

QgsPointV2 p( QgsWKBTypes::PointZ, data.secPoint.x, data.secPoint.y, data.secPoint.z );
QgsPointV2 p( QgsWKBTypes::PointZ,
( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.x : data.basePoint.x,
( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.y : data.basePoint.y,
( data.alignH > 0 || data.alignV > 0 ) ? data.secPoint.z : data.basePoint.z );

if ( !createFeature( layer, f, p ) )
{
Expand Down
4 changes: 3 additions & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1902,8 +1902,10 @@ void QgisApp::createMenus()
*/

// Layer menu
#ifndef SUPPORT_GEOPACKAGE
#if !defined(GDAL_COMPUTE_VERSION) || GDAL_VERSION_NUM < GDAL_COMPUTE_VERSION(2,0,0)
mProjectMenu->removeAction( mActionDwgImport );
#endif
#ifndef SUPPORT_GEOPACKAGE
mNewLayerMenu->removeAction( mActionNewGeoPackageLayer );
#endif

Expand Down

0 comments on commit 5a8e86b

Please sign in to comment.