diff --git a/src/app/dwg/libdxfrw/drw_entities.cpp b/src/app/dwg/libdxfrw/drw_entities.cpp index c952104ed10b..4cf4662a531b 100644 --- a/src/app/dwg/libdxfrw/drw_entities.cpp +++ b/src/app/dwg/libdxfrw/drw_entities.cpp @@ -105,6 +105,9 @@ bool DRW_Entity::parseCode( int code, dxfReader *reader ) case 430: colorName = reader->getString(); break; + case 440: + transparency = reader->getInt32(); + break; case 67: space = static_cast( reader->getInt32() ); break; @@ -279,7 +282,7 @@ bool DRW_Entity::parseDwg( DRW::Version version, dwgBuffer *buf, dwgBuffer* strB { /* RLZ: TODO */ dwgHandle ah = buf->getHandle(); - DRW_DBG( "App Handle: " ); + DRW_DBG( "\n App Handle: " ); DRW_DBGHL( ah.code, ah.size, ah.ref ); duint8 *tmpExtData = new duint8[extDataSize]; buf->getBytes( tmpExtData, extDataSize ); @@ -316,7 +319,7 @@ bool DRW_Entity::parseDwg( DRW::Version version, dwgBuffer *buf, dwgBuffer* strB DRW_DBG( extDataSize ); } //end parsing extData (EED) duint8 graphFlag = buf->getBit(); //B - DRW_DBG( " graphFlag: " ); + DRW_DBG( "\n graphFlag: " ); DRW_DBG( graphFlag ); DRW_DBG( "\n" ); if ( graphFlag ) @@ -396,7 +399,7 @@ bool DRW_Entity::parseDwg( DRW::Version version, dwgBuffer *buf, dwgBuffer* strB DRW_DBG( "\n" ); } //ENC color - color = buf->getEnColor( version ); //BS or CMC //ok for R14 or negate + color = buf->getEnColor( version, color24, transparency ); //BS or CMC //ok for R14 or negate ltypeScale = buf->getBitDouble(); //BD DRW_DBG( " entity color: " ); DRW_DBG( color ); @@ -421,7 +424,7 @@ bool DRW_Entity::parseDwg( DRW::Version version, dwgBuffer *buf, dwgBuffer* strB { ltFlags = plotFlags; lineType = plotStyleName; //RLZ: howto solve? if needed plotStyleName; - DRW_DBG( "ltFlags: " ); + DRW_DBG( " ltFlags: " ); DRW_DBG( ltFlags ); DRW_DBG( " lineType: " ); DRW_DBG( lineType.c_str() ); @@ -436,21 +439,21 @@ bool DRW_Entity::parseDwg( DRW::Version version, dwgBuffer *buf, dwgBuffer* strB if ( version > DRW::AC1018 ) //2007+ { materialFlag = buf->get2Bits(); //BB - DRW_DBG( "materialFlag: " ); + DRW_DBG( " materialFlag: " ); DRW_DBG( materialFlag ); shadowFlag = buf->getRawChar8(); //RC - DRW_DBG( "shadowFlag: " ); + DRW_DBG( " shadowFlag: " ); DRW_DBG( shadowFlag ); DRW_DBG( "\n" ); } if ( version > DRW::AC1021 ) //2010+ { duint8 visualFlags = buf->get2Bits(); //full & face visual style - DRW_DBG( "shadowFlag 2: " ); + DRW_DBG( " shadowFlag 2: " ); DRW_DBG( visualFlags ); DRW_DBG( "\n" ); duint8 unk = buf->getBit(); //edge visual style - DRW_DBG( "unknown bit: " ); + DRW_DBG( " unknown bit: " ); DRW_DBG( unk ); DRW_DBG( "\n" ); } @@ -1910,7 +1913,7 @@ bool DRW_MText::parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs ) if ( version > DRW::AC1014 ) //2000+ { buf->getBitShort();/* Linespacing Style BS 73 */ - buf->getBitDouble();/* Linespacing Factor BD 44 */ + interlin = buf->getBitDouble();/* Linespacing Factor BD 44 */ buf->getBit();/* Unknown bit B */ } if ( version > DRW::AC1015 ) //2004+ @@ -3842,7 +3845,7 @@ bool DRW_Viewport::parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs ) DRW_DBG( "\n" ); // DRW_DBG("Ambient Cmc or Enc: "); DRW_DBG(buf->getCmColor(version)); DRW_DBG("\n"); DRW_DBG( "Ambient (Cmc or Enc?), Enc: " ); - DRW_DBG( buf->getEnColor( version ) ); + DRW_DBG( buf->getEnColor( version, color24, transparency ) ); DRW_DBG( "\n" ); } ret = DRW_Entity::parseDwgEntHandle( version, buf ); @@ -3920,5 +3923,6 @@ bool DRW_Viewport::parseDwg( DRW::Version version, dwgBuffer *buf, duint32 bs ) if ( !ret ) return ret; + return buf->isGood(); } diff --git a/src/app/dwg/libdxfrw/drw_entities.h b/src/app/dwg/libdxfrw/drw_entities.h index 3a47f287781a..245180acbe2e 100644 --- a/src/app/dwg/libdxfrw/drw_entities.h +++ b/src/app/dwg/libdxfrw/drw_entities.h @@ -30,13 +30,13 @@ namespace DRW enum ETYPE { E3DFACE, -// E3DSOLID, // encrypted proprietary data -// ACAD_PROXY_ENTITY, + E3DSOLID, // encrypted proprietary data + ACAD_PROXY_ENTITY, ARC, -// ATTDEF, -// ATTRIB, + ATTDEF, + ATTRIB, BLOCK, // and ENDBLK -// BODY, // encrypted proprietary data + BODY, // encrypted proprietary data CIRCLE, DIMENSION, DIMALIGNED, @@ -48,39 +48,39 @@ namespace DRW DIMORDINATE, ELLIPSE, HATCH, -// HELIX, + HELIX, IMAGE, INSERT, LEADER, -// LIGHT, + LIGHT, LINE, LWPOLYLINE, -// MESH, -// MLINE, -// MLEADERSTYLE, -// MLEADER, + MESH, + MLINE, + MLEADERSTYLE, + MLEADER, MTEXT, -// OLEFRAME, -// OLE2FRAME, + OLEFRAME, + OLE2FRAME, POINT, POLYLINE, RAY, -// REGION, // encrypted proprietary data -// SECTION, -// SEQEND, // not needed?? used in polyline and insert/attrib and dwg -// SHAPE, + REGION, // encrypted proprietary data + SECTION, + SEQEND, // not needed?? used in polyline and insert/attrib and dwg + SHAPE, SOLID, SPLINE, -// SUN, -// SURFACE, // encrypted proprietary data can be four types -// TABLE, + SUN, + SURFACE, // encrypted proprietary data can be four types + TABLE, TEXT, -// TOLERANCE, + TOLERANCE, TRACE, UNDERLAY, VERTEX, VIEWPORT, -// WIPEOUT, // WIPEOUTVARIABLE + WIPEOUT, // WIPEOUTVARIABLE XLINE, UNKNOWN }; diff --git a/src/app/dwg/libdxfrw/drw_objects.cpp b/src/app/dwg/libdxfrw/drw_objects.cpp index 6e4c688f57a5..038baa39dd9c 100644 --- a/src/app/dwg/libdxfrw/drw_objects.cpp +++ b/src/app/dwg/libdxfrw/drw_objects.cpp @@ -733,6 +733,9 @@ void DRW_Layer::parseCode( int code, dxfReader *reader ) case 420: color24 = reader->getInt32(); break; + case 440: + transparency = reader->getInt32(); + break; default: DRW_TableEntry::parseCode( code, reader ); break; diff --git a/src/app/dwg/libdxfrw/drw_objects.h b/src/app/dwg/libdxfrw/drw_objects.h index 5b6ea3792907..141daac1170e 100644 --- a/src/app/dwg/libdxfrw/drw_objects.h +++ b/src/app/dwg/libdxfrw/drw_objects.h @@ -303,6 +303,7 @@ class DRW_Layer : public DRW_TableEntry UTF8STRING lineType; /*!< line type, code 6 */ int color; /*!< layer color, code 62 */ int color24; /*!< 24-bit color, code 420 */ + int transparency; /*!< Transparency, code 440 */ bool plotF; /*!< Plot flag, code 290 */ enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */ std::string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */ diff --git a/src/app/dwg/libdxfrw/intern/drw_dbg.cpp b/src/app/dwg/libdxfrw/intern/drw_dbg.cpp index 741c86d4ce04..854b5d7a74b9 100644 --- a/src/app/dwg/libdxfrw/intern/drw_dbg.cpp +++ b/src/app/dwg/libdxfrw/intern/drw_dbg.cpp @@ -10,14 +10,17 @@ ** along with this program. If not, see . ** ******************************************************************************/ -#include -#include #include "drw_dbg.h" -#include + +#include "../../../../core/qgslogger.h" + + +#include +#include DRW_dbg *DRW_dbg::instance = nullptr; -/*********private clases*************/ +/*********private classes*************/ class print_none { public: @@ -45,7 +48,11 @@ class print_debug : public print_none virtual void printHL( int c, int s, int h ); virtual void printPT( double x, double y, double z ); print_debug(); - virtual ~print_debug() {} + virtual ~print_debug() { QgsDebugMsgLevel( mBuf, 4 ); } + private: + QString mBuf; + QTextStream mTS; + void flush(); }; /********* debug class *************/ @@ -137,46 +144,64 @@ void DRW_dbg::printPT( double x, double y, double z ) prClass->printPT( x, y, z ); } -print_debug::print_debug() +print_debug::print_debug() : mTS( &mBuf ) +{ +} + +void print_debug::flush() { + QStringList lines = mBuf.split( '\n' ); + for ( int i = 0; i < lines.size() - 1; i++ ) + { + QgsDebugMsgLevel( lines[i], 4 ); + } + mBuf = lines.last(); } void print_debug::printS( std::string s ) { - qDebug() << QString::fromStdString( s ); + mTS << QString::fromStdString( s ); + flush(); } void print_debug::printI( long long int i ) { - qDebug() << i; + mTS << i; + flush(); } void print_debug::printUI( long long unsigned int i ) { - qDebug() << i; + mTS << i; + flush(); } void print_debug::printD( double d ) { - qDebug() << QString( "%1 " ).arg( d, 0, 'g' ); + mTS << QString( "%1 " ).arg( d, 0, 'g' ); + flush(); } void print_debug::printH( long long i ) { - qDebug() << QString( "0x%1" ).arg( i, 0, 16 ); + mTS << QString( "0x%1" ).arg( i, 0, 16 ); + flush(); } void print_debug::printB( int i ) { - qDebug() << QString( "0%1" ).arg( i, 0, 8 ); + mTS << QString( "0%1" ).arg( i, 0, 8 ); + flush(); } void print_debug::printHL( int c, int s, int h ) { - qDebug() << QString( "%1.%2 0x%3" ).arg( c ).arg( s ).arg( h, 0, 16 ); + mTS << QString( "%1.%2 0x%3" ).arg( c ).arg( s ).arg( h, 0, 16 ); + flush(); } void print_debug::printPT( double x, double y, double z ) { - qDebug() << QString( "x:%1 y:%2 z:%3" ).arg( x, 0, 'g' ).arg( y, 0, 'g' ).arg( z, 0, 'g' ); + mTS << QString( "x:%1 y:%2 z:%3" ).arg( x, 0, 'g' ).arg( y, 0, 'g' ).arg( z, 0, 'g' ); + flush(); } diff --git a/src/app/dwg/libdxfrw/intern/dwgbuffer.cpp b/src/app/dwg/libdxfrw/intern/dwgbuffer.cpp index dc367d6c1960..5f300baf1271 100644 --- a/src/app/dwg/libdxfrw/intern/dwgbuffer.cpp +++ b/src/app/dwg/libdxfrw/intern/dwgbuffer.cpp @@ -904,45 +904,47 @@ duint32 dwgBuffer::getCmColor( DRW::Version v ) * For R2004+, can be CMC or ENC * RGB value, first 4bits 0xC0 => ByLayer, 0xC1 => ByBlock, 0xC2 => RGB, 0xC3 => last 4 are ACIS */ -duint32 dwgBuffer::getEnColor( DRW::Version v ) +duint32 dwgBuffer::getEnColor( DRW::Version v, int &rgb, int &transparency ) { if ( v < DRW::AC1018 ) //2000- return getSBitShort(); - duint32 rgb = 0; + + rgb = -1; + transparency = 0; + duint32 cb = 0; duint16 idx = getBitShort(); DRW_DBG( "idx reads COLOR: " ); DRW_DBGH( idx ); duint16 flags = idx >> 8; + idx = idx & 0x1FF; //RLZ: warning this is correct? + DRW_DBG( "\nflag COLOR: " ); DRW_DBGH( flags ); DRW_DBG( ", index COLOR: " ); DRW_DBGH( idx ); -// if (flags & 0x80) { -// rgb = getBitLong(); -// DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb); -// } - if ( flags & 0x20 ) - { - cb = getBitLong(); - DRW_DBG( "\nTransparency COLOR: " ); - DRW_DBGH( cb ); - } - if ( flags & 0x40 ) - DRW_DBG( "\nacdbColor COLOR are present" ); - else + + if ( flags & 0x80 ) { + // complex color (rgb) + rgb = getBitLong() & 0xffffff; + + DRW_DBG( "\nRGB COLOR: " ); + DRW_DBGH( rgb ); + if ( flags & 0x80 ) { - rgb = getBitLong(); - DRW_DBG( "\nRGB COLOR: " ); - DRW_DBGH( rgb ); + DRW_DBG( "\nacdbColor COLOR are present" ); } } - /* if (flags & 0x80) - return getBitLong();*/ + if ( flags & 0x20 ) + { + transparency = getBitLong(); + DRW_DBG( "\nTransparency COLOR: " ); + DRW_DBGH( transparency ); + } return idx; //default return ByLayer } diff --git a/src/app/dwg/libdxfrw/intern/dwgbuffer.h b/src/app/dwg/libdxfrw/intern/dwgbuffer.h index 1300cb6f1a1a..96f7ccce7342 100644 --- a/src/app/dwg/libdxfrw/intern/dwgbuffer.h +++ b/src/app/dwg/libdxfrw/intern/dwgbuffer.h @@ -133,7 +133,7 @@ class dwgBuffer double getThickness( bool b_R2000_style );//BT //3DD duint32 getCmColor( DRW::Version v ); //CMC - duint32 getEnColor( DRW::Version v ); //ENC + duint32 getEnColor( DRW::Version v, int &rgb, int &transparency ); //ENC //TC duint16 getBERawShort16(); //RS big-endian order