Skip to content
Permalink
Browse files

dxf import:

* 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 5a8e86ba839336f8e6ab551ba28167c9e8f8a156
Showing with 12 additions and 8 deletions.
  1. +3 −4 src/app/dwg/libdxfrw/drw_entities.cpp
  2. +6 −3 src/app/dwg/qgsdwgimporter.cpp
  3. +3 −1 src/app/qgisapp.cpp
@@ -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();
@@ -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();
@@ -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+
{
@@ -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;
@@ -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();
@@ -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 ) )
{
@@ -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

0 comments on commit 5a8e86b

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