From 3628b43a843c402d58247e6ce785a4dee711b4c7 Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Sat, 28 Feb 2015 21:52:58 +0100 Subject: [PATCH] dxf2shp cleanup: * save block inserts in separate shape instead of expanding it once at the first insertion (also removes GPL-2 only code) * update dxflib to 3.7.5 (usable under GPL-2+) --- debian/copyright | 12 +- src/plugins/dxf2shp_converter/CMakeLists.txt | 1 - src/plugins/dxf2shp_converter/builder.cpp | 338 +- src/plugins/dxf2shp_converter/builder.h | 51 +- .../dxf2shp_converter/dxf2shpconvertergui.cpp | 42 +- .../dxf2shp_converter/dxf2shpconvertergui.ui | 9 +- .../dxf2shp_converter/dxflib/confdefs.h | 3 - .../dxflib/src/dl_attributes.h | 226 +- .../dxf2shp_converter/dxflib/src/dl_codes.h | 844 +- .../dxflib/src/dl_creationadapter.h | 156 +- .../dxflib/src/dl_creationinterface.h | 344 +- .../dxf2shp_converter/dxflib/src/dl_dxf.cpp | 8559 ++++++++--------- .../dxf2shp_converter/dxflib/src/dl_dxf.h | 605 +- .../dxflib/src/dl_entities.h | 2519 ++--- .../dxflib/src/dl_exception.h | 28 +- .../dxflib/src/dl_extrusion.h | 95 +- .../dxf2shp_converter/dxflib/src/dl_global.h | 38 + .../dxf2shp_converter/dxflib/src/dl_writer.h | 525 +- .../dxflib/src/dl_writer_ascii.cpp | 133 +- .../dxflib/src/dl_writer_ascii.h | 46 +- .../dxf2shp_converter/getInsertions.cpp | 81 - src/plugins/dxf2shp_converter/getInsertions.h | 60 - 22 files changed, 7318 insertions(+), 7397 deletions(-) delete mode 100644 src/plugins/dxf2shp_converter/dxflib/confdefs.h create mode 100644 src/plugins/dxf2shp_converter/dxflib/src/dl_global.h delete mode 100644 src/plugins/dxf2shp_converter/getInsertions.cpp delete mode 100644 src/plugins/dxf2shp_converter/getInsertions.h diff --git a/debian/copyright b/debian/copyright index 7e87ebf3892..39b8cd7ee66 100644 --- a/debian/copyright +++ b/debian/copyright @@ -293,22 +293,14 @@ Comment: The code is heavily based on Christopher Michaelis' DXF to Used for the Shapefile functionality. License: MIT -Files: src/plugins/dxf2shp_converter/getInsertions.h -Copyright: Christopher Michaelis -License: GPL-2 - -Files: src/plugins/dxf2shp_converter/getInsertions.cpp -Copyright: Christopher Michaelis -License: GPL-2+ - Files: src/plugins/dxf2shp_converter/shapelib-1.2.10/* Copyright: 1999, 2001-2002, Frank Warmerdam License: MIT or LGPL-2+ Files: src/plugins/dxf2shp_converter/dxflib/src/* -Copyright: 2001-2003, RibbonSoft +Copyright: 2001-2013, RibbonSoft GmbH 2001, Robert J. Campbell Jr -License: GPL-2 or dxflib-Commercial-License +License: GPL-2+ or dxflib-Commercial-License Files: src/plugins/evis/* Copyright: 2007, American Museum of Natural History diff --git a/src/plugins/dxf2shp_converter/CMakeLists.txt b/src/plugins/dxf2shp_converter/CMakeLists.txt index 6e03db40ce9..c3c706232e4 100644 --- a/src/plugins/dxf2shp_converter/CMakeLists.txt +++ b/src/plugins/dxf2shp_converter/CMakeLists.txt @@ -6,7 +6,6 @@ SET (dxf2shpconverter_SRCS dxf2shpconverter.cpp dxf2shpconvertergui.cpp builder.cpp - getInsertions.cpp dxflib/src/dl_dxf.cpp dxflib/src/dl_writer_ascii.cpp ) diff --git a/src/plugins/dxf2shp_converter/builder.cpp b/src/plugins/dxf2shp_converter/builder.cpp index af56db4e3ae..034b1f8fd69 100644 --- a/src/plugins/dxf2shp_converter/builder.cpp +++ b/src/plugins/dxf2shp_converter/builder.cpp @@ -20,28 +20,21 @@ //IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#include -#include - #include "builder.h" +#include +#include + #include "qgslogger.h" -Builder::Builder( std::string theFname, +Builder::Builder( QString theFname, int theShapefileType, - double *theGrpXVals, double *theGrpYVals, - std::string *theGrpNames, - int theInsertCount, - bool theConvertText ) + bool theConvertText, + bool theConvertInserts ) : fname( theFname ) , shapefileType( theShapefileType ) - , grpXVals( theGrpXVals ) - , grpYVals( theGrpYVals ) - , grpNames( theGrpNames ) - , insertCount( theInsertCount ) , convertText( theConvertText ) - , fetchedprims( 0 ) - , fetchedtexts( 0 ) + , convertInserts( theConvertInserts ) , ignoringBlock( false ) , current_polyline_willclose( false ) , store_next_vertex_for_polyline_close( false ) @@ -49,65 +42,22 @@ Builder::Builder( std::string theFname, , closePolyX( 0.0 ) , closePolyY( 0.0 ) , closePolyZ( 0.0 ) - , currentBlockX( 0.0 ) - , currentBlockY( 0.0 ) { } Builder::~Builder() { - polyVertex.clear(); - shpObjects.clear(); - textObjects.clear(); -} - -int Builder::textObjectsSize() -{ - return textObjects.size(); -} - -std::string Builder::outputShp() -{ - return outputshp; -} - -std::string Builder::outputTShp() -{ - return outputtshp; } void Builder::addBlock( const DL_BlockData& data ) { - QgsDebugMsg( "start block." ); - - if ( data.name.compare( "ADCADD_ZZ" ) == 0 ) - { - QgsDebugMsg( QString( "Ignoring block %1" ).arg( data.name.c_str() ) ); - ignoringBlock = true; - } - else - { - for ( int i = 0; i < insertCount; i++ ) - { - if ( grpNames[i] == data.name ) - { - currentBlockX = grpXVals[i]; - currentBlockY = grpYVals[i]; - QgsDebugMsg( QString( "Found coord for block: (%1,%2)" ).arg( grpXVals[i] ).arg( grpYVals[i] ) ); - } - } - } + Q_UNUSED( data ); + ignoringBlock = true; } void Builder::endBlock() { - FinalizeAnyPolyline(); - - currentBlockX = 0.0; - currentBlockY = 0.0; ignoringBlock = false; - - QgsDebugMsg( "end block." ); } void Builder::addLayer( const DL_LayerData& data ) @@ -132,17 +82,8 @@ void Builder::addPoint( const DL_PointData& data ) return; } - - double x = data.x + currentBlockX; - double y = data.y + currentBlockY; - double z = data.z; - - SHPObject *psObject; - psObject = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, 1, &x, &y, &z, NULL ); - - shpObjects.push_back( psObject ); - - fetchedprims++; + double x = data.x, y = data.y, z = data.z; + shpObjects << SHPCreateObject( shapefileType, shpObjects.size(), 0, NULL, NULL, 1, &x, &y, &z, NULL ); } void Builder::addLine( const DL_LineData& data ) @@ -167,22 +108,11 @@ void Builder::addLine( const DL_LineData& data ) } - double xv[2], yv[2], zv[2]; - xv[0] = data.x1 + currentBlockX; - yv[0] = data.y1 + currentBlockY; - zv[0] = data.z1; + double xv[2] = { data.x1, data.x2 }; + double yv[2] = { data.y1, data.y2 }; + double zv[2] = { data.z1, data.z2 }; - xv[1] = data.x2 + currentBlockX; - yv[1] = data.y2 + currentBlockY; - zv[1] = data.z2; - - SHPObject *psObject; - - psObject = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, 2, xv, yv, zv, NULL ); - - shpObjects.push_back( psObject ); - - fetchedprims++; + shpObjects << SHPCreateObject( shapefileType, shpObjects.size(), 0, NULL, NULL, 2, xv, yv, zv, NULL ); } @@ -218,11 +148,10 @@ void Builder::addPolyline( const DL_PolylineData& data ) } - SHPObject *psShape; int dim = polyVertex.size(); - double *xv = new double[dim]; - double *yv = new double[dim]; - double *zv = new double[dim]; + QVector xv( dim ); + QVector yv( dim ); + QVector zv( dim ); for ( int i = 0; i < dim; i++ ) { @@ -231,20 +160,11 @@ void Builder::addPolyline( const DL_PolylineData& data ) zv[i] = polyVertex[i].z; } - psShape = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, dim, xv, yv, zv, NULL ); - - delete [] xv; - delete [] yv; - delete [] zv; - - shpObjects.push_back( psShape ); - - - fetchedprims++; + shpObjects << SHPCreateObject( shapefileType, shpObjects.size(), 0, NULL, NULL, dim, xv.data(), yv.data(), zv.data(), NULL ); polyVertex.clear(); - QgsDebugMsg( QString( "polyline prepared: %1" ).arg( fetchedprims - 1 ) ); + QgsDebugMsg( QString( "polyline prepared: %1" ).arg( shpObjects.size() - 1 ) ); current_polyline_pointcount = 0; } @@ -283,20 +203,15 @@ void Builder::addVertex( const DL_VertexData& data ) return; } - DL_VertexData myVertex; - myVertex.x = data.x + currentBlockX; - myVertex.y = data.y + currentBlockY; - myVertex.z = data.z; - - polyVertex.push_back( myVertex ); + polyVertex << DL_VertexData( data.x, data.y, data.z ); current_polyline_pointcount++; if ( store_next_vertex_for_polyline_close ) { store_next_vertex_for_polyline_close = false; - closePolyX = data.x + currentBlockX; - closePolyY = data.y + currentBlockY; + closePolyX = data.x; + closePolyY = data.y; closePolyZ = data.z; } } @@ -349,8 +264,8 @@ void Builder::addArc( const DL_ArcData& data ) radianMeasure = i * M_PI / 180.0; - myPoint.x = data.radius * cos( radianMeasure ) + data.cx + currentBlockX; - myPoint.y = data.radius * sin( radianMeasure ) + data.cy + currentBlockY; + myPoint.x = data.radius * cos( radianMeasure ) + data.cx; + myPoint.y = data.radius * sin( radianMeasure ) + data.cy; myPoint.z = data.cz; arcPoints.push_back( myPoint ); @@ -361,11 +276,10 @@ void Builder::addArc( const DL_ArcData& data ) // Finalize - SHPObject *psShape; int dim = arcPoints.size(); - double *xv = new double[dim]; - double *yv = new double[dim]; - double *zv = new double[dim]; + QVector xv( dim ); + QVector yv( dim ); + QVector zv( dim ); for ( int i = 0; i < dim; i++ ) { @@ -375,18 +289,8 @@ void Builder::addArc( const DL_ArcData& data ) } - psShape = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, dim, xv, yv, zv, NULL ); - - delete [] xv; - delete [] yv; - delete [] zv; - - shpObjects.push_back( psShape ); - - fetchedprims++; - + shpObjects << SHPCreateObject( shapefileType, shpObjects.size(), 0, NULL, NULL, dim, xv.data(), yv.data(), zv.data(), NULL ); arcPoints.clear(); - } @@ -414,18 +318,17 @@ void Builder::addCircle( const DL_CircleData& data ) long shpIndex = 0; for ( double i = 0.0; i <= 2*M_PI; i += M_PI / 180.0, shpIndex++ ) { - myPoint.x = data.radius * cos( i ) + data.cx + currentBlockX; - myPoint.y = data.radius * sin( i ) + data.cy + currentBlockY; + myPoint.x = data.radius * cos( i ) + data.cx; + myPoint.y = data.radius * sin( i ) + data.cy; myPoint.z = data.cz; circlePoints.push_back( myPoint ); } - SHPObject *psShape; int dim = circlePoints.size(); - double *xv = new double[dim]; - double *yv = new double[dim]; - double *zv = new double[dim]; + QVector xv( dim ); + QVector yv( dim ); + QVector zv( dim ); for ( int i = 0; i < dim; i++ ) { @@ -434,36 +337,40 @@ void Builder::addCircle( const DL_CircleData& data ) zv[i] = circlePoints[i].z; } - psShape = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, dim, xv, yv, zv, NULL ); - - delete [] xv; - delete [] yv; - delete [] zv; - - shpObjects.push_back( psShape ); - - fetchedprims++; + shpObjects << SHPCreateObject( shapefileType, shpObjects.size(), 0, NULL, NULL, dim, xv.data(), yv.data(), zv.data(), NULL ); circlePoints.clear(); } +void Builder::addInsert( const DL_InsertData& data ) +{ + if ( !convertInserts ) + return; + + insertObjects << DL_InsertData( + data.name, + data.ipx, data.ipy, data.ipz, + data.sx, data.sy, data.sz, + data.angle, + data.cols, data.rows, + data.colSp, data.rowSp + ); +} + void Builder::addText( const DL_TextData &data ) { - if ( convertText ) - { - DL_TextData myText( - data.ipx + currentBlockX, data.ipy + currentBlockY, data.ipz, - data.apx, data.apy, data.apz, - data.height, data.xScaleFactor, data.textGenerationFlags, - data.hJustification, data.vJustification, - data.text, data.style, data.angle - ); + if ( !convertText ) + return; - textObjects.push_back( myText ); + textObjects << DL_TextData( + data.ipx, data.ipy, data.ipz, + data.apx, data.apy, data.apz, + data.height, data.xScaleFactor, data.textGenerationFlags, + data.hJustification, data.vJustification, + data.text, data.style, data.angle + ); - QgsDebugMsg( QString( "text: %1" ).arg( data.text.c_str() ) ); - fetchedtexts++; - } + QgsDebugMsg( QString( "text: %1" ).arg( data.text.c_str() ) ); } void Builder::FinalizeAnyPolyline() @@ -473,19 +380,13 @@ void Builder::FinalizeAnyPolyline() { if ( current_polyline_willclose ) { - DL_VertexData myVertex; - myVertex.x = closePolyX; - myVertex.y = closePolyY; - myVertex.z = closePolyZ; - - polyVertex.push_back( myVertex ); + polyVertex << DL_VertexData( closePolyX, closePolyY, closePolyZ ); } - SHPObject *psObject; int dim = polyVertex.size(); - double *xv = new double[dim]; - double *yv = new double[dim]; - double *zv = new double[dim]; + QVector xv( dim ); + QVector yv( dim ); + QVector zv( dim ); for ( int i = 0; i < dim; i++ ) { @@ -494,58 +395,47 @@ void Builder::FinalizeAnyPolyline() zv[i] = polyVertex[i].z; } - psObject = SHPCreateObject( shapefileType, fetchedprims, 0, NULL, NULL, dim, xv, yv, zv, NULL ); - - delete [] xv; - delete [] yv; - delete [] zv; - - shpObjects.push_back( psObject ); - + shpObjects << SHPCreateObject( shapefileType, shpObjects.size(), 0, NULL, NULL, dim, xv.data(), yv.data(), zv.data(), NULL ); polyVertex.clear(); - fetchedprims++; - - QgsDebugMsg( QString( "Finalized adding of polyline shape %1" ).arg( fetchedprims - 1 ) ); + QgsDebugMsg( QString( "Finalized adding of polyline shape %1" ).arg( shpObjects.size() - 1 ) ); current_polyline_pointcount = 0; } } void Builder::print_shpObjects() { - int dim = shpObjects.size(); - int dimTexts = textObjects.size(); - - QgsDebugMsg( QString( "Number of primitives: %1" ).arg( dim ) ); - QgsDebugMsg( QString( "Number of text fields: %1" ).arg( dimTexts ) ); + QgsDebugMsg( QString( "Number of primitives: %1" ).arg( shpObjects.size() ) ); + QgsDebugMsg( QString( "Number of text fields: %1" ).arg( textObjects.size() ) ); + QgsDebugMsg( QString( "Number of inserts fields: %1" ).arg( insertObjects.size() ) ); SHPHandle hSHP; - if ( fname.substr( fname.length() - 4 ).compare( ".shp" ) == 0 ) + if ( fname.endsWith( ".shp", Qt::CaseInsensitive ) ) { - outputdbf = fname; - outputdbf = outputdbf.replace(( outputdbf.length() - 3 ), outputdbf.length(), "dbf" ); - outputshp = fname; - outputshp = outputshp.replace(( outputshp.length() - 3 ), outputshp.length(), "shp" ); - outputtdbf = fname; - outputtdbf = outputtdbf.replace(( outputtdbf.length() - 4 ), outputtdbf.length(), "_texts.dbf" ); - outputtshp = fname; - outputtshp = outputtshp.replace(( outputtshp.length() - 4 ), outputtshp.length(), "_texts.shp" ); + QString fn( fname.mid( fname.length() - 4 ) ); + + outputdbf = fn + ".dbf"; + outputshp = fn + ".shp"; + outputtdbf = fn + "_texts.dbf"; + outputtshp = fn + "_texts.shp"; + outputidbf = fn + "_inserts.dbf"; + outputishp = fn + "_inserts.shp"; } else { - outputdbf = outputtdbf = fname + ".dbf"; - outputshp = outputtshp = fname + ".shp"; + outputdbf = outputtdbf = outputidbf = fname + ".dbf"; + outputshp = outputtshp = outputishp = fname + ".shp"; } - DBFHandle dbffile = DBFCreate( outputdbf.c_str() ); + DBFHandle dbffile = DBFCreate( outputdbf.toUtf8() ); DBFAddField( dbffile, "myid", FTInteger, 10, 0 ); - hSHP = SHPCreate( outputshp.c_str(), shapefileType ); + hSHP = SHPCreate( outputshp.toUtf8(), shapefileType ); QgsDebugMsg( "Writing to main shp file..." ); - for ( int i = 0; i < dim; i++ ) + for ( int i = 0; i < shpObjects.size(); i++ ) { SHPWriteObject( hSHP, -1, shpObjects[i] ); SHPDestroyObject( shpObjects[i] ); @@ -557,12 +447,12 @@ void Builder::print_shpObjects() QgsDebugMsg( "Done!" ); - if ( convertText && dimTexts > 0 ) + if ( textObjects.size() > 0 ) { SHPHandle thSHP; - DBFHandle Tdbffile = DBFCreate( outputtdbf.c_str() ); - thSHP = SHPCreate( outputtshp.c_str(), SHPT_POINT ); + DBFHandle Tdbffile = DBFCreate( outputtdbf.toUtf8() ); + thSHP = SHPCreate( outputtshp.toUtf8(), SHPT_POINT ); DBFAddField( Tdbffile, "tipx", FTDouble, 20, 10 ); DBFAddField( Tdbffile, "tipy", FTDouble, 20, 10 ); @@ -581,7 +471,7 @@ void Builder::print_shpObjects() QgsDebugMsg( "Writing Texts' shp File..." ); - for ( int i = 0; i < dimTexts; i++ ) + for ( int i = 0; i < textObjects.size(); i++ ) { SHPObject *psObject; double x = textObjects[i].ipx; @@ -618,4 +508,58 @@ void Builder::print_shpObjects() QgsDebugMsg( "Done!" ); } + + if ( insertObjects.size() > 0 ) + { + SHPHandle ihSHP; + + DBFHandle Idbffile = DBFCreate( outputidbf.toUtf8() ); + ihSHP = SHPCreate( outputishp.toUtf8(), SHPT_POINT ); + + DBFAddField( Idbffile, "name", FTString, 200, 0 ); + DBFAddField( Idbffile, "ipx", FTDouble, 20, 10 ); + DBFAddField( Idbffile, "ipy", FTDouble, 20, 10 ); + DBFAddField( Idbffile, "ipz", FTDouble, 20, 10 ); + DBFAddField( Idbffile, "sx", FTDouble, 20, 10 ); + DBFAddField( Idbffile, "sy", FTDouble, 20, 10 ); + DBFAddField( Idbffile, "sz", FTDouble, 20, 10 ); + DBFAddField( Idbffile, "angle", FTDouble, 20, 10 ); + DBFAddField( Idbffile, "cols", FTInteger, 20, 0 ); + DBFAddField( Idbffile, "rows", FTInteger, 20, 0 ); + DBFAddField( Idbffile, "colsp", FTDouble, 20, 10 ); + DBFAddField( Idbffile, "rowsp", FTDouble, 20, 10 ); + + QgsDebugMsg( "Writing Insert' shp File..." ); + + for ( int i = 0; i < insertObjects.size(); i++ ) + { + SHPObject *psObject; + double &x = insertObjects[i].ipx; + double &y = insertObjects[i].ipy; + double &z = insertObjects[i].ipz; + psObject = SHPCreateObject( SHPT_POINT, i, 0, NULL, NULL, 1, &x, &y, &z, NULL ); + + SHPWriteObject( ihSHP, -1, psObject ); + + int c = 0; + DBFWriteStringAttribute( Idbffile, i, c++, insertObjects[i].name.c_str() ); + DBFWriteDoubleAttribute( Idbffile, i, c++, insertObjects[i].ipx ); + DBFWriteDoubleAttribute( Idbffile, i, c++, insertObjects[i].ipy ); + DBFWriteDoubleAttribute( Idbffile, i, c++, insertObjects[i].ipz ); + DBFWriteDoubleAttribute( Idbffile, i, c++, insertObjects[i].sx ); + DBFWriteDoubleAttribute( Idbffile, i, c++, insertObjects[i].sy ); + DBFWriteDoubleAttribute( Idbffile, i, c++, insertObjects[i].sz ); + DBFWriteDoubleAttribute( Idbffile, i, c++, insertObjects[i].angle ); + DBFWriteIntegerAttribute( Idbffile, i, c++, insertObjects[i].cols ); + DBFWriteIntegerAttribute( Idbffile, i, c++, insertObjects[i].rows ); + DBFWriteDoubleAttribute( Idbffile, i, c++, insertObjects[i].colSp ); + DBFWriteDoubleAttribute( Idbffile, i, c++, insertObjects[i].rowSp ); + + SHPDestroyObject( psObject ); + } + SHPClose( ihSHP ); + DBFClose( Idbffile ); + + QgsDebugMsg( "Done!" ); + } } diff --git a/src/plugins/dxf2shp_converter/builder.h b/src/plugins/dxf2shp_converter/builder.h index 0f6a4129bb4..1568421adae 100644 --- a/src/plugins/dxf2shp_converter/builder.h +++ b/src/plugins/dxf2shp_converter/builder.h @@ -22,18 +22,15 @@ #include "dxflib/src/dl_creationadapter.h" #include "shapelib-1.2.10/shapefil.h" -#include "getInsertions.h" -#include + +#include +#include + class Builder: public DL_CreationAdapter { public: - Builder( std::string theFname, - int theShapefileType, - double *theGrpXVals, double *theGrpYVals, - std::string *theGrpNames, - int theInsertCount, - bool theConvertText ); + Builder( QString theFname, int theShapefileType, bool theConvertText, bool theConvertInserts ); ~Builder(); void FinalizeAnyPolyline(); @@ -41,6 +38,7 @@ class Builder: public DL_CreationAdapter virtual void addLayer( const DL_LayerData &data ) override; virtual void addPoint( const DL_PointData &data ) override; virtual void addLine( const DL_LineData &data ) override; + virtual void addInsert( const DL_InsertData &data ) override; virtual void addPolyline( const DL_PolylineData &data ) override; virtual void addArc( const DL_ArcData &data ) override; virtual void addCircle( const DL_CircleData &data ) override; @@ -52,30 +50,32 @@ class Builder: public DL_CreationAdapter void print_shpObjects(); - int textObjectsSize(); - std::string outputShp(); - std::string outputTShp(); + int textObjectsSize() const { return textObjects.size(); } + int insertObjectsSize() const { return insertObjects.size(); } + QString outputShp() const { return outputshp; } + QString outputTShp() const { return outputtshp; } + QString outputIShp() const { return outputishp; } private: - std::string fname; + QString fname; int shapefileType; // SHPT_POINT, ... - double *grpXVals; - double *grpYVals; - std::string *grpNames; - int insertCount; bool convertText; + bool convertInserts; - std::string outputdbf; - std::string outputshp; - std::string outputtdbf; - std::string outputtshp; + QString outputdbf; + QString outputshp; - std::vector polyVertex; - std::vector shpObjects; // all read objects are stored here - std::vector textObjects; + QString outputtdbf; + QString outputtshp; - int fetchedprims; - int fetchedtexts; + QString outputidbf; + QString outputishp; + + QList shpObjects; // all read objects are stored here + + QList polyVertex; + QList textObjects; + QList insertObjects; bool ignoringBlock; bool current_polyline_willclose; @@ -84,5 +84,4 @@ class Builder: public DL_CreationAdapter long current_polyline_pointcount; double closePolyX, closePolyY, closePolyZ; - double currentBlockX, currentBlockY; }; diff --git a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp b/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp index 3541936f3b2..d95fb6ad4e8 100644 --- a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp +++ b/src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp @@ -16,7 +16,6 @@ #include "qgscontexthelp.h" #include "builder.h" -#include "getInsertions.h" #include "dxflib/src/dl_dxf.h" //qt includes @@ -58,8 +57,9 @@ void dxf2shpConverterGui::on_buttonBox_accepted() return; } + QApplication::setOverrideCursor( Qt::BusyCursor ); + int type = SHPT_POINT; - bool convtexts = convertTextCheck->checkState(); if ( polyline->isChecked() ) type = SHPT_ARC; @@ -70,28 +70,7 @@ void dxf2shpConverterGui::on_buttonBox_accepted() if ( point->isChecked() ) type = SHPT_POINT; - InsertRetrClass *insertRetr = new InsertRetrClass(); - - DL_Dxf *dxf_inserts = new DL_Dxf(); - - if ( !dxf_inserts->in( inf.toStdString(), insertRetr ) ) - { - // if file open failed - QgsDebugMsg( "Aborting: The input file could not be opened." ); - delete dxf_inserts; - return; - } - - Builder *parser = new Builder( - outd.toStdString(), - type, - insertRetr->XVals, insertRetr->YVals, - insertRetr->Names, - insertRetr->countInserts, - convtexts ); - - QgsDebugMsg( QString( "Finished getting insertions. Count: %1" ).arg( insertRetr->countInserts ) ); - delete dxf_inserts; + Builder *parser = new Builder( outd, type, convertTextCheck->isChecked(), convertInsertCheck->isChecked() ); DL_Dxf *dxf_Main = new DL_Dxf(); @@ -100,23 +79,30 @@ void dxf2shpConverterGui::on_buttonBox_accepted() // if file open failed delete dxf_Main; QgsDebugMsg( "Aborting: The input file could not be opened." ); + QApplication::restoreOverrideCursor(); return; } - delete insertRetr; delete dxf_Main; parser->print_shpObjects(); - emit createLayer( QString(( parser->outputShp() ).c_str() ), QString( "Data layer" ) ); + emit createLayer( parser->outputShp(), "Data layer" ); - if ( convtexts && parser->textObjectsSize() > 0 ) + if ( convertTextCheck->isChecked() && parser->textObjectsSize() > 0 ) { - emit createLayer( QString(( parser->outputTShp() ).c_str() ), QString( "Text layer" ) ); + emit createLayer( parser->outputTShp(), "Text layer" ); + } + + if ( convertInsertCheck->isChecked() && parser->insertObjectsSize() > 0 ) + { + emit createLayer( parser->outputIShp(), "Insert layer" ); } delete parser; + QApplication::restoreOverrideCursor(); + accept(); } diff --git a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.ui b/src/plugins/dxf2shp_converter/dxf2shpconvertergui.ui index d3c3b34d321..38ffcc04f7f 100644 --- a/src/plugins/dxf2shp_converter/dxf2shpconvertergui.ui +++ b/src/plugins/dxf2shp_converter/dxf2shpconvertergui.ui @@ -59,7 +59,14 @@ - + + + + Export inserts + + + + Export text labels diff --git a/src/plugins/dxf2shp_converter/dxflib/confdefs.h b/src/plugins/dxf2shp_converter/dxflib/confdefs.h deleted file mode 100644 index f74e15c125c..00000000000 --- a/src/plugins/dxf2shp_converter/dxflib/confdefs.h +++ /dev/null @@ -1,3 +0,0 @@ -/* This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; version 2 of the License */ diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h index f4e33a12741..98d6720a8de 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h @@ -1,20 +1,14 @@ /**************************************************************************** -** $Id: dl_attributes.h 2334 2005-03-27 23:37:52Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -31,8 +25,10 @@ #ifndef DL_ATTRIBUTES_H #define DL_ATTRIBUTES_H +#include "dl_global.h" + #include -using std::string; +#include #include "dl_codes.h" @@ -42,158 +38,198 @@ using std::string; * * @author Andrew Mustun */ -class DL_Attributes -{ +class DXFLIB_EXPORT DL_Attributes { - public: +public: /** * Default constructor. */ - DL_Attributes() - { - setLayer( "" ); - setColor( 0 ); - setWidth( 0 ); - setLineType( "BYLAYER" ); + DL_Attributes() : + layer(""), + color(0), + color24(-1), + width(0), + linetype("BYLAYER"), + linetypeScale(1.0), + handle(-1), + inPaperSpace(false) { } - - /** * Constructor for DXF attributes. * * @param layer Layer name for this entity or NULL for no layer * (every entity should be on a named layer!). * @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER. - * @param width Line thickness. Defaults to zero. -1 = BYLAYER, + * @param width Line thickness. Defaults to zero. -1 = BYLAYER, * -2 = BYBLOCK, -3 = default width - * @param lineType Line type name or "BYLAYER" or "BYBLOCK". Defaults + * @param linetype Line type name or "BYLAYER" or "BYBLOCK". Defaults * to "BYLAYER" */ - DL_Attributes( const string& layer, - int color, int width, - const string& lineType ) - { - setLayer( layer ); - setColor( color ); - setWidth( width ); - setLineType( lineType ); + DL_Attributes(const std::string& layer, + int color, int width, + const std::string& linetype, + double linetypeScale) : + layer(layer), + color(color), + color24(-1), + width(width), + linetype(linetype), + linetypeScale(linetypeScale), + handle(-1), + inPaperSpace(false) { + + } + + /** + * Constructor for DXF attributes. + * + * @param layer Layer name for this entity or NULL for no layer + * (every entity should be on a named layer!). + * @param color Color number (0..256). 0 = BYBLOCK, 256 = BYLAYER. + * @param color24 24 bit color (see DXF reference). + * @param width Line thickness. Defaults to zero. -1 = BYLAYER, + * -2 = BYBLOCK, -3 = default width + * @param linetype Line type name or "BYLAYER" or "BYBLOCK". Defaults + * to "BYLAYER" + */ + DL_Attributes(const std::string& layer, + int color, int color24, int width, + const std::string& linetype, + int handle=-1) : + layer(layer), + color(color), + color24(color24), + width(width), + linetype(linetype), + linetypeScale(1.0), + handle(handle), + inPaperSpace(false) { } - - /** * Sets the layer. If the given pointer points to NULL, the * new layer name will be an empty but valid string. */ - void setLayer( const string& layer ) - { - this->layer = layer; + void setLayer(const std::string& layer) { + this->layer = layer; } - - /** * @return Layer name. */ - string getLayer() const - { - return layer; + std::string getLayer() const { + return layer; } - - /** * Sets the color. * * @see DL_Codes, dxfColors */ - void setColor( int color ) - { - this->color = color; + void setColor(int color) { + this->color = color; + } + + /** + * Sets the 24bit color. + * + * @see DL_Codes, dxfColors + */ + void setColor24(int color) { + this->color24 = color; } - - /** * @return Color. * * @see DL_Codes, dxfColors */ - int getColor() const - { - return color; + int getColor() const { + return color; + } + + /** + * @return 24 bit color or -1 if no 24bit color is defined. + * + * @see DL_Codes, dxfColors + */ + int getColor24() const { + return color24; } - - /** * Sets the width. */ - void setWidth( int width ) - { - this->width = width; + void setWidth(int width) { + this->width = width; } - - /** * @return Width. */ - int getWidth() const - { - return width; + int getWidth() const { + return width; } - - /** * Sets the line type. This can be any string and is not - * checked to be a valid line type. + * checked to be a valid line type. */ - void setLineType( const string& lineType ) - { - this->lineType = lineType; + void setLinetype(const std::string& linetype) { + this->linetype = linetype; } + /** + * Sets the entity specific line type scale. + */ + void setLinetypeScale(double linetypeScale) { + this->linetypeScale = linetypeScale; + } + double getLinetypeScale() const { + return linetypeScale; + } /** * @return Line type. */ - string getLineType() const - { - if ( lineType.length() == 0 ) - { - return "BYLAYER"; - } - else - { - return lineType; - } + std::string getLinetype() const { + if (linetype.length()==0) { + return "BYLAYER"; + } else { + return linetype; + } } - - - /** - * Copies attributes (deep copies) from another attribute object. - */ - DL_Attributes &operator= ( const DL_Attributes& attrib ) - { - setLayer( attrib.layer ); - setColor( attrib.color ); - setWidth( attrib.width ); - setLineType( attrib.lineType ); - - return *this; + void setHandle(int h) { + handle = h; } - private: - string layer; + int getHandle() const { + return handle; + } + + void setInPaperSpace(bool on) { + inPaperSpace = on; + } + + bool isInPaperSpace() { + return inPaperSpace; + } + +private: + std::string layer; int color; + int color24; int width; - string lineType; + std::string linetype; + double linetypeScale; + int handle; + + // DXF code 67 (true: entity in paper space, false: entity in model space (default): + bool inPaperSpace; }; #endif diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_codes.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_codes.h index 4be58e2ee11..cf6fb896f97 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_codes.h +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_codes.h @@ -1,21 +1,15 @@ /**************************************************************************** -** $Id: dl_codes.h 273 2005-02-28 18:14:39Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** Copyright (C) 2001 Robert J. Campbell Jr. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -36,14 +30,21 @@ #ifndef DXF_CODES_H #define DXF_CODES_H +#include "dl_global.h" + #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 -#if defined(__OS2__)||defined(__EMX__)||defined(_WIN32) +#if defined(__OS2__)||defined(__EMX__) #define strcasecmp(s,t) stricmp(s,t) #endif +#if defined(_WIN32) +#define strcasecmp(s,t) _stricmp(s,t) +#endif + + #ifdef _WIN32 #undef M_PI #define M_PI 3.14159265358979323846 @@ -63,40 +64,40 @@ /** * Codes for colors and DXF versions. */ -class DL_Codes -{ - public: +class DXFLIB_EXPORT DL_Codes { +public: /** * Standard DXF colors. */ - enum color - { - black = 250, - green = 3, - red = 1, - brown = 15, - yellow = 2, - cyan = 4, - magenta = 6, - gray = 8, - blue = 5, - l_blue = 163, - l_green = 121, - l_cyan = 131, - l_red = 23, - l_magenta = 221, - l_gray = 252, - white = 7, - bylayer = 256, - byblock = 0 + enum color { + black = 250, + green = 3, + red = 1, + brown = 15, + yellow = 2, + cyan = 4, + magenta = 6, + gray = 8, + blue = 5, + l_blue = 163, + l_green = 121, + l_cyan = 131, + l_red = 23, + l_magenta = 221, + l_gray = 252, + white = 7, + bylayer = 256, + byblock = 0 }; /** * Version numbers for the DXF Format. */ - enum version - { - AC1009, AC1012, AC1014, AC1015 + enum version { + AC1009, // R12 + AC1012, + AC1014, + AC1015 // R2000 }; }; @@ -104,442 +105,441 @@ class DL_Codes // Extended color palette: // The first entry is only for direct indexing starting with [1] // Color 1 is red (1,0,0) -const double dxfColors[][3] = -{ - {0, 0, 0}, // unused - {1, 0, 0}, // 1 - {1, 1, 0}, - {0, 1, 0}, - {0, 1, 1}, - {0, 0, 1}, - {1, 0, 1}, - {1, 1, 1}, // black or white - {0.5, 0.5, 0.5}, - {0.75, 0.75, 0.75}, - {1, 0, 0}, // 10 - {1, 0.5, 0.5}, - {0.65, 0, 0}, - {0.65, 0.325, 0.325}, - {0.5, 0, 0}, - {0.5, 0.25, 0.25}, - {0.3, 0, 0}, - {0.3, 0.15, 0.15}, - {0.15, 0, 0}, - {0.15, 0.075, 0.075}, - {1, 0.25, 0}, // 20 - {1, 0.625, 0.5}, - {0.65, 0.1625, 0}, - {0.65, 0.4063, 0.325}, - {0.5, 0.125, 0}, - {0.5, 0.3125, 0.25}, - {0.3, 0.075, 0}, - {0.3, 0.1875, 0.15}, - {0.15, 0.0375, 0}, - {0.15, 0.0938, 0.075}, - {1, 0.5, 0}, // 30 - {1, 0.75, 0.5}, - {0.65, 0.325, 0}, - {0.65, 0.4875, 0.325}, - {0.5, 0.25, 0}, - {0.5, 0.375, 0.25}, - {0.3, 0.15, 0}, - {0.3, 0.225, 0.15}, - {0.15, 0.075, 0}, - {0.15, 0.1125, 0.075}, - {1, 0.75, 0}, // 40 - {1, 0.875, 0.5}, - {0.65, 0.4875, 0}, - {0.65, 0.5688, 0.325}, - {0.5, 0.375, 0}, - {0.5, 0.4375, 0.25}, - {0.3, 0.225, 0}, - {0.3, 0.2625, 0.15}, - {0.15, 0.1125, 0}, - {0.15, 0.1313, 0.075}, - {1, 1, 0}, // 50 - {1, 1, 0.5}, - {0.65, 0.65, 0}, - {0.65, 0.65, 0.325}, - {0.5, 0.5, 0}, - {0.5, 0.5, 0.25}, - {0.3, 0.3, 0}, - {0.3, 0.3, 0.15}, - {0.15, 0.15, 0}, - {0.15, 0.15, 0.075}, - {0.75, 1, 0}, // 60 - {0.875, 1, 0.5}, - {0.4875, 0.65, 0}, - {0.5688, 0.65, 0.325}, - {0.375, 0.5, 0}, - {0.4375, 0.5, 0.25}, - {0.225, 0.3, 0}, - {0.2625, 0.3, 0.15}, - {0.1125, 0.15, 0}, - {0.1313, 0.15, 0.075}, - {0.5, 1, 0}, // 70 - {0.75, 1, 0.5}, - {0.325, 0.65, 0}, - {0.4875, 0.65, 0.325}, - {0.25, 0.5, 0}, - {0.375, 0.5, 0.25}, - {0.15, 0.3, 0}, - {0.225, 0.3, 0.15}, - {0.075, 0.15, 0}, - {0.1125, 0.15, 0.075}, - {0.25, 1, 0}, // 80 - {0.625, 1, 0.5}, - {0.1625, 0.65, 0}, - {0.4063, 0.65, 0.325}, - {0.125, 0.5, 0}, - {0.3125, 0.5, 0.25}, - {0.075, 0.3, 0}, - {0.1875, 0.3, 0.15}, - {0.0375, 0.15, 0}, - {0.0938, 0.15, 0.075}, - {0, 1, 0}, // 90 - {0.5, 1, 0.5}, - {0, 0.65, 0}, - {0.325, 0.65, 0.325}, - {0, 0.5, 0}, - {0.25, 0.5, 0.25}, - {0, 0.3, 0}, - {0.15, 0.3, 0.15}, - {0, 0.15, 0}, - {0.075, 0.15, 0.075}, - {0, 1, 0.25}, // 100 - {0.5, 1, 0.625}, - {0, 0.65, 0.1625}, - {0.325, 0.65, 0.4063}, - {0, 0.5, 0.125}, - {0.25, 0.5, 0.3125}, - {0, 0.3, 0.075}, - {0.15, 0.3, 0.1875}, - {0, 0.15, 0.0375}, - {0.075, 0.15, 0.0938}, - {0, 1, 0.5}, // 110 - {0.5, 1, 0.75}, - {0, 0.65, 0.325}, - {0.325, 0.65, 0.4875}, - {0, 0.5, 0.25}, - {0.25, 0.5, 0.375}, - {0, 0.3, 0.15}, - {0.15, 0.3, 0.225}, - {0, 0.15, 0.075}, - {0.075, 0.15, 0.1125}, - {0, 1, 0.75}, // 120 - {0.5, 1, 0.875}, - {0, 0.65, 0.4875}, - {0.325, 0.65, 0.5688}, - {0, 0.5, 0.375}, - {0.25, 0.5, 0.4375}, - {0, 0.3, 0.225}, - {0.15, 0.3, 0.2625}, - {0, 0.15, 0.1125}, - {0.075, 0.15, 0.1313}, - {0, 1, 1}, // 130 - {0.5, 1, 1}, - {0, 0.65, 0.65}, - {0.325, 0.65, 0.65}, - {0, 0.5, 0.5}, - {0.25, 0.5, 0.5}, - {0, 0.3, 0.3}, - {0.15, 0.3, 0.3}, - {0, 0.15, 0.15}, - {0.075, 0.15, 0.15}, - {0, 0.75, 1}, // 140 - {0.5, 0.875, 1}, - {0, 0.4875, 0.65}, - {0.325, 0.5688, 0.65}, - {0, 0.375, 0.5}, - {0.25, 0.4375, 0.5}, - {0, 0.225, 0.3}, - {0.15, 0.2625, 0.3}, - {0, 0.1125, 0.15}, - {0.075, 0.1313, 0.15}, - {0, 0.5, 1}, // 150 - {0.5, 0.75, 1}, - {0, 0.325, 0.65}, - {0.325, 0.4875, 0.65}, - {0, 0.25, 0.5}, - {0.25, 0.375, 0.5}, - {0, 0.15, 0.3}, - {0.15, 0.225, 0.3}, - {0, 0.075, 0.15}, - {0.075, 0.1125, 0.15}, - {0, 0.25, 1}, // 160 - {0.5, 0.625, 1}, - {0, 0.1625, 0.65}, - {0.325, 0.4063, 0.65}, - {0, 0.125, 0.5}, - {0.25, 0.3125, 0.5}, - {0, 0.075, 0.3}, - {0.15, 0.1875, 0.3}, - {0, 0.0375, 0.15}, - {0.075, 0.0938, 0.15}, - {0, 0, 1}, // 170 - {0.5, 0.5, 1}, - {0, 0, 0.65}, - {0.325, 0.325, 0.65}, - {0, 0, 0.5}, - {0.25, 0.25, 0.5}, - {0, 0, 0.3}, - {0.15, 0.15, 0.3}, - {0, 0, 0.15}, - {0.075, 0.075, 0.15}, - {0.25, 0, 1}, // 180 - {0.625, 0.5, 1}, - {0.1625, 0, 0.65}, - {0.4063, 0.325, 0.65}, - {0.125, 0, 0.5}, - {0.3125, 0.25, 0.5}, - {0.075, 0, 0.3}, - {0.1875, 0.15, 0.3}, - {0.0375, 0, 0.15}, - {0.0938, 0.075, 0.15}, - {0.5, 0, 1}, // 190 - {0.75, 0.5, 1}, - {0.325, 0, 0.65}, - {0.4875, 0.325, 0.65}, - {0.25, 0, 0.5}, - {0.375, 0.25, 0.5}, - {0.15, 0, 0.3}, - {0.225, 0.15, 0.3}, - {0.075, 0, 0.15}, - {0.1125, 0.075, 0.15}, - {0.75, 0, 1}, // 200 - {0.875, 0.5, 1}, - {0.4875, 0, 0.65}, - {0.5688, 0.325, 0.65}, - {0.375, 0, 0.5}, - {0.4375, 0.25, 0.5}, - {0.225, 0, 0.3}, - {0.2625, 0.15, 0.3}, - {0.1125, 0, 0.15}, - {0.1313, 0.075, 0.15}, - {1, 0, 1}, // 210 - {1, 0.5, 1}, - {0.65, 0, 0.65}, - {0.65, 0.325, 0.65}, - {0.5, 0, 0.5}, - {0.5, 0.25, 0.5}, - {0.3, 0, 0.3}, - {0.3, 0.15, 0.3}, - {0.15, 0, 0.15}, - {0.15, 0.075, 0.15}, - {1, 0, 0.75}, // 220 - {1, 0.5, 0.875}, - {0.65, 0, 0.4875}, - {0.65, 0.325, 0.5688}, - {0.5, 0, 0.375}, - {0.5, 0.25, 0.4375}, - {0.3, 0, 0.225}, - {0.3, 0.15, 0.2625}, - {0.15, 0, 0.1125}, - {0.15, 0.075, 0.1313}, - {1, 0, 0.5}, // 230 - {1, 0.5, 0.75}, - {0.65, 0, 0.325}, - {0.65, 0.325, 0.4875}, - {0.5, 0, 0.25}, - {0.5, 0.25, 0.375}, - {0.3, 0, 0.15}, - {0.3, 0.15, 0.225}, - {0.15, 0, 0.075}, - {0.15, 0.075, 0.1125}, - {1, 0, 0.25}, // 240 - {1, 0.5, 0.625}, - {0.65, 0, 0.1625}, - {0.65, 0.325, 0.4063}, - {0.5, 0, 0.125}, - {0.5, 0.25, 0.3125}, - {0.3, 0, 0.075}, - {0.3, 0.15, 0.1875}, - {0.15, 0, 0.0375}, - {0.15, 0.075, 0.0938}, - {0.33, 0.33, 0.33}, // 250 - {0.464, 0.464, 0.464}, - {0.598, 0.598, 0.598}, - {0.732, 0.732, 0.732}, - {0.866, 0.866, 0.866}, - {1, 1, 1} // 255 -} -; +const double dxfColors[][3] = { + {0,0,0}, // unused + {1,0,0}, // 1 + {1,1,0}, + {0,1,0}, + {0,1,1}, + {0,0,1}, + {1,0,1}, + {1,1,1}, // black or white + {0.5,0.5,0.5}, + {0.75,0.75,0.75}, + {1,0,0}, // 10 + {1,0.5,0.5}, + {0.65,0,0}, + {0.65,0.325,0.325}, + {0.5,0,0}, + {0.5,0.25,0.25}, + {0.3,0,0}, + {0.3,0.15,0.15}, + {0.15,0,0}, + {0.15,0.075,0.075}, + {1,0.25,0}, // 20 + {1,0.625,0.5}, + {0.65,0.1625,0}, + {0.65,0.4063,0.325}, + {0.5,0.125,0}, + {0.5,0.3125,0.25}, + {0.3,0.075,0}, + {0.3,0.1875,0.15}, + {0.15,0.0375,0}, + {0.15,0.0938,0.075}, + {1,0.5,0}, // 30 + {1,0.75,0.5}, + {0.65,0.325,0}, + {0.65,0.4875,0.325}, + {0.5,0.25,0}, + {0.5,0.375,0.25}, + {0.3,0.15,0}, + {0.3,0.225,0.15}, + {0.15,0.075,0}, + {0.15,0.1125,0.075}, + {1,0.75,0}, // 40 + {1,0.875,0.5}, + {0.65,0.4875,0}, + {0.65,0.5688,0.325}, + {0.5,0.375,0}, + {0.5,0.4375,0.25}, + {0.3,0.225,0}, + {0.3,0.2625,0.15}, + {0.15,0.1125,0}, + {0.15,0.1313,0.075}, + {1,1,0}, // 50 + {1,1,0.5}, + {0.65,0.65,0}, + {0.65,0.65,0.325}, + {0.5,0.5,0}, + {0.5,0.5,0.25}, + {0.3,0.3,0}, + {0.3,0.3,0.15}, + {0.15,0.15,0}, + {0.15,0.15,0.075}, + {0.75,1,0}, // 60 + {0.875,1,0.5}, + {0.4875,0.65,0}, + {0.5688,0.65,0.325}, + {0.375,0.5,0}, + {0.4375,0.5,0.25}, + {0.225,0.3,0}, + {0.2625,0.3,0.15}, + {0.1125,0.15,0}, + {0.1313,0.15,0.075}, + {0.5,1,0}, // 70 + {0.75,1,0.5}, + {0.325,0.65,0}, + {0.4875,0.65,0.325}, + {0.25,0.5,0}, + {0.375,0.5,0.25}, + {0.15,0.3,0}, + {0.225,0.3,0.15}, + {0.075,0.15,0}, + {0.1125,0.15,0.075}, + {0.25,1,0}, // 80 + {0.625,1,0.5}, + {0.1625,0.65,0}, + {0.4063,0.65,0.325}, + {0.125,0.5,0}, + {0.3125,0.5,0.25}, + {0.075,0.3,0}, + {0.1875,0.3,0.15}, + {0.0375,0.15,0}, + {0.0938,0.15,0.075}, + {0,1,0}, // 90 + {0.5,1,0.5}, + {0,0.65,0}, + {0.325,0.65,0.325}, + {0,0.5,0}, + {0.25,0.5,0.25}, + {0,0.3,0}, + {0.15,0.3,0.15}, + {0,0.15,0}, + {0.075,0.15,0.075}, + {0,1,0.25}, // 100 + {0.5,1,0.625}, + {0,0.65,0.1625}, + {0.325,0.65,0.4063}, + {0,0.5,0.125}, + {0.25,0.5,0.3125}, + {0,0.3,0.075}, + {0.15,0.3,0.1875}, + {0,0.15,0.0375}, + {0.075,0.15,0.0938}, + {0,1,0.5}, // 110 + {0.5,1,0.75}, + {0,0.65,0.325}, + {0.325,0.65,0.4875}, + {0,0.5,0.25}, + {0.25,0.5,0.375}, + {0,0.3,0.15}, + {0.15,0.3,0.225}, + {0,0.15,0.075}, + {0.075,0.15,0.1125}, + {0,1,0.75}, // 120 + {0.5,1,0.875}, + {0,0.65,0.4875}, + {0.325,0.65,0.5688}, + {0,0.5,0.375}, + {0.25,0.5,0.4375}, + {0,0.3,0.225}, + {0.15,0.3,0.2625}, + {0,0.15,0.1125}, + {0.075,0.15,0.1313}, + {0,1,1}, // 130 + {0.5,1,1}, + {0,0.65,0.65}, + {0.325,0.65,0.65}, + {0,0.5,0.5}, + {0.25,0.5,0.5}, + {0,0.3,0.3}, + {0.15,0.3,0.3}, + {0,0.15,0.15}, + {0.075,0.15,0.15}, + {0,0.75,1}, // 140 + {0.5,0.875,1}, + {0,0.4875,0.65}, + {0.325,0.5688,0.65}, + {0,0.375,0.5}, + {0.25,0.4375,0.5}, + {0,0.225,0.3}, + {0.15,0.2625,0.3}, + {0,0.1125,0.15}, + {0.075,0.1313,0.15}, + {0,0.5,1}, // 150 + {0.5,0.75,1}, + {0,0.325,0.65}, + {0.325,0.4875,0.65}, + {0,0.25,0.5}, + {0.25,0.375,0.5}, + {0,0.15,0.3}, + {0.15,0.225,0.3}, + {0,0.075,0.15}, + {0.075,0.1125,0.15}, + {0,0.25,1}, // 160 + {0.5,0.625,1}, + {0,0.1625,0.65}, + {0.325,0.4063,0.65}, + {0,0.125,0.5}, + {0.25,0.3125,0.5}, + {0,0.075,0.3}, + {0.15,0.1875,0.3}, + {0,0.0375,0.15}, + {0.075,0.0938,0.15}, + {0,0,1}, // 170 + {0.5,0.5,1}, + {0,0,0.65}, + {0.325,0.325,0.65}, + {0,0,0.5}, + {0.25,0.25,0.5}, + {0,0,0.3}, + {0.15,0.15,0.3}, + {0,0,0.15}, + {0.075,0.075,0.15}, + {0.25,0,1}, // 180 + {0.625,0.5,1}, + {0.1625,0,0.65}, + {0.4063,0.325,0.65}, + {0.125,0,0.5}, + {0.3125,0.25,0.5}, + {0.075,0,0.3}, + {0.1875,0.15,0.3}, + {0.0375,0,0.15}, + {0.0938,0.075,0.15}, + {0.5,0,1}, // 190 + {0.75,0.5,1}, + {0.325,0,0.65}, + {0.4875,0.325,0.65}, + {0.25,0,0.5}, + {0.375,0.25,0.5}, + {0.15,0,0.3}, + {0.225,0.15,0.3}, + {0.075,0,0.15}, + {0.1125,0.075,0.15}, + {0.75,0,1}, // 200 + {0.875,0.5,1}, + {0.4875,0,0.65}, + {0.5688,0.325,0.65}, + {0.375,0,0.5}, + {0.4375,0.25,0.5}, + {0.225,0,0.3}, + {0.2625,0.15,0.3}, + {0.1125,0,0.15}, + {0.1313,0.075,0.15}, + {1,0,1}, // 210 + {1,0.5,1}, + {0.65,0,0.65}, + {0.65,0.325,0.65}, + {0.5,0,0.5}, + {0.5,0.25,0.5}, + {0.3,0,0.3}, + {0.3,0.15,0.3}, + {0.15,0,0.15}, + {0.15,0.075,0.15}, + {1,0,0.75}, // 220 + {1,0.5,0.875}, + {0.65,0,0.4875}, + {0.65,0.325,0.5688}, + {0.5,0,0.375}, + {0.5,0.25,0.4375}, + {0.3,0,0.225}, + {0.3,0.15,0.2625}, + {0.15,0,0.1125}, + {0.15,0.075,0.1313}, + {1,0,0.5}, // 230 + {1,0.5,0.75}, + {0.65,0,0.325}, + {0.65,0.325,0.4875}, + {0.5,0,0.25}, + {0.5,0.25,0.375}, + {0.3,0,0.15}, + {0.3,0.15,0.225}, + {0.15,0,0.075}, + {0.15,0.075,0.1125}, + {1,0,0.25}, // 240 + {1,0.5,0.625}, + {0.65,0,0.1625}, + {0.65,0.325,0.4063}, + {0.5,0,0.125}, + {0.5,0.25,0.3125}, + {0.3,0,0.075}, + {0.3,0.15,0.1875}, + {0.15,0,0.0375}, + {0.15,0.075,0.0938}, + {0.33,0.33,0.33}, // 250 + {0.464,0.464,0.464}, + {0.598,0.598,0.598}, + {0.732,0.732,0.732}, + {0.866,0.866,0.866}, + {1,1,1} // 255 + } + ; // AutoCAD VERSION aliases -#define VER_R12 DL_Codes::AC1009 -#define VER_LT2 DL_Codes::AC1009 -#define VER_R13 DL_Codes::AC1012 // not supported yet -#define VER_LT95 DL_Codes::AC1012 // not supported yet -#define VER_R14 DL_Codes::AC1014 // not supported yet -#define VER_LT97 DL_Codes::AC1014 // not supported yet -#define VER_LT98 DL_Codes::AC1014 // not supported yet -#define VER_2000 DL_Codes::AC1015 -#define VER_2002 DL_Codes::AC1015 +#define DL_VERSION_R12 DL_Codes::AC1009 +#define DL_VERSION_LT2 DL_Codes::AC1009 +#define DL_VERSION_R13 DL_Codes::AC1012 // not supported yet +#define DL_VERSION_LT95 DL_Codes::AC1012 // not supported yet +#define DL_VERSION_R14 DL_Codes::AC1014 // not supported yet +#define DL_VERSION_LT97 DL_Codes::AC1014 // not supported yet +#define DL_VERSION_LT98 DL_Codes::AC1014 // not supported yet +#define DL_VERSION_2000 DL_Codes::AC1015 +#define DL_VERSION_2002 DL_Codes::AC1015 // DXF Group Codes: // Strings -#define STRGRP_START 0 -#define STRGRP_END 9 +#define DL_STRGRP_START 0 +#define DL_STRGRP_END 9 // Coordinates -#define CRDGRP_START 10 -#define CRDGRP_END 19 +#define DL_CRDGRP_START 10 +#define DL_CRDGRP_END 19 // Real values -#define RLGRP_START 38 -#define RLGRP_END 59 +#define DL_RLGRP_START 38 +#define DL_RLGRP_END 59 // Short integer values -#define SHOGRP_START 60 -#define SHOGRP_END 79 +#define DL_SHOGRP_START 60 +#define DL_SHOGRP_END 79 // New in Release 13, -#define SUBCLASS 100 +#define DL_SUBCLASS 100 // More coordinates -#define CRD2GRP_START 210 -#define CRD2GRP_END 239 +#define DL_CRD2GRP_START 210 +#define DL_CRD2GRP_END 239 // Extended data strings -#define ESTRGRP_START 1000 -#define ESTRGRP_END 1009 +#define DL_ESTRGRP_START 1000 +#define DL_ESTRGRP_END 1009 // Extended data reals -#define ERLGRP_START 1010 -#define ERLGRP_END 1059 +#define DL_ERLGRP_START 1010 +#define DL_ERLGRP_END 1059 -#define Y8_COORD_CODE 28 -#define Z0_COORD_CODE 30 -#define Z8_COORD_CODE 38 +#define DL_Y8_COORD_CODE 28 +#define DL_Z0_COORD_CODE 30 +#define DL_Z8_COORD_CODE 38 -#define POINT_COORD_CODE 10 -#define INSERT_COORD_CODE 10 +#define DL_POINT_COORD_CODE 10 +#define DL_INSERT_COORD_CODE 10 -#define CRD2GRP_START 210 -#define CRD2GRP_END 239 +#define DL_CRD2GRP_START 210 +#define DL_CRD2GRP_END 239 -#define THICKNESS 39 -#define FIRST_REAL_CODE THICKNESS -#define LAST_REAL_CODE 59 -#define FIRST_INT_CODE 60 -#define ATTFLAGS_CODE 70 -#define PLINE_FLAGS_CODE 70 -#define LAYER_FLAGS_CODE 70 -#define FLD_LEN_CODE 73 // Inside ATTRIB resbuf -#define LAST_INT_CODE 79 -#define X_EXTRU_CODE 210 -#define Y_EXTRU_CODE 220 -#define Z_EXTRU_CODE 230 -#define COMMENT_CODE 999 +#define DL_THICKNESS 39 +#define DL_FIRST_REAL_CODE THICKNESS +#define DL_LAST_REAL_CODE 59 +#define DL_FIRST_INT_CODE 60 +#define DL_ATTFLAGS_CODE 70 +#define DL_PLINE_FLAGS_CODE 70 +#define DL_LAYER_FLAGS_CODE 70 +#define DL_FLD_LEN_CODE 73 // Inside ATTRIB resbuf +#define DL_LAST_INT_CODE 79 +#define DL_X_EXTRU_CODE 210 +#define DL_Y_EXTRU_CODE 220 +#define DL_Z_EXTRU_CODE 230 +#define DL_COMMENT_CODE 999 // Start and endpoints of a line -#define LINE_START_CODE 10 // Followed by x coord -#define LINE_END_CODE 11 // Followed by x coord +#define DL_LINE_START_CODE 10 // Followed by x coord +#define DL_LINE_END_CODE 11 // Followed by x coord // Some codes used by blocks -#define BLOCK_FLAGS_CODE 70 // An int containing flags -#define BLOCK_BASE_CODE 10 // Origin of block definition -#define XREF_DEPENDENT 16 // If a block contains an XREF -#define XREF_RESOLVED 32 // If a XREF resolved ok -#define REFERENCED 64 // If a block is ref'd in DWG +#define DL_BLOCK_FLAGS_CODE 70 // An int containing flags +#define DL_BLOCK_BASE_CODE 10 // Origin of block definition +#define DL_XREF_DEPENDENT 16 // If a block contains an XREF +#define DL_XREF_RESOLVED 32 // If a XREF resolved ok +#define DL_REFERENCED 64 // If a block is ref'd in DWG -#define XSCALE_CODE 41 -#define YSCALE_CODE 42 -#define ANGLE_CODE 50 -#define INS_POINT_CODE 10 // Followed by x of ins pnt -#define NAME2_CODE 3 // Second appearance of name +#define DL_XSCALE_CODE 41 +#define DL_YSCALE_CODE 42 +#define DL_ANGLE_CODE 50 +#define DL_INS_POINT_CODE 10 // Followed by x of ins pnt +#define DL_NAME2_CODE 3 // Second appearance of name // Some codes used by circle entities -#define CENTER_CODE 10 // Followed by x of center -#define RADIUS_CODE 40 // Followd by radius of circle +#define DL_CENTER_CODE 10 // Followed by x of center +#define DL_RADIUS_CODE 40 // Followd by radius of circle -#define COND_OP_CODE -4 // Conditional op,ads_ssget +#define DL_COND_OP_CODE -4 // Conditional op,ads_ssget // When using ads_buildlist you MUST use RTDXF0 instead of these -#define ENTITY_TYPE_CODE 0 // Then there is LINE, 3DFACE.. -#define SES_CODE 0 // Start End String Code -#define FILE_SEP_CODE 0 // File separator -#define SOT_CODE 0 // Start Of Table -#define TEXTVAL_CODE 1 -#define NAME_CODE 2 -#define BLOCK_NAME_CODE 2 -#define SECTION_NAME_CODE 2 -#define ENT_HAND_CODE 5 // What follows is hexa string -#define TXT_STYLE_CODE 7 // Inside attributes -#define LAYER_NAME_CODE 8 // What follows is layer name -#define FIRST_XCOORD_CODE 10 // Group code x of 1st coord -#define FIRST_YCOORD_CODE 20 // Group code y of 1st coord -#define FIRST_ZCOORD_CODE 30 // Group code z of 1st coord -#define L_START_CODE 10 -#define L_END_CODE 11 -#define TXTHI_CODE 40 -#define SCALE_X_CODE 41 -#define SCALE_Y_CODE 42 -#define SCALE_Z_CODE 43 -#define BULGE_CODE 42 // Used in PLINE verts for arcs -#define ROTATION_CODE 50 -#define COLOR_CODE 62 // What follows is a color int -#define LTYPE_CODE 6 // What follows is a linetype +#define DL_ENTITY_TYPE_CODE 0 // Then there is LINE, 3DFACE.. +#define DL_SES_CODE 0 // Start End String Code +#define DL_FILE_SEP_CODE 0 // File separator +#define DL_SOT_CODE 0 // Start Of Table +#define DL_TEXTVAL_CODE 1 +#define DL_NAME_CODE 2 +#define DL_BLOCK_NAME_CODE 2 +#define DL_SECTION_NAME_CODE 2 +#define DL_ENT_HAND_CODE 5 // What follows is hexa string +#define DL_TXT_STYLE_CODE 7 // Inside attributes +#define DL_LAYER_NAME_CODE 8 // What follows is layer name +#define DL_FIRST_XCOORD_CODE 10 // Group code x of 1st coord +#define DL_FIRST_YCOORD_CODE 20 // Group code y of 1st coord +#define DL_FIRST_ZCOORD_CODE 30 // Group code z of 1st coord +#define DL_L_START_CODE 10 +#define DL_L_END_CODE 11 +#define DL_TXTHI_CODE 40 +#define DL_SCALE_X_CODE 41 +#define DL_SCALE_Y_CODE 42 +#define DL_SCALE_Z_CODE 43 +#define DL_BULGE_CODE 42 // Used in PLINE verts for arcs +#define DL_ROTATION_CODE 50 +#define DL_COLOUR_CODE 62 // What follows is a color int +#define DL_LTYPE_CODE 6 // What follows is a linetype // Attribute flags -#define ATTS_FOLLOW_CODE 66 -#define ATT_TAG_CODE 2 -#define ATT_VAL_CODE 1 -#define ATT_FLAGS_CODE 70 // 4 1 bit flags as follows... -#define ATT_INVIS_FLAG 1 -#define ATT_CONST_FLAG 2 -#define ATT_VERIFY_FLAG 4 // Prompt and verify -#define ATT_PRESET_FLAG 8 // No prompt and no verify +#define DL_ATTS_FOLLOW_CODE 66 +#define DL_ATT_TAG_CODE 2 +#define DL_ATT_VAL_CODE 1 +#define DL_ATT_FLAGS_CODE 70 // 4 1 bit flags as follows... +#define DL_ATT_INVIS_FLAG 1 +#define DL_ATT_CONST_FLAG 2 +#define DL_ATT_VERIFY_FLAG 4 // Prompt and verify +#define DL_ATT_PRESET_FLAG 8 // No prompt and no verify // PLINE defines // Flags -#define OPEN_PLINE 0x00 -#define CLOSED_PLINE 0x01 -#define POLYLINE3D 0x80 -#define PFACE_MESH 0x40 -#define PGON_MESH 0x10 +#define DL_OPEN_PLINE 0x00 +#define DL_CLOSED_PLINE 0x01 +#define DL_POLYLINE3D 0x80 +#define DL_PFACE_MESH 0x40 +#define DL_PGON_MESH 0x10 // Vertices follow entity, required in POLYLINES -#define VERTS_FOLLOW_CODE 66 // Value should always be 1 -#define VERTEX_COORD_CODE 10 +#define DL_VERTS_FOLLOW_CODE 66 // Value should always be 1 +#define DL_VERTEX_COORD_CODE 10 // LAYER flags -#define FROZEN 1 -#define FROZEN_BY_DEF 2 -#define LOCKED 4 -#define OBJECT_USED 64 // Object is ref'd in the dwg +#define DL_FROZEN 1 +#define DL_FROZEN_BY_DEF 2 +#define DL_LOCKED 4 +#define DL_OBJECT_USED 64 // Object is ref'd in the dwg -#define BLOCK_EN_CODE -2 // Block entity definition -#define E_NAME -1 // Entity name +#define DL_BLOCK_EN_CODE -2 // Block entity definition +#define DL_E_NAME -1 // Entity name // Extended data codes -#define EXTD_SENTINEL (-3) -#define EXTD_STR 1000 -#define EXTD_APP_NAME 1001 -#define EXTD_CTL_STR 1002 -#define EXTD_LYR_STR 1003 -#define EXTD_CHUNK 1004 -#define EXTD_HANDLE 1005 -#define EXTD_POINT 1010 -#define EXTD_POS 1011 -#define EXTD_DISP 1012 -#define EXTD_DIR 1013 -#define EXTD_FLOAT 1040 -#define EXTD_DIST 1041 -#define EXTD_SCALE 1042 -#define EXTD_INT16 1070 -#define EXTD_INT32 1071 +#define DL_EXTD_SENTINEL (-3) +#define DL_EXTD_STR 1000 +#define DL_EXTD_APP_NAME 1001 +#define DL_EXTD_CTL_STR 1002 +#define DL_EXTD_LYR_STR 1003 +#define DL_EXTD_CHUNK 1004 +#define DL_EXTD_HANDLE 1005 +#define DL_EXTD_POINT 1010 +#define DL_EXTD_POS 1011 +#define DL_EXTD_DISP 1012 +#define DL_EXTD_DIR 1013 +#define DL_EXTD_FLOAT 1040 +#define DL_EXTD_DIST 1041 +#define DL_EXTD_SCALE 1042 +#define DL_EXTD_INT16 1070 +#define DL_EXTD_INT32 1071 // UCS codes for use in ads_trans -#define WCS_TRANS_CODE 0 -#define UCS_TRANS_CODE 1 -#define DCS_TRANS_CODE 2 -#define PCS_TRANS_CODE 3 +#define DL_WCS_TRANS_CODE 0 +#define DL_UCS_TRANS_CODE 1 +#define DL_DCS_TRANS_CODE 2 +#define DL_PCS_TRANS_CODE 3 #endif diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_creationadapter.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_creationadapter.h index 10f748af3ec..8694630b49f 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_creationadapter.h +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_creationadapter.h @@ -1,20 +1,14 @@ /**************************************************************************** -** $Id: dl_creationadapter.h 2398 2005-06-06 18:12:14Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -31,73 +25,113 @@ #ifndef DL_CREATIONADAPTER_H #define DL_CREATIONADAPTER_H +#include "dl_global.h" + #include "dl_creationinterface.h" /** - * An abstract adapter class for receiving DXF events when a DXF file is being read. - * The methods in this class are empty. This class exists as convenience for creating + * An abstract adapter class for receiving DXF events when a DXF file is being read. + * The methods in this class are empty. This class exists as convenience for creating * listener objects. * * @author Andrew Mustun */ -class DL_CreationAdapter : public DL_CreationInterface -{ - public: +class DXFLIB_EXPORT DL_CreationAdapter : public DL_CreationInterface { +public: DL_CreationAdapter() {} virtual ~DL_CreationAdapter() {} - virtual void addLayer( const DL_LayerData& ) override {} - virtual void addBlock( const DL_BlockData& ) override {} - virtual void endBlock() override {} - virtual void addPoint( const DL_PointData& ) override {} - virtual void addLine( const DL_LineData& ) override {} - virtual void addArc( const DL_ArcData& ) override {} - virtual void addCircle( const DL_CircleData& ) override {} - virtual void addEllipse( const DL_EllipseData& ) override {} + virtual void processCodeValuePair(unsigned int, const std::string&) {} + virtual void endSection() {} + virtual void addLayer(const DL_LayerData&) {} + virtual void addLinetype(const DL_LinetypeData&) {} + virtual void addLinetypeDash(double) {} + virtual void addBlock(const DL_BlockData&) {} + virtual void endBlock() {} + virtual void addTextStyle(const DL_StyleData&) {} + virtual void addPoint(const DL_PointData&) {} + virtual void addLine(const DL_LineData&) {} + virtual void addXLine(const DL_XLineData&) {} + virtual void addRay(const DL_RayData&) {} - virtual void addPolyline( const DL_PolylineData& ) override {} - virtual void addVertex( const DL_VertexData& ) override {} + virtual void addArc(const DL_ArcData&) {} + virtual void addCircle(const DL_CircleData&) {} + virtual void addEllipse(const DL_EllipseData&) {} + + virtual void addPolyline(const DL_PolylineData&) {} + virtual void addVertex(const DL_VertexData&) {} + + virtual void addSpline(const DL_SplineData&) {} + virtual void addControlPoint(const DL_ControlPointData&) {} + virtual void addFitPoint(const DL_FitPointData&) {} + virtual void addKnot(const DL_KnotData&) {} + + virtual void addInsert(const DL_InsertData&) {} + + virtual void addMText(const DL_MTextData&) {} + virtual void addMTextChunk(const std::string&) {} + virtual void addText(const DL_TextData&) {} + virtual void addAttribute(const DL_AttributeData&) {} + + virtual void addDimAlign(const DL_DimensionData&, + const DL_DimAlignedData&) {} + virtual void addDimLinear(const DL_DimensionData&, + const DL_DimLinearData&) {} + virtual void addDimRadial(const DL_DimensionData&, + const DL_DimRadialData&) {} + virtual void addDimDiametric(const DL_DimensionData&, + const DL_DimDiametricData&) {} + virtual void addDimAngular(const DL_DimensionData&, + const DL_DimAngularData&) {} + virtual void addDimAngular3P(const DL_DimensionData&, + const DL_DimAngular3PData&) {} + virtual void addDimOrdinate(const DL_DimensionData&, + const DL_DimOrdinateData&) {} + virtual void addLeader(const DL_LeaderData&) {} + virtual void addLeaderVertex(const DL_LeaderVertexData&) {} + + virtual void addHatch(const DL_HatchData&) {} - virtual void addSpline( const DL_SplineData& ) override {} - virtual void addControlPoint( const DL_ControlPointData& ) override {} - virtual void addKnot( const DL_KnotData& ) override {} + virtual void addTrace(const DL_TraceData&) {} + virtual void add3dFace(const DL_3dFaceData&) {} + virtual void addSolid(const DL_SolidData&) {} + + virtual void addImage(const DL_ImageData&) {} + virtual void linkImage(const DL_ImageDefData&) {} + virtual void addHatchLoop(const DL_HatchLoopData&) {} + virtual void addHatchEdge(const DL_HatchEdgeData&) {} - virtual void addInsert( const DL_InsertData& ) override {} + virtual void addXRecord(const std::string&) {} + virtual void addXRecordString(int, const std::string&) {} + virtual void addXRecordReal(int, double) {} + virtual void addXRecordInt(int, int) {} + virtual void addXRecordBool(int, bool) {} - virtual void addMText( const DL_MTextData& ) override {} - virtual void addMTextChunk( const char* ) override {} - virtual void addText( const DL_TextData& ) override {} + virtual void addXDataApp(const std::string&) {} + virtual void addXDataString(int, const std::string&) {} + virtual void addXDataReal(int, double) {} + virtual void addXDataInt(int, int) {} - virtual void addDimAlign( const DL_DimensionData&, - const DL_DimAlignedData& ) override {} - virtual void addDimLinear( const DL_DimensionData&, - const DL_DimLinearData& ) override {} - virtual void addDimRadial( const DL_DimensionData&, - const DL_DimRadialData& ) override {} - virtual void addDimDiametric( const DL_DimensionData&, - const DL_DimDiametricData& ) override {} - virtual void addDimAngular( const DL_DimensionData&, - const DL_DimAngularData& ) override {} - virtual void addDimAngular3P( const DL_DimensionData&, - const DL_DimAngular3PData& ) override {} - virtual void addLeader( const DL_LeaderData& ) override {} - virtual void addLeaderVertex( const DL_LeaderVertexData& ) override {} + virtual void addDictionary(const DL_DictionaryData&) {} + virtual void addDictionaryEntry(const DL_DictionaryEntryData&) {} - virtual void addHatch( const DL_HatchData& ) override {} + virtual void endEntity() {} - virtual void addTrace( const DL_TraceData& ) override {} - virtual void addSolid( const DL_SolidData& ) override {} + virtual void addComment(const std::string&) {} - virtual void addImage( const DL_ImageData& ) override {} - virtual void linkImage( const DL_ImageDefData& ) override {} - virtual void addHatchLoop( const DL_HatchLoopData& ) override {} - virtual void addHatchEdge( const DL_HatchEdgeData& ) override {} - virtual void endEntity() override {} - virtual void setVariableVector( const char*, - double, double, double, int ) override {} - virtual void setVariableString( const char*, const char*, int ) override {} - virtual void setVariableInt( const char*, int, int ) override {} - virtual void setVariableDouble( const char*, double, int ) override {} - virtual void endSequence() override {} + virtual void setVariableVector(const std::string&, double, double, double, int) {} + virtual void setVariableString(const std::string&, const std::string&, int) {} + virtual void setVariableInt(const std::string&, int, int) {} + virtual void setVariableDouble(const std::string&, double, int) {} +#ifdef DL_COMPAT + virtual void setVariableVector(const char*, double, double, double, int) {} + virtual void setVariableString(const char*, const char*, int) {} + virtual void setVariableInt(const char*, int, int) {} + virtual void setVariableDouble(const char*, double, int) {} + virtual void processCodeValuePair(unsigned int, char*) {} + virtual void addComment(const char*) {} + virtual void addMTextChunk(const char*) {} +#endif + virtual void endSequence() {} }; #endif diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_creationinterface.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_creationinterface.h index 3e7b162a0ef..a4058f6fe20 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_creationinterface.h +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_creationinterface.h @@ -1,20 +1,14 @@ /**************************************************************************** -** $Id: dl_creationinterface.h 2397 2005-06-06 18:11:14Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -31,6 +25,8 @@ #ifndef DL_CREATIONINTERFACE_H #define DL_CREATIONINTERFACE_H +#include "dl_global.h" + #include #include "dl_attributes.h" @@ -40,30 +36,48 @@ /** * Abstract class (interface) for the creation of new entities. - * Inherit your class which takes care of the entities in the - * processed DXF file from this interface. + * Inherit your class which takes care of the entities in the + * processed DXF file from this interface. * - * Double arrays passed to your implementation contain 3 double + * Double arrays passed to your implementation contain 3 double * values for x, y, z coordinates unless stated differently. * * @author Andrew Mustun */ -class DL_CreationInterface -{ - public: - DL_CreationInterface() - { - extrusion = new DL_Extrusion; +class DXFLIB_EXPORT DL_CreationInterface { +public: + DL_CreationInterface() { + extrusion = new DL_Extrusion; } - virtual ~DL_CreationInterface() - { - delete extrusion; + virtual ~DL_CreationInterface() { + delete extrusion; } + /** + * Called for every code / value tuple of the DXF file. The complete DXF file + * contents can be handled by the implemetation of this function. + */ + virtual void processCodeValuePair(unsigned int groupCode, const std::string& groupValue) = 0; + + /** + * Called when a section (entity, table entry, etc.) is finished. + */ + virtual void endSection() = 0; + /** * Called for every layer. */ - virtual void addLayer( const DL_LayerData& data ) = 0; + virtual void addLayer(const DL_LayerData& data) = 0; + + /** + * Called for every linetype. + */ + virtual void addLinetype(const DL_LinetypeData& data) = 0; + + /** + * Called for every dash in linetype pattern + */ + virtual void addLinetypeDash(double length) = 0; /** * Called for every block. Note: all entities added after this @@ -71,196 +85,282 @@ class DL_CreationInterface * * @see endBlock() */ - virtual void addBlock( const DL_BlockData& data ) = 0; + virtual void addBlock(const DL_BlockData& data) = 0; /** Called to end the current block */ virtual void endBlock() = 0; + /** Called for every text style */ + virtual void addTextStyle(const DL_StyleData& data) = 0; + /** Called for every point */ - virtual void addPoint( const DL_PointData& data ) = 0; + virtual void addPoint(const DL_PointData& data) = 0; /** Called for every line */ - virtual void addLine( const DL_LineData& data ) = 0; + virtual void addLine(const DL_LineData& data) = 0; + + /** Called for every xline */ + virtual void addXLine(const DL_XLineData& data) = 0; + + /** Called for every ray */ + virtual void addRay(const DL_RayData& data) = 0; /** Called for every arc */ - virtual void addArc( const DL_ArcData& data ) = 0; + virtual void addArc(const DL_ArcData& data) = 0; /** Called for every circle */ - virtual void addCircle( const DL_CircleData& data ) = 0; + virtual void addCircle(const DL_CircleData& data) = 0; /** Called for every ellipse */ - virtual void addEllipse( const DL_EllipseData& data ) = 0; + virtual void addEllipse(const DL_EllipseData& data) = 0; /** Called for every polyline start */ - virtual void addPolyline( const DL_PolylineData& data ) = 0; + virtual void addPolyline(const DL_PolylineData& data) = 0; /** Called for every polyline vertex */ - virtual void addVertex( const DL_VertexData& data ) = 0; - + virtual void addVertex(const DL_VertexData& data) = 0; + /** Called for every spline */ - virtual void addSpline( const DL_SplineData& data ) = 0; - + virtual void addSpline(const DL_SplineData& data) = 0; + /** Called for every spline control point */ - virtual void addControlPoint( const DL_ControlPointData& data ) = 0; + virtual void addControlPoint(const DL_ControlPointData& data) = 0; + /** Called for every spline fit point */ + virtual void addFitPoint(const DL_FitPointData& data) = 0; + /** Called for every spline knot value */ - virtual void addKnot( const DL_KnotData& data ) = 0; + virtual void addKnot(const DL_KnotData& data) = 0; /** Called for every insert. */ - virtual void addInsert( const DL_InsertData& data ) = 0; - + virtual void addInsert(const DL_InsertData& data) = 0; + /** Called for every trace start */ - virtual void addTrace( const DL_TraceData& data ) = 0; + virtual void addTrace(const DL_TraceData& data) = 0; + + /** Called for every 3dface start */ + virtual void add3dFace(const DL_3dFaceData& data) = 0; /** Called for every solid start */ - virtual void addSolid( const DL_SolidData& data ) = 0; + virtual void addSolid(const DL_SolidData& data) = 0; /** Called for every Multi Text entity. */ - virtual void addMText( const DL_MTextData& data ) = 0; + virtual void addMText(const DL_MTextData& data) = 0; /** * Called for additional text chunks for MTEXT entities. - * The chunks come at 250 character in size each. Note that + * The chunks come at 250 character in size each. Note that * those chunks come before the actual MTEXT entity. */ - virtual void addMTextChunk( const char* text ) = 0; + virtual void addMTextChunk(const std::string& text) = 0; /** Called for every Text entity. */ - virtual void addText( const DL_TextData& data ) = 0; + virtual void addText(const DL_TextData& data) = 0; + + /** Called for every Block Attribute entity. */ + virtual void addAttribute(const DL_AttributeData& data) = 0; /** - * Called for every aligned dimension entity. + * Called for every aligned dimension entity. */ - virtual void addDimAlign( const DL_DimensionData& data, - const DL_DimAlignedData& edata ) = 0; + virtual void addDimAlign(const DL_DimensionData& data, + const DL_DimAlignedData& edata) = 0; /** - * Called for every linear or rotated dimension entity. + * Called for every linear or rotated dimension entity. */ - virtual void addDimLinear( const DL_DimensionData& data, - const DL_DimLinearData& edata ) = 0; + virtual void addDimLinear(const DL_DimensionData& data, + const DL_DimLinearData& edata) = 0; /** - * Called for every radial dimension entity. - */ - virtual void addDimRadial( const DL_DimensionData& data, - const DL_DimRadialData& edata ) = 0; - - /** - * Called for every diametric dimension entity. - */ - virtual void addDimDiametric( const DL_DimensionData& data, - const DL_DimDiametricData& edata ) = 0; - - /** - * Called for every angular dimension (2 lines version) entity. - */ - virtual void addDimAngular( const DL_DimensionData& data, - const DL_DimAngularData& edata ) = 0; - - /** - * Called for every angular dimension (3 points version) entity. - */ - virtual void addDimAngular3P( const DL_DimensionData& data, - const DL_DimAngular3PData& edata ) = 0; - - /** - * Called for every leader start. - */ - virtual void addLeader( const DL_LeaderData& data ) = 0; - - /** - * Called for every leader vertex + * Called for every radial dimension entity. */ - virtual void addLeaderVertex( const DL_LeaderVertexData& data ) = 0; + virtual void addDimRadial(const DL_DimensionData& data, + const DL_DimRadialData& edata) = 0; /** - * Called for every hatch entity. + * Called for every diametric dimension entity. */ - virtual void addHatch( const DL_HatchData& data ) = 0; + virtual void addDimDiametric(const DL_DimensionData& data, + const DL_DimDiametricData& edata) = 0; /** - * Called for every image entity. + * Called for every angular dimension (2 lines version) entity. */ - virtual void addImage( const DL_ImageData& data ) = 0; + virtual void addDimAngular(const DL_DimensionData& data, + const DL_DimAngularData& edata) = 0; + + /** + * Called for every angular dimension (3 points version) entity. + */ + virtual void addDimAngular3P(const DL_DimensionData& data, + const DL_DimAngular3PData& edata) = 0; + + /** + * Called for every ordinate dimension entity. + */ + virtual void addDimOrdinate(const DL_DimensionData& data, + const DL_DimOrdinateData& edata) = 0; + + /** + * Called for every leader start. + */ + virtual void addLeader(const DL_LeaderData& data) = 0; + + /** + * Called for every leader vertex + */ + virtual void addLeaderVertex(const DL_LeaderVertexData& data) = 0; + + /** + * Called for every hatch entity. + */ + virtual void addHatch(const DL_HatchData& data) = 0; + + /** + * Called for every image entity. + */ + virtual void addImage(const DL_ImageData& data) = 0; /** * Called for every image definition. */ - virtual void linkImage( const DL_ImageDefData& data ) = 0; + virtual void linkImage(const DL_ImageDefData& data) = 0; - /** - * Called for every hatch loop. + /** + * Called for every hatch loop. */ - virtual void addHatchLoop( const DL_HatchLoopData& data ) = 0; + virtual void addHatchLoop(const DL_HatchLoopData& data) = 0; - /** - * Called for every hatch edge entity. + /** + * Called for every hatch edge entity. */ - virtual void addHatchEdge( const DL_HatchEdgeData& data ) = 0; + virtual void addHatchEdge(const DL_HatchEdgeData& data) = 0; /** - * Called after an entity has been completed. + * Called for every XRecord with the given handle. + */ + virtual void addXRecord(const std::string& handle) = 0; + + /** + * Called for XRecords of type string. + */ + virtual void addXRecordString(int code, const std::string& value) = 0; + + /** + * Called for XRecords of type double. + */ + virtual void addXRecordReal(int code, double value) = 0; + + /** + * Called for XRecords of type int. + */ + virtual void addXRecordInt(int code, int value) = 0; + + /** + * Called for XRecords of type bool. + */ + virtual void addXRecordBool(int code, bool value) = 0; + + /** + * Called for every beginning of an XData section of the given application. + */ + virtual void addXDataApp(const std::string& appId) = 0; + + /** + * Called for XData tuples. + */ + virtual void addXDataString(int code, const std::string& value) = 0; + + /** + * Called for XData tuples. + */ + virtual void addXDataReal(int code, double value) = 0; + + /** + * Called for XData tuples. + */ + virtual void addXDataInt(int code, int value) = 0; + + /** + * Called for dictionary objects. + */ + virtual void addDictionary(const DL_DictionaryData& data) = 0; + + /** + * Called for dictionary entries. + */ + virtual void addDictionaryEntry(const DL_DictionaryEntryData& data) = 0; + + /** + * Called after an entity has been completed. */ virtual void endEntity() = 0; + + /** + * Called for every comment in the DXF file (code 999). + */ + virtual void addComment(const std::string& comment) = 0; /** * Called for every vector variable in the DXF file (e.g. "$EXTMIN"). */ - virtual void setVariableVector( const char* key, - double v1, double v2, double v3, int code ) = 0; - + virtual void setVariableVector(const std::string& key, double v1, double v2, double v3, int code) = 0; + /** * Called for every string variable in the DXF file (e.g. "$ACADVER"). */ - virtual void setVariableString( const char* key, const char* value, int code ) = 0; - + virtual void setVariableString(const std::string& key, const std::string& value, int code) = 0; + /** * Called for every int variable in the DXF file (e.g. "$ACADMAINTVER"). */ - virtual void setVariableInt( const char* key, int value, int code ) = 0; - + virtual void setVariableInt(const std::string& key, int value, int code) = 0; + /** * Called for every double variable in the DXF file (e.g. "$DIMEXO"). */ - virtual void setVariableDouble( const char* key, double value, int code ) = 0; + virtual void setVariableDouble(const std::string& key, double value, int code) = 0; - /** - * Called when a SEQEND occurs (when a POLYLINE or ATTRIB is done) - */ +#ifdef DL_COMPAT + virtual void setVariableVector(const char* key, double v1, double v2, double v3, int code) = 0; + virtual void setVariableString(const char* key, const char* value, int code) = 0; + virtual void setVariableInt(const char* key, int value, int code) = 0; + virtual void setVariableDouble(const char* key, double value, int code) = 0; + virtual void processCodeValuePair(unsigned int groupCode, char* groupValue) = 0; + virtual void addComment(const char* comment) = 0; + virtual void addMTextChunk(const char* text) = 0; +#endif + + /** + * Called when a SEQEND occurs (when a POLYLINE or ATTRIB is done) + */ virtual void endSequence() = 0; /** Sets the current attributes for entities. */ - void setAttributes( const DL_Attributes& attrib ) - { - attributes = attrib; + void setAttributes(const DL_Attributes& attrib) { + attributes = attrib; } /** @return the current attributes used for new entities. */ - DL_Attributes getAttributes() - { - return attributes; + DL_Attributes getAttributes() { + return attributes; } /** Sets the current attributes for entities. */ - void setExtrusion( double dx, double dy, double dz, double elevation ) - { - extrusion->setDirection( dx, dy, dz ); - extrusion->setElevation( elevation ); + void setExtrusion(double dx, double dy, double dz, double elevation) { + extrusion->setDirection(dx, dy, dz); + extrusion->setElevation(elevation); } /** @return the current attributes used for new entities. */ - DL_Extrusion* getExtrusion() - { - return extrusion; + DL_Extrusion* getExtrusion() { + return extrusion; } - protected: +protected: DL_Attributes attributes; DL_Extrusion *extrusion; - - DL_CreationInterface(const DL_CreationInterface &); - DL_CreationInterface&operator=(const DL_CreationInterface&); }; #endif diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp b/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp index 33361e57092..152b9d7b5f6 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.cpp @@ -1,20 +1,14 @@ /**************************************************************************** -** $Id: dl_dxf.cpp 2719 2005-09-24 20:41:23Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -38,49 +32,39 @@ #include "dl_attributes.h" #include "dl_codes.h" -#include "dl_creationinterface.h" +#include "dl_creationadapter.h" #include "dl_writer_ascii.h" -#include "qgslogger.h" +#include "iostream" /** * Default constructor. */ -DL_Dxf::DL_Dxf() -{ - styleHandleStd = 0; - version = VER_2000; +DL_Dxf::DL_Dxf() { + version = DL_VERSION_2000; - vertices = NULL; - maxVertices = 0; - vertexIndex = 0; + vertices = NULL; + maxVertices = 0; + vertexIndex = 0; - knots = NULL; - maxKnots = 0; - knotIndex = 0; + knots = NULL; + maxKnots = 0; + knotIndex = 0; - controlPoints = NULL; - maxControlPoints = 0; - controlPointIndex = 0; + weights = NULL; + weightIndex = 0; - leaderVertices = NULL; - maxLeaderVertices = 0; - leaderVertexIndex = 0; + controlPoints = NULL; + maxControlPoints = 0; + controlPointIndex = 0; - hatchLoops = NULL; - maxHatchLoops = 0; - hatchLoopIndex = -1; - hatchEdges = NULL; - maxHatchEdges = NULL; - hatchEdgeIndex = NULL; - dropEdges = false; + fitPoints = NULL; + maxFitPoints = 0; + fitPointIndex = 0; - groupCode = 0; - currentEntity = DL_Unknown; - firstCall = true; - libVersion = 0; - - //bulge = 0.0; + leaderVertices = NULL; + maxLeaderVertices = 0; + leaderVertexIndex = 0; } @@ -88,47 +72,25 @@ DL_Dxf::DL_Dxf() /** * Destructor. */ -DL_Dxf::~DL_Dxf() -{ - if ( vertices != NULL ) - { - delete[] vertices; - } - if ( knots != NULL ) - { - delete[] knots; - } - if ( controlPoints != NULL ) - { - delete[] controlPoints; - } - if ( leaderVertices != NULL ) - { - delete[] leaderVertices; - } - if ( hatchLoops != NULL ) - { - delete[] hatchLoops; - } - if ( hatchEdges != NULL ) - { - for ( int i = 0; i < maxHatchLoops; ++i ) - { - if ( hatchEdges[i] != NULL ) - { - delete[] hatchEdges[i]; - } +DL_Dxf::~DL_Dxf() { + if (vertices!=NULL) { + delete[] vertices; + } + if (knots!=NULL) { + delete[] knots; + } + if (controlPoints!=NULL) { + delete[] controlPoints; + } + if (fitPoints!=NULL) { + delete[] fitPoints; + } + if (weights!=NULL) { + delete[] weights; + } + if (leaderVertices!=NULL) { + delete[] leaderVertices; } - delete[] hatchEdges; - } - if ( maxHatchEdges != NULL ) - { - delete[] maxHatchEdges; - } - if ( hatchEdgeIndex != NULL ) - { - delete[] hatchEdgeIndex; - } } @@ -138,33 +100,26 @@ DL_Dxf::~DL_Dxf() * the given creation interface for every entity found in the file. * * @param file Input - * Path and name of file to read + * Path and name of file to read * @param creationInterface - * Pointer to the class which takes care of the entities in the file. + * Pointer to the class which takes care of the entities in the file. * * @retval true If \p file could be opened. * @retval false If \p file could not be opened. */ -bool DL_Dxf::in( const string& file, DL_CreationInterface* creationInterface ) -{ - FILE *fp; - firstCall = true; - currentEntity = DL_Unknown; - int errorCounter = 0; +bool DL_Dxf::in(const std::string& file, DL_CreationInterface* creationInterface) { + FILE *fp; + firstCall = true; + currentObjectType = DL_UNKNOWN; - fp = fopen( file.c_str(), "rt" ); - if ( fp ) - { - while ( readDxfGroups( fp, creationInterface, &errorCounter ) ) {} - fclose( fp ); - if ( errorCounter > 0 ) - { - QgsDebugMsg( QString( "DXF Filter: There have been %1 errors. The drawing might be incomplete / incorrect." ).arg( errorCounter ) ); + fp = fopen(file.c_str(), "rt"); + if (fp) { + while (readDxfGroups(fp, creationInterface)) {} + fclose(fp); + return true; } - return true; - } - return false; + return false; } @@ -174,32 +129,22 @@ bool DL_Dxf::in( const string& file, DL_CreationInterface* creationInterface ) * * @param stream The string stream. * @param creationInterface - * Pointer to the class which takes care of the entities in the file. + * Pointer to the class which takes care of the entities in the file. * * @retval true If \p file could be opened. * @retval false If \p file could not be opened. */ -#ifndef __GCC2x__ -bool DL_Dxf::in( std::stringstream& stream, - DL_CreationInterface* creationInterface ) -{ - - int errorCounter = 0; - - if ( stream.good() ) - { - firstCall = true; - currentEntity = DL_Unknown; - while ( readDxfGroups( stream, creationInterface, &errorCounter ) ) {} - if ( errorCounter > 0 ) - { - QgsDebugMsg( QString( "DXF Filter: There have been %1 errors. The drawing might be incomplete / incorrect." ).arg( errorCounter ) ); +bool DL_Dxf::in(std::stringstream& stream, + DL_CreationInterface* creationInterface) { + + if (stream.good()) { + firstCall=true; + currentObjectType = DL_UNKNOWN; + while (readDxfGroups(stream, creationInterface)) {} + return true; } - return true; - } - return false; + return false; } -#endif @@ -212,55 +157,35 @@ bool DL_Dxf::in( std::stringstream& stream, * the type of data. The value is on the next line.\n * * This function reads a couplet, determines the type of data, and - * passes the value to the appropriate handler function of + * passes the value to the the appropriate handler function of * \p creationInterface.\n - * + * * \p fp is advanced so that the next call to \p readDXFGroups() reads * the next couplet in the file. * * @param fp Handle of input file * @param creationInterface Handle of class which processes entities - * in the file + * in the file * * @retval true If EOF not reached. * @retval false If EOF reached. */ -bool DL_Dxf::readDxfGroups( FILE *fp, DL_CreationInterface* creationInterface, - int* errorCounter ) -{ +bool DL_Dxf::readDxfGroups(FILE *fp, DL_CreationInterface* creationInterface) { - bool ok = true; - static int line = 1; + static int line = 1; - // Read one group of the DXF file and chop the lines: - if ( DL_Dxf::getChoppedLine( groupCodeTmp, DL_DXF_MAXLINE, fp ) && - DL_Dxf::getChoppedLine( groupValue, DL_DXF_MAXLINE, fp ) ) - { + // Read one group of the DXF file and strip the lines: + if (DL_Dxf::getStrippedLine(groupCodeTmp, DL_DXF_MAXLINE, fp) && + DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, fp) ) { - groupCode = ( unsigned int )stringToInt( groupCodeTmp, &ok ); + groupCode = (unsigned int)toInt(groupCodeTmp); - if ( ok ) - { -// QgsDebugMsg(groupCode); -// QgsDebugMsg(groupValue); - line += 2; - processDXFGroup( creationInterface, groupCode, groupValue ); + creationInterface->processCodeValuePair(groupCode, groupValue); + line+=2; + processDXFGroup(creationInterface, groupCode, groupValue); } - else - { - QgsDebugMsg( QString( "DXF read error: Line: %1" ).arg( line ) ); - if ( errorCounter != NULL ) - { - ( *errorCounter )++; - } - // try to fix: - QgsDebugMsg( "DXF read error: trying to fix.." ); - // drop a line to sync: - DL_Dxf::getChoppedLine( groupCodeTmp, DL_DXF_MAXLINE, fp ); - } - } - return !feof( fp ); + return !feof(fp); } @@ -268,99 +193,69 @@ bool DL_Dxf::readDxfGroups( FILE *fp, DL_CreationInterface* creationInterface, /** * Same as above but for stringstreams. */ -#ifndef __GCC2x__ -bool DL_Dxf::readDxfGroups( std::stringstream& stream, - DL_CreationInterface* creationInterface, - int* errorCounter ) -{ +bool DL_Dxf::readDxfGroups(std::stringstream& stream, + DL_CreationInterface* creationInterface) { - bool ok = true; - static int line = 1; + static int line = 1; - // Read one group of the DXF file and chop the lines: - if ( DL_Dxf::getChoppedLine( groupCodeTmp, DL_DXF_MAXLINE, stream ) && - DL_Dxf::getChoppedLine( groupValue, DL_DXF_MAXLINE, stream ) ) - { + // Read one group of the DXF file and chop the lines: + if (DL_Dxf::getStrippedLine(groupCodeTmp, DL_DXF_MAXLINE, stream) && + DL_Dxf::getStrippedLine(groupValue, DL_DXF_MAXLINE, stream) ) { - groupCode = ( unsigned int )stringToInt( groupCodeTmp, &ok ); + groupCode = (unsigned int)toInt(groupCodeTmp); - if ( ok ) - { -// QgsDebugMsg(groupCode); -// QgsDebugMsg(groupValue); - line += 2; - processDXFGroup( creationInterface, groupCode, groupValue ); + line+=2; + processDXFGroup(creationInterface, groupCode, groupValue); } - else - { - QgsDebugMsg( QString( "DXF read error: Line: %1" ).arg( line ) ); - if ( errorCounter != NULL ) - { - ( *errorCounter )++; - } - // try to fix: - QgsDebugMsg( "DXF read error: trying to fix.." ); - // drop a line to sync: - DL_Dxf::getChoppedLine( groupCodeTmp, DL_DXF_MAXLINE, stream ); - } - } - return !stream.eof(); + return !stream.eof(); } -#endif /** - * @brief Reads line from file & strips whitespace at start and newline + * @brief Reads line from file & strips whitespace at start and newline * at end. * * @param s Output\n - * Pointer to character array that chopped line will be returned in. + * Pointer to character array that chopped line will be returned in. * @param size Size of \p s. (Including space for NULL.) * @param fp Input\n - * Handle of input file. + * Handle of input file. * * @retval true if line could be read * @retval false if \p fp is already at end of file * * @todo Change function to use safer FreeBSD strl* functions * @todo Is it a problem if line is blank (i.e., newline only)? - * Then, when function returns, (s==NULL). + * Then, when function returns, (s==NULL). */ -bool DL_Dxf::getChoppedLine( char *s, unsigned int size, FILE *fp ) -{ - if ( !feof( fp ) ) - { - // The whole line in the file. Includes space for NULL. - char* wholeLine = new char[size]; - // Only the useful part of the line - char* line; +bool DL_Dxf::getStrippedLine(std::string& s, unsigned int size, FILE *fp) { + if (!feof(fp)) { + // The whole line in the file. Includes space for NULL. + char* wholeLine = new char[size]; + // Only the useful part of the line + char* line; - line = fgets( wholeLine, size, fp ); + line = fgets(wholeLine, size, fp); - if ( line != NULL && line[0] != '\0' ) // Evaluates to fgets() retval - { - // line == wholeLine at this point. - // Both guaranteed to be NULL terminated. + if (line!=NULL && line[0] != '\0') { // Evaluates to fgets() retval + // line == wholeLine at this point. + // Both guaranteed to be NULL terminated. - // Strip leading whitespace and trailing CR/LF. - stripWhiteSpace( &line ); + // Strip leading whitespace and trailing CR/LF. + stripWhiteSpace(&line); - strncpy( s, line, size ); - s[size] = '\0'; - // s should always be NULL terminated, because: - assert( size > strlen( line ) ); + s = line; + assert(size > s.length()); + } + + delete[] wholeLine; // Done with wholeLine + + return true; + } else { + s = ""; + return false; } - - delete[] wholeLine; // Done with wholeLine - - return true; - } - else - { - s[0] = '\0'; - return false; - } } @@ -368,26 +263,24 @@ bool DL_Dxf::getChoppedLine( char *s, unsigned int size, FILE *fp ) /** * Same as above but for stringstreams. */ -#ifndef __GCC2x__ -bool DL_Dxf::getChoppedLine( char *s, unsigned int size, - std::stringstream& stream ) -{ +bool DL_Dxf::getStrippedLine(std::string &s, unsigned int size, + std::stringstream& stream) { - if ( !stream.eof() ) - { - // Only the useful part of the line - stream.getline( s, size ); - stripWhiteSpace( &s ); - assert( size > strlen( s ) ); - return true; - } - else - { - s[0] = '\0'; - return false; - } + if (!stream.eof()) { + // Only the useful part of the line + char* line = new char[size+1]; + char* oriLine = line; + stream.getline(line, size); + stripWhiteSpace(&line); + s = line; + assert(size > s.length()); + delete[] oriLine; + return true; + } else { + s[0] = '\0'; + return false; + } } -#endif @@ -396,39 +289,29 @@ bool DL_Dxf::getChoppedLine( char *s, unsigned int size, * and Line Feed (LF) from NULL terminated string. * * @param s Input and output. - * NULL terminates string. + * NULL terminates string. * * @retval true if \p s is non-NULL * @retval false if \p s is NULL */ -bool DL_Dxf::stripWhiteSpace( char** s ) -{ - if ( !s || !( *s ) ) - return false; +bool DL_Dxf::stripWhiteSpace(char** s) { + // last non-NULL char: + int lastChar = strlen(*s) - 1; - // last non-NULL char: - int lastChar = strlen( *s ) - 1; - if ( lastChar < 0 ) - return false; + // Is last character CR or LF? + while ( (lastChar >= 0) && + (((*s)[lastChar] == 10) || ((*s)[lastChar] == 13) || + ((*s)[lastChar] == ' ' || ((*s)[lastChar] == '\t'))) ) { + (*s)[lastChar] = '\0'; + lastChar--; + } -// QgsDebugMsg(QString("lastChar: %1").arg(lastChar)); - - // Is last character CR or LF? - while (( lastChar >= 0 ) && - ((( *s )[lastChar] == 10 ) || (( *s )[lastChar] == 13 ) || - (( *s )[lastChar] == ' ' || (( *s )[lastChar] == '\t' ) ) ) ) - { - ( *s )[lastChar] = '\0'; - lastChar--; - } - - // Skip whitespace, excluding \n, at beginning of line - while (( *s )[0] == ' ' || ( *s )[0] == '\t' ) - { - ++( *s ); - } - - return (( *s ) ? true : false ); + // Skip whitespace, excluding \n, at beginning of line + while ((*s)[0]==' ' || (*s)[0]=='\t') { + ++(*s); + } + + return ((*s) ? true : false); } @@ -445,413 +328,435 @@ bool DL_Dxf::stripWhiteSpace( char** s ) * @retval true if done processing current entity and new entity begun * @retval false if not done processing current entity */ -bool DL_Dxf::processDXFGroup( DL_CreationInterface* creationInterface, - int groupCode, const char *groupValue ) -{ +bool DL_Dxf::processDXFGroup(DL_CreationInterface* creationInterface, + int groupCode, const std::string& groupValue) { + //printf("%d\n", groupCode); + //printf("%s\n", groupValue.c_str()); -// QgsDebugMsg(QString("groupCode=%1 groupValue=%2").arg(groupCode).arg(groupValue)); - - // Init on first call - if ( firstCall ) - { - for ( int i = 0; i < DL_DXF_MAXGROUPCODE; ++i ) - { - values[i][0] = '\0'; - } - settingValue[0] = '\0'; - firstCall = false; - } - - // Indicates comment or dxflib version: - if ( groupCode == 999 ) - { -// QgsDebugMsg(QString("999: %1").arg(groupValue)); - if ( groupValue != NULL ) - { - if ( !strncmp( groupValue, "dxflib", 6 ) ) - { -// QgsDebugMsg("dxflib version found"); - libVersion = getLibVersion( &groupValue[7] ); - } - } - } - - // Indicates start of new entity or var - else if ( groupCode == 0 || groupCode == 9 ) - { - - // If new entity is encountered, the last one must be complete - // prepare attributes which can be used for most entities: - char name[DL_DXF_MAXLINE+1]; - if (( values[8] )[0] != '\0' ) - { - strcpy( name, values[8] ); - } - // defaults to layer '0': - else - { - strcpy( name, "0" ); + // Init values on first call + if (firstCall) { + settingValue[0] = '\0'; + firstCall=false; } - int width; - // Compatibillity with qcad1: - if (( values[39] )[0] != '\0' && - ( values[370] )[0] == '\0' ) - { - width = toInt( values[39], -1 ); - } - // since autocad 2002: - else if (( values[370] )[0] != '\0' ) - { - width = toInt( values[370], -1 ); - } - // default to BYLAYER: - else - { - width = -1; - } - - int color; - color = toInt( values[62], 256 ); - - char linetype[DL_DXF_MAXLINE+1]; - strncpy( linetype, toString( values[6], "BYLAYER" ), DL_DXF_MAXLINE ); - - attrib = DL_Attributes( values[8], // layer - color, // color - width, // width - linetype ); // linetype - creationInterface->setAttributes( attrib ); - - creationInterface->setExtrusion( toReal( values[210], 0.0 ), - toReal( values[220], 0.0 ), - toReal( values[230], 1.0 ), - toReal( values[30], 0.0 ) ); - - // Add the last entity via creationInterface - switch ( currentEntity ) - { - case DL_SETTING: - addSetting( creationInterface ); - break; - - case DL_LAYER: - addLayer( creationInterface ); - break; - - case DL_BLOCK: - addBlock( creationInterface ); - break; - - case DL_ENDBLK: - endBlock( creationInterface ); - break; - - case DL_ENTITY_POINT: - addPoint( creationInterface ); - break; - - case DL_ENTITY_LINE: - addLine( creationInterface ); - break; - - case DL_ENTITY_POLYLINE: - //bulge = toReal(values[42]); - // fall through - case DL_ENTITY_LWPOLYLINE: - addPolyline( creationInterface ); - break; - - case DL_ENTITY_VERTEX: - addVertex( creationInterface ); - break; - - case DL_ENTITY_SPLINE: - addSpline( creationInterface ); - break; - - case DL_ENTITY_ARC: - addArc( creationInterface ); - break; - - case DL_ENTITY_CIRCLE: - addCircle( creationInterface ); - break; - - case DL_ENTITY_ELLIPSE: - addEllipse( creationInterface ); - break; - - case DL_ENTITY_INSERT: - addInsert( creationInterface ); - break; - - case DL_ENTITY_MTEXT: - addMText( creationInterface ); - break; - - case DL_ENTITY_TEXT: - addText( creationInterface ); - break; - - case DL_ENTITY_ATTRIB: - addAttrib( creationInterface ); - break; - - case DL_ENTITY_DIMENSION: - { - int type = ( toInt( values[70], 0 ) & 0x07 ); - - switch ( type ) - { - case 0: - addDimLinear( creationInterface ); - break; - - case 1: - addDimAligned( creationInterface ); - break; - - case 2: - addDimAngular( creationInterface ); - break; - - case 3: - addDimDiametric( creationInterface ); - break; - - case 4: - addDimRadial( creationInterface ); - break; - - case 5: - addDimAngular3P( creationInterface ); - break; - - default: - break; + // Indicates comment or dxflib version: + if (groupCode==999) { + if (!groupValue.empty()) { + if (groupValue.substr(0, 6)=="dxflib") { + libVersion = getLibVersion(groupValue.substr(7)); + } + + addComment(creationInterface, groupValue); } - } - break; - - case DL_ENTITY_LEADER: - addLeader( creationInterface ); - break; - - case DL_ENTITY_HATCH: - addHatch( creationInterface ); - break; - - case DL_ENTITY_IMAGE: - addImage( creationInterface ); - break; - - case DL_ENTITY_IMAGEDEF: - addImageDef( creationInterface ); - break; - - case DL_ENTITY_TRACE: - addTrace( creationInterface ); - break; - - case DL_ENTITY_SOLID: - addSolid( creationInterface ); - break; - - case DL_ENTITY_SEQEND: - endSequence( creationInterface ); - break; - - default: - break; } + // Indicates start of new entity or variable: + else if (groupCode==0 || groupCode==9) { + // If new entity is encountered, the last one is complete. + // Prepare default attributes for next entity: + std::string layer = getStringValue(8, "0"); - // reset all values (they are not persistent and only this - // way we can detect default values for unstored settings) - for ( int i = 0; i < DL_DXF_MAXGROUPCODE; ++i ) - { - values[i][0] = '\0'; - } - settingValue[0] = '\0'; - settingKey[0] = '\0'; + int width; + // Compatibility with qcad1: + if (hasValue(39) && !hasValue(370)) { + width = getIntValue(39, -1); + } + // since autocad 2002: + else if (hasValue(370)) { + width = getIntValue(370, -1); + } + // default to BYLAYER: + else { + width = -1; + } + int color; + color = getIntValue(62, 256); + int color24; + color24 = getIntValue(420, -1); + int handle; + handle = getIntValue(5, -1); - // Last DXF entity or setting has been handled - // Now determine what the next entity or setting type is + std::string linetype = getStringValue(6, "BYLAYER"); - int prevEntity = currentEntity; + attrib = DL_Attributes(layer, // layer + color, // color + color24, // 24 bit color + width, // width + linetype, // linetype + handle); // handle + attrib.setInPaperSpace((bool)getIntValue(67, 0)); + attrib.setLinetypeScale(getRealValue(48, 1.0)); + creationInterface->setAttributes(attrib); - // Read DXF settings: - if ( groupValue[0] == '$' ) - { - currentEntity = DL_SETTING; - strncpy( settingKey, groupValue, DL_DXF_MAXLINE ); - settingKey[DL_DXF_MAXLINE] = '\0'; - } - // Read Layers: - else if ( !strcmp( groupValue, "LAYER" ) ) - { - currentEntity = DL_LAYER; + int elevationGroupCode=30; + if (currentObjectType==DL_ENTITY_LWPOLYLINE ) { + // see lwpolyline group codes reference + elevationGroupCode=38; + } + else { + // see polyline group codes reference + elevationGroupCode=30; + } - } - // Read Blocks: - else if ( !strcmp( groupValue, "BLOCK" ) ) - { - currentEntity = DL_BLOCK; - } - else if ( !strcmp( groupValue, "ENDBLK" ) ) - { - currentEntity = DL_ENDBLK; + creationInterface->setExtrusion(getRealValue(210, 0.0), + getRealValue(220, 0.0), + getRealValue(230, 1.0), + getRealValue(elevationGroupCode, 0.0)); - } - // Read entities: - else if ( !strcmp( groupValue, "POINT" ) ) - { - currentEntity = DL_ENTITY_POINT; - } - else if ( !strcmp( groupValue, "LINE" ) ) - { - currentEntity = DL_ENTITY_LINE; - } - else if ( !strcmp( groupValue, "POLYLINE" ) ) - { - currentEntity = DL_ENTITY_POLYLINE; - } - else if ( !strcmp( groupValue, "LWPOLYLINE" ) ) - { - currentEntity = DL_ENTITY_LWPOLYLINE; - } - else if ( !strcmp( groupValue, "VERTEX" ) ) - { - currentEntity = DL_ENTITY_VERTEX; - } - else if ( !strcmp( groupValue, "SPLINE" ) ) - { - currentEntity = DL_ENTITY_SPLINE; - } - else if ( !strcmp( groupValue, "ARC" ) ) - { - currentEntity = DL_ENTITY_ARC; - } - else if ( !strcmp( groupValue, "ELLIPSE" ) ) - { - currentEntity = DL_ENTITY_ELLIPSE; - } - else if ( !strcmp( groupValue, "CIRCLE" ) ) - { - currentEntity = DL_ENTITY_CIRCLE; - } - else if ( !strcmp( groupValue, "INSERT" ) ) - { - currentEntity = DL_ENTITY_INSERT; - } - else if ( !strcmp( groupValue, "TEXT" ) ) - { - currentEntity = DL_ENTITY_TEXT; - } - else if ( !strcmp( groupValue, "MTEXT" ) ) - { - currentEntity = DL_ENTITY_MTEXT; - } - else if ( !strcmp( groupValue, "ATTRIB" ) ) - { - currentEntity = DL_ENTITY_ATTRIB; - } - else if ( !strcmp( groupValue, "DIMENSION" ) ) - { - currentEntity = DL_ENTITY_DIMENSION; - } - else if ( !strcmp( groupValue, "LEADER" ) ) - { - currentEntity = DL_ENTITY_LEADER; - } - else if ( !strcmp( groupValue, "HATCH" ) ) - { - currentEntity = DL_ENTITY_HATCH; - } - else if ( !strcmp( groupValue, "IMAGE" ) ) - { - currentEntity = DL_ENTITY_IMAGE; - } - else if ( !strcmp( groupValue, "IMAGEDEF" ) ) - { - currentEntity = DL_ENTITY_IMAGEDEF; - } - else if ( !strcmp( groupValue, "TRACE" ) ) - { - currentEntity = DL_ENTITY_TRACE; - } - else if ( !strcmp( groupValue, "SOLID" ) ) - { - currentEntity = DL_ENTITY_SOLID; - } - else if ( !strcmp( groupValue, "SEQEND" ) ) - { - currentEntity = DL_ENTITY_SEQEND; - } - else - { - currentEntity = DL_Unknown; - } + // Add the previously parsed entity via creationInterface + switch (currentObjectType) { + case DL_SETTING: + addSetting(creationInterface); + break; - // end of old style POLYLINE entity - if ( prevEntity == DL_ENTITY_VERTEX && currentEntity != DL_ENTITY_VERTEX ) - { - endEntity( creationInterface ); - } + case DL_LAYER: + addLayer(creationInterface); + break; - return true; + case DL_LINETYPE: + addLinetype(creationInterface); + break; - } - else - { - // Group code does not indicate start of new entity or setting, - // so this group must be continuation of data for the current - // one. - if ( groupCode < DL_DXF_MAXGROUPCODE ) - { + case DL_BLOCK: + addBlock(creationInterface); + break; - bool handled = false; + case DL_ENDBLK: + endBlock(creationInterface); + break; - switch ( currentEntity ) - { - case DL_ENTITY_MTEXT: - handled = handleMTextData( creationInterface ); - break; + case DL_STYLE: + addTextStyle(creationInterface); + break; + case DL_ENTITY_POINT: + addPoint(creationInterface); + break; + + case DL_ENTITY_LINE: + addLine(creationInterface); + break; + + case DL_ENTITY_XLINE: + addXLine(creationInterface); + break; + + case DL_ENTITY_RAY: + addRay(creationInterface); + break; + + case DL_ENTITY_POLYLINE: case DL_ENTITY_LWPOLYLINE: - handled = handleLWPolylineData( creationInterface ); - break; + addPolyline(creationInterface); + break; + + case DL_ENTITY_VERTEX: + addVertex(creationInterface); + break; case DL_ENTITY_SPLINE: - handled = handleSplineData( creationInterface ); - break; + addSpline(creationInterface); + break; + + case DL_ENTITY_ARC: + addArc(creationInterface); + break; + + case DL_ENTITY_CIRCLE: + addCircle(creationInterface); + break; + + case DL_ENTITY_ELLIPSE: + addEllipse(creationInterface); + break; + + case DL_ENTITY_INSERT: + addInsert(creationInterface); + break; + + case DL_ENTITY_MTEXT: + addMText(creationInterface); + break; + + case DL_ENTITY_TEXT: + addText(creationInterface); + break; + + case DL_ENTITY_ATTRIB: + addAttribute(creationInterface); + break; + + case DL_ENTITY_DIMENSION: { + int type = (getIntValue(70, 0)&0x07); + + switch (type) { + case 0: + addDimLinear(creationInterface); + break; + + case 1: + addDimAligned(creationInterface); + break; + + case 2: + addDimAngular(creationInterface); + break; + + case 3: + addDimDiametric(creationInterface); + break; + + case 4: + addDimRadial(creationInterface); + break; + + case 5: + addDimAngular3P(creationInterface); + break; + + case 6: + addDimOrdinate(creationInterface); + break; + + default: + break; + } + } + break; case DL_ENTITY_LEADER: - handled = handleLeaderData( creationInterface ); - break; + addLeader(creationInterface); + break; case DL_ENTITY_HATCH: - handled = handleHatchData( creationInterface ); - break; + //addHatch(creationInterface); + handleHatchData(creationInterface); + break; + + case DL_ENTITY_IMAGE: + addImage(creationInterface); + break; + + case DL_ENTITY_IMAGEDEF: + addImageDef(creationInterface); + break; + + case DL_ENTITY_TRACE: + addTrace(creationInterface); + break; + + case DL_ENTITY_3DFACE: + add3dFace(creationInterface); + break; + + case DL_ENTITY_SOLID: + addSolid(creationInterface); + break; + + case DL_ENTITY_SEQEND: + endSequence(creationInterface); + break; default: - break; - } + break; + } - if ( !handled ) - { - // Normal group / value pair: - strncpy( values[groupCode], groupValue, DL_DXF_MAXLINE ); - values[groupCode][DL_DXF_MAXLINE] = '\0'; - } + creationInterface->endSection(); + + // reset all values (they are not persistent and only this + // way we can set defaults for omitted values) +// for (int i=0; iaddComment(comment); +} + +void DL_Dxf::addDictionary(DL_CreationInterface* creationInterface) { + creationInterface->addDictionary(DL_DictionaryData(getStringValue(5, ""))); +} + +void DL_Dxf::addDictionaryEntry(DL_CreationInterface* creationInterface) { + creationInterface->addDictionaryEntry(DL_DictionaryEntryData(getStringValue(3, ""), getStringValue(350, ""))); } @@ -859,58 +764,50 @@ bool DL_Dxf::processDXFGroup( DL_CreationInterface* creationInterface, /** * Adds a variable from the DXF file. */ -void DL_Dxf::addSetting( DL_CreationInterface* creationInterface ) -{ - int c = -1; - for ( int i = 0; i <= 380; ++i ) - { - if ( values[i][0] != '\0' ) - { - c = i; - break; +void DL_Dxf::addSetting(DL_CreationInterface* creationInterface) { + int c = -1; + std::map::iterator it = values.begin(); + if (it!=values.end()) { + c = it->first; } - } +// for (int i=0; i<=380; ++i) { +// if (values[i][0]!='\0') { +// c = i; +// break; +// } +// } - // string - if ( c >= 0 && c <= 9 ) - { - creationInterface->setVariableString( settingKey, - values[c], c ); - } - // vector - else if ( c >= 10 && c <= 39 ) - { - if ( c == 10 ) - { - creationInterface->setVariableVector( - settingKey, - toReal( values[c] ), - toReal( values[c+10] ), - toReal( values[c+20] ), - c ); + // string + if (c>=0 && c<=9) { + creationInterface->setVariableString(settingKey, values[c], c); + #ifdef DL_COMPAT + // backwards compatibility: + creationInterface->setVariableString(settingKey.c_str(), values[c].c_str(), c); + #endif + } + // vector + else if (c>=10 && c<=39) { + if (c==10) { + creationInterface->setVariableVector( + settingKey, + getRealValue(c, 0.0), + getRealValue(c+10, 0.0), + getRealValue(c+20, 0.0), + c); + } + } + // double + else if (c>=40 && c<=59) { + creationInterface->setVariableDouble(settingKey, getRealValue(c, 0.0), c); + } + // int + else if (c>=60 && c<=99) { + creationInterface->setVariableInt(settingKey, getIntValue(c, 0), c); + } + // misc + else if (c>=0) { + creationInterface->setVariableString(settingKey, getStringValue(c, ""), c); } - } - // double - else if ( c >= 40 && c <= 59 ) - { - creationInterface->setVariableDouble( settingKey, - toReal( values[c] ), - c ); - } - // int - else if ( c >= 60 && c <= 99 ) - { - creationInterface->setVariableInt( settingKey, - toInt( values[c] ), - c ); - } - // misc - else if ( c >= 0 ) - { - creationInterface->setVariableString( settingKey, - values[c], - c ); - } } @@ -918,47 +815,95 @@ void DL_Dxf::addSetting( DL_CreationInterface* creationInterface ) /** * Adds a layer that was read from the file via the creation interface. */ -void DL_Dxf::addLayer( DL_CreationInterface* creationInterface ) -{ - // correct some impossible attributes for layers: - attrib = creationInterface->getAttributes(); - if ( attrib.getColor() == 256 || attrib.getColor() == 0 ) - { - attrib.setColor( 7 ); - } - if ( attrib.getWidth() < 0 ) - { - attrib.setWidth( 1 ); - } - if ( !strcasecmp( attrib.getLineType().c_str(), "BYLAYER" ) || - !strcasecmp( attrib.getLineType().c_str(), "BYBLOCK" ) ) - { - attrib.setLineType( "CONTINUOUS" ); - } +void DL_Dxf::addLayer(DL_CreationInterface* creationInterface) { + // correct some invalid attributes for layers: + attrib = creationInterface->getAttributes(); + if (attrib.getColor()==256 || attrib.getColor()==0) { + attrib.setColor(7); + } + if (attrib.getWidth()<0) { + attrib.setWidth(1); + } - // add layer - creationInterface->addLayer( DL_LayerData( values[2], - toInt( values[70] ) ) ); + std::string linetype = attrib.getLinetype(); + std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper); + if (linetype=="BYLAYER" || linetype=="BYBLOCK") { + attrib.setLinetype("CONTINUOUS"); + } + + // add layer + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } + + creationInterface->addLayer(DL_LayerData(name, getIntValue(70, 0))); } +/** + * Adds a linetype that was read from the file via the creation interface. + */ +void DL_Dxf::addLinetype(DL_CreationInterface* creationInterface) { + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } + int numDashes = getIntValue(73, 0); + //double dashes[numDashes]; + + DL_LinetypeData d( + // name: + name, + // description: + getStringValue(3, ""), + // flags + getIntValue(70, 0), + // number of dashes: + numDashes, + // pattern length: + getRealValue(40, 0.0) + // pattern: + //dashes + ); + + if (name != "By Layer" && name != "By Block" && name != "BYLAYER" && name != "BYBLOCK") { + creationInterface->addLinetype(d); + } +} + +/** + * Handles all dashes in linetype pattern. + */ +bool DL_Dxf::handleLinetypeData(DL_CreationInterface* creationInterface) { + if (groupCode == 49) { + creationInterface->addLinetypeDash(toReal(groupValue)); + return true; + } + + return false; +} /** * Adds a block that was read from the file via the creation interface. */ -void DL_Dxf::addBlock( DL_CreationInterface* creationInterface ) -{ - DL_BlockData d( - // Name: - values[2], - // flags: - toInt( values[70] ), - // base point: - toReal( values[10] ), - toReal( values[20] ), - toReal( values[30] ) ); +void DL_Dxf::addBlock(DL_CreationInterface* creationInterface) { + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } - creationInterface->addBlock( d ); + DL_BlockData d( + // Name: + name, + // flags: + getIntValue(70, 0), + // base point: + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0)); + + creationInterface->addBlock(d); } @@ -966,22 +911,50 @@ void DL_Dxf::addBlock( DL_CreationInterface* creationInterface ) /** * Ends a block that was read from the file via the creation interface. */ -void DL_Dxf::endBlock( DL_CreationInterface* creationInterface ) -{ - creationInterface->endBlock(); +void DL_Dxf::endBlock(DL_CreationInterface* creationInterface) { + creationInterface->endBlock(); } +void DL_Dxf::addTextStyle(DL_CreationInterface* creationInterface) { + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } + + DL_StyleData d( + // name: + name, + // flags + getIntValue(70, 0), + // fixed text heigth: + getRealValue(40, 0.0), + // width factor: + getRealValue(41, 0.0), + // oblique angle: + getRealValue(50, 0.0), + // text generation flags: + getIntValue(71, 0), + // last height used: + getRealValue(42, 0.0), + // primart font file: + getStringValue(3, ""), + // big font file: + getStringValue(4, "") + ); + creationInterface->addTextStyle(d); +} + + /** * Adds a point entity that was read from the file via the creation interface. */ -void DL_Dxf::addPoint( DL_CreationInterface* creationInterface ) -{ - DL_PointData d( toReal( values[10] ), - toReal( values[20] ), - toReal( values[30] ) ); - creationInterface->addPoint( d ); +void DL_Dxf::addPoint(DL_CreationInterface* creationInterface) { + DL_PointData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0)); + creationInterface->addPoint(d); } @@ -989,16 +962,43 @@ void DL_Dxf::addPoint( DL_CreationInterface* creationInterface ) /** * Adds a line entity that was read from the file via the creation interface. */ -void DL_Dxf::addLine( DL_CreationInterface* creationInterface ) -{ - DL_LineData d( toReal( values[10] ), - toReal( values[20] ), - toReal( values[30] ), - toReal( values[11] ), - toReal( values[21] ), - toReal( values[31] ) ); +void DL_Dxf::addLine(DL_CreationInterface* creationInterface) { + DL_LineData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0)); - creationInterface->addLine( d ); + creationInterface->addLine(d); +} + +/** + * Adds an xline entity that was read from the file via the creation interface. + */ +void DL_Dxf::addXLine(DL_CreationInterface* creationInterface) { + DL_XLineData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0)); + + creationInterface->addXLine(d); +} + +/** + * Adds a ray entity that was read from the file via the creation interface. + */ +void DL_Dxf::addRay(DL_CreationInterface* creationInterface) { + DL_RayData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0)); + + creationInterface->addRay(d); } @@ -1006,24 +1006,23 @@ void DL_Dxf::addLine( DL_CreationInterface* creationInterface ) /** * Adds a polyline entity that was read from the file via the creation interface. */ -void DL_Dxf::addPolyline( DL_CreationInterface* creationInterface ) -{ - DL_PolylineData pd( maxVertices, toInt( values[71], 0 ), toInt( values[72], 0 ), toInt( values[70], 0 ) ); - creationInterface->addPolyline( pd ); +void DL_Dxf::addPolyline(DL_CreationInterface* creationInterface) { + DL_PolylineData pd(maxVertices, getIntValue(71, 0), getIntValue(72, 0), getIntValue(70, 0)); + creationInterface->addPolyline(pd); - if ( currentEntity == DL_ENTITY_LWPOLYLINE ) - { - for ( int i = 0; i < maxVertices; i++ ) - { - DL_VertexData d( vertices[i*4], - vertices[i*4+1], - vertices[i*4+2], - vertices[i*4+3] ); + maxVertices = std::min(maxVertices, vertexIndex+1); - creationInterface->addVertex( d ); + if (currentObjectType==DL_ENTITY_LWPOLYLINE) { + for (int i=0; iaddVertex(d); + } + creationInterface->endEntity(); } - creationInterface->endEntity(); - } } @@ -1032,88 +1031,81 @@ void DL_Dxf::addPolyline( DL_CreationInterface* creationInterface ) * Adds a polyline vertex entity that was read from the file * via the creation interface. */ -void DL_Dxf::addVertex( DL_CreationInterface* creationInterface ) -{ - DL_VertexData d( toReal( values[10] ), - toReal( values[20] ), - toReal( values[30] ), - //bulge); - toReal( values[42] ) ); +void DL_Dxf::addVertex(DL_CreationInterface* creationInterface) { - //bulge = toReal(values[42]); + // vertex defines a face of the mesh if its vertex flags group has the + // 128 bit set but not the 64 bit. 10, 20, 30 are irrelevant and set to + // 0 in this case + if ((getIntValue(70, 0)&128) && !(getIntValue(70, 0)&64)) { + return; + } - creationInterface->addVertex( d ); + DL_VertexData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(42, 0.0)); + + creationInterface->addVertex(d); } - /** * Adds a spline entity that was read from the file via the creation interface. */ -void DL_Dxf::addSpline( DL_CreationInterface* creationInterface ) -{ - DL_SplineData sd( toInt( values[71], 3 ), - maxKnots, - maxControlPoints, - toInt( values[70], 4 ) ); - /*DL_SplineData sd(toInt(values[71], 3), toInt(values[72], 0), - toInt(values[73], 0), toInt(values[70], 4));*/ - creationInterface->addSpline( sd ); +void DL_Dxf::addSpline(DL_CreationInterface* creationInterface) { + DL_SplineData sd(getIntValue(71, 3), + maxKnots, + maxControlPoints, + maxFitPoints, + getIntValue(70, 4)); - int i; - for ( i = 0; i < maxControlPoints; i++ ) - { - DL_ControlPointData d( controlPoints[i*3], - controlPoints[i*3+1], - controlPoints[i*3+2] ); + sd.tangentStartX = getRealValue(12, 0.0); + sd.tangentStartY = getRealValue(22, 0.0); + sd.tangentStartZ = getRealValue(32, 0.0); + sd.tangentEndX = getRealValue(13, 0.0); + sd.tangentEndY = getRealValue(23, 0.0); + sd.tangentEndZ = getRealValue(33, 0.0); - creationInterface->addControlPoint( d ); - } - for ( i = 0; i < maxKnots; i++ ) - { - DL_KnotData k( knots[i] ); + creationInterface->addSpline(sd); - creationInterface->addKnot( k ); - } + int i; + for (i=0; iaddControlPoint(d); + } + for (i=0; iaddFitPoint(d); + } + for (i=0; iaddKnot(k); + } + creationInterface->endEntity(); } -#if 0 -/** - * Adds a knot to the previously added spline. - */ -void DL_Dxf::addKnot( DL_CreationInterface* creationInterface ) -{ - QgsDebugMsg( "entered." ); -} -#endif - -#if 0 -/** - * Adds a control point to the previously added spline. - */ -void DL_Dxf::addControlPoint( DL_CreationInterface* creationInterface ) -{ - QgsDebugMsg( "entered." ); -} -#endif - - - /** * Adds an arc entity that was read from the file via the creation interface. */ -void DL_Dxf::addArc( DL_CreationInterface* creationInterface ) -{ - DL_ArcData d( toReal( values[10] ), - toReal( values[20] ), - toReal( values[30] ), - toReal( values[40] ), - toReal( values[50] ), - toReal( values[51] ) ); +void DL_Dxf::addArc(DL_CreationInterface* creationInterface) { + DL_ArcData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(40, 0.0), + getRealValue(50, 0.0), + getRealValue(51, 0.0)); - creationInterface->addArc( d ); + creationInterface->addArc(d); } @@ -1121,14 +1113,13 @@ void DL_Dxf::addArc( DL_CreationInterface* creationInterface ) /** * Adds a circle entity that was read from the file via the creation interface. */ -void DL_Dxf::addCircle( DL_CreationInterface* creationInterface ) -{ - DL_CircleData d( toReal( values[10] ), - toReal( values[20] ), - toReal( values[30] ), - toReal( values[40] ) ); +void DL_Dxf::addCircle(DL_CreationInterface* creationInterface) { + DL_CircleData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(40, 0.0)); - creationInterface->addCircle( d ); + creationInterface->addCircle(d); } @@ -1136,19 +1127,18 @@ void DL_Dxf::addCircle( DL_CreationInterface* creationInterface ) /** * Adds an ellipse entity that was read from the file via the creation interface. */ -void DL_Dxf::addEllipse( DL_CreationInterface* creationInterface ) -{ - DL_EllipseData d( toReal( values[10] ), - toReal( values[20] ), - toReal( values[30] ), - toReal( values[11] ), - toReal( values[21] ), - toReal( values[31] ), - toReal( values[40], 1.0 ), - toReal( values[41], 0.0 ), - toReal( values[42], 2*M_PI ) ); +void DL_Dxf::addEllipse(DL_CreationInterface* creationInterface) { + DL_EllipseData d(getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + getRealValue(40, 1.0), + getRealValue(41, 0.0), + getRealValue(42, 2*M_PI)); - creationInterface->addEllipse( d ); + creationInterface->addEllipse(d); } @@ -1156,149 +1146,264 @@ void DL_Dxf::addEllipse( DL_CreationInterface* creationInterface ) /** * Adds an insert entity that was read from the file via the creation interface. */ -void DL_Dxf::addInsert( DL_CreationInterface* creationInterface ) -{ - DL_InsertData d( values[2], - // insertion point - toReal( values[10], 0.0 ), - toReal( values[20], 0.0 ), - toReal( values[30], 0.0 ), - // scale: - toReal( values[41], 1.0 ), - toReal( values[42], 1.0 ), - toReal( values[43], 1.0 ), - // angle: - toReal( values[50], 0.0 ), - // cols / rows: - toInt( values[70], 1 ), - toInt( values[71], 1 ), - // spacing: - toReal( values[44], 0.0 ), - toReal( values[45], 0.0 ) ); +void DL_Dxf::addInsert(DL_CreationInterface* creationInterface) { + //printf("addInsert\n"); + //printf("code 50: %s\n", values[50]); + //printf("code 50 length: %d\n", strlen(values[50])); + //printf("code 50:\n"); + //getRealValue(50, 0.0); - creationInterface->addInsert( d ); + std::string name = getStringValue(2, ""); + if (name.length()==0) { + return; + } + + DL_InsertData d(name, + // insertion point + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // scale: + getRealValue(41, 1.0), + getRealValue(42, 1.0), + getRealValue(43, 1.0), + // angle (deg): + getRealValue(50, 0.0), + // cols / rows: + getIntValue(70, 1), + getIntValue(71, 1), + // spacing: + getRealValue(44, 0.0), + getRealValue(45, 0.0)); + + creationInterface->addInsert(d); } + /** * Adds a trace entity (4 edge closed polyline) that was read from the file via the creation interface. * * @author AHM */ -void DL_Dxf::addTrace( DL_CreationInterface* creationInterface ) -{ - DL_TraceData td; - - for ( int k = 0; k < 4; k++ ) - { - td.x[k] = toReal( values[10 + k] ); - td.y[k] = toReal( values[20 + k] ); - td.z[k] = toReal( values[30 + k] ); - } - creationInterface->addTrace( td ); +void DL_Dxf::addTrace(DL_CreationInterface* creationInterface) { + DL_TraceData td; + + for (int k = 0; k < 4; k++) { + td.x[k] = getRealValue(10 + k, 0.0); + td.y[k] = getRealValue(20 + k, 0.0); + td.z[k] = getRealValue(30 + k, 0.0); + } + creationInterface->addTrace(td); } + + +/** + * Adds a 3dface entity that was read from the file via the creation interface. + */ +void DL_Dxf::add3dFace(DL_CreationInterface* creationInterface) { + DL_3dFaceData td; + + for (int k = 0; k < 4; k++) { + td.x[k] = getRealValue(10 + k, 0.0); + td.y[k] = getRealValue(20 + k, 0.0); + td.z[k] = getRealValue(30 + k, 0.0); + } + creationInterface->add3dFace(td); +} + + + /** * Adds a solid entity (filled trace) that was read from the file via the creation interface. - * + * * @author AHM */ -void DL_Dxf::addSolid( DL_CreationInterface* creationInterface ) -{ - DL_SolidData sd; - - for ( int k = 0; k < 4; k++ ) - { - sd.x[k] = toReal( values[10 + k] ); - sd.y[k] = toReal( values[20 + k] ); - sd.z[k] = toReal( values[30 + k] ); - } - creationInterface->addSolid( sd ); +void DL_Dxf::addSolid(DL_CreationInterface* creationInterface) { + DL_SolidData sd; + + for (int k = 0; k < 4; k++) { + sd.x[k] = getRealValue(10 + k, 0.0); + sd.y[k] = getRealValue(20 + k, 0.0); + sd.z[k] = getRealValue(30 + k, 0.0); + } + creationInterface->addSolid(sd); } /** * Adds an MText entity that was read from the file via the creation interface. */ -void DL_Dxf::addMText( DL_CreationInterface* creationInterface ) -{ - double angle = 0.0; +void DL_Dxf::addMText(DL_CreationInterface* creationInterface) { + double angle = 0.0; - if ( values[50][0] != '\0' ) - { - if ( libVersion <= 0x02000200 ) - { - // wrong but compatible with dxflib <=2.0.2.0: - angle = toReal( values[50], 0.0 ); - } - else - { - angle = ( toReal( values[50], 0.0 ) * 2 * M_PI ) / 360.0; - } - } - else if ( values[11][0] != '\0' && values[21][0] != '\0' ) - { - double x = toReal( values[11], 0.0 ); - double y = toReal( values[21], 0.0 ); + if (hasValue(50)) { + if (libVersion<=0x02000200) { + // wrong but compatible with dxflib <=2.0.2.0: + angle = getRealValue(50, 0.0); + } else { + angle = (getRealValue(50, 0.0)*2*M_PI)/360.0; + } + } else if (hasValue(11) && hasValue(21)) { + double x = getRealValue(11, 0.0); + double y = getRealValue(21, 0.0); - if ( qAbs( x ) < 1.0e-6 ) - { - if ( y > 0.0 ) - { - angle = M_PI / 2.0; - } - else - { - angle = M_PI / 2.0 * 3.0; - } + if (fabs(x)<1.0e-6) { + if (y>0.0) { + angle = M_PI/2.0; + } else { + angle = M_PI/2.0*3.0; + } + } else { + angle = atan(y/x); + } } - else - { - angle = atan( y / x ); - } - } - DL_MTextData d( - // insertion point - toReal( values[10], 0.0 ), - toReal( values[20], 0.0 ), - toReal( values[30], 0.0 ), - // height - toReal( values[40], 2.5 ), - // width - toReal( values[41], 100.0 ), - // attachment point - toInt( values[71], 1 ), - // drawing direction - toInt( values[72], 1 ), - // line spacing style - toInt( values[73], 1 ), - // line spacing factor - toReal( values[44], 1.0 ), - // text - values[1], - // style - values[7], - // angle - angle ); - creationInterface->addMText( d ); + DL_MTextData d( + // insertion point + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // X direction vector + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + // height + getRealValue(40, 2.5), + // width + getRealValue(41, 0.0), + // attachment point + getIntValue(71, 1), + // drawing direction + getIntValue(72, 1), + // line spacing style + getIntValue(73, 1), + // line spacing factor + getRealValue(44, 1.0), + // text + getStringValue(1, ""), + // style + getStringValue(7, ""), + // angle + angle); + creationInterface->addMText(d); +} + +/** + * Handles all XRecord data. + */ +bool DL_Dxf::handleXRecordData(DL_CreationInterface* creationInterface) { + if (groupCode==105) { + return false; + } + + if (groupCode==5) { + creationInterface->addXRecord(groupValue); + return true; + } + + if (groupCode==280) { + xRecordValues = true; + return true; + } + + if (!xRecordValues) { + return false; + } + + // string: + if (groupCode<=9 || + groupCode==100 || groupCode==102 || groupCode==105 || + (groupCode>=300 && groupCode<=369) || + (groupCode>=1000 && groupCode<=1009)) { + + creationInterface->addXRecordString(groupCode, groupValue); + return true; + } + + // int: + else if ((groupCode>=60 && groupCode<=99) || (groupCode>=160 && groupCode<=179) || (groupCode>=270 && groupCode<=289)) { + creationInterface->addXRecordInt(groupCode, toInt(groupValue)); + return true; + } + + // bool: + else if (groupCode>=290 && groupCode<=299) { + creationInterface->addXRecordBool(groupCode, toBool(groupValue)); + return true; + } + + // double: + else if ((groupCode>=10 && groupCode<=59) || (groupCode>=110 && groupCode<=149) || (groupCode>=210 && groupCode<=239)) { + creationInterface->addXRecordReal(groupCode, toReal(groupValue)); + return true; + } + + return false; +} + +/** + * Handles all dictionary data. + */ +bool DL_Dxf::handleDictionaryData(DL_CreationInterface* creationInterface) { + if (groupCode==3) { + return true; + } + + if (groupCode==5) { + creationInterface->addDictionary(DL_DictionaryData(groupValue)); + return true; + } + + if (groupCode==350) { + creationInterface->addDictionaryEntry(DL_DictionaryEntryData(getStringValue(3, ""), groupValue)); + return true; + } + return false; } +/** + * Handles XData for all object types. + */ +bool DL_Dxf::handleXData(DL_CreationInterface* creationInterface) { + if (groupCode==1001) { + creationInterface->addXDataApp(groupValue); + return true; + } + else if (groupCode>=1000 && groupCode<=1009) { + creationInterface->addXDataString(groupCode, groupValue); + return true; + } + else if (groupCode>=1010 && groupCode<=1059) { + creationInterface->addXDataReal(groupCode, toReal(groupValue)); + return true; + } + else if (groupCode>=1060 && groupCode<=1070) { + creationInterface->addXDataInt(groupCode, toInt(groupValue)); + return true; + } + else if (groupCode==1071) { + creationInterface->addXDataInt(groupCode, toInt(groupValue)); + return true; + } + + return false; +} + /** * Handles additional MText data. */ -bool DL_Dxf::handleMTextData( DL_CreationInterface* creationInterface ) -{ - // Special handling of text chunks for MTEXT entities: - if ( groupCode == 3 ) - { - creationInterface->addMTextChunk( groupValue ); - return true; - } +bool DL_Dxf::handleMTextData(DL_CreationInterface* creationInterface) { + // Special handling of text chunks for MTEXT entities: + if (groupCode==3) { + creationInterface->addMTextChunk(groupValue); + return true; + } - return false; + return false; } @@ -1306,56 +1411,44 @@ bool DL_Dxf::handleMTextData( DL_CreationInterface* creationInterface ) /** * Handles additional polyline data. */ -bool DL_Dxf::handleLWPolylineData( DL_CreationInterface* /*creationInterface*/ ) -{ - // Allocate LWPolyline vertices (group code 90): - if ( groupCode == 90 ) - { - maxVertices = toInt( groupValue ); - if ( maxVertices > 0 ) - { - if ( vertices != NULL ) - { - delete[] vertices; - } - vertices = new double[4*maxVertices]; - for ( int i = 0; i < maxVertices; ++i ) - { - vertices[i*4] = 0.0; - vertices[i*4+1] = 0.0; - vertices[i*4+2] = 0.0; - vertices[i*4+3] = 0.0; - } - } - vertexIndex = -1; - return true; - } - - // Compute LWPolylines vertices (group codes 10/20/30/42): - else if ( groupCode == 10 || groupCode == 20 || - groupCode == 30 || groupCode == 42 ) - { - - if ( vertexIndex < maxVertices - 1 && groupCode == 10 ) - { - vertexIndex++; +bool DL_Dxf::handleLWPolylineData(DL_CreationInterface* /*creationInterface*/) { + // Allocate LWPolyline vertices (group code 90): + if (groupCode==90) { + maxVertices = toInt(groupValue); + if (maxVertices>0) { + if (vertices!=NULL) { + delete[] vertices; + } + vertices = new double[4*maxVertices]; + for (int i=0; i= 0 && vertexIndex < maxVertices ) - { - vertices[4*vertexIndex + ( groupCode/10-1 )] - = toReal( groupValue ); - } + // Process LWPolylines vertices (group codes 10/20/30/42): + else if (groupCode==10 || groupCode==20 || + groupCode==30 || groupCode==42) { + + if (vertexIndex=0 && vertexIndex 0 ) - { - if ( knots != NULL ) - { - delete[] knots; - } - knots = new double[maxKnots]; - for ( int i = 0; i < maxKnots; ++i ) - { - knots[i] = 0.0; - } - } - knotIndex = -1; - return true; - } - - // Allocate Spline control points (group code 73): - else if ( groupCode == 73 ) - { - maxControlPoints = toInt( groupValue ); - if ( maxControlPoints > 0 ) - { - if ( controlPoints != NULL ) - { - delete[] controlPoints; - } - controlPoints = new double[3*maxControlPoints]; - for ( int i = 0; i < maxControlPoints; ++i ) - { - controlPoints[i*3] = 0.0; - controlPoints[i*3+1] = 0.0; - controlPoints[i*3+2] = 0.0; - } - } - controlPointIndex = -1; - return true; - } - - // Compute spline knot vertices (group code 40): - else if ( groupCode == 40 ) - { - if ( knotIndex < maxKnots - 1 ) - { - knotIndex++; - knots[knotIndex] = toReal( groupValue ); - } - return true; - } - - // Compute spline control points (group codes 10/20/30): - else if ( groupCode == 10 || groupCode == 20 || - groupCode == 30 ) - { - - if ( controlPointIndex < maxControlPoints - 1 && groupCode == 10 ) - { - controlPointIndex++; +bool DL_Dxf::handleSplineData(DL_CreationInterface* /*creationInterface*/) { + // Allocate Spline knots (group code 72): + if (groupCode==72) { + maxKnots = toInt(groupValue); + if (maxKnots>0) { + if (knots!=NULL) { + delete[] knots; + } + knots = new double[maxKnots]; + for (int i=0; i= 0 && controlPointIndex < maxControlPoints ) - { - controlPoints[3*controlPointIndex + ( groupCode/10-1 )] - = toReal( groupValue ); + // Allocate Spline control points / weights (group code 73): + else if (groupCode==73) { + maxControlPoints = toInt(groupValue); + if (maxControlPoints>0) { + if (controlPoints!=NULL) { + delete[] controlPoints; + } + if (weights!=NULL) { + delete[] weights; + } + controlPoints = new double[3*maxControlPoints]; + weights = new double[maxControlPoints]; + for (int i=0; i0) { + if (fitPoints!=NULL) { + delete[] fitPoints; + } + fitPoints = new double[3*maxFitPoints]; + for (int i=0; i=0 && controlPointIndex=0 && fitPointIndex=0 && weightIndex 0 ) - { - if ( leaderVertices != NULL ) - { - delete[] leaderVertices; - } - leaderVertices = new double[3*maxLeaderVertices]; - for ( int i = 0; i < maxLeaderVertices; ++i ) - { - leaderVertices[i*3] = 0.0; - leaderVertices[i*3+1] = 0.0; - leaderVertices[i*3+2] = 0.0; - } - } - leaderVertexIndex = -1; - return true; - } - - // Compute Leader vertices (group codes 10/20/30): - else if ( groupCode == 10 || groupCode == 20 || groupCode == 30 ) - { - - if ( leaderVertexIndex < maxLeaderVertices - 1 && groupCode == 10 ) - { - leaderVertexIndex++; - } - - if ( groupCode <= 30 ) - { - if ( leaderVertexIndex >= 0 && - leaderVertexIndex < maxLeaderVertices ) - { - leaderVertices[3*leaderVertexIndex + ( groupCode/10-1 )] - = toReal( groupValue ); - } - } - return true; - } - - return false; -} - - - -/** - * Handles additional hatch data. - */ -bool DL_Dxf::handleHatchData( DL_CreationInterface* /*creationInterface*/ ) -{ - // Allocate hatch loops (group code 91): - if ( groupCode == 91 && toInt( groupValue ) > 0 ) - { - -// QgsDebugMsg(QString("allocating %1 loops").arg(toInt(groupValue))); - - if ( hatchLoops != NULL ) - { - delete[] hatchLoops; - hatchLoops = NULL; - } - if ( maxHatchEdges != NULL ) - { - delete[] maxHatchEdges; - maxHatchEdges = NULL; - } - if ( hatchEdgeIndex != NULL ) - { - delete[] hatchEdgeIndex; - hatchEdgeIndex = NULL; - } - if ( hatchEdges != NULL ) - { - for ( int i = 0; i < maxHatchLoops; ++i ) - { - delete[] hatchEdges[i]; - } - delete[] hatchEdges; - hatchEdges = NULL; - } - maxHatchLoops = toInt( groupValue ); - -// QgsDebugMsg(QString("maxHatchLoops: %1").arg(maxHatchLoops)); - - if ( maxHatchLoops > 0 ) - { - hatchLoops = new DL_HatchLoopData[maxHatchLoops]; - maxHatchEdges = new int[maxHatchLoops]; - hatchEdgeIndex = new int[maxHatchLoops]; - hatchEdges = new DL_HatchEdgeData*[maxHatchLoops]; -// QgsDebugMsg(QString("new hatchEdges[%1]").arg(maxHatchLoops)); - for ( int i = 0; i < maxHatchLoops; ++i ) - { - hatchEdges[i] = NULL; -// QgsDebugMsg(QString("hatchEdges[%1] = NULL").arg(i)); - maxHatchEdges[i] = 0; - } - hatchLoopIndex = -1; - dropEdges = false; - } -// QgsDebugMsg("done"); - return true; - } - - // Allocate hatch edges, group code 93 - if ( groupCode == 93 && toInt( groupValue ) > 0 ) - { - if ( hatchLoopIndex < maxHatchLoops - 1 && hatchLoops != NULL && - maxHatchEdges != NULL && hatchEdgeIndex != NULL && - hatchEdges != NULL ) - { - -// QgsDebugMsg(QString(" allocating %1 edges").arg(toInt(groupValue))); - dropEdges = false; - - hatchLoopIndex++; - hatchLoops[hatchLoopIndex] = DL_HatchLoopData( toInt( groupValue ) ); - - maxHatchEdges[hatchLoopIndex] = toInt( groupValue ); - hatchEdgeIndex[hatchLoopIndex] = -1; - hatchEdges[hatchLoopIndex] = new DL_HatchEdgeData[toInt( groupValue )]; - -// QgsDebugMsg(QString("hatchEdges[%1] = new %2").arg(hatchLoopIndex).arg(toInt(groupValue))); - } - else - { -// QgsDebugMsg(QString("dropping %1 edges").arg(toInt(groupValue))); - dropEdges = true; - } -// QgsDebugMsg("done"); - return true; - } - - // Init hatch edge for non-polyline boundary (group code 72) - if ( hatchEdges != NULL && - hatchEdgeIndex != NULL && - maxHatchEdges != NULL && - hatchLoopIndex >= 0 && - hatchLoopIndex < maxHatchLoops && - hatchEdgeIndex[hatchLoopIndex] < - maxHatchEdges[hatchLoopIndex] && - ( atoi( values[92] )&2 ) == 0 && // not a polyline - groupCode == 72 && - !dropEdges ) - { - -// QgsDebugMsg("Init hatch edge for non-polyline boundary"); -// QgsDebugMsg(QString("hatchLoopIndex: %1").arg(hatchLoopIndex)); -// QgsDebugMsg(QString("maxHatchLoops: %1").arg(maxHatchLoops)); - - hatchEdgeIndex[hatchLoopIndex]++; - -// QgsDebugMsg(QString(" init edge: type: %1 index: %2").arg(toInt(groupValue)).arg(hatchEdgeIndex[hatchLoopIndex])); - - hatchEdges[hatchLoopIndex][hatchEdgeIndex[hatchLoopIndex]] - .type = toInt( groupValue ); - hatchEdges[hatchLoopIndex][hatchEdgeIndex[hatchLoopIndex]] - .defined = false; - -// QgsDebugMsg("done"); - return true; - } - - // Handle hatch edges for non-polyline boundaries - // (group codes 10, 20, 11, 21, 40, 50, 51, 73) - if ( !dropEdges && - hatchEdges != NULL && - hatchEdgeIndex != NULL && - hatchLoopIndex >= 0 && - maxHatchEdges != NULL && - hatchLoopIndex < maxHatchLoops && - hatchEdges[hatchLoopIndex] != NULL && - hatchEdgeIndex[hatchLoopIndex] >= 0 && - hatchEdgeIndex[hatchLoopIndex] < - maxHatchEdges[hatchLoopIndex] && - (( atoi( values[92] )&2 ) == 0 ) && // not a polyline - ( groupCode == 10 || groupCode == 20 || - groupCode == 11 || groupCode == 21 || - groupCode == 40 || groupCode == 50 || - groupCode == 51 || groupCode == 73 ) ) - { - -// QgsDebugMsg("Handle hatch edge for non-polyline boundary"); -// QgsDebugMsg(QString(" found edge data: %1").arg(groupCode)); -// QgsDebugMsg(QString(" value: %1").arg(toReal(groupValue))); - - // can crash: -// QgsDebugMsg(QString(" defined: %1").arg((int)hatchEdges[hatchLoopIndex][hatchEdgeIndex[hatchLoopIndex]].defined)); - -// QgsDebugMsg(QString("92 flag: '%1'").arg(values[92])); -// QgsDebugMsg(QString("92 flag (int): '%1'").arg(atoi(values[92]))); - - if ( !hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].defined ) - { - if ( hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].type == 1 ) - { - switch ( groupCode ) - { - case 10: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].x1 - = toReal( groupValue ); - break; - case 20: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].y1 - = toReal( groupValue ); - break; - case 11: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].x2 - = toReal( groupValue ); - break; - case 21: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].y2 - = toReal( groupValue ); - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].defined = true; - break; - default: - break; - } - } - - if ( hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].type == 2 ) - { - switch ( groupCode ) - { - case 10: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].cx - = toReal( groupValue ); - break; - case 20: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].cy - = toReal( groupValue ); - break; - case 40: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].radius - = toReal( groupValue ); - break; - case 50: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].angle1 - = toReal( groupValue ) / 360.0 * 2 * M_PI; - break; - case 51: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].angle2 - = toReal( groupValue ) / 360.0 * 2 * M_PI; - break; - case 73: - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].ccw - = ( bool )toInt( groupValue ); - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].defined = true; - break; - default: - break; - } - } - } - return true; - } - -#if 0 - // 2003/12/31: polyline hatches can be extremely slow and are rarely used - // - // Handle hatch edges for polyline boundaries - // (group codes 10, 20, 42) - if ( !dropEdges && - hatchEdges != NULL && - hatchEdgeIndex != NULL && - hatchLoopIndex >= 0 && - hatchLoopIndex < maxHatchLoops && - hatchEdges[hatchLoopIndex] != NULL && - //hatchEdgeIndex[hatchLoopIndex]>=0 && - hatchEdgeIndex[hatchLoopIndex] < - maxHatchEdges[hatchLoopIndex] && - (( atoi( values[92] )&2 ) == 2 ) ) // a polyline - { - - if ( groupCode == 10 || groupCode == 20 || - groupCode == 42 ) - { - - QgsDebugMsg( QString( " found polyline edge data: %1" ).arg( groupCode ) ); - QgsDebugMsg( QString( " value: %1" ).arg( toReal( groupValue ) ) ); - - static double lastX = 0.0; - static double lastY = 0.0; - static double lastB = 0.0; - - if ( firstPolylineStatus < 2 ) - { - switch ( groupCode ) - { - case 10: - firstPolylineStatus++; - if ( firstPolylineStatus == 1 ) - { - lastX = toReal( groupValue ); - QgsDebugMsg( QString( " firstX: %1" ).arg( lastX ) ); +bool DL_Dxf::handleLeaderData(DL_CreationInterface* /*creationInterface*/) { + // Allocate Leader vertices (group code 76): + if (groupCode==76) { + maxLeaderVertices = toInt(groupValue); + if (maxLeaderVertices>0) { + if (leaderVertices!=NULL) { + delete[] leaderVertices; + } + leaderVertices = new double[3*maxLeaderVertices]; + for (int i=0; i 0.0 ) - { - angle += M_PI / 2.0; - } - else - { - angle -= M_PI / 2.0; - } - - if ( qAbs( alpha ) > M_PI ) - { - h *= -1.0; - } - - cx = mx + cos( angle ) * h; - cy = my + sin( angle ) * h; - - a1 = hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].type = 2; - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].ccw = ( toReal( groupValue ) > 0.0 ); - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].cx = cx; - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].cy = cy; - hatchEdges[hatchLoopIndex] - [hatchEdgeIndex[hatchLoopIndex]].radius = radius; - } - break; - * / - - default: - break; - } - } - else - { - // end polyline boundary - dropEdges = true; + leaderVertexIndex=-1; + return true; } - return true; - } -#endif + // Process Leader vertices (group codes 10/20/30): + else if (groupCode==10 || groupCode==20 || groupCode==30) { - return false; + if (leaderVertexIndex=0 && + leaderVertexIndexaddText( d ); + creationInterface->addText(d); } @@ -1928,35 +1651,36 @@ void DL_Dxf::addText( DL_CreationInterface* creationInterface ) * Adds an attrib entity that was read from the file via the creation interface. * @todo add attrib instead of normal text */ -void DL_Dxf::addAttrib( DL_CreationInterface* creationInterface ) -{ - DL_TextData d( - // insertion point - toReal( values[10], 0.0 ), - toReal( values[20], 0.0 ), - toReal( values[30], 0.0 ), - // alignment point - toReal( values[11], 0.0 ), - toReal( values[21], 0.0 ), - toReal( values[31], 0.0 ), - // height - toReal( values[40], 2.5 ), - // x scale - toReal( values[41], 1.0 ), - // generation flags - toInt( values[71], 0 ), - // h just - toInt( values[72], 0 ), - // v just - toInt( values[74], 0 ), - // text - values[1], - // style - values[7], - // angle - ( toReal( values[50], 0.0 )*2*M_PI ) / 360.0 ); +void DL_Dxf::addAttribute(DL_CreationInterface* creationInterface) { + DL_AttributeData d( + // insertion point + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // alignment point + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + // height + getRealValue(40, 2.5), + // x scale + getRealValue(41, 1.0), + // generation flags + getIntValue(71, 0), + // h just + getIntValue(72, 0), + // v just + getIntValue(74, 0), + // tag + getStringValue(2, ""), + // text + getStringValue(1, ""), + // style + getStringValue(7, ""), + // angle + (getRealValue(50, 0.0)*2*M_PI)/360.0); - creationInterface->addText( d ); + creationInterface->addAttribute(d); } @@ -1964,32 +1688,31 @@ void DL_Dxf::addAttrib( DL_CreationInterface* creationInterface ) /** * @return dimension data from current values. */ -DL_DimensionData DL_Dxf::getDimData() -{ - // generic dimension data: - return DL_DimensionData( - // def point - toReal( values[10], 0.0 ), - toReal( values[20], 0.0 ), - toReal( values[30], 0.0 ), - // text middle point - toReal( values[11], 0.0 ), - toReal( values[21], 0.0 ), - toReal( values[31], 0.0 ), - // type - toInt( values[70], 0 ), - // attachment point - toInt( values[71], 5 ), - // line sp. style - toInt( values[72], 1 ), - // line sp. factor - toReal( values[41], 1.0 ), - // text - values[1], - // style - values[3], - // angle - toReal( values[53], 0.0 ) ); +DL_DimensionData DL_Dxf::getDimData() { + // generic dimension data: + return DL_DimensionData( + // def point + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // text middle point + getRealValue(11, 0.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + // type + getIntValue(70, 0), + // attachment point + getIntValue(71, 5), + // line sp. style + getIntValue(72, 1), + // line sp. factor + getRealValue(41, 1.0), + // text + getStringValue(1, ""), + // style + getStringValue(3, ""), + // angle + getRealValue(53, 0.0)); } @@ -1997,25 +1720,24 @@ DL_DimensionData DL_Dxf::getDimData() /** * Adds a linear dimension entity that was read from the file via the creation interface. */ -void DL_Dxf::addDimLinear( DL_CreationInterface* creationInterface ) -{ - DL_DimensionData d = getDimData(); +void DL_Dxf::addDimLinear(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); - // horizontal / vertical / rotated dimension: - DL_DimLinearData dl( - // definition point 1 - toReal( values[13], 0.0 ), - toReal( values[23], 0.0 ), - toReal( values[33], 0.0 ), - // definition point 2 - toReal( values[14], 0.0 ), - toReal( values[24], 0.0 ), - toReal( values[34], 0.0 ), - // angle - toReal( values[50], 0.0 ), - // oblique - toReal( values[52], 0.0 ) ); - creationInterface->addDimLinear( d, dl ); + // horizontal / vertical / rotated dimension: + DL_DimLinearData dl( + // definition point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // definition point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0), + // angle + getRealValue(50, 0.0), + // oblique + getRealValue(52, 0.0)); + creationInterface->addDimLinear(d, dl); } @@ -2023,21 +1745,20 @@ void DL_Dxf::addDimLinear( DL_CreationInterface* creationInterface ) /** * Adds an aligned dimension entity that was read from the file via the creation interface. */ -void DL_Dxf::addDimAligned( DL_CreationInterface* creationInterface ) -{ - DL_DimensionData d = getDimData(); +void DL_Dxf::addDimAligned(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); - // aligned dimension: - DL_DimAlignedData da( - // extension point 1 - toReal( values[13], 0.0 ), - toReal( values[23], 0.0 ), - toReal( values[33], 0.0 ), - // extension point 2 - toReal( values[14], 0.0 ), - toReal( values[24], 0.0 ), - toReal( values[34], 0.0 ) ); - creationInterface->addDimAlign( d, da ); + // aligned dimension: + DL_DimAlignedData da( + // extension point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // extension point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0)); + creationInterface->addDimAlign(d, da); } @@ -2045,18 +1766,17 @@ void DL_Dxf::addDimAligned( DL_CreationInterface* creationInterface ) /** * Adds a radial dimension entity that was read from the file via the creation interface. */ -void DL_Dxf::addDimRadial( DL_CreationInterface* creationInterface ) -{ - DL_DimensionData d = getDimData(); +void DL_Dxf::addDimRadial(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); - DL_DimRadialData dr( - // definition point - toReal( values[15], 0.0 ), - toReal( values[25], 0.0 ), - toReal( values[35], 0.0 ), - // leader length: - toReal( values[40], 0.0 ) ); - creationInterface->addDimRadial( d, dr ); + DL_DimRadialData dr( + // definition point + getRealValue(15, 0.0), + getRealValue(25, 0.0), + getRealValue(35, 0.0), + // leader length: + getRealValue(40, 0.0)); + creationInterface->addDimRadial(d, dr); } @@ -2064,19 +1784,18 @@ void DL_Dxf::addDimRadial( DL_CreationInterface* creationInterface ) /** * Adds a diametric dimension entity that was read from the file via the creation interface. */ -void DL_Dxf::addDimDiametric( DL_CreationInterface* creationInterface ) -{ - DL_DimensionData d = getDimData(); +void DL_Dxf::addDimDiametric(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); - // diametric dimension: - DL_DimDiametricData dr( - // definition point - toReal( values[15], 0.0 ), - toReal( values[25], 0.0 ), - toReal( values[35], 0.0 ), - // leader length: - toReal( values[40], 0.0 ) ); - creationInterface->addDimDiametric( d, dr ); + // diametric dimension: + DL_DimDiametricData dr( + // definition point + getRealValue(15, 0.0), + getRealValue(25, 0.0), + getRealValue(35, 0.0), + // leader length: + getRealValue(40, 0.0)); + creationInterface->addDimDiametric(d, dr); } @@ -2084,54 +1803,75 @@ void DL_Dxf::addDimDiametric( DL_CreationInterface* creationInterface ) /** * Adds an angular dimension entity that was read from the file via the creation interface. */ -void DL_Dxf::addDimAngular( DL_CreationInterface* creationInterface ) -{ - DL_DimensionData d = getDimData(); +void DL_Dxf::addDimAngular(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); - // angular dimension: - DL_DimAngularData da( - // definition point 1 - toReal( values[13], 0.0 ), - toReal( values[23], 0.0 ), - toReal( values[33], 0.0 ), - // definition point 2 - toReal( values[14], 0.0 ), - toReal( values[24], 0.0 ), - toReal( values[34], 0.0 ), - // definition point 3 - toReal( values[15], 0.0 ), - toReal( values[25], 0.0 ), - toReal( values[35], 0.0 ), - // definition point 4 - toReal( values[16], 0.0 ), - toReal( values[26], 0.0 ), - toReal( values[36], 0.0 ) ); - creationInterface->addDimAngular( d, da ); + // angular dimension: + DL_DimAngularData da( + // definition point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // definition point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0), + // definition point 3 + getRealValue(15, 0.0), + getRealValue(25, 0.0), + getRealValue(35, 0.0), + // definition point 4 + getRealValue(16, 0.0), + getRealValue(26, 0.0), + getRealValue(36, 0.0)); + creationInterface->addDimAngular(d, da); } /** * Adds an angular dimension entity that was read from the file via the creation interface. */ -void DL_Dxf::addDimAngular3P( DL_CreationInterface* creationInterface ) -{ - DL_DimensionData d = getDimData(); +void DL_Dxf::addDimAngular3P(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); - // angular dimension (3P): - DL_DimAngular3PData da( - // definition point 1 - toReal( values[13], 0.0 ), - toReal( values[23], 0.0 ), - toReal( values[33], 0.0 ), - // definition point 2 - toReal( values[14], 0.0 ), - toReal( values[24], 0.0 ), - toReal( values[34], 0.0 ), - // definition point 3 - toReal( values[15], 0.0 ), - toReal( values[25], 0.0 ), - toReal( values[35], 0.0 ) ); - creationInterface->addDimAngular3P( d, da ); + // angular dimension (3P): + DL_DimAngular3PData da( + // definition point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // definition point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0), + // definition point 3 + getRealValue(15, 0.0), + getRealValue(25, 0.0), + getRealValue(35, 0.0)); + creationInterface->addDimAngular3P(d, da); +} + + + +/** + * Adds an ordinate dimension entity that was read from the file via the creation interface. + */ +void DL_Dxf::addDimOrdinate(DL_CreationInterface* creationInterface) { + DL_DimensionData d = getDimData(); + + // ordinate dimension: + DL_DimOrdinateData dl( + // definition point 1 + getRealValue(13, 0.0), + getRealValue(23, 0.0), + getRealValue(33, 0.0), + // definition point 2 + getRealValue(14, 0.0), + getRealValue(24, 0.0), + getRealValue(34, 0.0), + (getIntValue(70, 0)&64)==64 // true: X-type, false: Y-type + ); + creationInterface->addDimOrdinate(d, dl); } @@ -2139,98 +1879,314 @@ void DL_Dxf::addDimAngular3P( DL_CreationInterface* creationInterface ) /** * Adds a leader entity that was read from the file via the creation interface. */ -void DL_Dxf::addLeader( DL_CreationInterface* creationInterface ) -{ - // leader (arrow) - DL_LeaderData le( - // arrow head flag - toInt( values[71], 1 ), - // leader path type - toInt( values[72], 0 ), - // Leader creation flag - toInt( values[73], 3 ), - // Hookline direction flag - toInt( values[74], 1 ), - // Hookline flag - toInt( values[75], 0 ), - // Text annotation height - toReal( values[40], 1.0 ), - // Text annotation width - toReal( values[41], 1.0 ), - // Number of vertices in leader - toInt( values[76], 0 ) - ); - creationInterface->addLeader( le ); +void DL_Dxf::addLeader(DL_CreationInterface* creationInterface) { + // leader (arrow) + DL_LeaderData le( + // arrow head flag + getIntValue(71, 1), + // leader path type + getIntValue(72, 0), + // Leader creation flag + getIntValue(73, 3), + // Hookline direction flag + getIntValue(74, 1), + // Hookline flag + getIntValue(75, 0), + // Text annotation height + getRealValue(40, 1.0), + // Text annotation width + getRealValue(41, 1.0), + // Number of vertices in leader + getIntValue(76, 0) + ); + creationInterface->addLeader(le); - for ( int i = 0; i < maxLeaderVertices; i++ ) - { - DL_LeaderVertexData d( leaderVertices[i*3], - leaderVertices[i*3+1], - leaderVertices[i*3+2] ); + for (int i=0; iaddLeaderVertex( d ); - } + creationInterface->addLeaderVertex(d); + } + creationInterface->endEntity(); } - - /** * Adds a hatch entity that was read from the file via the creation interface. */ -void DL_Dxf::addHatch( DL_CreationInterface* creationInterface ) -{ - DL_HatchData hd( toInt( values[91], 1 ), - toInt( values[70], 0 ), - toReal( values[41], 1.0 ), - toReal( values[52], 0.0 ), - values[2] ); - creationInterface->addHatch( hd ); +void DL_Dxf::addHatch(DL_CreationInterface* creationInterface) { + DL_HatchData hd(getIntValue(91, 1), + getIntValue(70, 0), + getRealValue(41, 1.0), + getRealValue(52, 0.0), + getStringValue(2, "")); - for ( int l = 0; l < maxHatchLoops; l++ ) - { - DL_HatchLoopData ld( maxHatchEdges[l] ); - creationInterface->addHatchLoop( ld ); - for ( int b = 0; b < maxHatchEdges[l]; b++ ) - { - creationInterface->addHatchEdge( hatchEdges[l][b] ); + creationInterface->addHatch(hd); + + for (unsigned int i=0; iaddHatchLoop(DL_HatchLoopData(hatchEdges[i].size())); + for (unsigned int k=0; kaddHatchEdge(DL_HatchEdgeData(hatchEdges[i][k])); + } } - } - creationInterface->endEntity(); - currentEntity = DL_Unknown; + + creationInterface->endEntity(); } +void DL_Dxf::addHatchLoop() { + addHatchEdge(); + hatchEdges.push_back(std::vector()); +} + +void DL_Dxf::addHatchEdge() { + if (hatchEdge.defined) { + if (hatchEdges.size()>0) { + hatchEdges.back().push_back(hatchEdge); + } + hatchEdge = DL_HatchEdgeData(); + } +} + +/** + * Handles all hatch data. + */ +bool DL_Dxf::handleHatchData(DL_CreationInterface* creationInterface) { + // New polyline loop, group code 92 + // or new loop with individual edges, group code 93 + if (groupCode==92 || groupCode==93) { + if (firstHatchLoop) { + hatchEdges.clear(); + firstHatchLoop = false; + } + if (groupCode==92 && (toInt(groupValue)&2)==2) { + addHatchLoop(); + } + if (groupCode==93) { + addHatchLoop(); + } + return true; + } + + // New hatch edge or new section / entity: add last hatch edge: + if (groupCode==72 || groupCode==0 || groupCode==78 || groupCode==98) { + // polyline boundaries use code 72 for bulge flag: + if (groupCode!=72 || (getIntValue(92, 0)&2)==0) { + addHatchEdge(); + } + + if (groupCode==0 /*|| groupCode==78*/) { + addHatch(creationInterface); + } + else { + hatchEdge.type = toInt(groupValue); + } + return true; + } + + // polyline boundary: + if ((getIntValue(92, 0)&2)==2) { + switch (groupCode) { + case 10: + hatchEdge.type = 0; + hatchEdge.vertices.push_back(std::vector()); + hatchEdge.vertices.back().push_back(toReal(groupValue)); + return true; + case 20: + if (!hatchEdge.vertices.empty()) { + hatchEdge.vertices.back().push_back(toReal(groupValue)); + hatchEdge.defined = true; + } + return true; + case 42: + if (!hatchEdge.vertices.empty()) { + hatchEdge.vertices.back().push_back(toReal(groupValue)); + hatchEdge.defined = true; + } + return true; + } + } + else { + // Line edge: + if (hatchEdge.type==1) { + switch (groupCode) { + case 10: + hatchEdge.x1 = toReal(groupValue); + return true; + case 20: + hatchEdge.y1 = toReal(groupValue); + return true; + case 11: + hatchEdge.x2 = toReal(groupValue); + return true; + case 21: + hatchEdge.y2 = toReal(groupValue); + hatchEdge.defined = true; + return true; + } + } + + // Arc edge: + if (hatchEdge.type==2) { + switch(groupCode) { + case 10: + hatchEdge.cx = toReal(groupValue); + return true; + case 20: + hatchEdge.cy = toReal(groupValue); + return true; + case 40: + hatchEdge.radius = toReal(groupValue); + return true; + case 50: + hatchEdge.angle1 = toReal(groupValue)/360.0*2*M_PI; + return true; + case 51: + hatchEdge.angle2 = toReal(groupValue)/360.0*2*M_PI; + return true; + case 73: + hatchEdge.ccw = (bool)toInt(groupValue); + hatchEdge.defined = true; + return true; + } + } + + // Ellipse arc edge: + if (hatchEdge.type==3) { + switch (groupCode) { + case 10: + hatchEdge.cx = toReal(groupValue); + return true; + case 20: + hatchEdge.cy = toReal(groupValue); + return true; + case 11: + hatchEdge.mx = toReal(groupValue); + return true; + case 21: + hatchEdge.my = toReal(groupValue); + return true; + case 40: + hatchEdge.ratio = toReal(groupValue); + return true; + case 50: + hatchEdge.angle1 = toReal(groupValue)/360.0*2*M_PI; + return true; + case 51: + hatchEdge.angle2 = toReal(groupValue)/360.0*2*M_PI; + return true; + case 73: + hatchEdge.ccw = (bool)toInt(groupValue); + hatchEdge.defined = true; + return true; + } + } + + // Spline edge: + if (hatchEdge.type==4) { + switch (groupCode) { + case 94: + hatchEdge.degree = toInt(groupValue); + return true; + case 73: + hatchEdge.rational = toBool(groupValue); + return true; + case 74: + hatchEdge.periodic = toBool(groupValue); + return true; + case 95: + hatchEdge.nKnots = toInt(groupValue); + return true; + case 96: + hatchEdge.nControl = toInt(groupValue); + return true; + case 97: + hatchEdge.nFit = toInt(groupValue); + return true; + case 40: + if (hatchEdge.knots.size() < hatchEdge.nKnots) { + hatchEdge.knots.push_back(toReal(groupValue)); + } + return true; + case 10: + if (hatchEdge.controlPoints.size() < hatchEdge.nControl) { + std::vector v; + v.push_back(toReal(groupValue)); + hatchEdge.controlPoints.push_back(v); + } + return true; + case 20: + if (!hatchEdge.controlPoints.empty() && hatchEdge.controlPoints.back().size()==1) { + hatchEdge.controlPoints.back().push_back(toReal(groupValue)); + } + hatchEdge.defined = true; + return true; + case 42: + if (hatchEdge.weights.size() < hatchEdge.nControl) { + hatchEdge.weights.push_back(toReal(groupValue)); + } + return true; + case 11: + if (hatchEdge.fitPoints.size() < hatchEdge.nFit) { + std::vector v; + v.push_back(toReal(groupValue)); + hatchEdge.fitPoints.push_back(v); + } + return true; + case 21: + if (!hatchEdge.fitPoints.empty() && hatchEdge.fitPoints.back().size()==1) { + hatchEdge.fitPoints.back().push_back(toReal(groupValue)); + } + hatchEdge.defined = true; + return true; + case 12: + hatchEdge.startTangentX = toReal(groupValue); + return true; + case 22: + hatchEdge.startTangentY = toReal(groupValue); + return true; + case 13: + hatchEdge.endTangentX = toReal(groupValue); + return true; + case 23: + hatchEdge.endTangentY = toReal(groupValue); + return true; + } + } + } + + return false; +} /** * Adds an image entity that was read from the file via the creation interface. */ -void DL_Dxf::addImage( DL_CreationInterface* creationInterface ) -{ - DL_ImageData id( // pass ref insead of name we don't have yet - values[340], - // ins point: - toReal( values[10], 0.0 ), - toReal( values[20], 0.0 ), - toReal( values[30], 0.0 ), - // u vector: - toReal( values[11], 1.0 ), - toReal( values[21], 0.0 ), - toReal( values[31], 0.0 ), - // v vector: - toReal( values[12], 0.0 ), - toReal( values[22], 1.0 ), - toReal( values[32], 0.0 ), - // image size (pixel): - toInt( values[13], 1 ), - toInt( values[23], 1 ), - // brightness, contrast, fade - toInt( values[281], 50 ), - toInt( values[282], 50 ), - toInt( values[283], 0 ) ); +void DL_Dxf::addImage(DL_CreationInterface* creationInterface) { + DL_ImageData id(// pass ref insead of name we don't have yet + getStringValue(340, ""), + // ins point: + getRealValue(10, 0.0), + getRealValue(20, 0.0), + getRealValue(30, 0.0), + // u vector: + getRealValue(11, 1.0), + getRealValue(21, 0.0), + getRealValue(31, 0.0), + // v vector: + getRealValue(12, 0.0), + getRealValue(22, 1.0), + getRealValue(32, 0.0), + // image size (pixel): + getIntValue(13, 1), + getIntValue(23, 1), + // brightness, contrast, fade + getIntValue(281, 50), + getIntValue(282, 50), + getIntValue(283, 0)); - creationInterface->addImage( id ); - creationInterface->endEntity(); - currentEntity = DL_Unknown; + creationInterface->addImage(id); + creationInterface->endEntity(); + currentObjectType = DL_UNKNOWN; } @@ -2238,15 +2194,14 @@ void DL_Dxf::addImage( DL_CreationInterface* creationInterface ) /** * Adds an image definition that was read from the file via the creation interface. */ -void DL_Dxf::addImageDef( DL_CreationInterface* creationInterface ) -{ - DL_ImageDefData id( // handle - values[5], - values[1] ); +void DL_Dxf::addImageDef(DL_CreationInterface* creationInterface) { + DL_ImageDefData id(// handle + getStringValue(5, ""), + getStringValue(1, "")); - creationInterface->linkImage( id ); - creationInterface->endEntity(); - currentEntity = DL_Unknown; + creationInterface->linkImage(id); + creationInterface->endEntity(); + currentObjectType = DL_UNKNOWN; } @@ -2254,18 +2209,16 @@ void DL_Dxf::addImageDef( DL_CreationInterface* creationInterface ) /** * Ends some special entities like hatches or old style polylines. */ -void DL_Dxf::endEntity( DL_CreationInterface* creationInterface ) -{ - creationInterface->endEntity(); +void DL_Dxf::endEntity(DL_CreationInterface* creationInterface) { + creationInterface->endEntity(); } /** * Ends a sequence and notifies the creation interface. */ -void DL_Dxf::endSequence( DL_CreationInterface* creationInterface ) -{ - creationInterface->endSequence(); +void DL_Dxf::endSequence(DL_CreationInterface* creationInterface) { + creationInterface->endSequence(); } @@ -2273,44 +2226,32 @@ void DL_Dxf::endSequence( DL_CreationInterface* creationInterface ) * Converts the given string into an int. * ok is set to false if there was an error. */ -int DL_Dxf::stringToInt( const char* s, bool* ok ) -{ - if ( ok != NULL ) - { - // check string: - *ok = true; - int i = 0; - bool dot = false; - do - { - if ( s[i] == '\0' ) - { - break; - } - else if ( s[i] == '.' ) - { - if ( dot ) - { -// QgsDebugMsg("two dots"); - *ok = false; - } - else - { - dot = true; - } - } - else if ( s[i] < '0' || s[i] > '9' ) - { -// QgsDebugMsg(QString("NaN: '%1'").arg(s[i])); - *ok = false; - } - i++; - } - while ( s[i] != '\0' && *ok ); - } +//int DL_Dxf::stringToInt(const char* s, bool* ok) { +// if (ok!=NULL) { +// // check string: +// *ok = true; +// int i=0; +// bool dot = false; +// do { +// if (s[i]=='\0') { +// break; +// } else if (s[i]=='.') { +// if (dot==true) { +// //std::cerr << "two dots\n"; +// *ok = false; +// } else { +// dot = true; +// } +// } else if (s[i]<'0' || s[i]>'9') { +// //std::cerr << "NaN: '" << s[i] << "'\n"; +// *ok = false; +// } +// i++; +// } while(s[i]!='\0' && *ok==true); +// } - return atoi( s ); -} +// return atoi(s); +//} /** @@ -2322,62 +2263,56 @@ int DL_Dxf::stringToInt( const char* s, bool* ok ) * * @return Pointer to an ascii dxf writer object. */ -DL_WriterA* DL_Dxf::out( const char* file, DL_Codes::version version ) -{ - char* f = new char[strlen( file )+1]; - strcpy( f, file ); - this->version = version; +DL_WriterA* DL_Dxf::out(const char* file, DL_Codes::version version) { + char* f = new char[strlen(file)+1]; + strcpy(f, file); + this->version = version; - DL_WriterA* dw = new DL_WriterA( f, version ); - if ( dw->openFailed() ) - { - delete dw; - delete[] f; - return NULL; - } - else - { - delete[] f; - return dw; - } + DL_WriterA* dw = new DL_WriterA(f, version); + if (dw->openFailed()) { + delete dw; + delete[] f; + return NULL; + } else { + delete[] f; + return dw; + } } /** - * @brief Writes a DXF header to the file currently opened + * @brief Writes a DXF header to the file currently opened * by the given DXF writer object. */ -void DL_Dxf::writeHeader( DL_WriterA& dw ) -{ - dw.comment( "dxflib " DL_VERSION ); - dw.sectionHeader(); +void DL_Dxf::writeHeader(DL_WriterA& dw) { + dw.comment("dxflib " DL_VERSION); + dw.sectionHeader(); - dw.dxfString( 9, "$ACADVER" ); - switch ( version ) - { + dw.dxfString(9, "$ACADVER"); + switch (version) { case DL_Codes::AC1009: - dw.dxfString( 1, "AC1009" ); - break; + dw.dxfString(1, "AC1009"); + break; case DL_Codes::AC1012: - dw.dxfString( 1, "AC1012" ); - break; + dw.dxfString(1, "AC1012"); + break; case DL_Codes::AC1014: - dw.dxfString( 1, "AC1014" ); - break; + dw.dxfString(1, "AC1014"); + break; case DL_Codes::AC1015: - dw.dxfString( 1, "AC1015" ); - break; - } + dw.dxfString(1, "AC1015"); + break; + } - // Newer version require that (otherwise a*cad crashes..) - if ( version == VER_2000 ) - { - dw.dxfString( 9, "$HANDSEED" ); - dw.dxfHex( 5, 0xFFFF ); - } + // Newer version require that (otherwise a*cad crashes..) + if (version==DL_VERSION_2000) { + dw.dxfString(9, "$HANDSEED"); + dw.dxfHex(5, 0xFFFF); + } - //dw.sectionEnd(); + // commented out: more variables can be added after that by caller: + //dw.sectionEnd(); } @@ -2390,18 +2325,16 @@ void DL_Dxf::writeHeader( DL_WriterA& dw ) * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writePoint( DL_WriterA& dw, - const DL_PointData& data, - const DL_Attributes& attrib ) -{ - dw.entity( "POINT" ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbPoint" ); - } - dw.entityAttributes( attrib ); - dw.coord( POINT_COORD_CODE, data.x, data.y ); +void DL_Dxf::writePoint(DL_WriterA& dw, + const DL_PointData& data, + const DL_Attributes& attrib) { + dw.entity("POINT"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbPoint"); + } + dw.entityAttributes(attrib); + dw.coord(DL_POINT_COORD_CODE, data.x, data.y, data.z); } @@ -2413,19 +2346,61 @@ void DL_Dxf::writePoint( DL_WriterA& dw, * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeLine( DL_WriterA& dw, - const DL_LineData& data, - const DL_Attributes& attrib ) -{ - dw.entity( "LINE" ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbLine" ); - } - dw.entityAttributes( attrib ); - dw.coord( LINE_START_CODE, data.x1, data.y1 ); - dw.coord( LINE_END_CODE, data.x2, data.y2 ); +void DL_Dxf::writeLine(DL_WriterA& dw, + const DL_LineData& data, + const DL_Attributes& attrib) { + dw.entity("LINE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbLine"); + } + dw.entityAttributes(attrib); + dw.coord(DL_LINE_START_CODE, data.x1, data.y1, data.z1); + dw.coord(DL_LINE_END_CODE, data.x2, data.y2, data.z2); +} + + + +/** + * Writes an x line entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeXLine(DL_WriterA& dw, + const DL_XLineData& data, + const DL_Attributes& attrib) { + dw.entity("XLINE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbLine"); + } + dw.entityAttributes(attrib); + dw.coord(DL_LINE_START_CODE, data.bx, data.by, data.bz); + dw.coord(DL_LINE_END_CODE, data.dx, data.dy, data.dz); +} + + + +/** + * Writes a ray entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeRay(DL_WriterA& dw, + const DL_RayData& data, + const DL_Attributes& attrib) { + dw.entity("RAY"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbLine"); + } + dw.entityAttributes(attrib); + dw.coord(DL_LINE_START_CODE, data.bx, data.by, data.bz); + dw.coord(DL_LINE_END_CODE, data.dx, data.dy, data.dz); } @@ -2438,28 +2413,24 @@ void DL_Dxf::writeLine( DL_WriterA& dw, * @param attrib Attributes * @see writeVertex */ -void DL_Dxf::writePolyline( DL_WriterA& dw, - const DL_PolylineData& data, - const DL_Attributes& attrib ) -{ - if ( version == VER_2000 ) - { - dw.entity( "LWPOLYLINE" ); - dw.entityAttributes( attrib ); - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbPolyline" ); - dw.dxfInt( 90, ( int )data.number ); - dw.dxfInt( 70, data.flags ); - } - else - { - dw.entity( "POLYLINE" ); - dw.entityAttributes( attrib ); - polylineLayer = attrib.getLayer(); - dw.dxfInt( 66, 1 ); - dw.dxfInt( 70, data.flags ); - dw.coord( VERTEX_COORD_CODE, 0.0, 0.0 ); - } +void DL_Dxf::writePolyline(DL_WriterA& dw, + const DL_PolylineData& data, + const DL_Attributes& attrib) { + if (version==DL_VERSION_2000) { + dw.entity("LWPOLYLINE"); + dw.entityAttributes(attrib); + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbPolyline"); + dw.dxfInt(90, (int)data.number); + dw.dxfInt(70, data.flags); + } else { + dw.entity("POLYLINE"); + dw.entityAttributes(attrib); + polylineLayer = attrib.getLayer(); + dw.dxfInt(66, 1); + dw.dxfInt(70, data.flags); + dw.coord(DL_VERTEX_COORD_CODE, 0.0, 0.0, 0.0); + } } @@ -2471,47 +2442,38 @@ void DL_Dxf::writePolyline( DL_WriterA& dw, * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeVertex( DL_WriterA& dw, - const DL_VertexData& data ) -{ +void DL_Dxf::writeVertex(DL_WriterA& dw, + const DL_VertexData& data) { - if ( version == VER_2000 ) - { - dw.dxfReal( 10, data.x ); - dw.dxfReal( 20, data.y ); - if ( qAbs( data.bulge ) > 1.0e-10 ) - { - dw.dxfReal( 42, data.bulge ); + if (version==DL_VERSION_2000) { + dw.dxfReal(10, data.x); + dw.dxfReal(20, data.y); + dw.dxfReal(30, data.z); + if (fabs(data.bulge)>1.0e-10) { + dw.dxfReal(42, data.bulge); + } + } else { + dw.entity("VERTEX"); + //dw.entityAttributes(attrib); + dw.dxfString(8, polylineLayer); + dw.coord(DL_VERTEX_COORD_CODE, data.x, data.y, data.z); + if (fabs(data.bulge)>1.0e-10) { + dw.dxfReal(42, data.bulge); + } } - } - else - { - dw.entity( "VERTEX" ); - //dw.entityAttributes(attrib); - dw.dxfString( 8, polylineLayer ); - dw.coord( VERTEX_COORD_CODE, data.x, data.y ); - if ( qAbs( data.bulge ) > 1.0e-10 ) - { - dw.dxfReal( 42, data.bulge ); - } - } } - - + + /** * Writes the polyline end. Only needed for DXF R12. */ -void DL_Dxf::writePolylineEnd( DL_WriterA& dw ) -{ - if ( version == VER_2000 ) - { - } - else - { - dw.entity( "SEQEND" ); - } +void DL_Dxf::writePolylineEnd(DL_WriterA& dw) { + if (version==DL_VERSION_2000) { + } else { + dw.entity("SEQEND"); + } } @@ -2523,23 +2485,21 @@ void DL_Dxf::writePolylineEnd( DL_WriterA& dw ) * @param attrib Attributes * @see writeControlPoint */ -void DL_Dxf::writeSpline( DL_WriterA& dw, - const DL_SplineData& data, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeSpline(DL_WriterA& dw, + const DL_SplineData& data, + const DL_Attributes& attrib) { - dw.entity( "SPLINE" ); - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbSpline" ); - } - dw.dxfInt( 70, data.flags ); - dw.dxfInt( 71, data.degree ); - dw.dxfInt( 72, data.nKnots ); // number of knots - dw.dxfInt( 73, data.nControl ); // number of control points - dw.dxfInt( 74, 0 ); // number of fit points + dw.entity("SPLINE"); + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbSpline"); + } + dw.dxfInt(70, data.flags); + dw.dxfInt(71, data.degree); + dw.dxfInt(72, data.nKnots); // number of knots + dw.dxfInt(73, data.nControl); // number of control points + dw.dxfInt(74, data.nFit); // number of fit points } @@ -2551,13 +2511,29 @@ void DL_Dxf::writeSpline( DL_WriterA& dw, * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeControlPoint( DL_WriterA& dw, - const DL_ControlPointData& data ) -{ +void DL_Dxf::writeControlPoint(DL_WriterA& dw, + const DL_ControlPointData& data) { - dw.dxfReal( 10, data.x ); - dw.dxfReal( 20, data.y ); - dw.dxfReal( 30, data.z ); + dw.dxfReal(10, data.x); + dw.dxfReal(20, data.y); + dw.dxfReal(30, data.z); +} + + + +/** + * Writes a single fit point of a spline to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeFitPoint(DL_WriterA& dw, + const DL_FitPointData& data) { + + dw.dxfReal(11, data.x); + dw.dxfReal(21, data.y); + dw.dxfReal(31, data.z); } @@ -2569,11 +2545,10 @@ void DL_Dxf::writeControlPoint( DL_WriterA& dw, * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeKnot( DL_WriterA& dw, - const DL_KnotData& data ) -{ +void DL_Dxf::writeKnot(DL_WriterA& dw, + const DL_KnotData& data) { - dw.dxfReal( 40, data.k ); + dw.dxfReal(40, data.k); } @@ -2585,19 +2560,17 @@ void DL_Dxf::writeKnot( DL_WriterA& dw, * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeCircle( DL_WriterA& dw, - const DL_CircleData& data, - const DL_Attributes& attrib ) -{ - dw.entity( "CIRCLE" ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbCircle" ); - } - dw.entityAttributes( attrib ); - dw.coord( 10, data.cx, data.cy ); - dw.dxfReal( 40, data.radius ); +void DL_Dxf::writeCircle(DL_WriterA& dw, + const DL_CircleData& data, + const DL_Attributes& attrib) { + dw.entity("CIRCLE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbCircle"); + } + dw.entityAttributes(attrib); + dw.coord(10, data.cx, data.cy, data.cz); + dw.dxfReal(40, data.radius); } @@ -2609,28 +2582,24 @@ void DL_Dxf::writeCircle( DL_WriterA& dw, * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeArc( DL_WriterA& dw, - const DL_ArcData& data, - const DL_Attributes& attrib ) -{ - dw.entity( "ARC" ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - } - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbCircle" ); - } - dw.coord( 10, data.cx, data.cy ); - dw.dxfReal( 40, data.radius ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbArc" ); - } - dw.dxfReal( 50, data.angle1 ); - dw.dxfReal( 51, data.angle2 ); +void DL_Dxf::writeArc(DL_WriterA& dw, + const DL_ArcData& data, + const DL_Attributes& attrib) { + dw.entity("ARC"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbCircle"); + } + dw.coord(10, data.cx, data.cy, data.cz); + dw.dxfReal(40, data.radius); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbArc"); + } + dw.dxfReal(50, data.angle1); + dw.dxfReal(51, data.angle2); } @@ -2642,26 +2611,95 @@ void DL_Dxf::writeArc( DL_WriterA& dw, * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeEllipse( DL_WriterA& dw, - const DL_EllipseData& data, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeEllipse(DL_WriterA& dw, + const DL_EllipseData& data, + const DL_Attributes& attrib) { - if ( version > VER_R12 ) - { - dw.entity( "ELLIPSE" ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbEllipse" ); + if (version>DL_VERSION_R12) { + dw.entity("ELLIPSE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbEllipse"); + } + dw.entityAttributes(attrib); + dw.coord(10, data.cx, data.cy, data.cz); + dw.coord(11, data.mx, data.my, data.mz); + dw.dxfReal(40, data.ratio); + dw.dxfReal(41, data.angle1); + dw.dxfReal(42, data.angle2); } - dw.entityAttributes( attrib ); - dw.coord( 10, data.cx, data.cy ); - dw.coord( 11, data.mx, data.my ); - dw.dxfReal( 40, data.ratio ); - dw.dxfReal( 41, data.angle1 ); - dw.dxfReal( 42, data.angle2 ); - } +} + + + +/** + * Writes a solid entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeSolid(DL_WriterA& dw, + const DL_SolidData& data, + const DL_Attributes& attrib) { + dw.entity("SOLID"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbTrace"); + } + dw.entityAttributes(attrib); + dw.coord(10, data.x[0], data.y[0], data.z[0]); + dw.coord(11, data.x[1], data.y[1], data.z[1]); + dw.coord(12, data.x[2], data.y[2], data.z[2]); + dw.coord(13, data.x[3], data.y[3], data.z[3]); + dw.dxfReal(39, data.thickness); +} + +/** + * Writes a trace entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeTrace(DL_WriterA& dw, + const DL_TraceData& data, + const DL_Attributes& attrib) { + dw.entity("TRACE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbTrace"); + } + dw.entityAttributes(attrib); + dw.coord(10, data.x[0], data.y[0], data.z[0]); + dw.coord(11, data.x[1], data.y[1], data.z[1]); + dw.coord(12, data.x[2], data.y[2], data.z[2]); + dw.coord(13, data.x[3], data.y[3], data.z[3]); + dw.dxfReal(39, data.thickness); +} + + + +/** + * Writes a 3d face entity to the file. + * + * @param dw DXF writer + * @param data Entity data from the file + * @param attrib Attributes + */ +void DL_Dxf::write3dFace(DL_WriterA& dw, + const DL_3dFaceData& data, + const DL_Attributes& attrib) { + dw.entity("3DFACE"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbFace"); + } + dw.entityAttributes(attrib); + dw.coord(10, data.x[0], data.y[0], data.z[0]); + dw.coord(11, data.x[1], data.y[1], data.z[1]); + dw.coord(12, data.x[2], data.y[2], data.z[2]); + dw.coord(13, data.x[3], data.y[3], data.z[3]); } @@ -2673,48 +2711,42 @@ void DL_Dxf::writeEllipse( DL_WriterA& dw, * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeInsert( DL_WriterA& dw, - const DL_InsertData& data, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeInsert(DL_WriterA& dw, + const DL_InsertData& data, + const DL_Attributes& attrib) { - if ( data.name.empty() ) - { - QgsDebugMsg( "Block name must not be empty" ); - return; - } + if (data.name.empty()) { + std::cerr << "DL_Dxf::writeInsert: " + << "Block name must not be empty\n"; + return; + } - dw.entity( "INSERT" ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbBlockReference" ); - } - dw.entityAttributes( attrib ); - dw.dxfString( 2, data.name ); - dw.dxfReal( 10, data.ipx ); - dw.dxfReal( 20, data.ipy ); - dw.dxfReal( 30, 0.0 ); - if ( data.sx != 1.0 || data.sy != 1.0 ) - { - dw.dxfReal( 41, data.sx ); - dw.dxfReal( 42, data.sy ); - dw.dxfReal( 43, 1.0 ); - } - if ( data.angle != 0.0 ) - { - dw.dxfReal( 50, data.angle ); - } - if ( data.cols != 1 || data.rows != 1 ) - { - dw.dxfInt( 70, data.cols ); - dw.dxfInt( 71, data.rows ); - } - if ( data.colSp != 0.0 || data.rowSp != 0.0 ) - { - dw.dxfReal( 44, data.colSp ); - dw.dxfReal( 45, data.rowSp ); - } + dw.entity("INSERT"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbBlockReference"); + } + dw.entityAttributes(attrib); + dw.dxfString(2, data.name); + dw.dxfReal(10, data.ipx); + dw.dxfReal(20, data.ipy); + dw.dxfReal(30, data.ipz); + if (data.sx!=1.0 || data.sy!=1.0) { + dw.dxfReal(41, data.sx); + dw.dxfReal(42, data.sy); + dw.dxfReal(43, 1.0); + } + if (data.angle!=0.0) { + dw.dxfReal(50, data.angle); + } + if (data.cols!=1 || data.rows!=1) { + dw.dxfInt(70, data.cols); + dw.dxfInt(71, data.rows); + } + if (data.colSp!=0.0 || data.rowSp!=0.0) { + dw.dxfReal(44, data.colSp); + dw.dxfReal(45, data.rowSp); + } } @@ -2727,48 +2759,45 @@ void DL_Dxf::writeInsert( DL_WriterA& dw, * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeMText( DL_WriterA& dw, - const DL_MTextData& data, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeMText(DL_WriterA& dw, + const DL_MTextData& data, + const DL_Attributes& attrib) { - dw.entity( "MTEXT" ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbMText" ); - } - dw.entityAttributes( attrib ); - dw.dxfReal( 10, data.ipx ); - dw.dxfReal( 20, data.ipy ); - dw.dxfReal( 30, 0.0 ); - dw.dxfReal( 40, data.height ); - dw.dxfReal( 41, data.width ); + dw.entity("MTEXT"); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbMText"); + } + dw.entityAttributes(attrib); + dw.dxfReal(10, data.ipx); + dw.dxfReal(20, data.ipy); + dw.dxfReal(30, data.ipz); + dw.dxfReal(40, data.height); + dw.dxfReal(41, data.width); - dw.dxfInt( 71, data.attachmentPoint ); - dw.dxfInt( 72, data.drawingDirection ); + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.drawingDirection); - // Creare text chunks of 250 characters each: - int length = data.text.length(); - char chunk[251]; - int i; - for ( i = 250; i < length; i += 250 ) - { - strncpy( chunk, &data.text.c_str()[i-250], 250 ); - chunk[250] = '\0'; - dw.dxfString( 3, chunk ); - } - strncpy( chunk, &data.text.c_str()[i-250], 250 ); - chunk[250] = '\0'; - dw.dxfString( 1, chunk ); + // Creare text chunks of 250 characters each: + int length = data.text.length(); + char chunk[251]; + int i; + for (i=250; i VER_R12 ) - { - dw.dxfInt( 71, data.attachmentPoint ); - dw.dxfInt( 72, data.lineSpacingStyle ); // opt - dw.dxfReal( 41, data.lineSpacingFactor ); // opt - } + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } - dw.dxfReal( 42, data.angle ); + dw.dxfReal(42, data.angle); - dw.dxfString( 1, data.text ); // opt - //dw.dxfString(3, data.style); - dw.dxfString( 3, "Standard" ); + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbAlignedDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbAlignedDimension"); + } - dw.dxfReal( 13, edata.epx1 ); - dw.dxfReal( 23, edata.epy1 ); - dw.dxfReal( 33, 0.0 ); + dw.dxfReal(13, edata.epx1); + dw.dxfReal(23, edata.epy1); + dw.dxfReal(33, 0.0); - dw.dxfReal( 14, edata.epx2 ); - dw.dxfReal( 24, edata.epy2 ); - dw.dxfReal( 34, 0.0 ); + dw.dxfReal(14, edata.epx2); + dw.dxfReal(24, edata.epy2); + dw.dxfReal(34, 0.0); + + writeDimStyleOverrides(dw, data); } @@ -2884,73 +2959,61 @@ void DL_Dxf::writeDimAligned( DL_WriterA& dw, * @param data Specific linear dimension data from the file * @param attrib Attributes */ -void DL_Dxf::writeDimLinear( DL_WriterA& dw, - const DL_DimensionData& data, - const DL_DimLinearData& edata, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeDimLinear(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimLinearData& edata, + const DL_Attributes& attrib) { - dw.entity( "DIMENSION" ); + dw.entity("DIMENSION"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - } - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } - dw.dxfReal( 10, data.dpx ); - dw.dxfReal( 20, data.dpy ); - dw.dxfReal( 30, 0.0 ); + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); - dw.dxfReal( 11, data.mpx ); - dw.dxfReal( 21, data.mpy ); - dw.dxfReal( 31, 0.0 ); + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); - dw.dxfInt( 70, 0 ); - if ( version > VER_R12 ) - { - dw.dxfInt( 71, data.attachmentPoint ); - dw.dxfInt( 72, data.lineSpacingStyle ); // opt - dw.dxfReal( 41, data.lineSpacingFactor ); // opt - } + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } - dw.dxfReal( 42, data.angle ); + dw.dxfReal(42, data.angle); - dw.dxfString( 1, data.text ); // opt - //dw.dxfString(3, data.style); - dw.dxfString( 3, "Standard" ); + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbAlignedDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbAlignedDimension"); + } - dw.dxfReal( 13, edata.dpx1 ); - dw.dxfReal( 23, edata.dpy1 ); - dw.dxfReal( 33, 0.0 ); + dw.dxfReal(13, edata.dpx1); + dw.dxfReal(23, edata.dpy1); + dw.dxfReal(33, 0.0); - dw.dxfReal( 14, edata.dpx2 ); - dw.dxfReal( 24, edata.dpy2 ); - dw.dxfReal( 34, 0.0 ); + dw.dxfReal(14, edata.dpx2); + dw.dxfReal(24, edata.dpy2); + dw.dxfReal(34, 0.0); - dw.dxfReal( 50, edata.angle / ( 2.0*M_PI )*360.0 ); + dw.dxfReal(50, edata.angle/(2.0*M_PI)*360.0); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbRotatedDimension" ); - /* - dw.dxfString(1001, "ACAD"); - dw.dxfString(1000, "DSTYLE"); - dw.dxfString(1002, "{"); - dw.dxfInt(1070, 340); - dw.dxfInt(1005, 11); - dw.dxfString(1002, "}"); - */ - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbRotatedDimension"); + } + + writeDimStyleOverrides(dw, data); } @@ -2963,56 +3026,53 @@ void DL_Dxf::writeDimLinear( DL_WriterA& dw, * @param data Specific radial dimension data from the file * @param attrib Attributes */ -void DL_Dxf::writeDimRadial( DL_WriterA& dw, - const DL_DimensionData& data, - const DL_DimRadialData& edata, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeDimRadial(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimRadialData& edata, + const DL_Attributes& attrib) { - dw.entity( "DIMENSION" ); + dw.entity("DIMENSION"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - } - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } - dw.dxfReal( 10, data.dpx ); - dw.dxfReal( 20, data.dpy ); - dw.dxfReal( 30, 0.0 ); + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); - dw.dxfReal( 11, data.mpx ); - dw.dxfReal( 21, data.mpy ); - dw.dxfReal( 31, 0.0 ); + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); - dw.dxfInt( 70, 4 ); - if ( version > VER_R12 ) - { - dw.dxfInt( 71, data.attachmentPoint ); - dw.dxfInt( 72, data.lineSpacingStyle ); // opt - dw.dxfReal( 41, data.lineSpacingFactor ); // opt - } + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } - dw.dxfReal( 42, data.angle ); + dw.dxfReal(42, data.angle); - dw.dxfString( 1, data.text ); // opt - //dw.dxfString(3, data.style); - dw.dxfString( 3, "Standard" ); + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbRadialDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbRadialDimension"); + } - dw.dxfReal( 15, edata.dpx ); - dw.dxfReal( 25, edata.dpy ); - dw.dxfReal( 35, 0.0 ); + dw.dxfReal(15, edata.dpx); + dw.dxfReal(25, edata.dpy); + dw.dxfReal(35, 0.0); - dw.dxfReal( 40, edata.leader ); + dw.dxfReal(40, edata.leader); + + writeDimStyleOverrides(dw, data); } @@ -3025,56 +3085,53 @@ void DL_Dxf::writeDimRadial( DL_WriterA& dw, * @param data Specific diametric dimension data from the file * @param attrib Attributes */ -void DL_Dxf::writeDimDiametric( DL_WriterA& dw, - const DL_DimensionData& data, - const DL_DimDiametricData& edata, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeDimDiametric(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimDiametricData& edata, + const DL_Attributes& attrib) { - dw.entity( "DIMENSION" ); + dw.entity("DIMENSION"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - } - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } - dw.dxfReal( 10, data.dpx ); - dw.dxfReal( 20, data.dpy ); - dw.dxfReal( 30, 0.0 ); + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); - dw.dxfReal( 11, data.mpx ); - dw.dxfReal( 21, data.mpy ); - dw.dxfReal( 31, 0.0 ); + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); - dw.dxfInt( 70, 3 ); - if ( version > VER_R12 ) - { - dw.dxfInt( 71, data.attachmentPoint ); - dw.dxfInt( 72, data.lineSpacingStyle ); // opt - dw.dxfReal( 41, data.lineSpacingFactor ); // opt - } + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } - dw.dxfReal( 42, data.angle ); + dw.dxfReal(42, data.angle); - dw.dxfString( 1, data.text ); // opt - //dw.dxfString(3, data.style); - dw.dxfString( 3, "Standard" ); + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbDiametricDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDiametricDimension"); + } - dw.dxfReal( 15, edata.dpx ); - dw.dxfReal( 25, edata.dpy ); - dw.dxfReal( 35, 0.0 ); + dw.dxfReal(15, edata.dpx); + dw.dxfReal(25, edata.dpy); + dw.dxfReal(35, 0.0); - dw.dxfReal( 40, edata.leader ); + dw.dxfReal(40, edata.leader); + + writeDimStyleOverrides(dw, data); } @@ -3087,66 +3144,61 @@ void DL_Dxf::writeDimDiametric( DL_WriterA& dw, * @param data Specific angular dimension data from the file * @param attrib Attributes */ -void DL_Dxf::writeDimAngular( DL_WriterA& dw, - const DL_DimensionData& data, - const DL_DimAngularData& edata, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeDimAngular(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimAngularData& edata, + const DL_Attributes& attrib) { - dw.entity( "DIMENSION" ); + dw.entity("DIMENSION"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - } - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } - dw.dxfReal( 10, data.dpx ); - dw.dxfReal( 20, data.dpy ); - dw.dxfReal( 30, 0.0 ); + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); - dw.dxfReal( 11, data.mpx ); - dw.dxfReal( 21, data.mpy ); - dw.dxfReal( 31, 0.0 ); + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); - dw.dxfInt( 70, 2 ); - if ( version > VER_R12 ) - { - dw.dxfInt( 71, data.attachmentPoint ); - dw.dxfInt( 72, data.lineSpacingStyle ); // opt - dw.dxfReal( 41, data.lineSpacingFactor ); // opt - } + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } - dw.dxfReal( 42, data.angle ); + dw.dxfReal(42, data.angle); - dw.dxfString( 1, data.text ); // opt - //dw.dxfString(3, data.style); - dw.dxfString( 3, "Standard" ); + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDb2LineAngularDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDb2LineAngularDimension"); + } - dw.dxfReal( 13, edata.dpx1 ); - dw.dxfReal( 23, edata.dpy1 ); - dw.dxfReal( 33, 0.0 ); + dw.dxfReal(13, edata.dpx1); + dw.dxfReal(23, edata.dpy1); + dw.dxfReal(33, 0.0); - dw.dxfReal( 14, edata.dpx2 ); - dw.dxfReal( 24, edata.dpy2 ); - dw.dxfReal( 34, 0.0 ); + dw.dxfReal(14, edata.dpx2); + dw.dxfReal(24, edata.dpy2); + dw.dxfReal(34, 0.0); - dw.dxfReal( 15, edata.dpx3 ); - dw.dxfReal( 25, edata.dpy3 ); - dw.dxfReal( 35, 0.0 ); + dw.dxfReal(15, edata.dpx3); + dw.dxfReal(25, edata.dpy3); + dw.dxfReal(35, 0.0); - dw.dxfReal( 16, edata.dpx4 ); - dw.dxfReal( 26, edata.dpy4 ); - dw.dxfReal( 36, 0.0 ); + dw.dxfReal(16, edata.dpx4); + dw.dxfReal(26, edata.dpy4); + dw.dxfReal(36, 0.0); } @@ -3159,62 +3211,120 @@ void DL_Dxf::writeDimAngular( DL_WriterA& dw, * @param data Specific angular dimension data from the file * @param attrib Attributes */ -void DL_Dxf::writeDimAngular3P( DL_WriterA& dw, - const DL_DimensionData& data, - const DL_DimAngular3PData& edata, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeDimAngular3P(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimAngular3PData& edata, + const DL_Attributes& attrib) { - dw.entity( "DIMENSION" ); + dw.entity("DIMENSION"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - } - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } - dw.dxfReal( 10, data.dpx ); - dw.dxfReal( 20, data.dpy ); - dw.dxfReal( 30, 0.0 ); + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); - dw.dxfReal( 11, data.mpx ); - dw.dxfReal( 21, data.mpy ); - dw.dxfReal( 31, 0.0 ); + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); - dw.dxfInt( 70, 5 ); - if ( version > VER_R12 ) - { - dw.dxfInt( 71, data.attachmentPoint ); - dw.dxfInt( 72, data.lineSpacingStyle ); // opt - dw.dxfReal( 41, data.lineSpacingFactor ); // opt - } + dw.dxfInt(70, data.type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } - dw.dxfReal( 42, data.angle ); + dw.dxfReal(42, data.angle); - dw.dxfString( 1, data.text ); // opt - //dw.dxfString(3, data.style); - dw.dxfString( 3, "Standard" ); + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDb3PointAngularDimension" ); - } + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDb3PointAngularDimension"); + } - dw.dxfReal( 13, edata.dpx1 ); - dw.dxfReal( 23, edata.dpy1 ); - dw.dxfReal( 33, 0.0 ); + dw.dxfReal(13, edata.dpx1); + dw.dxfReal(23, edata.dpy1); + dw.dxfReal(33, 0.0); - dw.dxfReal( 14, edata.dpx2 ); - dw.dxfReal( 24, edata.dpy2 ); - dw.dxfReal( 34, 0.0 ); + dw.dxfReal(14, edata.dpx2); + dw.dxfReal(24, edata.dpy2); + dw.dxfReal(34, 0.0); - dw.dxfReal( 15, edata.dpx3 ); - dw.dxfReal( 25, edata.dpy3 ); - dw.dxfReal( 35, 0.0 ); + dw.dxfReal(15, edata.dpx3); + dw.dxfReal(25, edata.dpy3); + dw.dxfReal(35, 0.0); +} + + + + +/** + * Writes an ordinate dimension entity to the file. + * + * @param dw DXF writer + * @param data Generic dimension data for from the file + * @param data Specific ordinate dimension data from the file + * @param attrib Attributes + */ +void DL_Dxf::writeDimOrdinate(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimOrdinateData& edata, + const DL_Attributes& attrib) { + + dw.entity("DIMENSION"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + } + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimension"); + } + + dw.dxfReal(10, data.dpx); + dw.dxfReal(20, data.dpy); + dw.dxfReal(30, data.dpz); + + dw.dxfReal(11, data.mpx); + dw.dxfReal(21, data.mpy); + dw.dxfReal(31, 0.0); + + int type = data.type; + if (edata.xtype) { + type|=0x40; + } + + dw.dxfInt(70, type); + if (version>DL_VERSION_R12) { + dw.dxfInt(71, data.attachmentPoint); + dw.dxfInt(72, data.lineSpacingStyle); // opt + dw.dxfReal(41, data.lineSpacingFactor); // opt + } + + dw.dxfString(1, data.text); // opt + //dw.dxfString(3, data.style); + dw.dxfString(3, "Standard"); + + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbOrdinateDimension"); + } + + dw.dxfReal(13, edata.dpx1); + dw.dxfReal(23, edata.dpy1); + dw.dxfReal(33, 0.0); + + dw.dxfReal(14, edata.dpx2); + dw.dxfReal(24, edata.dpy2); + dw.dxfReal(34, 0.0); } @@ -3227,29 +3337,26 @@ void DL_Dxf::writeDimAngular3P( DL_WriterA& dw, * @param attrib Attributes * @see writeVertex */ -void DL_Dxf::writeLeader( DL_WriterA& dw, - const DL_LeaderData& data, - const DL_Attributes& attrib ) -{ - if ( version > VER_R12 ) - { - dw.entity( "LEADER" ); - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbLeader" ); +void DL_Dxf::writeLeader(DL_WriterA& dw, + const DL_LeaderData& data, + const DL_Attributes& attrib) { + if (version>DL_VERSION_R12) { + dw.entity("LEADER"); + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbLeader"); + } + dw.dxfString(3, "Standard"); + dw.dxfInt(71, data.arrowHeadFlag); + dw.dxfInt(72, data.leaderPathType); + dw.dxfInt(73, data.leaderCreationFlag); + dw.dxfInt(74, data.hooklineDirectionFlag); + dw.dxfInt(75, data.hooklineFlag); + dw.dxfReal(40, data.textAnnotationHeight); + dw.dxfReal(41, data.textAnnotationWidth); + dw.dxfInt(76, data.number); } - dw.dxfString( 3, "Standard" ); - dw.dxfInt( 71, data.arrowHeadFlag ); - dw.dxfInt( 72, data.leaderPathType ); - dw.dxfInt( 73, data.leaderCreationFlag ); - dw.dxfInt( 74, data.hooklineDirectionFlag ); - dw.dxfInt( 75, data.hooklineFlag ); - dw.dxfReal( 40, data.textAnnotationHeight ); - dw.dxfReal( 41, data.textAnnotationWidth ); - dw.dxfInt( 76, data.number ); - } } @@ -3260,14 +3367,12 @@ void DL_Dxf::writeLeader( DL_WriterA& dw, * @param dw DXF writer * @param data Entity data */ -void DL_Dxf::writeLeaderVertex( DL_WriterA& dw, - const DL_LeaderVertexData& data ) -{ - if ( version > VER_R12 ) - { - dw.dxfReal( 10, data.x ); - dw.dxfReal( 20, data.y ); - } +void DL_Dxf::writeLeaderVertex(DL_WriterA& dw, + const DL_LeaderVertexData& data) { + if (version>DL_VERSION_R12) { + dw.dxfReal(10, data.x); + dw.dxfReal(20, data.y); + } } @@ -3281,35 +3386,30 @@ void DL_Dxf::writeLeaderVertex( DL_WriterA& dw, * @param data Entity data. * @param attrib Attributes */ -void DL_Dxf::writeHatch1( DL_WriterA& dw, - const DL_HatchData& data, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeHatch1(DL_WriterA& dw, + const DL_HatchData& data, + const DL_Attributes& attrib) { - dw.entity( "HATCH" ); - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbHatch" ); - } - dw.dxfReal( 10, 0.0 ); // elevation - dw.dxfReal( 20, 0.0 ); - dw.dxfReal( 30, 0.0 ); - dw.dxfReal( 210, 0.0 ); // extrusion dir. - dw.dxfReal( 220, 0.0 ); - dw.dxfReal( 230, 1.0 ); - if ( !data.solid ) - { - dw.dxfString( 2, data.pattern ); - } - else - { - dw.dxfString( 2, "SOLID" ); - } - dw.dxfInt( 70, ( int )data.solid ); - dw.dxfInt( 71, 0 ); // associative - dw.dxfInt( 91, data.numLoops ); + dw.entity("HATCH"); + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbHatch"); + } + dw.dxfReal(10, 0.0); // elevation + dw.dxfReal(20, 0.0); + dw.dxfReal(30, 0.0); + dw.dxfReal(210, 0.0); // extrusion dir. + dw.dxfReal(220, 0.0); + dw.dxfReal(230, 1.0); + if (data.solid==false) { + dw.dxfString(2, data.pattern); + } else { + dw.dxfString(2, "SOLID"); + } + dw.dxfInt(70, (int)data.solid); + dw.dxfInt(71, 0); // non-associative + dw.dxfInt(91, data.numLoops); } @@ -3321,28 +3421,33 @@ void DL_Dxf::writeHatch1( DL_WriterA& dw, * @param data Entity data. * @param attrib Attributes */ -void DL_Dxf::writeHatch2( DL_WriterA& dw, - const DL_HatchData& data, - const DL_Attributes& /*attrib*/ ) -{ +void DL_Dxf::writeHatch2(DL_WriterA& dw, + const DL_HatchData& data, + const DL_Attributes& /*attrib*/) { - dw.dxfInt( 75, 0 ); // odd parity - dw.dxfInt( 76, 1 ); // pattern type - if ( !data.solid ) - { - dw.dxfReal( 52, data.angle ); - dw.dxfReal( 41, data.scale ); - dw.dxfInt( 77, 0 ); // not double - //dw.dxfInt(78, 0); - dw.dxfInt( 78, 1 ); - dw.dxfReal( 53, 45.0 ); - dw.dxfReal( 43, 0.0 ); - dw.dxfReal( 44, 0.0 ); - dw.dxfReal( 45, -0.0883883476483184 ); - dw.dxfReal( 46, 0.0883883476483185 ); - dw.dxfInt( 79, 0 ); - } - dw.dxfInt( 98, 0 ); + dw.dxfInt(75, 0); // odd parity + dw.dxfInt(76, 1); // pattern type + if (data.solid==false) { + dw.dxfReal(52, data.angle); + dw.dxfReal(41, data.scale); + dw.dxfInt(77, 0); // not double + //dw.dxfInt(78, 0); + dw.dxfInt(78, 1); + dw.dxfReal(53, 45.0); + dw.dxfReal(43, 0.0); + dw.dxfReal(44, 0.0); + dw.dxfReal(45, -0.0883883476483184); + dw.dxfReal(46, 0.0883883476483185); + dw.dxfInt(79, 0); + } + dw.dxfInt(98, 0); + + if (version==DL_VERSION_2000) { + dw.dxfString(1001, "ACAD"); + dw.dxfReal(1010, data.originX); + dw.dxfReal(1020, data.originY); + dw.dxfInt(1030, 0.0); + } } @@ -3355,13 +3460,12 @@ void DL_Dxf::writeHatch2( DL_WriterA& dw, * @param data Entity data. * @param attrib Attributes */ -void DL_Dxf::writeHatchLoop1( DL_WriterA& dw, - const DL_HatchLoopData& data ) -{ +void DL_Dxf::writeHatchLoop1(DL_WriterA& dw, + const DL_HatchLoopData& data) { - dw.dxfInt( 92, 1 ); - dw.dxfInt( 93, data.numEdges ); - //dw.dxfInt(97, 0); + dw.dxfInt(92, 1); + dw.dxfInt(93, data.numEdges); + //dw.dxfInt(97, 0); } @@ -3373,11 +3477,10 @@ void DL_Dxf::writeHatchLoop1( DL_WriterA& dw, * @param data Entity data. * @param attrib Attributes */ -void DL_Dxf::writeHatchLoop2( DL_WriterA& dw, - const DL_HatchLoopData& /*data*/ ) -{ +void DL_Dxf::writeHatchLoop2(DL_WriterA& dw, + const DL_HatchLoopData& /*data*/) { - dw.dxfInt( 97, 0 ); + dw.dxfInt(97, 0); } @@ -3388,31 +3491,83 @@ void DL_Dxf::writeHatchLoop2( DL_WriterA& dw, * @param data Entity data. * @param attrib Attributes */ -void DL_Dxf::writeHatchEdge( DL_WriterA& dw, - const DL_HatchEdgeData& data ) -{ +void DL_Dxf::writeHatchEdge(DL_WriterA& dw, + const DL_HatchEdgeData& data) { - dw.dxfInt( 72, data.type ); + if (data.type<1 || data.type>4) { + printf("WARNING: unsupported hatch edge type: %d", data.type); + } - switch ( data.type ) - { + dw.dxfInt(72, data.type); + + switch (data.type) { + // line: case 1: - dw.dxfReal( 10, data.x1 ); - dw.dxfReal( 20, data.y1 ); - dw.dxfReal( 11, data.x2 ); - dw.dxfReal( 21, data.y2 ); - break; + dw.dxfReal(10, data.x1); + dw.dxfReal(20, data.y1); + dw.dxfReal(11, data.x2); + dw.dxfReal(21, data.y2); + break; + + // arc: case 2: - dw.dxfReal( 10, data.cx ); - dw.dxfReal( 20, data.cy ); - dw.dxfReal( 40, data.radius ); - dw.dxfReal( 50, data.angle1 / ( 2*M_PI )*360.0 ); - dw.dxfReal( 51, data.angle2 / ( 2*M_PI )*360.0 ); - dw.dxfInt( 73, ( int )( data.ccw ) ); - break; + dw.dxfReal(10, data.cx); + dw.dxfReal(20, data.cy); + dw.dxfReal(40, data.radius); + dw.dxfReal(50, data.angle1/(2*M_PI)*360.0); + dw.dxfReal(51, data.angle2/(2*M_PI)*360.0); + dw.dxfInt(73, (int)(data.ccw)); + break; + + // ellipse arc: + case 3: + dw.dxfReal(10, data.cx); + dw.dxfReal(20, data.cy); + dw.dxfReal(11, data.mx); + dw.dxfReal(21, data.my); + dw.dxfReal(40, data.ratio); + dw.dxfReal(50, data.angle1/(2*M_PI)*360.0); + dw.dxfReal(51, data.angle2/(2*M_PI)*360.0); + dw.dxfInt(73, (int)(data.ccw)); + break; + + // spline: + case 4: + dw.dxfInt(94, data.degree); + dw.dxfBool(73, data.rational); + dw.dxfBool(74, data.periodic); + dw.dxfInt(95, data.nKnots); + dw.dxfInt(96, data.nControl); + for (unsigned int i=0; i0) { + dw.dxfInt(97, data.nFit); + for (unsigned int i=0; i1.0e-4 || fabs(data.startTangentY)>1.0e-4) { + dw.dxfReal(12, data.startTangentX); + dw.dxfReal(22, data.startTangentY); + } + if (fabs(data.endTangentX)>1.0e-4 || fabs(data.endTangentY)>1.0e-4) { + dw.dxfReal(13, data.endTangentX); + dw.dxfReal(23, data.endTangentY); + } + break; + default: - break; - } + break; + } } @@ -3422,62 +3577,59 @@ void DL_Dxf::writeHatchEdge( DL_WriterA& dw, * * @return IMAGEDEF handle. Needed for the IMAGEDEF counterpart. */ -int DL_Dxf::writeImage( DL_WriterA& dw, - const DL_ImageData& data, - const DL_Attributes& attrib ) -{ -#if 0 - if ( data.file.empty() ) - { - QgsDebugMsg( "Image file must not be empty" ); - return; - } -#endif +int DL_Dxf::writeImage(DL_WriterA& dw, + const DL_ImageData& data, + const DL_Attributes& attrib) { - dw.entity( "IMAGE" ); + /*if (data.file.empty()) { + std::cerr << "DL_Dxf::writeImage: " + << "Image file must not be empty\n"; + return; +}*/ - dw.entityAttributes( attrib ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbEntity" ); - dw.dxfString( 100, "AcDbRasterImage" ); - dw.dxfInt( 90, 0 ); - } - // insertion point - dw.dxfReal( 10, data.ipx ); - dw.dxfReal( 20, data.ipy ); - dw.dxfReal( 30, 0.0 ); + dw.entity("IMAGE"); - // vector along bottom side (1 pixel long) - dw.dxfReal( 11, data.ux ); - dw.dxfReal( 21, data.uy ); - dw.dxfReal( 31, 0.0 ); + dw.entityAttributes(attrib); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbEntity"); + dw.dxfString(100, "AcDbRasterImage"); + dw.dxfInt(90, 0); + } + // insertion point + dw.dxfReal(10, data.ipx); + dw.dxfReal(20, data.ipy); + dw.dxfReal(30, data.ipz); - // vector along left side (1 pixel long) - dw.dxfReal( 12, data.vx ); - dw.dxfReal( 22, data.vy ); - dw.dxfReal( 32, 0.0 ); + // vector along bottom side (1 pixel long) + dw.dxfReal(11, data.ux); + dw.dxfReal(21, data.uy); + dw.dxfReal(31, data.uz); - // image size in pixel - dw.dxfReal( 13, data.width ); - dw.dxfReal( 23, data.height ); + // vector along left side (1 pixel long) + dw.dxfReal(12, data.vx); + dw.dxfReal(22, data.vy); + dw.dxfReal(32, data.vz); - // handle of IMAGEDEF object - int handle = dw.incHandle(); - dw.dxfHex( 340, handle ); + // image size in pixel + dw.dxfReal(13, data.width); + dw.dxfReal(23, data.height); - // flags - dw.dxfInt( 70, 15 ); + // handle of IMAGEDEF object + int handle = dw.incHandle(); + dw.dxfHex(340, handle); - // clipping: - dw.dxfInt( 280, 0 ); + // flags + dw.dxfInt(70, 15); - // brightness, contrast, fade - dw.dxfInt( 281, data.brightness ); - dw.dxfInt( 282, data.contrast ); - dw.dxfInt( 283, data.fade ); + // clipping: + dw.dxfInt(280, 0); - return handle; + // brightness, contrast, fade + dw.dxfInt(281, data.brightness); + dw.dxfInt(282, data.contrast); + dw.dxfInt(283, data.fade); + + return handle; } @@ -3485,595 +3637,164 @@ int DL_Dxf::writeImage( DL_WriterA& dw, /** * Writes an image definiition entity. */ -void DL_Dxf::writeImageDef( DL_WriterA& dw, - int handle, - const DL_ImageData& data ) -{ +void DL_Dxf::writeImageDef(DL_WriterA& dw, + int handle, + const DL_ImageData& data) { - /*if (data.file.empty()) { - QgsDebugMsg("DL_Dxf::writeImage: Image file must not be empty"); - return; - }*/ + /*if (data.file.empty()) { + std::cerr << "DL_Dxf::writeImage: " + << "Image file must not be empty\n"; + return; +}*/ - dw.dxfString( 0, "IMAGEDEF" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, handle ); - } + dw.dxfString(0, "IMAGEDEF"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, handle); + } - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbRasterImageDef" ); - dw.dxfInt( 90, 0 ); - } - // file name: - dw.dxfString( 1, data.ref ); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbRasterImageDef"); + dw.dxfInt(90, 0); + } + // file name: + dw.dxfString(1, data.ref); - // image size in pixel - dw.dxfReal( 10, data.width ); - dw.dxfReal( 20, data.height ); + // image size in pixel + dw.dxfReal(10, data.width); + dw.dxfReal(20, data.height); - dw.dxfReal( 11, 1.0 ); - dw.dxfReal( 21, 1.0 ); + dw.dxfReal(11, 1.0); + dw.dxfReal(21, 1.0); - // loaded: - dw.dxfInt( 280, 1 ); - // units: - dw.dxfInt( 281, 0 ); + // loaded: + dw.dxfInt(280, 1); + // units: + dw.dxfInt(281, 0); } /** - * Writes a layer to the file. Layers are stored in the + * Writes a layer to the file. Layers are stored in the * tables section of a DXF file. * * @param dw DXF writer * @param data Entity data from the file * @param attrib Attributes */ -void DL_Dxf::writeLayer( DL_WriterA& dw, - const DL_LayerData& data, - const DL_Attributes& attrib ) -{ +void DL_Dxf::writeLayer(DL_WriterA& dw, + const DL_LayerData& data, + const DL_Attributes& attrib) { - if ( data.name.empty() ) - { - QgsDebugMsg( "DL_Dxf::writeLayer: Layer name must not be empty" ); - return; - } - - int color = attrib.getColor(); - if ( color <= 0 || color >= 256 ) - { - QgsDebugMsg( QString( "Layer color cannot be %1. Changed to 7." ).arg( color ) ); - color = 7; - } - - if ( data.name == "0" ) - { - dw.tableLayerEntry( 0x10 ); - } - else - { - dw.tableLayerEntry(); - } - - dw.dxfString( 2, data.name ); - dw.dxfInt( 70, data.flags ); - dw.dxfInt( 62, color ); - - dw.dxfString( 6, ( attrib.getLineType().length() == 0 ? - string( "CONTINUOUS" ) : attrib.getLineType() ) ); - - if ( version >= VER_2000 ) - { - // layer defpoints cannot be plotted - std::string lstr = data.name; - std::transform( lstr.begin(), lstr.end(), lstr.begin(), tolower ); - if ( lstr == "defpoints" ) - { - dw.dxfInt( 290, 0 ); + if (data.name.empty()) { + std::cerr << "DL_Dxf::writeLayer: " + << "Layer name must not be empty\n"; + return; + } + + int color = attrib.getColor(); + if (color>=256) { + std::cerr << "Layer color cannot be " << color << ". Changed to 7.\n"; + color = 7; + } + + if (data.name == "0") { + dw.tableLayerEntry(0x10); + } else { + dw.tableLayerEntry(); + } + + dw.dxfString(2, data.name); + dw.dxfInt(70, data.flags); + dw.dxfInt(62, color); + if (version>=DL_VERSION_2000 && attrib.getColor24()!=-1) { + dw.dxfInt(420, attrib.getColor24()); + } + + dw.dxfString(6, (attrib.getLinetype().length()==0 ? + std::string("CONTINUOUS") : attrib.getLinetype())); + + if (version>=DL_VERSION_2000) { + // layer defpoints cannot be plotted + std::string lstr = data.name; + std::transform(lstr.begin(), lstr.end(), lstr.begin(), tolower); + if (lstr=="defpoints") { + dw.dxfInt(290, 0); + } + } + if (version>=DL_VERSION_2000 && attrib.getWidth()!=-1) { + dw.dxfInt(370, attrib.getWidth()); + } + if (version>=DL_VERSION_2000) { + dw.dxfHex(390, 0xF); } - } - if ( version >= VER_2000 && attrib.getWidth() != -1 ) - { - dw.dxfInt( 370, attrib.getWidth() ); - } - if ( version >= VER_2000 ) - { - dw.dxfHex( 390, 0xF ); - } } /** - * Writes a line type to the file. Line types are stored in the + * Writes a line type to the file. Line types are stored in the * tables section of a DXF file. */ -void DL_Dxf::writeLineType( DL_WriterA& dw, - const DL_LineTypeData& data ) -{ - //const char* description, - //int elements, - //double patternLength) { +void DL_Dxf::writeLinetype(DL_WriterA& dw, + const DL_LinetypeData& data) { - if ( data.name.empty() ) - { - QgsDebugMsg( "DL_Dxf::writeLineType: Line type name must not be empty" ); - return; - } + std::string nameUpper = data.name; + std::transform(nameUpper.begin(), nameUpper.end(), nameUpper.begin(), ::toupper); - // ignore BYLAYER, BYBLOCK for R12 - if ( version < VER_2000 ) - { - if ( !strcasecmp( data.name.c_str(), "BYBLOCK" ) || - !strcasecmp( data.name.c_str(), "BYLAYER" ) ) - { - return; + if (data.name.empty()) { + std::cerr << "DL_Dxf::writeLinetype: " + << "Line type name must not be empty\n"; + return; } - } - // write id (not for R12) - if ( !strcasecmp( data.name.c_str(), "BYBLOCK" ) ) - { - dw.tableLineTypeEntry( 0x14 ); - } - else if ( !strcasecmp( data.name.c_str(), "BYLAYER" ) ) - { - dw.tableLineTypeEntry( 0x15 ); - } - else if ( !strcasecmp( data.name.c_str(), "CONTINUOUS" ) ) - { - dw.tableLineTypeEntry( 0x16 ); - } - else - { - dw.tableLineTypeEntry(); - } + // ignore BYLAYER, BYBLOCK for R12 + if (version=VER_2000) { - dw.dxfInt( 70, data.flags ); - //} + // write id (not for R12) + if (nameUpper=="BYBLOCK") { + dw.tableLinetypeEntry(0x14); + } else if (nameUpper=="BYLAYER") { + dw.tableLinetypeEntry(0x15); + } else if (nameUpper=="CONTINUOUS") { + dw.tableLinetypeEntry(0x16); + } else { + dw.tableLinetypeEntry(); + } - if ( !strcasecmp( data.name.c_str(), "BYBLOCK" ) ) - { - dw.dxfString( 3, "" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 0 ); - dw.dxfReal( 40, 0.0 ); - } - else if ( !strcasecmp( data.name.c_str(), "BYLAYER" ) ) - { - dw.dxfString( 3, "" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 0 ); - dw.dxfReal( 40, 0.0 ); - } - else if ( !strcasecmp( data.name.c_str(), "CONTINUOUS" ) ) - { - dw.dxfString( 3, "Solid line" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 0 ); - dw.dxfReal( 40, 0.0 ); - } - else if ( !strcasecmp( data.name.c_str(), "ACAD_ISO02W100" ) ) - { - dw.dxfString( 3, "ISO Dashed __ __ __ __ __ __ __ __ __ __ _" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 2 ); - dw.dxfReal( 40, 15.0 ); - dw.dxfReal( 49, 12.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "ACAD_ISO03W100" ) ) - { - dw.dxfString( 3, "ISO Dashed with Distance __ __ __ _" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 2 ); - dw.dxfReal( 40, 30.0 ); - dw.dxfReal( 49, 12.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -18.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "ACAD_ISO04W100" ) ) - { - dw.dxfString( 3, "ISO Long Dashed Dotted ____ . ____ . __" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 4 ); - dw.dxfReal( 40, 30.0 ); - dw.dxfReal( 49, 24.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "ACAD_ISO05W100" ) ) - { - dw.dxfString( 3, "ISO Long Dashed Double Dotted ____ .. __" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 6 ); - dw.dxfReal( 40, 33.0 ); - dw.dxfReal( 49, 24.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "BORDER" ) ) - { - dw.dxfString( 3, "Border __ __ . __ __ . __ __ . __ __ . __ __ ." ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 6 ); - dw.dxfReal( 40, 44.45 ); - dw.dxfReal( 49, 12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "BORDER2" ) ) - { - dw.dxfString( 3, "Border (.5x) __.__.__.__.__.__.__.__.__.__.__." ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 6 ); - dw.dxfReal( 40, 22.225 ); - dw.dxfReal( 49, 6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "BORDERX2" ) ) - { - dw.dxfString( 3, "Border (2x) ____ ____ . ____ ____ . ___" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 6 ); - dw.dxfReal( 40, 88.9 ); - dw.dxfReal( 49, 25.4 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 25.4 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "CENTER" ) ) - { - dw.dxfString( 3, "Center ____ _ ____ _ ____ _ ____ _ ____ _ ____" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 4 ); - dw.dxfReal( 40, 50.8 ); - dw.dxfReal( 49, 31.75 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "CENTER2" ) ) - { - dw.dxfString( 3, "Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 4 ); - dw.dxfReal( 40, 28.575 ); - dw.dxfReal( 49, 19.05 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "CENTERX2" ) ) - { - dw.dxfString( 3, "Center (2x) ________ __ ________ __ _____" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 4 ); - dw.dxfReal( 40, 101.6 ); - dw.dxfReal( 49, 63.5 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DASHDOT" ) ) - { - dw.dxfString( 3, "Dash dot __ . __ . __ . __ . __ . __ . __ . __" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 4 ); - dw.dxfReal( 40, 25.4 ); - dw.dxfReal( 49, 12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DASHDOT2" ) ) - { - dw.dxfString( 3, "Dash dot (.5x) _._._._._._._._._._._._._._._." ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 4 ); - dw.dxfReal( 40, 12.7 ); - dw.dxfReal( 49, 6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DASHDOTX2" ) ) - { - dw.dxfString( 3, "Dash dot (2x) ____ . ____ . ____ . ___" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 4 ); - dw.dxfReal( 40, 50.8 ); - dw.dxfReal( 49, 25.4 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DASHED" ) ) - { - dw.dxfString( 3, "Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 2 ); - dw.dxfReal( 40, 19.05 ); - dw.dxfReal( 49, 12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DASHED2" ) ) - { - dw.dxfString( 3, "Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 2 ); - dw.dxfReal( 40, 9.525 ); - dw.dxfReal( 49, 6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DASHEDX2" ) ) - { - dw.dxfString( 3, "Dashed (2x) ____ ____ ____ ____ ____ ___" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 2 ); - dw.dxfReal( 40, 38.1 ); - dw.dxfReal( 49, 25.4 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DIVIDE" ) ) - { - dw.dxfString( 3, "Divide ____ . . ____ . . ____ . . ____ . . ____" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 6 ); - dw.dxfReal( 40, 31.75 ); - dw.dxfReal( 49, 12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DIVIDE2" ) ) - { - dw.dxfString( 3, "Divide (.5x) __..__..__..__..__..__..__..__.._" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 6 ); - dw.dxfReal( 40, 15.875 ); - dw.dxfReal( 49, 6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DIVIDEX2" ) ) - { - dw.dxfString( 3, "Divide (2x) ________ . . ________ . . _" ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 6 ); - dw.dxfReal( 40, 63.5 ); - dw.dxfReal( 49, 25.4 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DOT" ) ) - { - dw.dxfString( 3, "Dot . . . . . . . . . . . . . . . . . . . . . ." ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 2 ); - dw.dxfReal( 40, 6.35 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -6.35 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DOT2" ) ) - { - dw.dxfString( 3, "Dot (.5x) ....................................." ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 2 ); - dw.dxfReal( 40, 3.175 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -3.175 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else if ( !strcasecmp( data.name.c_str(), "DOTX2" ) ) - { - dw.dxfString( 3, "Dot (2x) . . . . . . . . . . . . ." ); - dw.dxfInt( 72, 65 ); - dw.dxfInt( 73, 2 ); - dw.dxfReal( 40, 12.7 ); - dw.dxfReal( 49, 0.0 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - dw.dxfReal( 49, -12.7 ); - if ( version >= VER_R13 ) - dw.dxfInt( 74, 0 ); - } - else - { - QgsDebugMsg( "dxflib warning: DL_Dxf::writeLineType: Unknown Line Type" ); - } + dw.dxfString(2, data.name); + dw.dxfInt(70, data.flags); + + if (nameUpper=="BYBLOCK") { + dw.dxfString(3, ""); + dw.dxfInt(72, 65); + dw.dxfInt(73, 0); + dw.dxfReal(40, 0.0); + } else if (nameUpper=="BYLAYER") { + dw.dxfString(3, ""); + dw.dxfInt(72, 65); + dw.dxfInt(73, 0); + dw.dxfReal(40, 0.0); + } else if (nameUpper=="CONTINUOUS") { + dw.dxfString(3, "Solid line"); + dw.dxfInt(72, 65); + dw.dxfInt(73, 0); + dw.dxfReal(40, 0.0); + } else { + dw.dxfString(3, data.description); + dw.dxfInt(72, 65); + dw.dxfInt(73, data.numberOfDashes); + dw.dxfReal(40, data.patternLength); + for (int i = 0; i < data.numberOfDashes; i++) { + dw.dxfReal(49, data.pattern[i]); + if (version>=DL_VERSION_R13) { + dw.dxfInt(74, 0); + } + } + } } @@ -4083,24 +3804,23 @@ void DL_Dxf::writeLineType( DL_WriterA& dw, * * @param name Application name */ -void DL_Dxf::writeAppid( DL_WriterA& dw, const string& name ) -{ - if ( name.empty() ) - { - QgsDebugMsg( "DL_Dxf::writeAppid: Application name must not be empty" ); - return; - } +void DL_Dxf::writeAppid(DL_WriterA& dw, const std::string& name) { + if (name.empty()) { + std::cerr << "DL_Dxf::writeAppid: " + << "Application name must not be empty\n"; + return; + } - if ( !strcasecmp( name.c_str(), "ACAD" ) ) - { - dw.tableAppidEntry( 0x12 ); - } - else - { - dw.tableAppidEntry(); - } - dw.dxfString( 2, name ); - dw.dxfInt( 70, 0 ); + std::string n = name; + std::transform(n.begin(), n.end(), n.begin(), ::toupper); + + if (n=="ACAD") { + dw.tableAppidEntry(0x12); + } else { + dw.tableAppidEntry(); + } + dw.dxfString(2, name); + dw.dxfInt(70, 0); } @@ -4108,38 +3828,30 @@ void DL_Dxf::writeAppid( DL_WriterA& dw, const string& name ) /** * Writes a block's definition (no entities) to the DXF file. */ -void DL_Dxf::writeBlock( DL_WriterA& dw, const DL_BlockData& data ) -{ - if ( data.name.empty() ) - { - QgsDebugMsg( "DL_Dxf::writeBlock: Block name must not be empty" ); - return; - } +void DL_Dxf::writeBlock(DL_WriterA& dw, const DL_BlockData& data) { + if (data.name.empty()) { + std::cerr << "DL_Dxf::writeBlock: " + << "Block name must not be empty\n"; + return; + } - //bool paperSpace = !strcasecmp(name, "*paper_space"); - //!strcasecmp(name, "*paper_space0"); + std::string n = data.name; + std::transform(n.begin(), n.end(), n.begin(), ::toupper); - if ( !strcasecmp( data.name.c_str(), "*paper_space" ) ) - { - dw.sectionBlockEntry( 0x1C ); - } - else if ( !strcasecmp( data.name.c_str(), "*model_space" ) ) - { - dw.sectionBlockEntry( 0x20 ); - } - else if ( !strcasecmp( data.name.c_str(), "*paper_space0" ) ) - { - dw.sectionBlockEntry( 0x24 ); - } - else - { - dw.sectionBlockEntry(); - } - dw.dxfString( 2, data.name ); - dw.dxfInt( 70, 0 ); - dw.coord( 10, data.bpx, data.bpy ); - dw.dxfString( 3, data.name ); - dw.dxfString( 1, "" ); + if (n=="*PAPER_SPACE") { + dw.sectionBlockEntry(0x1C); + } else if (n=="*MODEL_SPACE") { + dw.sectionBlockEntry(0x20); + } else if (n=="*PAPER_SPACE0") { + dw.sectionBlockEntry(0x24); + } else { + dw.sectionBlockEntry(); + } + dw.dxfString(2, data.name); + dw.dxfInt(70, 0); + dw.coord(10, data.bpx, data.bpy, data.bpz); + dw.dxfString(3, data.name); + dw.dxfString(1, ""); } @@ -4149,398 +3861,373 @@ void DL_Dxf::writeBlock( DL_WriterA& dw, const DL_BlockData& data ) * * @param name Block name */ -void DL_Dxf::writeEndBlock( DL_WriterA& dw, const string& name ) -{ - if ( !strcasecmp( name.c_str(), "*paper_space" ) ) - { - dw.sectionBlockEntryEnd( 0x1D ); - } - else if ( !strcasecmp( name.c_str(), "*model_space" ) ) - { - dw.sectionBlockEntryEnd( 0x21 ); - } - else if ( !strcasecmp( name.c_str(), "*paper_space0" ) ) - { - dw.sectionBlockEntryEnd( 0x25 ); - } - else - { - dw.sectionBlockEntryEnd(); - } +void DL_Dxf::writeEndBlock(DL_WriterA& dw, const std::string& name) { + std::string n = name; + std::transform(n.begin(), n.end(), n.begin(), ::toupper); + + if (n=="*PAPER_SPACE") { + dw.sectionBlockEntryEnd(0x1D); + } else if (n=="*MODEL_SPACE") { + dw.sectionBlockEntryEnd(0x21); + } else if (n=="*PAPER_SPACE0") { + dw.sectionBlockEntryEnd(0x25); + } else { + dw.sectionBlockEntryEnd(); + } } /** - * Writes a viewport section. This section is needed in VER_R13. + * Writes a viewport section. This section is needed in DL_VERSION_R13. * Note that this method currently only writes a faked VPORT section * to make the file readable by Aut*cad. */ -void DL_Dxf::writeVPort( DL_WriterA& dw ) -{ - dw.dxfString( 0, "TABLE" ); - dw.dxfString( 2, "VPORT" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 0x8 ); - } - //dw.dxfHex(330, 0); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTable" ); - } - dw.dxfInt( 70, 1 ); - dw.dxfString( 0, "VPORT" ); - //dw.dxfHex(5, 0x2F); - if ( version == VER_2000 ) - { - dw.handle(); - } - //dw.dxfHex(330, 8); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTableRecord" ); - dw.dxfString( 100, "AcDbViewportTableRecord" ); - } - dw.dxfString( 2, "*Active" ); - dw.dxfInt( 70, 0 ); - dw.dxfReal( 10, 0.0 ); - dw.dxfReal( 20, 0.0 ); - dw.dxfReal( 11, 1.0 ); - dw.dxfReal( 21, 1.0 ); - dw.dxfReal( 12, 286.3055555555555 ); - dw.dxfReal( 22, 148.5 ); - dw.dxfReal( 13, 0.0 ); - dw.dxfReal( 23, 0.0 ); - dw.dxfReal( 14, 10.0 ); - dw.dxfReal( 24, 10.0 ); - dw.dxfReal( 15, 10.0 ); - dw.dxfReal( 25, 10.0 ); - dw.dxfReal( 16, 0.0 ); - dw.dxfReal( 26, 0.0 ); - dw.dxfReal( 36, 1.0 ); - dw.dxfReal( 17, 0.0 ); - dw.dxfReal( 27, 0.0 ); - dw.dxfReal( 37, 0.0 ); - dw.dxfReal( 40, 297.0 ); - dw.dxfReal( 41, 1.92798353909465 ); - dw.dxfReal( 42, 50.0 ); - dw.dxfReal( 43, 0.0 ); - dw.dxfReal( 44, 0.0 ); - dw.dxfReal( 50, 0.0 ); - dw.dxfReal( 51, 0.0 ); - dw.dxfInt( 71, 0 ); - dw.dxfInt( 72, 100 ); - dw.dxfInt( 73, 1 ); - dw.dxfInt( 74, 3 ); - dw.dxfInt( 75, 1 ); - dw.dxfInt( 76, 1 ); - dw.dxfInt( 77, 0 ); - dw.dxfInt( 78, 0 ); +void DL_Dxf::writeVPort(DL_WriterA& dw) { + dw.dxfString(0, "TABLE"); + dw.dxfString(2, "VPORT"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0x8); + } + //dw.dxfHex(330, 0); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt(70, 1); + dw.dxfString(0, "VPORT"); + //dw.dxfHex(5, 0x2F); + if (version==DL_VERSION_2000) { + dw.handle(); + } + //dw.dxfHex(330, 8); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbViewportTableRecord"); + } + dw.dxfString( 2, "*Active"); + dw.dxfInt( 70, 0); + dw.dxfReal( 10, 0.0); + dw.dxfReal( 20, 0.0); + dw.dxfReal( 11, 1.0); + dw.dxfReal( 21, 1.0); + dw.dxfReal( 12, 286.3055555555555); + dw.dxfReal( 22, 148.5); + dw.dxfReal( 13, 0.0); + dw.dxfReal( 23, 0.0); + dw.dxfReal( 14, 10.0); + dw.dxfReal( 24, 10.0); + dw.dxfReal( 15, 10.0); + dw.dxfReal( 25, 10.0); + dw.dxfReal( 16, 0.0); + dw.dxfReal( 26, 0.0); + dw.dxfReal( 36, 1.0); + dw.dxfReal( 17, 0.0); + dw.dxfReal( 27, 0.0); + dw.dxfReal( 37, 0.0); + dw.dxfReal( 40, 297.0); + dw.dxfReal( 41, 1.92798353909465); + dw.dxfReal( 42, 50.0); + dw.dxfReal( 43, 0.0); + dw.dxfReal( 44, 0.0); + dw.dxfReal( 50, 0.0); + dw.dxfReal( 51, 0.0); + dw.dxfInt( 71, 0); + dw.dxfInt( 72, 100); + dw.dxfInt( 73, 1); + dw.dxfInt( 74, 3); + dw.dxfInt( 75, 1); + dw.dxfInt( 76, 1); + dw.dxfInt( 77, 0); + dw.dxfInt( 78, 0); - if ( version == VER_2000 ) - { - dw.dxfInt( 281, 0 ); - dw.dxfInt( 65, 1 ); - dw.dxfReal( 110, 0.0 ); - dw.dxfReal( 120, 0.0 ); - dw.dxfReal( 130, 0.0 ); - dw.dxfReal( 111, 1.0 ); - dw.dxfReal( 121, 0.0 ); - dw.dxfReal( 131, 0.0 ); - dw.dxfReal( 112, 0.0 ); - dw.dxfReal( 122, 1.0 ); - dw.dxfReal( 132, 0.0 ); - dw.dxfInt( 79, 0 ); - dw.dxfReal( 146, 0.0 ); - } - dw.dxfString( 0, "ENDTAB" ); + if (version==DL_VERSION_2000) { + dw.dxfInt(281, 0); + dw.dxfInt( 65, 1); + dw.dxfReal(110, 0.0); + dw.dxfReal(120, 0.0); + dw.dxfReal(130, 0.0); + dw.dxfReal(111, 1.0); + dw.dxfReal(121, 0.0); + dw.dxfReal(131, 0.0); + dw.dxfReal(112, 0.0); + dw.dxfReal(122, 1.0); + dw.dxfReal(132, 0.0); + dw.dxfInt( 79, 0); + dw.dxfReal(146, 0.0); + } + dw.dxfString( 0, "ENDTAB"); } /** - * Writes a style section. This section is needed in VER_R13. - * Note that this method currently only writes a faked STYLE section - * to make the file readable by Aut*cad. + * Writes a style section. This section is needed in DL_VERSION_R13. */ -void DL_Dxf::writeStyle( DL_WriterA& dw ) -{ - dw.dxfString( 0, "TABLE" ); - dw.dxfString( 2, "STYLE" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 3 ); - } - //dw.dxfHex(330, 0); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTable" ); - } - dw.dxfInt( 70, 1 ); - dw.dxfString( 0, "STYLE" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 0x11 ); - } - //styleHandleStd = dw.handle(); - //dw.dxfHex(330, 3); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTableRecord" ); - dw.dxfString( 100, "AcDbTextStyleTableRecord" ); - } - dw.dxfString( 2, "Standard" ); - dw.dxfInt( 70, 0 ); - dw.dxfReal( 40, 0.0 ); - dw.dxfReal( 41, 0.75 ); - dw.dxfReal( 50, 0.0 ); - dw.dxfInt( 71, 0 ); - dw.dxfReal( 42, 2.5 ); - dw.dxfString( 3, "txt" ); - dw.dxfString( 4, "" ); - dw.dxfString( 0, "ENDTAB" ); +void DL_Dxf::writeStyle(DL_WriterA& dw, const DL_StyleData& style) { +// dw.dxfString( 0, "TABLE"); +// dw.dxfString( 2, "STYLE"); +// if (version==DL_VERSION_2000) { +// dw.dxfHex(5, 3); +// } + //dw.dxfHex(330, 0); +// if (version==DL_VERSION_2000) { +// dw.dxfString(100, "AcDbSymbolTable"); +// } +// dw.dxfInt( 70, 1); + dw.dxfString( 0, "STYLE"); + if (version==DL_VERSION_2000) { + if (style.name=="Standard") { + //dw.dxfHex(5, 0x11); + styleHandleStd = dw.handle(); + } + else { + dw.handle(); + } + } + //dw.dxfHex(330, 3); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbTextStyleTableRecord"); + } + dw.dxfString( 2, style.name); + dw.dxfInt( 70, style.flags); + dw.dxfReal( 40, style.fixedTextHeight); + dw.dxfReal( 41, style.widthFactor); + dw.dxfReal( 50, style.obliqueAngle); + dw.dxfInt( 71, style.textGenerationFlags); + dw.dxfReal( 42, style.lastHeightUsed); + if (version==DL_VERSION_2000) { + dw.dxfString( 3, ""); + dw.dxfString( 4, ""); + dw.dxfString(1001, "ACAD"); + //dw.dxfString(1000, style.name); + dw.dxfString(1000, style.primaryFontFile); + int xFlags = 0; + if (style.bold) { + xFlags = xFlags|0x2000000; + } + if (style.italic) { + xFlags = xFlags|0x1000000; + } + dw.dxfInt(1071, xFlags); + } + else { + dw.dxfString( 3, style.primaryFontFile); + dw.dxfString( 4, style.bigFontFile); + } + //dw.dxfString( 0, "ENDTAB"); } /** - * Writes a view section. This section is needed in VER_R13. + * Writes a view section. This section is needed in DL_VERSION_R13. * Note that this method currently only writes a faked VIEW section * to make the file readable by Aut*cad. */ -void DL_Dxf::writeView( DL_WriterA& dw ) -{ - dw.dxfString( 0, "TABLE" ); - dw.dxfString( 2, "VIEW" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 6 ); - } - //dw.dxfHex(330, 0); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTable" ); - } - dw.dxfInt( 70, 0 ); - dw.dxfString( 0, "ENDTAB" ); +void DL_Dxf::writeView(DL_WriterA& dw) { + dw.dxfString( 0, "TABLE"); + dw.dxfString( 2, "VIEW"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 6); + } + //dw.dxfHex(330, 0); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt( 70, 0); + dw.dxfString( 0, "ENDTAB"); } /** - * Writes a ucs section. This section is needed in VER_R13. + * Writes a ucs section. This section is needed in DL_VERSION_R13. * Note that this method currently only writes a faked UCS section * to make the file readable by Aut*cad. */ -void DL_Dxf::writeUcs( DL_WriterA& dw ) -{ - dw.dxfString( 0, "TABLE" ); - dw.dxfString( 2, "UCS" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 7 ); - } - //dw.dxfHex(330, 0); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTable" ); - } - dw.dxfInt( 70, 0 ); - dw.dxfString( 0, "ENDTAB" ); +void DL_Dxf::writeUcs(DL_WriterA& dw) { + dw.dxfString( 0, "TABLE"); + dw.dxfString( 2, "UCS"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 7); + } + //dw.dxfHex(330, 0); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt( 70, 0); + dw.dxfString( 0, "ENDTAB"); } /** - * Writes a dimstyle section. This section is needed in VER_R13. + * Writes a dimstyle section. This section is needed in DL_VERSION_R13. * Note that this method currently only writes a faked DIMSTYLE section * to make the file readable by Aut*cad. */ -void DL_Dxf::writeDimStyle( DL_WriterA& dw, - double dimasz, double dimexe, double dimexo, - double dimgap, double dimtxt ) -{ +void DL_Dxf::writeDimStyle(DL_WriterA& dw, + double dimasz, double dimexe, double dimexo, + double dimgap, double dimtxt) { - dw.dxfString( 0, "TABLE" ); - dw.dxfString( 2, "DIMSTYLE" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 0xA ); - dw.dxfString( 100, "AcDbSymbolTable" ); - } - dw.dxfInt( 70, 1 ); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbDimStyleTable" ); - dw.dxfInt( 71, 0 ); - } + dw.dxfString( 0, "TABLE"); + dw.dxfString( 2, "DIMSTYLE"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0xA); + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt( 70, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbDimStyleTable"); + dw.dxfInt( 71, 0); + } - dw.dxfString( 0, "DIMSTYLE" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 105, 0x27 ); - } - //dw.handle(105); - //dw.dxfHex(330, 0xA); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTableRecord" ); - dw.dxfString( 100, "AcDbDimStyleTableRecord" ); - } - dw.dxfString( 2, "Standard" ); - if ( version == VER_R12 ) - { - dw.dxfString( 3, "" ); - dw.dxfString( 4, "" ); - dw.dxfString( 5, "" ); - dw.dxfString( 6, "" ); - dw.dxfString( 7, "" ); - dw.dxfReal( 40, 1.0 ); - } + dw.dxfString( 0, "DIMSTYLE"); + if (version==DL_VERSION_2000) { + dw.dxfHex(105, 0x27); + } + //dw.handle(105); + //dw.dxfHex(330, 0xA); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbDimStyleTableRecord"); + } + dw.dxfString( 2, "Standard"); + if (version==DL_VERSION_R12) { + dw.dxfString( 3, ""); + dw.dxfString( 4, ""); + dw.dxfString( 5, ""); + dw.dxfString( 6, ""); + dw.dxfString( 7, ""); + dw.dxfReal( 40, 1.0); + } - dw.dxfReal( 41, dimasz ); - dw.dxfReal( 42, dimexo ); - dw.dxfReal( 43, 3.75 ); - dw.dxfReal( 44, dimexe ); - if ( version == VER_R12 ) - { - dw.dxfReal( 45, 0.0 ); - dw.dxfReal( 46, 0.0 ); - dw.dxfReal( 47, 0.0 ); - dw.dxfReal( 48, 0.0 ); - } - dw.dxfInt( 70, 0 ); - if ( version == VER_R12 ) - { - dw.dxfInt( 71, 0 ); - dw.dxfInt( 72, 0 ); - } - dw.dxfInt( 73, 0 ); - dw.dxfInt( 74, 0 ); - if ( version == VER_R12 ) - { - dw.dxfInt( 75, 0 ); - dw.dxfInt( 76, 0 ); - } - dw.dxfInt( 77, 1 ); - dw.dxfInt( 78, 8 ); - dw.dxfReal( 140, dimtxt ); - dw.dxfReal( 141, 2.5 ); - if ( version == VER_R12 ) - { - dw.dxfReal( 142, 0.0 ); - } - dw.dxfReal( 143, 0.03937007874016 ); - if ( version == VER_R12 ) - { - dw.dxfReal( 144, 1.0 ); - dw.dxfReal( 145, 0.0 ); - dw.dxfReal( 146, 1.0 ); - } - dw.dxfReal( 147, dimgap ); - if ( version == VER_R12 ) - { - dw.dxfInt( 170, 0 ); - } - dw.dxfInt( 171, 3 ); - dw.dxfInt( 172, 1 ); - if ( version == VER_R12 ) - { - dw.dxfInt( 173, 0 ); - dw.dxfInt( 174, 0 ); - dw.dxfInt( 175, 0 ); - dw.dxfInt( 176, 0 ); - dw.dxfInt( 177, 0 ); - dw.dxfInt( 178, 0 ); - } - if ( version == VER_2000 ) - { - dw.dxfInt( 271, 2 ); - dw.dxfInt( 272, 2 ); - dw.dxfInt( 274, 3 ); - dw.dxfInt( 278, 44 ); - dw.dxfInt( 283, 0 ); - dw.dxfInt( 284, 8 ); - //dw.dxfHex(340, styleHandleStd); - dw.dxfHex( 340, 0x11 ); - } - // * / - dw.dxfString( 0, "ENDTAB" ); + dw.dxfReal( 41, dimasz); + dw.dxfReal( 42, dimexo); + dw.dxfReal( 43, 3.75); + dw.dxfReal( 44, dimexe); + if (version==DL_VERSION_R12) { + dw.dxfReal( 45, 0.0); + dw.dxfReal( 46, 0.0); + dw.dxfReal( 47, 0.0); + dw.dxfReal( 48, 0.0); + } + dw.dxfInt( 70, 0); + if (version==DL_VERSION_R12) { + dw.dxfInt( 71, 0); + dw.dxfInt( 72, 0); + } + dw.dxfInt( 73, 0); + dw.dxfInt( 74, 0); + if (version==DL_VERSION_R12) { + dw.dxfInt( 75, 0); + dw.dxfInt( 76, 0); + } + dw.dxfInt( 77, 1); + dw.dxfInt( 78, 8); + dw.dxfReal(140, dimtxt); + dw.dxfReal(141, 2.5); + if (version==DL_VERSION_R12) { + dw.dxfReal(142, 0.0); + } + dw.dxfReal(143, 0.03937007874016); + if (version==DL_VERSION_R12) { + dw.dxfReal(144, 1.0); + dw.dxfReal(145, 0.0); + dw.dxfReal(146, 1.0); + } + dw.dxfReal(147, dimgap); + if (version==DL_VERSION_R12) { + dw.dxfInt(170, 0); + } + dw.dxfInt(171, 3); + dw.dxfInt(172, 1); + if (version==DL_VERSION_R12) { + dw.dxfInt(173, 0); + dw.dxfInt(174, 0); + dw.dxfInt(175, 0); + dw.dxfInt(176, 0); + dw.dxfInt(177, 0); + dw.dxfInt(178, 0); + } + if (version==DL_VERSION_2000) { + dw.dxfInt(271, 2); + dw.dxfInt(272, 2); + dw.dxfInt(274, 3); + dw.dxfInt(278, 44); + dw.dxfInt(283, 0); + dw.dxfInt(284, 8); + dw.dxfHex(340, styleHandleStd); + //dw.dxfHex(340, 0x11); + } + // * / + dw.dxfString( 0, "ENDTAB"); } /** - * Writes a blockrecord section. This section is needed in VER_R13. + * Writes a blockrecord section. This section is needed in DL_VERSION_R13. * Note that this method currently only writes a faked BLOCKRECORD section * to make the file readable by Aut*cad. */ -void DL_Dxf::writeBlockRecord( DL_WriterA& dw ) -{ - dw.dxfString( 0, "TABLE" ); - dw.dxfString( 2, "BLOCK_RECORD" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 1 ); - } - //dw.dxfHex(330, 0); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTable" ); - } - dw.dxfInt( 70, 1 ); +void DL_Dxf::writeBlockRecord(DL_WriterA& dw) { + dw.dxfString( 0, "TABLE"); + dw.dxfString( 2, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 1); + } + //dw.dxfHex(330, 0); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTable"); + } + dw.dxfInt( 70, 1); - dw.dxfString( 0, "BLOCK_RECORD" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 0x1F ); - } - //int msh = dw.handle(); - //dw.setModelSpaceHandle(msh); - //dw.dxfHex(330, 1); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTableRecord" ); - dw.dxfString( 100, "AcDbBlockTableRecord" ); - } - dw.dxfString( 2, "*Model_Space" ); - dw.dxfHex( 340, 0x22 ); + dw.dxfString( 0, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0x1F); + } + //int msh = dw.handle(); + //dw.setModelSpaceHandle(msh); + //dw.dxfHex(330, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbBlockTableRecord"); + } + dw.dxfString( 2, "*Model_Space"); + dw.dxfHex(340, 0x22); - dw.dxfString( 0, "BLOCK_RECORD" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 0x1B ); - } - //int psh = dw.handle(); - //dw.setPaperSpaceHandle(psh); - //dw.dxfHex(330, 1); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTableRecord" ); - dw.dxfString( 100, "AcDbBlockTableRecord" ); - } - dw.dxfString( 2, "*Paper_Space" ); - dw.dxfHex( 340, 0x1E ); + dw.dxfString( 0, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0x1B); + } + //int psh = dw.handle(); + //dw.setPaperSpaceHandle(psh); + //dw.dxfHex(330, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbBlockTableRecord"); + } + dw.dxfString( 2, "*Paper_Space"); + dw.dxfHex(340, 0x1E); - dw.dxfString( 0, "BLOCK_RECORD" ); - if ( version == VER_2000 ) - { - dw.dxfHex( 5, 0x23 ); - } - //int ps0h = dw.handle(); - //dw.setPaperSpace0Handle(ps0h); - //dw.dxfHex(330, 1); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTableRecord" ); - dw.dxfString( 100, "AcDbBlockTableRecord" ); - } - dw.dxfString( 2, "*Paper_Space0" ); - dw.dxfHex( 340, 0x26 ); + dw.dxfString( 0, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.dxfHex(5, 0x23); + } + //int ps0h = dw.handle(); + //dw.setPaperSpace0Handle(ps0h); + //dw.dxfHex(330, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbBlockTableRecord"); + } + dw.dxfString( 2, "*Paper_Space0"); + dw.dxfHex(340, 0x26); - //dw.dxfString( 0, "ENDTAB"); + //dw.dxfString( 0, "ENDTAB"); } @@ -4548,942 +4235,879 @@ void DL_Dxf::writeBlockRecord( DL_WriterA& dw ) /** * Writes a single block record with the given name. */ -void DL_Dxf::writeBlockRecord( DL_WriterA& dw, const string& name ) -{ - dw.dxfString( 0, "BLOCK_RECORD" ); - if ( version == VER_2000 ) - { - dw.handle(); - } - //dw->dxfHex(330, 1); - if ( version == VER_2000 ) - { - dw.dxfString( 100, "AcDbSymbolTableRecord" ); - dw.dxfString( 100, "AcDbBlockTableRecord" ); - } - dw.dxfString( 2, name ); - dw.dxfHex( 340, 0 ); +void DL_Dxf::writeBlockRecord(DL_WriterA& dw, const std::string& name) { + dw.dxfString( 0, "BLOCK_RECORD"); + if (version==DL_VERSION_2000) { + dw.handle(); + } + //dw->dxfHex(330, 1); + if (version==DL_VERSION_2000) { + dw.dxfString(100, "AcDbSymbolTableRecord"); + dw.dxfString(100, "AcDbBlockTableRecord"); + } + dw.dxfString( 2, name); + dw.dxfHex(340, 0); } /** - * Writes a objects section. This section is needed in VER_R13. + * Writes a objects section. This section is needed in DL_VERSION_R13. * Note that this method currently only writes a faked OBJECTS section * to make the file readable by Aut*cad. */ -void DL_Dxf::writeObjects( DL_WriterA& dw ) -{ - //int dicId, dicId2, dicId3, dicId4, dicId5; - //int dicId5; +void DL_Dxf::writeObjects(DL_WriterA& dw, const std::string& appDictionaryName) { + dw.dxfString( 0, "SECTION"); + dw.dxfString( 2, "OBJECTS"); - dw.dxfString( 0, "SECTION" ); - dw.dxfString( 2, "OBJECTS" ); - dw.dxfString( 0, "DICTIONARY" ); - dw.dxfHex( 5, 0xC ); // C - //dw.dxfHex(330, 0); - dw.dxfString( 100, "AcDbDictionary" ); - dw.dxfInt( 280, 0 ); - dw.dxfInt( 281, 1 ); - dw.dxfString( 3, "ACAD_GROUP" ); - //dw.dxfHex(350, dw.getNextHandle()); // D - dw.dxfHex( 350, 0xD ); // D - dw.dxfString( 3, "ACAD_LAYOUT" ); - dw.dxfHex( 350, 0x1A ); - //dw.dxfHex(350, dw.getNextHandle()+0); // 1A - dw.dxfString( 3, "ACAD_MLINESTYLE" ); - dw.dxfHex( 350, 0x17 ); - //dw.dxfHex(350, dw.getNextHandle()+1); // 17 - dw.dxfString( 3, "ACAD_PLOTSETTINGS" ); - dw.dxfHex( 350, 0x19 ); - //dw.dxfHex(350, dw.getNextHandle()+2); // 19 - dw.dxfString( 3, "ACAD_PLOTSTYLENAME" ); - dw.dxfHex( 350, 0xE ); - //dw.dxfHex(350, dw.getNextHandle()+3); // E - dw.dxfString( 3, "AcDbVariableDictionary" ); - dw.dxfHex( 350, dw.getNextHandle() ); // 2C - dw.dxfString( 0, "DICTIONARY" ); - dw.dxfHex( 5, 0xD ); - //dw.handle(); // D - //dw.dxfHex(330, 0xC); - dw.dxfString( 100, "AcDbDictionary" ); - dw.dxfInt( 280, 0 ); - dw.dxfInt( 281, 1 ); - dw.dxfString( 0, "ACDBDICTIONARYWDFLT" ); - dw.dxfHex( 5, 0xE ); - //dicId4 = dw.handle(); // E - //dw.dxfHex(330, 0xC); // C - dw.dxfString( 100, "AcDbDictionary" ); - dw.dxfInt( 281, 1 ); - dw.dxfString( 3, "Normal" ); - dw.dxfHex( 350, 0xF ); - //dw.dxfHex(350, dw.getNextHandle()+5); // F - dw.dxfString( 100, "AcDbDictionaryWithDefault" ); - dw.dxfHex( 340, 0xF ); - //dw.dxfHex(340, dw.getNextHandle()+5); // F - dw.dxfString( 0, "ACDBPLACEHOLDER" ); - dw.dxfHex( 5, 0xF ); - //dw.handle(); // F - //dw.dxfHex(330, dicId4); // E - dw.dxfString( 0, "DICTIONARY" ); - //dicId3 = dw.handle(); // 17 - dw.dxfHex( 5, 0x17 ); - //dw.dxfHex(330, 0xC); // C - dw.dxfString( 100, "AcDbDictionary" ); - dw.dxfInt( 280, 0 ); - dw.dxfInt( 281, 1 ); - dw.dxfString( 3, "Standard" ); - dw.dxfHex( 350, 0x18 ); - //dw.dxfHex(350, dw.getNextHandle()+5); // 18 - dw.dxfString( 0, "MLINESTYLE" ); - dw.dxfHex( 5, 0x18 ); - //dw.handle(); // 18 - //dw.dxfHex(330, dicId3); // 17 - dw.dxfString( 100, "AcDbMlineStyle" ); - dw.dxfString( 2, "STANDARD" ); - dw.dxfInt( 70, 0 ); - dw.dxfString( 3, "" ); - dw.dxfInt( 62, 256 ); - dw.dxfReal( 51, 90.0 ); - dw.dxfReal( 52, 90.0 ); - dw.dxfInt( 71, 2 ); - dw.dxfReal( 49, 0.5 ); - dw.dxfInt( 62, 256 ); - dw.dxfString( 6, "BYLAYER" ); - dw.dxfReal( 49, -0.5 ); - dw.dxfInt( 62, 256 ); - dw.dxfString( 6, "BYLAYER" ); - dw.dxfString( 0, "DICTIONARY" ); - dw.dxfHex( 5, 0x19 ); - //dw.handle(); // 17 - //dw.dxfHex(330, 0xC); // C - dw.dxfString( 100, "AcDbDictionary" ); - dw.dxfInt( 280, 0 ); - dw.dxfInt( 281, 1 ); - dw.dxfString( 0, "DICTIONARY" ); - //dicId2 = dw.handle(); // 1A - dw.dxfHex( 5, 0x1A ); - //dw.dxfHex(330, 0xC); - dw.dxfString( 100, "AcDbDictionary" ); - dw.dxfInt( 281, 1 ); - dw.dxfString( 3, "Layout1" ); - dw.dxfHex( 350, 0x1E ); - //dw.dxfHex(350, dw.getNextHandle()+2); // 1E - dw.dxfString( 3, "Layout2" ); - dw.dxfHex( 350, 0x26 ); - //dw.dxfHex(350, dw.getNextHandle()+4); // 26 - dw.dxfString( 3, "Model" ); - dw.dxfHex( 350, 0x22 ); - //dw.dxfHex(350, dw.getNextHandle()+5); // 22 - dw.dxfString( 0, "LAYOUT" ); - dw.dxfHex( 5, 0x1E ); - //dw.handle(); // 1E - //dw.dxfHex(330, dicId2); // 1A - dw.dxfString( 100, "AcDbPlotSettings" ); - dw.dxfString( 1, "" ); - dw.dxfString( 2, "C:\\Program Files\\AutoCAD 2002\\plotters\\DWF ePlot (optimized for plotting).pc3" ); - dw.dxfString( 4, "" ); - dw.dxfString( 6, "" ); - dw.dxfReal( 40, 0.0 ); - dw.dxfReal( 41, 0.0 ); - dw.dxfReal( 42, 0.0 ); - dw.dxfReal( 43, 0.0 ); - dw.dxfReal( 44, 0.0 ); - dw.dxfReal( 45, 0.0 ); - dw.dxfReal( 46, 0.0 ); - dw.dxfReal( 47, 0.0 ); - dw.dxfReal( 48, 0.0 ); - dw.dxfReal( 49, 0.0 ); - dw.dxfReal( 140, 0.0 ); - dw.dxfReal( 141, 0.0 ); - dw.dxfReal( 142, 1.0 ); - dw.dxfReal( 143, 1.0 ); - dw.dxfInt( 70, 688 ); - dw.dxfInt( 72, 0 ); - dw.dxfInt( 73, 0 ); - dw.dxfInt( 74, 5 ); - dw.dxfString( 7, "" ); - dw.dxfInt( 75, 16 ); - dw.dxfReal( 147, 1.0 ); - dw.dxfReal( 148, 0.0 ); - dw.dxfReal( 149, 0.0 ); - dw.dxfString( 100, "AcDbLayout" ); - dw.dxfString( 1, "Layout1" ); - dw.dxfInt( 70, 1 ); - dw.dxfInt( 71, 1 ); - dw.dxfReal( 10, 0.0 ); - dw.dxfReal( 20, 0.0 ); - dw.dxfReal( 11, 420.0 ); - dw.dxfReal( 21, 297.0 ); - dw.dxfReal( 12, 0.0 ); - dw.dxfReal( 22, 0.0 ); - dw.dxfReal( 32, 0.0 ); - dw.dxfReal( 14, 1.000000000000000E+20 ); - dw.dxfReal( 24, 1.000000000000000E+20 ); - dw.dxfReal( 34, 1.000000000000000E+20 ); - dw.dxfReal( 15, -1.000000000000000E+20 ); - dw.dxfReal( 25, -1.000000000000000E+20 ); - dw.dxfReal( 35, -1.000000000000000E+20 ); - dw.dxfReal( 146, 0.0 ); - dw.dxfReal( 13, 0.0 ); - dw.dxfReal( 23, 0.0 ); - dw.dxfReal( 33, 0.0 ); - dw.dxfReal( 16, 1.0 ); - dw.dxfReal( 26, 0.0 ); - dw.dxfReal( 36, 0.0 ); - dw.dxfReal( 17, 0.0 ); - dw.dxfReal( 27, 1.0 ); - dw.dxfReal( 37, 0.0 ); - dw.dxfInt( 76, 0 ); - //dw.dxfHex(330, dw.getPaperSpaceHandle()); // 1B - dw.dxfHex( 330, 0x1B ); - dw.dxfString( 0, "LAYOUT" ); - dw.dxfHex( 5, 0x22 ); - //dw.handle(); // 22 - //dw.dxfHex(330, dicId2); // 1A - dw.dxfString( 100, "AcDbPlotSettings" ); - dw.dxfString( 1, "" ); - dw.dxfString( 2, "C:\\Program Files\\AutoCAD 2002\\plotters\\DWF ePlot (optimized for plotting).pc3" ); - dw.dxfString( 4, "" ); - dw.dxfString( 6, "" ); - dw.dxfReal( 40, 0.0 ); - dw.dxfReal( 41, 0.0 ); - dw.dxfReal( 42, 0.0 ); - dw.dxfReal( 43, 0.0 ); - dw.dxfReal( 44, 0.0 ); - dw.dxfReal( 45, 0.0 ); - dw.dxfReal( 46, 0.0 ); - dw.dxfReal( 47, 0.0 ); - dw.dxfReal( 48, 0.0 ); - dw.dxfReal( 49, 0.0 ); - dw.dxfReal( 140, 0.0 ); - dw.dxfReal( 141, 0.0 ); - dw.dxfReal( 142, 1.0 ); - dw.dxfReal( 143, 1.0 ); - dw.dxfInt( 70, 1712 ); - dw.dxfInt( 72, 0 ); - dw.dxfInt( 73, 0 ); - dw.dxfInt( 74, 0 ); - dw.dxfString( 7, "" ); - dw.dxfInt( 75, 0 ); - dw.dxfReal( 147, 1.0 ); - dw.dxfReal( 148, 0.0 ); - dw.dxfReal( 149, 0.0 ); - dw.dxfString( 100, "AcDbLayout" ); - dw.dxfString( 1, "Model" ); - dw.dxfInt( 70, 1 ); - dw.dxfInt( 71, 0 ); - dw.dxfReal( 10, 0.0 ); - dw.dxfReal( 20, 0.0 ); - dw.dxfReal( 11, 12.0 ); - dw.dxfReal( 21, 9.0 ); - dw.dxfReal( 12, 0.0 ); - dw.dxfReal( 22, 0.0 ); - dw.dxfReal( 32, 0.0 ); - dw.dxfReal( 14, 0.0 ); - dw.dxfReal( 24, 0.0 ); - dw.dxfReal( 34, 0.0 ); - dw.dxfReal( 15, 0.0 ); - dw.dxfReal( 25, 0.0 ); - dw.dxfReal( 35, 0.0 ); - dw.dxfReal( 146, 0.0 ); - dw.dxfReal( 13, 0.0 ); - dw.dxfReal( 23, 0.0 ); - dw.dxfReal( 33, 0.0 ); - dw.dxfReal( 16, 1.0 ); - dw.dxfReal( 26, 0.0 ); - dw.dxfReal( 36, 0.0 ); - dw.dxfReal( 17, 0.0 ); - dw.dxfReal( 27, 1.0 ); - dw.dxfReal( 37, 0.0 ); - dw.dxfInt( 76, 0 ); - //dw.dxfHex(330, dw.getModelSpaceHandle()); // 1F - dw.dxfHex( 330, 0x1F ); - dw.dxfString( 0, "LAYOUT" ); - //dw.handle(); // 26 - dw.dxfHex( 5, 0x26 ); - //dw.dxfHex(330, dicId2); // 1A - dw.dxfString( 100, "AcDbPlotSettings" ); - dw.dxfString( 1, "" ); - dw.dxfString( 2, "C:\\Program Files\\AutoCAD 2002\\plotters\\DWF ePlot (optimized for plotting).pc3" ); - dw.dxfString( 4, "" ); - dw.dxfString( 6, "" ); - dw.dxfReal( 40, 0.0 ); - dw.dxfReal( 41, 0.0 ); - dw.dxfReal( 42, 0.0 ); - dw.dxfReal( 43, 0.0 ); - dw.dxfReal( 44, 0.0 ); - dw.dxfReal( 45, 0.0 ); - dw.dxfReal( 46, 0.0 ); - dw.dxfReal( 47, 0.0 ); - dw.dxfReal( 48, 0.0 ); - dw.dxfReal( 49, 0.0 ); - dw.dxfReal( 140, 0.0 ); - dw.dxfReal( 141, 0.0 ); - dw.dxfReal( 142, 1.0 ); - dw.dxfReal( 143, 1.0 ); - dw.dxfInt( 70, 688 ); - dw.dxfInt( 72, 0 ); - dw.dxfInt( 73, 0 ); - dw.dxfInt( 74, 5 ); - dw.dxfString( 7, "" ); - dw.dxfInt( 75, 16 ); - dw.dxfReal( 147, 1.0 ); - dw.dxfReal( 148, 0.0 ); - dw.dxfReal( 149, 0.0 ); - dw.dxfString( 100, "AcDbLayout" ); - dw.dxfString( 1, "Layout2" ); - dw.dxfInt( 70, 1 ); - dw.dxfInt( 71, 2 ); - dw.dxfReal( 10, 0.0 ); - dw.dxfReal( 20, 0.0 ); - dw.dxfReal( 11, 12.0 ); - dw.dxfReal( 21, 9.0 ); - dw.dxfReal( 12, 0.0 ); - dw.dxfReal( 22, 0.0 ); - dw.dxfReal( 32, 0.0 ); - dw.dxfReal( 14, 0.0 ); - dw.dxfReal( 24, 0.0 ); - dw.dxfReal( 34, 0.0 ); - dw.dxfReal( 15, 0.0 ); - dw.dxfReal( 25, 0.0 ); - dw.dxfReal( 35, 0.0 ); - dw.dxfReal( 146, 0.0 ); - dw.dxfReal( 13, 0.0 ); - dw.dxfReal( 23, 0.0 ); - dw.dxfReal( 33, 0.0 ); - dw.dxfReal( 16, 1.0 ); - dw.dxfReal( 26, 0.0 ); - dw.dxfReal( 36, 0.0 ); - dw.dxfReal( 17, 0.0 ); - dw.dxfReal( 27, 1.0 ); - dw.dxfReal( 37, 0.0 ); - dw.dxfInt( 76, 0 ); - //dw.dxfHex(330, dw.getPaperSpace0Handle()); // 23 - dw.dxfHex( 330, 0x23 ); - dw.dxfString( 0, "DICTIONARY" ); - //dw.dxfHex(5, 0x2C); - //dicId5 = - dw.handle(); // 2C - //dw.dxfHex(330, 0xC); // C - dw.dxfString( 100, "AcDbDictionary" ); - dw.dxfInt( 281, 1 ); - dw.dxfString( 3, "DIMASSOC" ); - //dw.dxfHex(350, 0x2F); - dw.dxfHex( 350, dw.getNextHandle() + 1 ); // 2E - dw.dxfString( 3, "HIDETEXT" ); - //dw.dxfHex(350, 0x2E); - dw.dxfHex( 350, dw.getNextHandle() ); // 2D - dw.dxfString( 0, "DICTIONARYVAR" ); - //dw.dxfHex(5, 0x2E); - dw.handle(); // 2E - //dw.dxfHex(330, dicId5); // 2C - dw.dxfString( 100, "DictionaryVariables" ); - dw.dxfInt( 280, 0 ); - dw.dxfInt( 1, 2 ); - dw.dxfString( 0, "DICTIONARYVAR" ); - //dw.dxfHex(5, 0x2D); - dw.handle(); // 2D - //dw.dxfHex(330, dicId5); // 2C - dw.dxfString( 100, "DictionaryVariables" ); - dw.dxfInt( 280, 0 ); - dw.dxfInt( 1, 1 ); + dw.dxfString( 0, "DICTIONARY"); + dw.dxfHex(5, 0xC); + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(280, 0); + dw.dxfInt(281, 1); + dw.dxfString( 3, "ACAD_GROUP"); + dw.dxfHex(350, 0xD); + dw.dxfString( 3, "ACAD_LAYOUT"); + dw.dxfHex(350, 0x1A); + dw.dxfString( 3, "ACAD_MLINESTYLE"); + dw.dxfHex(350, 0x17); + dw.dxfString( 3, "ACAD_PLOTSETTINGS"); + dw.dxfHex(350, 0x19); + dw.dxfString( 3, "ACAD_PLOTSTYLENAME"); + dw.dxfHex(350, 0xE); + dw.dxfString( 3, "AcDbVariableDictionary"); + int acDbVariableDictionaryHandle = dw.handle(350); + //int acDbVariableDictionaryHandle = dw.getNextHandle(); + //dw.dxfHex(350, acDbVariableDictionaryHandle); + //dw.incHandle(); + + if (appDictionaryName.length()!=0) { + dw.dxfString( 3, appDictionaryName); + appDictionaryHandle = dw.handle(350); + //appDictionaryHandle = dw.getNextHandle(); + //dw.dxfHex(350, appDictionaryHandle); + //dw.incHandle(); + } + + dw.dxfString( 0, "DICTIONARY"); + dw.dxfHex(5, 0xD); + //dw.handle(); // D + //dw.dxfHex(330, 0xC); + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(280, 0); + dw.dxfInt(281, 1); + + + dw.dxfString( 0, "ACDBDICTIONARYWDFLT"); + dw.dxfHex(5, 0xE); + //dicId4 = dw.handle(); // E + //dw.dxfHex(330, 0xC); // C + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(281, 1); + dw.dxfString( 3, "Normal"); + dw.dxfHex(350, 0xF); + //dw.dxfHex(350, dw.getNextHandle()+5); // F + dw.dxfString(100, "AcDbDictionaryWithDefault"); + dw.dxfHex(340, 0xF); + //dw.dxfHex(340, dw.getNextHandle()+5); // F + + + dw.dxfString( 0, "ACDBPLACEHOLDER"); + dw.dxfHex(5, 0xF); + //dw.handle(); // F + //dw.dxfHex(330, dicId4); // E + + + dw.dxfString( 0, "DICTIONARY"); + //dicId3 = dw.handle(); // 17 + dw.dxfHex(5, 0x17); + //dw.dxfHex(330, 0xC); // C + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(280, 0); + dw.dxfInt(281, 1); + dw.dxfString( 3, "Standard"); + dw.dxfHex(350, 0x18); + //dw.dxfHex(350, dw.getNextHandle()+5); // 18 + + + dw.dxfString( 0, "MLINESTYLE"); + dw.dxfHex(5, 0x18); + //dw.handle(); // 18 + //dw.dxfHex(330, dicId3); // 17 + dw.dxfString(100, "AcDbMlineStyle"); + dw.dxfString( 2, "STANDARD"); + dw.dxfInt( 70, 0); + dw.dxfString( 3, ""); + dw.dxfInt( 62, 256); + dw.dxfReal( 51, 90.0); + dw.dxfReal( 52, 90.0); + dw.dxfInt( 71, 2); + dw.dxfReal( 49, 0.5); + dw.dxfInt( 62, 256); + dw.dxfString( 6, "BYLAYER"); + dw.dxfReal( 49, -0.5); + dw.dxfInt( 62, 256); + dw.dxfString( 6, "BYLAYER"); + + + dw.dxfString( 0, "DICTIONARY"); + dw.dxfHex(5, 0x19); + //dw.handle(); // 17 + //dw.dxfHex(330, 0xC); // C + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(280, 0); + dw.dxfInt(281, 1); + + + dw.dxfString( 0, "DICTIONARY"); + //dicId2 = dw.handle(); // 1A + dw.dxfHex(5, 0x1A); + //dw.dxfHex(330, 0xC); + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(281, 1); + dw.dxfString( 3, "Layout1"); + dw.dxfHex(350, 0x1E); + //dw.dxfHex(350, dw.getNextHandle()+2); // 1E + dw.dxfString( 3, "Layout2"); + dw.dxfHex(350, 0x26); + //dw.dxfHex(350, dw.getNextHandle()+4); // 26 + dw.dxfString( 3, "Model"); + dw.dxfHex(350, 0x22); + //dw.dxfHex(350, dw.getNextHandle()+5); // 22 + + + dw.dxfString( 0, "LAYOUT"); + dw.dxfHex(5, 0x1E); + //dw.handle(); // 1E + //dw.dxfHex(330, dicId2); // 1A + dw.dxfString(100, "AcDbPlotSettings"); + dw.dxfString( 1, ""); + dw.dxfString( 2, "none_device"); + dw.dxfString( 4, ""); + dw.dxfString( 6, ""); + dw.dxfReal( 40, 0.0); + dw.dxfReal( 41, 0.0); + dw.dxfReal( 42, 0.0); + dw.dxfReal( 43, 0.0); + dw.dxfReal( 44, 0.0); + dw.dxfReal( 45, 0.0); + dw.dxfReal( 46, 0.0); + dw.dxfReal( 47, 0.0); + dw.dxfReal( 48, 0.0); + dw.dxfReal( 49, 0.0); + dw.dxfReal(140, 0.0); + dw.dxfReal(141, 0.0); + dw.dxfReal(142, 1.0); + dw.dxfReal(143, 1.0); + dw.dxfInt( 70, 688); + dw.dxfInt( 72, 0); + dw.dxfInt( 73, 0); + dw.dxfInt( 74, 5); + dw.dxfString( 7, ""); + dw.dxfInt( 75, 16); + dw.dxfReal(147, 1.0); + dw.dxfReal(148, 0.0); + dw.dxfReal(149, 0.0); + dw.dxfString(100, "AcDbLayout"); + dw.dxfString( 1, "Layout1"); + dw.dxfInt( 70, 1); + dw.dxfInt( 71, 1); + dw.dxfReal( 10, 0.0); + dw.dxfReal( 20, 0.0); + dw.dxfReal( 11, 420.0); + dw.dxfReal( 21, 297.0); + dw.dxfReal( 12, 0.0); + dw.dxfReal( 22, 0.0); + dw.dxfReal( 32, 0.0); + dw.dxfReal( 14, 1.000000000000000E+20); + dw.dxfReal( 24, 1.000000000000000E+20); + dw.dxfReal( 34, 1.000000000000000E+20); + dw.dxfReal( 15, -1.000000000000000E+20); + dw.dxfReal( 25, -1.000000000000000E+20); + dw.dxfReal( 35, -1.000000000000000E+20); + dw.dxfReal(146, 0.0); + dw.dxfReal( 13, 0.0); + dw.dxfReal( 23, 0.0); + dw.dxfReal( 33, 0.0); + dw.dxfReal( 16, 1.0); + dw.dxfReal( 26, 0.0); + dw.dxfReal( 36, 0.0); + dw.dxfReal( 17, 0.0); + dw.dxfReal( 27, 1.0); + dw.dxfReal( 37, 0.0); + dw.dxfInt( 76, 0); + //dw.dxfHex(330, dw.getPaperSpaceHandle()); // 1B + dw.dxfHex(330, 0x1B); + + + dw.dxfString( 0, "LAYOUT"); + dw.dxfHex(5, 0x22); + //dw.handle(); // 22 + //dw.dxfHex(330, dicId2); // 1A + dw.dxfString(100, "AcDbPlotSettings"); + dw.dxfString( 1, ""); + dw.dxfString( 2, "none_device"); + dw.dxfString( 4, ""); + dw.dxfString( 6, ""); + dw.dxfReal( 40, 0.0); + dw.dxfReal( 41, 0.0); + dw.dxfReal( 42, 0.0); + dw.dxfReal( 43, 0.0); + dw.dxfReal( 44, 0.0); + dw.dxfReal( 45, 0.0); + dw.dxfReal( 46, 0.0); + dw.dxfReal( 47, 0.0); + dw.dxfReal( 48, 0.0); + dw.dxfReal( 49, 0.0); + dw.dxfReal(140, 0.0); + dw.dxfReal(141, 0.0); + dw.dxfReal(142, 1.0); + dw.dxfReal(143, 1.0); + dw.dxfInt( 70, 1712); + dw.dxfInt( 72, 0); + dw.dxfInt( 73, 0); + dw.dxfInt( 74, 0); + dw.dxfString( 7, ""); + dw.dxfInt( 75, 0); + dw.dxfReal(147, 1.0); + dw.dxfReal(148, 0.0); + dw.dxfReal(149, 0.0); + dw.dxfString(100, "AcDbLayout"); + dw.dxfString( 1, "Model"); + dw.dxfInt( 70, 1); + dw.dxfInt( 71, 0); + dw.dxfReal( 10, 0.0); + dw.dxfReal( 20, 0.0); + dw.dxfReal( 11, 12.0); + dw.dxfReal( 21, 9.0); + dw.dxfReal( 12, 0.0); + dw.dxfReal( 22, 0.0); + dw.dxfReal( 32, 0.0); + dw.dxfReal( 14, 0.0); + dw.dxfReal( 24, 0.0); + dw.dxfReal( 34, 0.0); + dw.dxfReal( 15, 0.0); + dw.dxfReal( 25, 0.0); + dw.dxfReal( 35, 0.0); + dw.dxfReal(146, 0.0); + dw.dxfReal( 13, 0.0); + dw.dxfReal( 23, 0.0); + dw.dxfReal( 33, 0.0); + dw.dxfReal( 16, 1.0); + dw.dxfReal( 26, 0.0); + dw.dxfReal( 36, 0.0); + dw.dxfReal( 17, 0.0); + dw.dxfReal( 27, 1.0); + dw.dxfReal( 37, 0.0); + dw.dxfInt( 76, 0); + //dw.dxfHex(330, dw.getModelSpaceHandle()); // 1F + dw.dxfHex(330, 0x1F); + + + dw.dxfString( 0, "LAYOUT"); + //dw.handle(); // 26 + dw.dxfHex(5, 0x26); + //dw.dxfHex(330, dicId2); // 1A + dw.dxfString(100, "AcDbPlotSettings"); + dw.dxfString( 1, ""); + dw.dxfString( 2, "none_device"); + dw.dxfString( 4, ""); + dw.dxfString( 6, ""); + dw.dxfReal( 40, 0.0); + dw.dxfReal( 41, 0.0); + dw.dxfReal( 42, 0.0); + dw.dxfReal( 43, 0.0); + dw.dxfReal( 44, 0.0); + dw.dxfReal( 45, 0.0); + dw.dxfReal( 46, 0.0); + dw.dxfReal( 47, 0.0); + dw.dxfReal( 48, 0.0); + dw.dxfReal( 49, 0.0); + dw.dxfReal(140, 0.0); + dw.dxfReal(141, 0.0); + dw.dxfReal(142, 1.0); + dw.dxfReal(143, 1.0); + dw.dxfInt( 70, 688); + dw.dxfInt( 72, 0); + dw.dxfInt( 73, 0); + dw.dxfInt( 74, 5); + dw.dxfString( 7, ""); + dw.dxfInt( 75, 16); + dw.dxfReal(147, 1.0); + dw.dxfReal(148, 0.0); + dw.dxfReal(149, 0.0); + dw.dxfString(100, "AcDbLayout"); + dw.dxfString( 1, "Layout2"); + dw.dxfInt( 70, 1); + dw.dxfInt( 71, 2); + dw.dxfReal( 10, 0.0); + dw.dxfReal( 20, 0.0); + dw.dxfReal( 11, 12.0); + dw.dxfReal( 21, 9.0); + dw.dxfReal( 12, 0.0); + dw.dxfReal( 22, 0.0); + dw.dxfReal( 32, 0.0); + dw.dxfReal( 14, 0.0); + dw.dxfReal( 24, 0.0); + dw.dxfReal( 34, 0.0); + dw.dxfReal( 15, 0.0); + dw.dxfReal( 25, 0.0); + dw.dxfReal( 35, 0.0); + dw.dxfReal(146, 0.0); + dw.dxfReal( 13, 0.0); + dw.dxfReal( 23, 0.0); + dw.dxfReal( 33, 0.0); + dw.dxfReal( 16, 1.0); + dw.dxfReal( 26, 0.0); + dw.dxfReal( 36, 0.0); + dw.dxfReal( 17, 0.0); + dw.dxfReal( 27, 1.0); + dw.dxfReal( 37, 0.0); + dw.dxfInt( 76, 0); + //dw.dxfHex(330, dw.getPaperSpace0Handle()); // 23 + dw.dxfHex(330, 0x23); + + dw.dxfString( 0, "DICTIONARY"); + //dw.dxfHex(5, 0x2C); + //dicId5 = + dw.dxfHex(5, acDbVariableDictionaryHandle); + //dw.handle(); // 2C + //dw.dxfHex(330, 0xC); // C + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(281, 1); + dw.dxfString( 3, "DIMASSOC"); + //dw.dxfHex(350, 0x2F); + dw.dxfHex(350, dw.getNextHandle()+1); // 2E + dw.dxfString( 3, "HIDETEXT"); + //dw.dxfHex(350, 0x2E); + dw.dxfHex(350, dw.getNextHandle()); // 2D + + + dw.dxfString( 0, "DICTIONARYVAR"); + //dw.dxfHex(5, 0x2E); + dw.handle(); // 2E + //dw.dxfHex(330, dicId5); // 2C + dw.dxfString(100, "DictionaryVariables"); + dw.dxfInt(280, 0); + dw.dxfInt( 1, 2); + + + dw.dxfString( 0, "DICTIONARYVAR"); + //dw.dxfHex(5, 0x2D); + dw.handle(); // 2D + //dw.dxfHex(330, dicId5); // 2C + dw.dxfString(100, "DictionaryVariables"); + dw.dxfInt(280, 0); + dw.dxfInt( 1, 1); } +void DL_Dxf::writeAppDictionary(DL_WriterA& dw) { + dw.dxfString( 0, "DICTIONARY"); + //dw.handle(); + dw.dxfHex(5, appDictionaryHandle); + dw.dxfString(100, "AcDbDictionary"); + dw.dxfInt(281, 1); +} + +int DL_Dxf::writeDictionaryEntry(DL_WriterA& dw, const std::string& name) { + dw.dxfString( 3, name); + int handle = dw.getNextHandle(); + dw.dxfHex(350, handle); + dw.incHandle(); + return handle; +} + +void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, int value) { + dw.dxfString( 0, "XRECORD"); + dw.dxfHex(5, handle); + dw.dxfHex(330, appDictionaryHandle); + dw.dxfString(100, "AcDbXrecord"); + dw.dxfInt(280, 1); + dw.dxfInt(90, value); +} + +void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, double value) { + dw.dxfString( 0, "XRECORD"); + dw.dxfHex(5, handle); + dw.dxfHex(330, appDictionaryHandle); + dw.dxfString(100, "AcDbXrecord"); + dw.dxfInt(280, 1); + dw.dxfReal(40, value); +} + +void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, bool value) { + dw.dxfString( 0, "XRECORD"); + dw.dxfHex(5, handle); + dw.dxfHex(330, appDictionaryHandle); + dw.dxfString(100, "AcDbXrecord"); + dw.dxfInt(280, 1); + dw.dxfBool(290, value); +} + +void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, const std::string& value) { + dw.dxfString( 0, "XRECORD"); + dw.dxfHex(5, handle); + dw.dxfHex(330, appDictionaryHandle); + dw.dxfString(100, "AcDbXrecord"); + dw.dxfInt(280, 1); + dw.dxfString(1000, value); +} /** - * Writes the end of the objects section. This section is needed in VER_R13. + * Writes the end of the objects section. This section is needed in DL_VERSION_R13. * Note that this method currently only writes a faked OBJECTS section * to make the file readable by Aut*cad. */ -void DL_Dxf::writeObjectsEnd( DL_WriterA& dw ) -{ - dw.dxfString( 0, "ENDSEC" ); +void DL_Dxf::writeObjectsEnd(DL_WriterA& dw) { + dw.dxfString( 0, "ENDSEC"); } + + +/** + * Writes a comment to the DXF file. + */ +void DL_Dxf::writeComment(DL_WriterA& dw, const std::string& comment) { + dw.dxfString(999, comment); +} /** * Checks if the given variable is known by the given DXF version. */ -bool DL_Dxf::checkVariable( const char* var, DL_Codes::version version ) -{ - if ( version >= VER_2000 ) - { - return true; - } - else if ( version == VER_R12 ) - { - // these are all the variables recognized by dxf r12: - if ( !strcmp( var, "$ACADVER" ) ) - { - return true; +bool DL_Dxf::checkVariable(const char* var, DL_Codes::version version) { + if (version>=DL_VERSION_2000) { + return true; + } else if (version==DL_VERSION_R12) { + // these are all the variables recognized by dxf r12: + if (!strcmp(var, "$ACADVER")) { + return true; + } + if (!strcmp(var, "$ACADVER")) { + return true; + } + if (!strcmp(var, "$ANGBASE")) { + return true; + } + if (!strcmp(var, "$ANGDIR")) { + return true; + } + if (!strcmp(var, "$ATTDIA")) { + return true; + } + if (!strcmp(var, "$ATTMODE")) { + return true; + } + if (!strcmp(var, "$ATTREQ")) { + return true; + } + if (!strcmp(var, "$AUNITS")) { + return true; + } + if (!strcmp(var, "$AUPREC")) { + return true; + } + if (!strcmp(var, "$AXISMODE")) { + return true; + } + if (!strcmp(var, "$AXISUNIT")) { + return true; + } + if (!strcmp(var, "$BLIPMODE")) { + return true; + } + if (!strcmp(var, "$CECOLOR")) { + return true; + } + if (!strcmp(var, "$CELTYPE")) { + return true; + } + if (!strcmp(var, "$CHAMFERA")) { + return true; + } + if (!strcmp(var, "$CHAMFERB")) { + return true; + } + if (!strcmp(var, "$CLAYER")) { + return true; + } + if (!strcmp(var, "$COORDS")) { + return true; + } + if (!strcmp(var, "$DIMALT")) { + return true; + } + if (!strcmp(var, "$DIMALTD")) { + return true; + } + if (!strcmp(var, "$DIMALTF")) { + return true; + } + if (!strcmp(var, "$DIMAPOST")) { + return true; + } + if (!strcmp(var, "$DIMASO")) { + return true; + } + if (!strcmp(var, "$DIMASZ")) { + return true; + } + if (!strcmp(var, "$DIMBLK")) { + return true; + } + if (!strcmp(var, "$DIMBLK1")) { + return true; + } + if (!strcmp(var, "$DIMBLK2")) { + return true; + } + if (!strcmp(var, "$DIMCEN")) { + return true; + } + if (!strcmp(var, "$DIMCLRD")) { + return true; + } + if (!strcmp(var, "$DIMCLRE")) { + return true; + } + if (!strcmp(var, "$DIMCLRT")) { + return true; + } + if (!strcmp(var, "$DIMDLE")) { + return true; + } + if (!strcmp(var, "$DIMDLI")) { + return true; + } + if (!strcmp(var, "$DIMEXE")) { + return true; + } + if (!strcmp(var, "$DIMEXO")) { + return true; + } + if (!strcmp(var, "$DIMGAP")) { + return true; + } + if (!strcmp(var, "$DIMLFAC")) { + return true; + } + if (!strcmp(var, "$DIMLIM")) { + return true; + } + if (!strcmp(var, "$DIMPOST")) { + return true; + } + if (!strcmp(var, "$DIMRND")) { + return true; + } + if (!strcmp(var, "$DIMSAH")) { + return true; + } + if (!strcmp(var, "$DIMSCALE")) { + return true; + } + if (!strcmp(var, "$DIMSE1")) { + return true; + } + if (!strcmp(var, "$DIMSE2")) { + return true; + } + if (!strcmp(var, "$DIMSHO")) { + return true; + } + if (!strcmp(var, "$DIMSOXD")) { + return true; + } + if (!strcmp(var, "$DIMSTYLE")) { + return true; + } + if (!strcmp(var, "$DIMTAD")) { + return true; + } + if (!strcmp(var, "$DIMTFAC")) { + return true; + } + if (!strcmp(var, "$DIMTIH")) { + return true; + } + if (!strcmp(var, "$DIMTIX")) { + return true; + } + if (!strcmp(var, "$DIMTM")) { + return true; + } + if (!strcmp(var, "$DIMTOFL")) { + return true; + } + if (!strcmp(var, "$DIMTOH")) { + return true; + } + if (!strcmp(var, "$DIMTOL")) { + return true; + } + if (!strcmp(var, "$DIMTP")) { + return true; + } + if (!strcmp(var, "$DIMTSZ")) { + return true; + } + if (!strcmp(var, "$DIMTVP")) { + return true; + } + if (!strcmp(var, "$DIMTXT")) { + return true; + } + if (!strcmp(var, "$DIMZIN")) { + return true; + } + if (!strcmp(var, "$DWGCODEPAGE")) { + return true; + } + if (!strcmp(var, "$DRAGMODE")) { + return true; + } + if (!strcmp(var, "$ELEVATION")) { + return true; + } + if (!strcmp(var, "$EXTMAX")) { + return true; + } + if (!strcmp(var, "$EXTMIN")) { + return true; + } + if (!strcmp(var, "$FILLETRAD")) { + return true; + } + if (!strcmp(var, "$FILLMODE")) { + return true; + } + if (!strcmp(var, "$HANDLING")) { + return true; + } + if (!strcmp(var, "$HANDSEED")) { + return true; + } + if (!strcmp(var, "$INSBASE")) { + return true; + } + if (!strcmp(var, "$LIMCHECK")) { + return true; + } + if (!strcmp(var, "$LIMMAX")) { + return true; + } + if (!strcmp(var, "$LIMMIN")) { + return true; + } + if (!strcmp(var, "$LTSCALE")) { + return true; + } + if (!strcmp(var, "$LUNITS")) { + return true; + } + if (!strcmp(var, "$LUPREC")) { + return true; + } + if (!strcmp(var, "$MAXACTVP")) { + return true; + } + if (!strcmp(var, "$MENU")) { + return true; + } + if (!strcmp(var, "$MIRRTEXT")) { + return true; + } + if (!strcmp(var, "$ORTHOMODE")) { + return true; + } + if (!strcmp(var, "$OSMODE")) { + return true; + } + if (!strcmp(var, "$PDMODE")) { + return true; + } + if (!strcmp(var, "$PDSIZE")) { + return true; + } + if (!strcmp(var, "$PELEVATION")) { + return true; + } + if (!strcmp(var, "$PEXTMAX")) { + return true; + } + if (!strcmp(var, "$PEXTMIN")) { + return true; + } + if (!strcmp(var, "$PLIMCHECK")) { + return true; + } + if (!strcmp(var, "$PLIMMAX")) { + return true; + } + if (!strcmp(var, "$PLIMMIN")) { + return true; + } + if (!strcmp(var, "$PLINEGEN")) { + return true; + } + if (!strcmp(var, "$PLINEWID")) { + return true; + } + if (!strcmp(var, "$PSLTSCALE")) { + return true; + } + if (!strcmp(var, "$PUCSNAME")) { + return true; + } + if (!strcmp(var, "$PUCSORG")) { + return true; + } + if (!strcmp(var, "$PUCSXDIR")) { + return true; + } + if (!strcmp(var, "$PUCSYDIR")) { + return true; + } + if (!strcmp(var, "$QTEXTMODE")) { + return true; + } + if (!strcmp(var, "$REGENMODE")) { + return true; + } + if (!strcmp(var, "$SHADEDGE")) { + return true; + } + if (!strcmp(var, "$SHADEDIF")) { + return true; + } + if (!strcmp(var, "$SKETCHINC")) { + return true; + } + if (!strcmp(var, "$SKPOLY")) { + return true; + } + if (!strcmp(var, "$SPLFRAME")) { + return true; + } + if (!strcmp(var, "$SPLINESEGS")) { + return true; + } + if (!strcmp(var, "$SPLINETYPE")) { + return true; + } + if (!strcmp(var, "$SURFTAB1")) { + return true; + } + if (!strcmp(var, "$SURFTAB2")) { + return true; + } + if (!strcmp(var, "$SURFTYPE")) { + return true; + } + if (!strcmp(var, "$SURFU")) { + return true; + } + if (!strcmp(var, "$SURFV")) { + return true; + } + if (!strcmp(var, "$TDCREATE")) { + return true; + } + if (!strcmp(var, "$TDINDWG")) { + return true; + } + if (!strcmp(var, "$TDUPDATE")) { + return true; + } + if (!strcmp(var, "$TDUSRTIMER")) { + return true; + } + if (!strcmp(var, "$TEXTSIZE")) { + return true; + } + if (!strcmp(var, "$TEXTSTYLE")) { + return true; + } + if (!strcmp(var, "$THICKNESS")) { + return true; + } + if (!strcmp(var, "$TILEMODE")) { + return true; + } + if (!strcmp(var, "$TRACEWID")) { + return true; + } + if (!strcmp(var, "$UCSNAME")) { + return true; + } + if (!strcmp(var, "$UCSORG")) { + return true; + } + if (!strcmp(var, "$UCSXDIR")) { + return true; + } + if (!strcmp(var, "$UCSYDIR")) { + return true; + } + if (!strcmp(var, "$UNITMODE")) { + return true; + } + if (!strcmp(var, "$USERI1")) { + return true; + } + if (!strcmp(var, "$USERR1")) { + return true; + } + if (!strcmp(var, "$USRTIMER")) { + return true; + } + if (!strcmp(var, "$VISRETAIN")) { + return true; + } + if (!strcmp(var, "$WORLDVIEW")) { + return true; + } + if (!strcmp(var, "$FASTZOOM")) { + return true; + } + if (!strcmp(var, "$GRIDMODE")) { + return true; + } + if (!strcmp(var, "$GRIDUNIT")) { + return true; + } + if (!strcmp(var, "$SNAPANG")) { + return true; + } + if (!strcmp(var, "$SNAPBASE")) { + return true; + } + if (!strcmp(var, "$SNAPISOPAIR")) { + return true; + } + if (!strcmp(var, "$SNAPMODE")) { + return true; + } + if (!strcmp(var, "$SNAPSTYLE")) { + return true; + } + if (!strcmp(var, "$SNAPUNIT")) { + return true; + } + if (!strcmp(var, "$VIEWCTR")) { + return true; + } + if (!strcmp(var, "$VIEWDIR")) { + return true; + } + if (!strcmp(var, "$VIEWSIZE")) { + return true; + } + return false; } - if ( !strcmp( var, "$ACADVER" ) ) - { - return true; - } - if ( !strcmp( var, "$ANGBASE" ) ) - { - return true; - } - if ( !strcmp( var, "$ANGDIR" ) ) - { - return true; - } - if ( !strcmp( var, "$ATTDIA" ) ) - { - return true; - } - if ( !strcmp( var, "$ATTMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$ATTREQ" ) ) - { - return true; - } - if ( !strcmp( var, "$AUNITS" ) ) - { - return true; - } - if ( !strcmp( var, "$AUPREC" ) ) - { - return true; - } - if ( !strcmp( var, "$AXISMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$AXISUNIT" ) ) - { - return true; - } - if ( !strcmp( var, "$BLIPMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$CECOLOR" ) ) - { - return true; - } - if ( !strcmp( var, "$CELTYPE" ) ) - { - return true; - } - if ( !strcmp( var, "$CHAMFERA" ) ) - { - return true; - } - if ( !strcmp( var, "$CHAMFERB" ) ) - { - return true; - } - if ( !strcmp( var, "$CLAYER" ) ) - { - return true; - } - if ( !strcmp( var, "$COORDS" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMALT" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMALTD" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMALTF" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMAPOST" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMASO" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMASZ" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMBLK" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMBLK1" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMBLK2" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMCEN" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMCLRD" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMCLRE" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMCLRT" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMDLE" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMDLI" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMEXE" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMEXO" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMGAP" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMLFAC" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMLIM" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMPOST" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMRND" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMSAH" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMSCALE" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMSE1" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMSE2" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMSHO" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMSOXD" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMSTYLE" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTAD" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTFAC" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTIH" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTIX" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTM" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTOFL" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTOH" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTOL" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTP" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTSZ" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTVP" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMTXT" ) ) - { - return true; - } - if ( !strcmp( var, "$DIMZIN" ) ) - { - return true; - } - if ( !strcmp( var, "$DWGCODEPAGE" ) ) - { - return true; - } - if ( !strcmp( var, "$DRAGMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$ELEVATION" ) ) - { - return true; - } - if ( !strcmp( var, "$EXTMAX" ) ) - { - return true; - } - if ( !strcmp( var, "$EXTMIN" ) ) - { - return true; - } - if ( !strcmp( var, "$FILLETRAD" ) ) - { - return true; - } - if ( !strcmp( var, "$FILLMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$HANDLING" ) ) - { - return true; - } - if ( !strcmp( var, "$HANDSEED" ) ) - { - return true; - } - if ( !strcmp( var, "$INSBASE" ) ) - { - return true; - } - if ( !strcmp( var, "$LIMCHECK" ) ) - { - return true; - } - if ( !strcmp( var, "$LIMMAX" ) ) - { - return true; - } - if ( !strcmp( var, "$LIMMIN" ) ) - { - return true; - } - if ( !strcmp( var, "$LTSCALE" ) ) - { - return true; - } - if ( !strcmp( var, "$LUNITS" ) ) - { - return true; - } - if ( !strcmp( var, "$LUPREC" ) ) - { - return true; - } - if ( !strcmp( var, "$MAXACTVP" ) ) - { - return true; - } - if ( !strcmp( var, "$MENU" ) ) - { - return true; - } - if ( !strcmp( var, "$MIRRTEXT" ) ) - { - return true; - } - if ( !strcmp( var, "$ORTHOMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$OSMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$PDMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$PDSIZE" ) ) - { - return true; - } - if ( !strcmp( var, "$PELEVATION" ) ) - { - return true; - } - if ( !strcmp( var, "$PEXTMAX" ) ) - { - return true; - } - if ( !strcmp( var, "$PEXTMIN" ) ) - { - return true; - } - if ( !strcmp( var, "$PLIMCHECK" ) ) - { - return true; - } - if ( !strcmp( var, "$PLIMMAX" ) ) - { - return true; - } - if ( !strcmp( var, "$PLIMMIN" ) ) - { - return true; - } - if ( !strcmp( var, "$PLINEGEN" ) ) - { - return true; - } - if ( !strcmp( var, "$PLINEWID" ) ) - { - return true; - } - if ( !strcmp( var, "$PSLTSCALE" ) ) - { - return true; - } - if ( !strcmp( var, "$PUCSNAME" ) ) - { - return true; - } - if ( !strcmp( var, "$PUCSORG" ) ) - { - return true; - } - if ( !strcmp( var, "$PUCSXDIR" ) ) - { - return true; - } - if ( !strcmp( var, "$PUCSYDIR" ) ) - { - return true; - } - if ( !strcmp( var, "$QTEXTMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$REGENMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$SHADEDGE" ) ) - { - return true; - } - if ( !strcmp( var, "$SHADEDIF" ) ) - { - return true; - } - if ( !strcmp( var, "$SKETCHINC" ) ) - { - return true; - } - if ( !strcmp( var, "$SKPOLY" ) ) - { - return true; - } - if ( !strcmp( var, "$SPLFRAME" ) ) - { - return true; - } - if ( !strcmp( var, "$SPLINESEGS" ) ) - { - return true; - } - if ( !strcmp( var, "$SPLINETYPE" ) ) - { - return true; - } - if ( !strcmp( var, "$SURFTAB1" ) ) - { - return true; - } - if ( !strcmp( var, "$SURFTAB2" ) ) - { - return true; - } - if ( !strcmp( var, "$SURFTYPE" ) ) - { - return true; - } - if ( !strcmp( var, "$SURFU" ) ) - { - return true; - } - if ( !strcmp( var, "$SURFV" ) ) - { - return true; - } - if ( !strcmp( var, "$TDCREATE" ) ) - { - return true; - } - if ( !strcmp( var, "$TDINDWG" ) ) - { - return true; - } - if ( !strcmp( var, "$TDUPDATE" ) ) - { - return true; - } - if ( !strcmp( var, "$TDUSRTIMER" ) ) - { - return true; - } - if ( !strcmp( var, "$TEXTSIZE" ) ) - { - return true; - } - if ( !strcmp( var, "$TEXTSTYLE" ) ) - { - return true; - } - if ( !strcmp( var, "$THICKNESS" ) ) - { - return true; - } - if ( !strcmp( var, "$TILEMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$TRACEWID" ) ) - { - return true; - } - if ( !strcmp( var, "$UCSNAME" ) ) - { - return true; - } - if ( !strcmp( var, "$UCSORG" ) ) - { - return true; - } - if ( !strcmp( var, "$UCSXDIR" ) ) - { - return true; - } - if ( !strcmp( var, "$UCSYDIR" ) ) - { - return true; - } - if ( !strcmp( var, "$UNITMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$USERI1" ) ) - { - return true; - } - if ( !strcmp( var, "$USERR1" ) ) - { - return true; - } - if ( !strcmp( var, "$USRTIMER" ) ) - { - return true; - } - if ( !strcmp( var, "$VISRETAIN" ) ) - { - return true; - } - if ( !strcmp( var, "$WORLDVIEW" ) ) - { - return true; - } - if ( !strcmp( var, "$FASTZOOM" ) ) - { - return true; - } - if ( !strcmp( var, "$GRIDMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$GRIDUNIT" ) ) - { - return true; - } - if ( !strcmp( var, "$SNAPANG" ) ) - { - return true; - } - if ( !strcmp( var, "$SNAPBASE" ) ) - { - return true; - } - if ( !strcmp( var, "$SNAPISOPAIR" ) ) - { - return true; - } - if ( !strcmp( var, "$SNAPMODE" ) ) - { - return true; - } - if ( !strcmp( var, "$SNAPSTYLE" ) ) - { - return true; - } - if ( !strcmp( var, "$SNAPUNIT" ) ) - { - return true; - } - if ( !strcmp( var, "$VIEWCTR" ) ) - { - return true; - } - if ( !strcmp( var, "$VIEWDIR" ) ) - { - return true; - } - if ( !strcmp( var, "$VIEWSIZE" ) ) - { - return true; - } - return false; - } - return false; + return false; } @@ -5492,108 +5116,123 @@ bool DL_Dxf::checkVariable( const char* var, DL_Codes::version version ) * @returns the library version as int (4 bytes, each byte one version number). * e.g. if str = "2.0.2.0" getLibVersion returns 0x02000200 */ -int DL_Dxf::getLibVersion( const char* str ) -{ - int d[4]; - int idx = 0; - char v[4][5]; - int ret = 0; +int DL_Dxf::getLibVersion(const std::string& str) { + int d[4]; + int idx = 0; + //char v[4][5]; + std::string v[4]; + int ret = 0; - for ( unsigned int i = 0; i < strlen( str ) && idx < 3; ++i ) - { - if ( str[i] == '.' ) - { - d[idx] = i; - idx++; + for (unsigned int i=0; i=2) { + d[3] = str.length(); - strncpy( v[0], str, d[0] ); - v[0][d[0]] = '\0'; -// QgsDebugMsg(QString("v[0]: %1").arg(atoi(v[0]))); + v[0] = str.substr(0, d[0]); + v[1] = str.substr(d[0]+1, d[1]-d[0]-1); + v[2] = str.substr(d[1]+1, d[2]-d[1]-1); + if (idx>=3) { + v[3] = str.substr(d[2]+1, d[3]-d[2]-1); + } + else { + v[3] = "0"; + } - strncpy( v[1], &str[d[0] + 1], d[1] - d[0] - 1 ); - v[1][d[1] - d[0] - 1] = '\0'; -// QgsDebugMsg(QString("v[1]: %1").arg(atoi(v[1]))); + ret = (atoi(v[0].c_str())<<(3*8)) + + (atoi(v[1].c_str())<<(2*8)) + + (atoi(v[2].c_str())<<(1*8)) + + (atoi(v[3].c_str())<<(0*8)); - strncpy( v[2], &str[d[1] + 1], d[2] - d[1] - 1 ); - v[2][d[2] - d[1] - 1] = '\0'; -// QgsDebugMsg(QString("v[2]: %1").arg(atoi(v[2]))); - - strncpy( v[3], &str[d[2] + 1], d[3] - d[2] - 1 ); - v[3][d[3] - d[2] - 1] = '\0'; -// QgsDebugMsg(QString("v[3]: %1").arg(atoi(v[3]))); - - ret = ( atoi( v[0] ) << ( 3 * 8 ) ) + - ( atoi( v[1] ) << ( 2 * 8 ) ) + - ( atoi( v[2] ) << ( 1 * 8 ) ) + - ( atoi( v[3] ) << ( 0 * 8 ) ); - - return ret; - } - else - { - QgsDebugMsg( QString( "DL_Dxf::getLibVersion: invalid version number: %1" ).arg( str ) ); - return 0; - } + return ret; + } else { + std::cerr << "DL_Dxf::getLibVersion: invalid version number: " << str << "\n"; + return 0; + } } +/** + * Converts the given string into a double or returns the given + * default valud (def) if value is NULL or empty. + */ +//double DL_Dxf::toReal(const char* value, double def) { +// if (value!=NULL && value[0] != '\0') { +// printf("toReal: not empty: %s\n", value); +// printf("toReal: val: %f\n", atof(value)); +// printf("toReal: 0: %d\n", value[0]); +// printf("toReal: 1: %d\n", value[1]); +// printf("toReal: 2: %d\n", value[2]); +// double ret; +// if (strchr(value, ',') != NULL) { +// char* tmp = new char[strlen(value)+1]; +// strcpy(tmp, value); +// DL_WriterA::strReplace(tmp, ',', '.'); +// ret = atof(tmp); +// delete[] tmp; +// } +// else { +// ret = atof(value); +// } +// return ret; +// } else { +// return def; +// } +//} /** * Some test routines. */ -void DL_Dxf::test() -{ - char* buf1; - char* buf2; - char* buf3; - char* buf4; - char* buf5; - char* buf6; +void DL_Dxf::test() { + char* buf1; + char* buf2; + char* buf3; + char* buf4; + char* buf5; + char* buf6; - buf1 = new char[10]; - buf2 = new char[10]; - buf3 = new char[10]; - buf4 = new char[10]; - buf5 = new char[10]; - buf6 = new char[10]; + buf1 = new char[10]; + buf2 = new char[10]; + buf3 = new char[10]; + buf4 = new char[10]; + buf5 = new char[10]; + buf6 = new char[10]; - strcpy( buf1, " 10\n" ); - strcpy( buf2, "10" ); - strcpy( buf3, "10\n" ); - strcpy( buf4, " 10 \n" ); - strcpy( buf5, " 10 \r" ); - strcpy( buf6, "\t10 \n" ); + strcpy(buf1, " 10\n"); + strcpy(buf2, "10"); + strcpy(buf3, "10\n"); + strcpy(buf4, " 10 \n"); + strcpy(buf5, " 10 \r"); + strcpy(buf6, "\t10 \n"); - QgsDebugMsg( QString( "1 buf1: '%1'" ).arg( buf1 ) ); - stripWhiteSpace( &buf1 ); - QgsDebugMsg( QString( "2 buf1: '%1'" ).arg( buf1 ) ); - //assert(!strcmp(buf1, "10")); + std::cout << "1 buf1: '" << buf1 << "'\n"; + stripWhiteSpace(&buf1); + std::cout << "2 buf1: '" << buf1 << "'\n"; + //assert(!strcmp(buf1, "10")); - QgsDebugMsg( QString( "1 buf2: '%1'" ).arg( buf2 ) ); - stripWhiteSpace( &buf2 ); - QgsDebugMsg( QString( "2 buf2: '%1'" ).arg( buf2 ) ); + std::cout << "1 buf2: '" << buf2 << "'\n"; + stripWhiteSpace(&buf2); + std::cout << "2 buf2: '" << buf2 << "'\n"; - QgsDebugMsg( QString( "1 buf3: '%1'" ).arg( buf3 ) ); - stripWhiteSpace( &buf3 ); - QgsDebugMsg( QString( "2 buf3: '%1'" ).arg( buf3 ) ); + std::cout << "1 buf3: '" << buf3 << "'\n"; + stripWhiteSpace(&buf3); + std::cout << "2 buf3: '" << buf3 << "'\n"; - QgsDebugMsg( QString( "1 buf4: '%1'" ).arg( buf4 ) ); - stripWhiteSpace( &buf4 ); - QgsDebugMsg( QString( "2 buf4: '%1'" ).arg( buf4 ) ); + std::cout << "1 buf4: '" << buf4 << "'\n"; + stripWhiteSpace(&buf4); + std::cout << "2 buf4: '" << buf4 << "'\n"; - QgsDebugMsg( QString( "1 buf5: '%1'" ).arg( buf5 ) ); - stripWhiteSpace( &buf5 ); - QgsDebugMsg( QString( "2 buf5: '%1'" ).arg( buf5 ) ); + std::cout << "1 buf5: '" << buf5 << "'\n"; + stripWhiteSpace(&buf5); + std::cout << "2 buf5: '" << buf5 << "'\n"; - QgsDebugMsg( QString( "1 buf6: '%1'" ).arg( buf6 ) ); - stripWhiteSpace( &buf6 ); - QgsDebugMsg( QString( "2 buf6: '%1'" ).arg( buf6 ) ); + std::cout << "1 buf6: '" << buf6 << "'\n"; + stripWhiteSpace(&buf6); + std::cout << "2 buf6: '" << buf6 << "'\n"; } diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.h index 706d5793dfa..29153c53fb4 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.h +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_dxf.h @@ -1,20 +1,14 @@ /**************************************************************************** -** $Id: dl_dxf.h 2398 2005-06-06 18:12:14Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -31,12 +25,13 @@ #ifndef DL_DXF_H #define DL_DXF_H +#include "dl_global.h" + #include #include -#include -#ifndef __GCC2x__ +#include #include -#endif +#include #include "dl_attributes.h" #include "dl_codes.h" @@ -57,13 +52,19 @@ class DL_CreationInterface; class DL_WriterA; -#define DL_VERSION "2.0.4.8" +#define DL_VERSION "3.7.5.0" -#define DL_Unknown 0 +#define DL_VERSION_MAJOR 3 +#define DL_VERSION_MINOR 7 +#define DL_VERSION_REV 5 +#define DL_VERSION_BUILD 0 + +#define DL_UNKNOWN 0 #define DL_LAYER 10 #define DL_BLOCK 11 #define DL_ENDBLK 12 #define DL_LINETYPE 13 +#define DL_STYLE 20 #define DL_SETTING 50 #define DL_ENTITY_POINT 100 #define DL_ENTITY_LINE 101 @@ -87,19 +88,24 @@ class DL_WriterA; #define DL_ENTITY_IMAGEDEF 119 #define DL_ENTITY_TRACE 120 #define DL_ENTITY_SOLID 121 -#define DL_ENTITY_SEQEND 122 +#define DL_ENTITY_3DFACE 122 +#define DL_ENTITY_XLINE 123 +#define DL_ENTITY_RAY 124 +#define DL_ENTITY_SEQEND 125 +#define DL_XRECORD 200 +#define DL_DICTIONARY 210 /** * Reading and writing of DXF files. * - * This class can read in a DXF file and calls methods from the + * This class can read in a DXF file and calls methods from the * interface DL_EntityContainer to add the entities to the * contianer provided by the user of the library. * * It can also be used to write DXF files to a certain extent. * - * When saving entities, special values for colors and linetypes + * When saving entities, special values for colors and linetypes * can be used: * * Special colors are 0 (=BYBLOCK) and 256 (=BYLAYER). @@ -107,316 +113,385 @@ class DL_WriterA; * * @author Andrew Mustun */ -class DL_Dxf -{ - public: +class DXFLIB_EXPORT DL_Dxf { +public: DL_Dxf(); ~DL_Dxf(); - bool in( const string& file, - DL_CreationInterface* creationInterface ); - bool readDxfGroups( FILE* fp, - DL_CreationInterface* creationInterface, - int* errorCounter = NULL ); - static bool getChoppedLine( char* s, unsigned int size, - FILE *stream ); + bool in(const std::string& file, + DL_CreationInterface* creationInterface); + bool readDxfGroups(FILE* fp, + DL_CreationInterface* creationInterface); + static bool getStrippedLine(std::string& s, unsigned int size, + FILE* stream); + + bool readDxfGroups(std::stringstream& stream, + DL_CreationInterface* creationInterface); + bool in(std::stringstream &stream, + DL_CreationInterface* creationInterface); + static bool getStrippedLine(std::string& s, unsigned int size, + std::stringstream& stream); -#ifndef __GCC2x__ + static bool stripWhiteSpace(char** s); - bool readDxfGroups( std::stringstream &stream, - DL_CreationInterface* creationInterface, - int* errorCounter = NULL ); - bool in( std::stringstream &stream, - DL_CreationInterface* creationInterface ); - static bool getChoppedLine( char *s, unsigned int size, - std::stringstream &stream ); -#endif + bool processDXFGroup(DL_CreationInterface* creationInterface, + int groupCode, const std::string& groupValue); + void addSetting(DL_CreationInterface* creationInterface); + void addLayer(DL_CreationInterface* creationInterface); + void addLinetype(DL_CreationInterface *creationInterface); + void addBlock(DL_CreationInterface* creationInterface); + void endBlock(DL_CreationInterface* creationInterface); + void addTextStyle(DL_CreationInterface* creationInterface); - static bool stripWhiteSpace( char** s ); + void addPoint(DL_CreationInterface* creationInterface); + void addLine(DL_CreationInterface* creationInterface); + void addXLine(DL_CreationInterface* creationInterface); + void addRay(DL_CreationInterface* creationInterface); + + void addPolyline(DL_CreationInterface* creationInterface); + void addVertex(DL_CreationInterface* creationInterface); + + void addSpline(DL_CreationInterface* creationInterface); + + void addArc(DL_CreationInterface* creationInterface); + void addCircle(DL_CreationInterface* creationInterface); + void addEllipse(DL_CreationInterface* creationInterface); + void addInsert(DL_CreationInterface* creationInterface); + + void addTrace(DL_CreationInterface* creationInterface); + void add3dFace(DL_CreationInterface* creationInterface); + void addSolid(DL_CreationInterface* creationInterface); - bool processDXFGroup( DL_CreationInterface* creationInterface, - int groupCode, const char* groupValue ); - void addSetting( DL_CreationInterface* creationInterface ); - void addLayer( DL_CreationInterface* creationInterface ); - void addBlock( DL_CreationInterface* creationInterface ); - void endBlock( DL_CreationInterface* creationInterface ); + void addMText(DL_CreationInterface* creationInterface); + void addText(DL_CreationInterface* creationInterface); - void addPoint( DL_CreationInterface* creationInterface ); - void addLine( DL_CreationInterface* creationInterface ); + void addAttribute(DL_CreationInterface* creationInterface); - void addPolyline( DL_CreationInterface* creationInterface ); - void addVertex( DL_CreationInterface* creationInterface ); - - void addSpline( DL_CreationInterface* creationInterface ); - //void addKnot(DL_CreationInterface* creationInterface); - //void addControlPoint(DL_CreationInterface* creationInterface); - - void addArc( DL_CreationInterface* creationInterface ); - void addCircle( DL_CreationInterface* creationInterface ); - void addEllipse( DL_CreationInterface* creationInterface ); - void addInsert( DL_CreationInterface* creationInterface ); - - void addTrace( DL_CreationInterface* creationInterface ); - void addSolid( DL_CreationInterface* creationInterface ); - - void addMText( DL_CreationInterface* creationInterface ); - bool handleMTextData( DL_CreationInterface* creationInterface ); - bool handleLWPolylineData( DL_CreationInterface* creationInterface ); - bool handleSplineData( DL_CreationInterface* creationInterface ); - bool handleLeaderData( DL_CreationInterface* creationInterface ); - bool handleHatchData( DL_CreationInterface* creationInterface ); - - void addText( DL_CreationInterface* creationInterface ); - void addAttrib( DL_CreationInterface* creationInterface ); DL_DimensionData getDimData(); - void addDimLinear( DL_CreationInterface* creationInterface ); - void addDimAligned( DL_CreationInterface* creationInterface ); - void addDimRadial( DL_CreationInterface* creationInterface ); - void addDimDiametric( DL_CreationInterface* creationInterface ); - void addDimAngular( DL_CreationInterface* creationInterface ); - void addDimAngular3P( DL_CreationInterface* creationInterface ); - void addLeader( DL_CreationInterface* creationInterface ); - void addHatch( DL_CreationInterface* creationInterface ); - void addImage( DL_CreationInterface* creationInterface ); - void addImageDef( DL_CreationInterface* creationInterface ); + void addDimLinear(DL_CreationInterface* creationInterface); + void addDimAligned(DL_CreationInterface* creationInterface); + void addDimRadial(DL_CreationInterface* creationInterface); + void addDimDiametric(DL_CreationInterface* creationInterface); + void addDimAngular(DL_CreationInterface* creationInterface); + void addDimAngular3P(DL_CreationInterface* creationInterface); + void addDimOrdinate(DL_CreationInterface* creationInterface); - void endEntity( DL_CreationInterface* creationInterface ); + void addLeader(DL_CreationInterface* creationInterface); - void endSequence( DL_CreationInterface* creationInterface ); + void addHatch(DL_CreationInterface* creationInterface); + void addHatchLoop(); + void addHatchEdge(); + bool handleHatchData(DL_CreationInterface* creationInterface); - int stringToInt( const char* s, bool* ok = NULL ); + void addImage(DL_CreationInterface* creationInterface); + void addImageDef(DL_CreationInterface* creationInterface); + + void addComment(DL_CreationInterface* creationInterface, const std::string& comment); - DL_WriterA* out( const char* file, - DL_Codes::version version = VER_2000 ); + void addDictionary(DL_CreationInterface* creationInterface); + void addDictionaryEntry(DL_CreationInterface* creationInterface); - void writeHeader( DL_WriterA& dw ); + bool handleXRecordData(DL_CreationInterface* creationInterface); + bool handleDictionaryData(DL_CreationInterface* creationInterface); - void writePoint( DL_WriterA& dw, - const DL_PointData& data, - const DL_Attributes& attrib ); - void writeLine( DL_WriterA& dw, - const DL_LineData& data, - const DL_Attributes& attrib ); - void writePolyline( DL_WriterA& dw, - const DL_PolylineData& data, - const DL_Attributes& attrib ); - void writeVertex( DL_WriterA& dw, - const DL_VertexData& data ); - void writePolylineEnd( DL_WriterA& dw ); - void writeSpline( DL_WriterA& dw, - const DL_SplineData& data, - const DL_Attributes& attrib ); - void writeControlPoint( DL_WriterA& dw, - const DL_ControlPointData& data ); - void writeKnot( DL_WriterA& dw, - const DL_KnotData& data ); - void writeCircle( DL_WriterA& dw, - const DL_CircleData& data, - const DL_Attributes& attrib ); - void writeArc( DL_WriterA& dw, - const DL_ArcData& data, - const DL_Attributes& attrib ); - void writeEllipse( DL_WriterA& dw, - const DL_EllipseData& data, - const DL_Attributes& attrib ); - void writeInsert( DL_WriterA& dw, - const DL_InsertData& data, - const DL_Attributes& attrib ); - void writeMText( DL_WriterA& dw, - const DL_MTextData& data, - const DL_Attributes& attrib ); - void writeText( DL_WriterA& dw, - const DL_TextData& data, - const DL_Attributes& attrib ); - void writeDimAligned( DL_WriterA& dw, - const DL_DimensionData& data, - const DL_DimAlignedData& edata, - const DL_Attributes& attrib ); - void writeDimLinear( DL_WriterA& dw, + bool handleXData(DL_CreationInterface *creationInterface); + bool handleMTextData(DL_CreationInterface* creationInterface); + bool handleLWPolylineData(DL_CreationInterface* creationInterface); + bool handleSplineData(DL_CreationInterface* creationInterface); + bool handleLeaderData(DL_CreationInterface* creationInterface); + bool handleLinetypeData(DL_CreationInterface* creationInterface); + + void endEntity(DL_CreationInterface* creationInterface); + + void endSequence(DL_CreationInterface* creationInterface); + + //int stringToInt(const char* s, bool* ok=NULL); + + DL_WriterA* out(const char* file, + DL_Codes::version version=DL_VERSION_2000); + + void writeHeader(DL_WriterA& dw); + + void writePoint(DL_WriterA& dw, + const DL_PointData& data, + const DL_Attributes& attrib); + void writeLine(DL_WriterA& dw, + const DL_LineData& data, + const DL_Attributes& attrib); + void writeXLine(DL_WriterA& dw, + const DL_XLineData& data, + const DL_Attributes& attrib); + void writeRay(DL_WriterA& dw, + const DL_RayData& data, + const DL_Attributes& attrib); + void writePolyline(DL_WriterA& dw, + const DL_PolylineData& data, + const DL_Attributes& attrib); + void writeVertex(DL_WriterA& dw, + const DL_VertexData& data); + void writePolylineEnd(DL_WriterA& dw); + void writeSpline(DL_WriterA& dw, + const DL_SplineData& data, + const DL_Attributes& attrib); + void writeControlPoint(DL_WriterA& dw, + const DL_ControlPointData& data); + void writeFitPoint(DL_WriterA& dw, + const DL_FitPointData& data); + void writeKnot(DL_WriterA& dw, + const DL_KnotData& data); + void writeCircle(DL_WriterA& dw, + const DL_CircleData& data, + const DL_Attributes& attrib); + void writeArc(DL_WriterA& dw, + const DL_ArcData& data, + const DL_Attributes& attrib); + void writeEllipse(DL_WriterA& dw, + const DL_EllipseData& data, + const DL_Attributes& attrib); + void writeSolid(DL_WriterA& dw, + const DL_SolidData& data, + const DL_Attributes& attrib); + void writeTrace(DL_WriterA& dw, + const DL_TraceData& data, + const DL_Attributes& attrib); + void write3dFace(DL_WriterA& dw, + const DL_3dFaceData& data, + const DL_Attributes& attrib); + void writeInsert(DL_WriterA& dw, + const DL_InsertData& data, + const DL_Attributes& attrib); + void writeMText(DL_WriterA& dw, + const DL_MTextData& data, + const DL_Attributes& attrib); + void writeText(DL_WriterA& dw, + const DL_TextData& data, + const DL_Attributes& attrib); + void writeAttribute(DL_WriterA& dw, + const DL_AttributeData& data, + const DL_Attributes& attrib); + void writeDimStyleOverrides(DL_WriterA& dw, + const DL_DimensionData& data); + void writeDimAligned(DL_WriterA& dw, const DL_DimensionData& data, - const DL_DimLinearData& edata, - const DL_Attributes& attrib ); - void writeDimRadial( DL_WriterA& dw, + const DL_DimAlignedData& edata, + const DL_Attributes& attrib); + void writeDimLinear(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimLinearData& edata, + const DL_Attributes& attrib); + void writeDimRadial(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimRadialData& edata, + const DL_Attributes& attrib); + void writeDimDiametric(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimDiametricData& edata, + const DL_Attributes& attrib); + void writeDimAngular(DL_WriterA& dw, const DL_DimensionData& data, - const DL_DimRadialData& edata, - const DL_Attributes& attrib ); - void writeDimDiametric( DL_WriterA& dw, - const DL_DimensionData& data, - const DL_DimDiametricData& edata, - const DL_Attributes& attrib ); - void writeDimAngular( DL_WriterA& dw, - const DL_DimensionData& data, - const DL_DimAngularData& edata, - const DL_Attributes& attrib ); - void writeDimAngular3P( DL_WriterA& dw, - const DL_DimensionData& data, - const DL_DimAngular3PData& edata, - const DL_Attributes& attrib ); - void writeLeader( DL_WriterA& dw, - const DL_LeaderData& data, - const DL_Attributes& attrib ); - void writeLeaderVertex( DL_WriterA& dw, - const DL_LeaderVertexData& data ); - void writeHatch1( DL_WriterA& dw, - const DL_HatchData& data, - const DL_Attributes& attrib ); - void writeHatch2( DL_WriterA& dw, - const DL_HatchData& data, - const DL_Attributes& attrib ); - void writeHatchLoop1( DL_WriterA& dw, - const DL_HatchLoopData& data ); - void writeHatchLoop2( DL_WriterA& dw, - const DL_HatchLoopData& data ); - void writeHatchEdge( DL_WriterA& dw, - const DL_HatchEdgeData& data ); + const DL_DimAngularData& edata, + const DL_Attributes& attrib); + void writeDimAngular3P(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimAngular3PData& edata, + const DL_Attributes& attrib); + void writeDimOrdinate(DL_WriterA& dw, + const DL_DimensionData& data, + const DL_DimOrdinateData& edata, + const DL_Attributes& attrib); + void writeLeader(DL_WriterA& dw, + const DL_LeaderData& data, + const DL_Attributes& attrib); + void writeLeaderVertex(DL_WriterA& dw, + const DL_LeaderVertexData& data); + void writeHatch1(DL_WriterA& dw, + const DL_HatchData& data, + const DL_Attributes& attrib); + void writeHatch2(DL_WriterA& dw, + const DL_HatchData& data, + const DL_Attributes& attrib); + void writeHatchLoop1(DL_WriterA& dw, + const DL_HatchLoopData& data); + void writeHatchLoop2(DL_WriterA& dw, + const DL_HatchLoopData& data); + void writeHatchEdge(DL_WriterA& dw, + const DL_HatchEdgeData& data); - int writeImage( DL_WriterA& dw, - const DL_ImageData& data, - const DL_Attributes& attrib ); + int writeImage(DL_WriterA& dw, + const DL_ImageData& data, + const DL_Attributes& attrib); - void writeImageDef( DL_WriterA& dw, int handle, - const DL_ImageData& data ); + void writeImageDef(DL_WriterA& dw, int handle, + const DL_ImageData& data); - void writeLayer( DL_WriterA& dw, - const DL_LayerData& data, - const DL_Attributes& attrib ); + void writeLayer(DL_WriterA& dw, + const DL_LayerData& data, + const DL_Attributes& attrib); - void writeLineType( DL_WriterA& dw, - const DL_LineTypeData& data ); + void writeLinetype(DL_WriterA& dw, + const DL_LinetypeData& data); - void writeAppid( DL_WriterA& dw, const string& name ); + void writeAppid(DL_WriterA& dw, const std::string& name); - void writeBlock( DL_WriterA& dw, - const DL_BlockData& data ); - void writeEndBlock( DL_WriterA& dw, const string& name ); + void writeBlock(DL_WriterA& dw, + const DL_BlockData& data); + void writeEndBlock(DL_WriterA& dw, const std::string& name); - void writeVPort( DL_WriterA& dw ); - void writeStyle( DL_WriterA& dw ); - void writeView( DL_WriterA& dw ); - void writeUcs( DL_WriterA& dw ); - void writeDimStyle( DL_WriterA& dw, - double dimasz, double dimexe, double dimexo, - double dimgap, double dimtxt ); - void writeBlockRecord( DL_WriterA& dw ); - void writeBlockRecord( DL_WriterA& dw, const string& name ); - void writeObjects( DL_WriterA& dw ); - void writeObjectsEnd( DL_WriterA& dw ); + void writeVPort(DL_WriterA& dw); + void writeStyle(DL_WriterA& dw, const DL_StyleData& style); + void writeView(DL_WriterA& dw); + void writeUcs(DL_WriterA& dw); + void writeDimStyle(DL_WriterA& dw, + double dimasz, double dimexe, double dimexo, + double dimgap, double dimtxt); + void writeBlockRecord(DL_WriterA& dw); + void writeBlockRecord(DL_WriterA& dw, const std::string& name); + void writeObjects(DL_WriterA& dw, const std::string& appDictionaryName = ""); + void writeAppDictionary(DL_WriterA& dw); + int writeDictionaryEntry(DL_WriterA& dw, const std::string& name); + void writeXRecord(DL_WriterA& dw, int handle, int value); + void writeXRecord(DL_WriterA& dw, int handle, double value); + void writeXRecord(DL_WriterA& dw, int handle, bool value); + void writeXRecord(DL_WriterA& dw, int handle, const std::string& value); + void writeObjectsEnd(DL_WriterA& dw); + + void writeComment(DL_WriterA& dw, const std::string& comment); /** - * Converts the given string into a double or returns the given + * Converts the given string into a double or returns the given * default valud (def) if value is NULL or empty. */ - static double toReal( const char* value, double def = 0.0 ) - { - if ( value != NULL && value[0] != '\0' ) - { - double ret; - if ( strchr( value, ',' ) != NULL ) - { - char* tmp = new char[strlen( value )+1]; - strcpy( tmp, value ); - DL_WriterA::strReplace( tmp, ',', '.' ); - ret = atof( tmp ); - delete[] tmp; - } - else - { - ret = atof( value ); - } - return ret; - } - else - { - return def; - } - } + //static double toReal(const char* value, double def=0.0); + /** - * Converts the given string into an int or returns the given + * Converts the given string into an int or returns the given * default valud (def) if value is NULL or empty. */ - static int toInt( const char* value, int def = 0 ) - { - if ( value != NULL && value[0] != '\0' ) - { - return atoi( value ); - } - else - { - return def; - } - } +// static int toInt(const char* value, int def=0) { +// if (value!=NULL && value[0] != '\0') { +// return atoi(value); +// } + +// return def; +// } + /** - * Converts the given string into a string or returns the given + * Converts the given string into a string or returns the given * default valud (def) if value is NULL or empty. */ - static const char* toString( const char* value, const char* def = "" ) - { - if ( value != NULL && value[0] != '\0' ) - { - return value; - } - else - { - return def; - } +// static const char* toString(const char* value, const char* def="") { +// if (value!=NULL && value[0] != '\0') { +// return value; +// } else { +// return def; +// } +// } + + static bool checkVariable(const char* var, DL_Codes::version version); + + DL_Codes::version getVersion() { + return version; } - static bool checkVariable( const char* var, DL_Codes::version version ); - - DL_Codes::version getVersion() - { - return version; - } - - int getLibVersion( const char* str ); + int getLibVersion(const std::string &str); static void test(); - private: - DL_Codes::version version; - unsigned long styleHandleStd; + bool hasValue(int code) { + return values.count(code)==1; + } - string polylineLayer; + int getIntValue(int code, int def) { + if (!hasValue(code)) { + return def; + } + return toInt(values[code]); + } + + int toInt(const std::string& str) { + char* p; + return strtol(str.c_str(), &p, 10); + } + + bool toBool(const std::string& str) { + char* p; + return (bool)strtol(str.c_str(), &p, 10); + } + + std::string getStringValue(int code, const std::string& def) { + if (!hasValue(code)) { + return def; + } + return values[code]; + } + + double getRealValue(int code, double def) { + if (!hasValue(code)) { + return def; + } + return toReal(values[code]); + } + + double toReal(const std::string& str) { + double ret; + // make sure the real value uses '.' not ',': + std::string str2 = str; + std::replace(str2.begin(), str2.end(), ',', '.'); + // make sure c++ expects '.' not ',': + std::istringstream istr(str2); + istr.imbue(std::locale("C")); + istr >> ret; + return ret; + } + +private: + DL_Codes::version version; + + std::string polylineLayer; double* vertices; int maxVertices; int vertexIndex; - + double* knots; int maxKnots; int knotIndex; + + double* weights; + int weightIndex; double* controlPoints; int maxControlPoints; int controlPointIndex; + double* fitPoints; + int maxFitPoints; + int fitPointIndex; + double* leaderVertices; int maxLeaderVertices; int leaderVertexIndex; - // array of hatch loops - DL_HatchLoopData* hatchLoops; - int maxHatchLoops; - int hatchLoopIndex; - // array in format [loop#][edge#] - DL_HatchEdgeData** hatchEdges; - int* maxHatchEdges; - int* hatchEdgeIndex; - bool dropEdges; + bool firstHatchLoop; + DL_HatchEdgeData hatchEdge; + std::vector > hatchEdges; + + std::string xRecordHandle; + bool xRecordValues; // Only the useful part of the group code - char groupCodeTmp[DL_DXF_MAXLINE+1]; + std::string groupCodeTmp; // ...same as integer unsigned int groupCode; // Only the useful part of the group value - char groupValue[DL_DXF_MAXLINE+1]; + std::string groupValue; // Current entity type - int currentEntity; + int currentObjectType; // Value of the current setting char settingValue[DL_DXF_MAXLINE+1]; // Key of the current setting (e.g. "$ACADVER") - char settingKey[DL_DXF_MAXLINE+1]; + std::string settingKey; // Stores the group codes - char values[DL_DXF_MAXGROUPCODE][DL_DXF_MAXLINE+1]; + std::map values; // First call of this method. We initialize all group values in // the first call. bool firstCall; @@ -424,6 +499,10 @@ class DL_Dxf DL_Attributes attrib; // library version. hex: 0x20003001 = 2.0.3.1 int libVersion; + // app specific dictionary handle: + unsigned long appDictionaryHandle; + // handle of standard text style, referenced by dimstyle: + unsigned long styleHandleStd; }; #endif diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_entities.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_entities.h index 5d803a65cd9..317324c7a8e 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_entities.h +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_entities.h @@ -1,20 +1,14 @@ /**************************************************************************** -** $Id: dl_entities.h 2398 2005-06-06 18:12:14Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -31,1145 +25,1345 @@ #ifndef DL_ENTITIES_H #define DL_ENTITIES_H +#include "dl_global.h" #include -using std::string; +#include /** * Layer Data. - * - * @author Andrew Mustun */ -struct DL_LayerData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_LayerData( const string& lName, - int lFlags ) - { - name = lName; - flags = lFlags; - } +struct DXFLIB_EXPORT DL_LayerData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LayerData(const std::string& lName, + int lFlags) { + name = lName; + flags = lFlags; + } - /** Layer name. */ - string name; - /** Layer flags. (1 = frozen, 2 = frozen by default, 4 = locked) */ - int flags; + /** Layer name. */ + std::string name; + /** Layer flags. (1 = frozen, 2 = frozen by default, 4 = locked) */ + int flags; }; /** * Block Data. - * - * @author Andrew Mustun */ -struct DL_BlockData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_BlockData( const string& bName, - int bFlags, - double bbpx, double bbpy, double bbpz ) - { - name = bName; - flags = bFlags; - bpx = bbpx; - bpy = bbpy; - bpz = bbpz; - } +struct DXFLIB_EXPORT DL_BlockData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_BlockData(const std::string& bName, + int bFlags, + double bbpx, double bbpy, double bbpz) { + name = bName; + flags = bFlags; + bpx = bbpx; + bpy = bbpy; + bpz = bbpz; + } - /** Block name. */ - string name; - /** Block flags. (not used currently) */ - int flags; - /** X Coordinate of base point. */ - double bpx; - /** Y Coordinate of base point. */ - double bpy; - /** Z Coordinate of base point. */ - double bpz; + /** Block name. */ + std::string name; + /** Block flags. (not used currently) */ + int flags; + /** X Coordinate of base point. */ + double bpx; + /** Y Coordinate of base point. */ + double bpy; + /** Z Coordinate of base point. */ + double bpz; }; - /** * Line Type Data. - * - * @author Andrew Mustun */ -struct DL_LineTypeData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_LineTypeData( const string& lName, - int lFlags ) - { - name = lName; - flags = lFlags; - } +struct DXFLIB_EXPORT DL_LinetypeData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LinetypeData( + const std::string& name, + const std::string& description, + int flags, + int numberOfDashes, + double patternLength, + double* pattern = NULL + ) + : name(name), + description(description), + flags(flags), + numberOfDashes(numberOfDashes), + patternLength(patternLength), + pattern(pattern) + {} - /** Line type name. */ - string name; - /** Line type flags. */ - int flags; + /** Linetype name */ + std::string name; + /** Linetype description */ + std::string description; + /** Linetype flags */ + int flags; + /** Number of dashes */ + int numberOfDashes; + /** Pattern length */ + double patternLength; + /** Pattern */ + double* pattern; }; /** - * Point Data. - * - * @author Andrew Mustun + * Text style data. */ -struct DL_PointData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_PointData( double px = 0.0, double py = 0.0, double pz = 0.0 ) - { - x = px; - y = py; - z = pz; - } +struct DXFLIB_EXPORT DL_StyleData { + /** + * Constructor + * Parameters: see member variables. + */ + DL_StyleData( + const std::string& name, + int flags, + double fixedTextHeight, + double widthFactor, + double obliqueAngle, + int textGenerationFlags, + double lastHeightUsed, + const std::string& primaryFontFile, + const std::string& bigFontFile + ) + : name(name), + flags(flags), + fixedTextHeight(fixedTextHeight), + widthFactor(widthFactor), + obliqueAngle(obliqueAngle), + textGenerationFlags(textGenerationFlags), + lastHeightUsed(lastHeightUsed), + primaryFontFile(primaryFontFile), + bigFontFile(bigFontFile), + bold(false), + italic(false) { + } - /*! X Coordinate of the point. */ - double x; - /*! Y Coordinate of the point. */ - double y; - /*! Z Coordinate of the point. */ - double z; + bool operator==(const DL_StyleData& other) { + // ignore lastHeightUsed: + return (name==other.name && + flags==other.flags && + fixedTextHeight==other.fixedTextHeight && + widthFactor==other.widthFactor && + obliqueAngle==other.obliqueAngle && + textGenerationFlags==other.textGenerationFlags && + primaryFontFile==other.primaryFontFile && + bigFontFile==other.bigFontFile); + } + + /** Style name */ + std::string name; + /** Style flags */ + int flags; + /** Fixed text height or 0 for not fixed. */ + double fixedTextHeight; + /** Width factor */ + double widthFactor; + /** Oblique angle */ + double obliqueAngle; + /** Text generation flags */ + int textGenerationFlags; + /** Last height used */ + double lastHeightUsed; + /** Primary font file name */ + std::string primaryFontFile; + /** Big font file name */ + std::string bigFontFile; + + bool bold; + bool italic; +}; + +/** + * Point Data. + */ +struct DXFLIB_EXPORT DL_PointData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_PointData(double px=0.0, double py=0.0, double pz=0.0) { + x = px; + y = py; + z = pz; + } + + /*! X Coordinate of the point. */ + double x; + /*! Y Coordinate of the point. */ + double y; + /*! Z Coordinate of the point. */ + double z; }; /** * Line Data. - * - * @author Andrew Mustun */ -struct DL_LineData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_LineData( double lx1, double ly1, double lz1, - double lx2, double ly2, double lz2 ) - { - x1 = lx1; - y1 = ly1; - z1 = lz1; +struct DXFLIB_EXPORT DL_LineData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LineData(double lx1, double ly1, double lz1, + double lx2, double ly2, double lz2) { + x1 = lx1; + y1 = ly1; + z1 = lz1; - x2 = lx2; - y2 = ly2; - z2 = lz2; - } + x2 = lx2; + y2 = ly2; + z2 = lz2; + } - /*! X Start coordinate of the point. */ - double x1; - /*! Y Start coordinate of the point. */ - double y1; - /*! Z Start coordinate of the point. */ - double z1; + /*! X Start coordinate of the point. */ + double x1; + /*! Y Start coordinate of the point. */ + double y1; + /*! Z Start coordinate of the point. */ + double z1; - /*! X End coordinate of the point. */ - double x2; - /*! Y End coordinate of the point. */ - double y2; - /*! Z End coordinate of the point. */ - double z2; + /*! X End coordinate of the point. */ + double x2; + /*! Y End coordinate of the point. */ + double y2; + /*! Z End coordinate of the point. */ + double z2; +}; + +/** + * XLine Data. + */ +struct DXFLIB_EXPORT DL_XLineData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_XLineData(double bx, double by, double bz, + double dx, double dy, double dz) : + bx(bx), by(by), bz(bz), + dx(dx), dy(dy), dz(dz) { + } + + /*! X base point. */ + double bx; + /*! Y base point. */ + double by; + /*! Z base point. */ + double bz; + + /*! X direction vector. */ + double dx; + /*! Y direction vector. */ + double dy; + /*! Z direction vector. */ + double dz; +}; + +/** + * Ray Data. + */ +struct DXFLIB_EXPORT DL_RayData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_RayData(double bx, double by, double bz, + double dx, double dy, double dz) : + bx(bx), by(by), bz(bz), + dx(dx), dy(dy), dz(dz) { + } + + /*! X base point. */ + double bx; + /*! Y base point. */ + double by; + /*! Z base point. */ + double bz; + + /*! X direction vector. */ + double dx; + /*! Y direction vector. */ + double dy; + /*! Z direction vector. */ + double dz; }; /** * Arc Data. - * - * @author Andrew Mustun */ -struct DL_ArcData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_ArcData( double acx, double acy, double acz, - double aRadius, - double aAngle1, double aAngle2 ) - { +struct DXFLIB_EXPORT DL_ArcData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_ArcData(double acx, double acy, double acz, + double aRadius, + double aAngle1, double aAngle2) { - cx = acx; - cy = acy; - cz = acz; - radius = aRadius; - angle1 = aAngle1; - angle2 = aAngle2; - } + cx = acx; + cy = acy; + cz = acz; + radius = aRadius; + angle1 = aAngle1; + angle2 = aAngle2; + } - /*! X Coordinate of center point. */ - double cx; - /*! Y Coordinate of center point. */ - double cy; - /*! Z Coordinate of center point. */ - double cz; + /*! X Coordinate of center point. */ + double cx; + /*! Y Coordinate of center point. */ + double cy; + /*! Z Coordinate of center point. */ + double cz; - /*! Radius of arc. */ - double radius; - /*! Startangle of arc in degrees. */ - double angle1; - /*! Endangle of arc in degrees. */ - double angle2; + /*! Radius of arc. */ + double radius; + /*! Startangle of arc in degrees. */ + double angle1; + /*! Endangle of arc in degrees. */ + double angle2; }; /** * Circle Data. - * - * @author Andrew Mustun */ -struct DL_CircleData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_CircleData( double acx, double acy, double acz, - double aRadius ) - { +struct DXFLIB_EXPORT DL_CircleData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_CircleData(double acx, double acy, double acz, + double aRadius) { - cx = acx; - cy = acy; - cz = acz; - radius = aRadius; - } + cx = acx; + cy = acy; + cz = acz; + radius = aRadius; + } - /*! X Coordinate of center point. */ - double cx; - /*! Y Coordinate of center point. */ - double cy; - /*! Z Coordinate of center point. */ - double cz; + /*! X Coordinate of center point. */ + double cx; + /*! Y Coordinate of center point. */ + double cy; + /*! Z Coordinate of center point. */ + double cz; - /*! Radius of arc. */ - double radius; + /*! Radius of arc. */ + double radius; }; /** * Polyline Data. - * - * @author Andrew Mustun */ -struct DL_PolylineData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_PolylineData( int pNumber, int pMVerteces, int pNVerteces, int pFlags ) - { - number = pNumber; - m = pMVerteces; - n = pNVerteces; - flags = pFlags; - } +struct DXFLIB_EXPORT DL_PolylineData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_PolylineData(int pNumber, int pMVerteces, int pNVerteces, int pFlags) { + number = pNumber; + m = pMVerteces; + n = pNVerteces; + flags = pFlags; + } - /*! Number of vertices in this polyline. */ - unsigned int number; + /*! Number of vertices in this polyline. */ + unsigned int number; - /*! Number of vertices in m direction if polyline is a polygon mesh. */ - unsigned int m; + /*! Number of vertices in m direction if polyline is a polygon mesh. */ + unsigned int m; - /*! Number of vertices in n direction if polyline is a polygon mesh. */ - unsigned int n; + /*! Number of vertices in n direction if polyline is a polygon mesh. */ + unsigned int n; - /*! Flags */ - int flags; + /*! Flags */ + int flags; }; /** * Vertex Data. - * - * @author Andrew Mustun */ -struct DL_VertexData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_VertexData( double px = 0.0, double py = 0.0, double pz = 0.0, - double pBulge = 0.0 ) - { - x = px; - y = py; - z = pz; - bulge = pBulge; - } +struct DXFLIB_EXPORT DL_VertexData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_VertexData(double px=0.0, double py=0.0, double pz=0.0, + double pBulge=0.0) { + x = px; + y = py; + z = pz; + bulge = pBulge; + } - /*! X Coordinate of the vertex. */ - double x; - /*! Y Coordinate of the vertex. */ - double y; - /*! Z Coordinate of the vertex. */ - double z; - /*! Bulge of vertex. - * (The tangent of 1/4 of the arc angle or 0 for lines) */ - double bulge; + /*! X Coordinate of the vertex. */ + double x; + /*! Y Coordinate of the vertex. */ + double y; + /*! Z Coordinate of the vertex. */ + double z; + /*! Bulge of vertex. + * (The tangent of 1/4 of the arc angle or 0 for lines) */ + double bulge; }; /** - * Trace Data. - * - * @author AHM + * Trace Data / solid data / 3d face data. */ -struct DL_TraceData -{ - double x[4]; - double y[4]; - double z[4]; +struct DXFLIB_EXPORT DL_TraceData { + DL_TraceData() { + thickness = 0.0; + for (int i=0; i<4; i++) { + x[i] = 0.0; + y[i] = 0.0; + z[i] = 0.0; + } + } + + /** + * Constructor. + * Parameters: see member variables. + */ + DL_TraceData(double sx1, double sy1, double sz1, + double sx2, double sy2, double sz2, + double sx3, double sy3, double sz3, + double sx4, double sy4, double sz4, + double sthickness=0.0) { + + thickness = sthickness; + + x[0] = sx1; + y[0] = sy1; + z[0] = sz1; + + x[1] = sx2; + y[1] = sy2; + z[1] = sz2; + + x[2] = sx3; + y[2] = sy3; + z[2] = sz3; + + x[3] = sx4; + y[3] = sy4; + z[3] = sz4; + } + + /*! Thickness */ + double thickness; + + /*! Points */ + double x[4]; + double y[4]; + double z[4]; }; + + + /** * Solid Data. - * - * @author AHM */ typedef DL_TraceData DL_SolidData; /** - * Spline Data. - * - * @author Andrew Mustun + * 3dface Data. */ -struct DL_SplineData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_SplineData( int pDegree, int pNKnots, int pNControl, int pFlags ) - { - degree = pDegree; - nKnots = pNKnots; - nControl = pNControl; - flags = pFlags; - } +typedef DL_TraceData DL_3dFaceData; - /*! Degree of the spline curve. */ - unsigned int degree; - /*! Number of knots. */ - unsigned int nKnots; +/** + * Spline Data. + */ +struct DXFLIB_EXPORT DL_SplineData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_SplineData(int degree, + int nKnots, + int nControl, + int nFit, + int flags) : + degree(degree), + nKnots(nKnots), + nControl(nControl), + nFit(nFit), + flags(flags) { + } - /*! Number of control points. */ - unsigned int nControl; + /*! Degree of the spline curve. */ + unsigned int degree; - /*! Flags */ - int flags; + /*! Number of knots. */ + unsigned int nKnots; + + /*! Number of control points. */ + unsigned int nControl; + + /*! Number of fit points. */ + unsigned int nFit; + + /*! Flags */ + int flags; + + double tangentStartX; + double tangentStartY; + double tangentStartZ; + double tangentEndX; + double tangentEndY; + double tangentEndZ; }; /** * Spline knot data. - * - * @author Andrew Mustun */ -struct DL_KnotData -{ - DL_KnotData() {} - /** - * Constructor. - * Parameters: see member variables. - */ - DL_KnotData( double pk ) - { - k = pk; - } +struct DXFLIB_EXPORT DL_KnotData { + DL_KnotData() {} + /** + * Constructor. + * Parameters: see member variables. + */ + DL_KnotData(double pk) { + k = pk; + } - /*! Knot value. */ - double k; + /*! Knot value. */ + double k; }; /** * Spline control point data. - * - * @author Andrew Mustun */ -struct DL_ControlPointData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_ControlPointData( double px, double py, double pz ) - { - x = px; - y = py; - z = pz; - } +struct DXFLIB_EXPORT DL_ControlPointData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_ControlPointData(double px, double py, double pz, double weight) { + x = px; + y = py; + z = pz; + w = weight; + } - /*! X coordinate of the control point. */ - double x; - /*! Y coordinate of the control point. */ - double y; - /*! Z coordinate of the control point. */ - double z; + /*! X coordinate of the control point. */ + double x; + /*! Y coordinate of the control point. */ + double y; + /*! Z coordinate of the control point. */ + double z; + /*! Weight of control point. */ + double w; }; + +/** + * Spline fit point data. + */ +struct DXFLIB_EXPORT DL_FitPointData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_FitPointData(double x, double y, double z) : x(x), y(y), z(z) {} + + /*! X coordinate of the fit point. */ + double x; + /*! Y coordinate of the fit point. */ + double y; + /*! Z coordinate of the fit point. */ + double z; +}; + + + /** * Ellipse Data. - * - * @author Andrew Mustun */ -struct DL_EllipseData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_EllipseData( double ecx, double ecy, double ecz, - double emx, double emy, double emz, - double eRatio, - double eAngle1, double eAngle2 ) - { +struct DXFLIB_EXPORT DL_EllipseData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_EllipseData(double cx, double cy, double cz, + double mx, double my, double mz, + double ratio, + double angle1, double angle2) + : cx(cx), + cy(cy), + cz(cz), + mx(mx), + my(my), + mz(mz), + ratio(ratio), + angle1(angle1), + angle2(angle2) { + } - cx = ecx; - cy = ecy; - cz = ecz; - mx = emx; - my = emy; - mz = emz; - ratio = eRatio; - angle1 = eAngle1; - angle2 = eAngle2; - } + /*! X Coordinate of center point. */ + double cx; + /*! Y Coordinate of center point. */ + double cy; + /*! Z Coordinate of center point. */ + double cz; - /*! X Coordinate of center point. */ - double cx; - /*! Y Coordinate of center point. */ - double cy; - /*! Z Coordinate of center point. */ - double cz; + /*! X coordinate of the endpoint of the major axis. */ + double mx; + /*! Y coordinate of the endpoint of the major axis. */ + double my; + /*! Z coordinate of the endpoint of the major axis. */ + double mz; - /*! X coordinate of the endpoint of the major axis. */ - double mx; - /*! Y coordinate of the endpoint of the major axis. */ - double my; - /*! Z coordinate of the endpoint of the major axis. */ - double mz; - - /*! Ratio of minor axis to major axis.. */ - double ratio; - /*! Startangle of ellipse in rad. */ - double angle1; - /*! Endangle of ellipse in rad. */ - double angle2; + /*! Ratio of minor axis to major axis.. */ + double ratio; + /*! Startangle of ellipse in rad. */ + double angle1; + /*! Endangle of ellipse in rad. */ + double angle2; }; /** * Insert Data. - * - * @author Andrew Mustun */ -struct DL_InsertData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_InsertData( const string& iName, - double iipx, double iipy, double iipz, - double isx, double isy, double isz, - double iAngle, - int iCols, int iRows, - double iColSp, double iRowSp ) - { - name = iName; - ipx = iipx; - ipy = iipy; - ipz = iipz; - sx = isx; - sy = isy; - sz = isz; - angle = iAngle; - cols = iCols; - rows = iRows; - colSp = iColSp; - rowSp = iRowSp; - } +struct DXFLIB_EXPORT DL_InsertData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_InsertData(const std::string& name, + double ipx, double ipy, double ipz, + double sx, double sy, double sz, + double angle, + int cols, int rows, + double colSp, double rowSp) : + name(name), + ipx(ipx), ipy(ipy), ipz(ipz), + sx(sx), sy(sy), sz(sz), + angle(angle), + cols(cols), rows(rows), + colSp(colSp), rowSp(rowSp) { + } - /*! Name of the referred block. */ - string name; - /*! X Coordinate of insertion point. */ - double ipx; - /*! Y Coordinate of insertion point. */ - double ipy; - /*! Z Coordinate of insertion point. */ - double ipz; - /*! X Scale factor. */ - double sx; - /*! Y Scale factor. */ - double sy; - /*! Z Scale factor. */ - double sz; - /*! Rotation angle in rad. */ - double angle; - /*! Number of colums if we insert an array of the block or 1. */ - int cols; - /*! Number of rows if we insert an array of the block or 1. */ - int rows; - /*! Values for the spacing between cols. */ - double colSp; - /*! Values for the spacing between rows. */ - double rowSp; + /*! Name of the referred block. */ + std::string name; + /*! X Coordinate of insertion point. */ + double ipx; + /*! Y Coordinate of insertion point. */ + double ipy; + /*! Z Coordinate of insertion point. */ + double ipz; + /*! X Scale factor. */ + double sx; + /*! Y Scale factor. */ + double sy; + /*! Z Scale factor. */ + double sz; + /*! Rotation angle in degrees. */ + double angle; + /*! Number of colums if we insert an array of the block or 1. */ + int cols; + /*! Number of rows if we insert an array of the block or 1. */ + int rows; + /*! Values for the spacing between cols. */ + double colSp; + /*! Values for the spacing between rows. */ + double rowSp; }; /** * MText Data. - * - * @author Andrew Mustun */ -struct DL_MTextData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_MTextData( double tipx, double tipy, double tipz, - double tHeight, double tWidth, - int tAttachmentPoint, - int tDrawingDirection, - int tLineSpacingStyle, - double tLineSpacingFactor, - const string& tText, - const string& tStyle, - double tAngle ) - { - ipx = tipx; - ipy = tipy; - ipz = tipz; +struct DXFLIB_EXPORT DL_MTextData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_MTextData(double ipx, double ipy, double ipz, + double dirx, double diry, double dirz, + double height, double width, + int attachmentPoint, + int drawingDirection, + int lineSpacingStyle, + double lineSpacingFactor, + const std::string& text, + const std::string& style, + double angle) : + ipx(ipx), ipy(ipy), ipz(ipz), + dirx(dirx), diry(diry), dirz(dirz), + height(height), width(width), + attachmentPoint(attachmentPoint), + drawingDirection(drawingDirection), + lineSpacingStyle(lineSpacingStyle), + lineSpacingFactor(lineSpacingFactor), + text(text), + style(style), + angle(angle) { - height = tHeight; - width = tWidth; - attachmentPoint = tAttachmentPoint; - drawingDirection = tDrawingDirection; - lineSpacingStyle = tLineSpacingStyle; - lineSpacingFactor = tLineSpacingFactor; - text = tText; - style = tStyle; - angle = tAngle; - } + } - /*! X Coordinate of insertion point. */ - double ipx; - /*! Y Coordinate of insertion point. */ - double ipy; - /*! Z Coordinate of insertion point. */ - double ipz; - /*! Text height */ - double height; - /*! Width of the text box. */ - double width; - /** - * Attachment point. - * - * 1 = Top left, 2 = Top center, 3 = Top right, - * 4 = Middle left, 5 = Middle center, 6 = Middle right, - * 7 = Bottom left, 8 = Bottom center, 9 = Bottom right - */ - int attachmentPoint; - /** - * Drawing direction. - * - * 1 = left to right, 3 = top to bottom, 5 = by style - */ - int drawingDirection; - /** - * Line spacing style. - * - * 1 = at least, 2 = exact - */ - int lineSpacingStyle; - /** - * Line spacing factor. 0.25 .. 4.0 - */ - double lineSpacingFactor; - /*! Text string. */ - string text; - /*! Style string. */ - string style; - /*! Rotation angle. */ - double angle; + /*! X Coordinate of insertion point. */ + double ipx; + /*! Y Coordinate of insertion point. */ + double ipy; + /*! Z Coordinate of insertion point. */ + double ipz; + /*! X Coordinate of X direction vector. */ + double dirx; + /*! Y Coordinate of X direction vector. */ + double diry; + /*! Z Coordinate of X direction vector. */ + double dirz; + /*! Text height */ + double height; + /*! Width of the text box. */ + double width; + /** + * Attachment point. + * + * 1 = Top left, 2 = Top center, 3 = Top right, + * 4 = Middle left, 5 = Middle center, 6 = Middle right, + * 7 = Bottom left, 8 = Bottom center, 9 = Bottom right + */ + int attachmentPoint; + /** + * Drawing direction. + * + * 1 = left to right, 3 = top to bottom, 5 = by style + */ + int drawingDirection; + /** + * Line spacing style. + * + * 1 = at least, 2 = exact + */ + int lineSpacingStyle; + /** + * Line spacing factor. 0.25 .. 4.0 + */ + double lineSpacingFactor; + /*! Text string. */ + std::string text; + /*! Style string. */ + std::string style; + /*! Rotation angle. */ + double angle; }; /** * Text Data. - * - * @author Andrew Mustun */ -struct DL_TextData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_TextData( double tipx, double tipy, double tipz, - double tapx, double tapy, double tapz, - double tHeight, double tXScaleFactor, - int tTextGenerationFlags, - int tHJustification, - int tVJustification, - const string& tText, - const string& tStyle, - double tAngle ) - { - ipx = tipx; - ipy = tipy; - ipz = tipz; +struct DXFLIB_EXPORT DL_TextData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_TextData(double ipx, double ipy, double ipz, + double apx, double apy, double apz, + double height, double xScaleFactor, + int textGenerationFlags, + int hJustification, + int vJustification, + const std::string& text, + const std::string& style, + double angle) + : ipx(ipx), ipy(ipy), ipz(ipz), + apx(apx), apy(apy), apz(apz), + height(height), xScaleFactor(xScaleFactor), + textGenerationFlags(textGenerationFlags), + hJustification(hJustification), + vJustification(vJustification), + text(text), + style(style), + angle(angle) { + } - apx = tapx; - apy = tapy; - apz = tapz; + /*! X Coordinate of insertion point. */ + double ipx; + /*! Y Coordinate of insertion point. */ + double ipy; + /*! Z Coordinate of insertion point. */ + double ipz; - height = tHeight; - xScaleFactor = tXScaleFactor; - textGenerationFlags = tTextGenerationFlags; - hJustification = tHJustification; - vJustification = tVJustification; - text = tText; - style = tStyle; - angle = tAngle; - } + /*! X Coordinate of alignment point. */ + double apx; + /*! Y Coordinate of alignment point. */ + double apy; + /*! Z Coordinate of alignment point. */ + double apz; - /*! X Coordinate of insertion point. */ - double ipx; - /*! Y Coordinate of insertion point. */ - double ipy; - /*! Z Coordinate of insertion point. */ - double ipz; - - /*! X Coordinate of alignment point. */ - double apx; - /*! Y Coordinate of alignment point. */ - double apy; - /*! Z Coordinate of alignment point. */ - double apz; - - /*! Text height */ - double height; - /*! Relative X scale factor. */ - double xScaleFactor; - /*! 0 = default, 2 = Backwards, 4 = Upside down */ - int textGenerationFlags; - /** - * Horizontal justification. - * - * 0 = Left (default), 1 = Center, 2 = Right, - * 3 = Aligned, 4 = Middle, 5 = Fit - * For 3, 4, 5 the vertical alignment has to be 0. - */ - int hJustification; - /** - * Vertical justification. - * - * 0 = Baseline (default), 1 = Bottom, 2 = Middle, 3= Top - */ - int vJustification; - /*! Text string. */ - string text; - /*! Style (font). */ - string style; - /*! Rotation angle of dimension text away from default orientation. */ - double angle; + /*! Text height */ + double height; + /*! Relative X scale factor. */ + double xScaleFactor; + /*! 0 = default, 2 = Backwards, 4 = Upside down */ + int textGenerationFlags; + /** + * Horizontal justification. + * + * 0 = Left (default), 1 = Center, 2 = Right, + * 3 = Aligned, 4 = Middle, 5 = Fit + * For 3, 4, 5 the vertical alignment has to be 0. + */ + int hJustification; + /** + * Vertical justification. + * + * 0 = Baseline (default), 1 = Bottom, 2 = Middle, 3= Top + */ + int vJustification; + /*! Text string. */ + std::string text; + /*! Style (font). */ + std::string style; + /*! Rotation angle of dimension text away from default orientation. */ + double angle; }; +/** + * Block attribute data. + */ +struct DXFLIB_EXPORT DL_AttributeData : public DL_TextData { + DL_AttributeData(const DL_TextData& tData, const std::string& tag) + : DL_TextData(tData), tag(tag) { + + } + + /** + * Constructor. + * Parameters: see member variables. + */ + DL_AttributeData(double ipx, double ipy, double ipz, + double apx, double apy, double apz, + double height, double xScaleFactor, + int textGenerationFlags, + int hJustification, + int vJustification, + const std::string& tag, + const std::string& text, + const std::string& style, + double angle) + : DL_TextData(ipx, ipy, ipz, + apx, apy, apz, + height, xScaleFactor, + textGenerationFlags, + hJustification, + vJustification, + text, + style, + angle), + tag(tag) { + } + + /*! Tag. */ + std::string tag; +}; + /** * Generic Dimension Data. - * - * @author Andrew Mustun */ -struct DL_DimensionData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_DimensionData( double ddpx, double ddpy, double ddpz, - double dmpx, double dmpy, double dmpz, - int dType, - int dAttachmentPoint, - int dLineSpacingStyle, - double dLineSpacingFactor, - const string& dText, - const string& dStyle, - double dAngle ) - { +struct DXFLIB_EXPORT DL_DimensionData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimensionData(double dpx, double dpy, double dpz, + double mpx, double mpy, double mpz, + int type, + int attachmentPoint, + int lineSpacingStyle, + double lineSpacingFactor, + const std::string& text, + const std::string& style, + double angle, + double linearFactor = 1.0) : + dpx(dpx), dpy(dpy), dpz(dpz), + mpx(mpx), mpy(mpy), mpz(mpz), + type(type), + attachmentPoint(attachmentPoint), + lineSpacingStyle(lineSpacingStyle), + lineSpacingFactor(lineSpacingFactor), + text(text), + style(style), + angle(angle), + linearFactor(linearFactor) { - dpx = ddpx; - dpy = ddpy; - dpz = ddpz; + } - mpx = dmpx; - mpy = dmpy; - mpz = dmpz; - - type = dType; - - attachmentPoint = dAttachmentPoint; - lineSpacingStyle = dLineSpacingStyle; - lineSpacingFactor = dLineSpacingFactor; - text = dText; - style = dStyle; - angle = dAngle; - } - - /*! X Coordinate of definition point. */ - double dpx; - /*! Y Coordinate of definition point. */ - double dpy; - /*! Z Coordinate of definition point. */ - double dpz; - /*! X Coordinate of middle point of the text. */ - double mpx; - /*! Y Coordinate of middle point of the text. */ - double mpy; - /*! Z Coordinate of middle point of the text. */ - double mpz; - /** - * Dimension type. - * - * 0 Rotated, horizontal, or vertical - * 1 Aligned - * 2 Angular - * 3 Diametric - * 4 Radius - * 5 Angular 3-point - * 6 Ordinate - * 64 Ordinate type. This is a bit value (bit 7) - * used only with integer value 6. If set, - * ordinate is X-type; if not set, ordinate is - * Y-type - * 128 This is a bit value (bit 8) added to the - * other group 70 values if the dimension text - * has been positioned at a user-defined - * location rather than at the default location - */ - int type; - /** - * Attachment point. - * - * 1 = Top left, 2 = Top center, 3 = Top right, - * 4 = Middle left, 5 = Middle center, 6 = Middle right, - * 7 = Bottom left, 8 = Bottom center, 9 = Bottom right, - */ - int attachmentPoint; - /** - * Line spacing style. - * - * 1 = at least, 2 = exact - */ - int lineSpacingStyle; - /** - * Line spacing factor. 0.25 .. 4.0 - */ - double lineSpacingFactor; - /** - * Text string. - * - * Text string entered explicitly by user or null - * or "<>" for the actual measurement or " " (one blank space). - * for supressing the text. - */ - string text; - /*! Dimension style (font name). */ - string style; - /** - * Rotation angle of dimension text away from - * default orientation. - */ - double angle; + /*! X Coordinate of definition point. */ + double dpx; + /*! Y Coordinate of definition point. */ + double dpy; + /*! Z Coordinate of definition point. */ + double dpz; + /*! X Coordinate of middle point of the text. */ + double mpx; + /*! Y Coordinate of middle point of the text. */ + double mpy; + /*! Z Coordinate of middle point of the text. */ + double mpz; + /** + * Dimension type. + * + * 0 Rotated, horizontal, or vertical + * 1 Aligned + * 2 Angular + * 3 Diametric + * 4 Radius + * 5 Angular 3-point + * 6 Ordinate + * 64 Ordinate type. This is a bit value (bit 7) + * used only with integer value 6. If set, + * ordinate is X-type; if not set, ordinate is + * Y-type + * 128 This is a bit value (bit 8) added to the + * other group 70 values if the dimension text + * has been positioned at a user-defined + * location rather than at the default location + */ + int type; + /** + * Attachment point. + * + * 1 = Top left, 2 = Top center, 3 = Top right, + * 4 = Middle left, 5 = Middle center, 6 = Middle right, + * 7 = Bottom left, 8 = Bottom center, 9 = Bottom right, + */ + int attachmentPoint; + /** + * Line spacing style. + * + * 1 = at least, 2 = exact + */ + int lineSpacingStyle; + /** + * Line spacing factor. 0.25 .. 4.0 + */ + double lineSpacingFactor; + /** + * Text string. + * + * Text string entered explicitly by user or null + * or "<>" for the actual measurement or " " (one blank space). + * for supressing the text. + */ + std::string text; + /*! Dimension style (font name). */ + std::string style; + /** + * Rotation angle of dimension text away from + * default orientation. + */ + double angle; + /** + * Linear factor style override. + */ + double linearFactor; }; /** * Aligned Dimension Data. - * - * @author Andrew Mustun */ -struct DL_DimAlignedData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_DimAlignedData( double depx1, double depy1, double depz1, - double depx2, double depy2, double depz2 ) - { +struct DXFLIB_EXPORT DL_DimAlignedData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimAlignedData(double depx1, double depy1, double depz1, + double depx2, double depy2, double depz2) { - epx1 = depx1; - epy1 = depy1; - epz1 = depz1; + epx1 = depx1; + epy1 = depy1; + epz1 = depz1; - epx2 = depx2; - epy2 = depy2; - epz2 = depz2; - } + epx2 = depx2; + epy2 = depy2; + epz2 = depz2; + } - /*! X Coordinate of Extension point 1. */ - double epx1; - /*! Y Coordinate of Extension point 1. */ - double epy1; - /*! Z Coordinate of Extension point 1. */ - double epz1; + /*! X Coordinate of Extension point 1. */ + double epx1; + /*! Y Coordinate of Extension point 1. */ + double epy1; + /*! Z Coordinate of Extension point 1. */ + double epz1; - /*! X Coordinate of Extension point 2. */ - double epx2; - /*! Y Coordinate of Extension point 2. */ - double epy2; - /*! Z Coordinate of Extension point 2. */ - double epz2; + /*! X Coordinate of Extension point 2. */ + double epx2; + /*! Y Coordinate of Extension point 2. */ + double epy2; + /*! Z Coordinate of Extension point 2. */ + double epz2; }; /** - * Linear Dimension Data. - * - * @author Andrew Mustun + * Linear (rotated) Dimension Data. */ -struct DL_DimLinearData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_DimLinearData( double ddpx1, double ddpy1, double ddpz1, - double ddpx2, double ddpy2, double ddpz2, - double dAngle, double dOblique ) - { +struct DXFLIB_EXPORT DL_DimLinearData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimLinearData(double ddpx1, double ddpy1, double ddpz1, + double ddpx2, double ddpy2, double ddpz2, + double dAngle, double dOblique) { - dpx1 = ddpx1; - dpy1 = ddpy1; - dpz1 = ddpz1; + dpx1 = ddpx1; + dpy1 = ddpy1; + dpz1 = ddpz1; - dpx2 = ddpx2; - dpy2 = ddpy2; - dpz2 = ddpz2; + dpx2 = ddpx2; + dpy2 = ddpy2; + dpz2 = ddpz2; - angle = dAngle; - oblique = dOblique; - } + angle = dAngle; + oblique = dOblique; + } - /*! X Coordinate of Extension point 1. */ - double dpx1; - /*! Y Coordinate of Extension point 1. */ - double dpy1; - /*! Z Coordinate of Extension point 1. */ - double dpz1; + /*! X Coordinate of Extension point 1. */ + double dpx1; + /*! Y Coordinate of Extension point 1. */ + double dpy1; + /*! Z Coordinate of Extension point 1. */ + double dpz1; - /*! X Coordinate of Extension point 2. */ - double dpx2; - /*! Y Coordinate of Extension point 2. */ - double dpy2; - /*! Z Coordinate of Extension point 2. */ - double dpz2; + /*! X Coordinate of Extension point 2. */ + double dpx2; + /*! Y Coordinate of Extension point 2. */ + double dpy2; + /*! Z Coordinate of Extension point 2. */ + double dpz2; - /*! Rotation angle (angle of dimension line) in degrees. */ - double angle; - /*! Oblique angle in degrees. */ - double oblique; + /*! Rotation angle (angle of dimension line) in degrees. */ + double angle; + /*! Oblique angle in degrees. */ + double oblique; }; /** * Radial Dimension Data. - * - * @author Andrew Mustun */ -struct DL_DimRadialData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_DimRadialData( double ddpx, double ddpy, double ddpz, double dleader ) - { - dpx = ddpx; - dpy = ddpy; - dpz = ddpz; +struct DXFLIB_EXPORT DL_DimRadialData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimRadialData(double ddpx, double ddpy, double ddpz, double dleader) { + dpx = ddpx; + dpy = ddpy; + dpz = ddpz; - leader = dleader; - } + leader = dleader; + } - /*! X Coordinate of definition point. */ - double dpx; - /*! Y Coordinate of definition point. */ - double dpy; - /*! Z Coordinate of definition point. */ - double dpz; + /*! X Coordinate of definition point. */ + double dpx; + /*! Y Coordinate of definition point. */ + double dpy; + /*! Z Coordinate of definition point. */ + double dpz; - /*! Leader length */ - double leader; + /*! Leader length */ + double leader; }; /** * Diametric Dimension Data. - * - * @author Andrew Mustun */ -struct DL_DimDiametricData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_DimDiametricData( double ddpx, double ddpy, double ddpz, double dleader ) - { - dpx = ddpx; - dpy = ddpy; - dpz = ddpz; +struct DXFLIB_EXPORT DL_DimDiametricData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimDiametricData(double ddpx, double ddpy, double ddpz, double dleader) { + dpx = ddpx; + dpy = ddpy; + dpz = ddpz; - leader = dleader; - } + leader = dleader; + } - /*! X Coordinate of definition point. */ - double dpx; - /*! Y Coordinate of definition point. */ - double dpy; - /*! Z Coordinate of definition point. */ - double dpz; + /*! X Coordinate of definition point (DXF 15). */ + double dpx; + /*! Y Coordinate of definition point (DXF 25). */ + double dpy; + /*! Z Coordinate of definition point (DXF 35). */ + double dpz; - /*! Leader length */ - double leader; + /*! Leader length */ + double leader; }; /** * Angular Dimension Data. - * - * @author Andrew Mustun */ -struct DL_DimAngularData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_DimAngularData( double ddpx1, double ddpy1, double ddpz1, - double ddpx2, double ddpy2, double ddpz2, - double ddpx3, double ddpy3, double ddpz3, - double ddpx4, double ddpy4, double ddpz4 ) - { +struct DXFLIB_EXPORT DL_DimAngularData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimAngularData(double ddpx1, double ddpy1, double ddpz1, + double ddpx2, double ddpy2, double ddpz2, + double ddpx3, double ddpy3, double ddpz3, + double ddpx4, double ddpy4, double ddpz4) { - dpx1 = ddpx1; - dpy1 = ddpy1; - dpz1 = ddpz1; + dpx1 = ddpx1; + dpy1 = ddpy1; + dpz1 = ddpz1; - dpx2 = ddpx2; - dpy2 = ddpy2; - dpz2 = ddpz2; + dpx2 = ddpx2; + dpy2 = ddpy2; + dpz2 = ddpz2; - dpx3 = ddpx3; - dpy3 = ddpy3; - dpz3 = ddpz3; + dpx3 = ddpx3; + dpy3 = ddpy3; + dpz3 = ddpz3; - dpx4 = ddpx4; - dpy4 = ddpy4; - dpz4 = ddpz4; - } + dpx4 = ddpx4; + dpy4 = ddpy4; + dpz4 = ddpz4; + } - /*! X Coordinate of definition point 1. */ - double dpx1; - /*! Y Coordinate of definition point 1. */ - double dpy1; - /*! Z Coordinate of definition point 1. */ - double dpz1; + /*! X Coordinate of definition point 1. */ + double dpx1; + /*! Y Coordinate of definition point 1. */ + double dpy1; + /*! Z Coordinate of definition point 1. */ + double dpz1; - /*! X Coordinate of definition point 2. */ - double dpx2; - /*! Y Coordinate of definition point 2. */ - double dpy2; - /*! Z Coordinate of definition point 2. */ - double dpz2; + /*! X Coordinate of definition point 2. */ + double dpx2; + /*! Y Coordinate of definition point 2. */ + double dpy2; + /*! Z Coordinate of definition point 2. */ + double dpz2; - /*! X Coordinate of definition point 3. */ - double dpx3; - /*! Y Coordinate of definition point 3. */ - double dpy3; - /*! Z Coordinate of definition point 3. */ - double dpz3; + /*! X Coordinate of definition point 3. */ + double dpx3; + /*! Y Coordinate of definition point 3. */ + double dpy3; + /*! Z Coordinate of definition point 3. */ + double dpz3; - /*! X Coordinate of definition point 4. */ - double dpx4; - /*! Y Coordinate of definition point 4. */ - double dpy4; - /*! Z Coordinate of definition point 4. */ - double dpz4; + /*! X Coordinate of definition point 4. */ + double dpx4; + /*! Y Coordinate of definition point 4. */ + double dpy4; + /*! Z Coordinate of definition point 4. */ + double dpz4; }; /** * Angular Dimension Data (3 points version). - * - * @author Andrew Mustun */ -struct DL_DimAngular3PData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_DimAngular3PData( double ddpx1, double ddpy1, double ddpz1, - double ddpx2, double ddpy2, double ddpz2, - double ddpx3, double ddpy3, double ddpz3 ) - { +struct DXFLIB_EXPORT DL_DimAngular3PData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimAngular3PData(double ddpx1, double ddpy1, double ddpz1, + double ddpx2, double ddpy2, double ddpz2, + double ddpx3, double ddpy3, double ddpz3) { - dpx1 = ddpx1; - dpy1 = ddpy1; - dpz1 = ddpz1; + dpx1 = ddpx1; + dpy1 = ddpy1; + dpz1 = ddpz1; - dpx2 = ddpx2; - dpy2 = ddpy2; - dpz2 = ddpz2; + dpx2 = ddpx2; + dpy2 = ddpy2; + dpz2 = ddpz2; - dpx3 = ddpx3; - dpy3 = ddpy3; - dpz3 = ddpz3; - } + dpx3 = ddpx3; + dpy3 = ddpy3; + dpz3 = ddpz3; + } - /*! X Coordinate of definition point 1. */ - double dpx1; - /*! Y Coordinate of definition point 1. */ - double dpy1; - /*! Z Coordinate of definition point 1. */ - double dpz1; + /*! X Coordinate of definition point 1. */ + double dpx1; + /*! Y Coordinate of definition point 1. */ + double dpy1; + /*! Z Coordinate of definition point 1. */ + double dpz1; - /*! X Coordinate of definition point 2. */ - double dpx2; - /*! Y Coordinate of definition point 2. */ - double dpy2; - /*! Z Coordinate of definition point 2. */ - double dpz2; + /*! X Coordinate of definition point 2. */ + double dpx2; + /*! Y Coordinate of definition point 2. */ + double dpy2; + /*! Z Coordinate of definition point 2. */ + double dpz2; - /*! X Coordinate of definition point 3. */ - double dpx3; - /*! Y Coordinate of definition point 3. */ - double dpy3; - /*! Z Coordinate of definition point 3. */ - double dpz3; + /*! X Coordinate of definition point 3. */ + double dpx3; + /*! Y Coordinate of definition point 3. */ + double dpy3; + /*! Z Coordinate of definition point 3. */ + double dpz3; +}; + + + +/** + * Ordinate Dimension Data. + */ +struct DXFLIB_EXPORT DL_DimOrdinateData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_DimOrdinateData(double ddpx1, double ddpy1, double ddpz1, + double ddpx2, double ddpy2, double ddpz2, + bool dxtype) { + + dpx1 = ddpx1; + dpy1 = ddpy1; + dpz1 = ddpz1; + + dpx2 = ddpx2; + dpy2 = ddpy2; + dpz2 = ddpz2; + + xtype = dxtype; + } + + /*! X Coordinate of definition point 1. */ + double dpx1; + /*! Y Coordinate of definition point 1. */ + double dpy1; + /*! Z Coordinate of definition point 1. */ + double dpz1; + + /*! X Coordinate of definition point 2. */ + double dpx2; + /*! Y Coordinate of definition point 2. */ + double dpy2; + /*! Z Coordinate of definition point 2. */ + double dpz2; + + /*! True if the dimension indicates the X-value, false for Y-value */ + bool xtype; }; /** * Leader (arrow). - * - * @author Andrew Mustun */ -struct DL_LeaderData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_LeaderData( int lArrowHeadFlag, - int lLeaderPathType, - int lLeaderCreationFlag, - int lHooklineDirectionFlag, - int lHooklineFlag, - double lTextAnnotationHeight, - double lTextAnnotationWidth, - int lNumber ) - { +struct DXFLIB_EXPORT DL_LeaderData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LeaderData(int lArrowHeadFlag, + int lLeaderPathType, + int lLeaderCreationFlag, + int lHooklineDirectionFlag, + int lHooklineFlag, + double lTextAnnotationHeight, + double lTextAnnotationWidth, + int lNumber) { - arrowHeadFlag = lArrowHeadFlag; - leaderPathType = lLeaderPathType; - leaderCreationFlag = lLeaderCreationFlag; - hooklineDirectionFlag = lHooklineDirectionFlag; - hooklineFlag = lHooklineFlag; - textAnnotationHeight = lTextAnnotationHeight; - textAnnotationWidth = lTextAnnotationWidth; - number = lNumber; - } + arrowHeadFlag = lArrowHeadFlag; + leaderPathType = lLeaderPathType; + leaderCreationFlag = lLeaderCreationFlag; + hooklineDirectionFlag = lHooklineDirectionFlag; + hooklineFlag = lHooklineFlag; + textAnnotationHeight = lTextAnnotationHeight; + textAnnotationWidth = lTextAnnotationWidth; + number = lNumber; + } - /*! Arrow head flag (71). */ - int arrowHeadFlag; - /*! Leader path type (72). */ - int leaderPathType; - /*! Leader creation flag (73). */ - int leaderCreationFlag; - /*! Hookline direction flag (74). */ - int hooklineDirectionFlag; - /*! Hookline flag (75) */ - int hooklineFlag; - /*! Text annotation height (40). */ - double textAnnotationHeight; - /*! Text annotation width (41) */ - double textAnnotationWidth; - /*! Number of vertices in leader (76). */ - int number; + /*! Arrow head flag (71). */ + int arrowHeadFlag; + /*! Leader path type (72). */ + int leaderPathType; + /*! Leader creation flag (73). */ + int leaderCreationFlag; + /*! Hookline direction flag (74). */ + int hooklineDirectionFlag; + /*! Hookline flag (75) */ + int hooklineFlag; + /*! Text annotation height (40). */ + double textAnnotationHeight; + /*! Text annotation width (41) */ + double textAnnotationWidth; + /*! Number of vertices in leader (76). */ + int number; }; /** * Leader Vertex Data. - * - * @author Andrew Mustun */ -struct DL_LeaderVertexData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_LeaderVertexData( double px = 0.0, double py = 0.0, double pz = 0.0 ) - { - x = px; - y = py; - z = pz; - } +struct DXFLIB_EXPORT DL_LeaderVertexData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_LeaderVertexData(double px=0.0, double py=0.0, double pz=0.0) { + x = px; + y = py; + z = pz; + } - /*! X Coordinate of the vertex. */ - double x; - /*! Y Coordinate of the vertex. */ - double y; - /*! Z Coordinate of the vertex. */ - double z; + /*! X Coordinate of the vertex. */ + double x; + /*! Y Coordinate of the vertex. */ + double y; + /*! Z Coordinate of the vertex. */ + double z; }; @@ -1177,40 +1371,46 @@ struct DL_LeaderVertexData /** * Hatch data. */ -struct DL_HatchData -{ - /** - * Default constructor. - */ - DL_HatchData() {} +struct DXFLIB_EXPORT DL_HatchData { + /** + * Default constructor. + */ + DL_HatchData() {} - /** - * Constructor. - * Parameters: see member variables. - */ - DL_HatchData( int hNumLoops, - bool hSolid, - double hScale, - double hAngle, - const string& hPattern ) - { - numLoops = hNumLoops; - solid = hSolid; - scale = hScale; - angle = hAngle; - pattern = hPattern; - } + /** + * Constructor. + * Parameters: see member variables. + */ + DL_HatchData(int numLoops, + bool solid, + double scale, + double angle, + const std::string& pattern, + double originX = 0.0, + double originY = 0.0) : + numLoops(numLoops), + solid(solid), + scale(scale), + angle(angle), + pattern(pattern), + originX(originX), + originY(originY) { - /*! Number of boundary paths (loops). */ - int numLoops; - /*! Solid fill flag (true=solid, false=pattern). */ - bool solid; - /*! Pattern scale or spacing */ - double scale; - /*! Pattern angle */ - double angle; - /*! Pattern name. */ - string pattern; + } + + /*! Number of boundary paths (loops). */ + int numLoops; + /*! Solid fill flag (true=solid, false=pattern). */ + bool solid; + /*! Pattern scale or spacing */ + double scale; + /*! Pattern angle in degrees */ + double angle; + /*! Pattern name. */ + std::string pattern; + /*! Pattern origin */ + double originX; + double originY; }; @@ -1218,23 +1418,21 @@ struct DL_HatchData /** * Hatch boundary path (loop) data. */ -struct DL_HatchLoopData -{ - /** - * Default constructor. - */ - DL_HatchLoopData() : numEdges( 0 ) {} - /** - * Constructor. - * Parameters: see member variables. - */ - DL_HatchLoopData( int hNumEdges ) - { - numEdges = hNumEdges; - } +struct DXFLIB_EXPORT DL_HatchLoopData { + /** + * Default constructor. + */ + DL_HatchLoopData() {} + /** + * Constructor. + * Parameters: see member variables. + */ + DL_HatchLoopData(int hNumEdges) { + numEdges = hNumEdges; + } - /*! Number of edges in this loop. */ - int numEdges; + /*! Number of edges in this loop. */ + int numEdges; }; @@ -1242,193 +1440,284 @@ struct DL_HatchLoopData /** * Hatch edge data. */ -struct DL_HatchEdgeData -{ - /** - * Default constructor. - */ - DL_HatchEdgeData() - : type( 1 ) - , defined( false ) - , x1( 0. ), y1( 0. ) - , x2( 0. ), y2( 0. ) - , cx( 0. ), cy( 0. ) - , radius( 0. ) - , angle1( 0. ) - , angle2( 0. ) - , ccw( false ) - { - } +struct DXFLIB_EXPORT DL_HatchEdgeData { + /** + * Default constructor. + */ + DL_HatchEdgeData() : defined(false), x1(0.0), y1(0.0), x2(0.0), y2(0.0) { + } - /** - * Constructor for a line edge. - * Parameters: see member variables. - */ - DL_HatchEdgeData( double lx1, double ly1, - double lx2, double ly2 ) - : type( 1 ) - , defined( true ) - , x1( lx1 ), y1( ly1 ) - , x2( lx2 ), y2( ly2 ) - , cx( 0. ), cy( 0. ) - , radius( 0. ) - , angle1( 0. ) - , angle2( 0. ) - , ccw( false ) - { - } + /** + * Constructor for a line edge. + * Parameters: see member variables. + */ + DL_HatchEdgeData(double x1, double y1, + double x2, double y2) : + defined(true), + type(1), + x1(x1), + y1(y1), + x2(x2), + y2(y2) { + } - /** - * Constructor for an arc edge. - * Parameters: see member variables. - */ - DL_HatchEdgeData( double acx, double acy, - double aRadius, - double aAngle1, double aAngle2, - bool aCcw ) - : type( 2 ) - , defined( true ) - , x1( 0. ), y1( 0. ) - , x2( 0. ), y2( 0. ) - , cx( acx ), cy( acy ) - , radius( aRadius ) - , angle1( aAngle1 ) - , angle2( aAngle2 ) - , ccw( aCcw ) - { - } + /** + * Constructor for an arc edge. + * Parameters: see member variables. + */ + DL_HatchEdgeData(double cx, double cy, + double radius, + double angle1, double angle2, + bool ccw) : + defined(true), + type(2), + cx(cx), + cy(cy), + radius(radius), + angle1(angle1), + angle2(angle2), + ccw(ccw) { + } - /** - * Edge type. 1=line, 2=arc. - */ - int type; + /** + * Constructor for an ellipse arc edge. + * Parameters: see member variables. + */ + DL_HatchEdgeData(double cx, double cy, + double mx, double my, + double ratio, + double angle1, double angle2, + bool ccw) : + defined(true), + type(3), + cx(cx), + cy(cy), + angle1(angle1), + angle2(angle2), + ccw(ccw), + mx(mx), + my(my), + ratio(ratio) { + } - /** - * Set to true if this edge is fully defined. - */ - bool defined; + /** + * Constructor for a spline edge. + * Parameters: see member variables. + */ + DL_HatchEdgeData(unsigned int degree, + bool rational, + bool periodic, + unsigned int nKnots, + unsigned int nControl, + unsigned int nFit, + const std::vector& knots, + const std::vector >& controlPoints, + const std::vector >& fitPoints, + const std::vector& weights, + double startTangentX, + double startTangentY, + double endTangentX, + double endTangentY) : + defined(true), + type(4), + degree(degree), + rational(rational), + periodic(periodic), + nKnots(nKnots), + nControl(nControl), + nFit(nFit), + controlPoints(controlPoints), + knots(knots), + weights(weights), + fitPoints(fitPoints), + startTangentX(startTangentX), + startTangentY(startTangentY), + endTangentX(endTangentX), + endTangentY(endTangentY) { + } - /*! Start point (X). */ - double x1; - /*! Start point (Y). */ - double y1; - /*! End point (X). */ - double x2; - /*! End point (Y). */ - double y2; - /*! Center point of arc (X). */ - double cx; - /*! Center point of arc (Y). */ - double cy; - /*! Arc radius. */ - double radius; - /*! Start angle. */ - double angle1; - /*! End angle. */ - double angle2; - /*! Counterclockwise flag. */ - bool ccw; + /** + * Set to true if this edge is fully defined. + */ + bool defined; + + /** + * Edge type. 1=line, 2=arc, 3=elliptic arc, 4=spline. + */ + int type; + + // line edges: + + /*! Start point (X). */ + double x1; + /*! Start point (Y). */ + double y1; + /*! End point (X). */ + double x2; + /*! End point (Y). */ + double y2; + + /*! Center point of arc or ellipse arc (X). */ + double cx; + /*! Center point of arc or ellipse arc (Y). */ + double cy; + /*! Arc radius. */ + double radius; + /*! Start angle of arc or ellipse arc. */ + double angle1; + /*! End angle of arc or ellipse arc. */ + double angle2; + /*! Counterclockwise flag for arc or ellipse arc. */ + bool ccw; + + /*! Major axis end point (X). */ + double mx; + /*! Major axis end point (Y). */ + double my; + /*! Axis ratio */ + double ratio; + + + /*! Spline degree */ + unsigned int degree; + bool rational; + bool periodic; + /*! Number of knots. */ + unsigned int nKnots; + /*! Number of control points. */ + unsigned int nControl; + /*! Number of fit points. */ + unsigned int nFit; + + std::vector > controlPoints; + std::vector knots; + std::vector weights; + std::vector > fitPoints; + + double startTangentX; + double startTangentY; + + double endTangentX; + double endTangentY; + + /** Polyline boundary vertices (x y [bulge])*/ + std::vector > vertices; + //bool closed; }; /** * Image Data. - * - * @author Andrew Mustun */ -struct DL_ImageData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_ImageData( const string& iref, - double iipx, double iipy, double iipz, - double iux, double iuy, double iuz, - double ivx, double ivy, double ivz, - int iwidth, int iheight, - int ibrightness, int icontrast, int ifade ) - { - ref = iref; - ipx = iipx; - ipy = iipy; - ipz = iipz; - ux = iux; - uy = iuy; - uz = iuz; - vx = ivx; - vy = ivy; - vz = ivz; - width = iwidth; - height = iheight; - brightness = ibrightness; - contrast = icontrast; - fade = ifade; - } +struct DXFLIB_EXPORT DL_ImageData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_ImageData(const std::string& iref, + double iipx, double iipy, double iipz, + double iux, double iuy, double iuz, + double ivx, double ivy, double ivz, + int iwidth, int iheight, + int ibrightness, int icontrast, int ifade) { + ref = iref; + ipx = iipx; + ipy = iipy; + ipz = iipz; + ux = iux; + uy = iuy; + uz = iuz; + vx = ivx; + vy = ivy; + vz = ivz; + width = iwidth; + height = iheight; + brightness = ibrightness; + contrast = icontrast; + fade = ifade; + } - /*! Reference to the image file - (unique, used to refer to the image def object). */ - string ref; - /*! X Coordinate of insertion point. */ - double ipx; - /*! Y Coordinate of insertion point. */ - double ipy; - /*! Z Coordinate of insertion point. */ - double ipz; - /*! X Coordinate of u vector along bottom of image. */ - double ux; - /*! Y Coordinate of u vector along bottom of image. */ - double uy; - /*! Z Coordinate of u vector along bottom of image. */ - double uz; - /*! X Coordinate of v vector along left side of image. */ - double vx; - /*! Y Coordinate of v vector along left side of image. */ - double vy; - /*! Z Coordinate of v vector along left side of image. */ - double vz; - /*! Width of image in pixel. */ - int width; - /*! Height of image in pixel. */ - int height; - /*! Brightness (0..100, default = 50). */ - int brightness; - /*! Contrast (0..100, default = 50). */ - int contrast; - /*! Fade (0..100, default = 0). */ - int fade; + /*! Reference to the image file + (unique, used to refer to the image def object). */ + std::string ref; + /*! X Coordinate of insertion point. */ + double ipx; + /*! Y Coordinate of insertion point. */ + double ipy; + /*! Z Coordinate of insertion point. */ + double ipz; + /*! X Coordinate of u vector along bottom of image. */ + double ux; + /*! Y Coordinate of u vector along bottom of image. */ + double uy; + /*! Z Coordinate of u vector along bottom of image. */ + double uz; + /*! X Coordinate of v vector along left side of image. */ + double vx; + /*! Y Coordinate of v vector along left side of image. */ + double vy; + /*! Z Coordinate of v vector along left side of image. */ + double vz; + /*! Width of image in pixel. */ + int width; + /*! Height of image in pixel. */ + int height; + /*! Brightness (0..100, default = 50). */ + int brightness; + /*! Contrast (0..100, default = 50). */ + int contrast; + /*! Fade (0..100, default = 0). */ + int fade; }; /** * Image Definition Data. - * - * @author Andrew Mustun */ -struct DL_ImageDefData -{ - /** - * Constructor. - * Parameters: see member variables. - */ - DL_ImageDefData( const string& iref, - const string& ifile ) - { - ref = iref; - file = ifile; - } +struct DXFLIB_EXPORT DL_ImageDefData { + /** + * Constructor. + * Parameters: see member variables. + */ + DL_ImageDefData(const std::string& iref, + const std::string& ifile) { + ref = iref; + file = ifile; + } - /*! Reference to the image file - (unique, used to refer to the image def object). */ - string ref; + /*! Reference to the image file + (unique, used to refer to the image def object). */ + std::string ref; - /*! Image file */ - string file; + /*! Image file */ + std::string file; +}; + + + +/** + * Dictionary data. + */ +struct DXFLIB_EXPORT DL_DictionaryData { + DL_DictionaryData(const std::string& handle) : handle(handle) {} + std::string handle; +}; + + + +/** + * Dictionary entry data. + */ +struct DXFLIB_EXPORT DL_DictionaryEntryData { + DL_DictionaryEntryData(const std::string& name, const std::string& handle) : + name(name), handle(handle) {} + + std::string name; + std::string handle; }; #endif // EOF - diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_exception.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_exception.h index b372937ce1a..7fd944b1329 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_exception.h +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_exception.h @@ -1,21 +1,15 @@ /**************************************************************************** -** $Id: dl_exception.h 163 2003-07-01 15:51:48Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** Copyright (C) 2001 Robert J. Campbell Jr. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -32,6 +26,8 @@ #ifndef DL_EXCEPTION_H #define DL_EXCEPTION_H +#include "dl_global.h" + #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 @@ -39,21 +35,21 @@ /** * Used for exception handling. */ -class DL_Exception {} +class DXFLIB_EXPORT DL_Exception {} ; /** * Used for exception handling. */ -class DL_NullStrExc : public DL_Exception {} +class DXFLIB_EXPORT DL_NullStrExc : public DL_Exception {} ; /** * Used for exception handling. */ -class DL_GroupCodeExc : public DL_Exception -{ - DL_GroupCodeExc() {} +class DXFLIB_EXPORT DL_GroupCodeExc : public DL_Exception { + DL_GroupCodeExc(int gc=0) : groupCode(gc) {} + int groupCode; }; #endif diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h index 289e1c3e501..c36315b7e18 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h @@ -1,20 +1,14 @@ /**************************************************************************** -** $Id: dl_extrusion.h 273 2005-02-28 18:14:39Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -31,6 +25,8 @@ #ifndef DL_EXTRUSION_H #define DL_EXTRUSION_H +#include "dl_global.h" + #include @@ -40,28 +36,25 @@ * * @author Andrew Mustun */ -class DL_Extrusion -{ +class DXFLIB_EXPORT DL_Extrusion { - public: +public: /** * Default constructor. */ - DL_Extrusion() - { - direction = new double[3]; - setDirection( 0.0, 0.0, 1.0 ); - setElevation( 0.0 ); + DL_Extrusion() { + direction = new double[3]; + setDirection(0.0, 0.0, 1.0); + setElevation(0.0); } /** * Destructor. */ - ~DL_Extrusion() - { - delete direction; + ~DL_Extrusion() { + delete[] direction ; } @@ -73,23 +66,21 @@ class DL_Extrusion * @param elevation Distance of the entities XY plane from the origin of the * world coordinate system */ - DL_Extrusion( double dx, double dy, double dz, double elevation ) - { - direction = new double[3]; - setDirection( dx, dy, dz ); - setElevation( elevation ); + DL_Extrusion(double dx, double dy, double dz, double elevation) { + direction = new double[3]; + setDirection(dx, dy, dz); + setElevation(elevation); } /** - * Sets the direction vector. + * Sets the direction vector. */ - void setDirection( double dx, double dy, double dz ) - { - direction[0] = dx; - direction[1] = dy; - direction[2] = dz; + void setDirection(double dx, double dy, double dz) { + direction[0]=dx; + direction[1]=dy; + direction[2]=dz; } @@ -97,9 +88,8 @@ class DL_Extrusion /** * @return direction vector. */ - double* getDirection() const - { - return direction; + double* getDirection() const { + return direction; } @@ -107,11 +97,10 @@ class DL_Extrusion /** * @return direction vector. */ - void getDirection( double dir[] ) const - { - dir[0] = direction[0]; - dir[1] = direction[1]; - dir[2] = direction[2]; + void getDirection(double dir[]) const { + dir[0]=direction[0]; + dir[1]=direction[1]; + dir[2]=direction[2]; } @@ -119,9 +108,8 @@ class DL_Extrusion /** * Sets the elevation. */ - void setElevation( double elevation ) - { - this->elevation = elevation; + void setElevation(double elevation) { + this->elevation = elevation; } @@ -129,9 +117,8 @@ class DL_Extrusion /** * @return Elevation. */ - double getElevation() const - { - return elevation; + double getElevation() const { + return elevation; } @@ -139,23 +126,19 @@ class DL_Extrusion /** * Copies extrusion (deep copies) from another extrusion object. */ - DL_Extrusion &operator= ( const DL_Extrusion& extru ) - { - setDirection( extru.direction[0], extru.direction[1], extru.direction[2] ); - setElevation( extru.elevation ); + DL_Extrusion operator = (const DL_Extrusion& extru) { + setDirection(extru.direction[0], extru.direction[1], extru.direction[2]); + setElevation(extru.elevation); - return *this; + return *this; } - private: +private: double *direction; double elevation; - - DL_Extrusion(const DL_Extrusion &); }; #endif -// EOF diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_global.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_global.h new file mode 100644 index 00000000000..8e48c592a14 --- /dev/null +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_global.h @@ -0,0 +1,38 @@ +/**************************************************************************** +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. +** Copyright (C) 2001 Robert J. Campbell Jr. +** +** This file is part of the dxflib project. +** +** This file is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** Licensees holding valid dxflib Professional Edition licenses may use +** this file in accordance with the dxflib Commercial License +** Agreement provided with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.ribbonsoft.com for further details. +** +** Contact info@ribbonsoft.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#if defined(DXFLIB_DLL) +# ifdef _WIN32 +# if defined(DXFLIB_LIBRARY) +# define DXFLIB_EXPORT __declspec(dllexport) +# else +# define DXFLIB_EXPORT __declspec(dllimport) +# endif +# else +# define DXFLIB_EXPORT +# endif +#else +# define DXFLIB_EXPORT +#endif diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer.h b/src/plugins/dxf2shp_converter/dxflib/src/dl_writer.h index c22d751b694..2aa09d50237 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer.h +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_writer.h @@ -1,21 +1,15 @@ /**************************************************************************** -** $Id: dl_writer.h 2398 2005-06-06 18:12:14Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** Copyright (C) 2001 Robert J. Campbell Jr. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -32,13 +26,18 @@ #ifndef DL_WRITER_H #define DL_WRITER_H +#include "dl_global.h" + +#ifndef _WIN32 +#include +#endif + #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 -#if defined(__OS2__)||defined(__EMX__)||defined(_WIN32) -#define strcasecmp(s,t) stricmp(s,t) -#endif +#include +#include #include "dl_attributes.h" #include "dl_codes.h" @@ -49,24 +48,22 @@ * Defines interface for writing low level DXF constructs to * a file. Implementation is defined in derived classes that write * to binary or ASCII files. - * + * * Implements functions that write higher level constructs in terms of * the low level ones. * * @todo Add error checking for string/entry length. */ -class DL_Writer -{ - public: +class DXFLIB_EXPORT DL_Writer { +public: /** - * @para version DXF version. Defaults to VER_2002. + * @param version DXF version. Defaults to DL_VERSION_2002. */ - DL_Writer( DL_Codes::version version ) : m_handle( 0x30 ) - { - this->version = version; - modelSpaceHandle = 0; - paperSpaceHandle = 0; - paperSpace0Handle = 0; + DL_Writer(DL_Codes::version version) : m_handle(0x30) { + this->version = version; + modelSpaceHandle = 0; + paperSpaceHandle = 0; + paperSpace0Handle = 0; } virtual ~DL_Writer() {} @@ -81,10 +78,9 @@ class DL_Writer * name * */ - void section( const char* name ) const - { - dxfString( 0, "SECTION" ); - dxfString( 2, name ); + void section(const char* name) const { + dxfString(0, "SECTION"); + dxfString(2, name); } /** @@ -97,9 +93,8 @@ class DL_Writer * HEADER * */ - void sectionHeader() const - { - section( "HEADER" ); + void sectionHeader() const { + section("HEADER"); } /** @@ -112,9 +107,8 @@ class DL_Writer * TABLES * */ - void sectionTables() const - { - section( "TABLES" ); + void sectionTables() const { + section("TABLES"); } /** @@ -127,9 +121,8 @@ class DL_Writer * BLOCKS * */ - void sectionBlocks() const - { - section( "BLOCKS" ); + void sectionBlocks() const { + section("BLOCKS"); } /** @@ -142,9 +135,8 @@ class DL_Writer * ENTITIES * */ - void sectionEntities() const - { - section( "ENTITIES" ); + void sectionEntities() const { + section("ENTITIES"); } /** @@ -157,9 +149,8 @@ class DL_Writer * CLASSES * */ - void sectionClasses() const - { - section( "CLASSES" ); + void sectionClasses() const { + section("CLASSES"); } /** @@ -172,9 +163,8 @@ class DL_Writer * OBJECTS * */ - void sectionObjects() const - { - section( "OBJECTS" ); + void sectionObjects() const { + section("OBJECTS"); } /** @@ -185,9 +175,8 @@ class DL_Writer * ENDSEC * */ - void sectionEnd() const - { - dxfString( 0, "ENDSEC" ); + void sectionEnd() const { + dxfString(0, "ENDSEC"); } /** @@ -202,16 +191,19 @@ class DL_Writer * num * */ - void table( const char* name, int num, int handle ) const - { - dxfString( 0, "TABLE" ); - dxfString( 2, name ); - if ( version >= VER_2000 ) - { - dxfHex( 5, handle ); - dxfString( 100, "AcDbSymbolTable" ); - } - dxfInt( 70, num ); + void table(const char* name, int num, int h=0) const { + dxfString(0, "TABLE"); + dxfString(2, name); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } + else { + dxfHex(5, h); + } + dxfString(100, "AcDbSymbolTable"); + } + dxfInt(70, num); } /** Table for layers. @@ -227,9 +219,8 @@ class DL_Writer * num * */ - void tableLayers( int num ) const - { - table( "LAYER", num, 2 ); + void tableLayers(int num) const { + table("LAYER", num, 2); } /** Table for line types. @@ -245,10 +236,9 @@ class DL_Writer * num * */ - void tableLineTypes( int num ) const - { - //lineTypeHandle = 5; - table( "LTYPE", num, 5 ); + void tableLinetypes(int num) const { + //linetypeHandle = 5; + table("LTYPE", num, 5); } /** Table for application id. @@ -264,9 +254,25 @@ class DL_Writer * num * */ - void tableAppid( int num ) const - { - table( "APPID", num, 9 ); + void tableAppid(int num) const { + table("APPID", num, 9); + } + + /** Table for text style. + * + * @param num Number of text styles. + * + *
+     *   0
+     *  TABLE
+     *   2
+     *  STYLE
+     *   70
+     *      num
+     * 
+ */ + void tableStyle(int num) const { + table("STYLE", num, 3); } /** @@ -277,9 +283,8 @@ class DL_Writer * ENDTAB * */ - void tableEnd() const - { - dxfString( 0, "ENDTAB" ); + void tableEnd() const { + dxfString(0, "ENDTAB"); } /** @@ -290,9 +295,8 @@ class DL_Writer * EOF * */ - void dxfEOF() const - { - dxfString( 0, "EOF" ); + void dxfEOF() const { + dxfString(0, "EOF"); } /** @@ -303,9 +307,8 @@ class DL_Writer * text * */ - void comment( const char* text ) const - { - dxfString( 999, text ); + void comment(const char* text) const { + dxfString(999, text); } /** @@ -315,16 +318,14 @@ class DL_Writer * 0 * entTypeName * - * - * @return Unique handle or 0. + * + * @return Unique handle or 0. */ - void entity( const char* entTypeName ) const - { - dxfString( 0, entTypeName ); - if ( version >= VER_2000 ) - { - handle(); - } + void entity(const char* entTypeName) const { + dxfString(0, entTypeName); + if (version>=DL_VERSION_2000) { + handle(); + } } /** @@ -341,36 +342,37 @@ class DL_Writer * linetype * */ - void entityAttributes( const DL_Attributes& attrib ) const - { - - // layer name: - dxfString( 8, attrib.getLayer() ); - - // R12 doesn't accept BYLAYER values. The value has to be missing - // in that case. - if ( version >= VER_2000 || - attrib.getColor() != 256 ) - { - dxfInt( 62, attrib.getColor() ); - } - if ( version >= VER_2000 ) - { - dxfInt( 370, attrib.getWidth() ); - } - if ( version >= VER_2000 || - strcasecmp( attrib.getLineType().c_str(), "BYLAYER" ) ) - { - dxfString( 6, attrib.getLineType() ); - } + void entityAttributes(const DL_Attributes& attrib) const { + + // layer name: + dxfString(8, attrib.getLayer()); + + // R12 doesn't accept BYLAYER values. The value has to be missing + // in that case. + if (version>=DL_VERSION_2000 || attrib.getColor()!=256) { + dxfInt(62, attrib.getColor()); + } + if (version>=DL_VERSION_2000 && attrib.getColor24()!=-1) { + dxfInt(420, attrib.getColor24()); + } + if (version>=DL_VERSION_2000) { + dxfInt(370, attrib.getWidth()); + } + if (version>=DL_VERSION_2000) { + dxfReal(48, attrib.getLinetypeScale()); + } + std::string linetype = attrib.getLinetype(); + std::transform(linetype.begin(), linetype.end(), linetype.begin(), ::toupper); + if (version>=DL_VERSION_2000 || linetype=="BYLAYER") { + dxfString(6, attrib.getLinetype()); + } } /** * Subclass. */ - void subClass( const char* sub ) const - { - dxfString( 100, sub ); + void subClass(const char* sub) const { + dxfString(100, sub); } /** @@ -381,22 +383,17 @@ class DL_Writer * LAYER * */ - void tableLayerEntry( unsigned long int h = 0 ) const - { - dxfString( 0, "LAYER" ); - if ( version >= VER_2000 ) - { - if ( h == 0 ) - { - handle(); + void tableLayerEntry(unsigned long int h=0) const { + dxfString(0, "LAYER"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + dxfString(100, "AcDbSymbolTableRecord"); + dxfString(100, "AcDbLayerTableRecord"); } - else - { - dxfHex( 5, h ); - } - dxfString( 100, "AcDbSymbolTableRecord" ); - dxfString( 100, "AcDbLayerTableRecord" ); - } } /** @@ -407,23 +404,18 @@ class DL_Writer * LTYPE * */ - void tableLineTypeEntry( unsigned long int h = 0 ) const - { - dxfString( 0, "LTYPE" ); - if ( version >= VER_2000 ) - { - if ( h == 0 ) - { - handle(); + void tableLinetypeEntry(unsigned long int h=0) const { + dxfString(0, "LTYPE"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + //dxfHex(330, 0x5); + dxfString(100, "AcDbSymbolTableRecord"); + dxfString(100, "AcDbLinetypeTableRecord"); } - else - { - dxfHex( 5, h ); - } - //dxfHex(330, 0x5); - dxfString( 100, "AcDbSymbolTableRecord" ); - dxfString( 100, "AcDbLinetypeTableRecord" ); - } } /** @@ -434,23 +426,18 @@ class DL_Writer * APPID * */ - void tableAppidEntry( unsigned long int h = 0 ) const - { - dxfString( 0, "APPID" ); - if ( version >= VER_2000 ) - { - if ( h == 0 ) - { - handle(); + void tableAppidEntry(unsigned long int h=0) const { + dxfString(0, "APPID"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + //dxfHex(330, 0x9); + dxfString(100, "AcDbSymbolTableRecord"); + dxfString(100, "AcDbRegAppTableRecord"); } - else - { - dxfHex( 5, h ); - } - //dxfHex(330, 0x9); - dxfString( 100, "AcDbSymbolTableRecord" ); - dxfString( 100, "AcDbRegAppTableRecord" ); - } } /** @@ -461,28 +448,22 @@ class DL_Writer * BLOCK * */ - void sectionBlockEntry( unsigned long int h = 0 ) const - { - dxfString( 0, "BLOCK" ); - if ( version >= VER_2000 ) - { - if ( h == 0 ) - { - handle(); + void sectionBlockEntry(unsigned long int h=0) const { + dxfString(0, "BLOCK"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + //dxfHex(330, blockHandle); + dxfString(100, "AcDbEntity"); + if (h==0x1C) { + dxfInt(67, 1); + } + dxfString(8, "0"); // TODO: Layer for block + dxfString(100, "AcDbBlockBegin"); } - else - { - dxfHex( 5, h ); - } - //dxfHex(330, blockHandle); - dxfString( 100, "AcDbEntity" ); - if ( h == 0x1C ) - { - dxfInt( 67, 1 ); - } - dxfString( 8, "0" ); // TODO: Layer for block - dxfString( 100, "AcDbBlockBegin" ); - } } /** @@ -493,135 +474,112 @@ class DL_Writer * ENDBLK * */ - void sectionBlockEntryEnd( unsigned long int h = 0 ) const - { - dxfString( 0, "ENDBLK" ); - if ( version >= VER_2000 ) - { - if ( h == 0 ) - { - handle(); + void sectionBlockEntryEnd(unsigned long int h=0) const { + dxfString(0, "ENDBLK"); + if (version>=DL_VERSION_2000) { + if (h==0) { + handle(); + } else { + dxfHex(5, h); + } + //dxfHex(330, blockHandle); + dxfString(100, "AcDbEntity"); + if (h==0x1D) { + dxfInt(67, 1); + } + dxfString(8, "0"); // TODO: Layer for block + dxfString(100, "AcDbBlockEnd"); } - else - { - dxfHex( 5, h ); + } + + void color(int col=256) const { + dxfInt(62, col); + } + void linetype(const char *lt) const { + dxfString(6, lt); + } + void linetypeScale(double scale) const { + dxfReal(48, scale); + } + void lineWeight(int lw) const { + dxfInt(370, lw); + } + + void coord(int gc, double x, double y, double z=0) const { + dxfReal(gc, x); + dxfReal(gc+10, y); + dxfReal(gc+20, z); + } + + void coordTriplet(int gc, const double* value) const { + if (value) { + dxfReal(gc, *value++); + dxfReal(gc+10, *value++); + dxfReal(gc+20, *value++); } - //dxfHex(330, blockHandle); - dxfString( 100, "AcDbEntity" ); - if ( h == 0x1D ) - { - dxfInt( 67, 1 ); - } - dxfString( 8, "0" ); // TODO: Layer for block - dxfString( 100, "AcDbBlockEnd" ); - } } - void color( int col = 256 ) const - { - dxfInt( 62, col ); - } - void lineType( const char *lt ) const - { - dxfString( 6, lt ); - } - void lineTypeScale( double scale ) const - { - dxfReal( 48, scale ); - } - void lineWeight( int lw ) const - { - dxfInt( 370, lw ); - } - - void coord( int gc, double x, double y, double z = 0 ) const - { - dxfReal( gc, x ); - dxfReal( gc + 10, y ); - dxfReal( gc + 20, z ); - } - - void coordTriplet( int gc, const double* value ) const - { - if ( value ) - { - dxfReal( gc, *value++ ); - dxfReal( gc + 10, *value++ ); - dxfReal( gc + 20, *value++ ); - } - } - - void resetHandle() const - { - m_handle = 1; + void resetHandle() const { + m_handle = 1; } /** * Writes a unique handle and returns it. */ - unsigned long handle( int gc = 5 ) const - { - // handle has to be hex - dxfHex( gc, m_handle ); - return m_handle++; + unsigned long handle(int gc=5) const { + // handle has to be hex + dxfHex(gc, m_handle); + return m_handle++; } /** * @return Next handle that will be written. */ - unsigned long getNextHandle() const - { - return m_handle; + unsigned long getNextHandle() const { + return m_handle; } - + /** * Increases handle, so that the handle returned remains available. */ - unsigned long incHandle() const - { - return m_handle++; + unsigned long incHandle() const { + return m_handle++; } /** - * Sets the handle of the model space. Entities refer to + * Sets the handle of the model space. Entities refer to * this handle. */ - void setModelSpaceHandle( unsigned long h ) - { - modelSpaceHandle = h; + void setModelSpaceHandle(unsigned long h) { + modelSpaceHandle = h; } - unsigned long getModelSpaceHandle() - { - return modelSpaceHandle; + unsigned long getModelSpaceHandle() { + return modelSpaceHandle; } /** - * Sets the handle of the paper space. Some special blocks refer to + * Sets the handle of the paper space. Some special blocks refer to * this handle. */ - void setPaperSpaceHandle( unsigned long h ) - { - paperSpaceHandle = h; + void setPaperSpaceHandle(unsigned long h) { + paperSpaceHandle = h; } - unsigned long getPaperSpaceHandle() - { - return paperSpaceHandle; + unsigned long getPaperSpaceHandle() { + return paperSpaceHandle; } /** - * Sets the handle of the paper space 0. Some special blocks refer to + * Sets the handle of the paper space 0. Some special blocks refer to * this handle. */ - void setPaperSpace0Handle( unsigned long h ) - { - paperSpace0Handle = h; + void setPaperSpace0Handle(unsigned long h) { + paperSpace0Handle = h; } - unsigned long getPaperSpace0Handle() - { - return paperSpace0Handle; + unsigned long getPaperSpace0Handle() { + return paperSpace0Handle; } /** @@ -631,7 +589,7 @@ class DL_Writer * @param gc Group code. * @param value The real value. */ - virtual void dxfReal( int gc, double value ) const = 0; + virtual void dxfReal(int gc, double value) const = 0; /** * Must be overwritten by the implementing class to write an @@ -640,7 +598,18 @@ class DL_Writer * @param gc Group code. * @param value The int value. */ - virtual void dxfInt( int gc, int value ) const = 0; + virtual void dxfInt(int gc, int value) const = 0; + + /** + * Can be overwritten by the implementing class to write a + * bool value to the file. + * + * @param gc Group code. + * @param value The bool value. + */ + virtual void dxfBool(int gc, bool value) const { + dxfInt(gc, (int)value); + } /** * Must be overwritten by the implementing class to write an @@ -649,7 +618,7 @@ class DL_Writer * @param gc Group code. * @param value The int value. */ - virtual void dxfHex( int gc, int value ) const = 0; + virtual void dxfHex(int gc, int value) const = 0; /** * Must be overwritten by the implementing class to write a @@ -658,7 +627,7 @@ class DL_Writer * @param gc Group code. * @param value The string. */ - virtual void dxfString( int gc, const char* value ) const = 0; + virtual void dxfString(int gc, const char* value) const = 0; /** * Must be overwritten by the implementing class to write a @@ -667,9 +636,9 @@ class DL_Writer * @param gc Group code. * @param value The string. */ - virtual void dxfString( int gc, const string& value ) const = 0; + virtual void dxfString(int gc, const std::string& value) const = 0; - protected: +protected: mutable unsigned long m_handle; mutable unsigned long modelSpaceHandle; mutable unsigned long paperSpaceHandle; @@ -679,7 +648,7 @@ class DL_Writer * DXF version to be created. */ DL_Codes::version version; - private: +private: }; #endif diff --git a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.cpp b/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.cpp index 59633227bd1..32d26fe924b 100644 --- a/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.cpp +++ b/src/plugins/dxf2shp_converter/dxflib/src/dl_writer_ascii.cpp @@ -1,21 +1,15 @@ /**************************************************************************** -** $Id: dl_writer_ascii.cpp 242 2004-04-12 22:39:43Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. +** Copyright (C) 2001-2013 RibbonSoft, GmbH. All rights reserved. ** Copyright (C) 2001 Robert J. Campbell Jr. ** ** This file is part of the dxflib project. ** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This program is free software; you can redistribute it and/or modify +** This file is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; version 2 of the License +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. ** -** Licensees holding valid dxflib Professional Edition licenses may use +** Licensees holding valid dxflib Professional Edition licenses may use ** this file in accordance with the dxflib Commercial License ** Agreement provided with the Software. ** @@ -29,8 +23,12 @@ ** **********************************************************************/ -#include -#include +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include +#include #include "dl_writer_ascii.h" #include "dl_exception.h" @@ -39,9 +37,8 @@ /** * Closes the output file. */ -void DL_WriterA::close() const -{ - m_ofile.close(); +void DL_WriterA::close() const { + m_ofile.close(); } @@ -49,9 +46,8 @@ void DL_WriterA::close() const * @retval true Opening file has failed. * @retval false Otherwise. */ -bool DL_WriterA::openFailed() const -{ - return m_ofile.fail(); +bool DL_WriterA::openFailed() const { + return m_ofile.fail(); } @@ -62,37 +58,31 @@ bool DL_WriterA::openFailed() const * @param gc Group code. * @param value Double value */ -void DL_WriterA::dxfReal( int gc, double value ) const -{ - char str[256]; - sprintf( str, "%.16f", value ); +void DL_WriterA::dxfReal(int gc, double value) const { + char str[256]; + sprintf(str, "%.16lf", value); + + // fix for german locale: + strReplace(str, ',', '.'); - // fix for german locale: - strReplace( str, ',', '.' ); - - // Cut away those zeros at the end: - bool dot = false; - int end = -1; - for ( unsigned int i = 0; i < strlen( str ); ++i ) - { - if ( str[i] == '.' ) - { - dot = true; - end = i + 2; - continue; + // Cut away those zeros at the end: + bool dot = false; + int end = -1; + for (unsigned int i=0; i0 && end<(int)strlen(str)) { + str[end] = '\0'; } - } - if ( end > 0 && end < ( int )strlen( str ) ) - { - str[end] = '\0'; - } - dxfString( gc, str ); - m_ofile.flush(); + dxfString(gc, str); + m_ofile.flush(); } @@ -103,10 +93,8 @@ void DL_WriterA::dxfReal( int gc, double value ) const * @param gc Group code. * @param value Int value */ -void DL_WriterA::dxfInt( int gc, int value ) const -{ - m_ofile << ( gc < 10 ? " " : ( gc < 100 ? " " : "" ) ) << gc << "\n" - << value << "\n"; +void DL_WriterA::dxfInt(int gc, int value) const { + m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n" << value << "\n"; } @@ -117,11 +105,10 @@ void DL_WriterA::dxfInt( int gc, int value ) const * @param gc Group code. * @param value Int value */ -void DL_WriterA::dxfHex( int gc, int value ) const -{ - char str[12]; - sprintf( str, "%0X", value ); - dxfString( gc, str ); +void DL_WriterA::dxfHex(int gc, int value) const { + char str[12]; + sprintf(str, "%0X", value); + dxfString(gc, str); } @@ -132,39 +119,33 @@ void DL_WriterA::dxfHex( int gc, int value ) const * @param gc Group code. * @param value String */ -void DL_WriterA::dxfString( int gc, const char* value ) const -{ - if ( value == NULL ) - { +void DL_WriterA::dxfString(int gc, const char* value) const { + if (value==NULL) { #ifndef __GCC2x__ - throw DL_NullStrExc(); + //throw DL_NullStrExc(); #endif - } - m_ofile << ( gc < 10 ? " " : ( gc < 100 ? " " : "" ) ) << gc << "\n" - << value << "\n"; + } + m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n" + << value << "\n"; } -void DL_WriterA::dxfString( int gc, const string& value ) const -{ - m_ofile << ( gc < 10 ? " " : ( gc < 100 ? " " : "" ) ) << gc << "\n" - << value << "\n"; +void DL_WriterA::dxfString(int gc, const std::string& value) const { + m_ofile << (gc<10 ? " " : (gc<100 ? " " : "")) << gc << "\n" + << value << "\n"; } /** * Replaces every occurence of src with dest in the null terminated str. */ -void DL_WriterA::strReplace( char* str, char src, char dest ) -{ - size_t i; - for ( i = 0; i < strlen( str ); i++ ) - { - if ( str[i] == src ) - { - str[i] = dest; +void DL_WriterA::strReplace(char* str, char src, char dest) { + size_t i; + for (i=0; i 1000 #pragma once #endif // _MSC_VER > 1000 @@ -39,36 +35,34 @@ #include "dl_writer.h" #include #include -using std::string; /** * Implements functions defined in DL_Writer for writing low * level DXF constructs to an ASCII format DXF file. - * + * * @para fname File name of the file to be created. - * @para version DXF version. Defaults to VER_2002. + * @para version DXF version. Defaults to DL_VERSION_2002. * * @todo What if \c fname is NULL? Or \c fname can't be opened for * another reason? */ -class DL_WriterA : public DL_Writer -{ - public: - DL_WriterA( const char* fname, DL_Codes::version version = VER_2000 ) - : DL_Writer( version ), m_ofile( fname ) {} +class DXFLIB_EXPORT DL_WriterA : public DL_Writer { +public: + DL_WriterA(const char* fname, DL_Codes::version version=DL_VERSION_2000) + : DL_Writer(version), m_ofile(fname) {} virtual ~DL_WriterA() {} bool openFailed() const; void close() const; - void dxfReal( int gc, double value ) const override; - void dxfInt( int gc, int value ) const override; - void dxfHex( int gc, int value ) const override; - void dxfString( int gc, const char* value ) const override; - void dxfString( int gc, const string& value ) const override; + void dxfReal(int gc, double value) const; + void dxfInt(int gc, int value) const; + void dxfHex(int gc, int value) const; + void dxfString(int gc, const char* value) const; + void dxfString(int gc, const std::string& value) const; - static void strReplace( char* str, char src, char dest ); + static void strReplace(char* str, char src, char dest); - private: +private: /** * DXF file to be created. */ diff --git a/src/plugins/dxf2shp_converter/getInsertions.cpp b/src/plugins/dxf2shp_converter/getInsertions.cpp deleted file mode 100644 index d90e9114092..00000000000 --- a/src/plugins/dxf2shp_converter/getInsertions.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - getInsertions.cpp - --------------------- - copyright : (C) by Christopher Michaelis - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -// LICENSE: -// -// This code is released under the GPL (GNU Public License) version 2.0. -// For full details, see the file GPL.txt included with this source code. -// -// What this means: -// -// This means, in simple terms, that you are free to use this code for any open-source or -// public domain project. You may NOT use this source code as part of a commercial application. -// It may be included, in binary form and bearing a GPL notice, along with commercial -// applications, but the code shall not be compiled directly into a closed-source, -// commercial application. -// -// This code is based on two other products: -// DXFLIB (http://www.ribbonsoft.com/dxflib.html) -// This is a library for reading DXF files, also GPL. -// MAPWINGIS (http://www.mapwindow.org) -// This is a library for many general-purpose GIS and mapping applications. It's -// used for the Shapefile functionality. This software is also open source, this one MPL. -// -// Questions/Comments/Thoughts? -// http://www.happysquirrel.com/index.php?feature=hs_questions -// -// Thank you! -// - -// getInsertions.cpp: The class which retrieves the block insertions from the DXF file - - -#include "getInsertions.h" - -InsertRetrClass::InsertRetrClass() -{ - Names = new string[MaxInserts]; - XVals = new double[MaxInserts]; - YVals = new double[MaxInserts]; - - countInserts = 0; -} - -InsertRetrClass::~InsertRetrClass() -{ - if ( Names != NULL ) - { - delete [] Names; - Names = NULL; - } - if ( XVals != NULL ) - { - delete [] XVals; - XVals = NULL; - } - if ( YVals != NULL ) - { - delete [] YVals; - YVals = NULL; - } -} - -void InsertRetrClass::addInsert( const DL_InsertData &data ) -{ - if ( countInserts < MaxInserts ) - { - Names[countInserts] = data.name; - XVals[countInserts] = data.ipx; - YVals[countInserts] = data.ipy; - } - countInserts++; -} diff --git a/src/plugins/dxf2shp_converter/getInsertions.h b/src/plugins/dxf2shp_converter/getInsertions.h deleted file mode 100644 index ddf62f36767..00000000000 --- a/src/plugins/dxf2shp_converter/getInsertions.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - getInsertions.h - --------------------- - copyright : (C) by Christopher Michaelis - *************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; version 2 of the License * - * * - ***************************************************************************/ -/* This source has been formatted by an unregistered SourceFormatX */ -/* If you want to remove this info, please register this shareware */ -/* Please visit http://www.textrush.com to get more information */ - -// What this means: -// -// This means, in simple terms, that you are free to use this code for any open-source or -// public domain project. You may NOT use this source code as part of a commercial application. -// It may be included, in binary form and bearing a GPL notice, along with commercial -// applications, but the code shall not be compiled directly into a closed-source, -// commercial application. -// -// This code is based on two other products: -// DXFLIB (http://www.ribbonsoft.com/dxflib.html) -// This is a library for reading DXF files, also GPL. -// MAPWINGIS (http://www.mapwindow.org) -// This is a library for many general-purpose GIS and mapping applications. It's -// used for the Shapefile functionality. This software is also open source, this one MPL. -// -// Questions/Comments/Thoughts? -// http://www.happysquirrel.com/index.php?feature=hs_questions -// -// Thank you! -// Christopher Michaelis - -// getInsertions.h: The class which retrieves the block insertions from the DXF file - -#ifndef INSERTIONCLASS_H -#define INSERTIONCLASS_H - -#include "dxflib/src/dl_creationadapter.h" - -class InsertRetrClass: public DL_CreationAdapter -{ - public: - InsertRetrClass(); - ~InsertRetrClass(); - - virtual void addInsert( const DL_InsertData &data ) override; - - string *Names; - double *XVals; - double *YVals; - - int countInserts; - const static int MaxInserts = 1000000; -}; - -#endif