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+)
This commit is contained in:
Juergen E. Fischer 2015-02-28 21:52:58 +01:00
parent ec0ab3f7ce
commit 3628b43a84
22 changed files with 7318 additions and 7397 deletions

12
debian/copyright vendored
View File

@ -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

View File

@ -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
)

View File

@ -20,28 +20,21 @@
//IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#include <cmath>
#include <string>
#include "builder.h"
#include <cmath>
#include <QVector>
#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<double> xv( dim );
QVector<double> yv( dim );
QVector<double> 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<double> xv( dim );
QVector<double> yv( dim );
QVector<double> 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<double> xv( dim );
QVector<double> yv( dim );
QVector<double> 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<double> xv( dim );
QVector<double> yv( dim );
QVector<double> 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!" );
}
}

View File

@ -22,18 +22,15 @@
#include "dxflib/src/dl_creationadapter.h"
#include "shapelib-1.2.10/shapefil.h"
#include "getInsertions.h"
#include <vector>
#include <QList>
#include <QString>
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 <DL_VertexData> polyVertex;
std::vector <SHPObject *> shpObjects; // all read objects are stored here
std::vector <DL_TextData> textObjects;
QString outputtdbf;
QString outputtshp;
int fetchedprims;
int fetchedtexts;
QString outputidbf;
QString outputishp;
QList<SHPObject *> shpObjects; // all read objects are stored here
QList<DL_VertexData> polyVertex;
QList<DL_TextData> textObjects;
QList<DL_InsertData> 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;
};

View File

@ -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();
}

View File

@ -59,7 +59,14 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="convertInsertCheck">
<property name="text">
<string>Export inserts</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="convertTextCheck">
<property name="text">
<string>Export text labels</string>

View File

@ -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 */

View File

@ -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 <string>
using std::string;
#include <vector>
#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

View File

@ -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

View File

@ -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

View File

@ -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 <string.h>
#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 <b>before</b> 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

File diff suppressed because it is too large Load Diff

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef __GCC2x__
#include <string>
#include <sstream>
#endif
#include <map>
#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<std::vector<DL_HatchEdgeData> > 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<int, std::string> 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

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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 <math.h>
@ -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

View File

@ -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

View File

@ -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 <strings.h>
#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 <iostream>
#include <algorithm>
#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
* </pre>
*/
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
* </pre>
*/
void sectionHeader() const
{
section( "HEADER" );
void sectionHeader() const {
section("HEADER");
}
/**
@ -112,9 +107,8 @@ class DL_Writer
* TABLES
* </pre>
*/
void sectionTables() const
{
section( "TABLES" );
void sectionTables() const {
section("TABLES");
}
/**
@ -127,9 +121,8 @@ class DL_Writer
* BLOCKS
* </pre>
*/
void sectionBlocks() const
{
section( "BLOCKS" );
void sectionBlocks() const {
section("BLOCKS");
}
/**
@ -142,9 +135,8 @@ class DL_Writer
* ENTITIES
* </pre>
*/
void sectionEntities() const
{
section( "ENTITIES" );
void sectionEntities() const {
section("ENTITIES");
}
/**
@ -157,9 +149,8 @@ class DL_Writer
* CLASSES
* </pre>
*/
void sectionClasses() const
{
section( "CLASSES" );
void sectionClasses() const {
section("CLASSES");
}
/**
@ -172,9 +163,8 @@ class DL_Writer
* OBJECTS
* </pre>
*/
void sectionObjects() const
{
section( "OBJECTS" );
void sectionObjects() const {
section("OBJECTS");
}
/**
@ -185,9 +175,8 @@ class DL_Writer
* ENDSEC
* </pre>
*/
void sectionEnd() const
{
dxfString( 0, "ENDSEC" );
void sectionEnd() const {
dxfString(0, "ENDSEC");
}
/**
@ -202,16 +191,19 @@ class DL_Writer
* num
* </pre>
*/
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
* </pre>
*/
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
* </pre>
*/
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
* </pre>
*/
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.
*
* <pre>
* 0
* TABLE
* 2
* STYLE
* 70
* num
* </pre>
*/
void tableStyle(int num) const {
table("STYLE", num, 3);
}
/**
@ -277,9 +283,8 @@ class DL_Writer
* ENDTAB
* </pre>
*/
void tableEnd() const
{
dxfString( 0, "ENDTAB" );
void tableEnd() const {
dxfString(0, "ENDTAB");
}
/**
@ -290,9 +295,8 @@ class DL_Writer
* EOF
* </pre>
*/
void dxfEOF() const
{
dxfString( 0, "EOF" );
void dxfEOF() const {
dxfString(0, "EOF");
}
/**
@ -303,9 +307,8 @@ class DL_Writer
* text
* </pre>
*/
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
* </pre>
*
* @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
* </pre>
*/
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
* </pre>
*/
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
* </pre>
*/
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
* </pre>
*/
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
* </pre>
*/
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
* </pre>
*/
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

View File

@ -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 <cstdio>
#include <cstring>
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <stdio.h>
#include <string.h>
#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; i<strlen(str); ++i) {
if (str[i]=='.') {
dot = true;
end = i+2;
continue;
} else if (dot && str[i]!='0') {
end = i+1;
}
}
else if ( dot && str[i] != '0' )
{
end = i + 1;
if (end>0 && 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<strlen(str); i++) {
if (str[i]==src) {
str[i] = dest;
}
}
}
}

View File

@ -1,21 +1,15 @@
/****************************************************************************
** $Id: dl_writer_ascii.h 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.
** 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_WRITER_ASCII_H
#define DL_WRITER_ASCII_H
#include "dl_global.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
@ -39,36 +35,34 @@
#include "dl_writer.h"
#include <fstream>
#include <string>
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.
*/

View File

@ -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++;
}

View File

@ -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