Commit 40eb9c9c authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: First work to add a DXF file import to create board outlines. The DXF...

Pcbnew: First work to add a DXF file import to create board outlines. The DXF import is based on DXF lib import/export  from LibreCad.
parents e8ad48ad 55e9b4d1
...@@ -360,6 +360,7 @@ add_subdirectory( cvpcb ) ...@@ -360,6 +360,7 @@ add_subdirectory( cvpcb )
add_subdirectory( eeschema ) add_subdirectory( eeschema )
add_subdirectory( gerbview ) add_subdirectory( gerbview )
add_subdirectory( kicad ) add_subdirectory( kicad )
add_subdirectory( lib_dxf )
add_subdirectory( pcbnew ) add_subdirectory( pcbnew )
add_subdirectory( polygon ) add_subdirectory( polygon )
add_subdirectory( pagelayout_editor ) add_subdirectory( pagelayout_editor )
......
include_directories(intern)
set(LIBDXF_SRCS
libdxfrw.cpp
intern/dxfwriter.cpp
intern/drw_textcodec.cpp
intern/dxfreader.cpp
drw_objects.cpp
drw_entities.cpp
)
add_library(lib_dxf STATIC ${LIBDXF_SRCS})
This library comes from the LibreCAD project, a 2D CAD program.
see http://sourceforge.net/projects/libdxfrw/
the latest sources are on:
https://github.com/LibreCAD/LibreCAD/tree/master/libraries/libdxfrw/src
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#ifndef DRW_BASE_H
#define DRW_BASE_H
#define DRW_VERSION "0.5.10"
#include <string>
#include <cmath>
using std::string;
#define UTF8STRING std::string
#define DRW_UNUSED( x ) (void) x
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
# define DRW_WIN
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
# define DRW_WIN
#elif defined(__MWERKS__) && defined(__INTEL__)
# define DRW_WIN
#else
# define DRW_POSIX
#endif
#ifndef M_PI
#define M_PI 3.141592653589793238462643
#endif
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif
#define M_PIx2 6.283185307179586 // 2*PI
#define ARAD 57.29577951308232
namespace DRW {
// ! Version numbers for the DXF Format.
enum Version {
UNKNOWNV, /*!< UNKNOWN VERSION. */
AC1006, /*!< R10. */
AC1009, /*!< R11 & R12. */
AC1012, /*!< R13. */
AC1014, /*!< R14. */
AC1015, /*!< ACAD 2000. */
AC1018, /*!< ACAD 2004. */
AC1021, /*!< ACAD 2007. */
AC1024 /*!< ACAD 2010. */
};
enum error {
BAD_NONE, /*!< No error. */
BAD_UNKNOWN, /*!< UNKNOWN. */
BAD_OPEN, /*!< error opening file. */
BAD_VERSION, /*!< unsupported version. */
BAD_READ_FILE_HEADER, /*!< error in file header read process. */
BAD_READ_HEADER, /*!< error in header vars read process. */
BAD_READ_OFFSETS, /*!< error in object map read process. */
BAD_READ_CLASSES, /*!< error in classes read process. */
BAD_READ_TABLES, /*!< error in tables read process. */
BAD_READ_ENTITIES /*!< error in entities read process. */
};
}
// ! Class to handle 3D coordinate point
/*!
* Class to handle 3D coordinate point
* @author Rallaz
*/
class DRW_Coord
{
public:
DRW_Coord() { x = 0; y = 0; z = 0; }
DRW_Coord( double ix, double iy, double iz )
{
x = ix; y = iy; z = iz;
}
DRW_Coord operator =( const DRW_Coord& data )
{
x = data.x; y = data.y; z = data.z;
return *this;
}
/*!< convert to unitary vector */
void unitize()
{
double dist;
dist = sqrt( x * x + y * y + z * z );
if( dist > 0.0 )
{
x = x / dist;
y = y / dist;
z = z / dist;
}
}
public:
double x;
double y;
double z;
};
// ! Class to handle vertex
/*!
* Class to handle vertex for lwpolyline entity
* @author Rallaz
*/
class DRW_Vertex2D
{
public:
DRW_Vertex2D()
{
// eType = DRW::LWPOLYLINE;
stawidth = endwidth = bulge = 0;
}
DRW_Vertex2D( double sx, double sy, double b )
{
stawidth = endwidth = 0;
x = sx;
y = sy;
bulge = b;
}
public:
double x; /*!< x coordinate, code 10 */
double y; /*!< y coordinate, code 20 */
double stawidth; /*!< Start width, code 40 */
double endwidth; /*!< End width, code 41 */
double bulge; /*!< bulge, code 42 */
};
// ! Class to handle header vars
/*!
* Class to handle header vars
* @author Rallaz
*/
class DRW_Variant
{
public:
enum TYPE {
STRING,
INTEGER,
DOUBLE,
COORD,
INVALID
};
DRW_Variant()
{
type = INVALID;
}
~DRW_Variant()
{
if( type == COORD )
delete content.v;
}
enum TYPE type;
void addString( UTF8STRING s ) { setType( STRING ); data = s; content.s = &data; }
void addInt( int i ) { setType( INTEGER ); content.i = i; }
void addDouble( double d ) { setType( DOUBLE ); content.d = d; }
void addCoord( DRW_Coord* v ) { setType( COORD ); content.v = v; }
void setType( enum TYPE t )
{
if( type == COORD )
delete content.v;
type = t;
}
void setCoordX( double d ) { if( type == COORD ) content.v->x = d; }
void setCoordY( double d ) { if( type == COORD ) content.v->y = d; }
void setCoordZ( double d ) { if( type == COORD ) content.v->z = d; }
private:
typedef union
{
UTF8STRING* s;
int i;
double d;
DRW_Coord* v;
} DRW_VarContent;
public:
DRW_VarContent content;
public:
int code;
// string version;
// string codepage;
private:
// DRW_VarContent content;
string data;
};
// ! Class to convert between line width and integer
/*!
* Class to convert between line width and integer
* verifing valid values, if value is not valid
* returns widthDefault.
* @author Rallaz
*/
class DRW_LW_Conv
{
public:
enum lineWidth {
width00 = 0, /*!< 0.00mm (dxf 0)*/
width01 = 1, /*!< 0.05mm (dxf 5)*/
width02 = 2, /*!< 0.09mm (dxf 9)*/
width03 = 3, /*!< 0.13mm (dxf 13)*/
width04 = 4, /*!< 0.15mm (dxf 15)*/
width05 = 5, /*!< 0.18mm (dxf 18)*/
width06 = 6, /*!< 0.20mm (dxf 20)*/
width07 = 7, /*!< 0.25mm (dxf 25)*/
width08 = 8, /*!< 0.30mm (dxf 30)*/
width09 = 9, /*!< 0.35mm (dxf 35)*/
width10 = 10, /*!< 0.40mm (dxf 40)*/
width11 = 11, /*!< 0.50mm (dxf 50)*/
width12 = 12, /*!< 0.53mm (dxf 53)*/
width13 = 13, /*!< 0.60mm (dxf 60)*/
width14 = 14, /*!< 0.70mm (dxf 70)*/
width15 = 15, /*!< 0.80mm (dxf 80)*/
width16 = 16, /*!< 0.90mm (dxf 90)*/
width17 = 17, /*!< 1.00mm (dxf 100)*/
width18 = 18, /*!< 1.06mm (dxf 106)*/
width19 = 19, /*!< 1.20mm (dxf 120)*/
width20 = 20, /*!< 1.40mm (dxf 140)*/
width21 = 21, /*!< 1.58mm (dxf 158)*/
width22 = 22, /*!< 2.00mm (dxf 200)*/
width23 = 23, /*!< 2.11mm (dxf 211)*/
widthByLayer = 29, /*!< by layer (dxf -1) */
widthByBlock = 30, /*!< by block (dxf -2) */
widthDefault = 31 /*!< by default (dxf -3) */
};
static int lineWidth2dxfInt( enum lineWidth lw )
{
switch( lw )
{
case widthByLayer:
return -1;
case widthByBlock:
return -2;
case widthDefault:
return -3;
case width00:
return 0;
case width01:
return 5;
case width02:
return 9;
case width03:
return 13;
case width04:
return 15;
case width05:
return 18;
case width06:
return 20;
case width07:
return 25;
case width08:
return 30;
case width09:
return 35;
case width10:
return 40;
case width11:
return 50;
case width12:
return 53;
case width13:
return 60;
case width14:
return 70;
case width15:
return 80;
case width16:
return 90;
case width17:
return 100;
case width18:
return 106;
case width19:
return 120;
case width20:
return 140;
case width21:
return 158;
case width22:
return 200;
case width23:
return 211;
default:
return -3;
}
return static_cast<int> (lw);
}
static int lineWidth2dwgInt( enum lineWidth lw )
{
return static_cast<int> (lw);
}
static enum lineWidth dxfInt2lineWidth( int i )
{
if( i<0 )
{
if( i==-1 )
return widthByLayer;
else if( i==-2 )
return widthByBlock;
else if( i==-3 )
return widthDefault;
}
else if( i<3 )
{
return width00;
}
else if( i<7 )
{
return width01;
}
else if( i<11 )
{
return width02;
}
else if( i<14 )
{
return width03;
}
else if( i<16 )
{
return width04;
}
else if( i<19 )
{
return width05;
}
else if( i<22 )
{
return width06;
}
else if( i<27 )
{
return width07;
}
else if( i<32 )
{
return width08;
}
else if( i<37 )
{
return width09;
}
else if( i<45 )
{
return width10;
}
else if( i<52 )
{
return width11;
}
else if( i<57 )
{
return width12;
}
else if( i<65 )
{
return width13;
}
else if( i<75 )
{
return width14;
}
else if( i<85 )
{
return width15;
}
else if( i<95 )
{
return width16;
}
else if( i<103 )
{
return width17;
}
else if( i<112 )
{
return width18;
}
else if( i<130 )
{
return width19;
}
else if( i<149 )
{
return width20;
}
else if( i<180 )
{
return width21;
}
else if( i<205 )
{
return width22;
}
else
{
return width23;
}
// default by default
return widthDefault;
}
static enum lineWidth dwgInt2lineWidth( int i )
{
if( (i>-1 && i<24) || (i>28 && i<32) )
{
return static_cast<lineWidth> (i);
}
// default by default
return widthDefault;
}
};
#endif
// EOF
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#include <cstdlib>
#include "drw_entities.h"
#include "intern/dxfreader.h"
// ! Calculate arbitary axis
/*!
* Calculate arbitary axis for apply extrusions
* @author Rallaz
*/
void DRW_Entity::calculateAxis( DRW_Coord extPoint )
{
if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 )
{
extAxisX.x = extPoint.z;
extAxisX.y = 0;
extAxisX.z = -extPoint.x;
}
else
{
extAxisX.x = -extPoint.y;
extAxisX.y = extPoint.x;
extAxisX.z = 0;
}
extAxisX.unitize();
extAxisY.x = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z);
extAxisY.y = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x);
extAxisY.z = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y);
extAxisY.unitize();
}
// ! Extrude a point using arbitary axis
/*!
* apply extrusion in a point using arbitary axis (previous calculated)
* @author Rallaz
*/
void DRW_Entity::extrudePoint( DRW_Coord extPoint, DRW_Coord* point )
{
double px, py, pz;
px = (extAxisX.x * point->x) + (extAxisY.x * point->y) + (extPoint.x * point->z);
py = (extAxisX.y * point->x) + (extAxisY.y * point->y) + (extPoint.y * point->z);
pz = (extAxisX.z * point->x) + (extAxisY.z * point->y) + (extPoint.z * point->z);
point->x = px;
point->y = py;
point->z = pz;
}
void DRW_Entity::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 5:
handle = reader->getHandleString();
break;
case 330:
handleBlock = reader->getHandleString();
break;
case 8:
layer = reader->getUtf8String();
break;
case 6:
lineType = reader->getUtf8String();
break;
case 62:
color = reader->getInt32();
break;
case 370:
lWeight = DRW_LW_Conv::dxfInt2lineWidth( reader->getInt32() );
break;
case 48:
ltypeScale = reader->getDouble();
break;
case 60:
visible = reader->getBool();
break;
case 420:
color24 = reader->getInt32();
break;
case 430:
colorName = reader->getString();
break;
case 67:
space = reader->getInt32();
break;
default:
break;
}
}
void DRW_Point::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 10:
basePoint.x = reader->getDouble();
break;
case 20:
basePoint.y = reader->getDouble();
break;
case 30:
basePoint.z = reader->getDouble();
break;
case 39:
thickness = reader->getDouble();
break;
case 210:
haveExtrusion = true;
extPoint.x = reader->getDouble();
break;
case 220:
extPoint.y = reader->getDouble();
break;
case 230:
extPoint.z = reader->getDouble();
break;
default:
DRW_Entity::parseCode( code, reader );
break;
}
}
void DRW_Line::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 11:
secPoint.x = reader->getDouble();
break;
case 21:
secPoint.y = reader->getDouble();
break;
case 31:
secPoint.z = reader->getDouble();
break;
default:
DRW_Point::parseCode( code, reader );
break;
}
}
void DRW_Circle::applyExtrusion()
{
if( haveExtrusion )
{
calculateAxis( extPoint );
extrudePoint( extPoint, &basePoint );
}
}
void DRW_Circle::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 40:
radious = reader->getDouble();
break;
default:
DRW_Point::parseCode( code, reader );
break;
}
}
void DRW_Arc::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 50:
staangle = reader->getDouble() / ARAD;
break;
case 51:
endangle = reader->getDouble() / ARAD;
break;
default:
DRW_Circle::parseCode( code, reader );
break;
}
}
void DRW_Ellipse::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 40:
ratio = reader->getDouble();
break;
case 41:
staparam = reader->getDouble();
break;
case 42:
endparam = reader->getDouble();
break;
default:
DRW_Line::parseCode( code, reader );
break;
}
}
void DRW_Ellipse::applyExtrusion()
{
if( haveExtrusion )
{
calculateAxis( extPoint );
extrudePoint( extPoint, &secPoint );
double intialparam = staparam;
if( extPoint.z < 0. )
{
staparam = M_PIx2 - endparam;
endparam = M_PIx2 - intialparam;
}
}
}
// if ratio > 1 minor axis are greather than major axis, correct it
void DRW_Ellipse::correctAxis()
{
bool complete = false;
if( staparam == endparam )
{
staparam = 0.0;
endparam = M_PIx2; // 2*M_PI;
complete = true;
}
if( ratio > 1 )
{
if( fabs( endparam - staparam - M_PIx2 ) < 1.0e-10 )
complete = true;
double incX = secPoint.x;
secPoint.x = -(secPoint.y * ratio);
secPoint.y = incX * ratio;
ratio = 1 / ratio;
if( !complete )
{
if( staparam < M_PI_2 )
staparam += M_PI * 2;
if( endparam < M_PI_2 )
endparam += M_PI * 2;
endparam -= M_PI_2;
staparam -= M_PI_2;
}
}
}
// parts are the number of vertex to split polyline, default 128
void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts )
{
double radMajor, radMinor, cosRot, sinRot, incAngle, curAngle;
double cosCurr, sinCurr;
radMajor = sqrt( secPoint.x * secPoint.x + secPoint.y * secPoint.y );
radMinor = radMajor * ratio;
// calculate sin & cos of included angle
incAngle = atan2( secPoint.y, secPoint.x );
cosRot = cos( incAngle );
sinRot = sin( incAngle );
incAngle = M_PIx2 / parts;
curAngle = staparam;
int i = curAngle / incAngle;
do {
if( curAngle > endparam )
{
curAngle = endparam;
i = parts + 2;
}
cosCurr = cos( curAngle );
sinCurr = sin( curAngle );
double x = basePoint.x + (cosCurr * cosRot * radMajor) - (sinCurr * sinRot * radMinor);
double y = basePoint.y + (cosCurr * sinRot * radMajor) + (sinCurr * cosRot * radMinor);
pol->addVertex( DRW_Vertex( x, y, 0.0, 0.0 ) );
curAngle = (++i) * incAngle;
} while( i<parts );
if( fabs( endparam - staparam - M_PIx2 ) < 1.0e-10 )
{
pol->flags = 1;
}
pol->layer = this->layer;
pol->lineType = this->lineType;
pol->color = this->color;
pol->lWeight = this->lWeight;
pol->extPoint = this->extPoint;
}
void DRW_Trace::applyExtrusion()
{
if( haveExtrusion )
{
calculateAxis( extPoint );
extrudePoint( extPoint, &basePoint );
extrudePoint( extPoint, &secPoint );
extrudePoint( extPoint, &thirdPoint );
extrudePoint( extPoint, &fourPoint );
}
}
void DRW_Trace::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 12:
thirdPoint.x = reader->getDouble();
break;
case 22:
thirdPoint.y = reader->getDouble();
break;
case 32:
thirdPoint.z = reader->getDouble();
break;
case 13:
fourPoint.x = reader->getDouble();
break;
case 23:
fourPoint.y = reader->getDouble();
break;
case 33:
fourPoint.z = reader->getDouble();
break;
default:
DRW_Line::parseCode( code, reader );
break;
}
}
void DRW_Solid::parseCode( int code, dxfReader* reader )
{
DRW_Trace::parseCode( code, reader );
}
void DRW_3Dface::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 70:
invisibleflag = reader->getInt32();
break;
default:
DRW_Trace::parseCode( code, reader );
break;
}
}
void DRW_Block::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 2:
name = reader->getUtf8String();
break;
case 70:
flags = reader->getInt32();
break;
default:
DRW_Point::parseCode( code, reader );
break;
}
}
void DRW_Insert::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 2:
name = reader->getUtf8String();
break;
case 41:
xscale = reader->getDouble();
break;
case 42:
yscale = reader->getDouble();
break;
case 43:
zscale = reader->getDouble();
break;
case 50:
angle = reader->getDouble();
break;
case 70:
colcount = reader->getInt32();
break;
case 71:
rowcount = reader->getInt32();
break;
case 44:
colspace = reader->getDouble();
break;
case 45:
rowspace = reader->getDouble();
break;
default:
DRW_Point::parseCode( code, reader );
break;
}
}
void DRW_LWPolyline::applyExtrusion()
{
if( haveExtrusion )
{
calculateAxis( extPoint );
for( unsigned int i = 0; i<vertlist.size(); i++ )
{
DRW_Vertex2D* vert = vertlist.at( i );
DRW_Coord v( vert->x, vert->y, elevation );
extrudePoint( extPoint, &v );
vert->x = v.x;
vert->y = v.y;
}
}
}
void DRW_LWPolyline::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 10:
{
vertex = new DRW_Vertex2D();
vertlist.push_back( vertex );
vertex->x = reader->getDouble();
break;
}
case 20:
if( vertex != NULL )
vertex->y = reader->getDouble();
break;
case 40:
if( vertex != NULL )
vertex->stawidth = reader->getDouble();
break;
case 41:
if( vertex != NULL )
vertex->endwidth = reader->getDouble();
break;
case 42:
if( vertex != NULL )
vertex->bulge = reader->getDouble();
break;
case 38:
elevation = reader->getDouble();
break;
case 39:
thickness = reader->getDouble();
break;
case 43:
width = reader->getDouble();
break;
case 70:
flags = reader->getInt32();
break;
case 90:
vertexnum = reader->getInt32();
vertlist.reserve( vertexnum );
break;
case 210:
haveExtrusion = true;
extPoint.x = reader->getDouble();
break;
case 220:
extPoint.y = reader->getDouble();
break;
case 230:
extPoint.z = reader->getDouble();
break;
default:
DRW_Entity::parseCode( code, reader );
break;
}
}
void DRW_Text::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 40:
height = reader->getDouble();
break;
case 41:
widthscale = reader->getDouble();
break;
case 50:
angle = reader->getDouble();
break;
case 51:
oblique = reader->getDouble();
break;
case 71:
textgen = reader->getInt32();
break;
case 72:
alignH = (HAlign) reader->getInt32();
break;
case 73:
alignV = (VAlign) reader->getInt32();
break;
case 1:
text = reader->getUtf8String();
break;
case 7:
style = reader->getUtf8String();
break;
default:
DRW_Line::parseCode( code, reader );
break;
}
}
void DRW_MText::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 1:
text += reader->getString();
text = reader->toUtf8String( text );
break;
case 11:
haveXAxis = true;
DRW_Text::parseCode( code, reader );
break;
case 3:
text += reader->getString();
break;
case 44:
interlin = reader->getDouble();
break;
default:
DRW_Text::parseCode( code, reader );
break;
}
}
void DRW_MText::updateAngle()
{
if( haveXAxis )
{
angle = atan2( secPoint.y, secPoint.x ) * 180 / M_PI;
}
}
void DRW_Polyline::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 70:
flags = reader->getInt32();
break;
case 40:
defstawidth = reader->getDouble();
break;
case 41:
defendwidth = reader->getDouble();
break;
case 71:
vertexcount = reader->getInt32();
break;
case 72:
facecount = reader->getInt32();
break;
case 73:
smoothM = reader->getInt32();
break;
case 74:
smoothN = reader->getInt32();
break;
case 75:
curvetype = reader->getInt32();
break;
default:
DRW_Point::parseCode( code, reader );
break;
}
}
void DRW_Vertex::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 70:
flags = reader->getInt32();
break;
case 40:
stawidth = reader->getDouble();
break;
case 41:
endwidth = reader->getDouble();
break;
case 42:
bulge = reader->getDouble();
break;
case 50:
tgdir = reader->getDouble();
break;
case 71:
vindex1 = reader->getInt32();
break;
case 72:
vindex2 = reader->getInt32();
break;
case 73:
vindex3 = reader->getInt32();
break;
case 74:
vindex4 = reader->getInt32();
break;
case 91:
identifier = reader->getInt32();
break;
default:
DRW_Point::parseCode( code, reader );
break;
}
}
void DRW_Hatch::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 2:
name = reader->getUtf8String();
break;
case 70:
solid = reader->getInt32();
break;
case 71:
associative = reader->getInt32();
break;
case 72: /*edge type*/
if( ispol ) // if is polyline is a as_bulge flag
{
break;
}
else if( reader->getInt32() == 1 ) // line
{
addLine();
}
else if( reader->getInt32() == 2 ) // arc
{
addArc();
}
else if( reader->getInt32() == 3 ) // elliptic arc
{
addEllipse();
}
else if( reader->getInt32() == 4 ) // spline
{
addSpline();
}
break;
case 10:
if( pt )
pt->basePoint.x = reader->getDouble();
else if( pline )
{
plvert = pline->addVertex();
plvert->x = reader->getDouble();
}
break;
case 20:
if( pt )
pt->basePoint.y = reader->getDouble();
else if( plvert )
plvert->y = reader->getDouble();
break;
case 11:
if( line )
line->secPoint.x = reader->getDouble();
else if( ellipse )
ellipse->secPoint.x = reader->getDouble();
break;
case 21:
if( line )
line->secPoint.y = reader->getDouble();
else if( ellipse )
ellipse->secPoint.y = reader->getDouble();
break;
case 40:
if( arc )
arc->radious = reader->getDouble();
else if( ellipse )
ellipse->ratio = reader->getDouble();
break;
case 41:
scale = reader->getDouble();
break;
case 42:
if( plvert )
plvert->bulge = reader->getDouble();
break;
case 50:
if( arc )
arc->staangle = reader->getDouble() / ARAD;
else if( ellipse )
ellipse->staparam = reader->getDouble() / ARAD;
break;
case 51:
if( arc )
arc->endangle = reader->getDouble() / ARAD;
else if( ellipse )
ellipse->endparam = reader->getDouble() / ARAD;
break;
case 52:
angle = reader->getDouble();
break;
case 73:
if( arc )
arc->isccw = reader->getInt32();
else if( pline )
pline->flags = reader->getInt32();
break;
case 75:
hstyle = reader->getInt32();
break;
case 76:
hpattern = reader->getInt32();
break;
case 77:
doubleflag = reader->getInt32();
break;
case 78:
deflines = reader->getInt32();
break;
case 91:
loopsnum = reader->getInt32();
looplist.reserve( loopsnum );
break;
case 92:
loop = new DRW_HatchLoop( reader->getInt32() );
looplist.push_back( loop );
if( reader->getInt32() & 2 )
{
ispol = true;
clearEntities();
pline = new DRW_LWPolyline;
loop->objlist.push_back( pline );
}
else
ispol = false;
break;
case 93:
if( pline )
pline->vertexnum = reader->getInt32();
else
loop->numedges = reader->getInt32(); // aqui reserve
break;
case 98: // seed points ??
clearEntities();
break;
default:
DRW_Point::parseCode( code, reader );
break;
}
}
void DRW_Spline::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 210:
ex = reader->getDouble();
break;
case 220:
ey = reader->getDouble();
break;
case 230:
ez = reader->getDouble();
break;
case 12:
tgsx = reader->getDouble();
break;
case 22:
tgsy = reader->getDouble();
break;
case 32:
tgsz = reader->getDouble();
break;
case 13:
tgex = reader->getDouble();
break;
case 23:
tgey = reader->getDouble();
break;
case 33:
tgez = reader->getDouble();
break;
case 70:
flags = reader->getInt32();
break;
case 71:
degree = reader->getInt32();
break;
case 72:
nknots = reader->getInt32();
break;
case 73:
ncontrol = reader->getInt32();
break;
case 74:
nfit = reader->getInt32();
break;
case 42:
tolknot = reader->getDouble();
break;
case 43:
tolcontrol = reader->getDouble();
break;
case 44:
tolfit = reader->getDouble();
break;
case 10:
{
controlpoint = new DRW_Coord();
controllist.push_back( controlpoint );
controlpoint->x = reader->getDouble();
break;
}
case 20:
if( controlpoint != NULL )
controlpoint->y = reader->getDouble();
break;
case 30:
if( controlpoint != NULL )
controlpoint->z = reader->getDouble();
break;
case 11:
{
fitpoint = new DRW_Coord();
fitlist.push_back( fitpoint );
fitpoint->x = reader->getDouble();
break;
}
case 21:
if( fitpoint != NULL )
fitpoint->y = reader->getDouble();
break;
case 31:
if( fitpoint != NULL )
fitpoint->z = reader->getDouble();
break;
case 40:
knotslist.push_back( reader->getDouble() );
break;
// case 41:
// break;
default:
DRW_Entity::parseCode( code, reader );
break;
}
}
void DRW_Image::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 12:
vx = reader->getDouble();
break;
case 22:
vy = reader->getDouble();
break;
case 32:
vz = reader->getDouble();
break;
case 13:
sizeu = reader->getDouble();
break;
case 23:
sizev = reader->getDouble();
break;
case 340:
ref = reader->getString();
break;
case 280:
clip = reader->getInt32();
break;
case 281:
brightness = reader->getInt32();
break;
case 282:
contrast = reader->getInt32();
break;
case 283:
fade = reader->getInt32();
break;
default:
DRW_Line::parseCode( code, reader );
break;
}
}
void DRW_Dimension::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 1:
text = reader->getUtf8String();
break;
case 2:
name = reader->getString();
break;
case 3:
style = reader->getUtf8String();
break;
case 70:
type = reader->getInt32();
break;
case 71:
align = reader->getInt32();
break;
case 72:
linesty = reader->getInt32();
break;
case 10:
defPoint.x = reader->getDouble();
break;
case 20:
defPoint.y = reader->getDouble();
break;
case 30:
defPoint.z = reader->getDouble();
break;
case 11:
textPoint.x = reader->getDouble();
break;
case 21:
textPoint.y = reader->getDouble();
break;
case 31:
textPoint.z = reader->getDouble();
break;
case 12:
clonePoint.x = reader->getDouble();
break;
case 22:
clonePoint.y = reader->getDouble();
break;
case 32:
clonePoint.z = reader->getDouble();
break;
case 13:
def1.x = reader->getDouble();
break;
case 23:
def1.y = reader->getDouble();
break;
case 33:
def1.z = reader->getDouble();
break;
case 14:
def2.x = reader->getDouble();
break;
case 24:
def2.y = reader->getDouble();
break;
case 34:
def2.z = reader->getDouble();
break;
case 15:
circlePoint.x = reader->getDouble();
break;
case 25:
circlePoint.y = reader->getDouble();
break;
case 35:
circlePoint.z = reader->getDouble();
break;
case 16:
arcPoint.x = reader->getDouble();
break;
case 26:
arcPoint.y = reader->getDouble();
break;
case 36:
arcPoint.z = reader->getDouble();
break;
case 41:
linefactor = reader->getDouble();
break;
case 53:
rot = reader->getDouble();
break;
case 50:
angle = reader->getDouble();
break;
case 52:
oblique = reader->getDouble();
break;
case 40:
length = reader->getDouble();
break;
/* case 51:
* hdir = reader->getDouble();
* break;*/
default:
DRW_Entity::parseCode( code, reader );
break;
}
}
void DRW_Leader::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 3:
style = reader->getUtf8String();
break;
case 71:
arrow = reader->getInt32();
break;
case 72:
leadertype = reader->getInt32();
break;
case 73:
flag = reader->getInt32();
break;
case 74:
hookline = reader->getInt32();
break;
case 75:
hookflag = reader->getInt32();
break;
case 76:
vertnum = reader->getInt32();
break;
case 77:
coloruse = reader->getInt32();
break;
case 40:
textheight = reader->getDouble();
break;
case 41:
textwidth = reader->getDouble();
break;
case 10:
{
vertexpoint = new DRW_Coord();
vertexlist.push_back( vertexpoint );
vertexpoint->x = reader->getDouble();
break;
}
case 20:
if( vertexpoint != NULL )
vertexpoint->y = reader->getDouble();
break;
case 30:
if( vertexpoint != NULL )
vertexpoint->z = reader->getDouble();
break;
case 340:
handle = reader->getString();
break;
case 210:
extrusionPoint.x = reader->getDouble();
break;
case 220:
extrusionPoint.y = reader->getDouble();
break;
case 230:
extrusionPoint.z = reader->getDouble();
break;
case 211:
horizdir.x = reader->getDouble();
break;
case 221:
horizdir.y = reader->getDouble();
break;
case 231:
horizdir.z = reader->getDouble();
break;
case 212:
offsetblock.x = reader->getDouble();
break;
case 222:
offsetblock.y = reader->getDouble();
break;
case 232:
offsetblock.z = reader->getDouble();
break;
case 213:
offsettext.x = reader->getDouble();
break;
case 223:
offsettext.y = reader->getDouble();
break;
case 233:
offsettext.z = reader->getDouble();
break;
default:
DRW_Entity::parseCode( code, reader );
break;
}
}
void DRW_Viewport::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 40:
pswidth = reader->getDouble();
break;
case 41:
psheight = reader->getDouble();
break;
case 68:
vpstatus = reader->getInt32();
break;
case 69:
vpID = reader->getInt32();
break;
case 12:
{
centerPX = reader->getDouble();
break;
}
case 22:
centerPY = reader->getDouble();
break;
default:
DRW_Point::parseCode( code, reader );
break;
}
}
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#ifndef DRW_ENTITIES_H
#define DRW_ENTITIES_H
#include <string>
#include <vector>
#include "drw_base.h"
class dxfReader;
class DRW_Polyline;
using std::string;
namespace DRW {
// ! Entity's type.
enum ETYPE {
POINT,
LINE,
CIRCLE,
ARC,
ELLIPSE,
TRACE,
SOLID,
BLOCK,
INSERT,
LWPOLYLINE,
POLYLINE,
VERTEX,
SPLINE,
HATCH,
TEXT,
MTEXT,
E3DFACE,
IMAGE,
LEADER,
DIMENSION,
DIMALIGNED,
DIMLINEAR,
DIMRADIAL,
DIMDIAMETRIC,
DIMANGULAR,
DIMANGULAR3P,
DIMORDINATE,
// OVERLAYBOX,
// CONSTRUCTIONLINE,
RAY,
XLINE,
VIEWPORT,
UNKNOWN
};
}
// ! Base class for entities
/*!
* Base class for entities
* @author Rallaz
*/
class DRW_Entity
{
public:
// initializes default values
DRW_Entity()
{
eType = DRW::UNKNOWN;
lineType = "BYLAYER";
color = 256; // default BYLAYER (256)
ltypeScale = 1.0;
visible = true;
layer = "0";
lWeight = DRW_LW_Conv::widthByLayer; // default BYLAYER (dxf -1, dwg 29)
handleBlock = space = 0; // default ModelSpace (0) & handleBlock = no handle (0)
haveExtrusion = false;
color24 = -1; // default -1 not set
}
virtual ~DRW_Entity() {}
DRW_Entity( const DRW_Entity& d )
{
eType = d.eType;
handle = d.handle;
handleBlock = d.handleBlock;
layer = d.layer;
lineType = d.lineType;
color = d.color;
color24 = d.color24;
colorName = d.colorName;
ltypeScale = d.ltypeScale;
visible = d.visible;
lWeight = d.lWeight;
space = d.space;
haveExtrusion = d.haveExtrusion;
}
virtual void applyExtrusion() = 0;
protected:
void parseCode( int code, dxfReader* reader );
void calculateAxis( DRW_Coord extPoint );
void extrudePoint( DRW_Coord extPoint, DRW_Coord* point );
public:
enum DRW::ETYPE eType; /*!< enum: entity type, code 0 */
int handle; /*!< entity identifier, code 5 */
int handleBlock; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */
UTF8STRING layer; /*!< layer name, code 8 */
UTF8STRING lineType; /*!< line type, code 6 */
int color; /*!< entity color, code 62 */
enum DRW_LW_Conv::lineWidth lWeight; /*!< entity lineweight, code 370 */
double ltypeScale; /*!< linetype scale, code 48 */
bool visible; /*!< entity visibility, code 60 */
int color24; /*!< 24-bit color, code 420 */
string colorName; /*!< color name, code 430 */
int space; /*!< space indicator 0 = model, 1 paper, code 67*/
bool haveExtrusion; /*!< set to true if the entity have extrusion*/
private:
DRW_Coord extAxisX;
DRW_Coord extAxisY;
};
// ! Class to handle point entity
/*!
* Class to handle point entity
* @author Rallaz
*/
class DRW_Point : public DRW_Entity
{
public:
DRW_Point()
{
eType = DRW::POINT;
basePoint.z = extPoint.x = extPoint.y = 0;
extPoint.z = 1;
thickness = 0;
}
virtual void applyExtrusion() {}
void parseCode( int code, dxfReader* reader );
public:
DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */
double thickness; /*!< thickness, code 39 */
DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */
};
// ! Class to handle line entity
/*!
* Class to handle line entity
* @author Rallaz
*/
class DRW_Line : public DRW_Point
{
public:
DRW_Line()
{
eType = DRW::LINE;
secPoint.z = 0;
}
virtual void applyExtrusion() {}
void parseCode( int code, dxfReader* reader );
public:
DRW_Coord secPoint; /*!< second point, code 11, 21 & 31 */
};
// ! Class to handle ray entity
/*!
* Class to handle ray entity
* @author Rallaz
*/
class DRW_Ray : public DRW_Line
{
public:
DRW_Ray()
{
eType = DRW::RAY;
}
};
// ! Class to handle xline entity
/*!
* Class to handle xline entity
* @author Rallaz
*/
class DRW_Xline : public DRW_Line
{
public:
DRW_Xline()
{
eType = DRW::XLINE;
}
};
// ! Class to handle circle entity
/*!
* Class to handle circle entity
* @author Rallaz
*/
class DRW_Circle : public DRW_Point
{
public:
DRW_Circle()
{
eType = DRW::CIRCLE;
}
virtual void applyExtrusion();
void parseCode( int code, dxfReader* reader );
public:
double radious; /*!< radius, code 40 */
};
// ! Class to handle arc entity
/*!
* Class to handle arc entity
* @author Rallaz
*/
class DRW_Arc : public DRW_Circle
{
public:
DRW_Arc()
{
eType = DRW::ARC;
isccw = 1;
}
virtual void applyExtrusion() { DRW_Circle::applyExtrusion(); }
void parseCode( int code, dxfReader* reader );
public:
double staangle; /*!< start angle, code 50 in radians*/
double endangle; /*!< end angle, code 51 in radians */
int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */
};
// ! Class to handle ellipse entity
/*!
* Class to handle ellipse and elliptic arc entity
* Note: start/end parameter are in radians for ellipse entity but
* for hatch boundary are in degrees
* @author Rallaz
*/
class DRW_Ellipse : public DRW_Line
{
public:
DRW_Ellipse()
{
eType = DRW::ELLIPSE;
isccw = 1;
}
void parseCode( int code, dxfReader* reader );
void toPolyline( DRW_Polyline* pol, int parts = 128 );
virtual void applyExtrusion();
void correctAxis();
public:
double ratio; /*!< ratio, code 40 */
double staparam; /*!< start parameter, code 41, 0.0 for full ellipse*/
double endparam; /*!< end parameter, code 42, 2*PI for full ellipse */
int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */
};
// ! Class to handle trace entity
/*!
* Class to handle trace entity
* @author Rallaz
*/
class DRW_Trace : public DRW_Line
{
public:
DRW_Trace()
{
eType = DRW::TRACE;
thirdPoint.z = 0;
fourPoint.z = 0;
}
virtual void applyExtrusion();
void parseCode( int code, dxfReader* reader );
public:
DRW_Coord thirdPoint; /*!< third point, code 12, 22 & 32 */
DRW_Coord fourPoint; /*!< four point, code 13, 23 & 33 */
};
// ! Class to handle solid entity
/*!
* Class to handle solid entity
* @author Rallaz
*/
class DRW_Solid : public DRW_Trace
{
public:
DRW_Solid()
{
eType = DRW::SOLID;
}
void parseCode( int code, dxfReader* reader );
};
// ! Class to handle 3dface entity
/*!
* Class to handle 3dface entity
* @author Rallaz
*/
class DRW_3Dface : public DRW_Trace
{
public:
DRW_3Dface()
{
eType = DRW::E3DFACE;
invisibleflag = 0;
}
virtual void applyExtrusion() {}
void parseCode( int code, dxfReader* reader );
public:
int invisibleflag; /*!< invisible edge flag, code 70 */
};
// ! Class to handle block entries
/*!
* Class to handle block entries
* @author Rallaz
*/
class DRW_Block : public DRW_Point
{
public:
DRW_Block()
{
eType = DRW::BLOCK;
layer = "0";
flags = 0;
name = "*U0";
}
virtual void applyExtrusion() {}
void parseCode( int code, dxfReader* reader );
public:
UTF8STRING name; /*!< block name, code 2 */
int flags; /*!< block type, code 70 */
};
// ! Class to handle insert entries
/*!
* Class to handle insert entries
* @author Rallaz
*/
class DRW_Insert : public DRW_Point
{
public:
DRW_Insert()
{
eType = DRW::INSERT;
xscale = 1;
yscale = 1;
zscale = 1;
angle = 0;
colcount = 1;
rowcount = 1;
colspace = 0;
rowspace = 0;
}
virtual void applyExtrusion() { DRW_Point::applyExtrusion(); }
void parseCode( int code, dxfReader* reader );
public:
UTF8STRING name; /*!< block name, code 2 */
double xscale; /*!< x scale factor, code 41 */
double yscale; /*!< y scale factor, code 42 */
double zscale; /*!< z scale factor, code 43 */
double angle; /*!< rotation angle, code 50 */
int colcount; /*!< column count, code 70 */
int rowcount; /*!< row count, code 71 */
double colspace; /*!< column space, code 44 */
double rowspace; /*!< row space, code 45 */
};
// ! Class to handle lwpolyline entity
/*!
* Class to handle lwpolyline entity
* @author Rallaz
*/
class DRW_LWPolyline : public DRW_Entity
{
public:
DRW_LWPolyline()
{
eType = DRW::LWPOLYLINE;
elevation = thickness = width = 0.0;
flags = 0;
extPoint.x = extPoint.y = 0;
extPoint.z = 1;
vertex = NULL;
}
~DRW_LWPolyline()
{
while( !vertlist.empty() )
{
vertlist.pop_back();
}
}
virtual void applyExtrusion();
void addVertex( DRW_Vertex2D v )
{
DRW_Vertex2D* vert = new DRW_Vertex2D();
vert->x = v.x;
vert->y = v.y;
vert->stawidth = v.stawidth;
vert->endwidth = v.endwidth;
vert->bulge = v.bulge;
vertlist.push_back( vert );
}
DRW_Vertex2D* addVertex()
{
DRW_Vertex2D* vert = new DRW_Vertex2D();
vert->stawidth = 0;
vert->endwidth = 0;
vert->bulge = 0;
vertlist.push_back( vert );
return vert;
}
void parseCode( int code, dxfReader* reader );
public:
int vertexnum; /*!< number of vertex, code 90 */
int flags; /*!< polyline flag, code 70, default 0 */
double width; /*!< constant width, code 43 */
double elevation; /*!< elevation, code 38 */
double thickness; /*!< thickness, code 39 */
DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */
DRW_Vertex2D* vertex; /*!< current vertex to add data */
std::vector<DRW_Vertex2D*> vertlist; /*!< vertex list */
};
// ! Class to handle insert entries
/*!
* Class to handle insert entries
* @author Rallaz
*/
class DRW_Text : public DRW_Line
{
public:
// ! Vertical alignments.
enum VAlign {
VBaseLine = 0, /*!< Top = 0 */
VBottom, /*!< Bottom = 1 */
VMiddle, /*!< Middle = 2 */
VTop /*!< Top = 3 */
};
// ! Horizontal alignments.
enum HAlign {
HLeft = 0, /*!< Left = 0 */
HCenter, /*!< Centered = 1 */
HRight, /*!< Right = 2 */
HAligned, /*!< Aligned = 3 (if VAlign==0) */
HMiddle, /*!< middle = 4 (if VAlign==0) */
HFit /*!< fit into point = 5 (if VAlign==0) */
};
DRW_Text()
{
eType = DRW::TEXT;
angle = 0;
widthscale = 1;
oblique = 0;
style = "STANDARD";
textgen = 0;
alignH = HLeft;
alignV = VBaseLine;
}
virtual void applyExtrusion() {} // RLZ TODO
void parseCode( int code, dxfReader* reader );
public:
double height; /*!< height text, code 40 */
UTF8STRING text; /*!< text string, code 1 */
double angle; /*!< rotation angle in degrees (360), code 50 */
double widthscale; /*!< width factor, code 41 */
double oblique; /*!< oblique angle, code 51 */
UTF8STRING style; /*!< style name, code 7 */
int textgen; /*!< text generation, code 71 */
enum HAlign alignH; /*!< horizontal align, code 72 */
enum VAlign alignV; /*!< vertical align, code 73 */
};
// ! Class to handle insert entries
/*!
* Class to handle insert entries
* @author Rallaz
*/
class DRW_MText : public DRW_Text
{
public:
// ! Attachments.
enum Attach {
TopLeft = 1,
TopCenter,
TopRight,
MiddleLeft,
MiddleCenter,
MiddleRight,
BottomLeft,
BottomCenter,
BottomRight
};
DRW_MText()
{
eType = DRW::MTEXT;
interlin = 1;
alignV = (VAlign) TopLeft;
textgen = 1;
haveXAxis = false; // if true needed to recalculate angle
}
void parseCode( int code, dxfReader* reader );
void updateAngle(); // recalculate angle if 'haveXAxis' is true
public:
double interlin; /*!< width factor, code 44 */
private:
bool haveXAxis;
};
// ! Class to handle vertex
/*!
* Class to handle vertex for polyline entity
* @author Rallaz
*/
class DRW_Vertex : public DRW_Point
{
public:
DRW_Vertex()
{
eType = DRW::VERTEX;
stawidth = endwidth = bulge = 0;
vindex1 = vindex2 = vindex3 = vindex4 = 0;
flags = identifier = 0;
}
DRW_Vertex( double sx, double sy, double sz, double b )
{
stawidth = endwidth = 0;
vindex1 = vindex2 = vindex3 = vindex4 = 0;
flags = identifier = 0;
basePoint.x = sx;
basePoint.y = sy;
basePoint.z = sz;
bulge = b;
}
void parseCode( int code, dxfReader* reader );
public:
double stawidth; /*!< Start width, code 40 */
double endwidth; /*!< End width, code 41 */
double bulge; /*!< bulge, code 42 */
int flags; /*!< vertex flag, code 70, default 0 */
double tgdir; /*!< curve fit tangent direction, code 50 */
int vindex1; /*!< polyface mesh vertex index, code 71, default 0 */
int vindex2; /*!< polyface mesh vertex index, code 72, default 0 */
int vindex3; /*!< polyface mesh vertex index, code 73, default 0 */
int vindex4; /*!< polyface mesh vertex index, code 74, default 0 */
int identifier; /*!< vertex identifier, code 91, default 0 */
};
// ! Class to handle polyline entity
/*!
* Class to handle polyline entity
* @author Rallaz
*/
class DRW_Polyline : public DRW_Point
{
public:
DRW_Polyline()
{
eType = DRW::POLYLINE;
defstawidth = defendwidth = 0.0;
basePoint.x = basePoint.y = 0.0;
flags = vertexcount = facecount = 0;
smoothM = smoothN = curvetype = 0;
}
~DRW_Polyline()
{
while( !vertlist.empty() )
{
vertlist.pop_back();
}
}
void addVertex( DRW_Vertex v )
{
DRW_Vertex* vert = new DRW_Vertex();
vert->basePoint.x = v.basePoint.x;
vert->basePoint.y = v.basePoint.y;
vert->basePoint.z = v.basePoint.z;
vert->stawidth = v.stawidth;
vert->endwidth = v.endwidth;
vert->bulge = v.bulge;
vertlist.push_back( vert );
}
void appendVertex( DRW_Vertex* v )
{
vertlist.push_back( v );
}
void parseCode( int code, dxfReader* reader );
public:
int flags; /*!< polyline flag, code 70, default 0 */
double defstawidth; /*!< Start width, code 40, default 0 */
double defendwidth; /*!< End width, code 41, default 0 */
int vertexcount; /*!< polygon mesh M vertex or polyface vertex num, code 71, default 0 */
int facecount; /*!< polygon mesh N vertex or polyface face num, code 72, default 0 */
int smoothM; /*!< smooth surface M density, code 73, default 0 */
int smoothN; /*!< smooth surface M density, code 74, default 0 */
int curvetype; /*!< curves & smooth surface type, code 75, default 0 */
std::vector<DRW_Vertex*> vertlist; /*!< vertex list */
};
// ! Class to handle spline entity
/*!
* Class to handle spline entity
* @author Rallaz
*/
class DRW_Spline : public DRW_Entity
{
public:
DRW_Spline()
{
eType = DRW::SPLINE;
flags = nknots = ncontrol = nfit = 0;
ex = ey = 0.0;
ez = 1.0;
tolknot = tolcontrol = tolfit = 0.0000001;
}
~DRW_Spline()
{
while( !controllist.empty() )
{
controllist.pop_back();
}
while( !fitlist.empty() )
{
fitlist.pop_back();
}
}
virtual void applyExtrusion() {}
void parseCode( int code, dxfReader* reader );
public:
double ex; /*!< normal vector x coordinate, code 210 */
double ey; /*!< normal vector y coordinate, code 220 */
double ez; /*!< normal vector z coordinate, code 230 */
double tgsx; /*!< start tangent x coordinate, code 12 */
double tgsy; /*!< start tangent y coordinate, code 22 */
double tgsz; /*!< start tangent z coordinate, code 32 */
double tgex; /*!< end tangent x coordinate, code 13 */
double tgey; /*!< end tangent y coordinate, code 23 */
double tgez; /*!< end tangent z coordinate, code 33 */
int flags; /*!< spline flag, code 70 */
int degree; /*!< degree of the spline, code 71 */
int nknots; /*!< number of knots, code 72, default 0 */
int ncontrol; /*!< number of control points, code 73, default 0 */
int nfit; /*!< number of fit points, code 74, default 0 */
double tolknot; /*!< knot tolerance, code 42, default 0.0000001 */
double tolcontrol; /*!< control point tolerance, code 43, default 0.0000001 */
double tolfit; /*!< fit point tolerance, code 44, default 0.0000001 */
std::vector<double> knotslist; /*!< knots list, code 40 */
std::vector<DRW_Coord*> controllist; /*!< control points list, code 10, 20 & 30 */
std::vector<DRW_Coord*> fitlist; /*!< fit points list, code 11, 21 & 31 */
private:
DRW_Coord* controlpoint; /*!< current control point to add data */
DRW_Coord* fitpoint; /*!< current fit point to add data */
};
// ! Class to handle hatch loop
/*!
* Class to handle hatch loop
* @author Rallaz
*/
class DRW_HatchLoop
{
public:
DRW_HatchLoop( int t )
{
type = t;
numedges = 0;
}
~DRW_HatchLoop()
{
/* while (!pollist.empty()) {
* pollist.pop_back();
* }*/
while( !objlist.empty() )
{
objlist.pop_back();
}
}
void update()
{
numedges = objlist.size();
}
public:
int type; /*!< boundary path type, code 92, polyline=2, default=0 */
int numedges; /*!< number of edges (if not a polyline), code 93 */
// TODO: store lwpolylines as entities
// std::vector<DRW_LWPolyline *> pollist; /*!< polyline list */
std::vector<DRW_Entity*> objlist; /*!< entities list */
};
// ! Class to handle hatch entity
/*!
* Class to handle hatch entity
* @author Rallaz
*/
// TODO: handle lwpolylines, splines and ellipses
class DRW_Hatch : public DRW_Point
{
public:
DRW_Hatch()
{
eType = DRW::HATCH;
angle = scale = 0.0;
basePoint.x = basePoint.y = basePoint.z = 0.0;
loopsnum = hstyle = associative = 0;
solid = hpattern = 1;
deflines = doubleflag = 0;
loop = NULL;
clearEntities();
}
~DRW_Hatch()
{
while( !looplist.empty() )
{
looplist.pop_back();
}
}
void appendLoop( DRW_HatchLoop* v )
{
looplist.push_back( v );
}
virtual void applyExtrusion() {}
void parseCode( int code, dxfReader* reader );
public:
UTF8STRING name; /*!< hatch pattern name, code 2 */
int solid; /*!< solid fill flag, code 70, solid=1, pattern=0 */
int associative; /*!< associativity, code 71, associatve=1, non-assoc.=0 */
int hstyle; /*!< hatch style, code 75 */
int hpattern; /*!< hatch pattern type, code 76 */
int doubleflag; /*!< hatch pattern double flag, code 77, double=1, single=0 */
int loopsnum; /*!< namber of boundary paths (loops), code 91 */
double angle; /*!< hatch pattern angle, code 52 */
double scale; /*!< hatch pattern scale, code 41 */
int deflines; /*!< number of pattern definition lines, code 78 */
std::vector<DRW_HatchLoop*> looplist; /*!< polyline list */
private:
void clearEntities()
{
pt = line = NULL;
pline = NULL;
arc = NULL;
ellipse = NULL;
spline = NULL;
plvert = NULL;
}
void addLine()
{
clearEntities();
if( loop )
{
pt = line = new DRW_Line;
loop->objlist.push_back( line );
}
}
void addArc()
{
clearEntities();
if( loop )
{
pt = arc = new DRW_Arc;
loop->objlist.push_back( arc );
}
}
void addEllipse()
{
clearEntities();
if( loop )
{
pt = ellipse = new DRW_Ellipse;
loop->objlist.push_back( ellipse );
}
}
void addSpline()
{
clearEntities();
if( loop )
{
pt = NULL;
spline = new DRW_Spline;
loop->objlist.push_back( spline );
}
}
DRW_HatchLoop* loop; /*!< current loop to add data */
DRW_Line* line;
DRW_Arc* arc;
DRW_Ellipse* ellipse;
DRW_Spline* spline;
DRW_LWPolyline* pline;
DRW_Point* pt;
DRW_Vertex2D* plvert;
bool ispol;
};
// ! Class to handle image entity
/*!
* Class to handle image entity
* @author Rallaz
*/
class DRW_Image : public DRW_Line
{
public:
DRW_Image()
{
eType = DRW::IMAGE;
vz = fade = clip = 0;
brightness = contrast = 50;
}
void parseCode( int code, dxfReader* reader );
public:
string ref; /*!< Hard reference to imagedef object, code 340 */
double vx; /*!< V-vector of single pixel, x coordinate, code 12 */
double vy; /*!< V-vector of single pixel, y coordinate, code 22 */
double vz; /*!< V-vector of single pixel, z coordinate, code 32 */
double sizeu; /*!< image size in pixels, U value, code 13 */
double sizev; /*!< image size in pixels, V value, code 23 */
double dz; /*!< z coordinate, code 33 */
int clip; /*!< Clipping state, code 280, 0=off 1=on */
int brightness; /*!< Brightness value, code 281, (0-100) default 50 */
int contrast; /*!< Brightness value, code 282, (0-100) default 50 */
int fade; /*!< Brightness value, code 283, (0-100) default 0 */
};
// ! Base class for dimension entity
/*!
* Base class for dimension entity
* @author Rallaz
*/
class DRW_Dimension : public DRW_Entity
{
public:
DRW_Dimension()
{
eType = DRW::DIMENSION;
linesty = 1;
linefactor = extPoint.z = 1.0;
angle = oblique = rot = 0.0;
align = 5;
style = "STANDARD";
defPoint.z = extPoint.x = extPoint.y = 0;
textPoint.z = rot = 0;
clonePoint.x = clonePoint.y = clonePoint.z = 0;
}
DRW_Dimension( const DRW_Dimension& d ) : DRW_Entity( d )
{
eType = DRW::DIMENSION;
type = d.type;
name = d.name;
defPoint = d.defPoint;
textPoint = d.textPoint;
text = d.text;
style = d.style;
align = d.align;
linesty = d.linesty;
linefactor = d.linefactor;
rot = d.rot;
extPoint = d.extPoint;
clonePoint = d.clonePoint;
def1 = d.def1;
def2 = d.def2;
angle = d.angle;
oblique = d.oblique;
arcPoint = d.arcPoint;
circlePoint = d.circlePoint;
length = d.length;
}
virtual ~DRW_Dimension() {}
void parseCode( int code, dxfReader* reader );
virtual void applyExtrusion() {}
DRW_Coord getDefPoint() const { return defPoint; } /*!< Definition point, code 10, 20 & 30 */
void setDefPoint( const DRW_Coord p ) { defPoint = p; }
DRW_Coord getTextPoint() const { return textPoint; } /*!< Middle point of text, code 11, 21 & 31 */
void setTextPoint( const DRW_Coord p ) { textPoint = p; }
string getStyle() const { return style; } /*!< Dimension style, code 3 */
void setStyle( const string s ) { style = s; }
int getAlign() const { return align; } /*!< attachment point, code 71 */
void setAlign( const int a ) { align = a; }
int getTextLineStyle() const { return linesty; } /*!< Dimension text line spacing style, code 72, default 1 */
void setTextLineStyle( const int l ) { linesty = l; }
string getText() const { return text; } /*!< Dimension text explicitly entered by the user, code 1 */
void setText( const string t ) { text = t; }
double getTextLineFactor() const { return linefactor; } /*!< Dimension text line spacing factor, code 41, default 1? */
void setTextLineFactor( const double l ) { linefactor = l; }
double getDir() const { return rot; } /*!< rotation angle of the dimension text, code 53 (optional) default 0 */
void setDir( const double d ) { rot = d; }
DRW_Coord getExtrusion() { return extPoint; } /*!< extrusion, code 210, 220 & 230 */
void setExtrusion( const DRW_Coord p ) { extPoint = p; }
string getName() { return name; } /*!< Name of the block that contains the entities, code 2 */
void setName( const string s ) { name = s; }
// int getType(){ return type;} /*!< Dimension type, code 70 */
protected:
DRW_Coord getPt2() const { return clonePoint; }
void setPt2( const DRW_Coord p ) { clonePoint = p; }
DRW_Coord getPt3() const { return def1; }
void setPt3( const DRW_Coord p ) { def1 = p; }
DRW_Coord getPt4() const { return def2; }
void setPt4( const DRW_Coord p ) { def2 = p; }
DRW_Coord getPt5() const { return circlePoint; }
void setPt5( const DRW_Coord p ) { circlePoint = p; }
DRW_Coord getPt6() const { return arcPoint; }
void setPt6( const DRW_Coord p ) { arcPoint = p; }
double getAn50() const { return angle; } /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
void setAn50( const double d ) { angle = d; }
double getOb52() const { return oblique; } /*!< oblique angle, code 52 */
void setOb52( const double d ) { oblique = d; }
double getRa40() const { return length; } /*!< Leader length, code 40 */
void setRa40( const double d ) { length = d; }
public:
int type; /*!< Dimension type, code 70 */
private:
string name; /*!< Name of the block that contains the entities, code 2 */
DRW_Coord defPoint; /*!< definition point, code 10, 20 & 30 (WCS) */
DRW_Coord textPoint; /*!< Middle point of text, code 11, 21 & 31 (OCS) */
UTF8STRING text; /*!< Dimension text explicitly entered by the user, code 1 */
UTF8STRING style; /*!< Dimension style, code 3 */
int align; /*!< attachment point, code 71 */
int linesty; /*!< Dimension text line spacing style, code 72, default 1 */
double linefactor; /*!< Dimension text line spacing factor, code 41, default 1? (value range 0.25 to 4.00*/
double rot; /*!< rotation angle of the dimension text, code 53 */
DRW_Coord extPoint; /*!< extrusion normal vector, code 210, 220 & 230 */
// double hdir; /*!< horizontal direction for the dimension, code 51, default ? */
DRW_Coord clonePoint; /*!< Insertion point for clones (Baseline & Continue), code 12, 22 & 32 (OCS) */
DRW_Coord def1; /*!< Definition point 1for linear & angular, code 13, 23 & 33 (WCS) */
DRW_Coord def2; /*!< Definition point 2, code 14, 24 & 34 (WCS) */
double angle; /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
double oblique; /*!< oblique angle, code 52 */
DRW_Coord circlePoint; /*!< Definition point for diameter, radius & angular dims code 15, 25 & 35 (WCS) */
DRW_Coord arcPoint; /*!< Point defining dimension arc, x coordinate, code 16, 26 & 36 (OCS) */
double length; /*!< Leader length, code 40 */
};
// ! Class to handle aligned dimension entity
/*!
* Class to handle aligned dimension entity
* @author Rallaz
*/
class DRW_DimAligned : public DRW_Dimension
{
public:
DRW_DimAligned()
{
eType = DRW::DIMALIGNED;
}
DRW_DimAligned( const DRW_Dimension& d ) : DRW_Dimension( d )
{
eType = DRW::DIMALIGNED;
}
DRW_Coord getClonepoint() const { return getPt2(); } /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */
void setClonePoint( DRW_Coord c ) { setPt2( c ); }
DRW_Coord getDimPoint() const { return getDefPoint(); } /*!< dim line location point, code 10, 20 & 30 */
void setDimPoint( const DRW_Coord p ) { setDefPoint( p ); }
DRW_Coord getDef1Point() const { return getPt3(); } /*!< Definition point 1, code 13, 23 & 33 */
void setDef1Point( const DRW_Coord p ) { setPt3( p ); }
DRW_Coord getDef2Point() const { return getPt4(); } /*!< Definition point 2, code 14, 24 & 34 */
void setDef2Point( const DRW_Coord p ) { setPt4( p ); }
};
// ! Class to handle linear or rotated dimension entity
/*!
* Class to handle linear or rotated dimension entity
* @author Rallaz
*/
class DRW_DimLinear : public DRW_DimAligned
{
public:
DRW_DimLinear()
{
eType = DRW::DIMLINEAR;
}
DRW_DimLinear( const DRW_Dimension& d ) : DRW_DimAligned( d )
{
eType = DRW::DIMLINEAR;
}
double getAngle() const { return getAn50(); } /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
void setAngle( const double d ) { setAn50( d ); }
double getOblique() const { return getOb52(); } /*!< oblique angle, code 52 */
void setOblique( const double d ) { setOb52( d ); }
};
// ! Class to handle radial dimension entity
/*!
* Class to handle aligned, linear or rotated dimension entity
* @author Rallaz
*/
class DRW_DimRadial : public DRW_Dimension
{
public:
DRW_DimRadial()
{
eType = DRW::DIMRADIAL;
}
DRW_DimRadial( const DRW_Dimension& d ) : DRW_Dimension( d )
{
eType = DRW::DIMRADIAL;
}
DRW_Coord getCenterPoint() const { return getDefPoint(); } /*!< center point, code 10, 20 & 30 */
void setCenterPoint( const DRW_Coord p ) { setDefPoint( p ); }
DRW_Coord getDiameterPoint() const { return getPt5(); } /*!< Definition point for radius, code 15, 25 & 35 */
void setDiameterPoint( const DRW_Coord p ) { setPt5( p ); }
double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */
void setLeaderLength( const double d ) { setRa40( d ); }
};
// ! Class to handle radial dimension entity
/*!
* Class to handle aligned, linear or rotated dimension entity
* @author Rallaz
*/
class DRW_DimDiametric : public DRW_Dimension
{
public:
DRW_DimDiametric()
{
eType = DRW::DIMDIAMETRIC;
}
DRW_DimDiametric( const DRW_Dimension& d ) : DRW_Dimension( d )
{
eType = DRW::DIMDIAMETRIC;
}
DRW_Coord getDiameter1Point() const { return getPt5(); } /*!< First definition point for diameter, code 15, 25 & 35 */
void setDiameter1Point( const DRW_Coord p ) { setPt5( p ); }
DRW_Coord getDiameter2Point() const { return getDefPoint(); } /*!< Oposite point for diameter, code 10, 20 & 30 */
void setDiameter2Point( const DRW_Coord p ) { setDefPoint( p ); }
double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */
void setLeaderLength( const double d ) { setRa40( d ); }
};
// ! Class to handle angular dimension entity
/*!
* Class to handle angular dimension entity
* @author Rallaz
*/
class DRW_DimAngular : public DRW_Dimension
{
public:
DRW_DimAngular()
{
eType = DRW::DIMANGULAR;
}
DRW_DimAngular( const DRW_Dimension& d ) : DRW_Dimension( d )
{
eType = DRW::DIMANGULAR;
}
DRW_Coord getFirstLine1() const { return getPt3(); } /*!< Definition point line 1-1, code 13, 23 & 33 */
void setFirstLine1( const DRW_Coord p ) { setPt3( p ); }
DRW_Coord getFirstLine2() const { return getPt4(); } /*!< Definition point line 1-2, code 14, 24 & 34 */
void setFirstLine2( const DRW_Coord p ) { setPt4( p ); }
DRW_Coord getSecondLine1() const { return getPt5(); } /*!< Definition point line 2-1, code 15, 25 & 35 */
void setSecondLine1( const DRW_Coord p ) { setPt5( p ); }
DRW_Coord getSecondLine2() const { return getDefPoint(); } /*!< Definition point line 2-2, code 10, 20 & 30 */
void setSecondLine2( const DRW_Coord p ) { setDefPoint( p ); }
DRW_Coord getDimPoint() const { return getPt6(); } /*!< Dimension definition point, code 16, 26 & 36 */
void setDimPoint( const DRW_Coord p ) { setPt6( p ); }
};
// ! Class to handle angular 3p dimension entity
/*!
* Class to handle angular 3p dimension entity
* @author Rallaz
*/
class DRW_DimAngular3p : public DRW_Dimension
{
public:
DRW_DimAngular3p()
{
eType = DRW::DIMANGULAR3P;
}
DRW_DimAngular3p( const DRW_Dimension& d ) : DRW_Dimension( d )
{
eType = DRW::DIMANGULAR3P;
}
DRW_Coord getFirstLine() const { return getPt3(); } /*!< Definition point line 1, code 13, 23 & 33 */
void setFirstLine( const DRW_Coord p ) { setPt3( p ); }
DRW_Coord getSecondLine() const { return getPt4(); } /*!< Definition point line 2, code 14, 24 & 34 */
void setSecondLine( const DRW_Coord p ) { setPt4( p ); }
DRW_Coord getVertexPoint() const { return getPt5(); } /*!< Vertex point, code 15, 25 & 35 */
void SetVertexPoint( const DRW_Coord p ) { setPt5( p ); }
DRW_Coord getDimPoint() const { return getDefPoint(); } /*!< Dimension definition point, code 10, 20 & 30 */
void setDimPoint( const DRW_Coord p ) { setDefPoint( p ); }
};
// ! Class to handle ordinate dimension entity
/*!
* Class to handle ordinate dimension entity
* @author Rallaz
*/
class DRW_DimOrdinate : public DRW_Dimension
{
public:
DRW_DimOrdinate()
{
eType = DRW::DIMORDINATE;
}
DRW_DimOrdinate( const DRW_Dimension& d ) : DRW_Dimension( d )
{
eType = DRW::DIMORDINATE;
}
DRW_Coord getOriginPoint() const { return getDefPoint(); } /*!< Origin definition point, code 10, 20 & 30 */
void setOriginPoint( const DRW_Coord p ) { setDefPoint( p ); }
DRW_Coord getFirstLine() const { return getPt3(); } /*!< Feature location point, code 13, 23 & 33 */
void setFirstLine( const DRW_Coord p ) { setPt3( p ); }
DRW_Coord getSecondLine() const { return getPt4(); } /*!< Leader end point, code 14, 24 & 34 */
void setSecondLine( const DRW_Coord p ) { setPt4( p ); }
};
// ! Class to handle leader entity
/*!
* Class to handle leader entity
* @author Rallaz
*/
class DRW_Leader : public DRW_Entity
{
public:
DRW_Leader()
{
eType = DRW::LEADER;
flag = 3;
hookflag = vertnum = leadertype = 0;
extrusionPoint.x = extrusionPoint.y = 0.0;
arrow = 1;
extrusionPoint.z = 1.0;
}
~DRW_Leader()
{
while( !vertexlist.empty() )
{
vertexlist.pop_back();
}
}
virtual void applyExtrusion() {}
void parseCode( int code, dxfReader* reader );
public:
UTF8STRING style; /*!< Dimension style name, code 3 */
int arrow; /*!< Arrowhead flag, code 71, 0=Disabled; 1=Enabled */
int leadertype; /*!< Leader path type, code 72, 0=Straight line segments; 1=Spline */
int flag; /*!< Leader creation flag, code 73, default 3 */
int hookline; /*!< Hook line direction flag, code 74, default 1 */
int hookflag; /*!< Hook line flag, code 75 */
double textheight; /*!< Text annotation height, code 40 */
double textwidth; /*!< Text annotation width, code 41 */
int vertnum; /*!< Number of vertices, code 76 */
int coloruse; /*!< Color to use if leader's DIMCLRD = BYBLOCK, code 77 */
string handle; /*!< Hard reference to associated annotation, code 340 */
DRW_Coord extrusionPoint; /*!< Normal vector, code 210, 220 & 230 */
DRW_Coord horizdir; /*!< "Horizontal" direction for leader, code 211, 221 & 231 */
DRW_Coord offsetblock; /*!< Offset of last leader vertex from block, code 212, 222 & 232 */
DRW_Coord offsettext; /*!< Offset of last leader vertex from annotation, code 213, 223 & 233 */
std::vector<DRW_Coord*> vertexlist; /*!< vertex points list, code 10, 20 & 30 */
private:
DRW_Coord* vertexpoint; /*!< current control point to add data */
};
// ! Class to handle viewport entity
/*!
* Class to handle viewport entity
* @author Rallaz
*/
class DRW_Viewport : public DRW_Point
{
public:
DRW_Viewport()
{
eType = DRW::VIEWPORT;
vpstatus = 0;
pswidth = 205;
psheight = 156;
centerPX = 128.5;
centerPY = 97.5;
}
virtual void applyExtrusion() {}
void parseCode( int code, dxfReader* reader );
public:
double pswidth; /*!< Width in paper space units, code 40 */
double psheight; /*!< Height in paper space units, code 41 */
int vpstatus; /*!< Viewport status, code 68 */
int vpID; /*!< Viewport ID, code 69 */
double centerPX; /*!< view center piont X, code 12 */
double centerPY; /*!< view center piont Y, code 22 */
};
#endif
// EOF
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#ifndef DRW_INTERFACE_H
#define DRW_INTERFACE_H
#include <string.h>
#include "drw_entities.h"
#include "drw_objects.h"
// #include "dl_extrusion.h"
/**
* Abstract class (interface) for comunicate dxfReader with the application.
* Inherit your class which takes care of the entities in the
* processed DXF file from this interface.
*
* @author Rallaz
*/
class DRW_Interface
{
public:
DRW_Interface()
{
// extrusion = new DL_Extrusion;
}
virtual ~DRW_Interface()
{
// delete extrusion;
}
/** Called when header is parsed. */
virtual void addHeader( const DRW_Header* data ) = 0;
/** Called for every line Type. */
virtual void addLType( const DRW_LType& data ) = 0;
/** Called for every layer. */
virtual void addLayer( const DRW_Layer& data ) = 0;
/** Called for every dim style. */
virtual void addDimStyle( const DRW_Dimstyle& data ) = 0;
/** Called for every VPORT table. */
virtual void addVport( const DRW_Vport& data ) = 0;
/** Called for every text style. */
virtual void addTextStyle( const DRW_Textstyle& data ) = 0;
/**
* Called for every block. Note: all entities added after this
* command go into this block until endBlock() is called.
*
* @see endBlock()
*/
virtual void addBlock( const DRW_Block& data ) = 0;
/**
* In DWG called when the following entities corresponding to a
* block different from the current. Note: all entities added after this
* command go into this block until setBlock() is called already.
*
* int handle are the value of DRW_Block::handleBlock added with addBlock()
*/
virtual void setBlock( const int handle ) = 0;
/** Called to end the current block */
virtual void endBlock() = 0;
/** Called for every point */
virtual void addPoint( const DRW_Point& data ) = 0;
/** Called for every line */
virtual void addLine( const DRW_Line& data ) = 0;
/** Called for every ray */
virtual void addRay( const DRW_Ray& data ) = 0;
/** Called for every xline */
virtual void addXline( const DRW_Xline& data ) = 0;
/** Called for every arc */
virtual void addArc( const DRW_Arc& data ) = 0;
/** Called for every circle */
virtual void addCircle( const DRW_Circle& data ) = 0;
/** Called for every ellipse */
virtual void addEllipse( const DRW_Ellipse& data ) = 0;
/** Called for every lwpolyline */
virtual void addLWPolyline( const DRW_LWPolyline& data ) = 0;
/** Called for every polyline start */
virtual void addPolyline( const DRW_Polyline& data ) = 0;
/** Called for every spline */
virtual void addSpline( const DRW_Spline* data ) = 0;
/** Called for every spline knot value */
virtual void addKnot( const DRW_Entity& data ) = 0;
/** Called for every insert. */
virtual void addInsert( const DRW_Insert& data ) = 0;
/** Called for every trace start */
virtual void addTrace( const DRW_Trace& data ) = 0;
/** Called for every 3dface start */
virtual void add3dFace( const DRW_3Dface& data ) = 0;
/** Called for every solid start */
virtual void addSolid( const DRW_Solid& data ) = 0;
/** Called for every Multi Text entity. */
virtual void addMText( const DRW_MText& data ) = 0;
/** Called for every Text entity. */
virtual void addText( const DRW_Text& data ) = 0;
/**
* Called for every aligned dimension entity.
*/
virtual void addDimAlign( const DRW_DimAligned* data ) = 0;
/**
* Called for every linear or rotated dimension entity.
*/
virtual void addDimLinear( const DRW_DimLinear* data ) = 0;
/**
* Called for every radial dimension entity.
*/
virtual void addDimRadial( const DRW_DimRadial* data ) = 0;
/**
* Called for every diametric dimension entity.
*/
virtual void addDimDiametric( const DRW_DimDiametric* data ) = 0;
/**
* Called for every angular dimension (2 lines version) entity.
*/
virtual void addDimAngular( const DRW_DimAngular* data ) = 0;
/**
* Called for every angular dimension (3 points version) entity.
*/
virtual void addDimAngular3P( const DRW_DimAngular3p* data ) = 0;
/**
* Called for every ordinate dimension entity.
*/
virtual void addDimOrdinate( const DRW_DimOrdinate* data ) = 0;
/**
* Called for every leader start.
*/
virtual void addLeader( const DRW_Leader* data ) = 0;
/**
* Called for every hatch entity.
*/
virtual void addHatch( const DRW_Hatch* data ) = 0;
/**
* Called for every viewport entity.
*/
virtual void addViewport( const DRW_Viewport& data ) = 0;
/**
* Called for every image entity.
*/
virtual void addImage( const DRW_Image* data ) = 0;
/**
* Called for every image definition.
*/
virtual void linkImage( const DRW_ImageDef* data ) = 0;
/**
* Called for every comment in the DXF file (code 999).
*/
virtual void addComment( const char* comment ) = 0;
/** Sets the current attributes for entities. */
/* 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;
// }
virtual void writeHeader( DRW_Header& data ) = 0;
virtual void writeBlocks() = 0;
virtual void writeBlockRecords() = 0;
virtual void writeEntities() = 0;
virtual void writeLTypes() = 0;
virtual void writeLayers() = 0;
virtual void writeTextstyles() = 0;
virtual void writeVports() = 0;
virtual void writeDimstyles() = 0;
protected:
// DL_Attributes attributes;
// DL_Extrusion *extrusion;
};
#endif
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#include <iostream>
#include <math.h>
#include "drw_objects.h"
#include "intern/dxfreader.h"
#include "intern/dxfwriter.h"
// ! Base class for tables entries
/*!
* Base class for tables entries
* @author Rallaz
*/
void DRW_TableEntry::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 5:
handle = reader->getHandleString();
break;
case 330:
handleBlock = reader->getHandleString();
break;
case 2:
name = reader->getUtf8String();
break;
case 70:
flags = reader->getInt32();
break;
default:
break;
}
}
// ! Class to handle dimstyle entries
/*!
* Class to handle ldim style symbol table entries
* @author Rallaz
*/
void DRW_Dimstyle::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 105:
handle = reader->getHandleString();
break;
case 3:
dimpost = reader->getUtf8String();
break;
case 4:
dimapost = reader->getUtf8String();
break;
case 5:
dimblk = reader->getUtf8String();
break;
case 6:
dimblk1 = reader->getUtf8String();
break;
case 7:
dimblk2 = reader->getUtf8String();
break;
case 40:
dimscale = reader->getDouble();
break;
case 41:
dimasz = reader->getDouble();
break;
case 42:
dimexo = reader->getDouble();
break;
case 43:
dimdli = reader->getDouble();
break;
case 44:
dimexe = reader->getDouble();
break;
case 45:
dimrnd = reader->getDouble();
break;
case 46:
dimdle = reader->getDouble();
break;
case 47:
dimtp = reader->getDouble();
break;
case 48:
dimtm = reader->getDouble();
break;
case 140:
dimtxt = reader->getDouble();
break;
case 141:
dimcen = reader->getDouble();
break;
case 142:
dimtsz = reader->getDouble();
break;
case 143:
dimaltf = reader->getDouble();
break;
case 144:
dimlfac = reader->getDouble();
break;
case 145:
dimtvp = reader->getDouble();
break;
case 146:
dimtfac = reader->getDouble();
break;
case 147:
dimgap = reader->getDouble();
break;
case 148:
dimaltrnd = reader->getDouble();
break;
case 71:
dimtol = reader->getInt32();
break;
case 72:
dimlim = reader->getInt32();
break;
case 73:
dimtih = reader->getInt32();
break;
case 74:
dimtoh = reader->getInt32();
break;
case 75:
dimse1 = reader->getInt32();
break;
case 76:
dimse2 = reader->getInt32();
break;
case 77:
dimtad = reader->getInt32();
break;
case 78:
dimzin = reader->getInt32();
break;
case 79:
dimazin = reader->getInt32();
break;
case 170:
dimalt = reader->getInt32();
break;
case 171:
dimaltd = reader->getInt32();
break;
case 172:
dimtofl = reader->getInt32();
break;
case 173:
dimsah = reader->getInt32();
break;
case 174:
dimtix = reader->getInt32();
break;
case 175:
dimsoxd = reader->getInt32();
break;
case 176:
dimclrd = reader->getInt32();
break;
case 177:
dimclre = reader->getInt32();
break;
case 178:
dimclrt = reader->getInt32();
break;
case 179:
dimadec = reader->getInt32();
break;
case 270:
dimunit = reader->getInt32();
break;
case 271:
dimdec = reader->getInt32();
break;
case 272:
dimtdec = reader->getInt32();
break;
case 273:
dimaltu = reader->getInt32();
break;
case 274:
dimalttd = reader->getInt32();
break;
case 275:
dimaunit = reader->getInt32();
break;
case 276:
dimfrac = reader->getInt32();
break;
case 277:
dimlunit = reader->getInt32();
break;
case 278:
dimdsep = reader->getInt32();
break;
case 279:
dimtmove = reader->getInt32();
break;
case 280:
dimjust = reader->getInt32();
break;
case 281:
dimsd1 = reader->getInt32();
break;
case 282:
dimsd2 = reader->getInt32();
break;
case 283:
dimtolj = reader->getInt32();
break;
case 284:
dimtzin = reader->getInt32();
break;
case 285:
dimaltz = reader->getInt32();
break;
case 286:
dimaltttz = reader->getInt32();
break;
case 287:
dimfit = reader->getInt32();
break;
case 288:
dimupt = reader->getInt32();
break;
case 289:
dimatfit = reader->getInt32();
break;
case 340:
dimtxsty = reader->getUtf8String();
break;
case 341:
dimldrblk = reader->getUtf8String();
break;
case 342:
dimblk = reader->getUtf8String();
break;
case 343:
dimblk1 = reader->getUtf8String();
break;
case 344:
dimblk2 = reader->getUtf8String();
break;
default:
DRW_TableEntry::parseCode( code, reader );
break;
}
}
// ! Class to handle line type entries
/*!
* Class to handle line type symbol table entries
* @author Rallaz
*/
void DRW_LType::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 3:
desc = reader->getUtf8String();
break;
case 73:
size = reader->getInt32();
path.reserve( size );
break;
case 40:
length = reader->getDouble();
break;
case 49:
path.push_back( reader->getDouble() );
pathIdx++;
break;
/* case 74:
* haveShape = reader->getInt32();
* break;*/
default:
DRW_TableEntry::parseCode( code, reader );
break;
}
}
// ! Update line type
/*!
* Update the size and length of line type acording to the path
* @author Rallaz
*/
/*TODO: control max length permited */
void DRW_LType::update()
{
double d = 0;
size = path.size();
for( int i = 0; i< size; i++ )
{
d += fabs( path.at( i ) );
}
length = d;
}
// ! Class to handle layer entries
/*!
* Class to handle layer symbol table entries
* @author Rallaz
*/
void DRW_Layer::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 6:
lineType = reader->getUtf8String();
break;
case 62:
color = reader->getInt32();
break;
case 290:
plotF = reader->getBool();
break;
case 370:
lWeight = DRW_LW_Conv::dxfInt2lineWidth( reader->getInt32() );
break;
case 390:
handlePlotS = reader->getString();
break;
case 347:
handlePlotM = reader->getString();
break;
case 420:
color24 = reader->getInt32();
break;
default:
DRW_TableEntry::parseCode( code, reader );
break;
}
}
// ! Class to handle text style entries
/*!
* Class to handle text style symbol table entries
* @author Rallaz
*/
void DRW_Textstyle::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 3:
font = reader->getUtf8String();
break;
case 4:
bigFont = reader->getUtf8String();
break;
case 40:
height = reader->getDouble();
break;
case 41:
width = reader->getDouble();
break;
case 50:
oblique = reader->getDouble();
break;
case 42:
lastHeight = reader->getDouble();
break;
case 71:
genFlag = reader->getInt32();
break;
case 1071:
fontFamily = reader->getInt32();
break;
default:
DRW_TableEntry::parseCode( code, reader );
break;
}
}
// ! Class to handle vport entries
/*!
* Class to handle vport symbol table entries
* @author Rallaz
*/
void DRW_Vport::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 10:
lowerLeft.x = reader->getDouble();
break;
case 20:
lowerLeft.y = reader->getDouble();
break;
case 11:
UpperRight.x = reader->getDouble();
break;
case 21:
UpperRight.y = reader->getDouble();
break;
case 12:
center.x = reader->getDouble();
break;
case 22:
center.y = reader->getDouble();
break;
case 13:
snapBase.x = reader->getDouble();
break;
case 23:
snapBase.y = reader->getDouble();
break;
case 14:
snapSpacing.x = reader->getDouble();
break;
case 24:
snapSpacing.y = reader->getDouble();
break;
case 15:
gridSpacing.x = reader->getDouble();
break;
case 25:
gridSpacing.y = reader->getDouble();
break;
case 16:
viewDir.x = reader->getDouble();
break;
case 26:
viewDir.y = reader->getDouble();
break;
case 36:
viewDir.z = reader->getDouble();
break;
case 17:
viewTarget.x = reader->getDouble();
break;
case 27:
viewTarget.y = reader->getDouble();
break;
case 37:
viewTarget.z = reader->getDouble();
break;
case 40:
height = reader->getDouble();
break;
case 41:
ratio = reader->getDouble();
break;
case 42:
lensHeight = reader->getDouble();
break;
case 43:
frontClip = reader->getDouble();
break;
case 44:
backClip = reader->getDouble();
break;
case 50:
snapAngle = reader->getDouble();
break;
case 51:
twistAngle = reader->getDouble();
break;
case 71:
viewMode = reader->getInt32();
break;
case 72:
circleZoom = reader->getInt32();
break;
case 73:
fastZoom = reader->getInt32();
break;
case 74:
ucsIcon = reader->getInt32();
break;
case 75:
snap = reader->getInt32();
break;
case 76:
grid = reader->getInt32();
break;
case 77:
snapStyle = reader->getInt32();
break;
case 78:
snapIsopair = reader->getInt32();
break;
default:
DRW_TableEntry::parseCode( code, reader );
break;
}
}
void DRW_ImageDef::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 1:
name = reader->getUtf8String();
break;
case 5:
handle = reader->getString();
break;
case 10:
u = reader->getDouble();
break;
case 20:
v = reader->getDouble();
break;
case 11:
up = reader->getDouble();
break;
case 12:
vp = reader->getDouble();
break;
case 21:
vp = reader->getDouble();
break;
case 280:
loaded = reader->getInt32();
break;
case 281:
resolution = reader->getInt32();
break;
default:
break;
}
}
void DRW_Header::addComment( string c )
{
if( !comments.empty() )
comments += '\n';
comments += c;
}
void DRW_Header::parseCode( int code, dxfReader* reader )
{
switch( code )
{
case 9:
curr = new DRW_Variant();
name = reader->getString();
if( version < DRW::AC1015 && name == "$DIMUNIT" )
name = "$DIMLUNIT";
vars[name] = curr;
break;
case 1:
curr->addString( reader->getUtf8String() );
if( name =="$ACADVER" )
{
reader->setVersion( curr->content.s );
version = reader->getVersion();
}
curr->code = code;
break;
case 2:
curr->addString( reader->getUtf8String() );
curr->code = code;
break;
case 3:
curr->addString( reader->getUtf8String() );
if( name =="$DWGCODEPAGE" )
{
reader->setCodePage( curr->content.s );
curr->addString( reader->getCodePage() );
}
curr->code = code;
break;
case 6:
curr->addString( reader->getUtf8String() );
curr->code = code;
break;
case 7:
curr->addString( reader->getUtf8String() );
curr->code = code;
break;
case 8:
curr->addString( reader->getUtf8String() );
curr->code = code;
break;
case 10:
curr->addCoord( new DRW_Coord() );
curr->setCoordX( reader->getDouble() );
curr->code = code;
break;
case 20:
curr->setCoordY( reader->getDouble() );
break;
case 30:
curr->setCoordZ( reader->getDouble() );
curr->code = code;
break;
case 40:
curr->addDouble( reader->getDouble() );
curr->code = code;
break;
case 50:
curr->addDouble( reader->getDouble() );
curr->code = code;
break;
case 62:
curr->addInt( reader->getInt32() );
curr->code = code;
break;
case 70:
curr->addInt( reader->getInt32() );
curr->code = code;
break;
case 280:
curr->addInt( reader->getInt32() );
curr->code = code;
break;
case 290:
curr->addInt( reader->getInt32() );
curr->code = code;
break;
case 370:
curr->addInt( reader->getInt32() );
curr->code = code;
break;
case 380:
curr->addInt( reader->getInt32() );
curr->code = code;
break;
case 390:
curr->addString( reader->getUtf8String() );
curr->code = code;
break;
default:
break;
}
}
void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
{
/*RLZ: TODO complete all vars to AC1024*/
double varDouble;
int varInt;
std::string varStr;
DRW_Coord varCoord;
writer->writeString( 2, "HEADER" );
writer->writeString( 9, "$ACADVER" );
switch( ver )
{
case DRW::AC1006: // unsupported version acad 10
case DRW::AC1009: // acad 11 & 12
varStr = "AC1009";
break;
case DRW::AC1012: // unsupported version acad 13
case DRW::AC1014: // acad 14
varStr = "AC1014";
break;
case DRW::AC1015: // acad 2000
varStr = "AC1015";
break;
case DRW::AC1018: // acad 2004
varStr = "AC1018";
break;
/* case DRW::AC1021: //acad 2007
* varStr = "AC1021";
* break;*/
case DRW::AC1024: // acad 2010
varStr = "AC1024";
break;
default: // acad 2007 default version
varStr = "AC1021";
break;
}
writer->writeString( 1, varStr );
writer->setVersion( &varStr );
if( ver > DRW::AC1012 )
{
writer->writeString( 9, "$HANDSEED" );
// RLZ dxfHex(5, 0xFFFF);
writer->writeString( 5, "20000" );
}
if( !getStr( "$DWGCODEPAGE", &varStr ) )
{
varStr = "ANSI_1252";
}
writer->writeString( 9, "$DWGCODEPAGE" );
writer->setCodePage( &varStr );
writer->writeString( 3, writer->getCodePage() );
writer->writeString( 9, "$INSBASE" );
if( getCoord( "$INSBASE", &varCoord ) )
{
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
writer->writeDouble( 30, varCoord.z );
}
else
{
writer->writeDouble( 10, 0.0 );
writer->writeDouble( 20, 0.0 );
writer->writeDouble( 30, 0.0 );
}
writer->writeString( 9, "$EXTMIN" );
if( getCoord( "$EXTMIN", &varCoord ) )
{
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
writer->writeDouble( 30, varCoord.z );
}
else
{
writer->writeDouble( 10, 1.0000000000000000E+020 );
writer->writeDouble( 20, 1.0000000000000000E+020 );
writer->writeDouble( 30, 1.0000000000000000E+020 );
}
writer->writeString( 9, "$EXTMAX" );
if( getCoord( "$EXTMAX", &varCoord ) )
{
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
writer->writeDouble( 30, varCoord.z );
}
else
{
writer->writeDouble( 10, -1.0000000000000000E+020 );
writer->writeDouble( 20, -1.0000000000000000E+020 );
writer->writeDouble( 30, -1.0000000000000000E+020 );
}
writer->writeString( 9, "$LIMMIN" );
if( getCoord( "$LIMMIN", &varCoord ) )
{
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
}
else
{
writer->writeDouble( 10, 0.0 );
writer->writeDouble( 20, 0.0 );
}
writer->writeString( 9, "$LIMMAX" );
if( getCoord( "$LIMMAX", &varCoord ) )
{
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
}
else
{
writer->writeDouble( 10, 420.0 );
writer->writeDouble( 20, 297.0 );
}
writer->writeString( 9, "$ORTHOMODE" );
if( getInt( "$ORTHOMODE", &varInt ) )
writer->writeInt16( 70, varInt );
else
writer->writeInt16( 70, 0 );
writer->writeString( 9, "$LTSCALE" );
if( getDouble( "$LTSCALE", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 1.0 );
writer->writeString( 9, "$TEXTSTYLE" );
if( getStr( "$TEXTSTYLE", &varStr ) )
if( ver == DRW::AC1009 )
writer->writeUtf8Caps( 7, varStr );
else
writer->writeUtf8String( 7, varStr );
else
writer->writeString( 7, "STANDARD" );
writer->writeString( 9, "$DIMASZ" );
if( getDouble( "$DIMASZ", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 2.5 );
writer->writeString( 9, "$DIMSCALE" );
if( getDouble( "$DIMSCALE", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 1.0 );
writer->writeString( 9, "$DIMEXO" );
if( getDouble( "$DIMEXO", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 0.625 );
writer->writeString( 9, "$DIMEXE" );
if( getDouble( "$DIMEXE", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 1.25 );
writer->writeString( 9, "$DIMTXT" );
if( getDouble( "$DIMTXT", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 2.5 );
writer->writeString( 9, "$DIMTSZ" );
if( getDouble( "$DIMTSZ", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 0.0 );
if( ver > DRW::AC1009 )
{
writer->writeString( 9, "$DIMAUNIT" );
if( getInt( "$DIMAUNIT", &varInt ) )
writer->writeInt16( 70, varInt );
else
writer->writeInt16( 70, 0 );
writer->writeString( 9, "$DIMADEC" );
if( getInt( "$DIMADEC", &varInt ) )
writer->writeInt16( 70, varInt );
else
writer->writeInt16( 70, 0 );
}
// verify if exist "$DIMLUNIT" or obsolete "$DIMUNIT" (pre v2000)
if( !getInt( "$DIMLUNIT", &varInt ) )
{
if( !getInt( "$DIMUNIT", &varInt ) )
varInt = 2;
}
// verify valid values from 1 to 6
if( varInt<1 || varInt>6 )
varInt = 2;
if( ver > DRW::AC1014 )
{
writer->writeString( 9, "$DIMLUNIT" );
writer->writeInt16( 70, varInt );
}
else
{
writer->writeString( 9, "$DIMUNIT" );
writer->writeInt16( 70, varInt );
}
writer->writeString( 9, "$DIMSTYLE" );
if( getStr( "$DIMSTYLE", &varStr ) )
if( ver == DRW::AC1009 )
writer->writeUtf8Caps( 2, varStr );
else
writer->writeUtf8String( 2, varStr );
else
writer->writeString( 2, "STANDARD" );
writer->writeString( 9, "$DIMGAP" );
if( getDouble( "$DIMGAP", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 0.625 );
writer->writeString( 9, "$DIMTIH" );
if( getInt( "$DIMTIH", &varInt ) )
writer->writeInt16( 70, varInt );
else
writer->writeInt16( 70, 0 );
writer->writeString( 9, "$LUNITS" );
if( getInt( "$LUNITS", &varInt ) )
writer->writeInt16( 70, varInt );
else
writer->writeInt16( 70, 2 );
writer->writeString( 9, "$LUPREC" );
if( getInt( "$LUPREC", &varInt ) )
writer->writeInt16( 70, varInt );
else
writer->writeInt16( 70, 4 );
writer->writeString( 9, "$AUNITS" );
if( getInt( "$AUNITS", &varInt ) )
writer->writeInt16( 70, varInt );
else
writer->writeInt16( 70, 0 );
writer->writeString( 9, "$AUPREC" );
if( getInt( "$AUPREC", &varInt ) )
writer->writeInt16( 70, varInt );
else
writer->writeInt16( 70, 2 );
if( ver > DRW::AC1009 )
{
writer->writeString( 9, "$SPLINESEGS" );
if( getInt( "$SPLINESEGS", &varInt ) )
{
writer->writeInt16( 70, varInt );
}
else
writer->writeInt16( 70, 8 );
}
/* RLZ: moved to active VPORT, but can write in header if present*/
if( getInt( "$GRIDMODE", &varInt ) )
{
writer->writeString( 9, "$GRIDMODE" );
writer->writeInt16( 70, varInt );
}
if( getInt( "$SNAPSTYLE", &varInt ) )
{
writer->writeString( 9, "$SNAPSTYLE" );
writer->writeInt16( 70, varInt );
}
if( getCoord( "$GRIDUNIT", &varCoord ) )
{
writer->writeString( 9, "$GRIDUNIT" );
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
}
if( getCoord( "$VIEWCTR", &varCoord ) )
{
writer->writeString( 9, "$VIEWCTR" );
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
}
/* RLZ: moved to active VPORT, but can write in header if present*/
if( ver > DRW::AC1009 )
{
writer->writeString( 9, "$PINSBASE" );
if( getCoord( "$PINSBASE", &varCoord ) )
{
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
writer->writeDouble( 30, varCoord.z );
}
else
{
writer->writeDouble( 10, 0.0 );
writer->writeDouble( 20, 0.0 );
writer->writeDouble( 30, 0.0 );
}
}
writer->writeString( 9, "$PLIMMIN" );
if( getCoord( "$PLIMMIN", &varCoord ) )
{
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
}
else
{
writer->writeDouble( 10, 0.0 );
writer->writeDouble( 20, 0.0 );
}
writer->writeString( 9, "$PLIMMAX" );
if( getCoord( "$PLIMMAX", &varCoord ) )
{
writer->writeDouble( 10, varCoord.x );
writer->writeDouble( 20, varCoord.y );
}
else
{
writer->writeDouble( 10, 297.0 );
writer->writeDouble( 20, 210.0 );
}
if( ver > DRW::AC1014 )
{
writer->writeString( 9, "$INSUNITS" );
if( getInt( "$INSUNITS", &varInt ) )
writer->writeInt16( 70, varInt );
else
writer->writeInt16( 70, 0 );
}
if( ver > DRW::AC1009 )
{
writer->writeString( 9, "$PSVPSCALE" );
if( getDouble( "$PSVPSCALE", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 0.0 );
}
std::map<std::string, DRW_Variant*>::const_iterator it;
for( it = vars.begin(); it != vars.end(); it++ )
{
std::cerr << (*it).first << std::endl;
}
}
bool DRW_Header::getDouble( string key, double* varDouble )
{
bool result = false;
std::map<std::string, DRW_Variant*>::iterator it;
it = vars.find( key );
if( it != vars.end() )
{
DRW_Variant* var = (*it).second;
if( var->type == DRW_Variant::DOUBLE )
{
*varDouble = var->content.d;
result = true;
}
vars.erase( it );
}
return result;
}
bool DRW_Header::getInt( string key, int* varInt )
{
bool result = false;
std::map<std::string, DRW_Variant*>::iterator it;
it = vars.find( key );
if( it != vars.end() )
{
DRW_Variant* var = (*it).second;
if( var->type == DRW_Variant::INTEGER )
{
*varInt = var->content.i;
result = true;
}
vars.erase( it );
}
return result;
}
bool DRW_Header::getStr( string key, std::string* varStr )
{
bool result = false;
std::map<std::string, DRW_Variant*>::iterator it;
it = vars.find( key );
if( it != vars.end() )
{
DRW_Variant* var = (*it).second;
if( var->type == DRW_Variant::STRING )
{
*varStr = *var->content.s;
result = true;
}
vars.erase( it );
}
return result;
}
bool DRW_Header::getCoord( string key, DRW_Coord* varCoord )
{
bool result = false;
std::map<std::string, DRW_Variant*>::iterator it;
it = vars.find( key );
if( it != vars.end() )
{
DRW_Variant* var = (*it).second;
if( var->type == DRW_Variant::COORD )
{
*varCoord = *var->content.v;
result = true;
}
vars.erase( it );
}
return result;
}
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#ifndef DRW_OBJECTS_H
#define DRW_OBJECTS_H
#include <string>
#include <vector>
#include <map>
#include "drw_base.h"
class dxfReader;
class dxfWriter;
using std::string;
namespace DRW {
// ! Table entries type.
enum TTYPE {
UNKNOWNT,
LTYPE,
LAYER,
STYLE,
DIMSTYLE,
VPORT,
BLOCK_RECORD
};
}
// ! Base class for tables entries
/*!
* Base class for tables entries
* @author Rallaz
*/
class DRW_TableEntry
{
public:
// initializes default values
DRW_TableEntry()
{
tType = DRW::UNKNOWNT;
flags = 0;
}
virtual ~DRW_TableEntry() {}
protected:
void parseCode( int code, dxfReader* reader );
public:
enum DRW::TTYPE tType; /*!< enum: entity type, code 0 */
int handle; /*!< entity identifier, code 5 */
int handleBlock; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */
UTF8STRING name; /*!< entry name, code 2 */
int flags; /*!< Flags relevant to entry, code 70 */
};
// ! Class to handle dimstyle entries
/*!
* Class to handle dim style symbol table entries
* @author Rallaz
*/
class DRW_Dimstyle : public DRW_TableEntry
{
public:
DRW_Dimstyle() { reset(); }
void reset()
{
tType = DRW::DIMSTYLE;
dimasz = dimtxt = dimexe = 0.18;
dimexo = 0.0625;
dimgap = dimcen = 0.09;
dimtxsty = "Standard";
dimscale = dimlfac = dimtfac = 1.0;
dimdli = 0.38;
dimrnd = dimdle = dimtp = dimtm = dimtsz = dimtvp = 0.0;
dimaltf = 25.4;
dimtol = dimlim = dimse1 = dimse2 = dimtad = dimzin = 0;
dimtoh = dimtolj = 1;
dimalt = dimtofl = dimsah = dimtix = dimsoxd = 0;
dimaltd = dimunit = dimaltu = dimalttd = dimlunit = 2;
dimclrd = dimclre = dimclrt = dimjust = dimupt = 0;
dimazin = dimaltz = dimaltttz = dimtzin = dimfrac = 0;
dimtih = dimadec = dimaunit = dimsd1 = dimsd2 = dimtmove = 0;
dimaltrnd = 0.0;
dimdec = dimtdec = 4;
dimfit = dimatfit = 3;
dimdsep = '.';
dimlwd = dimlwe = -2;
}
void parseCode( int code, dxfReader* reader );
public:
// V12
UTF8STRING dimpost; /*!< code 3 */
UTF8STRING dimapost; /*!< code 4 */
/* handle are code 105 */
UTF8STRING dimblk; /*!< code 5, code 342 V2000+ */
UTF8STRING dimblk1; /*!< code 6, code 343 V2000+ */
UTF8STRING dimblk2; /*!< code 7, code 344 V2000+ */
double dimscale; /*!< code 40 */
double dimasz; /*!< code 41 */
double dimexo; /*!< code 42 */
double dimdli; /*!< code 43 */
double dimexe; /*!< code 44 */
double dimrnd; /*!< code 45 */
double dimdle; /*!< code 46 */
double dimtp; /*!< code 47 */
double dimtm; /*!< code 48 */
double dimtxt; /*!< code 140 */
double dimcen; /*!< code 141 */
double dimtsz; /*!< code 142 */
double dimaltf; /*!< code 143 */
double dimlfac; /*!< code 144 */
double dimtvp; /*!< code 145 */
double dimtfac; /*!< code 146 */
double dimgap; /*!< code 147 */
double dimaltrnd; /*!< code 148 V2000+ */
int dimtol; /*!< code 71 */
int dimlim; /*!< code 72 */
int dimtih; /*!< code 73 */
int dimtoh; /*!< code 74 */
int dimse1; /*!< code 75 */
int dimse2; /*!< code 76 */
int dimtad; /*!< code 77 */
int dimzin; /*!< code 78 */
int dimazin; /*!< code 79 V2000+ */
int dimalt; /*!< code 170 */
int dimaltd; /*!< code 171 */
int dimtofl; /*!< code 172 */
int dimsah; /*!< code 173 */
int dimtix; /*!< code 174 */
int dimsoxd; /*!< code 175 */
int dimclrd; /*!< code 176 */
int dimclre; /*!< code 177 */
int dimclrt; /*!< code 178 */
int dimadec; /*!< code 179 V2000+ */
int dimunit; /*!< code 270 R13+ (obsolete 2000+, use dimlunit & dimfrac) */
int dimdec; /*!< code 271 R13+ */
int dimtdec; /*!< code 272 R13+ */
int dimaltu; /*!< code 273 R13+ */
int dimalttd; /*!< code 274 R13+ */
int dimaunit; /*!< code 275 R13+ */
int dimfrac; /*!< code 276 V2000+ */
int dimlunit; /*!< code 277 V2000+ */
int dimdsep; /*!< code 278 V2000+ */
int dimtmove; /*!< code 279 V2000+ */
int dimjust; /*!< code 280 R13+ */
int dimsd1; /*!< code 281 R13+ */
int dimsd2; /*!< code 282 R13+ */
int dimtolj; /*!< code 283 R13+ */
int dimtzin; /*!< code 284 R13+ */
int dimaltz; /*!< code 285 R13+ */
int dimaltttz; /*!< code 286 R13+ */
int dimfit; /*!< code 287 R13+ (obsolete 2000+, use dimatfit & dimtmove)*/
int dimupt; /*!< code 288 R13+ */
int dimatfit; /*!< code 289 V2000+ */
UTF8STRING dimtxsty; /*!< code 340 R13+ */
UTF8STRING dimldrblk; /*!< code 341 V2000+ */
int dimlwd; /*!< code 371 V2000+ */
int dimlwe; /*!< code 372 V2000+ */
};
// ! Class to handle line type entries
/*!
* Class to handle line type symbol table entries
* @author Rallaz
*/
/*TODO: handle complex lineType*/
class DRW_LType : public DRW_TableEntry
{
public:
DRW_LType() { reset(); }
void reset()
{
tType = DRW::LTYPE;
desc = "";
size = 0;
length = 0.0;
pathIdx = 0;
/* color = 256; // default BYLAYER (256)
* plotF = true; // default TRUE (plot yes)
* lWeight = -1; // default BYLAYER (-1)*/
// align = 65; //always 65
}
void parseCode( int code, dxfReader* reader );
void update();
public:
UTF8STRING desc; /*!< descriptive string, code 3 */
// int align; /*!< align code, always 65 ('A') code 72 */
int size; /*!< element number, code 73 */
double length; /*!< total length of pattern, code 40 */
// int haveShape; /*!< complex linetype type, code 74 */
std::vector<double> path; /*!< trace, point or space length sequence, code 49 */
private:
int pathIdx;
};
// ! Class to handle layer entries
/*!
* Class to handle layer symbol table entries
* @author Rallaz
*/
class DRW_Layer : public DRW_TableEntry
{
public:
DRW_Layer() { reset(); }
void reset()
{
tType = DRW::LAYER;
lineType = "CONTINUOUS";
color = 7; // default BYLAYER (256)
plotF = true; // default TRUE (plot yes)
lWeight = DRW_LW_Conv::widthDefault; // default BYDEFAULT (dxf -3, dwg 31)
color24 = -1; // default -1 not set
}
void parseCode( int code, dxfReader* reader );
public:
UTF8STRING lineType; /*!< line type, code 6 */
int color; /*!< layer color, code 62 */
int color24; /*!< 24-bit color, code 420 */
bool plotF; /*!< Plot flag, code 290 */
enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */
string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */
string handlePlotM; /*!< Hard-pointer ID/handle of materialstyle, code 347 */
};
// ! Class to handle text style entries
/*!
* Class to handle text style symbol table entries
* @author Rallaz
*/
class DRW_Textstyle : public DRW_TableEntry
{
public:
DRW_Textstyle() { reset(); }
void reset()
{
tType = DRW::STYLE;
height = oblique = 0.0;
width = lastHeight = 1.0;
font = "txt";
genFlag = 0; // 2= X mirror, 4= Y mirror
fontFamily = 0;
}
void parseCode( int code, dxfReader* reader );
public:
double height; /*!< Fixed text height (0 not set), code 40 */
double width; /*!< Width factor, code 41 */
double oblique; /*!< Oblique angle, code 50 */
int genFlag; /*!< Text generation flags, code 71 */
double lastHeight; /*!< Last height used, code 42 */
UTF8STRING font; /*!< primary font file name, code 3 */
UTF8STRING bigFont; /*!< bigfont file name or blank if none, code 4 */
int fontFamily; /*!< ttf font family, italic and bold flags, code 1071 */
};
// ! Class to handle vport entries
/*!
* Class to handle vport symbol table entries
* @author Rallaz
*/
class DRW_Vport : public DRW_TableEntry
{
public:
DRW_Vport() { reset(); }
void reset()
{
UpperRight.x = UpperRight.y = 1.0;
snapSpacing.x = snapSpacing.y = 10.0;
gridSpacing = snapSpacing;
center.x = 0.651828;
center.y = -0.16;
viewDir.z = 1;
height = 5.13732;
ratio = 2.4426877;
lensHeight = 50;
frontClip = backClip = snapAngle = twistAngle = 0.0;
viewMode = snap = grid = snapStyle = snapIsopair = 0;
fastZoom = 1;
circleZoom = 100;
ucsIcon = 3;
gridBehavior = 7;
}
void parseCode( int code, dxfReader* reader );
public:
DRW_Coord lowerLeft; /*!< Lower left corner, code 10 & 20 */
DRW_Coord UpperRight; /*!< Upper right corner, code 11 & 21 */
DRW_Coord center; /*!< center point in WCS, code 12 & 22 */
DRW_Coord snapBase; /*!< snap base point in DCS, code 13 & 23 */
DRW_Coord snapSpacing; /*!< snap Spacing, code 14 & 24 */
DRW_Coord gridSpacing; /*!< grid Spacing, code 15 & 25 */
DRW_Coord viewDir; /*!< view direction from target point, code 16, 26 & 36 */
DRW_Coord viewTarget; /*!< view target point, code 17, 27 & 37 */
double height; /*!< view height, code 40 */
double ratio; /*!< viewport aspect ratio, code 41 */
double lensHeight; /*!< lens height, code 42 */
double frontClip; /*!< front clipping plane, code 43 */
double backClip; /*!< back clipping plane, code 44 */
double snapAngle; /*!< snap rotation angle, code 50 */
double twistAngle; /*!< view twist angle, code 51 */
int viewMode; /*!< view mode, code 71 */
int circleZoom; /*!< circle zoom percent, code 72 */
int fastZoom; /*!< fast zoom setting, code 73 */
int ucsIcon; /*!< UCSICON setting, code 74 */
int snap; /*!< snap on/off, code 75 */
int grid; /*!< grid on/off, code 76 */
int snapStyle; /*!< snap style, code 77 */
int snapIsopair; /*!< snap isopair, code 78 */
int gridBehavior; /*!< grid behavior, code 60, undocummented */
/** code 60, bit coded possible value are
* bit 1 (1) show out of limits
* bit 2 (2) adaptive grid
* bit 3 (4) allow subdivision
* bit 4 (8) follow dinamic SCP
**/
};
// ! Class to handle imagedef entries
/*!
* Class to handle image definitions object entries
* @author Rallaz
*/
class DRW_ImageDef
{
public:
DRW_ImageDef()
{
version = 0;
}
void parseCode( int code, dxfReader* reader );
public:
string handle; /*!< entity identifier, code 5 */
UTF8STRING name; /*!< File name of image, code 1 */
int version; /*!< class version, code 90, 0=R14 version */
double u; /*!< image size in pixels U value, code 10 */
double v; /*!< image size in pixels V value, code 20 */
double up; /*!< default size of one pixel U value, code 11 */
double vp; /*!< default size of one pixel V value, code 12 really is 21*/
int loaded; /*!< image is loaded flag, code 280, 0=unloaded, 1=loaded */
int resolution; /*!< resolution units, code 281, 0=no, 2=centimeters, 5=inch */
std::map<string, string> reactors;
};
// ! Class to handle header entries
/*!
* Class to handle layer symbol table entries
* @author Rallaz
*/
class DRW_Header
{
public:
DRW_Header()
{
}
~DRW_Header()
{
vars.clear();
}
void parseCode( int code, dxfReader* reader );
void write( dxfWriter* writer, DRW::Version ver );
void addComment( string c );
string getComments() const { return comments; }
private:
bool getDouble( string key, double* varDouble );
bool getInt( string key, int* varInt );
bool getStr( string key, string* varStr );
bool getCoord( string key, DRW_Coord* varStr );
public:
std::map<string, DRW_Variant*> vars;
private:
string comments;
string name;
DRW_Variant* curr;
int version; // to use on read
};
namespace DRW {
// Extended color palette:
// The first entry is only for direct indexing starting with [1]
// Color 1 is red (1,0,0)
const unsigned char dxfColors[][3] =
{
{ 0, 0, 0 }, // unused
{ 255, 0, 0 }, // 1 red
{ 255, 255, 0 }, // 2 yellow
{ 0, 255, 0 }, // 3 green
{ 0, 255, 255 }, // 4 cyan
{ 0, 0, 255 }, // 5 blue
{ 255, 0, 255 }, // 6 magenta
{ 0, 0, 0 }, // 7 black or white
{ 128, 128, 128 }, // 8 50% gray
{ 192, 192, 192 }, // 9 75% gray
{ 255, 0, 0 }, // 10
{ 255, 127, 127 },
{ 204, 0, 0 },
{ 204, 102, 102 },
{ 153, 0, 0 },
{ 153, 76, 76 }, // 15
{ 127, 0, 0 },
{ 127, 63, 63 },
{ 76, 0, 0 },
{ 76, 38, 38 },
{ 255, 63, 0 }, // 20
{ 255, 159, 127 },
{ 204, 51, 0 },
{ 204, 127, 102 },
{ 153, 38, 0 },
{ 153, 95, 76 }, // 25
{ 127, 31, 0 },
{ 127, 79, 63 },
{ 76, 19, 0 },
{ 76, 47, 38 },
{ 255, 127, 0 }, // 30
{ 255, 191, 127 },
{ 204, 102, 0 },
{ 204, 153, 102 },
{ 153, 76, 0 },
{ 153, 114, 76 }, // 35
{ 127, 63, 0 },
{ 127, 95, 63 },
{ 76, 38, 0 },
{ 76, 57, 38 },
{ 255, 191, 0 }, // 40
{ 255, 223, 127 },
{ 204, 153, 0 },
{ 204, 178, 102 },
{ 153, 114, 0 },
{ 153, 133, 76 }, // 45
{ 127, 95, 0 },
{ 127, 111, 63 },
{ 76, 57, 0 },
{ 76, 66, 38 },
{ 255, 255, 0 }, // 50
{ 255, 255, 127 },
{ 204, 204, 0 },
{ 204, 204, 102 },
{ 153, 153, 0 },
{ 153, 153, 76 }, // 55
{ 127, 127, 0 },
{ 127, 127, 63 },
{ 76, 76, 0 },
{ 76, 76, 38 },
{ 191, 255, 0 }, // 60
{ 223, 255, 127 },
{ 153, 204, 0 },
{ 178, 204, 102 },
{ 114, 153, 0 },
{ 133, 153, 76 }, // 65
{ 95, 127, 0 },
{ 111, 127, 63 },
{ 57, 76, 0 },
{ 66, 76, 38 },
{ 127, 255, 0 }, // 70
{ 191, 255, 127 },
{ 102, 204, 0 },
{ 153, 204, 102 },
{ 76, 153, 0 },
{ 114, 153, 76 }, // 75
{ 63, 127, 0 },
{ 95, 127, 63 },
{ 38, 76, 0 },
{ 57, 76, 38 },
{ 63, 255, 0 }, // 80
{ 159, 255, 127 },
{ 51, 204, 0 },
{ 127, 204, 102 },
{ 38, 153, 0 },
{ 95, 153, 76 }, // 85
{ 31, 127, 0 },
{ 79, 127, 63 },
{ 19, 76, 0 },
{ 47, 76, 38 },
{ 0, 255, 0 }, // 90
{ 127, 255, 127 },
{ 0, 204, 0 },
{ 102, 204, 102 },
{ 0, 153, 0 },
{ 76, 153, 76 }, // 95
{ 0, 127, 0 },
{ 63, 127, 63 },
{ 0, 76, 0 },
{ 38, 76, 38 },
{ 0, 255, 63 }, // 100
{ 127, 255, 159 },
{ 0, 204, 51 },
{ 102, 204, 127 },
{ 0, 153, 38 },
{ 76, 153, 95 }, // 105
{ 0, 127, 31 },
{ 63, 127, 79 },
{ 0, 76, 19 },
{ 38, 76, 47 },
{ 0, 255, 127 }, // 110
{ 127, 255, 191 },
{ 0, 204, 102 },
{ 102, 204, 153 },
{ 0, 153, 76 },
{ 76, 153, 114 }, // 115
{ 0, 127, 63 },
{ 63, 127, 95 },
{ 0, 76, 38 },
{ 38, 76, 57 },
{ 0, 255, 191 }, // 120
{ 127, 255, 223 },
{ 0, 204, 153 },
{ 102, 204, 178 },
{ 0, 153, 114 },
{ 76, 153, 133 }, // 125
{ 0, 127, 95 },
{ 63, 127, 111 },
{ 0, 76, 57 },
{ 38, 76, 66 },
{ 0, 255, 255 }, // 130
{ 127, 255, 255 },
{ 0, 204, 204 },
{ 102, 204, 204 },
{ 0, 153, 153 },
{ 76, 153, 153 }, // 135
{ 0, 127, 127 },
{ 63, 127, 127 },
{ 0, 76, 76 },
{ 38, 76, 76 },
{ 0, 191, 255 }, // 140
{ 127, 223, 255 },
{ 0, 153, 204 },
{ 102, 178, 204 },
{ 0, 114, 153 },
{ 76, 133, 153 }, // 145
{ 0, 95, 127 },
{ 63, 111, 127 },
{ 0, 57, 76 },
{ 38, 66, 76 },
{ 0, 127, 255 }, // 150
{ 127, 191, 255 },
{ 0, 102, 204 },
{ 102, 153, 204 },
{ 0, 76, 153 },
{ 76, 114, 153 }, // 155
{ 0, 63, 127 },
{ 63, 95, 127 },
{ 0, 38, 76 },
{ 38, 57, 76 },
{ 0, 66, 255 }, // 160
{ 127, 159, 255 },
{ 0, 51, 204 },
{ 102, 127, 204 },
{ 0, 38, 153 },
{ 76, 95, 153 }, // 165
{ 0, 31, 127 },
{ 63, 79, 127 },
{ 0, 19, 76 },
{ 38, 47, 76 },
{ 0, 0, 255 }, // 170
{ 127, 127, 255 },
{ 0, 0, 204 },
{ 102, 102, 204 },
{ 0, 0, 153 },
{ 76, 76, 153 }, // 175
{ 0, 0, 127 },
{ 63, 63, 127 },
{ 0, 0, 76 },
{ 38, 38, 76 },
{ 63, 0, 255 }, // 180
{ 159, 127, 255 },
{ 50, 0, 204 },
{ 127, 102, 204 },
{ 38, 0, 153 },
{ 95, 76, 153 }, // 185
{ 31, 0, 127 },
{ 79, 63, 127 },
{ 19, 0, 76 },
{ 47, 38, 76 },
{ 127, 0, 255 }, // 190
{ 191, 127, 255 },
{ 102, 0, 204 },
{ 153, 102, 204 },
{ 76, 0, 153 },
{ 114, 76, 153 }, // 195
{ 63, 0, 127 },
{ 95, 63, 127 },
{ 38, 0, 76 },
{ 57, 38, 76 },
{ 191, 0, 255 }, // 200
{ 223, 127, 255 },
{ 153, 0, 204 },
{ 178, 102, 204 },
{ 114, 0, 153 },
{ 133, 76, 153 }, // 205
{ 95, 0, 127 },
{ 111, 63, 127 },
{ 57, 0, 76 },
{ 66, 38, 76 },
{ 255, 0, 255 }, // 210
{ 255, 127, 255 },
{ 204, 0, 204 },
{ 204, 102, 204 },
{ 153, 0, 153 },
{ 153, 76, 153 }, // 215
{ 127, 0, 127 },
{ 127, 63, 127 },
{ 76, 0, 76 },
{ 76, 38, 76 },
{ 255, 0, 191 }, // 220
{ 255, 127, 223 },
{ 204, 0, 153 },
{ 204, 102, 178 },
{ 153, 0, 114 },
{ 153, 76, 133 }, // 225
{ 127, 0, 95 },
{ 127, 63, 11 },
{ 76, 0, 57 },
{ 76, 38, 66 },
{ 255, 0, 127 }, // 230
{ 255, 127, 191 },
{ 204, 0, 102 },
{ 204, 102, 153 },
{ 153, 0, 76 },
{ 153, 76, 114 }, // 235
{ 127, 0, 63 },
{ 127, 63, 95 },
{ 76, 0, 38 },
{ 76, 38, 57 },
{ 255, 0, 63 }, // 240
{ 255, 127, 159 },
{ 204, 0, 51 },
{ 204, 102, 127 },
{ 153, 0, 38 },
{ 153, 76, 95 }, // 245
{ 127, 0, 31 },
{ 127, 63, 79 },
{ 76, 0, 19 },
{ 76, 38, 47 },
{ 51, 51, 51 }, // 250
{ 91, 91, 91 },
{ 132, 132, 132 },
{ 173, 173, 173 },
{ 214, 214, 214 },
{ 255, 255, 255 } // 255
};
}
#endif
// EOF
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef DRW_CPTABLES_H
#define DRW_CPTABLES_H
//first entry in all tables are 0x80
#define CPOFFSET 0x80
#define CPLENGHTCOMMON 128
//Table 874
static const int DRW_Table874[] = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x00 , //3 #UNDEFINED
0x00 , //4 #UNDEFINED
0x00 , //5 #UNDEFINED
0x2026, //6 #HORIZONTAL ELLIPSIS
0x00 , //7 #UNDEFINED
0x00 , //8 #UNDEFINED
0x00 , //9 #UNDEFINED
0x00 , //10 #UNDEFINED
0x00 , //11 #UNDEFINED
0x00 , //12 #UNDEFINED
0x00 , //13 #UNDEFINED
0x00 , //14 #UNDEFINED
0x00 , //15 #UNDEFINED
0x00 , //16 #UNDEFINED
0x00 , //17 #UNDEFINED
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x00 , //25 #UNDEFINED
0x00 , //26 #UNDEFINED
0x00 , //27 #UNDEFINED
0x00 , //28 #UNDEFINED
0x00 , //29 #UNDEFINED
0x00 , //30 #UNDEFINED
0x00 , //31 #UNDEFINED
0x00 , //32 #UNDEFINED
0x00A0, //33 #NO-BREAK SPACE
0x0E01, //34 #THAI CHARACTER KO KAI
0x0E02, //35 #THAI CHARACTER KHO KHAI
0x0E03, //36 #THAI CHARACTER KHO KHUAT
0x0E04, //37 #THAI CHARACTER KHO KHWAI
0x0E05, //38 #THAI CHARACTER KHO KHON
0x0E06, //39 #THAI CHARACTER KHO RAKHANG
0x0E07, //40 #THAI CHARACTER NGO NGU
0x0E08, //41 #THAI CHARACTER CHO CHAN
0x0E09, //42 #THAI CHARACTER CHO CHING
0x0E0A, //43 #THAI CHARACTER CHO CHANG
0x0E0B, //44 #THAI CHARACTER SO SO
0x0E0C, //45 #THAI CHARACTER CHO CHOE
0x0E0D, //46 #THAI CHARACTER YO YING
0x0E0E, //47 #THAI CHARACTER DO CHADA
0x0E0F, //48 #THAI CHARACTER TO PATAK
0x0E10, //49 #THAI CHARACTER THO THAN
0x0E11, //50 #THAI CHARACTER THO NANGMONTHO
0x0E12, //51 #THAI CHARACTER THO PHUTHAO
0x0E13, //52 #THAI CHARACTER NO NEN
0x0E14, //53 #THAI CHARACTER DO DEK
0x0E15, //54 #THAI CHARACTER TO TAO
0x0E16, //55 #THAI CHARACTER THO THUNG
0x0E17, //56 #THAI CHARACTER THO THAHAN
0x0E18, //57 #THAI CHARACTER THO THONG
0x0E19, //58 #THAI CHARACTER NO NU
0x0E1A, //59 #THAI CHARACTER BO BAIMAI
0x0E1B, //60 #THAI CHARACTER PO PLA
0x0E1C, //61 #THAI CHARACTER PHO PHUNG
0x0E1D, //62 #THAI CHARACTER FO FA
0x0E1E, //63 #THAI CHARACTER PHO PHAN
0x0E1F, //64 #THAI CHARACTER FO FAN
0x0E20, //65 #THAI CHARACTER PHO SAMPHAO
0x0E21, //66 #THAI CHARACTER MO MA
0x0E22, //67 #THAI CHARACTER YO YAK
0x0E23, //68 #THAI CHARACTER RO RUA
0x0E24, //69 #THAI CHARACTER RU
0x0E25, //70 #THAI CHARACTER LO LING
0x0E26, //71 #THAI CHARACTER LU
0x0E27, //72 #THAI CHARACTER WO WAEN
0x0E28, //73 #THAI CHARACTER SO SALA
0x0E29, //74 #THAI CHARACTER SO RUSI
0x0E2A, //75 #THAI CHARACTER SO SUA
0x0E2B, //76 #THAI CHARACTER HO HIP
0x0E2C, //77 #THAI CHARACTER LO CHULA
0x0E2D, //78 #THAI CHARACTER O ANG
0x0E2E, //79 #THAI CHARACTER HO NOKHUK
0x0E2F, //80 #THAI CHARACTER PAIYANNOI
0x0E30, //81 #THAI CHARACTER SARA A
0x0E31, //82 #THAI CHARACTER MAI HAN-AKAT
0x0E32, //83 #THAI CHARACTER SARA AA
0x0E33, //84 #THAI CHARACTER SARA AM
0x0E34, //85 #THAI CHARACTER SARA I
0x0E35, //86 #THAI CHARACTER SARA II
0x0E36, //87 #THAI CHARACTER SARA UE
0x0E37, //88 #THAI CHARACTER SARA UEE
0x0E38, //89 #THAI CHARACTER SARA U
0x0E39, //90 #THAI CHARACTER SARA UU
0x0E3A, //91 #THAI CHARACTER PHINTHU
0x00 , //92 #UNDEFINED
0x00 , //93 #UNDEFINED
0x00 , //94 #UNDEFINED
0x00 , //95 #UNDEFINED
0x0E3F, //96 #THAI CURRENCY SYMBOL BAHT
0x0E40, //97 #THAI CHARACTER SARA E
0x0E41, //98 #THAI CHARACTER SARA AE
0x0E42, //99 #THAI CHARACTER SARA O
0x0E43, //100 #THAI CHARACTER SARA AI MAIMUAN
0x0E44, //101 #THAI CHARACTER SARA AI MAIMALAI
0x0E45, //102 #THAI CHARACTER LAKKHANGYAO
0x0E46, //103 #THAI CHARACTER MAIYAMOK
0x0E47, //104 #THAI CHARACTER MAITAIKHU
0x0E48, //105 #THAI CHARACTER MAI EK
0x0E49, //106 #THAI CHARACTER MAI THO
0x0E4A, //107 #THAI CHARACTER MAI TRI
0x0E4B, //108 #THAI CHARACTER MAI CHATTAWA
0x0E4C, //109 #THAI CHARACTER THANTHAKHAT
0x0E4D, //110 #THAI CHARACTER NIKHAHIT
0x0E4E, //111 #THAI CHARACTER YAMAKKAN
0x0E4F, //112 #THAI CHARACTER FONGMAN
0x0E50, //113 #THAI DIGIT ZERO
0x0E51, //114 #THAI DIGIT ONE
0x0E52, //115 #THAI DIGIT TWO
0x0E53, //116 #THAI DIGIT THREE
0x0E54, //117 #THAI DIGIT FOUR
0x0E55, //118 #THAI DIGIT FIVE
0x0E56, //119 #THAI DIGIT SIX
0x0E57, //120 #THAI DIGIT SEVEN
0x0E58, //121 #THAI DIGIT EIGHT
0x0E59, //122 #THAI DIGIT NINE
0x0E5A, //123 #THAI CHARACTER ANGKHANKHU
0x0E5B, //124 #THAI CHARACTER KHOMUT
0x00 , //125 #UNDEFINED
0x00 , //126 #UNDEFINED
0x00 , //127 #UNDEFINED
0x00 //128 #UNDEFINED
};
//Table 1250
static const int DRW_Table1250[] = {
0x20AC, //1 #EURO SIGN
0x00, //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
0x00, //4 #UNDEFINED
0x201E, //5 #DOUBLE LOW-9 QUOTATION MARK
0x2026, //6 #HORIZONTAL ELLIPSIS
0x2020, //7 #DAGGER
0x2021, //8 #DOUBLE DAGGER
0x00, //9 #UNDEFINED
0x2030, //10 #PER MILLE SIGN
0x0160, //11 #LATIN CAPITAL LETTER S WITH CARON
0x2039, //12 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x015A, //13 #LATIN CAPITAL LETTER S WITH ACUTE
0x0164, //14 #LATIN CAPITAL LETTER T WITH CARON
0x017D, //15 #LATIN CAPITAL LETTER Z WITH CARON
0x0179, //16 #LATIN CAPITAL LETTER Z WITH ACUTE
0x00, //17 #UNDEFINED
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x00, //25 #UNDEFINED
0x2122, //26 #TRADE MARK SIGN
0x0161, //27 #LATIN SMALL LETTER S WITH CARON
0x203A, //28 #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x015B, //29 #LATIN SMALL LETTER S WITH ACUTE
0x0165, //30 #LATIN SMALL LETTER T WITH CARON
0x017E, //31 #LATIN SMALL LETTER Z WITH CARON
0x017A, //32 #LATIN SMALL LETTER Z WITH ACUTE
0x00A0, //33 #NO-BREAK SPACE
0x02C7, //34 #CARON
0x02D8, //35 #BREVE
0x0141, //36 #LATIN CAPITAL LETTER L WITH STROKE
0x00A4, //37 #CURRENCY SIGN
0x0104, //38 #LATIN CAPITAL LETTER A WITH OGONEK
0x00A6, //39 #BROKEN BAR
0x00A7, //40 #SECTION SIGN
0x00A8, //41 #DIAERESIS
0x00A9, //42 #COPYRIGHT SIGN
0x015E, //43 #LATIN CAPITAL LETTER S WITH CEDILLA
0x00AB, //44 #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //45 #NOT SIGN
0x00AD, //46 #SOFT HYPHEN
0x00AE, //47 #REGISTERED SIGN
0x017B, //48 #LATIN CAPITAL LETTER Z WITH DOT ABOVE
0x00B0, //49 #DEGREE SIGN
0x00B1, //50 #PLUS-MINUS SIGN
0x02DB, //51 #OGONEK
0x0142, //52 #LATIN SMALL LETTER L WITH STROKE
0x00B4, //53 #ACUTE ACCENT
0x00B5, //54 #MICRO SIGN
0x00B6, //55 #PILCROW SIGN
0x00B7, //56 #MIDDLE DOT
0x00B8, //57 #CEDILLA
0x0105, //58 #LATIN SMALL LETTER A WITH OGONEK
0x015F, //59 #LATIN SMALL LETTER S WITH CEDILLA
0x00BB, //60 #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x013D, //61 #LATIN CAPITAL LETTER L WITH CARON
0x02DD, //62 #DOUBLE ACUTE ACCENT
0x013E, //63 #LATIN SMALL LETTER L WITH CARON
0x017C, //64 #LATIN SMALL LETTER Z WITH DOT ABOVE
0x0154, //65 #LATIN CAPITAL LETTER R WITH ACUTE
0x00C1, //66 #LATIN CAPITAL LETTER A WITH ACUTE
0x00C2, //67 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
0x0102, //68 #LATIN CAPITAL LETTER A WITH BREVE
0x00C4, //69 #LATIN CAPITAL LETTER A WITH DIAERESIS
0x0139, //70 #LATIN CAPITAL LETTER L WITH ACUTE
0x0106, //71 #LATIN CAPITAL LETTER C WITH ACUTE
0x00C7, //72 #LATIN CAPITAL LETTER C WITH CEDILLA
0x010C, //73 #LATIN CAPITAL LETTER C WITH CARON
0x00C9, //74 #LATIN CAPITAL LETTER E WITH ACUTE
0x0118, //75 #LATIN CAPITAL LETTER E WITH OGONEK
0x00CB, //76 #LATIN CAPITAL LETTER E WITH DIAERESIS
0x011A, //77 #LATIN CAPITAL LETTER E WITH CARON
0x00CD, //78 #LATIN CAPITAL LETTER I WITH ACUTE
0x00CE, //79 #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
0x010E, //80 #LATIN CAPITAL LETTER D WITH CARON
0x0110, //81 #LATIN CAPITAL LETTER D WITH STROKE
0x0143, //82 #LATIN CAPITAL LETTER N WITH ACUTE
0x0147, //83 #LATIN CAPITAL LETTER N WITH CARON
0x00D3, //84 #LATIN CAPITAL LETTER O WITH ACUTE
0x00D4, //85 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
0x0150, //86 #LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
0x00D6, //87 #LATIN CAPITAL LETTER O WITH DIAERESIS
0x00D7, //88 #MULTIPLICATION SIGN
0x0158, //89 #LATIN CAPITAL LETTER R WITH CARON
0x016E, //90 #LATIN CAPITAL LETTER U WITH RING ABOVE
0x00DA, //91 #LATIN CAPITAL LETTER U WITH ACUTE
0x0170, //92 #LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
0x00DC, //93 #LATIN CAPITAL LETTER U WITH DIAERESIS
0x00DD, //94 #LATIN CAPITAL LETTER Y WITH ACUTE
0x0162, //95 #LATIN CAPITAL LETTER T WITH CEDILLA
0x00DF, //96 #LATIN SMALL LETTER SHARP S
0x0155, //97 #LATIN SMALL LETTER R WITH ACUTE
0x00E1, //98 #LATIN SMALL LETTER A WITH ACUTE
0x00E2, //99 #LATIN SMALL LETTER A WITH CIRCUMFLEX
0x0103, //100 #LATIN SMALL LETTER A WITH BREVE
0x00E4, //101 #LATIN SMALL LETTER A WITH DIAERESIS
0x013A, //102 #LATIN SMALL LETTER L WITH ACUTE
0x0107, //103 #LATIN SMALL LETTER C WITH ACUTE
0x00E7, //104 #LATIN SMALL LETTER C WITH CEDILLA
0x010D, //105 #LATIN SMALL LETTER C WITH CARON
0x00E9, //106 #LATIN SMALL LETTER E WITH ACUTE
0x0119, //107 #LATIN SMALL LETTER E WITH OGONEK
0x00EB, //108 #LATIN SMALL LETTER E WITH DIAERESIS
0x011B, //109 #LATIN SMALL LETTER E WITH CARON
0x00ED, //110 #LATIN SMALL LETTER I WITH ACUTE
0x00EE, //111 #LATIN SMALL LETTER I WITH CIRCUMFLEX
0x010F, //112 #LATIN SMALL LETTER D WITH CARON
0x0111, //113 #LATIN SMALL LETTER D WITH STROKE
0x0144, //114 #LATIN SMALL LETTER N WITH ACUTE
0x0148, //115 #LATIN SMALL LETTER N WITH CARON
0x00F3, //116 #LATIN SMALL LETTER O WITH ACUTE
0x00F4, //117 #LATIN SMALL LETTER O WITH CIRCUMFLEX
0x0151, //118 #LATIN SMALL LETTER O WITH DOUBLE ACUTE
0x00F6, //119 #LATIN SMALL LETTER O WITH DIAERESIS
0x00F7, //120 #DIVISION SIGN
0x0159, //121 #LATIN SMALL LETTER R WITH CARON
0x016F, //122 #LATIN SMALL LETTER U WITH RING ABOVE
0x00FA, //123 #LATIN SMALL LETTER U WITH ACUTE
0x0171, //124 #LATIN SMALL LETTER U WITH DOUBLE ACUTE
0x00FC, //125 #LATIN SMALL LETTER U WITH DIAERESIS
0x00FD, //126 #LATIN SMALL LETTER Y WITH ACUTE
0x0163, //127 #LATIN SMALL LETTER T WITH CEDILLA
0x02D9 //128 #DOT ABOVE
};
//Table 1251
static const int DRW_Table1251[] = {
0x0402, //1 #CYRILLIC CAPITAL LETTER DJE
0x0403, //2 #CYRILLIC CAPITAL LETTER GJE
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
0x0453, //4 #CYRILLIC SMALL LETTER GJE
0x201E, //5 #DOUBLE LOW-9 QUOTATION MARK
0x2026, //6 #HORIZONTAL ELLIPSIS
0x2020, //7 #DAGGER
0x2021, //8 #DOUBLE DAGGER
0x20AC, //9 #EURO SIGN
0x2030, //10 #PER MILLE SIGN
0x0409, //11 #CYRILLIC CAPITAL LETTER LJE
0x2039, //12 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x040A, //13 #CYRILLIC CAPITAL LETTER NJE
0x040C, //14 #CYRILLIC CAPITAL LETTER KJE
0x040B, //15 #CYRILLIC CAPITAL LETTER TSHE
0x040F, //16 #CYRILLIC CAPITAL LETTER DZHE
0x0452, //17 #CYRILLIC SMALL LETTER DJE
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x00, //25 #UNDEFINED
0x2122, //26 #TRADE MARK SIGN
0x0459, //27 #CYRILLIC SMALL LETTER LJE
0x203A, //28 #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x045A, //29 #CYRILLIC SMALL LETTER NJE
0x045C, //30 #CYRILLIC SMALL LETTER KJE
0x045B, //31 #CYRILLIC SMALL LETTER TSHE
0x045F, //32 #CYRILLIC SMALL LETTER DZHE
0x00A0, //33 #NO-BREAK SPACE
0x040E, //34 #CYRILLIC CAPITAL LETTER SHORT U
0x045E, //35 #CYRILLIC SMALL LETTER SHORT U
0x0408, //36 #CYRILLIC CAPITAL LETTER JE
0x00A4, //37 #CURRENCY SIGN
0x0490, //38 #CYRILLIC CAPITAL LETTER GHE WITH UPTURN
0x00A6, //39 #BROKEN BAR
0x00A7, //40 #SECTION SIGN
0x0401, //41 #CYRILLIC CAPITAL LETTER IO
0x00A9, //42 #COPYRIGHT SIGN
0x0404, //43 #CYRILLIC CAPITAL LETTER UKRAINIAN IE
0x00AB, //44 #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //45 #NOT SIGN
0x00AD, //46 #SOFT HYPHEN
0x00AE, //47 #REGISTERED SIGN
0x0407, //48 #CYRILLIC CAPITAL LETTER YI
0x00B0, //49 #DEGREE SIGN
0x00B1, //50 #PLUS-MINUS SIGN
0x0406, //51 #CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
0x0456, //52 #CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
0x0491, //53 #CYRILLIC SMALL LETTER GHE WITH UPTURN
0x00B5, //54 #MICRO SIGN
0x00B6, //55 #PILCROW SIGN
0x00B7, //56 #MIDDLE DOT
0x0451, //57 #CYRILLIC SMALL LETTER IO
0x2116, //58 #NUMERO SIGN
0x0454, //59 #CYRILLIC SMALL LETTER UKRAINIAN IE
0x00BB, //60 #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x0458, //61 #CYRILLIC SMALL LETTER JE
0x0405, //62 #CYRILLIC CAPITAL LETTER DZE
0x0455, //63 #CYRILLIC SMALL LETTER DZE
0x0457, //64 #CYRILLIC SMALL LETTER YI
0x0410, //65 #CYRILLIC CAPITAL LETTER A
0x0411, //66 #CYRILLIC CAPITAL LETTER BE
0x0412, //67 #CYRILLIC CAPITAL LETTER VE
0x0413, //68 #CYRILLIC CAPITAL LETTER GHE
0x0414, //69 #CYRILLIC CAPITAL LETTER DE
0x0415, //70 #CYRILLIC CAPITAL LETTER IE
0x0416, //71 #CYRILLIC CAPITAL LETTER ZHE
0x0417, //72 #CYRILLIC CAPITAL LETTER ZE
0x0418, //73 #CYRILLIC CAPITAL LETTER I
0x0419, //74 #CYRILLIC CAPITAL LETTER SHORT I
0x041A, //75 #CYRILLIC CAPITAL LETTER KA
0x041B, //76 #CYRILLIC CAPITAL LETTER EL
0x041C, //77 #CYRILLIC CAPITAL LETTER EM
0x041D, //78 #CYRILLIC CAPITAL LETTER EN
0x041E, //79 #CYRILLIC CAPITAL LETTER O
0x041F, //80 #CYRILLIC CAPITAL LETTER PE
0x0420, //81 #CYRILLIC CAPITAL LETTER ER
0x0421, //82 #CYRILLIC CAPITAL LETTER ES
0x0422, //83 #CYRILLIC CAPITAL LETTER TE
0x0423, //84 #CYRILLIC CAPITAL LETTER U
0x0424, //85 #CYRILLIC CAPITAL LETTER EF
0x0425, //86 #CYRILLIC CAPITAL LETTER HA
0x0426, //87 #CYRILLIC CAPITAL LETTER TSE
0x0427, //88 #CYRILLIC CAPITAL LETTER CHE
0x0428, //89 #CYRILLIC CAPITAL LETTER SHA
0x0429, //90 #CYRILLIC CAPITAL LETTER SHCHA
0x042A, //91 #CYRILLIC CAPITAL LETTER HARD SIGN
0x042B, //92 #CYRILLIC CAPITAL LETTER YERU
0x042C, //93 #CYRILLIC CAPITAL LETTER SOFT SIGN
0x042D, //94 #CYRILLIC CAPITAL LETTER E
0x042E, //95 #CYRILLIC CAPITAL LETTER YU
0x042F, //96 #CYRILLIC CAPITAL LETTER YA
0x0430, //97 #CYRILLIC SMALL LETTER A
0x0431, //98 #CYRILLIC SMALL LETTER BE
0x0432, //99 #CYRILLIC SMALL LETTER VE
0x0433, //100 #CYRILLIC SMALL LETTER GHE
0x0434, //101 #CYRILLIC SMALL LETTER DE
0x0435, //102 #CYRILLIC SMALL LETTER IE
0x0436, //103 #CYRILLIC SMALL LETTER ZHE
0x0437, //104 #CYRILLIC SMALL LETTER ZE
0x0438, //105 #CYRILLIC SMALL LETTER I
0x0439, //106 #CYRILLIC SMALL LETTER SHORT I
0x043A, //107 #CYRILLIC SMALL LETTER KA
0x043B, //108 #CYRILLIC SMALL LETTER EL
0x043C, //109 #CYRILLIC SMALL LETTER EM
0x043D, //110 #CYRILLIC SMALL LETTER EN
0x043E, //111 #CYRILLIC SMALL LETTER O
0x043F, //112 #CYRILLIC SMALL LETTER PE
0x0440, //113 #CYRILLIC SMALL LETTER ER
0x0441, //114 #CYRILLIC SMALL LETTER ES
0x0442, //115 #CYRILLIC SMALL LETTER TE
0x0443, //116 #CYRILLIC SMALL LETTER U
0x0444, //117 #CYRILLIC SMALL LETTER EF
0x0445, //118 #CYRILLIC SMALL LETTER HA
0x0446, //119 #CYRILLIC SMALL LETTER TSE
0x0447, //120 #CYRILLIC SMALL LETTER CHE
0x0448, //121 #CYRILLIC SMALL LETTER SHA
0x0449, //122 #CYRILLIC SMALL LETTER SHCHA
0x044A, //123 #CYRILLIC SMALL LETTER HARD SIGN
0x044B, //124 #CYRILLIC SMALL LETTER YERU
0x044C, //125 #CYRILLIC SMALL LETTER SOFT SIGN
0x044D, //126 #CYRILLIC SMALL LETTER E
0x044E, //127 #CYRILLIC SMALL LETTER YU
0x044F //128 #CYRILLIC SMALL LETTER YA
};
//Table 1252
static const int DRW_Table1252[] = {
0x20AC, //1 #EURO SIGN
0x00, //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
0x0192, //4 #LATIN SMALL LETTER F WITH HOOK
0x201E, //5 #DOUBLE LOW-9 QUOTATION MARK
0x2026, //6 #HORIZONTAL ELLIPSIS
0x2020, //7 #DAGGER
0x2021, //8 #DOUBLE DAGGER
0x02C6, //9 #MODIFIER LETTER CIRCUMFLEX ACCENT
0x2030, //10 #PER MILLE SIGN
0x0160, //11 #LATIN CAPITAL LETTER S WITH CARON
0x2039, //12 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x0152, //13 #LATIN CAPITAL LIGATURE OE
0x00, //14 #UNDEFINED
0x017D, //15 #LATIN CAPITAL LETTER Z WITH CARON
0x00, //16 #UNDEFINED
0x00, //17 #UNDEFINED
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x02DC, //25 #SMALL TILDE
0x2122, //26 #TRADE MARK SIGN
0x0161, //27 #LATIN SMALL LETTER S WITH CARON
0x203A, //28 #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x0153, //29 #LATIN SMALL LIGATURE OE
0x00, //30 #UNDEFINED
0x017E, //31 #LATIN SMALL LETTER Z WITH CARON
0x0178, //32 #LATIN CAPITAL LETTER Y WITH DIAERESIS
0x00A0, //33 #NO-BREAK SPACE
0x00A1, //34 #INVERTED EXCLAMATION MARK
0x00A2, //35 #CENT SIGN
0x00A3, //36 #POUND SIGN
0x00A4, //37 #CURRENCY SIGN
0x00A5, //38 #YEN SIGN
0x00A6, //39 #BROKEN BAR
0x00A7, //40 #SECTION SIGN
0x00A8, //41 #DIAERESIS
0x00A9, //42 #COPYRIGHT SIGN
0x00AA, //43 #FEMININE ORDINAL INDICATOR
0x00AB, //44 #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //45 #NOT SIGN
0x00AD, //46 #SOFT HYPHEN
0x00AE, //47 #REGISTERED SIGN
0x00AF, //48 #MACRON
0x00B0, //49 #DEGREE SIGN
0x00B1, //50 #PLUS-MINUS SIGN
0x00B2, //51 #SUPERSCRIPT TWO
0x00B3, //52 #SUPERSCRIPT THREE
0x00B4, //53 #ACUTE ACCENT
0x00B5, //54 #MICRO SIGN
0x00B6, //55 #PILCROW SIGN
0x00B7, //56 #MIDDLE DOT
0x00B8, //57 #CEDILLA
0x00B9, //58 #SUPERSCRIPT ONE
0x00BA, //59 #MASCULINE ORDINAL INDICATOR
0x00BB, //60 #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00BC, //61 #VULGAR FRACTION ONE QUARTER
0x00BD, //62 #VULGAR FRACTION ONE HALF
0x00BE, //63 #VULGAR FRACTION THREE QUARTERS
0x00BF, //64 #INVERTED QUESTION MARK
0x00C0, //65 #LATIN CAPITAL LETTER A WITH GRAVE
0x00C1, //66 #LATIN CAPITAL LETTER A WITH ACUTE
0x00C2, //67 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
0x00C3, //68 #LATIN CAPITAL LETTER A WITH TILDE
0x00C4, //69 #LATIN CAPITAL LETTER A WITH DIAERESIS
0x00C5, //70 #LATIN CAPITAL LETTER A WITH RING ABOVE
0x00C6, //71 #LATIN CAPITAL LETTER AE
0x00C7, //72 #LATIN CAPITAL LETTER C WITH CEDILLA
0x00C8, //73 #LATIN CAPITAL LETTER E WITH GRAVE
0x00C9, //74 #LATIN CAPITAL LETTER E WITH ACUTE
0x00CA, //75 #LATIN CAPITAL LETTER E WITH CIRCUMFLEX
0x00CB, //76 #LATIN CAPITAL LETTER E WITH DIAERESIS
0x00CC, //77 #LATIN CAPITAL LETTER I WITH GRAVE
0x00CD, //78 #LATIN CAPITAL LETTER I WITH ACUTE
0x00CE, //79 #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
0x00CF, //80 #LATIN CAPITAL LETTER I WITH DIAERESIS
0x00D0, //81 #LATIN CAPITAL LETTER ETH
0x00D1, //82 #LATIN CAPITAL LETTER N WITH TILDE
0x00D2, //83 #LATIN CAPITAL LETTER O WITH GRAVE
0x00D3, //84 #LATIN CAPITAL LETTER O WITH ACUTE
0x00D4, //85 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
0x00D5, //86 #LATIN CAPITAL LETTER O WITH TILDE
0x00D6, //87 #LATIN CAPITAL LETTER O WITH DIAERESIS
0x00D7, //88 #MULTIPLICATION SIGN
0x00D8, //89 #LATIN CAPITAL LETTER O WITH STROKE
0x00D9, //90 #LATIN CAPITAL LETTER U WITH GRAVE
0x00DA, //91 #LATIN CAPITAL LETTER U WITH ACUTE
0x00DB, //92 #LATIN CAPITAL LETTER U WITH CIRCUMFLEX
0x00DC, //93 #LATIN CAPITAL LETTER U WITH DIAERESIS
0x00DD, //94 #LATIN CAPITAL LETTER Y WITH ACUTE
0x00DE, //95 #LATIN CAPITAL LETTER THORN
0x00DF, //96 #LATIN SMALL LETTER SHARP S
0x00E0, //97 #LATIN SMALL LETTER A WITH GRAVE
0x00E1, //98 #LATIN SMALL LETTER A WITH ACUTE
0x00E2, //99 #LATIN SMALL LETTER A WITH CIRCUMFLEX
0x00E3, //100 #LATIN SMALL LETTER A WITH TILDE
0x00E4, //101 #LATIN SMALL LETTER A WITH DIAERESIS
0x00E5, //102 #LATIN SMALL LETTER A WITH RING ABOVE
0x00E6, //103 #LATIN SMALL LETTER AE
0x00E7, //104 #LATIN SMALL LETTER C WITH CEDILLA
0x00E8, //105 #LATIN SMALL LETTER E WITH GRAVE
0x00E9, //106 #LATIN SMALL LETTER E WITH ACUTE
0x00EA, //107 #LATIN SMALL LETTER E WITH CIRCUMFLEX
0x00EB, //108 #LATIN SMALL LETTER E WITH DIAERESIS
0x00EC, //109 #LATIN SMALL LETTER I WITH GRAVE
0x00ED, //110 #LATIN SMALL LETTER I WITH ACUTE
0x00EE, //111 #LATIN SMALL LETTER I WITH CIRCUMFLEX
0x00EF, //112 #LATIN SMALL LETTER I WITH DIAERESIS
0x00F0, //113 #LATIN SMALL LETTER ETH
0x00F1, //114 #LATIN SMALL LETTER N WITH TILDE
0x00F2, //115 #LATIN SMALL LETTER O WITH GRAVE
0x00F3, //116 #LATIN SMALL LETTER O WITH ACUTE
0x00F4, //117 #LATIN SMALL LETTER O WITH CIRCUMFLEX
0x00F5, //118 #LATIN SMALL LETTER O WITH TILDE
0x00F6, //119 #LATIN SMALL LETTER O WITH DIAERESIS
0x00F7, //120 #DIVISION SIGN
0x00F8, //121 #LATIN SMALL LETTER O WITH STROKE
0x00F9, //122 #LATIN SMALL LETTER U WITH GRAVE
0x00FA, //123 #LATIN SMALL LETTER U WITH ACUTE
0x00FB, //124 #LATIN SMALL LETTER U WITH CIRCUMFLEX
0x00FC, //125 #LATIN SMALL LETTER U WITH DIAERESIS
0x00FD, //126 #LATIN SMALL LETTER Y WITH ACUTE
0x00FE, //127 #LATIN SMALL LETTER THORN
0x00FF //128 #LATIN SMALL LETTER Y WITH DIAERESIS
};
//Table 1253
static const int DRW_Table1253[] = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
0x0192, //4 #LATIN SMALL LETTER F WITH HOOK
0x201E, //5 #DOUBLE LOW-9 QUOTATION MARK
0x2026, //6 #HORIZONTAL ELLIPSIS
0x2020, //7 #DAGGER
0x2021, //8 #DOUBLE DAGGER
0x00 , //9 #UNDEFINED
0x2030, //10 #PER MILLE SIGN
0x00 , //11 #UNDEFINED
0x2039, //12 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x00 , //13 #UNDEFINED
0x00 , //14 #UNDEFINED
0x00 , //15 #UNDEFINED
0x00 , //16 #UNDEFINED
0x00 , //17 #UNDEFINED
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x00 , //25 #UNDEFINED
0x2122, //26 #TRADE MARK SIGN
0x00 , //27 #UNDEFINED
0x203A, //28 #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x00 , //29 #UNDEFINED
0x00 , //30 #UNDEFINED
0x00 , //31 #UNDEFINED
0x00 , //32 #UNDEFINED
0x00A0, //33 #NO-BREAK SPACE
0x0385, //34 #GREEK DIALYTIKA TONOS
0x0386, //35 #GREEK CAPITAL LETTER ALPHA WITH TONOS
0x00A3, //36 #POUND SIGN
0x00A4, //37 #CURRENCY SIGN
0x00A5, //38 #YEN SIGN
0x00A6, //39 #BROKEN BAR
0x00A7, //40 #SECTION SIGN
0x00A8, //41 #DIAERESIS
0x00A9, //42 #COPYRIGHT SIGN
0x00 , //43 #UNDEFINED
0x00AB, //44 #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //45 #NOT SIGN
0x00AD, //46 #SOFT HYPHEN
0x00AE, //47 #REGISTERED SIGN
0x2015, //48 #HORIZONTAL BAR
0x00B0, //49 #DEGREE SIGN
0x00B1, //50 #PLUS-MINUS SIGN
0x00B2, //51 #SUPERSCRIPT TWO
0x00B3, //52 #SUPERSCRIPT THREE
0x0384, //53 #GREEK TONOS
0x00B5, //54 #MICRO SIGN
0x00B6, //55 #PILCROW SIGN
0x00B7, //56 #MIDDLE DOT
0x0388, //57 #GREEK CAPITAL LETTER EPSILON WITH TONOS
0x0389, //58 #GREEK CAPITAL LETTER ETA WITH TONOS
0x038A, //59 #GREEK CAPITAL LETTER IOTA WITH TONOS
0x00BB, //60 #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x038C, //61 #GREEK CAPITAL LETTER OMICRON WITH TONOS
0x00BD, //62 #VULGAR FRACTION ONE HALF
0x038E, //63 #GREEK CAPITAL LETTER UPSILON WITH TONOS
0x038F, //64 #GREEK CAPITAL LETTER OMEGA WITH TONOS
0x0390, //65 #GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
0x0391, //66 #GREEK CAPITAL LETTER ALPHA
0x0392, //67 #GREEK CAPITAL LETTER BETA
0x0393, //68 #GREEK CAPITAL LETTER GAMMA
0x0394, //69 #GREEK CAPITAL LETTER DELTA
0x0395, //70 #GREEK CAPITAL LETTER EPSILON
0x0396, //71 #GREEK CAPITAL LETTER ZETA
0x0397, //72 #GREEK CAPITAL LETTER ETA
0x0398, //73 #GREEK CAPITAL LETTER THETA
0x0399, //74 #GREEK CAPITAL LETTER IOTA
0x039A, //75 #GREEK CAPITAL LETTER KAPPA
0x039B, //76 #GREEK CAPITAL LETTER LAMDA
0x039C, //77 #GREEK CAPITAL LETTER MU
0x039D, //78 #GREEK CAPITAL LETTER NU
0x039E, //79 #GREEK CAPITAL LETTER XI
0x039F, //80 #GREEK CAPITAL LETTER OMICRON
0x03A0, //81 #GREEK CAPITAL LETTER PI
0x03A1, //82 #GREEK CAPITAL LETTER RHO
0x00 , //83 #UNDEFINED
0x03A3, //84 #GREEK CAPITAL LETTER SIGMA
0x03A4, //85 #GREEK CAPITAL LETTER TAU
0x03A5, //86 #GREEK CAPITAL LETTER UPSILON
0x03A6, //87 #GREEK CAPITAL LETTER PHI
0x03A7, //88 #GREEK CAPITAL LETTER CHI
0x03A8, //89 #GREEK CAPITAL LETTER PSI
0x03A9, //90 #GREEK CAPITAL LETTER OMEGA
0x03AA, //91 #GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
0x03AB, //92 #GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
0x03AC, //93 #GREEK SMALL LETTER ALPHA WITH TONOS
0x03AD, //94 #GREEK SMALL LETTER EPSILON WITH TONOS
0x03AE, //95 #GREEK SMALL LETTER ETA WITH TONOS
0x03AF, //96 #GREEK SMALL LETTER IOTA WITH TONOS
0x03B0, //97 #GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
0x03B1, //98 #GREEK SMALL LETTER ALPHA
0x03B2, //99 #GREEK SMALL LETTER BETA
0x03B3, //100 #GREEK SMALL LETTER GAMMA
0x03B4, //101 #GREEK SMALL LETTER DELTA
0x03B5, //102 #GREEK SMALL LETTER EPSILON
0x03B6, //103 #GREEK SMALL LETTER ZETA
0x03B7, //104 #GREEK SMALL LETTER ETA
0x03B8, //105 #GREEK SMALL LETTER THETA
0x03B9, //106 #GREEK SMALL LETTER IOTA
0x03BA, //107 #GREEK SMALL LETTER KAPPA
0x03BB, //108 #GREEK SMALL LETTER LAMDA
0x03BC, //109 #GREEK SMALL LETTER MU
0x03BD, //110 #GREEK SMALL LETTER NU
0x03BE, //111 #GREEK SMALL LETTER XI
0x03BF, //112 #GREEK SMALL LETTER OMICRON
0x03C0, //113 #GREEK SMALL LETTER PI
0x03C1, //114 #GREEK SMALL LETTER RHO
0x03C2, //115 #GREEK SMALL LETTER FINAL SIGMA
0x03C3, //116 #GREEK SMALL LETTER SIGMA
0x03C4, //117 #GREEK SMALL LETTER TAU
0x03C5, //118 #GREEK SMALL LETTER UPSILON
0x03C6, //119 #GREEK SMALL LETTER PHI
0x03C7, //120 #GREEK SMALL LETTER CHI
0x03C8, //121 #GREEK SMALL LETTER PSI
0x03C9, //122 #GREEK SMALL LETTER OMEGA
0x03CA, //123 #GREEK SMALL LETTER IOTA WITH DIALYTIKA
0x03CB, //124 #GREEK SMALL LETTER UPSILON WITH DIALYTIKA
0x03CC, //125 #GREEK SMALL LETTER OMICRON WITH TONOS
0x03CD, //126 #GREEK SMALL LETTER UPSILON WITH TONOS
0x03CE, //127 #GREEK SMALL LETTER OMEGA WITH TONOS
0x00 //128 #UNDEFINED
};
//Table 1254
static const int DRW_Table1254[] = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
0x0192, //4 #LATIN SMALL LETTER F WITH HOOK
0x201E, //5 #DOUBLE LOW-9 QUOTATION MARK
0x2026, //6 #HORIZONTAL ELLIPSIS
0x2020, //7 #DAGGER
0x2021, //8 #DOUBLE DAGGER
0x02C6, //9 #MODIFIER LETTER CIRCUMFLEX ACCENT
0x2030, //10 #PER MILLE SIGN
0x0160, //11 #LATIN CAPITAL LETTER S WITH CARON
0x2039, //12 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x0152, //13 #LATIN CAPITAL LIGATURE OE
0x00 , //14 #UNDEFINED
0x00 , //15 #UNDEFINED
0x00 , //16 #UNDEFINED
0x00 , //17 #UNDEFINED
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x02DC, //25 #SMALL TILDE
0x2122, //26 #TRADE MARK SIGN
0x0161, //27 #LATIN SMALL LETTER S WITH CARON
0x203A, //28 #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x0153, //29 #LATIN SMALL LIGATURE OE
0x00 , //30 #UNDEFINED
0x00 , //31 #UNDEFINED
0x0178, //32 #LATIN CAPITAL LETTER Y WITH DIAERESIS
0x00A0, //33 #NO-BREAK SPACE
0x00A1, //34 #INVERTED EXCLAMATION MARK
0x00A2, //35 #CENT SIGN
0x00A3, //36 #POUND SIGN
0x00A4, //37 #CURRENCY SIGN
0x00A5, //38 #YEN SIGN
0x00A6, //39 #BROKEN BAR
0x00A7, //40 #SECTION SIGN
0x00A8, //41 #DIAERESIS
0x00A9, //42 #COPYRIGHT SIGN
0x00AA, //43 #FEMININE ORDINAL INDICATOR
0x00AB, //44 #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //45 #NOT SIGN
0x00AD, //46 #SOFT HYPHEN
0x00AE, //47 #REGISTERED SIGN
0x00AF, //48 #MACRON
0x00B0, //49 #DEGREE SIGN
0x00B1, //50 #PLUS-MINUS SIGN
0x00B2, //51 #SUPERSCRIPT TWO
0x00B3, //52 #SUPERSCRIPT THREE
0x00B4, //53 #ACUTE ACCENT
0x00B5, //54 #MICRO SIGN
0x00B6, //55 #PILCROW SIGN
0x00B7, //56 #MIDDLE DOT
0x00B8, //57 #CEDILLA
0x00B9, //58 #SUPERSCRIPT ONE
0x00BA, //59 #MASCULINE ORDINAL INDICATOR
0x00BB, //60 #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00BC, //61 #VULGAR FRACTION ONE QUARTER
0x00BD, //62 #VULGAR FRACTION ONE HALF
0x00BE, //63 #VULGAR FRACTION THREE QUARTERS
0x00BF, //64 #INVERTED QUESTION MARK
0x00C0, //65 #LATIN CAPITAL LETTER A WITH GRAVE
0x00C1, //66 #LATIN CAPITAL LETTER A WITH ACUTE
0x00C2, //67 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
0x00C3, //68 #LATIN CAPITAL LETTER A WITH TILDE
0x00C4, //69 #LATIN CAPITAL LETTER A WITH DIAERESIS
0x00C5, //70 #LATIN CAPITAL LETTER A WITH RING ABOVE
0x00C6, //71 #LATIN CAPITAL LETTER AE
0x00C7, //72 #LATIN CAPITAL LETTER C WITH CEDILLA
0x00C8, //73 #LATIN CAPITAL LETTER E WITH GRAVE
0x00C9, //74 #LATIN CAPITAL LETTER E WITH ACUTE
0x00CA, //75 #LATIN CAPITAL LETTER E WITH CIRCUMFLEX
0x00CB, //76 #LATIN CAPITAL LETTER E WITH DIAERESIS
0x00CC, //77 #LATIN CAPITAL LETTER I WITH GRAVE
0x00CD, //78 #LATIN CAPITAL LETTER I WITH ACUTE
0x00CE, //79 #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
0x00CF, //80 #LATIN CAPITAL LETTER I WITH DIAERESIS
0x011E, //81 #LATIN CAPITAL LETTER G WITH BREVE
0x00D1, //82 #LATIN CAPITAL LETTER N WITH TILDE
0x00D2, //83 #LATIN CAPITAL LETTER O WITH GRAVE
0x00D3, //84 #LATIN CAPITAL LETTER O WITH ACUTE
0x00D4, //85 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
0x00D5, //86 #LATIN CAPITAL LETTER O WITH TILDE
0x00D6, //87 #LATIN CAPITAL LETTER O WITH DIAERESIS
0x00D7, //88 #MULTIPLICATION SIGN
0x00D8, //89 #LATIN CAPITAL LETTER O WITH STROKE
0x00D9, //90 #LATIN CAPITAL LETTER U WITH GRAVE
0x00DA, //91 #LATIN CAPITAL LETTER U WITH ACUTE
0x00DB, //92 #LATIN CAPITAL LETTER U WITH CIRCUMFLEX
0x00DC, //93 #LATIN CAPITAL LETTER U WITH DIAERESIS
0x0130, //94 #LATIN CAPITAL LETTER I WITH DOT ABOVE
0x015E, //95 #LATIN CAPITAL LETTER S WITH CEDILLA
0x00DF, //96 #LATIN SMALL LETTER SHARP S
0x00E0, //97 #LATIN SMALL LETTER A WITH GRAVE
0x00E1, //98 #LATIN SMALL LETTER A WITH ACUTE
0x00E2, //99 #LATIN SMALL LETTER A WITH CIRCUMFLEX
0x00E3, //100 #LATIN SMALL LETTER A WITH TILDE
0x00E4, //101 #LATIN SMALL LETTER A WITH DIAERESIS
0x00E5, //102 #LATIN SMALL LETTER A WITH RING ABOVE
0x00E6, //103 #LATIN SMALL LETTER AE
0x00E7, //104 #LATIN SMALL LETTER C WITH CEDILLA
0x00E8, //105 #LATIN SMALL LETTER E WITH GRAVE
0x00E9, //106 #LATIN SMALL LETTER E WITH ACUTE
0x00EA, //107 #LATIN SMALL LETTER E WITH CIRCUMFLEX
0x00EB, //108 #LATIN SMALL LETTER E WITH DIAERESIS
0x00EC, //109 #LATIN SMALL LETTER I WITH GRAVE
0x00ED, //110 #LATIN SMALL LETTER I WITH ACUTE
0x00EE, //111 #LATIN SMALL LETTER I WITH CIRCUMFLEX
0x00EF, //112 #LATIN SMALL LETTER I WITH DIAERESIS
0x011F, //113 #LATIN SMALL LETTER G WITH BREVE
0x00F1, //114 #LATIN SMALL LETTER N WITH TILDE
0x00F2, //115 #LATIN SMALL LETTER O WITH GRAVE
0x00F3, //116 #LATIN SMALL LETTER O WITH ACUTE
0x00F4, //117 #LATIN SMALL LETTER O WITH CIRCUMFLEX
0x00F5, //118 #LATIN SMALL LETTER O WITH TILDE
0x00F6, //119 #LATIN SMALL LETTER O WITH DIAERESIS
0x00F7, //120 #DIVISION SIGN
0x00F8, //121 #LATIN SMALL LETTER O WITH STROKE
0x00F9, //122 #LATIN SMALL LETTER U WITH GRAVE
0x00FA, //123 #LATIN SMALL LETTER U WITH ACUTE
0x00FB, //124 #LATIN SMALL LETTER U WITH CIRCUMFLEX
0x00FC, //125 #LATIN SMALL LETTER U WITH DIAERESIS
0x0131, //126 #LATIN SMALL LETTER DOTLESS I
0x015F, //127 #LATIN SMALL LETTER S WITH CEDILLA
0x00FF //128 #LATIN SMALL LETTER Y WITH DIAERESIS
};
//Table 1255
static const int DRW_Table1255[] = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
0x0192, //4 #LATIN SMALL LETTER F WITH HOOK
0x201E, //5 #DOUBLE LOW-9 QUOTATION MARK
0x2026, //6 #HORIZONTAL ELLIPSIS
0x2020, //7 #DAGGER
0x2021, //8 #DOUBLE DAGGER
0x02C6, //9 #MODIFIER LETTER CIRCUMFLEX ACCENT
0x2030, //10 #PER MILLE SIGN
0x00 , //11 #UNDEFINED
0x2039, //12 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x00 , //13 #UNDEFINED
0x00 , //14 #UNDEFINED
0x00 , //15 #UNDEFINED
0x00 , //16 #UNDEFINED
0x00 , //17 #UNDEFINED
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x02DC, //25 #SMALL TILDE
0x2122, //26 #TRADE MARK SIGN
0x00 , //27 #UNDEFINED
0x203A, //28 #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x00 , //29 #UNDEFINED
0x00 , //30 #UNDEFINED
0x00 , //31 #UNDEFINED
0x00 , //32 #UNDEFINED
0x00A0, //33 #NO-BREAK SPACE
0x00A1, //34 #INVERTED EXCLAMATION MARK
0x00A2, //35 #CENT SIGN
0x00A3, //36 #POUND SIGN
0x20AA, //37 #NEW SHEQEL SIGN
0x00A5, //38 #YEN SIGN
0x00A6, //39 #BROKEN BAR
0x00A7, //40 #SECTION SIGN
0x00A8, //41 #DIAERESIS
0x00A9, //42 #COPYRIGHT SIGN
0x00D7, //43 #MULTIPLICATION SIGN
0x00AB, //44 #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //45 #NOT SIGN
0x00AD, //46 #SOFT HYPHEN
0x00AE, //47 #REGISTERED SIGN
0x00AF, //48 #MACRON
0x00B0, //49 #DEGREE SIGN
0x00B1, //50 #PLUS-MINUS SIGN
0x00B2, //51 #SUPERSCRIPT TWO
0x00B3, //52 #SUPERSCRIPT THREE
0x00B4, //53 #ACUTE ACCENT
0x00B5, //54 #MICRO SIGN
0x00B6, //55 #PILCROW SIGN
0x00B7, //56 #MIDDLE DOT
0x00B8, //57 #CEDILLA
0x00B9, //58 #SUPERSCRIPT ONE
0x00F7, //59 #DIVISION SIGN
0x00BB, //60 #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00BC, //61 #VULGAR FRACTION ONE QUARTER
0x00BD, //62 #VULGAR FRACTION ONE HALF
0x00BE, //63 #VULGAR FRACTION THREE QUARTERS
0x00BF, //64 #INVERTED QUESTION MARK
0x05B0, //65 #HEBREW POINT SHEVA
0x05B1, //66 #HEBREW POINT HATAF SEGOL
0x05B2, //67 #HEBREW POINT HATAF PATAH
0x05B3, //68 #HEBREW POINT HATAF QAMATS
0x05B4, //69 #HEBREW POINT HIRIQ
0x05B5, //70 #HEBREW POINT TSERE
0x05B6, //71 #HEBREW POINT SEGOL
0x05B7, //72 #HEBREW POINT PATAH
0x05B8, //73 #HEBREW POINT QAMATS
0x05B9, //74 #HEBREW POINT HOLAM
0x00 , //75 #UNDEFINED
0x05BB, //76 #HEBREW POINT QUBUTS
0x05BC, //77 #HEBREW POINT DAGESH OR MAPIQ
0x05BD, //78 #HEBREW POINT METEG
0x05BE, //79 #HEBREW PUNCTUATION MAQAF
0x05BF, //80 #HEBREW POINT RAFE
0x05C0, //81 #HEBREW PUNCTUATION PASEQ
0x05C1, //82 #HEBREW POINT SHIN DOT
0x05C2, //83 #HEBREW POINT SIN DOT
0x05C3, //84 #HEBREW PUNCTUATION SOF PASUQ
0x05F0, //85 #HEBREW LIGATURE YIDDISH DOUBLE VAV
0x05F1, //86 #HEBREW LIGATURE YIDDISH VAV YOD
0x05F2, //87 #HEBREW LIGATURE YIDDISH DOUBLE YOD
0x05F3, //88 #HEBREW PUNCTUATION GERESH
0x05F4, //89 #HEBREW PUNCTUATION GERSHAYIM
0x00 , //90 #UNDEFINED
0x00 , //91 #UNDEFINED
0x00 , //92 #UNDEFINED
0x00 , //93 #UNDEFINED
0x00 , //94 #UNDEFINED
0x00 , //95 #UNDEFINED
0x00 , //96 #UNDEFINED
0x05D0, //97 #HEBREW LETTER ALEF
0x05D1, //98 #HEBREW LETTER BET
0x05D2, //99 #HEBREW LETTER GIMEL
0x05D3, //100 #HEBREW LETTER DALET
0x05D4, //101 #HEBREW LETTER HE
0x05D5, //102 #HEBREW LETTER VAV
0x05D6, //103 #HEBREW LETTER ZAYIN
0x05D7, //104 #HEBREW LETTER HET
0x05D8, //105 #HEBREW LETTER TET
0x05D9, //106 #HEBREW LETTER YOD
0x05DA, //107 #HEBREW LETTER FINAL KAF
0x05DB, //108 #HEBREW LETTER KAF
0x05DC, //109 #HEBREW LETTER LAMED
0x05DD, //110 #HEBREW LETTER FINAL MEM
0x05DE, //111 #HEBREW LETTER MEM
0x05DF, //112 #HEBREW LETTER FINAL NUN
0x05E0, //113 #HEBREW LETTER NUN
0x05E1, //114 #HEBREW LETTER SAMEKH
0x05E2, //115 #HEBREW LETTER AYIN
0x05E3, //116 #HEBREW LETTER FINAL PE
0x05E4, //117 #HEBREW LETTER PE
0x05E5, //118 #HEBREW LETTER FINAL TSADI
0x05E6, //119 #HEBREW LETTER TSADI
0x05E7, //120 #HEBREW LETTER QOF
0x05E8, //121 #HEBREW LETTER RESH
0x05E9, //122 #HEBREW LETTER SHIN
0x05EA, //123 #HEBREW LETTER TAV
0x00 , //124 #UNDEFINED
0x00 , //125 #UNDEFINED
0x200E, //126 #LEFT-TO-RIGHT MARK
0x200F, //127 #RIGHT-TO-LEFT MARK
0x00 //128 #UNDEFINED
};
//Table 1256
static const int DRW_Table1256[] = {
0x20AC, //1 #EURO SIGN
0x067E, //2 #ARABIC LETTER PEH
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
0x0192, //4 #LATIN SMALL LETTER F WITH HOOK
0x201E, //5 #DOUBLE LOW-9 QUOTATION MARK
0x2026, //6 #HORIZONTAL ELLIPSIS
0x2020, //7 #DAGGER
0x2021, //8 #DOUBLE DAGGER
0x02C6, //9 #MODIFIER LETTER CIRCUMFLEX ACCENT
0x2030, //10 #PER MILLE SIGN
0x0679, //11 #ARABIC LETTER TTEH
0x2039, //12 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x0152, //13 #LATIN CAPITAL LIGATURE OE
0x0686, //14 #ARABIC LETTER TCHEH
0x0698, //15 #ARABIC LETTER JEH
0x0688, //16 #ARABIC LETTER DDAL
0x06AF, //17 #ARABIC LETTER GAF
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x06A9, //25 #ARABIC LETTER KEHEH
0x2122, //26 #TRADE MARK SIGN
0x0691, //27 #ARABIC LETTER RREH
0x203A, //28 #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x0153, //29 #LATIN SMALL LIGATURE OE
0x200C, //30 #ZERO WIDTH NON-JOINER
0x200D, //31 #ZERO WIDTH JOINER
0x06BA, //32 #ARABIC LETTER NOON GHUNNA
0x00A0, //33 #NO-BREAK SPACE
0x060C, //34 #ARABIC COMMA
0x00A2, //35 #CENT SIGN
0x00A3, //36 #POUND SIGN
0x00A4, //37 #CURRENCY SIGN
0x00A5, //38 #YEN SIGN
0x00A6, //39 #BROKEN BAR
0x00A7, //40 #SECTION SIGN
0x00A8, //41 #DIAERESIS
0x00A9, //42 #COPYRIGHT SIGN
0x06BE, //43 #ARABIC LETTER HEH DOACHASHMEE
0x00AB, //44 #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //45 #NOT SIGN
0x00AD, //46 #SOFT HYPHEN
0x00AE, //47 #REGISTERED SIGN
0x00AF, //48 #MACRON
0x00B0, //49 #DEGREE SIGN
0x00B1, //50 #PLUS-MINUS SIGN
0x00B2, //51 #SUPERSCRIPT TWO
0x00B3, //52 #SUPERSCRIPT THREE
0x00B4, //53 #ACUTE ACCENT
0x00B5, //54 #MICRO SIGN
0x00B6, //55 #PILCROW SIGN
0x00B7, //56 #MIDDLE DOT
0x00B8, //57 #CEDILLA
0x00B9, //58 #SUPERSCRIPT ONE
0x061B, //59 #ARABIC SEMICOLON
0x00BB, //60 #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00BC, //61 #VULGAR FRACTION ONE QUARTER
0x00BD, //62 #VULGAR FRACTION ONE HALF
0x00BE, //63 #VULGAR FRACTION THREE QUARTERS
0x061F, //64 #ARABIC QUESTION MARK
0x06C1, //65 #ARABIC LETTER HEH GOAL
0x0621, //66 #ARABIC LETTER HAMZA
0x0622, //67 #ARABIC LETTER ALEF WITH MADDA ABOVE
0x0623, //68 #ARABIC LETTER ALEF WITH HAMZA ABOVE
0x0624, //69 #ARABIC LETTER WAW WITH HAMZA ABOVE
0x0625, //70 #ARABIC LETTER ALEF WITH HAMZA BELOW
0x0626, //71 #ARABIC LETTER YEH WITH HAMZA ABOVE
0x0627, //72 #ARABIC LETTER ALEF
0x0628, //73 #ARABIC LETTER BEH
0x0629, //74 #ARABIC LETTER TEH MARBUTA
0x062A, //75 #ARABIC LETTER TEH
0x062B, //76 #ARABIC LETTER THEH
0x062C, //77 #ARABIC LETTER JEEM
0x062D, //78 #ARABIC LETTER HAH
0x062E, //79 #ARABIC LETTER KHAH
0x062F, //80 #ARABIC LETTER DAL
0x0630, //81 #ARABIC LETTER THAL
0x0631, //82 #ARABIC LETTER REH
0x0632, //83 #ARABIC LETTER ZAIN
0x0633, //84 #ARABIC LETTER SEEN
0x0634, //85 #ARABIC LETTER SHEEN
0x0635, //86 #ARABIC LETTER SAD
0x0636, //87 #ARABIC LETTER DAD
0x00D7, //88 #MULTIPLICATION SIGN
0x0637, //89 #ARABIC LETTER TAH
0x0638, //90 #ARABIC LETTER ZAH
0x0639, //91 #ARABIC LETTER AIN
0x063A, //92 #ARABIC LETTER GHAIN
0x0640, //93 #ARABIC TATWEEL
0x0641, //94 #ARABIC LETTER FEH
0x0642, //95 #ARABIC LETTER QAF
0x0643, //96 #ARABIC LETTER KAF
0x00E0, //97 #LATIN SMALL LETTER A WITH GRAVE
0x0644, //98 #ARABIC LETTER LAM
0x00E2, //99 #LATIN SMALL LETTER A WITH CIRCUMFLEX
0x0645, //100 #ARABIC LETTER MEEM
0x0646, //101 #ARABIC LETTER NOON
0x0647, //102 #ARABIC LETTER HEH
0x0648, //103 #ARABIC LETTER WAW
0x00E7, //104 #LATIN SMALL LETTER C WITH CEDILLA
0x00E8, //105 #LATIN SMALL LETTER E WITH GRAVE
0x00E9, //106 #LATIN SMALL LETTER E WITH ACUTE
0x00EA, //107 #LATIN SMALL LETTER E WITH CIRCUMFLEX
0x00EB, //108 #LATIN SMALL LETTER E WITH DIAERESIS
0x0649, //109 #ARABIC LETTER ALEF MAKSURA
0x064A, //110 #ARABIC LETTER YEH
0x00EE, //111 #LATIN SMALL LETTER I WITH CIRCUMFLEX
0x00EF, //112 #LATIN SMALL LETTER I WITH DIAERESIS
0x064B, //113 #ARABIC FATHATAN
0x064C, //114 #ARABIC DAMMATAN
0x064D, //115 #ARABIC KASRATAN
0x064E, //116 #ARABIC FATHA
0x00F4, //117 #LATIN SMALL LETTER O WITH CIRCUMFLEX
0x064F, //118 #ARABIC DAMMA
0x0650, //119 #ARABIC KASRA
0x00F7, //120 #DIVISION SIGN
0x0651, //121 #ARABIC SHADDA
0x00F9, //122 #LATIN SMALL LETTER U WITH GRAVE
0x0652, //123 #ARABIC SUKUN
0x00FB, //124 #LATIN SMALL LETTER U WITH CIRCUMFLEX
0x00FC, //125 #LATIN SMALL LETTER U WITH DIAERESIS
0x200E, //126 #LEFT-TO-RIGHT MARK
0x200F, //127 #RIGHT-TO-LEFT MARK
0x06D2 //128 #ARABIC LETTER YEH BARREE
};
//Table 1257
static const int DRW_Table1257[] = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
0x00 , //4 #UNDEFINED
0x201E, //5 #DOUBLE LOW-9 QUOTATION MARK
0x2026, //6 #HORIZONTAL ELLIPSIS
0x2020, //7 #DAGGER
0x2021, //8 #DOUBLE DAGGER
0x00 , //9 #UNDEFINED
0x2030, //10 #PER MILLE SIGN
0x00 , //11 #UNDEFINED
0x2039, //12 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x00 , //13 #UNDEFINED
0x00A8, //14 #DIAERESIS
0x02C7, //15 #CARON
0x00B8, //16 #CEDILLA
0x00 , //17 #UNDEFINED
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x00 , //25 #UNDEFINED
0x2122, //26 #TRADE MARK SIGN
0x00 , //27 #UNDEFINED
0x203A, //28 #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x00 , //29 #UNDEFINED
0x00AF, //30 #MACRON
0x02DB, //31 #OGONEK
0x00 , //32 #UNDEFINED
0x00A0, //33 #NO-BREAK SPACE
0x00 , //34 #UNDEFINED
0x00A2, //35 #CENT SIGN
0x00A3, //36 #POUND SIGN
0x00A4, //37 #CURRENCY SIGN
0x00 , //38 #UNDEFINED
0x00A6, //39 #BROKEN BAR
0x00A7, //40 #SECTION SIGN
0x00D8, //41 #LATIN CAPITAL LETTER O WITH STROKE
0x00A9, //42 #COPYRIGHT SIGN
0x0156, //43 #LATIN CAPITAL LETTER R WITH CEDILLA
0x00AB, //44 #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //45 #NOT SIGN
0x00AD, //46 #SOFT HYPHEN
0x00AE, //47 #REGISTERED SIGN
0x00C6, //48 #LATIN CAPITAL LETTER AE
0x00B0, //49 #DEGREE SIGN
0x00B1, //50 #PLUS-MINUS SIGN
0x00B2, //51 #SUPERSCRIPT TWO
0x00B3, //52 #SUPERSCRIPT THREE
0x00B4, //53 #ACUTE ACCENT
0x00B5, //54 #MICRO SIGN
0x00B6, //55 #PILCROW SIGN
0x00B7, //56 #MIDDLE DOT
0x00F8, //57 #LATIN SMALL LETTER O WITH STROKE
0x00B9, //58 #SUPERSCRIPT ONE
0x0157, //59 #LATIN SMALL LETTER R WITH CEDILLA
0x00BB, //60 #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00BC, //61 #VULGAR FRACTION ONE QUARTER
0x00BD, //62 #VULGAR FRACTION ONE HALF
0x00BE, //63 #VULGAR FRACTION THREE QUARTERS
0x00E6, //64 #LATIN SMALL LETTER AE
0x0104, //65 #LATIN CAPITAL LETTER A WITH OGONEK
0x012E, //66 #LATIN CAPITAL LETTER I WITH OGONEK
0x0100, //67 #LATIN CAPITAL LETTER A WITH MACRON
0x0106, //68 #LATIN CAPITAL LETTER C WITH ACUTE
0x00C4, //69 #LATIN CAPITAL LETTER A WITH DIAERESIS
0x00C5, //70 #LATIN CAPITAL LETTER A WITH RING ABOVE
0x0118, //71 #LATIN CAPITAL LETTER E WITH OGONEK
0x0112, //72 #LATIN CAPITAL LETTER E WITH MACRON
0x010C, //73 #LATIN CAPITAL LETTER C WITH CARON
0x00C9, //74 #LATIN CAPITAL LETTER E WITH ACUTE
0x0179, //75 #LATIN CAPITAL LETTER Z WITH ACUTE
0x0116, //76 #LATIN CAPITAL LETTER E WITH DOT ABOVE
0x0122, //77 #LATIN CAPITAL LETTER G WITH CEDILLA
0x0136, //78 #LATIN CAPITAL LETTER K WITH CEDILLA
0x012A, //79 #LATIN CAPITAL LETTER I WITH MACRON
0x013B, //80 #LATIN CAPITAL LETTER L WITH CEDILLA
0x0160, //81 #LATIN CAPITAL LETTER S WITH CARON
0x0143, //82 #LATIN CAPITAL LETTER N WITH ACUTE
0x0145, //83 #LATIN CAPITAL LETTER N WITH CEDILLA
0x00D3, //84 #LATIN CAPITAL LETTER O WITH ACUTE
0x014C, //85 #LATIN CAPITAL LETTER O WITH MACRON
0x00D5, //86 #LATIN CAPITAL LETTER O WITH TILDE
0x00D6, //87 #LATIN CAPITAL LETTER O WITH DIAERESIS
0x00D7, //88 #MULTIPLICATION SIGN
0x0172, //89 #LATIN CAPITAL LETTER U WITH OGONEK
0x0141, //90 #LATIN CAPITAL LETTER L WITH STROKE
0x015A, //91 #LATIN CAPITAL LETTER S WITH ACUTE
0x016A, //92 #LATIN CAPITAL LETTER U WITH MACRON
0x00DC, //93 #LATIN CAPITAL LETTER U WITH DIAERESIS
0x017B, //94 #LATIN CAPITAL LETTER Z WITH DOT ABOVE
0x017D, //95 #LATIN CAPITAL LETTER Z WITH CARON
0x00DF, //96 #LATIN SMALL LETTER SHARP S
0x0105, //97 #LATIN SMALL LETTER A WITH OGONEK
0x012F, //98 #LATIN SMALL LETTER I WITH OGONEK
0x0101, //99 #LATIN SMALL LETTER A WITH MACRON
0x0107, //100 #LATIN SMALL LETTER C WITH ACUTE
0x00E4, //101 #LATIN SMALL LETTER A WITH DIAERESIS
0x00E5, //102 #LATIN SMALL LETTER A WITH RING ABOVE
0x0119, //103 #LATIN SMALL LETTER E WITH OGONEK
0x0113, //104 #LATIN SMALL LETTER E WITH MACRON
0x010D, //105 #LATIN SMALL LETTER C WITH CARON
0x00E9, //106 #LATIN SMALL LETTER E WITH ACUTE
0x017A, //107 #LATIN SMALL LETTER Z WITH ACUTE
0x0117, //108 #LATIN SMALL LETTER E WITH DOT ABOVE
0x0123, //109 #LATIN SMALL LETTER G WITH CEDILLA
0x0137, //110 #LATIN SMALL LETTER K WITH CEDILLA
0x012B, //111 #LATIN SMALL LETTER I WITH MACRON
0x013C, //112 #LATIN SMALL LETTER L WITH CEDILLA
0x0161, //113 #LATIN SMALL LETTER S WITH CARON
0x0144, //114 #LATIN SMALL LETTER N WITH ACUTE
0x0146, //115 #LATIN SMALL LETTER N WITH CEDILLA
0x00F3, //116 #LATIN SMALL LETTER O WITH ACUTE
0x014D, //117 #LATIN SMALL LETTER O WITH MACRON
0x00F5, //118 #LATIN SMALL LETTER O WITH TILDE
0x00F6, //119 #LATIN SMALL LETTER O WITH DIAERESIS
0x00F7, //120 #DIVISION SIGN
0x0173, //121 #LATIN SMALL LETTER U WITH OGONEK
0x0142, //122 #LATIN SMALL LETTER L WITH STROKE
0x015B, //123 #LATIN SMALL LETTER S WITH ACUTE
0x016B, //124 #LATIN SMALL LETTER U WITH MACRON
0x00FC, //125 #LATIN SMALL LETTER U WITH DIAERESIS
0x017C, //126 #LATIN SMALL LETTER Z WITH DOT ABOVE
0x017E, //127 #LATIN SMALL LETTER Z WITH CARON
0x02D9 //128 #DOT ABOVE
};
//Table 1258
static const int DRW_Table1258[] = {
0x20AC, //1 #EURO SIGN
0x00 , //2 #UNDEFINED
0x201A, //3 #SINGLE LOW-9 QUOTATION MARK
0x0192, //4 #LATIN SMALL LETTER F WITH HOOK
0x201E, //5 #DOUBLE LOW-9 QUOTATION MARK
0x2026, //6 #HORIZONTAL ELLIPSIS
0x2020, //7 #DAGGER
0x2021, //8 #DOUBLE DAGGER
0x02C6, //9 #MODIFIER LETTER CIRCUMFLEX ACCENT
0x2030, //10 #PER MILLE SIGN
0x00 , //11 #UNDEFINED
0x2039, //12 #SINGLE LEFT-POINTING ANGLE QUOTATION MARK
0x0152, //13 #LATIN CAPITAL LIGATURE OE
0x00 , //14 #UNDEFINED
0x00 , //15 #UNDEFINED
0x00 , //16 #UNDEFINED
0x00 , //17 #UNDEFINED
0x2018, //18 #LEFT SINGLE QUOTATION MARK
0x2019, //19 #RIGHT SINGLE QUOTATION MARK
0x201C, //20 #LEFT DOUBLE QUOTATION MARK
0x201D, //21 #RIGHT DOUBLE QUOTATION MARK
0x2022, //22 #BULLET
0x2013, //23 #EN DASH
0x2014, //24 #EM DASH
0x02DC, //25 #SMALL TILDE
0x2122, //26 #TRADE MARK SIGN
0x00 , //27 #UNDEFINED
0x203A, //28 #SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
0x0153, //29 #LATIN SMALL LIGATURE OE
0x00 , //30 #UNDEFINED
0x00 , //31 #UNDEFINED
0x0178, //32 #LATIN CAPITAL LETTER Y WITH DIAERESIS
0x00A0, //33 #NO-BREAK SPACE
0x00A1, //34 #INVERTED EXCLAMATION MARK
0x00A2, //35 #CENT SIGN
0x00A3, //36 #POUND SIGN
0x00A4, //37 #CURRENCY SIGN
0x00A5, //38 #YEN SIGN
0x00A6, //39 #BROKEN BAR
0x00A7, //40 #SECTION SIGN
0x00A8, //41 #DIAERESIS
0x00A9, //42 #COPYRIGHT SIGN
0x00AA, //43 #FEMININE ORDINAL INDICATOR
0x00AB, //44 #LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00AC, //45 #NOT SIGN
0x00AD, //46 #SOFT HYPHEN
0x00AE, //47 #REGISTERED SIGN
0x00AF, //48 #MACRON
0x00B0, //49 #DEGREE SIGN
0x00B1, //50 #PLUS-MINUS SIGN
0x00B2, //51 #SUPERSCRIPT TWO
0x00B3, //52 #SUPERSCRIPT THREE
0x00B4, //53 #ACUTE ACCENT
0x00B5, //54 #MICRO SIGN
0x00B6, //55 #PILCROW SIGN
0x00B7, //56 #MIDDLE DOT
0x00B8, //57 #CEDILLA
0x00B9, //58 #SUPERSCRIPT ONE
0x00BA, //59 #MASCULINE ORDINAL INDICATOR
0x00BB, //60 #RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
0x00BC, //61 #VULGAR FRACTION ONE QUARTER
0x00BD, //62 #VULGAR FRACTION ONE HALF
0x00BE, //63 #VULGAR FRACTION THREE QUARTERS
0x00BF, //64 #INVERTED QUESTION MARK
0x00C0, //65 #LATIN CAPITAL LETTER A WITH GRAVE
0x00C1, //66 #LATIN CAPITAL LETTER A WITH ACUTE
0x00C2, //67 #LATIN CAPITAL LETTER A WITH CIRCUMFLEX
0x0102, //68 #LATIN CAPITAL LETTER A WITH BREVE
0x00C4, //69 #LATIN CAPITAL LETTER A WITH DIAERESIS
0x00C5, //70 #LATIN CAPITAL LETTER A WITH RING ABOVE
0x00C6, //71 #LATIN CAPITAL LETTER AE
0x00C7, //72 #LATIN CAPITAL LETTER C WITH CEDILLA
0x00C8, //73 #LATIN CAPITAL LETTER E WITH GRAVE
0x00C9, //74 #LATIN CAPITAL LETTER E WITH ACUTE
0x00CA, //75 #LATIN CAPITAL LETTER E WITH CIRCUMFLEX
0x00CB, //76 #LATIN CAPITAL LETTER E WITH DIAERESIS
0x0300, //77 #COMBINING GRAVE ACCENT
0x00CD, //78 #LATIN CAPITAL LETTER I WITH ACUTE
0x00CE, //79 #LATIN CAPITAL LETTER I WITH CIRCUMFLEX
0x00CF, //80 #LATIN CAPITAL LETTER I WITH DIAERESIS
0x0110, //81 #LATIN CAPITAL LETTER D WITH STROKE
0x00D1, //82 #LATIN CAPITAL LETTER N WITH TILDE
0x0309, //83 #COMBINING HOOK ABOVE
0x00D3, //84 #LATIN CAPITAL LETTER O WITH ACUTE
0x00D4, //85 #LATIN CAPITAL LETTER O WITH CIRCUMFLEX
0x01A0, //86 #LATIN CAPITAL LETTER O WITH HORN
0x00D6, //87 #LATIN CAPITAL LETTER O WITH DIAERESIS
0x00D7, //88 #MULTIPLICATION SIGN
0x00D8, //89 #LATIN CAPITAL LETTER O WITH STROKE
0x00D9, //90 #LATIN CAPITAL LETTER U WITH GRAVE
0x00DA, //91 #LATIN CAPITAL LETTER U WITH ACUTE
0x00DB, //92 #LATIN CAPITAL LETTER U WITH CIRCUMFLEX
0x00DC, //93 #LATIN CAPITAL LETTER U WITH DIAERESIS
0x01AF, //94 #LATIN CAPITAL LETTER U WITH HORN
0x0303, //95 #COMBINING TILDE
0x00DF, //96 #LATIN SMALL LETTER SHARP S
0x00E0, //97 #LATIN SMALL LETTER A WITH GRAVE
0x00E1, //98 #LATIN SMALL LETTER A WITH ACUTE
0x00E2, //99 #LATIN SMALL LETTER A WITH CIRCUMFLEX
0x0103, //100 #LATIN SMALL LETTER A WITH BREVE
0x00E4, //101 #LATIN SMALL LETTER A WITH DIAERESIS
0x00E5, //102 #LATIN SMALL LETTER A WITH RING ABOVE
0x00E6, //103 #LATIN SMALL LETTER AE
0x00E7, //104 #LATIN SMALL LETTER C WITH CEDILLA
0x00E8, //105 #LATIN SMALL LETTER E WITH GRAVE
0x00E9, //106 #LATIN SMALL LETTER E WITH ACUTE
0x00EA, //107 #LATIN SMALL LETTER E WITH CIRCUMFLEX
0x00EB, //108 #LATIN SMALL LETTER E WITH DIAERESIS
0x0301, //109 #COMBINING ACUTE ACCENT
0x00ED, //110 #LATIN SMALL LETTER I WITH ACUTE
0x00EE, //111 #LATIN SMALL LETTER I WITH CIRCUMFLEX
0x00EF, //112 #LATIN SMALL LETTER I WITH DIAERESIS
0x0111, //113 #LATIN SMALL LETTER D WITH STROKE
0x00F1, //114 #LATIN SMALL LETTER N WITH TILDE
0x0323, //115 #COMBINING DOT BELOW
0x00F3, //116 #LATIN SMALL LETTER O WITH ACUTE
0x00F4, //117 #LATIN SMALL LETTER O WITH CIRCUMFLEX
0x01A1, //118 #LATIN SMALL LETTER O WITH HORN
0x00F6, //119 #LATIN SMALL LETTER O WITH DIAERESIS
0x00F7, //120 #DIVISION SIGN
0x00F8, //121 #LATIN SMALL LETTER O WITH STROKE
0x00F9, //122 #LATIN SMALL LETTER U WITH GRAVE
0x00FA, //123 #LATIN SMALL LETTER U WITH ACUTE
0x00FB, //124 #LATIN SMALL LETTER U WITH CIRCUMFLEX
0x00FC, //125 #LATIN SMALL LETTER U WITH DIAERESIS
0x01B0, //126 #LATIN SMALL LETTER U WITH HORN
0x20AB, //127 #DONG SIGN
0x00FF //128 #LATIN SMALL LETTER Y WITH DIAERESIS
};
#endif // DRW_CPTABLES_H
#include "drw_textcodec.h"
#include <sstream>
#include <iomanip>
#include <algorithm>
#include "../drw_base.h"
#include "drw_cptables.h"
#include "drw_cptable932.h"
#include "drw_cptable936.h"
#include "drw_cptable949.h"
#include "drw_cptable950.h"
DRW_TextCodec::DRW_TextCodec() {
version = DRW::AC1021;
conv = new DRW_Converter(NULL, 0);
}
DRW_TextCodec::~DRW_TextCodec() {
delete conv;
}
void DRW_TextCodec::setVersion(std::string *v){
std::string versionStr = *v;
if (versionStr == "AC1009" || versionStr == "AC1006") {
version = DRW::AC1009;
cp = "ANSI_1252";
setCodePage(&cp);
} else if (versionStr == "AC1012" || versionStr == "AC1014"
|| versionStr == "AC1015" || versionStr == "AC1018") {
version = DRW::AC1015;
if (cp.empty()) { //codepage not set, initialize
cp = "ANSI_1252";
setCodePage(&cp);
}
} else {
version = DRW::AC1021;
cp = "ANSI_1252";
}
}
void DRW_TextCodec::setCodePage(std::string *c){
cp = correctCodePage(*c);
delete conv;
if (version == DRW::AC1009 || version == DRW::AC1015) {
if (cp == "ANSI_874")
conv = new DRW_ConvTable(DRW_Table874, CPLENGHTCOMMON);
else if (cp == "ANSI_932")
conv = new DRW_Conv932Table(DRW_Table932, DRW_LeadTable932,
DRW_DoubleTable932, CPLENGHT932);
else if (cp == "ANSI_936")
conv = new DRW_ConvDBCSTable(DRW_Table936, DRW_LeadTable936,
DRW_DoubleTable936, CPLENGHT936);
else if (cp == "ANSI_949")
conv = new DRW_ConvDBCSTable(DRW_Table949, DRW_LeadTable949,
DRW_DoubleTable949, CPLENGHT949);
else if (cp == "ANSI_950")
conv = new DRW_ConvDBCSTable(DRW_Table950, DRW_LeadTable950,
DRW_DoubleTable950, CPLENGHT950);
else if (cp == "ANSI_1250")
conv = new DRW_ConvTable(DRW_Table1250, CPLENGHTCOMMON);
else if (cp == "ANSI_1251")
conv = new DRW_ConvTable(DRW_Table1251, CPLENGHTCOMMON);
else if (cp == "ANSI_1253")
conv = new DRW_ConvTable(DRW_Table1253, CPLENGHTCOMMON);
else if (cp == "ANSI_1254")
conv = new DRW_ConvTable(DRW_Table1254, CPLENGHTCOMMON);
else if (cp == "ANSI_1255")
conv = new DRW_ConvTable(DRW_Table1255, CPLENGHTCOMMON);
else if (cp == "ANSI_1256")
conv = new DRW_ConvTable(DRW_Table1256, CPLENGHTCOMMON);
else if (cp == "ANSI_1257")
conv = new DRW_ConvTable(DRW_Table1257, CPLENGHTCOMMON);
else if (cp == "ANSI_1258")
conv = new DRW_ConvTable(DRW_Table1258, CPLENGHTCOMMON);
else if (cp == "UTF-8") { //DXF older than 2007 are write in win codepages
cp = "ANSI_1252";
conv = new DRW_Converter(NULL, 0);
} else
conv = new DRW_ConvTable(DRW_Table1252, CPLENGHTCOMMON);
} else {
conv = new DRW_Converter(NULL, 0);
}
}
std::string DRW_TextCodec::toUtf8(std::string s) {
return conv->toUtf8(&s);
}
std::string DRW_TextCodec::fromUtf8(std::string s) {
return conv->fromUtf8(&s);
}
std::string DRW_Converter::toUtf8(std::string *s) {
std::string result;
int j = 0;
unsigned int i= 0;
for (i=0; i < s->length(); i++) {
unsigned char c = s->at(i);
if (c < 0x80) { //ascii check for /U+????
if (c == '\\' && i+6 < s->length() && s->at(i+1) == 'U' && s->at(i+2) == '+') {
result += s->substr(j,i-j);
result += encodeText(s->substr(i,7));
i +=6;
j = i+1;
}
} else if (c < 0xE0 ) {//2 bits
i++;
} else if (c < 0xF0 ) {//3 bits
i +=2;
} else if (c < 0xF8 ) {//4 bits
i +=3;
}
}
result += s->substr(j);
return result;
}
std::string DRW_ConvTable::fromUtf8(std::string *s) {
std::string result;
bool notFound;
int code;
int j = 0;
for (unsigned int i=0; i < s->length(); i++) {
unsigned char c = s->at(i);
if (c > 0x7F) { //need to decode
result += s->substr(j,i-j);
std::string part1 = s->substr(i,4);
int l;
code = decodeNum(part1, &l);
j = i+l;
i = j - 1;
notFound = true;
for (int k=0; k<cpLenght; k++){
if(table[k] == code) {
result += CPOFFSET + k; //translate from table
notFound = false;
break;
}
}
if (notFound)
result += decodeText(code);
}
}
result += s->substr(j);
return result;
}
std::string DRW_ConvTable::toUtf8(std::string *s) {
std::string res;
string::iterator it;
for ( it=s->begin() ; it < s->end(); it++ ) {
unsigned char c = *it;
if (c < 0x80) {
//check for \U+ encoded text
if (c == '\\') {
if (it+6 < s->end() && *(it+1) == 'U' && *(it+2) == '+') {
res += encodeText(std::string(it, it+7));
it +=6;
} else {
res +=c; //no \U+ encoded text write
}
} else
res +=c; //c!='\' ascii char write
} else {//end c < 0x80
res += encodeNum(table[c-0x80]); //translate from table
}
} //end for
return res;
}
std::string DRW_Converter::encodeText(std::string stmp){
int code;
#if defined(__APPLE__)
int Succeeded = sscanf (&( stmp.substr(3,4)[0]), "%x", &code );
if ( !Succeeded || Succeeded == EOF )
code = 0;
#else
std::istringstream sd(stmp.substr(3,4));
sd >> std::hex >> code;
#endif
return encodeNum(code);
}
std::string DRW_Converter::decodeText(int c){
std::string res = "\\U+";
std::string num;
#if defined(__APPLE__)
std::string str(16, '\0');
snprintf (&(str[0]), 16, "%04X", c );
num = str;
#else
std::stringstream ss;
ss << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << c;
ss >> num;
#endif
res += num;
return res;
}
std::string DRW_Converter::encodeNum(int c){
unsigned char ret[5];
if (c < 128) { // 0-7F US-ASCII 7 bits
ret[0] = c;
ret[1] = 0;
} else if (c < 0x800) { //80-07FF 2 bytes
ret[0] = 0xC0 | (c >> 6);
ret[1] = 0x80 | (c & 0x3f);
ret[2] = 0;
} else if (c< 0x10000) { //800-FFFF 3 bytes
ret[0] = 0xe0 | (c >> 12);
ret[1] = 0x80 | ((c >> 6) & 0x3f);
ret[2] = 0x80 | (c & 0x3f);
ret[3] = 0;
} else { //10000-10FFFF 4 bytes
ret[0] = 0xf0 | (c >> 18);
ret[1] = 0x80 | ((c >> 12) & 0x3f);
ret[2] = 0x80 | ((c >> 6) & 0x3f);
ret[3] = 0x80 | (c & 0x3f);
ret[4] = 0;
}
return std::string((char*)ret);
}
/** 's' is a string with at least 4 bytes lenght
** returned 'b' is byte lenght of encoded char: 2,3 or 4
**/
int DRW_Converter::decodeNum(std::string s, int *b){
int code= 0;
unsigned char c = s.at(0);
if ( (c& 0xE0) == 0xC0) { //2 bytes
code = ( c&0x1F)<<6;
code = (s.at(1) &0x3F) | code;
*b = 2;
} else if ( (c& 0xF0) == 0xE0) { //3 bytes
code = ( c&0x0F)<<12;
code = ((s.at(1) &0x3F)<<6) | code;
code = (s.at(2) &0x3F) | code;
*b = 3;
} else if ( (c& 0xF8) == 0xF0) { //4 bytes
code = ( c&0x07)<<18;
code = ((s.at(1) &0x3F)<<12) | code;
code = ((s.at(2) &0x3F)<<6) | code;
code = (s.at(3) &0x3F) | code;
*b = 4;
}
return code;
}
std::string DRW_ConvDBCSTable::fromUtf8(std::string *s) {
std::string result;
bool notFound;
int code;
int j = 0;
for (unsigned int i=0; i < s->length(); i++) {
unsigned char c = s->at(i);
if (c > 0x7F) { //need to decode
result += s->substr(j,i-j);
std::string part1 = s->substr(i,4);
int l;
code = decodeNum(part1, &l);
j = i+l;
i = j - 1;
notFound = true;
for (int k=0; k<cpLenght; k++){
if(doubleTable[k][1] == code) {
int data = doubleTable[k][0];
char d[3];
d[0] = data >> 8;
d[1] = data & 0xFF;
d[2]= '\0';
result += d; //translate from table
notFound = false;
break;
}
}
if (notFound)
result += decodeText(code);
} //direct conversion
}
result += s->substr(j);
return result;
}
std::string DRW_ConvDBCSTable::toUtf8(std::string *s) {
std::string res;
string::iterator it;
for ( it=s->begin() ; it < s->end(); it++ ) {
bool notFound = true;
unsigned char c = *it;
if (c < 0x80) {
notFound = false;
//check for \U+ encoded text
if (c == '\\') {
if (it+6 < s->end() && *(it+1) == 'U' && *(it+2) == '+') {
res += encodeText(std::string(it, it+7));
it +=6;
} else {
res +=c; //no \U+ encoded text write
}
} else
res +=c; //c!='\' ascii char write
} else if(c == 0x80 ){//1 byte table
notFound = false;
res += encodeNum(0x20AC);//euro sign
} else {//2 bytes
++it;
int code = (c << 8) | (unsigned char )(*it);
int sta = leadTable[c-0x81];
int end = leadTable[c-0x80];
for (int k=sta; k<end; k++){
if(doubleTable[k][0] == code) {
res += encodeNum(doubleTable[k][1]); //translate from table
notFound = false;
break;
}
}
}
//not found
if (notFound) res += encodeNum(NOTFOUND936);
} //end for
return res;
}
std::string DRW_Conv932Table::fromUtf8(std::string *s) {
std::string result;
bool notFound;
int code;
int j = 0;
for (unsigned int i=0; i < s->length(); i++) {
unsigned char c = s->at(i);
if (c > 0x7F) { //need to decode
result += s->substr(j,i-j);
std::string part1 = s->substr(i,4);
int l;
code = decodeNum(part1, &l);
j = i+l;
i = j - 1;
notFound = true;
// 1 byte table
if (code > 0xff60 && code < 0xFFA0) {
result += code - CPOFFSET932; //translate from table
notFound = false;
}
if (notFound && ( code<0xF8 || (code>0x390 && code<0x542) ||
(code>0x200F && code<0x9FA1) || code>0xF928 )) {
for (int k=0; k<cpLenght; k++){
if(doubleTable[k][1] == code) {
int data = doubleTable[k][0];
char d[3];
d[0] = data >> 8;
d[1] = data & 0xFF;
d[2]= '\0';
result += d; //translate from table
notFound = false;
break;
}
}
}
if (notFound)
result += decodeText(code);
} //direct conversion
}
result += s->substr(j);
return result;
}
std::string DRW_Conv932Table::toUtf8(std::string *s) {
std::string res;
string::iterator it;
for ( it=s->begin() ; it < s->end(); it++ ) {
bool notFound = true;
unsigned char c = *it;
if (c < 0x80) {
notFound = false;
//check for \U+ encoded text
if (c == '\\') {
if (it+6 < s->end() && *(it+1) == 'U' && *(it+2) == '+') {
res += encodeText(std::string(it, it+7));
it +=6;
} else {
res +=c; //no \U+ encoded text write
}
} else
res +=c; //c!='\' ascii char write
} else if(c > 0xA0 && c < 0xE0 ){//1 byte table
notFound = false;
res += encodeNum(c + CPOFFSET932); //translate from table
} else {//2 bytes
++it;
int code = (c << 8) | (unsigned char )(*it);
int sta;
int end=0;
if (c > 0x80 && c < 0xA0) {
sta = DRW_LeadTable932[c-0x81];
end = DRW_LeadTable932[c-0x80];
} else if (c > 0xDF && c < 0xFD){
sta = DRW_LeadTable932[c-0xC1];
end = DRW_LeadTable932[c-0xC0];
}
if (end > 0) {
for (int k=sta; k<end; k++){
if(DRW_DoubleTable932[k][0] == code) {
res += encodeNum(DRW_DoubleTable932[k][1]); //translate from table
notFound = false;
break;
}
}
}
}
//not found
if (notFound) res += encodeNum(NOTFOUND932);
} //end for
return res;
}
std::string DRW_TextCodec::correctCodePage(const std::string& s) {
//stringstream cause crash in OS/X, bug#3597944
std::string cp=s;
transform(cp.begin(), cp.end(), cp.begin(), toupper);
//Latin/Thai
if (cp=="ANSI_874" || cp=="CP874" || cp=="ISO8859-11" || cp=="TIS-620") {
return "ANSI_874";
//Central Europe and Eastern Europe
} else if (cp=="ANSI_1250" || cp=="CP1250" || cp=="ISO8859-2") {
return "ANSI_1250";
//Cyrillic script
} else if (cp=="ANSI_1251" || cp=="CP1251" || cp=="ISO8859-5" || cp=="KOI8-R" ||
cp=="KOI8-U" || cp=="IBM 866") {
return "ANSI_1251";
//Western Europe
} else if (cp=="ANSI_1252" || cp=="CP1252" || cp=="LATIN1" || cp=="ISO-8859-1" ||
cp=="CP819" || cp=="CSISO" || cp=="IBM819" || cp=="ISO_8859-1" || cp=="APPLE ROMAN" ||
cp=="ISO8859-1" || cp=="ISO8859-15" || cp=="ISO-IR-100" || cp=="L1" || cp=="IBM 850") {
return "ANSI_1252";
//Greek
} else if (cp=="ANSI_1253" || cp=="CP1253" || cp=="iso8859-7") {
return "ANSI_1253";
//Turkish
} else if (cp=="ANSI_1254" || cp=="CP1254" || cp=="iso8859-9" || cp=="iso8859-3") {
return "ANSI_1254";
//Hebrew
} else if (cp=="ANSI_1255" || cp=="CP1255" || cp=="iso8859-8") {
return "ANSI_1255";
//Arabic
} else if (cp=="ANSI_1256" || cp=="CP1256" || cp=="ISO8859-6") {
return "ANSI_1256";
//Baltic
} else if (cp=="ANSI_1257" || cp=="CP1257" || cp=="ISO8859-4" || cp=="ISO8859-10" || cp=="ISO8859-13") {
return "ANSI_1257";
//Vietnamese
} else if (cp=="ANSI_1258" || cp=="CP1258") {
return "ANSI_1258";
//Japanese
} else if (cp=="ANSI_932" || cp=="SHIFT-JIS" || cp=="SHIFT_JIS" || cp=="CSSHIFTJIS" ||
cp=="CSWINDOWS31J" || cp=="MS_KANJI" || cp=="X-MS-CP932" || cp=="X-SJIS" ||
cp=="EUCJP" || cp=="EUC-JP" || cp=="CSEUCPKDFMTJAPANESE" || cp=="X-EUC" ||
cp=="X-EUC-JP" || cp=="JIS7") {
return "ANSI_932";
//Chinese PRC GBK (XGB) simplified
} else if (cp=="ANSI_936" || cp=="GBK" || cp=="GB2312" || cp=="CHINESE" || cp=="CN-GB" ||
cp=="CSGB2312" || cp=="CSGB231280" || cp=="CSISO58BG231280" ||
cp=="GB_2312-80" || cp=="GB231280" || cp=="GB2312-80" || cp=="GBK" ||
cp=="ISO-IR-58" || cp=="GB18030") {
return "ANSI_936";
//Korean
} else if (cp=="ANSI_949" || cp=="EUCKR") {
return "ANSI_949";
//Chinese Big5 (Taiwan, Hong Kong SAR)
} else if (cp=="ANSI_950" || cp=="BIG5" || cp=="CN-BIG5" || cp=="CSBIG5" ||
cp=="X-X-BIG5" || cp=="BIG5-HKSCS") {
return "ANSI_950";
//celtic
/* } else if (cp=="ISO8859-14") {
return "ISO8859-14";
} else if (cp=="TSCII") {
return "TSCII"; //tamil
} else if (cp=="UTF16") {
return "UTF16"; */
} else if (cp=="UTF-8" || cp=="UTF8" || cp=="UTF88-BIT") {
return "UTF-8";
}
return "ANSI_1252";
}
#ifndef DRW_TEXTCODEC_H
#define DRW_TEXTCODEC_H
#include <string>
class DRW_Converter;
class DRW_TextCodec
{
public:
DRW_TextCodec();
~DRW_TextCodec();
std::string fromUtf8(std::string s);
std::string toUtf8(std::string s);
int getVersion(){return version;}
void setVersion(std::string *v);
void setVersion(int v){version = v;}
void setCodePage(std::string *c);
void setCodePage(std::string c){setCodePage(&c);}
std::string getCodePage(){return cp;}
private:
std::string correctCodePage(const std::string& s);
private:
int version;
std::string cp;
DRW_Converter *conv;
};
class DRW_Converter
{
public:
DRW_Converter(const int *t, int l){table = t;
cpLenght = l;}
virtual ~DRW_Converter(){}
virtual std::string fromUtf8(std::string *s) {return *s;}
virtual std::string toUtf8(std::string *s);
std::string encodeText(std::string stmp);
std::string decodeText(int c);
std::string encodeNum(int c);
int decodeNum(std::string s, int *b);
const int *table;
int cpLenght;
};
class DRW_ConvTable : public DRW_Converter {
public:
DRW_ConvTable(const int *t, int l):DRW_Converter(t, l) {}
virtual std::string fromUtf8(std::string *s);
virtual std::string toUtf8(std::string *s);
};
class DRW_ConvDBCSTable : public DRW_Converter {
public:
DRW_ConvDBCSTable(const int *t, const int *lt, const int dt[][2], int l):DRW_Converter(t, l) {
leadTable = lt;
doubleTable = dt;
}
virtual std::string fromUtf8(std::string *s);
virtual std::string toUtf8(std::string *s);
private:
const int *leadTable;
const int (*doubleTable)[2];
};
class DRW_Conv932Table : public DRW_Converter {
public:
DRW_Conv932Table(const int *t, const int *lt, const int dt[][2], int l):DRW_Converter(t, l) {
leadTable = lt;
doubleTable = dt;
}
virtual std::string fromUtf8(std::string *s);
virtual std::string toUtf8(std::string *s);
private:
const int *leadTable;
const int (*doubleTable)[2];
};
#endif // DRW_TEXTCODEC_H
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#include <stdlib.h>
#include <fstream>
#include <string>
#include <sstream>
#include "dxfreader.h"
#include "drw_textcodec.h"
#ifdef DRW_DBG
#include <iostream> //for debug
#define DBG(a) std::cerr << a
#else
#define DBG(a)
#endif
bool dxfReader::readRec(int *codeData, bool skip) {
// std::string text;
int code;
#ifdef DRW_DBG
count = count+2; //DBG
/* if (count > 10250)
DBG("line 10256");*/
#endif
if (!readCode(&code))
return false;
*codeData = code;
if (code < 10)
readString();
else if (code < 60)
readDouble();
else if (code < 80)
readInt();
else if (code > 89 && code < 100) //TODO this is an int 32b
readInt32();
else if (code == 100 || code == 102 || code == 105)
readString();
else if (code > 109 && code < 150) //skip not used at the v2012
readDouble();
else if (code > 159 && code < 170) //skip not used at the v2012
readInt64();
else if (code < 180)
readInt();
else if (code > 209 && code < 240) //skip not used at the v2012
readDouble();
else if (code > 269 && code < 290) //skip not used at the v2012
readInt();
else if (code < 300) //TODO this is a boolean indicator, int in Binary?
readBool();
else if (code < 370)
readString();
else if (code < 390)
readInt();
else if (code < 400)
readString();
else if (code < 410)
readInt();
else if (code < 420)
readString();
else if (code < 430) //TODO this is an int 32b
readInt32();
else if (code < 440)
readString();
else if (code < 450) //TODO this is an int 32b
readInt32();
else if (code < 460) //TODO this is long??
readInt();
else if (code < 470) //TODO this is a floating point double precision??
readDouble();
else if (code < 481)
readString();
else if (code > 998 && code < 1009) //skip not used at the v2012
readString();
else if (code < 1060) //TODO this is a floating point double precision??
readDouble();
else if (code < 1071)
readInt();
else if (code == 1071) //TODO this is an int 32b
readInt32();
else if (skip)
//skip safely this dxf entry ( ok for ascii dxf)
readString();
else
//break in binary files because the conduct is unpredictable
return false;
return (filestr->good());
}
int dxfReader::getHandleString(){
int res;
#if defined(__APPLE__)
int Succeeded = sscanf ( strData.c_str(), "%x", &res );
if ( !Succeeded || Succeeded == EOF )
res = 0;
#else
std::istringstream Convert(strData);
if ( !(Convert >> std::hex >>res) )
res = 0;
#endif
return res;
}
bool dxfReaderBinary::readCode(int *code) {
unsigned short *int16p;
char buffer[2];
filestr->read(buffer,2);
int16p = (unsigned short *) buffer;
//exist a 32bits int (code 90) with 2 bytes???
if ((*code == 90) && (*int16p>2000)){
DBG(*code); DBG(" de 16bits\n");
filestr->seekg(-4, std::ios_base::cur);
filestr->read(buffer,2);
int16p = (unsigned short *) buffer;
}
*code = *int16p;
DBG(*code); DBG("\n");
return (filestr->good());
}
bool dxfReaderBinary::readString() {
std::getline(*filestr, strData, '\0');
DBG(strData); DBG("\n");
return (filestr->good());
}
bool dxfReaderBinary::readString(std::string *text) {
std::getline(*filestr, *text, '\0');
DBG(*text); DBG("\n");
return (filestr->good());
}
bool dxfReaderBinary::readInt() {
char buffer[2];
filestr->read(buffer,2);
intData = (int)((buffer[1] << 8) | buffer[0]);
DBG(intData); DBG("\n");
return (filestr->good());
}
bool dxfReaderBinary::readInt32() {
unsigned int *int32p;
char buffer[4];
filestr->read(buffer,4);
int32p = (unsigned int *) buffer;
intData = *int32p;
DBG(intData); DBG("\n");
return (filestr->good());
}
bool dxfReaderBinary::readInt64() {
unsigned long long int *int64p; //64 bits integer pointer
char buffer[8];
filestr->read(buffer,8);
int64p = (unsigned long long int *) buffer;
int64 = *int64p;
DBG(int64); DBG(" int64\n");
return (filestr->good());
}
bool dxfReaderBinary::readDouble() {
double *result;
char buffer[8];
filestr->read(buffer,8);
result = (double *) buffer;
doubleData = *result;
DBG(doubleData); DBG("\n");
return (filestr->good());
}
//saved as int or add a bool member??
bool dxfReaderBinary::readBool() {
char buffer[1];
filestr->read(buffer,1);
intData = (int)(buffer[0]);
DBG(intData); DBG("\n");
return (filestr->good());
}
bool dxfReaderAscii::readCode(int *code) {
std::string text;
std::getline(*filestr, text);
*code = atoi(text.c_str());
DBG(*code); DBG("\n");
return (filestr->good());
}
bool dxfReaderAscii::readString(std::string *text) {
std::getline(*filestr, *text);
if (!text->empty() && text->at(text->size()-1) == '\r')
text->erase(text->size()-1);
return (filestr->good());
}
bool dxfReaderAscii::readString() {
std::getline(*filestr, strData);
if (!strData.empty() && strData.at(strData.size()-1) == '\r')
strData.erase(strData.size()-1);
DBG(strData); DBG("\n");
return (filestr->good());
}
bool dxfReaderAscii::readInt() {
std::string text;
if (readString(&text)){
intData = atoi(text.c_str());
DBG(intData); DBG("\n");
return true;
} else
return false;
}
bool dxfReaderAscii::readInt32() {
return readInt();
}
bool dxfReaderAscii::readInt64() {
return readInt();
}
bool dxfReaderAscii::readDouble() {
std::string text;
if (readString(&text)){
#if defined(__APPLE__)
int succeeded=sscanf( & (text[0]), "%lg", &doubleData);
if(succeeded != 1) {
DBG("dxfReaderAscii::readDouble(): reading double error: ");
DBG(text);
DBG('\n');
}
#else
std::istringstream sd(text);
sd >> doubleData;
DBG(doubleData); DBG('\n');
#endif
return true;
} else
return false;
}
//saved as int or add a bool member??
bool dxfReaderAscii::readBool() {
std::string text;
if (readString(&text)){
intData = atoi(text.c_str());
DBG(intData); DBG("\n");
return true;
} else
return false;
}
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#ifndef DXFREADER_H
#define DXFREADER_H
#include "drw_textcodec.h"
class dxfReader {
public:
dxfReader(std::ifstream *stream){
filestr = stream;
#ifdef DRW_DBG
count =0;
#endif
}
virtual ~dxfReader(){}
virtual bool readCode(int *code) = 0; //return true if sucesful (not EOF)
virtual bool readString(std::string *text) = 0;
virtual bool readString() = 0;
bool readRec(int *code, bool skip);
virtual bool readInt() = 0;
virtual bool readInt32() = 0;
virtual bool readInt64() = 0;
virtual bool readDouble() = 0;
virtual bool readBool() = 0;
std::string getString() {return strData;}
int getHandleString();//Convert hex string to int
std::string toUtf8String(std::string t) {return decoder.toUtf8(t);}
std::string getUtf8String() {return decoder.toUtf8(strData);}
double getDouble() {return doubleData;}
int getInt32() {return intData;}
unsigned long long int getInt64() {return int64;}
bool getBool() { return (intData==0) ? false : true;}
int getVersion(){return decoder.getVersion();}
void setVersion(std::string *v){decoder.setVersion(v);}
void setCodePage(std::string *c){decoder.setCodePage(c);}
std::string getCodePage(){ return decoder.getCodePage();}
#ifdef DRW_DBG
int count;//DBG
#endif
protected:
std::ifstream *filestr;
std::string strData;
double doubleData;
signed short intData; //16 bits integer
unsigned long long int int64; //64 bits integer
private:
DRW_TextCodec decoder;
};
class dxfReaderBinary : public dxfReader {
public:
dxfReaderBinary(std::ifstream *stream):dxfReader(stream){ }
virtual ~dxfReaderBinary() {}
virtual bool readCode(int *code);
virtual bool readString(std::string *text);
virtual bool readString();
virtual bool readInt();
virtual bool readInt32();
virtual bool readInt64();
virtual bool readDouble();
virtual bool readBool();
};
class dxfReaderAscii : public dxfReader {
public:
dxfReaderAscii(std::ifstream *stream):dxfReader(stream){ }
virtual ~dxfReaderAscii(){}
virtual bool readCode(int *code);
virtual bool readString(std::string *text);
virtual bool readString();
virtual bool readInt();
virtual bool readDouble();
virtual bool readInt32();
virtual bool readInt64();
virtual bool readBool();
};
#endif // DXFREADER_H
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#include <stdlib.h>
#include <fstream>
#include <string>
#include <algorithm>
#include "dxfwriter.h"
#ifdef DRW_DBG
#include <iostream> //for debug
#define DBG(a) std::cerr << a
#else
#define DBG(a)
#endif
//RLZ TODO change std::endl to x0D x0A (13 10)
/*bool dxfWriter::readRec(int *codeData, bool skip) {
// std::string text;
int code;
#ifdef DRW_DBG
count = count+2; //DBG
#endif
if (!readCode(&code))
return false;
*codeData = code;
if (code < 10)
readString();
else if (code < 60)
readDouble();
else if (code < 80)
readInt();
else if (code > 89 && code < 100) //TODO this is an int 32b
readInt32();
else if (code == 100 || code == 102 || code == 105)
readString();
else if (code > 109 && code < 150) //skip not used at the v2012
readDouble();
else if (code > 159 && code < 170) //skip not used at the v2012
readInt64();
else if (code < 180)
readInt();
else if (code > 209 && code < 240) //skip not used at the v2012
readDouble();
else if (code > 269 && code < 290) //skip not used at the v2012
readInt();
else if (code < 300) //TODO this is a boolean indicator, int in Binary?
readBool();
else if (code < 370)
readString();
else if (code < 390)
readInt();
else if (code < 400)
readString();
else if (code < 410)
readInt();
else if (code < 420)
readString();
else if (code < 430) //TODO this is an int 32b
readInt32();
else if (code < 440)
readString();
else if (code < 450) //TODO this is an int 32b
readInt32();
else if (code < 460) //TODO this is long??
readInt();
else if (code < 470) //TODO this is a floating point double precision??
readDouble();
else if (code < 481)
readString();
else if (code > 998 && code < 1009) //skip not used at the v2012
readString();
else if (code < 1060) //TODO this is a floating point double precision??
readDouble();
else if (code < 1071)
readInt();
else if (code == 1071) //TODO this is an int 32b
readInt32();
else if (skip)
//skip safely this dxf entry ( ok for ascii dxf)
readString();
else
//break in binary files because the conduct is unpredictable
return false;
return (filestr->good());
}*/
bool dxfWriter::writeUtf8String(int code, std::string text) {
std::string t = encoder.fromUtf8(text);
return writeString(code, t);
}
bool dxfWriter::writeUtf8Caps(int code, std::string text) {
std::string strname = text;
std::transform(strname.begin(), strname.end(), strname.begin(),::toupper);
std::string t = encoder.fromUtf8(strname);
return writeString(code, t);
}
bool dxfWriterBinary::writeString(int code, std::string text) {
char bufcode[2];
bufcode[0] =code & 0xFF;
bufcode[1] =code >> 8;
filestr->write(bufcode, 2);
*filestr << text << '\0';
return (filestr->good());
}
/*bool dxfWriterBinary::readCode(int *code) {
unsigned short *int16p;
char buffer[2];
filestr->read(buffer,2);
int16p = (unsigned short *) buffer;
//exist a 32bits int (code 90) with 2 bytes???
if ((*code == 90) && (*int16p>2000)){
DBG(*code); DBG(" de 16bits\n");
filestr->seekg(-4, std::ios_base::cur);
filestr->read(buffer,2);
int16p = (unsigned short *) buffer;
}
*code = *int16p;
DBG(*code); DBG("\n");
return (filestr->good());
}*/
/*bool dxfWriterBinary::readString() {
std::getline(*filestr, strData, '\0');
DBG(strData); DBG("\n");
return (filestr->good());
}*/
/*bool dxfWriterBinary::readString(std::string *text) {
std::getline(*filestr, *text, '\0');
DBG(*text); DBG("\n");
return (filestr->good());
}*/
bool dxfWriterBinary::writeInt16(int code, int data) {
char bufcode[2];
char buffer[2];
bufcode[0] =code & 0xFF;
bufcode[1] =code >> 8;
buffer[0] =data & 0xFF;
buffer[1] =data >> 8;
filestr->write(bufcode, 2);
filestr->write(buffer, 2);
return (filestr->good());
}
bool dxfWriterBinary::writeInt32(int code, int data) {
char buffer[4];
buffer[0] =code & 0xFF;
buffer[1] =code >> 8;
filestr->write(buffer, 2);
buffer[0] =data & 0xFF;
buffer[1] =data >> 8;
buffer[2] =data >> 16;
buffer[3] =data >> 24;
filestr->write(buffer, 4);
return (filestr->good());
}
bool dxfWriterBinary::writeInt64(int code, unsigned long long int data) {
char buffer[8];
buffer[0] =code & 0xFF;
buffer[1] =code >> 8;
filestr->write(buffer, 2);
buffer[0] =data & 0xFF;
buffer[1] =data >> 8;
buffer[2] =data >> 16;
buffer[3] =data >> 24;
buffer[4] =data >> 32;
buffer[5] =data >> 40;
buffer[6] =data >> 48;
buffer[7] =data >> 56;
filestr->write(buffer, 8);
return (filestr->good());
}
bool dxfWriterBinary::writeDouble(int code, double data) {
char bufcode[2];
char buffer[8];
bufcode[0] =code & 0xFF;
bufcode[1] =code >> 8;
filestr->write(bufcode, 2);
unsigned char *val;
val = (unsigned char *) &data;
for (int i=0; i<8; i++) {
buffer[i] =val[i];
}
filestr->write(buffer, 8);
return (filestr->good());
}
//saved as int or add a bool member??
bool dxfWriterBinary::writeBool(int code, bool data) {
char buffer[1];
char bufcode[2];
bufcode[0] =code & 0xFF;
bufcode[1] =code >> 8;
filestr->write(bufcode, 2);
buffer[0] = data;
filestr->write(buffer, 1);
return (filestr->good());
}
bool dxfWriterAscii::writeString(int code, std::string text) {
*filestr << code << std::endl << text << std::endl ;
/* std::getline(*filestr, strData, '\0');
DBG(strData); DBG("\n");*/
return (filestr->good());
}
/*bool dxfWriterAscii::readCode(int *code) {
std::string text;
std::getline(*filestr, text);
*code = atoi(text.c_str());
DBG(*code); DBG("\n");
return (filestr->good());
}*/
/*bool dxfWriterAscii::readString(std::string *text) {
std::getline(*filestr, *text);
if (text->at(text->size()-1) == '\r')
text->erase(text->size()-1);
return (filestr->good());
}*/
/*bool dxfWriterAscii::readString() {
std::getline(*filestr, strData);
if (strData.at(strData.size()-1) == '\r')
strData.erase(strData.size()-1);
DBG(strData); DBG("\n");
return (filestr->good());
}*/
bool dxfWriterAscii::writeInt16(int code, int data) {
// *filestr << code << "\r\n" << data << "\r\n";
*filestr << code << std::endl << data << std::endl;
return (filestr->good());
}
bool dxfWriterAscii::writeInt32(int code, int data) {
return writeInt16(code, data);
}
bool dxfWriterAscii::writeInt64(int code, unsigned long long int data) {
*filestr << code << std::endl << data << std::endl;
return (filestr->good());
}
bool dxfWriterAscii::writeDouble(int code, double data) {
std::streamsize prec = filestr->precision();
filestr->precision(12);
*filestr << code << std::endl << data << std::endl;
filestr->precision(prec);
return (filestr->good());
}
//saved as int or add a bool member??
bool dxfWriterAscii::writeBool(int code, bool data) {
*filestr << code << std::endl << data << std::endl;
return (filestr->good());
}
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#ifndef DXFWRITER_H
#define DXFWRITER_H
#include "drw_textcodec.h"
class dxfWriter {
public:
dxfWriter(std::ofstream *stream){filestr = stream; /*count =0;*/}
virtual ~dxfWriter(){}
virtual bool writeString(int code, std::string text) = 0;
bool writeUtf8String(int code, std::string text);
bool writeUtf8Caps(int code, std::string text);
std::string fromUtf8String(std::string t) {return encoder.fromUtf8(t);}
virtual bool writeInt16(int code, int data) = 0;
virtual bool writeInt32(int code, int data) = 0;
virtual bool writeInt64(int code, unsigned long long int data) = 0;
virtual bool writeDouble(int code, double data) = 0;
virtual bool writeBool(int code, bool data) = 0;
void setVersion(std::string *v){encoder.setVersion(v);}
void setCodePage(std::string *c){encoder.setCodePage(c);}
std::string getCodePage(){return encoder.getCodePage();}
protected:
std::ofstream *filestr;
private:
DRW_TextCodec encoder;
};
class dxfWriterBinary : public dxfWriter {
public:
dxfWriterBinary(std::ofstream *stream):dxfWriter(stream){ }
virtual ~dxfWriterBinary() {}
virtual bool writeString(int code, std::string text);
virtual bool writeInt16(int code, int data);
virtual bool writeInt32(int code, int data);
virtual bool writeInt64(int code, unsigned long long int data);
virtual bool writeDouble(int code, double data);
virtual bool writeBool(int code, bool data);
};
class dxfWriterAscii : public dxfWriter {
public:
dxfWriterAscii(std::ofstream *stream):dxfWriter(stream){ }
virtual ~dxfWriterAscii(){}
virtual bool writeString(int code, std::string text);
virtual bool writeInt16(int code, int data);
virtual bool writeInt32(int code, int data);
virtual bool writeInt64(int code, unsigned long long int data);
virtual bool writeDouble(int code, double data);
virtual bool writeBool(int code, bool data);
};
#endif // DXFWRITER_H
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#include "libdxfrw.h"
#include <fstream>
#include <algorithm>
#include <sstream>
#include "intern/drw_textcodec.h"
#include "intern/dxfreader.h"
#include "intern/dxfwriter.h"
#include <assert.h>
#ifdef DRW_DBG
#include <iostream> // for debug
#define DBG( a ) std::cerr << a
#else
#define DBG( a )
#endif
#define FIRSTHANDLE 48
/*enum sections {
* secUnknown,
* secHeader,
* secTables,
* secBlocks,
* secEntities,
* secObjects
* };*/
dxfRW::dxfRW( const char* name )
{
fileName = name;
reader = NULL;
writer = NULL;
applyExt = false;
elParts = 128; // parts munber when convert ellipse to polyline
}
dxfRW::~dxfRW()
{
if( reader != NULL )
delete reader;
}
bool dxfRW::read( DRW_Interface* interface_, bool ext )
{
assert( fileName.empty() == false );
bool isOk = false;
applyExt = ext;
std::ifstream filestr;
if( interface_ == NULL )
return isOk;
DBG( "dxfRW::read 1def\n" );
filestr.open( fileName.c_str(), std::ios_base::in | std::ios::binary );
if( !filestr.is_open() )
return isOk;
if( !filestr.good() )
return isOk;
char line[22];
char line2[22] = "AutoCAD Binary DXF\r\n";
line2[20] = (char) 26;
line2[21] = '\0';
filestr.read( line, 22 );
filestr.close();
iface = interface_;
DBG( "dxfRW::read 2\n" );
if( strcmp( line, line2 ) == 0 )
{
filestr.open( fileName.c_str(), std::ios_base::in | std::ios::binary );
binary = true;
// skip sentinel
filestr.seekg( 22, std::ios::beg );
reader = new dxfReaderBinary( &filestr );
DBG( "dxfRW::read binary file\n" );
}
else
{
binary = false;
filestr.open( fileName.c_str(), std::ios_base::in );
reader = new dxfReaderAscii( &filestr );
}
isOk = processDxf();
filestr.close();
delete reader;
reader = NULL;
return isOk;
}
bool dxfRW::write( DRW_Interface* interface_, DRW::Version ver, bool bin )
{
bool isOk = false;
std::ofstream filestr;
version = ver;
binary = bin;
iface = interface_;
if( binary )
{
filestr.open( fileName.c_str(), std::ios_base::out | std::ios::binary | std::ios::trunc );
// write sentinel
filestr << "AutoCAD Binary DXF\r\n" << (char) 26 << '\0';
writer = new dxfWriterBinary( &filestr );
DBG( "dxfRW::read binary file\n" );
}
else
{
filestr.open( fileName.c_str(), std::ios_base::out | std::ios::trunc );
writer = new dxfWriterAscii( &filestr );
std::string comm = std::string( "dxfrw " ) + std::string( DRW_VERSION );
writer->writeString( 999, comm );
}
DRW_Header header;
iface->writeHeader( header );
writer->writeString( 0, "SECTION" );
entCount = FIRSTHANDLE;
header.write( writer, version );
writer->writeString( 0, "ENDSEC" );
writer->writeString( 0, "SECTION" );
writer->writeString( 2, "CLASSES" );
writer->writeString( 0, "ENDSEC" );
writer->writeString( 0, "SECTION" );
writer->writeString( 2, "TABLES" );
writeTables();
writer->writeString( 0, "ENDSEC" );
writer->writeString( 0, "SECTION" );
writer->writeString( 2, "BLOCKS" );
writeBlocks();
writer->writeString( 0, "ENDSEC" );
writer->writeString( 0, "SECTION" );
writer->writeString( 2, "ENTITIES" );
iface->writeEntities();
writer->writeString( 0, "ENDSEC" );
if( version > DRW::AC1009 )
{
writer->writeString( 0, "SECTION" );
writer->writeString( 2, "OBJECTS" );
writeObjects();
writer->writeString( 0, "ENDSEC" );
}
writer->writeString( 0, "EOF" );
filestr.flush();
filestr.close();
isOk = true;
delete writer;
writer = NULL;
return isOk;
}
bool dxfRW::writeEntity( DRW_Entity* ent )
{
ent->handle = ++entCount;
writer->writeString( 5, toHexStr( ent->handle ) );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbEntity" );
}
if( ent->space == 1 )
writer->writeInt16( 67, 1 );
if( version > DRW::AC1009 )
{
writer->writeUtf8String( 8, ent->layer );
writer->writeUtf8String( 6, ent->lineType );
}
else
{
writer->writeUtf8Caps( 8, ent->layer );
writer->writeUtf8Caps( 6, ent->lineType );
}
writer->writeInt16( 62, ent->color );
if( version > DRW::AC1015 && ent->color24 >= 0 )
{
writer->writeInt32( 420, ent->color24 );
}
if( version > DRW::AC1014 )
{
writer->writeInt16( 370, DRW_LW_Conv::lineWidth2dxfInt( ent->lWeight ) );
}
return true;
}
bool dxfRW::writeLineType( DRW_LType* ent )
{
string strname = ent->name;
transform( strname.begin(), strname.end(), strname.begin(), ::toupper );
// do not write linetypes handled by library
if( strname == "BYLAYER" || strname == "BYBLOCK" || strname == "CONTINUOUS" )
{
return true;
}
writer->writeString( 0, "LTYPE" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, toHexStr( ++entCount ) );
if( version > DRW::AC1012 )
{
writer->writeString( 330, "5" );
}
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbLinetypeTableRecord" );
writer->writeUtf8String( 2, ent->name );
}
else
writer->writeUtf8Caps( 2, ent->name );
writer->writeInt16( 70, ent->flags );
writer->writeUtf8String( 3, ent->desc );
ent->update();
writer->writeInt16( 72, 65 );
writer->writeInt16( 73, ent->size );
writer->writeDouble( 40, ent->length );
for( unsigned int i = 0; i< ent->path.size(); i++ )
{
writer->writeDouble( 49, ent->path.at( i ) );
if( version > DRW::AC1009 )
{
writer->writeInt16( 74, 0 );
}
}
return true;
}
bool dxfRW::writeLayer( DRW_Layer* ent )
{
writer->writeString( 0, "LAYER" );
if( !wlayer0 && ent->name == "0" )
{
wlayer0 = true;
if( version > DRW::AC1009 )
{
writer->writeString( 5, "10" );
}
}
else
{
if( version > DRW::AC1009 )
{
writer->writeString( 5, toHexStr( ++entCount ) );
}
}
if( version > DRW::AC1012 )
{
writer->writeString( 330, "2" );
}
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbLayerTableRecord" );
writer->writeUtf8String( 2, ent->name );
}
else
{
writer->writeUtf8Caps( 2, ent->name );
}
writer->writeInt16( 70, ent->flags );
writer->writeInt16( 62, ent->color );
if( version > DRW::AC1015 && ent->color24 >= 0 )
{
writer->writeInt32( 420, ent->color24 );
}
if( version > DRW::AC1009 )
{
writer->writeUtf8String( 6, ent->lineType );
if( !ent->plotF )
writer->writeBool( 290, ent->plotF );
writer->writeInt16( 370, DRW_LW_Conv::lineWidth2dxfInt( ent->lWeight ) );
writer->writeString( 390, "F" );
}
else
writer->writeUtf8Caps( 6, ent->lineType );
// writer->writeString(347, "10012");
return true;
}
bool dxfRW::writeTextstyle( DRW_Textstyle* ent )
{
writer->writeString( 0, "STYLE" );
if( !dimstyleStd )
{
// stringstream cause crash in OS/X, bug#3597944
std::string name = ent->name;
transform( name.begin(), name.end(), name.begin(), toupper );
if( name == "STANDARD" )
dimstyleStd = true;
}
if( version > DRW::AC1009 )
{
writer->writeString( 5, toHexStr( ++entCount ) );
}
if( version > DRW::AC1012 )
{
writer->writeString( 330, "2" );
}
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbTextStyleTableRecord" );
writer->writeUtf8String( 2, ent->name );
}
else
{
writer->writeUtf8Caps( 2, ent->name );
}
writer->writeInt16( 70, ent->flags );
writer->writeDouble( 40, ent->height );
writer->writeDouble( 41, ent->width );
writer->writeDouble( 50, ent->oblique );
writer->writeInt16( 71, ent->genFlag );
writer->writeDouble( 42, ent->lastHeight );
if( version > DRW::AC1009 )
{
writer->writeUtf8String( 3, ent->font );
writer->writeUtf8String( 4, ent->bigFont );
if( ent->fontFamily != 0 )
writer->writeInt32( 1071, ent->fontFamily );
}
else
{
writer->writeUtf8Caps( 3, ent->font );
writer->writeUtf8Caps( 4, ent->bigFont );
}
return true;
}
bool dxfRW::writeVport( DRW_Vport* ent )
{
if( !dimstyleStd )
{
ent->name = "*ACTIVE";
dimstyleStd = true;
}
writer->writeString( 0, "VPORT" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, toHexStr( ++entCount ) );
if( version > DRW::AC1012 )
writer->writeString( 330, "2" );
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbViewportTableRecord" );
writer->writeUtf8String( 2, ent->name );
}
else
writer->writeUtf8Caps( 2, ent->name );
writer->writeInt16( 70, ent->flags );
writer->writeDouble( 10, ent->lowerLeft.x );
writer->writeDouble( 20, ent->lowerLeft.y );
writer->writeDouble( 11, ent->UpperRight.x );
writer->writeDouble( 21, ent->UpperRight.y );
writer->writeDouble( 12, ent->center.x );
writer->writeDouble( 22, ent->center.y );
writer->writeDouble( 13, ent->snapBase.x );
writer->writeDouble( 23, ent->snapBase.y );
writer->writeDouble( 14, ent->snapSpacing.x );
writer->writeDouble( 24, ent->snapSpacing.y );
writer->writeDouble( 15, ent->gridSpacing.x );
writer->writeDouble( 25, ent->gridSpacing.y );
writer->writeDouble( 16, ent->viewDir.x );
writer->writeDouble( 26, ent->viewDir.y );
writer->writeDouble( 36, ent->viewDir.z );
writer->writeDouble( 17, ent->viewTarget.z );
writer->writeDouble( 27, ent->viewTarget.z );
writer->writeDouble( 37, ent->viewTarget.z );
writer->writeDouble( 40, ent->height );
writer->writeDouble( 41, ent->ratio );
writer->writeDouble( 42, ent->lensHeight );
writer->writeDouble( 43, ent->frontClip );
writer->writeDouble( 44, ent->backClip );
writer->writeDouble( 50, ent->snapAngle );
writer->writeDouble( 51, ent->twistAngle );
writer->writeInt16( 71, ent->viewMode );
writer->writeInt16( 72, ent->circleZoom );
writer->writeInt16( 73, ent->fastZoom );
writer->writeInt16( 74, ent->ucsIcon );
writer->writeInt16( 75, ent->snap );
writer->writeInt16( 76, ent->grid );
writer->writeInt16( 77, ent->snapStyle );
writer->writeInt16( 78, ent->snapIsopair );
if( version > DRW::AC1014 )
{
writer->writeInt16( 281, 0 );
writer->writeInt16( 65, 1 );
writer->writeDouble( 110, 0.0 );
writer->writeDouble( 120, 0.0 );
writer->writeDouble( 130, 0.0 );
writer->writeDouble( 111, 1.0 );
writer->writeDouble( 121, 0.0 );
writer->writeDouble( 131, 0.0 );
writer->writeDouble( 112, 0.0 );
writer->writeDouble( 122, 1.0 );
writer->writeDouble( 132, 0.0 );
writer->writeInt16( 79, 0 );
writer->writeDouble( 146, 0.0 );
if( version > DRW::AC1018 )
{
writer->writeString( 348, "10020" );
writer->writeInt16( 60, ent->gridBehavior ); // v2007 undocummented see DRW_Vport class
writer->writeInt16( 61, 5 );
writer->writeBool( 292, 1 );
writer->writeInt16( 282, 1 );
writer->writeDouble( 141, 0.0 );
writer->writeDouble( 142, 0.0 );
writer->writeInt16( 63, 250 );
writer->writeInt32( 421, 3358443 );
}
}
return true;
}
bool dxfRW::writeDimstyle( DRW_Dimstyle* ent )
{
writer->writeString( 0, "DIMSTYLE" );
if( !dimstyleStd )
{
std::string name = ent->name;
std::transform( name.begin(), name.end(), name.begin(), ::toupper );
if( name == "STANDARD" )
dimstyleStd = true;
}
if( version > DRW::AC1009 )
{
writer->writeString( 105, toHexStr( ++entCount ) );
}
if( version > DRW::AC1012 )
{
writer->writeString( 330, "A" );
}
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbDimStyleTableRecord" );
writer->writeUtf8String( 2, ent->name );
}
else
writer->writeUtf8Caps( 2, ent->name );
writer->writeInt16( 70, ent->flags );
if( version == DRW::AC1009 || !( ent->dimpost.empty() ) )
writer->writeUtf8String( 3, ent->dimpost );
if( version == DRW::AC1009 || !( ent->dimapost.empty() ) )
writer->writeUtf8String( 4, ent->dimapost );
if( version == DRW::AC1009 || !( ent->dimblk.empty() ) )
writer->writeUtf8String( 5, ent->dimblk );
if( version == DRW::AC1009 || !( ent->dimblk1.empty() ) )
writer->writeUtf8String( 6, ent->dimblk1 );
if( version == DRW::AC1009 || !( ent->dimblk2.empty() ) )
writer->writeUtf8String( 7, ent->dimblk2 );
writer->writeDouble( 40, ent->dimscale );
writer->writeDouble( 41, ent->dimasz );
writer->writeDouble( 42, ent->dimexo );
writer->writeDouble( 43, ent->dimdli );
writer->writeDouble( 44, ent->dimexe );
writer->writeDouble( 45, ent->dimrnd );
writer->writeDouble( 46, ent->dimdle );
writer->writeDouble( 47, ent->dimtp );
writer->writeDouble( 48, ent->dimtm );
writer->writeDouble( 140, ent->dimtxt );
writer->writeDouble( 141, ent->dimcen );
writer->writeDouble( 142, ent->dimtsz );
writer->writeDouble( 143, ent->dimaltf );
writer->writeDouble( 144, ent->dimlfac );
writer->writeDouble( 145, ent->dimtvp );
writer->writeDouble( 146, ent->dimtfac );
writer->writeDouble( 147, ent->dimgap );
if( version > DRW::AC1014 )
{
writer->writeDouble( 148, ent->dimaltrnd );
}
writer->writeInt16( 71, ent->dimtol );
writer->writeInt16( 72, ent->dimlim );
writer->writeInt16( 73, ent->dimtih );
writer->writeInt16( 74, ent->dimtoh );
writer->writeInt16( 75, ent->dimse1 );
writer->writeInt16( 76, ent->dimse2 );
writer->writeInt16( 77, ent->dimtad );
writer->writeInt16( 78, ent->dimzin );
if( version > DRW::AC1014 )
{
writer->writeInt16( 79, ent->dimazin );
}
writer->writeInt16( 170, ent->dimalt );
writer->writeInt16( 171, ent->dimaltd );
writer->writeInt16( 172, ent->dimtofl );
writer->writeInt16( 173, ent->dimsah );
writer->writeInt16( 174, ent->dimtix );
writer->writeInt16( 175, ent->dimsoxd );
writer->writeInt16( 176, ent->dimclrd );
writer->writeInt16( 177, ent->dimclre );
writer->writeInt16( 178, ent->dimclrt );
if( version > DRW::AC1014 )
{
writer->writeInt16( 179, ent->dimadec );
}
if( version > DRW::AC1009 )
{
if( version < DRW::AC1015 )
writer->writeInt16( 270, ent->dimunit );
writer->writeInt16( 271, ent->dimdec );
writer->writeInt16( 272, ent->dimtdec );
writer->writeInt16( 273, ent->dimaltu );
writer->writeInt16( 274, ent->dimalttd );
writer->writeInt16( 275, ent->dimaunit );
}
if( version > DRW::AC1014 )
{
writer->writeInt16( 276, ent->dimfrac );
writer->writeInt16( 277, ent->dimlunit );
writer->writeInt16( 278, ent->dimdsep );
writer->writeInt16( 279, ent->dimtmove );
}
if( version > DRW::AC1009 )
{
writer->writeInt16( 280, ent->dimjust );
writer->writeInt16( 281, ent->dimsd1 );
writer->writeInt16( 282, ent->dimsd2 );
writer->writeInt16( 283, ent->dimtolj );
writer->writeInt16( 284, ent->dimtzin );
writer->writeInt16( 285, ent->dimaltz );
writer->writeInt16( 286, ent->dimaltttz );
if( version < DRW::AC1015 )
writer->writeInt16( 287, ent->dimfit );
writer->writeInt16( 288, ent->dimupt );
}
if( version > DRW::AC1014 )
{
writer->writeInt16( 289, ent->dimatfit );
}
if( version > DRW::AC1009 )
{
writer->writeUtf8String( 340, ent->dimtxsty );
}
if( version > DRW::AC1014 )
{
writer->writeUtf8String( 341, ent->dimldrblk );
writer->writeInt16( 371, ent->dimlwd );
writer->writeInt16( 372, ent->dimlwe );
}
return true;
}
bool dxfRW::writePoint( DRW_Point* ent )
{
writer->writeString( 0, "POINT" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbPoint" );
}
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
if( ent->basePoint.z != 0.0 )
{
writer->writeDouble( 30, ent->basePoint.z );
}
return true;
}
bool dxfRW::writeLine( DRW_Line* ent )
{
writer->writeString( 0, "LINE" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbLine" );
}
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
if( ent->basePoint.z != 0.0 || ent->secPoint.z != 0.0 )
{
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 11, ent->secPoint.x );
writer->writeDouble( 21, ent->secPoint.y );
writer->writeDouble( 31, ent->secPoint.z );
}
else
{
writer->writeDouble( 11, ent->secPoint.x );
writer->writeDouble( 21, ent->secPoint.y );
}
return true;
}
bool dxfRW::writeRay( DRW_Ray* ent )
{
writer->writeString( 0, "RAY" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbRay" );
}
DRW_Coord crd = ent->secPoint;
crd.unitize();
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
if( ent->basePoint.z != 0.0 || ent->secPoint.z != 0.0 )
{
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 11, crd.x );
writer->writeDouble( 21, crd.y );
writer->writeDouble( 31, crd.z );
}
else
{
writer->writeDouble( 11, crd.x );
writer->writeDouble( 21, crd.y );
}
return true;
}
bool dxfRW::writeXline( DRW_Xline* ent )
{
writer->writeString( 0, "XLINE" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbXline" );
}
DRW_Coord crd = ent->secPoint;
crd.unitize();
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
if( ent->basePoint.z != 0.0 || ent->secPoint.z != 0.0 )
{
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 11, crd.x );
writer->writeDouble( 21, crd.y );
writer->writeDouble( 31, crd.z );
}
else
{
writer->writeDouble( 11, crd.x );
writer->writeDouble( 21, crd.y );
}
return true;
}
bool dxfRW::writeCircle( DRW_Circle* ent )
{
writer->writeString( 0, "CIRCLE" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbCircle" );
}
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
if( ent->basePoint.z != 0.0 )
{
writer->writeDouble( 30, ent->basePoint.z );
}
writer->writeDouble( 40, ent->radious );
return true;
}
bool dxfRW::writeArc( DRW_Arc* ent )
{
writer->writeString( 0, "ARC" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbCircle" );
}
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
if( ent->basePoint.z != 0.0 )
{
writer->writeDouble( 30, ent->basePoint.z );
}
writer->writeDouble( 40, ent->radious );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbArc" );
}
writer->writeDouble( 50, ent->staangle * ARAD );
writer->writeDouble( 51, ent->endangle * ARAD );
return true;
}
bool dxfRW::writeEllipse( DRW_Ellipse* ent )
{
// verify axis/ratio and params for full ellipse
ent->correctAxis();
if( version > DRW::AC1009 )
{
writer->writeString( 0, "ELLIPSE" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbEllipse" );
}
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 11, ent->secPoint.x );
writer->writeDouble( 21, ent->secPoint.y );
writer->writeDouble( 31, ent->secPoint.z );
writer->writeDouble( 40, ent->ratio );
writer->writeDouble( 41, ent->staparam );
writer->writeDouble( 42, ent->endparam );
}
else
{
DRW_Polyline pol;
// RLZ: copy properties
ent->toPolyline( &pol, elParts );
writePolyline( &pol );
}
return true;
}
bool dxfRW::writeTrace( DRW_Trace* ent )
{
writer->writeString( 0, "TRACE" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbTrace" );
}
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 11, ent->secPoint.x );
writer->writeDouble( 21, ent->secPoint.y );
writer->writeDouble( 31, ent->secPoint.z );
writer->writeDouble( 12, ent->thirdPoint.x );
writer->writeDouble( 22, ent->thirdPoint.y );
writer->writeDouble( 32, ent->thirdPoint.z );
writer->writeDouble( 13, ent->fourPoint.x );
writer->writeDouble( 23, ent->fourPoint.y );
writer->writeDouble( 33, ent->fourPoint.z );
return true;
}
bool dxfRW::writeSolid( DRW_Solid* ent )
{
writer->writeString( 0, "SOLID" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbTrace" );
}
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 11, ent->secPoint.x );
writer->writeDouble( 21, ent->secPoint.y );
writer->writeDouble( 31, ent->secPoint.z );
writer->writeDouble( 12, ent->thirdPoint.x );
writer->writeDouble( 22, ent->thirdPoint.y );
writer->writeDouble( 32, ent->thirdPoint.z );
writer->writeDouble( 13, ent->fourPoint.x );
writer->writeDouble( 23, ent->fourPoint.y );
writer->writeDouble( 33, ent->fourPoint.z );
return true;
}
bool dxfRW::write3dface( DRW_3Dface* ent )
{
writer->writeString( 0, "3DFACE" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbFace" );
}
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 11, ent->secPoint.x );
writer->writeDouble( 21, ent->secPoint.y );
writer->writeDouble( 31, ent->secPoint.z );
writer->writeDouble( 12, ent->thirdPoint.x );
writer->writeDouble( 22, ent->thirdPoint.y );
writer->writeDouble( 32, ent->thirdPoint.z );
writer->writeDouble( 13, ent->fourPoint.x );
writer->writeDouble( 23, ent->fourPoint.y );
writer->writeDouble( 33, ent->fourPoint.z );
writer->writeInt16( 70, ent->invisibleflag );
return true;
}
bool dxfRW::writeLWPolyline( DRW_LWPolyline* ent )
{
if( version > DRW::AC1009 )
{
writer->writeString( 0, "LWPOLYLINE" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbPolyline" );
}
ent->vertexnum = ent->vertlist.size();
writer->writeInt32( 90, ent->vertexnum );
writer->writeInt16( 70, ent->flags );
writer->writeDouble( 43, ent->width );
if( ent->elevation != 0 )
writer->writeDouble( 38, ent->elevation );
if( ent->thickness != 0 )
writer->writeDouble( 39, ent->thickness );
for( int i = 0; i< ent->vertexnum; i++ )
{
DRW_Vertex2D* v = ent->vertlist.at( i );
writer->writeDouble( 10, v->x );
writer->writeDouble( 20, v->y );
if( v->stawidth != 0 )
writer->writeDouble( 40, v->stawidth );
if( v->endwidth != 0 )
writer->writeDouble( 41, v->endwidth );
if( v->bulge != 0 )
writer->writeDouble( 42, v->bulge );
}
}
else
{
// RLZ: TODO convert lwpolyline in polyline (not exist in acad 12)
}
return true;
}
bool dxfRW::writePolyline( DRW_Polyline* ent )
{
writer->writeString( 0, "POLYLINE" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
if( ent->flags & 8 || ent->flags & 16 )
writer->writeString( 100, "AcDb2dPolyline" );
else
writer->writeString( 100, "AcDb3dPolyline" );
}
else
writer->writeInt16( 66, 1 );
writer->writeDouble( 10, 0.0 );
writer->writeDouble( 20, 0.0 );
writer->writeDouble( 30, ent->basePoint.z );
if( ent->thickness != 0 )
{
writer->writeDouble( 39, ent->thickness );
}
writer->writeInt16( 70, ent->flags );
if( ent->defstawidth != 0 )
{
writer->writeDouble( 40, ent->defstawidth );
}
if( ent->defendwidth != 0 )
{
writer->writeDouble( 41, ent->defendwidth );
}
if( ent->flags & 16 || ent->flags & 32 )
{
writer->writeInt16( 71, ent->vertexcount );
writer->writeInt16( 72, ent->facecount );
}
if( ent->smoothM != 0 )
{
writer->writeInt16( 73, ent->smoothM );
}
if( ent->smoothN != 0 )
{
writer->writeInt16( 74, ent->smoothN );
}
if( ent->curvetype != 0 )
{
writer->writeInt16( 75, ent->curvetype );
}
DRW_Coord crd = ent->extPoint;
if( crd.x != 0 || crd.y != 0 || crd.z != 1 )
{
writer->writeDouble( 210, crd.x );
writer->writeDouble( 220, crd.y );
writer->writeDouble( 230, crd.z );
}
int vertexnum = ent->vertlist.size();
for( int i = 0; i< vertexnum; i++ )
{
DRW_Vertex* v = ent->vertlist.at( i );
writer->writeString( 0, "VERTEX" );
writeEntity( ent );
if( version > DRW::AC1009 )
writer->writeString( 100, "AcDbVertex" );
if( (v->flags & 128) && !(v->flags & 64) )
{
writer->writeDouble( 10, 0 );
writer->writeDouble( 20, 0 );
writer->writeDouble( 30, 0 );
}
else
{
writer->writeDouble( 10, v->basePoint.x );
writer->writeDouble( 20, v->basePoint.y );
writer->writeDouble( 30, v->basePoint.z );
}
if( v->stawidth != 0 )
writer->writeDouble( 40, v->stawidth );
if( v->endwidth != 0 )
writer->writeDouble( 41, v->endwidth );
if( v->bulge != 0 )
writer->writeDouble( 42, v->bulge );
if( v->flags != 0 )
{
writer->writeInt16( 70, ent->flags );
}
if( v->flags & 2 )
{
writer->writeDouble( 50, v->tgdir );
}
if( v->flags & 128 )
{
if( v->vindex1 != 0 )
{
writer->writeInt16( 71, v->vindex1 );
}
if( v->vindex2 != 0 )
{
writer->writeInt16( 72, v->vindex2 );
}
if( v->vindex3 != 0 )
{
writer->writeInt16( 73, v->vindex3 );
}
if( v->vindex4 != 0 )
{
writer->writeInt16( 74, v->vindex4 );
}
if( !(v->flags & 64) )
{
writer->writeInt32( 91, v->identifier );
}
}
}
writer->writeString( 0, "SEQEND" );
writeEntity( ent );
return true;
}
bool dxfRW::writeSpline( DRW_Spline* ent )
{
if( version > DRW::AC1009 )
{
writer->writeString( 0, "SPLINE" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbSpline" );
}
writer->writeDouble( 210, ent->ex );
writer->writeDouble( 220, ent->ey );
writer->writeDouble( 230, ent->ez );
writer->writeInt16( 70, ent->flags );
writer->writeInt16( 71, ent->degree );
writer->writeInt16( 72, ent->nknots );
writer->writeInt16( 73, ent->ncontrol );
writer->writeInt16( 74, ent->nfit );
writer->writeDouble( 42, ent->tolknot );
writer->writeDouble( 43, ent->tolcontrol );
// RLZ: warning check if nknots are correct and ncontrol
for( int i = 0; i< ent->nknots; i++ )
{
writer->writeDouble( 40, ent->knotslist.at( i ) );
}
for( int i = 0; i< ent->ncontrol; i++ )
{
DRW_Coord* crd = ent->controllist.at( i );
writer->writeDouble( 10, crd->x );
writer->writeDouble( 20, crd->y );
writer->writeDouble( 30, crd->z );
}
}
else
{
// RLZ: TODO convert spline in polyline (not exist in acad 12)
}
return true;
}
bool dxfRW::writeHatch( DRW_Hatch* ent )
{
if( version > DRW::AC1009 )
{
writer->writeString( 0, "HATCH" );
writeEntity( ent );
writer->writeString( 100, "AcDbHatch" );
writer->writeDouble( 10, 0.0 );
writer->writeDouble( 20, 0.0 );
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 210, ent->extPoint.x );
writer->writeDouble( 220, ent->extPoint.y );
writer->writeDouble( 230, ent->extPoint.z );
writer->writeString( 2, ent->name );
writer->writeInt16( 70, ent->solid );
writer->writeInt16( 71, ent->associative );
ent->loopsnum = ent->looplist.size();
writer->writeInt16( 91, ent->loopsnum );
// write paths data
for( int i = 0; i< ent->loopsnum; i++ )
{
DRW_HatchLoop* loop = ent->looplist.at( i );
writer->writeInt16( 92, loop->type );
if( (loop->type & 2) == 2 )
{
// RLZ: polyline boundary writeme
}
else
{
// boundary path
loop->update();
writer->writeInt16( 93, loop->numedges );
for( int j = 0; j<loop->numedges; ++j )
{
switch( ( loop->objlist.at( j ) )->eType )
{
case DRW::LINE:
{
writer->writeInt16( 72, 1 );
DRW_Line* l = (DRW_Line*) loop->objlist.at( j );
writer->writeDouble( 10, l->basePoint.x );
writer->writeDouble( 20, l->basePoint.y );
writer->writeDouble( 11, l->secPoint.x );
writer->writeDouble( 21, l->secPoint.y );
break;
}
case DRW::ARC:
{
writer->writeInt16( 72, 2 );
DRW_Arc* a = (DRW_Arc*) loop->objlist.at( j );
writer->writeDouble( 10, a->basePoint.x );
writer->writeDouble( 20, a->basePoint.y );
writer->writeDouble( 40, a->radious );
writer->writeDouble( 50, a->staangle * ARAD );
writer->writeDouble( 51, a->endangle * ARAD );
writer->writeInt16( 73, a->isccw );
break;
}
case DRW::ELLIPSE:
{
writer->writeInt16( 72, 3 );
DRW_Ellipse* a = (DRW_Ellipse*) loop->objlist.at( j );
a->correctAxis();
writer->writeDouble( 10, a->basePoint.x );
writer->writeDouble( 20, a->basePoint.y );
writer->writeDouble( 11, a->secPoint.x );
writer->writeDouble( 21, a->secPoint.y );
writer->writeDouble( 40, a->ratio );
writer->writeDouble( 50, a->staparam * ARAD );
writer->writeDouble( 51, a->endparam * ARAD );
writer->writeInt16( 73, a->isccw );
break;
}
case DRW::SPLINE:
// RLZ: spline boundary writeme
// writer->writeInt16(72, 4);
break;
default:
break;
}
}
writer->writeInt16( 97, 0 );
}
}
writer->writeInt16( 75, ent->hstyle );
writer->writeInt16( 76, ent->hpattern );
if( !ent->solid )
{
writer->writeDouble( 52, ent->angle );
writer->writeDouble( 41, ent->scale );
writer->writeInt16( 77, ent->doubleflag );
writer->writeInt16( 78, ent->deflines );
}
/* if (ent->deflines > 0){
* writer->writeInt16(78, ent->deflines);
* }*/
writer->writeInt32( 98, 0 );
}
else
{
// RLZ: TODO verify in acad12
}
return true;
}
bool dxfRW::writeLeader( DRW_Leader* ent )
{
if( version > DRW::AC1009 )
{
writer->writeString( 0, "LEADER" );
writeEntity( ent );
writer->writeString( 100, "AcDbLeader" );
writer->writeUtf8String( 3, ent->style );
writer->writeInt16( 71, ent->arrow );
writer->writeInt16( 72, ent->leadertype );
writer->writeInt16( 73, ent->flag );
writer->writeInt16( 74, ent->hookline );
writer->writeInt16( 75, ent->hookflag );
writer->writeDouble( 40, ent->textheight );
writer->writeDouble( 41, ent->textwidth );
writer->writeDouble( 76, ent->vertnum );
writer->writeDouble( 76, ent->vertexlist.size() );
for( unsigned int i = 0; i<ent->vertexlist.size(); i++ )
{
DRW_Coord* vert = ent->vertexlist.at( i );
writer->writeDouble( 10, vert->x );
writer->writeDouble( 20, vert->y );
writer->writeDouble( 30, vert->z );
}
}
else
{
// RLZ: todo not supported by acad 12 saved as unnamed block
}
return true;
}
bool dxfRW::writeDimension( DRW_Dimension* ent )
{
if( version > DRW::AC1009 )
{
writer->writeString( 0, "DIMENSION" );
writeEntity( ent );
writer->writeString( 100, "AcDbDimension" );
// writer->writeString(2, ent->name);
writer->writeDouble( 10, ent->getDefPoint().x );
writer->writeDouble( 20, ent->getDefPoint().y );
writer->writeDouble( 30, ent->getDefPoint().z );
writer->writeDouble( 11, ent->getTextPoint().x );
writer->writeDouble( 21, ent->getTextPoint().y );
writer->writeDouble( 31, ent->getTextPoint().z );
if( !(ent->type & 32) )
ent->type = ent->type + 32;
writer->writeInt16( 70, ent->type );
if( !( ent->getText().empty() ) )
writer->writeUtf8String( 1, ent->getText() );
writer->writeInt16( 71, ent->getAlign() );
if( ent->getTextLineStyle() != 1 )
writer->writeInt16( 72, ent->getTextLineStyle() );
if( ent->getTextLineFactor() != 1 )
writer->writeDouble( 41, ent->getTextLineFactor() );
writer->writeUtf8String( 3, ent->getStyle() );
if( ent->getTextLineFactor() != 0 )
writer->writeDouble( 53, ent->getDir() );
writer->writeDouble( 210, ent->getExtrusion().x );
writer->writeDouble( 220, ent->getExtrusion().y );
writer->writeDouble( 230, ent->getExtrusion().z );
switch( ent->eType )
{
case DRW::DIMALIGNED:
case DRW::DIMLINEAR:
{
DRW_DimAligned* dd = (DRW_DimAligned*) ent;
writer->writeString( 100, "AcDbAlignedDimension" );
DRW_Coord crd = dd->getClonepoint();
if( crd.x != 0 || crd.y != 0 || crd.z != 0 )
{
writer->writeDouble( 12, crd.x );
writer->writeDouble( 22, crd.y );
writer->writeDouble( 32, crd.z );
}
writer->writeDouble( 13, dd->getDef1Point().x );
writer->writeDouble( 23, dd->getDef1Point().y );
writer->writeDouble( 33, dd->getDef1Point().z );
writer->writeDouble( 14, dd->getDef2Point().x );
writer->writeDouble( 24, dd->getDef2Point().y );
writer->writeDouble( 34, dd->getDef2Point().z );
if( ent->eType == DRW::DIMLINEAR )
{
DRW_DimLinear* dl = (DRW_DimLinear*) ent;
if( dl->getAngle() != 0 )
writer->writeDouble( 50, dl->getAngle() );
if( dl->getOblique() != 0 )
writer->writeDouble( 52, dl->getOblique() );
writer->writeString( 100, "AcDbRotatedDimension" );
}
break;
}
case DRW::DIMRADIAL:
{
DRW_DimRadial* dd = (DRW_DimRadial*) ent;
writer->writeString( 100, "AcDbRadialDimension" );
writer->writeDouble( 15, dd->getDiameterPoint().x );
writer->writeDouble( 25, dd->getDiameterPoint().y );
writer->writeDouble( 35, dd->getDiameterPoint().z );
writer->writeDouble( 40, dd->getLeaderLength() );
break;
}
case DRW::DIMDIAMETRIC:
{
DRW_DimDiametric* dd = (DRW_DimDiametric*) ent;
writer->writeString( 100, "AcDbDiametricDimension" );
writer->writeDouble( 15, dd->getDiameter1Point().x );
writer->writeDouble( 25, dd->getDiameter1Point().y );
writer->writeDouble( 35, dd->getDiameter1Point().z );
writer->writeDouble( 40, dd->getLeaderLength() );
break;
}
case DRW::DIMANGULAR:
{
DRW_DimAngular* dd = (DRW_DimAngular*) ent;
writer->writeString( 100, "AcDb2LineAngularDimension" );
writer->writeDouble( 13, dd->getFirstLine1().x );
writer->writeDouble( 23, dd->getFirstLine1().y );
writer->writeDouble( 33, dd->getFirstLine1().z );
writer->writeDouble( 14, dd->getFirstLine2().x );
writer->writeDouble( 24, dd->getFirstLine2().y );
writer->writeDouble( 34, dd->getFirstLine2().z );
writer->writeDouble( 15, dd->getSecondLine1().x );
writer->writeDouble( 25, dd->getSecondLine1().y );
writer->writeDouble( 35, dd->getSecondLine1().z );
writer->writeDouble( 16, dd->getDimPoint().x );
writer->writeDouble( 26, dd->getDimPoint().y );
writer->writeDouble( 36, dd->getDimPoint().z );
break;
}
case DRW::DIMANGULAR3P:
{
DRW_DimAngular3p* dd = (DRW_DimAngular3p*) ent;
writer->writeDouble( 13, dd->getFirstLine().x );
writer->writeDouble( 23, dd->getFirstLine().y );
writer->writeDouble( 33, dd->getFirstLine().z );
writer->writeDouble( 14, dd->getSecondLine().x );
writer->writeDouble( 24, dd->getSecondLine().y );
writer->writeDouble( 34, dd->getSecondLine().z );
writer->writeDouble( 15, dd->getVertexPoint().x );
writer->writeDouble( 25, dd->getVertexPoint().y );
writer->writeDouble( 35, dd->getVertexPoint().z );
break;
}
case DRW::DIMORDINATE:
{
DRW_DimOrdinate* dd = (DRW_DimOrdinate*) ent;
writer->writeString( 100, "AcDbOrdinateDimension" );
writer->writeDouble( 13, dd->getFirstLine().x );
writer->writeDouble( 23, dd->getFirstLine().y );
writer->writeDouble( 33, dd->getFirstLine().z );
writer->writeDouble( 14, dd->getSecondLine().x );
writer->writeDouble( 24, dd->getSecondLine().y );
writer->writeDouble( 34, dd->getSecondLine().z );
break;
}
default:
break;
}
}
else
{
// RLZ: todo not supported by acad 12 saved as unnamed block
}
return true;
}
bool dxfRW::writeInsert( DRW_Insert* ent )
{
writer->writeString( 0, "INSERT" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbBlockReference" );
writer->writeUtf8String( 2, ent->name );
}
else
writer->writeUtf8Caps( 2, ent->name );
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 41, ent->xscale );
writer->writeDouble( 42, ent->yscale );
writer->writeDouble( 43, ent->zscale );
writer->writeDouble( 50, ent->angle );
writer->writeInt16( 70, ent->colcount );
writer->writeInt16( 71, ent->rowcount );
writer->writeDouble( 44, ent->colspace );
writer->writeDouble( 45, ent->rowspace );
return true;
}
bool dxfRW::writeText( DRW_Text* ent )
{
writer->writeString( 0, "TEXT" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbText" );
}
// writer->writeDouble(39, ent->thickness);
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 40, ent->height );
writer->writeUtf8String( 1, ent->text );
writer->writeDouble( 50, ent->angle );
writer->writeDouble( 41, ent->widthscale );
writer->writeDouble( 51, ent->oblique );
if( version > DRW::AC1009 )
writer->writeUtf8String( 7, ent->style );
else
writer->writeUtf8Caps( 7, ent->style );
writer->writeInt16( 71, ent->textgen );
if( ent->alignH != DRW_Text::HLeft )
{
writer->writeInt16( 72, ent->alignH );
}
if( ent->alignH != DRW_Text::HLeft || ent->alignV != DRW_Text::VBaseLine )
{
writer->writeDouble( 11, ent->secPoint.x );
writer->writeDouble( 21, ent->secPoint.y );
writer->writeDouble( 31, ent->secPoint.z );
}
writer->writeDouble( 210, ent->extPoint.x );
writer->writeDouble( 220, ent->extPoint.y );
writer->writeDouble( 230, ent->extPoint.z );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbText" );
}
if( ent->alignV != DRW_Text::VBaseLine )
{
writer->writeInt16( 73, ent->alignV );
}
return true;
}
bool dxfRW::writeMText( DRW_MText* ent )
{
if( version > DRW::AC1009 )
{
writer->writeString( 0, "MTEXT" );
writeEntity( ent );
writer->writeString( 100, "AcDbMText" );
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 40, ent->height );
writer->writeDouble( 41, ent->widthscale );
writer->writeInt16( 71, ent->textgen );
writer->writeInt16( 72, ent->alignH );
std::string text = writer->fromUtf8String( ent->text );
int i;
for( i = 0; (text.size() - i) > 250; )
{
writer->writeString( 3, text.substr( i, 250 ) );
i += 250;
}
writer->writeString( 1, text.substr( i ) );
writer->writeString( 7, ent->style );
writer->writeDouble( 210, ent->extPoint.x );
writer->writeDouble( 220, ent->extPoint.y );
writer->writeDouble( 230, ent->extPoint.z );
writer->writeDouble( 50, ent->angle );
writer->writeInt16( 73, ent->alignV );
writer->writeDouble( 44, ent->interlin );
// RLZ ... 11, 21, 31 needed?
}
else
{
// RLZ: TODO convert mtext in text lines (not exist in acad 12)
}
return true;
}
bool dxfRW::writeViewport( DRW_Viewport* ent )
{
writer->writeString( 0, "VIEWPORT" );
writeEntity( ent );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbViewport" );
}
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
if( ent->basePoint.z != 0.0 )
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 40, ent->pswidth );
writer->writeDouble( 41, ent->psheight );
writer->writeInt16( 68, ent->vpstatus );
writer->writeInt16( 69, ent->vpID );
writer->writeDouble( 12, ent->centerPX ); // RLZ: verify if exist in V12
writer->writeDouble( 22, ent->centerPY ); // RLZ: verify if exist in V12
return true;
}
DRW_ImageDef* dxfRW::writeImage( DRW_Image* ent, std::string name )
{
if( version > DRW::AC1009 )
{
// search if exist imagedef with this mane (image inserted more than 1 time)
// RLZ: imagedef_reactor seem needed to read in acad
DRW_ImageDef* id = NULL;
for( unsigned int i = 0; i<imageDef.size(); i++ )
{
if( imageDef.at( i )->name == name )
{
id = imageDef.at( i );
continue;
}
}
if( id == NULL )
{
id = new DRW_ImageDef();
imageDef.push_back( id );
id->handle = toHexStr( ++entCount );
}
id->name = name;
std::string idReactor = toHexStr( ++entCount );
writer->writeString( 0, "IMAGE" );
writeEntity( ent );
writer->writeString( 100, "AcDbRasterImage" );
writer->writeDouble( 10, ent->basePoint.x );
writer->writeDouble( 20, ent->basePoint.y );
writer->writeDouble( 30, ent->basePoint.z );
writer->writeDouble( 11, ent->secPoint.x );
writer->writeDouble( 21, ent->secPoint.y );
writer->writeDouble( 31, ent->secPoint.z );
writer->writeDouble( 12, ent->vx );
writer->writeDouble( 22, ent->vy );
writer->writeDouble( 32, ent->vz );
writer->writeDouble( 13, ent->sizeu );
writer->writeDouble( 23, ent->sizev );
writer->writeString( 340, id->handle );
writer->writeInt16( 70, 1 );
writer->writeInt16( 280, ent->clip );
writer->writeInt16( 281, ent->brightness );
writer->writeInt16( 282, ent->contrast );
writer->writeInt16( 283, ent->fade );
writer->writeString( 360, idReactor );
id->reactors[idReactor] = ent->handle;
return id;
}
return NULL; // not exist in acad 12
}
bool dxfRW::writeBlockRecord( std::string name )
{
if( version > DRW::AC1009 )
{
writer->writeString( 0, "BLOCK_RECORD" );
writer->writeString( 5, toHexStr( ++entCount ) );
blockMap[name] = entCount;
entCount = 2 + entCount; // reserve 2 for BLOCK & ENDBLOCK
if( version > DRW::AC1014 )
{
writer->writeString( 330, "1" );
}
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbBlockTableRecord" );
writer->writeUtf8String( 2, name );
if( version > DRW::AC1018 )
{
// writer->writeInt16(340, 22);
writer->writeInt16( 70, 0 );
writer->writeInt16( 280, 1 );
writer->writeInt16( 281, 0 );
}
}
return true;
}
bool dxfRW::writeBlock( DRW_Block* bk )
{
if( writingBlock )
{
writer->writeString( 0, "ENDBLK" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, toHexStr( currHandle + 2 ) );
if( version > DRW::AC1014 )
{
writer->writeString( 330, toHexStr( currHandle ) );
}
writer->writeString( 100, "AcDbEntity" );
}
writer->writeString( 8, "0" );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbBlockEnd" );
}
}
writingBlock = true;
writer->writeString( 0, "BLOCK" );
if( version > DRW::AC1009 )
{
currHandle = ( *( blockMap.find( bk->name ) ) ).second;
writer->writeString( 5, toHexStr( currHandle + 1 ) );
if( version > DRW::AC1014 )
{
writer->writeString( 330, toHexStr( currHandle ) );
}
writer->writeString( 100, "AcDbEntity" );
}
writer->writeString( 8, "0" );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbBlockBegin" );
writer->writeUtf8String( 2, bk->name );
}
else
writer->writeUtf8Caps( 2, bk->name );
writer->writeInt16( 70, bk->flags );
writer->writeDouble( 10, bk->basePoint.x );
writer->writeDouble( 20, bk->basePoint.y );
if( bk->basePoint.z != 0.0 )
{
writer->writeDouble( 30, bk->basePoint.z );
}
if( version > DRW::AC1009 )
writer->writeUtf8String( 3, bk->name );
else
writer->writeUtf8Caps( 3, bk->name );
writer->writeString( 1, "" );
return true;
}
bool dxfRW::writeTables()
{
writer->writeString( 0, "TABLE" );
writer->writeString( 2, "VPORT" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "8" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbSymbolTable" );
}
writer->writeInt16( 70, 1 ); // end table def
/*** VPORT ***/
dimstyleStd = false;
iface->writeVports();
if( !dimstyleStd )
{
DRW_Vport portact;
portact.name = "*ACTIVE";
writeVport( &portact );
}
writer->writeString( 0, "ENDTAB" );
/*** LTYPE ***/
writer->writeString( 0, "TABLE" );
writer->writeString( 2, "LTYPE" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "5" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbSymbolTable" );
}
writer->writeInt16( 70, 4 ); // end table def
// Mandatory linetypes
writer->writeString( 0, "LTYPE" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "14" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "5" );
}
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbLinetypeTableRecord" );
writer->writeString( 2, "ByBlock" );
}
else
writer->writeString( 2, "BYBLOCK" );
writer->writeInt16( 70, 0 );
writer->writeString( 3, "" );
writer->writeInt16( 72, 65 );
writer->writeInt16( 73, 0 );
writer->writeDouble( 40, 0.0 );
writer->writeString( 0, "LTYPE" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "15" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "5" );
}
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbLinetypeTableRecord" );
writer->writeString( 2, "ByLayer" );
}
else
writer->writeString( 2, "BYLAYER" );
writer->writeInt16( 70, 0 );
writer->writeString( 3, "" );
writer->writeInt16( 72, 65 );
writer->writeInt16( 73, 0 );
writer->writeDouble( 40, 0.0 );
writer->writeString( 0, "LTYPE" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "16" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "5" );
}
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbLinetypeTableRecord" );
writer->writeString( 2, "Continuous" );
}
else
{
writer->writeString( 2, "CONTINUOUS" );
}
writer->writeInt16( 70, 0 );
writer->writeString( 3, "Solid line" );
writer->writeInt16( 72, 65 );
writer->writeInt16( 73, 0 );
writer->writeDouble( 40, 0.0 );
// Aplication linetypes
iface->writeLTypes();
writer->writeString( 0, "ENDTAB" );
/*** LAYER ***/
writer->writeString( 0, "TABLE" );
writer->writeString( 2, "LAYER" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "2" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbSymbolTable" );
}
writer->writeInt16( 70, 1 ); // end table def
wlayer0 = false;
iface->writeLayers();
if( !wlayer0 )
{
DRW_Layer lay0;
lay0.name = "0";
writeLayer( &lay0 );
}
writer->writeString( 0, "ENDTAB" );
/*** STYLE ***/
writer->writeString( 0, "TABLE" );
writer->writeString( 2, "STYLE" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "3" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbSymbolTable" );
}
writer->writeInt16( 70, 3 ); // end table def
dimstyleStd = false;
iface->writeTextstyles();
if( !dimstyleStd )
{
DRW_Textstyle tsty;
tsty.name = "Standard";
writeTextstyle( &tsty );
}
writer->writeString( 0, "ENDTAB" );
writer->writeString( 0, "TABLE" );
writer->writeString( 2, "VIEW" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "6" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbSymbolTable" );
}
writer->writeInt16( 70, 0 ); // end table def
writer->writeString( 0, "ENDTAB" );
writer->writeString( 0, "TABLE" );
writer->writeString( 2, "UCS" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "7" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbSymbolTable" );
}
writer->writeInt16( 70, 0 ); // end table def
writer->writeString( 0, "ENDTAB" );
writer->writeString( 0, "TABLE" );
writer->writeString( 2, "APPID" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "9" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbSymbolTable" );
}
writer->writeInt16( 70, 1 ); // end table def
writer->writeString( 0, "APPID" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "12" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "9" );
}
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbRegAppTableRecord" );
}
writer->writeString( 2, "ACAD" );
writer->writeInt16( 70, 0 );
writer->writeString( 0, "ENDTAB" );
writer->writeString( 0, "TABLE" );
writer->writeString( 2, "DIMSTYLE" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "A" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbSymbolTable" );
}
writer->writeInt16( 70, 1 ); // end table def
if( version > DRW::AC1014 )
{
writer->writeString( 100, "AcDbDimStyleTable" );
writer->writeInt16( 71, 1 ); // end table def
}
dimstyleStd = false;
iface->writeDimstyles();
if( !dimstyleStd )
{
DRW_Dimstyle dsty;
dsty.name = "Standard";
writeDimstyle( &dsty );
}
writer->writeString( 0, "ENDTAB" );
if( version > DRW::AC1009 )
{
writer->writeString( 0, "TABLE" );
writer->writeString( 2, "BLOCK_RECORD" );
writer->writeString( 5, "1" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbSymbolTable" );
writer->writeInt16( 70, 2 ); // end table def
writer->writeString( 0, "BLOCK_RECORD" );
writer->writeString( 5, "1F" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "1" );
}
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbBlockTableRecord" );
writer->writeString( 2, "*Model_Space" );
if( version > DRW::AC1018 )
{
// writer->writeInt16(340, 22);
writer->writeInt16( 70, 0 );
writer->writeInt16( 280, 1 );
writer->writeInt16( 281, 0 );
}
writer->writeString( 0, "BLOCK_RECORD" );
writer->writeString( 5, "1E" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "1" );
}
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbBlockTableRecord" );
writer->writeString( 2, "*Paper_Space" );
if( version > DRW::AC1018 )
{
// writer->writeInt16(340, 22);
writer->writeInt16( 70, 0 );
writer->writeInt16( 280, 1 );
writer->writeInt16( 281, 0 );
}
iface->writeBlockRecords();
writer->writeString( 0, "ENDTAB" );
}
return true;
}
bool dxfRW::writeBlocks()
{
writer->writeString( 0, "BLOCK" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "20" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "1F" );
}
writer->writeString( 100, "AcDbEntity" );
}
writer->writeString( 8, "0" );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbBlockBegin" );
writer->writeString( 2, "*Model_Space" );
}
else
writer->writeString( 2, "$MODEL_SPACE" );
writer->writeInt16( 70, 0 );
writer->writeDouble( 10, 0.0 );
writer->writeDouble( 20, 0.0 );
writer->writeDouble( 30, 0.0 );
if( version > DRW::AC1009 )
writer->writeString( 3, "*Model_Space" );
else
writer->writeString( 3, "$MODEL_SPACE" );
writer->writeString( 1, "" );
writer->writeString( 0, "ENDBLK" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "21" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "1F" );
}
writer->writeString( 100, "AcDbEntity" );
}
writer->writeString( 8, "0" );
if( version > DRW::AC1009 )
writer->writeString( 100, "AcDbBlockEnd" );
writer->writeString( 0, "BLOCK" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "1C" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "1B" );
}
writer->writeString( 100, "AcDbEntity" );
}
writer->writeString( 8, "0" );
if( version > DRW::AC1009 )
{
writer->writeString( 100, "AcDbBlockBegin" );
writer->writeString( 2, "*Paper_Space" );
}
else
writer->writeString( 2, "$PAPER_SPACE" );
writer->writeInt16( 70, 0 );
writer->writeDouble( 10, 0.0 );
writer->writeDouble( 20, 0.0 );
writer->writeDouble( 30, 0.0 );
if( version > DRW::AC1009 )
writer->writeString( 3, "*Paper_Space" );
else
writer->writeString( 3, "$PAPER_SPACE" );
writer->writeString( 1, "" );
writer->writeString( 0, "ENDBLK" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, "1D" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "1F" );
}
writer->writeString( 100, "AcDbEntity" );
}
writer->writeString( 8, "0" );
if( version > DRW::AC1009 )
writer->writeString( 100, "AcDbBlockEnd" );
writingBlock = false;
iface->writeBlocks();
if( writingBlock )
{
writingBlock = false;
writer->writeString( 0, "ENDBLK" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, toHexStr( currHandle + 2 ) );
// writer->writeString(5, "1D");
if( version > DRW::AC1014 )
{
writer->writeString( 330, toHexStr( currHandle ) );
}
writer->writeString( 100, "AcDbEntity" );
}
writer->writeString( 8, "0" );
if( version > DRW::AC1009 )
writer->writeString( 100, "AcDbBlockEnd" );
}
return true;
}
bool dxfRW::writeObjects()
{
writer->writeString( 0, "DICTIONARY" );
std::string imgDictH;
writer->writeString( 5, "C" );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "0" );
}
writer->writeString( 100, "AcDbDictionary" );
writer->writeInt16( 281, 1 );
writer->writeString( 3, "ACAD_GROUP" );
writer->writeString( 350, "D" );
if( imageDef.size() != 0 )
{
writer->writeString( 3, "ACAD_IMAGE_DICT" );
imgDictH = toHexStr( ++entCount );
writer->writeString( 350, imgDictH );
}
writer->writeString( 0, "DICTIONARY" );
writer->writeString( 5, "D" );
writer->writeString( 330, "C" );
writer->writeString( 100, "AcDbDictionary" );
writer->writeInt16( 281, 1 );
// write IMAGEDEF_REACTOR
for( unsigned int i = 0; i<imageDef.size(); i++ )
{
DRW_ImageDef* id = imageDef.at( i );
std::map<string, string>::iterator it;
for( it = id->reactors.begin(); it != id->reactors.end(); it++ )
{
writer->writeString( 0, "IMAGEDEF_REACTOR" );
writer->writeString( 5, (*it).first );
writer->writeString( 330, (*it).second );
writer->writeString( 100, "AcDbRasterImageDefReactor" );
writer->writeInt16( 90, 2 ); // version 2=R14 to v2010
writer->writeString( 330, (*it).second );
}
}
if( imageDef.size() != 0 )
{
writer->writeString( 0, "DICTIONARY" );
writer->writeString( 5, imgDictH );
writer->writeString( 330, "C" );
writer->writeString( 100, "AcDbDictionary" );
writer->writeInt16( 281, 1 );
for( unsigned int i = 0; i<imageDef.size(); i++ )
{
size_t f1, f2;
f1 = imageDef.at( i )->name.find_last_of( "/\\" );
f2 = imageDef.at( i )->name.find_last_of( '.' );
++f1;
writer->writeString( 3, imageDef.at( i )->name.substr( f1, f2 - f1 ) );
writer->writeString( 350, imageDef.at( i )->handle );
}
}
for( unsigned int i = 0; i<imageDef.size(); i++ )
{
DRW_ImageDef* id = imageDef.at( i );
writer->writeString( 0, "IMAGEDEF" );
writer->writeString( 5, id->handle );
if( version > DRW::AC1014 )
{
// writer->writeString(330, "0"); handle to DICTIONARY
}
writer->writeString( 102, "{ACAD_REACTORS" );
std::map<string, string>::iterator it;
for( it = id->reactors.begin(); it != id->reactors.end(); it++ )
{
writer->writeString( 330, (*it).first );
}
writer->writeString( 102, "}" );
writer->writeString( 100, "AcDbRasterImageDef" );
writer->writeInt16( 90, 0 ); // version 0=R14 to v2010
writer->writeUtf8String( 1, id->name );
writer->writeDouble( 10, id->u );
writer->writeDouble( 20, id->v );
writer->writeDouble( 11, id->up );
writer->writeDouble( 21, id->vp );
writer->writeInt16( 280, id->loaded );
writer->writeInt16( 281, id->resolution );
}
// no more needed imageDef, delete it
while( !imageDef.empty() )
{
imageDef.pop_back();
}
return true;
}
/********* Reader Process *********/
bool dxfRW::processDxf()
{
DBG( "dxfRW::processDxf() start processing dxf\n" );
int code;
bool more = true;
string sectionstr;
// section = secUnknown;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( " processDxf\n" );
if( code == 999 )
{
header.addComment( reader->getString() );
}
else if( code == 0 )
{
sectionstr = reader->getString();
DBG( sectionstr ); DBG( " processDxf\n" );
if( sectionstr == "EOF" )
{
return true; // found EOF terminate
}
if( sectionstr == "SECTION" )
{
more = reader->readRec( &code, !binary );
DBG( code ); DBG( " processDxf\n" );
if( !more )
return false; // wrong dxf file
if( code == 2 )
{
sectionstr = reader->getString();
DBG( sectionstr ); DBG( " processDxf\n" );
// found section, process it
if( sectionstr == "HEADER" )
{
processHeader();
}
else if( sectionstr == "CLASSES" )
{
// processClasses();
}
else if( sectionstr == "TABLES" )
{
processTables();
}
else if( sectionstr == "BLOCKS" )
{
processBlocks();
}
else if( sectionstr == "ENTITIES" )
{
processEntities( false );
}
else if( sectionstr == "OBJECTS" )
{
processObjects();
}
}
}
}
/* if (!more)
* return true;*/
}
return true;
}
/********* Header Section *********/
bool dxfRW::processHeader()
{
DBG( "dxfRW::processHeader\n" );
int code;
string sectionstr;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( " processHeader\n" );
if( code == 0 )
{
sectionstr = reader->getString();
DBG( sectionstr ); DBG( " processHeader\n\n" );
if( sectionstr == "ENDSEC" )
{
iface->addHeader( &header );
return true; // found ENDSEC terminate
}
}
else
header.parseCode( code, reader );
}
return true;
}
/********* Tables Section *********/
bool dxfRW::processTables()
{
DBG( "dxfRW::processTables\n" );
int code;
string sectionstr;
bool more = true;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
if( code == 0 )
{
sectionstr = reader->getString();
DBG( sectionstr ); DBG( " processHeader\n\n" );
if( sectionstr == "TABLE" )
{
more = reader->readRec( &code, !binary );
DBG( code ); DBG( "\n" );
if( !more )
return false; // wrong dxf file
if( code == 2 )
{
sectionstr = reader->getString();
DBG( sectionstr ); DBG( " processHeader\n\n" );
// found section, process it
if( sectionstr == "LTYPE" )
{
processLType();
}
else if( sectionstr == "LAYER" )
{
processLayer();
}
else if( sectionstr == "STYLE" )
{
processTextStyle();
}
else if( sectionstr == "VPORT" )
{
processVports();
}
else if( sectionstr == "VIEW" )
{
// processView();
}
else if( sectionstr == "UCS" )
{
// processUCS();
}
else if( sectionstr == "APPID" )
{
// processAppId();
}
else if( sectionstr == "DIMSTYLE" )
{
processDimStyle();
}
else if( sectionstr == "BLOCK_RECORD" )
{
// processBlockRecord();
}
}
}
else if( sectionstr == "ENDSEC" )
{
return true; // found ENDSEC terminate
}
}
}
return true;
}
bool dxfRW::processLType()
{
DBG( "dxfRW::processLType\n" );
int code;
string sectionstr;
bool reading = false;
DRW_LType ltype;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
if( code == 0 )
{
if( reading )
{
ltype.update();
iface->addLType( ltype );
}
sectionstr = reader->getString();
DBG( sectionstr ); DBG( "\n" );
if( sectionstr == "LTYPE" )
{
reading = true;
ltype.reset();
}
else if( sectionstr == "ENDTAB" )
{
return true; // found ENDTAB terminate
}
}
else if( reading )
ltype.parseCode( code, reader );
}
return true;
}
bool dxfRW::processLayer()
{
DBG( "dxfRW::processLayer\n" );
int code;
string sectionstr;
bool reading = false;
DRW_Layer layer;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
if( code == 0 )
{
if( reading )
iface->addLayer( layer );
sectionstr = reader->getString();
DBG( sectionstr ); DBG( "\n" );
if( sectionstr == "LAYER" )
{
reading = true;
layer.reset();
}
else if( sectionstr == "ENDTAB" )
{
return true; // found ENDTAB terminate
}
}
else if( reading )
layer.parseCode( code, reader );
}
return true;
}
bool dxfRW::processDimStyle()
{
DBG( "dxfRW::processDimStyle" );
int code;
string sectionstr;
bool reading = false;
DRW_Dimstyle dimSty;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
if( code == 0 )
{
if( reading )
iface->addDimStyle( dimSty );
sectionstr = reader->getString();
DBG( sectionstr ); DBG( "\n" );
if( sectionstr == "DIMSTYLE" )
{
reading = true;
dimSty.reset();
}
else if( sectionstr == "ENDTAB" )
{
return true; // found ENDTAB terminate
}
}
else if( reading )
dimSty.parseCode( code, reader );
}
return true;
}
bool dxfRW::processTextStyle()
{
DBG( "dxfRW::processTextStyle" );
int code;
string sectionstr;
bool reading = false;
DRW_Textstyle TxtSty;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
if( code == 0 )
{
if( reading )
iface->addTextStyle( TxtSty );
sectionstr = reader->getString();
DBG( sectionstr ); DBG( "\n" );
if( sectionstr == "STYLE" )
{
reading = true;
TxtSty.reset();
}
else if( sectionstr == "ENDTAB" )
{
return true; // found ENDTAB terminate
}
}
else if( reading )
TxtSty.parseCode( code, reader );
}
return true;
}
bool dxfRW::processVports()
{
DBG( "dxfRW::processVports" );
int code;
string sectionstr;
bool reading = false;
DRW_Vport vp;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
if( code == 0 )
{
if( reading )
iface->addVport( vp );
sectionstr = reader->getString();
DBG( sectionstr ); DBG( "\n" );
if( sectionstr == "VPORT" )
{
reading = true;
vp.reset();
}
else if( sectionstr == "ENDTAB" )
{
return true; // found ENDTAB terminate
}
}
else if( reading )
vp.parseCode( code, reader );
}
return true;
}
/********* Block Section *********/
bool dxfRW::processBlocks()
{
DBG( "dxfRW::processBlocks\n" );
int code;
string sectionstr;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
if( code == 0 )
{
sectionstr = reader->getString();
DBG( sectionstr ); DBG( "\n" );
if( sectionstr == "BLOCK" )
{
processBlock();
}
else if( sectionstr == "ENDSEC" )
{
return true; // found ENDSEC terminate
}
}
}
return true;
}
bool dxfRW::processBlock()
{
DBG( "dxfRW::processBlock" );
int code;
DRW_Block block;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addBlock( block );
if( nextentity == "ENDBLK" )
{
iface->endBlock();
return true; // found ENDBLK, terminate
}
else
{
processEntities( true );
iface->endBlock();
return true; // found ENDBLK, terminate
}
}
default:
block.parseCode( code, reader );
break;
}
}
return true;
}
/********* Entities Section *********/
bool dxfRW::processEntities( bool isblock )
{
DBG( "dxfRW::processEntities\n" );
int code;
if( !reader->readRec( &code, !binary ) )
{
return false;
}
bool next = true;
if( code == 0 )
{
nextentity = reader->getString();
}
else if( !isblock )
{
return false; // first record in entities is 0
}
do {
if( nextentity == "ENDSEC" || nextentity == "ENDBLK" )
{
return true; // found ENDSEC or ENDBLK terminate
}
else if( nextentity == "POINT" )
{
processPoint();
}
else if( nextentity == "LINE" )
{
processLine();
}
else if( nextentity == "CIRCLE" )
{
processCircle();
}
else if( nextentity == "ARC" )
{
processArc();
}
else if( nextentity == "ELLIPSE" )
{
processEllipse();
}
else if( nextentity == "TRACE" )
{
processTrace();
}
else if( nextentity == "SOLID" )
{
processSolid();
}
else if( nextentity == "INSERT" )
{
processInsert();
}
else if( nextentity == "LWPOLYLINE" )
{
processLWPolyline();
}
else if( nextentity == "POLYLINE" )
{
processPolyline();
}
else if( nextentity == "TEXT" )
{
processText();
}
else if( nextentity == "MTEXT" )
{
processMText();
}
else if( nextentity == "HATCH" )
{
processHatch();
}
else if( nextentity == "SPLINE" )
{
processSpline();
}
else if( nextentity == "3DFACE" )
{
process3dface();
}
else if( nextentity == "VIEWPORT" )
{
processViewport();
}
else if( nextentity == "IMAGE" )
{
processImage();
}
else if( nextentity == "DIMENSION" )
{
processDimension();
}
else if( nextentity == "LEADER" )
{
processLeader();
}
else if( nextentity == "RAY" )
{
processRay();
}
else if( nextentity == "XLINE" )
{
processXline();
}
else
{
if( reader->readRec( &code, !binary ) )
{
if( code == 0 )
nextentity = reader->getString();
}
else
return false; // end of file without ENDSEC
}
} while( next );
return true;
}
bool dxfRW::processEllipse()
{
DBG( "dxfRW::processEllipse" );
int code;
DRW_Ellipse ellipse;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
if( applyExt )
ellipse.applyExtrusion();
iface->addEllipse( ellipse );
return true; // found new entity or ENDSEC, terminate
}
default:
ellipse.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processTrace()
{
DBG( "dxfRW::processTrace" );
int code;
DRW_Trace trace;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
if( applyExt )
trace.applyExtrusion();
iface->addTrace( trace );
return true; // found new entity or ENDSEC, terminate
}
default:
trace.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processSolid()
{
DBG( "dxfRW::processSolid" );
int code;
DRW_Solid solid;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
if( applyExt )
solid.applyExtrusion();
iface->addSolid( solid );
return true; // found new entity or ENDSEC, terminate
}
default:
solid.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::process3dface()
{
DBG( "dxfRW::process3dface" );
int code;
DRW_3Dface face;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->add3dFace( face );
return true; // found new entity or ENDSEC, terminate
}
default:
face.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processViewport()
{
DBG( "dxfRW::processViewport" );
int code;
DRW_Viewport vp;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addViewport( vp );
return true; // found new entity or ENDSEC, terminate
}
default:
vp.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processPoint()
{
DBG( "dxfRW::processPoint\n" );
int code;
DRW_Point point;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addPoint( point );
return true; // found new entity or ENDSEC, terminate
}
default:
point.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processLine()
{
DBG( "dxfRW::processLine\n" );
int code;
DRW_Line line;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addLine( line );
return true; // found new entity or ENDSEC, terminate
}
default:
line.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processRay()
{
DBG( "dxfRW::processRay\n" );
int code;
DRW_Ray line;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addRay( line );
return true; // found new entity or ENDSEC, terminate
}
default:
line.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processXline()
{
DBG( "dxfRW::processXline\n" );
int code;
DRW_Xline line;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addXline( line );
return true; // found new entity or ENDSEC, terminate
}
default:
line.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processCircle()
{
DBG( "dxfRW::processPoint\n" );
int code;
DRW_Circle circle;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
if( applyExt )
circle.applyExtrusion();
iface->addCircle( circle );
return true; // found new entity or ENDSEC, terminate
}
default:
circle.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processArc()
{
DBG( "dxfRW::processPoint\n" );
int code;
DRW_Arc arc;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
if( applyExt )
arc.applyExtrusion();
iface->addArc( arc );
return true; // found new entity or ENDSEC, terminate
}
default:
arc.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processInsert()
{
DBG( "dxfRW::processInsert" );
int code;
DRW_Insert insert;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addInsert( insert );
return true; // found new entity or ENDSEC, terminate
}
default:
insert.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processLWPolyline()
{
DBG( "dxfRW::processLWPolyline" );
int code;
DRW_LWPolyline pl;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
if( applyExt )
pl.applyExtrusion();
iface->addLWPolyline( pl );
return true; // found new entity or ENDSEC, terminate
}
default:
pl.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processPolyline()
{
DBG( "dxfRW::processPolyline" );
int code;
DRW_Polyline pl;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
if( nextentity != "VERTEX" )
{
iface->addPolyline( pl );
return true; // found new entity or ENDSEC, terminate
}
else
{
processVertex( &pl );
}
}
default:
pl.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processVertex( DRW_Polyline* pl )
{
DBG( "dxfRW::processVertex" );
int code;
DRW_Vertex* v = new DRW_Vertex();
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
pl->appendVertex( v );
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
if( nextentity == "SEQEND" )
{
return true; // found SEQEND no more vertex, terminate
}
else if( nextentity == "VERTEX" )
{
v = new DRW_Vertex(); // another vertex
}
}
default:
v->parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processText()
{
DBG( "dxfRW::processText" );
int code;
DRW_Text txt;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addText( txt );
return true; // found new entity or ENDSEC, terminate
}
default:
txt.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processMText()
{
DBG( "dxfRW::processMText" );
int code;
DRW_MText txt;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
txt.updateAngle();
iface->addMText( txt );
return true; // found new entity or ENDSEC, terminate
}
default:
txt.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processHatch()
{
DBG( "dxfRW::processHatch" );
int code;
DRW_Hatch hatch;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addHatch( &hatch );
return true; // found new entity or ENDSEC, terminate
}
default:
hatch.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processSpline()
{
DBG( "dxfRW::processSpline" );
int code;
DRW_Spline sp;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addSpline( &sp );
return true; // found new entity or ENDSEC, terminate
}
default:
sp.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processImage()
{
DBG( "dxfRW::processImage" );
int code;
DRW_Image img;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addImage( &img );
return true; // found new entity or ENDSEC, terminate
}
default:
img.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processDimension()
{
DBG( "dxfRW::processDimension" );
int code;
DRW_Dimension dim;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
int type = dim.type & 0x0F;
switch( type )
{
case 0:
{
DRW_DimLinear d( dim );
iface->addDimLinear( &d );
break;
}
case 1:
{
DRW_DimAligned d( dim );
iface->addDimAlign( &d );
break;
}
case 2:
{
DRW_DimAngular d( dim );
iface->addDimAngular( &d );
break;
}
case 3:
{
DRW_DimDiametric d( dim );
iface->addDimDiametric( &d );
break;
}
case 4:
{
DRW_DimRadial d( dim );
iface->addDimRadial( &d );
break;
}
case 5:
{
DRW_DimAngular3p d( dim );
iface->addDimAngular3P( &d );
break;
}
case 6:
{
DRW_DimOrdinate d( dim );
iface->addDimOrdinate( &d );
break;
}
}
return true; // found new entity or ENDSEC, terminate
}
default:
dim.parseCode( code, reader );
break;
}
}
return true;
}
bool dxfRW::processLeader()
{
DBG( "dxfRW::processLeader" );
int code;
DRW_Leader leader;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->addLeader( &leader );
return true; // found new entity or ENDSEC, terminate
}
default:
leader.parseCode( code, reader );
break;
}
}
return true;
}
/********* Objects Section *********/
bool dxfRW::processObjects()
{
DBG( "dxfRW::processObjects\n" );
int code;
if( !reader->readRec( &code, !binary ) )
{
return false;
}
bool next = true;
if( code == 0 )
{
nextentity = reader->getString();
}
else
{
return false; // first record in objects is 0
}
do {
if( nextentity == "ENDSEC" )
{
return true; // found ENDSEC terminate
}
else if( nextentity == "IMAGEDEF" )
{
processImageDef();
}
else
{
if( reader->readRec( &code, !binary ) )
{
if( code == 0 )
nextentity = reader->getString();
}
else
return false; // end of file without ENDSEC
}
} while( next );
return true;
}
bool dxfRW::processImageDef()
{
DBG( "dxfRW::processImageDef" );
int code;
DRW_ImageDef img;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
switch( code )
{
case 0:
{
nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" );
iface->linkImage( &img );
return true; // found new entity or ENDSEC, terminate
}
default:
img.parseCode( code, reader );
break;
}
}
return true;
}
/** utility function
* convert a int to string in hex
**/
std::string dxfRW::toHexStr( int n )
{
#if defined(__APPLE__)
std::string buffer( 9, '\0' );
snprintf( &buffer[0], 9, "%X", n );
return buffer;
#else
std::ostringstream Convert;
Convert << std::uppercase << std::hex << n;
return Convert.str();
#endif
}
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed 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. **
** You should have received a copy of the GNU General Public License **
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
******************************************************************************/
#ifndef LIBDXFRW_H
#define LIBDXFRW_H
#include <string>
#include "drw_entities.h"
#include "drw_objects.h"
#include "drw_interface.h"
class dxfReader;
class dxfWriter;
class dxfRW
{
public:
dxfRW( const char* name );
~dxfRW();
// / reads the file specified in constructor
/*!
* An interface must be provided. It is used by the class to signal various
* components being added.
* @param interface_ the interface to use
* @param ext should the extrusion be applied to convert in 2D?
* @return true for success
*/
bool read( DRW_Interface* interface_, bool ext );
void setBinary( bool b ) { binary = b; }
bool write( DRW_Interface* interface_, DRW::Version ver, bool bin );
bool writeLineType( DRW_LType* ent );
bool writeLayer( DRW_Layer* ent );
bool writeDimstyle( DRW_Dimstyle* ent );
bool writeTextstyle( DRW_Textstyle* ent );
bool writeVport( DRW_Vport* ent );
bool writePoint( DRW_Point* ent );
bool writeLine( DRW_Line* ent );
bool writeRay( DRW_Ray* ent );
bool writeXline( DRW_Xline* ent );
bool writeCircle( DRW_Circle* ent );
bool writeArc( DRW_Arc* ent );
bool writeEllipse( DRW_Ellipse* ent );
bool writeTrace( DRW_Trace* ent );
bool writeSolid( DRW_Solid* ent );
bool write3dface( DRW_3Dface* ent );
bool writeLWPolyline( DRW_LWPolyline* ent );
bool writePolyline( DRW_Polyline* ent );
bool writeSpline( DRW_Spline* ent );
bool writeBlockRecord( std::string name );
bool writeBlock( DRW_Block* ent );
bool writeInsert( DRW_Insert* ent );
bool writeMText( DRW_MText* ent );
bool writeText( DRW_Text* ent );
bool writeHatch( DRW_Hatch* ent );
bool writeViewport( DRW_Viewport* ent );
DRW_ImageDef* writeImage( DRW_Image* ent, std::string name );
bool writeLeader( DRW_Leader* ent );
bool writeDimension( DRW_Dimension* ent );
void setEllipseParts( int parts ) { elParts = parts; } /*!< set parts munber when convert ellipse to polyline */
private:
// / used by read() to parse the content of the file
bool processDxf();
bool processHeader();
bool processTables();
bool processBlocks();
bool processBlock();
bool processEntities( bool isblock );
bool processObjects();
bool processLType();
bool processLayer();
bool processDimStyle();
bool processTextStyle();
bool processVports();
bool processPoint();
bool processLine();
bool processRay();
bool processXline();
bool processCircle();
bool processArc();
bool processEllipse();
bool processTrace();
bool processSolid();
bool processInsert();
bool processLWPolyline();
bool processPolyline();
bool processVertex( DRW_Polyline* pl );
bool processText();
bool processMText();
bool processHatch();
bool processSpline();
bool process3dface();
bool processViewport();
bool processImage();
bool processImageDef();
bool processDimension();
bool processLeader();
// bool writeHeader();
bool writeEntity( DRW_Entity* ent );
bool writeTables();
bool writeBlocks();
bool writeObjects();
std::string toHexStr( int n );
private:
DRW::Version version;
std::string fileName;
std::string codePage;
bool binary;
dxfReader* reader;
dxfWriter* writer;
DRW_Interface* iface;
DRW_Header header;
// int section;
string nextentity;
int entCount;
bool wlayer0;
bool dimstyleStd;
bool applyExt;
bool writingBlock;
int elParts; /*!< parts munber when convert ellipse to polyline */
std::map<std::string, int> blockMap;
std::vector<DRW_ImageDef*> imageDef; /*!< imageDef list */
int currHandle;
};
#endif // LIBDXFRW_H
...@@ -26,6 +26,8 @@ include_directories( ...@@ -26,6 +26,8 @@ include_directories(
../common ../common
../polygon ../polygon
../common/dialogs ../common/dialogs
../lib_dxf
./import_dxf
${INC_AFTER} ${INC_AFTER}
) )
...@@ -114,6 +116,11 @@ set( PCBNEW_DIALOGS ...@@ -114,6 +116,11 @@ set( PCBNEW_DIALOGS
dialogs/dialog_footprint_wizard_list.cpp dialogs/dialog_footprint_wizard_list.cpp
) )
set( PCBNEW_IMPORT_DXF
import_dxf/dialog_dxf_import.cpp
import_dxf/dxf2brd_items.cpp
)
set( PCBNEW_AUTOROUTER_SRCS set( PCBNEW_AUTOROUTER_SRCS
autorouter/automove.cpp autorouter/automove.cpp
autorouter/autoplac.cpp autorouter/autoplac.cpp
...@@ -145,6 +152,7 @@ set( PCBNEW_CLASS_SRCS ...@@ -145,6 +152,7 @@ set( PCBNEW_CLASS_SRCS
cross-probing.cpp cross-probing.cpp
deltrack.cpp deltrack.cpp
${PCBNEW_DIALOGS} ${PCBNEW_DIALOGS}
${PCBNEW_IMPORT_DXF}
dragsegm.cpp dragsegm.cpp
drc.cpp drc.cpp
drc_clearance_test_functions.cpp drc_clearance_test_functions.cpp
...@@ -347,6 +355,7 @@ if( KICAD_SCRIPTING_MODULES ) ...@@ -347,6 +355,7 @@ if( KICAD_SCRIPTING_MODULES )
pcbcommon pcbcommon
common common
pcad2kicadpcb pcad2kicadpcb
lib_dxf
${GITHUB_PLUGIN_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES}
polygon polygon
bitmaps bitmaps
...@@ -515,6 +524,7 @@ target_link_libraries( pcbnew ...@@ -515,6 +524,7 @@ target_link_libraries( pcbnew
pcad2kicadpcb pcad2kicadpcb
polygon polygon
bitmaps bitmaps
lib_dxf
${GITHUB_PLUGIN_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES}
${wxWidgets_LIBRARIES} ${wxWidgets_LIBRARIES}
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
......
...@@ -51,10 +51,9 @@ ...@@ -51,10 +51,9 @@
#include <class_pcb_text.h> #include <class_pcb_text.h>
#include <modview_frame.h> #include <modview_frame.h>
#include <class_pcb_layer_box_selector.h> #include <class_pcb_layer_box_selector.h>
#include <dialog_drc.h> #include <dialog_drc.h>
#include <dialog_global_edit_tracks_and_vias.h> #include <dialog_global_edit_tracks_and_vias.h>
#include <invoke_pcb_dialog.h>
// Handles the selection of command events. // Handles the selection of command events.
void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
...@@ -1185,6 +1184,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -1185,6 +1184,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
ArchiveModulesOnBoard( wxEmptyString, false ); ArchiveModulesOnBoard( wxEmptyString, false );
break; break;
case ID_GEN_IMPORT_DXF_FILE:
InvokeDXFDialogImport( this );
m_canvas->Refresh();
break;
default: default:
wxString msg; wxString msg;
msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ), msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() unknown event id %d" ),
......
#include <dxf2brd_items.h>
#include <wxPcbStruct.h>
#include <convert_from_iu.h>
bool InvokeDXFDialogImport( PCB_EDIT_FRAME* aCaller )
{
wxFileDialog dlg( aCaller,
wxT( "Open File" ),
wxEmptyString, wxEmptyString,
wxT( "dxf Files (*.dxf)|*.dxf|*.DXF" ),
wxFD_OPEN|wxFD_FILE_MUST_EXIST );
dlg.ShowModal();
wxString fileName = dlg.GetPath();
if( !fileName.IsEmpty() )
{
BOARD * brd = aCaller->GetBoard();
DXF2BRD_CONVERTER dxf_importer;
// Set coordinates offset for import (offset is given in mm)
double offsetY = - aCaller->GetPageSizeIU().y * MM_PER_IU;
dxf_importer.SetOffset( 0.0, offsetY );
dxf_importer.SetBrdLayer( DRAW_N );
dxf_importer.ImportDxfFile( fileName, brd );
}
return true;
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
// The DXF reader lib (libdxfrw) comes from LibreCAD project, a 2D CAD program
// libdxfrw can be found on http://sourceforge.net/projects/libdxfrw/
// or (latest sources) on
// https://github.com/LibreCAD/LibreCAD/tree/master/libraries/libdxfrw/src
//
// There is no doc to use it, but have a look to
// https://github.com/LibreCAD/LibreCAD/blob/master/librecad/src/lib/filters/rs_filterdxf.cpp
// and https://github.com/LibreCAD/LibreCAD/blob/master/librecad/src/lib/filters/rs_filterdxf.h
// Each time a dxf entity is read, a "call back" fuction is called
// like void DXF2BRD_CONVERTER::addLine( const DRW_Line& data ) when a line is read.
// this function just add the BOARD entity from dxf parameters (start and end point ...)
#include "libdxfrw.h"
#include "dxf2brd_items.h"
#include <wx/arrstr.h>
#include <wx/regex.h>
#include <trigo.h>
#include <class_board.h>
#include <class_drawsegment.h>
#include <class_pcb_text.h>
DXF2BRD_CONVERTER::DXF2BRD_CONVERTER() : DRW_Interface()
{
m_xOffset = 0.0; // X coord offset for conversion (in mm)
m_yOffset = 0.0; // Y coord offset for conversion (in mm)
m_Dfx2mm = 1.0; // The scale factor to convert DXF units to mm
m_dxf = NULL;
m_brd = NULL;
m_version = 0;
m_defaultThickness = 0.1;
m_brdLayer = DRAW_N;
}
DXF2BRD_CONVERTER::~DXF2BRD_CONVERTER()
{
}
// coordinate conversions from dxf to internal units
int DXF2BRD_CONVERTER::mapX( double aDxfCoordX )
{
return Millimeter2iu( m_xOffset + (aDxfCoordX * m_Dfx2mm) );
}
int DXF2BRD_CONVERTER::mapY( double aDxfCoordY )
{
return Millimeter2iu( -m_yOffset - (aDxfCoordY * m_Dfx2mm) );
}
int DXF2BRD_CONVERTER::mapDim( double aDxfValue )
{
return Millimeter2iu( aDxfValue * m_Dfx2mm );
}
/**
* Implementation of the method used for communicate
* with this filter.
*
* @param aFile = the full filename.
* @param aLayersList = where to store the list of layer names
*/
bool DXF2BRD_CONVERTER::ImportDxfFile( const wxString& aFile, BOARD* aBoard )
{
m_brd = aBoard;
m_dxf = new dxfRW( aFile.ToUTF8() );
bool success = m_dxf->read( this, true );
if( success==false )
{
return false;
}
delete m_dxf;
m_dxf = NULL;
return true;
}
/**
* Implementation of the method which handles layers.
*/
void DXF2BRD_CONVERTER::addLayer( const DRW_Layer& data )
{
#if 0
wxString name = wxString::FromUTF8( data.name.c_str() );
wxLogMessage( name );
#endif
}
/*
* Import line entities.
*/
void DXF2BRD_CONVERTER::addLine( const DRW_Line& data )
{
DRAWSEGMENT* segm = new DRAWSEGMENT( m_brd );
segm->SetLayer( m_brdLayer );
wxPoint start( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
segm->SetStart( start );
wxPoint end( mapX( data.secPoint.x ), mapY( data.secPoint.y ) );
segm->SetEnd( end );
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
m_brd->Add( segm );
}
/*
* Import Circle entities.
*/
void DXF2BRD_CONVERTER::addCircle( const DRW_Circle& data )
{
DRAWSEGMENT* segm = new DRAWSEGMENT( m_brd );
segm->SetLayer( m_brdLayer );
segm->SetShape( S_CIRCLE );
wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
segm->SetPosition( center );
wxPoint circle_start( mapX( data.basePoint.x + data.radious ),
mapY( data.basePoint.y ) );
segm->SetEnd( circle_start );
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
m_brd->Add( segm );
}
/*
* Import Arc entities.
*/
void DXF2BRD_CONVERTER::addArc( const DRW_Arc& data )
{
DRAWSEGMENT* segm = new DRAWSEGMENT( m_brd );
segm->SetLayer( m_brdLayer );
segm->SetShape( S_ARC );
// Init arc centre:
wxPoint center( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
segm->SetPosition( center );
// Init arc start point
double arcStartx = data.radious;
double arcStarty = 0;
RotatePoint( &arcStartx, &arcStarty, -RAD2DECIDEG( data.staangle ) );
wxPoint arcStart( mapX( arcStartx + data.basePoint.x ),
mapY( arcStarty + data.basePoint.y ) );
segm->SetEnd( arcStart );
// calculate arc angle (arcs are CCW, and should be < 0 in Pcbnew)
double angle = -RAD2DECIDEG( data.endangle - data.staangle );
if( angle > 0.0 )
angle -= 3600.0;
segm->SetAngle( angle );
segm->SetWidth( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
m_brd->Add( segm );
}
/**
* Import texts (TEXT).
*/
void DXF2BRD_CONVERTER::addText(const DRW_Text& data)
{
TEXTE_PCB* pcb_text = new TEXTE_PCB( m_brd );
pcb_text->SetLayer( m_brdLayer );
wxPoint refPoint( mapX(data.basePoint.x), mapY(data.basePoint.y) );
wxPoint secPoint( mapX(data.secPoint.x), mapY(data.secPoint.y) );
if (data.alignV !=0 || data.alignH !=0 ||data.alignH ==DRW_Text::HMiddle)
{
if (data.alignH !=DRW_Text::HAligned && data.alignH !=DRW_Text::HFit)
{
wxPoint tmp = secPoint;
secPoint = refPoint;
refPoint = tmp;
}
}
switch( data.alignV )
{
case DRW_Text::VBaseLine: // Top
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
break;
case DRW_Text::VBottom:
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
break;
case DRW_Text::VMiddle:
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
break;
case DRW_Text::VTop:
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
break;
}
switch( data.alignH )
{
case DRW_Text::HLeft:
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
break;
case DRW_Text::HCenter:
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
break;
case DRW_Text::HRight:
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
break;
case DRW_Text::HAligned:
// no equivalent options in text pcb.
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
break;
case DRW_Text::HMiddle:
// no equivalent options in text pcb.
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
break;
case DRW_Text::HFit:
// no equivalent options in text pcb.
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
break;
}
#if 0
wxString sty = wxString::FromUTF8(data.style.c_str());
sty=sty.ToLower();
if (data.textgen==2)
{
// Text dir = left to right;
} else if (data.textgen==4)
{
/ Text dir = top to bottom;
} else
{
}
#endif
wxString text = toNativeString( wxString::FromUTF8( data.text.c_str() ) );
pcb_text->SetTextPosition( refPoint );
pcb_text->SetOrientation( data.angle * 10 );
// The 0.8 factor gives a better height/width ratio with our font
pcb_text->SetWidth( mapDim( data.height * 0.8 ) );
pcb_text->SetHeight( mapDim( data.height ) );
pcb_text->SetThickness( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
pcb_text->SetText( text );
m_brd->Add( pcb_text );
}
/**
* Import multi line texts (MTEXT).
*/
void DXF2BRD_CONVERTER::addMText( const DRW_MText& data )
{
wxString text = toNativeString( wxString::FromUTF8( data.text.c_str() ) );
wxString attrib, tmp;
/* Some texts start by '\' and have formating chars (font name, font option...)
* ending with ';'
* Here are some mtext formatting codes:
* Format code Purpose
* \0...\o Turns overline on and off
* \L...\l Turns underline on and off
* \~ Inserts a nonbreaking space
\\ Inserts a backslash
\\\{...\} Inserts an opening and closing brace
\\ \File name; Changes to the specified font file
\\ \Hvalue; Changes to the text height specified in drawing units
\\ \Hvaluex; Changes the text height to a multiple of the current text height
\\ \S...^...; Stacks the subsequent text at the \, #, or ^ symbol
\\ \Tvalue; Adjusts the space between characters, from.75 to 4 times
\\ \Qangle; Changes obliquing angle
\\ \Wvalue; Changes width factor to produce wide text
\\ \A Sets the alignment value; valid values: 0, 1, 2 (bottom, center, top) while( text.StartsWith( wxT("\\") ) )
*/
while( text.StartsWith( wxT( "\\" ) ) )
{
attrib << text.BeforeFirst( ';' );
tmp = text.AfterFirst( ';' );
text = tmp;
}
TEXTE_PCB* pcb_text = new TEXTE_PCB( m_brd );
pcb_text->SetLayer( m_brdLayer );
wxPoint textpos( mapX( data.basePoint.x ), mapY( data.basePoint.y ) );
pcb_text->SetTextPosition( textpos );
pcb_text->SetOrientation( data.angle * 10 );
// The 0.8 factor gives a better height/width ratio with our font
pcb_text->SetWidth( mapDim( data.height * 0.8 ) );
pcb_text->SetHeight( mapDim( data.height ) );
pcb_text->SetThickness( mapDim( data.thickness == 0 ? m_defaultThickness
: data.thickness ) );
pcb_text->SetText( text );
// Initialize text justifications:
if( data.textgen <= 3 )
{
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
}
else if( data.textgen <= 6 )
{
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER );
}
else
{
pcb_text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
}
if( data.textgen % 3 == 1 )
{
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
}
else if( data.textgen % 3 == 2 )
{
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER );
}
else
{
pcb_text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
}
#if 0 // These setting have no mening in Pcbnew
if( data.alignH==1 )
{
// Text is left to right;
}
else if( data.alignH == 3 )
{
// Text is top to bottom;
}
else
{
// use ByStyle;
}
if( data.alignV==1 )
{
// use AtLeast;
}
else
{
// useExact;
}
#endif
m_brd->Add( pcb_text );
}
/**
* Sets the header variables from the DXF file.
*/
void DXF2BRD_CONVERTER::addHeader( const DRW_Header* data )
{
std::map<std::string, DRW_Variant*>::const_iterator it;
for( it = data->vars.begin(); it != data->vars.end(); it++ )
{
std::string key = ( (*it).first ).c_str();
if( key == "$DWGCODEPAGE" )
{
DRW_Variant* var = (*it).second;
m_codePage = ( *var->content.s );
}
}
}
/**
* Converts a native unicode string into a DXF encoded string.
*
* DXF endoding includes the following special sequences:
* - %%%c for a diameter sign
* - %%%d for a degree sign
* - %%%p for a plus/minus sign
*/
wxString DXF2BRD_CONVERTER::toDxfString( const wxString& str )
{
wxString res;
int j = 0;
for( unsigned i = 0; i<str.length(); ++i )
{
int c = str[i];
if( c>175 || c<11 )
{
res.append( str.Mid( j, i - j ) );
j = i;
switch( c )
{
case 0x0A:
res += wxT("\\P");
break;
// diameter:
#ifdef __WINDOWS_
// windows, as always, is special.
case 0x00D8:
#else
case 0x2205:
#endif
res += wxT("%%C");
break;
// degree:
case 0x00B0:
res += wxT("%%D");
break;
// plus/minus
case 0x00B1:
res += wxT("%%P");
break;
default:
j--;
break;
}
j++;
}
}
res.append( str.Mid( j ) );
return res;
}
/**
* Converts a DXF encoded string into a native Unicode string.
*/
wxString DXF2BRD_CONVERTER::toNativeString( const wxString& data )
{
wxString res;
// Ignore font tags:
int j = 0;
for( unsigned i = 0; i<data.length(); ++i )
{
if( data[ i ] == 0x7B ) // is '{' ?
{
if( data[ i + 1 ] == 0x5c && data[ i + 2 ] == 0x66 ) // is "\f" ?
{
// found font tag, append parsed part
res.append( data.Mid( j, i - j ) );
// skip to ';'
for( unsigned k = i + 3; k < data.length(); ++k )
{
if( data[ k ] == 0x3B )
{
i = j = ++k;
break;
}
}
// add to '}'
for( unsigned k = i; k<data.length(); ++k )
{
if( data[ k ] == 0x7D )
{
res.append( data.Mid( i, k - i ) );
i = j = ++k;
break;
}
}
}
}
}
res.append( data.Mid( j ) );
#if 1
wxRegEx regexp;
// Line feed:
regexp.Compile( wxT( "\\\\P" ) );
regexp.Replace( &res, wxT( "\n" ) );
// Space:
regexp.Compile( wxT( "\\\\~" ) );
regexp.Replace( &res, wxT( " " ) );
// diameter:
regexp.Compile( wxT( "%%[cC]" ) );
#ifdef __WINDOWS__
// windows, as always, is special.
regexp.Replace( &res, wxChar( 0xD8 ) );
#else
// Empty_set, diameter is 0x2300
regexp.Replace( &res, wxChar( 0x2205 ) );
#endif
// degree:
regexp.Compile( wxT( "%%[dD]" ) );
regexp.Replace( &res, wxChar( 0x00B0 ) );
// plus/minus
regexp.Compile( wxT( "%%[pP]" ) );
regexp.Replace( &res, wxChar( 0x00B1 ) );
#endif
return res;
}
void DXF2BRD_CONVERTER::addTextStyle( const DRW_Textstyle& data )
{
// TODO
}
/****************************************************************************
**
** This file comes from the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2011 Rallaz, rallazz@gmail.com
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
**
**
** This file may be distributed and/or modified 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.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
**********************************************************************/
#ifndef FILTERDXFRW_H
#define FILTERDXFRW_H
#include "drw_interface.h"
#include "wx/wx.h"
class dxfRW;
class BOARD;
/**
* This format filter class can import and export DXF files.
* It depends on the dxflib library.
*
* @author Rallaz
*/
class DXF2BRD_CONVERTER : public DRW_Interface
{
private:
BOARD * m_brd;
double m_xOffset; // X coord offset for conversion (in mm)
double m_yOffset; // Y coord offset for conversion (in mm)
double m_defaultThickness; // default line thickness for conversion (in dxf units)
double m_Dfx2mm; // The scale factor to convert DXF units to mm
int m_brdLayer; // The board layer to place imported dfx items
int m_version;
std::string m_codePage;
dxfRW* m_dxf;
public:
DXF2BRD_CONVERTER();
~DXF2BRD_CONVERTER();
/**
* Set the coordinate offset between the importede dxf items
* and Pcbnew.
* because dxf files have the Y axis from bottom to top;
* aOffsetX = 0, and aOffsetY = - vertical page size to import a full page
* @param aOffsetX = the X offset in mm
* @param aOffsetY = the Y offset in mm
*/
void SetOffset( double aOffsetX, double aOffsetY )
{
m_xOffset =aOffsetX;
m_yOffset =aOffsetY;
}
/**
* Set the layer number to import dxf items.
* the layer should be a techicanl layer, not a copper layer
*/
void SetBrdLayer( int aBrdLayer ) { m_brdLayer = aBrdLayer; }
bool ImportDxfFile( const wxString& aFile, BOARD * aBoard );
private:
// coordinate conversions from dxf to internal units
int mapX( double aDxfCoordX );
int mapY( double aDxfCoordY );
int mapDim( double aDxfValue );
// Methods from DRW_CreationInterface:
// They are "call back" fonctions, called when the corresponding object
// is read in dxf file
// Depending of the application, they can do something or not
virtual void addHeader( const DRW_Header* data );
virtual void addLType( const DRW_LType& data ){}
virtual void addLayer( const DRW_Layer& data );
virtual void addDimStyle( const DRW_Dimstyle& data ){}
virtual void addBlock(const DRW_Block& data ){}
virtual void endBlock(){}
virtual void addPoint(const DRW_Point& data ){}
virtual void addLine(const DRW_Line& data);
virtual void addRay(const DRW_Ray& data ){}
virtual void addXline(const DRW_Xline& data ){}
virtual void addCircle(const DRW_Circle& data );
virtual void addArc(const DRW_Arc& data );
virtual void addEllipse(const DRW_Ellipse& data ){}
virtual void addLWPolyline(const DRW_LWPolyline& data ){}
virtual void addText(const DRW_Text& data );
virtual void addPolyline(const DRW_Polyline& data ){}
virtual void addSpline(const DRW_Spline* data ){}
virtual void addKnot(const DRW_Entity&) {}
virtual void addInsert(const DRW_Insert& data ){}
virtual void addTrace(const DRW_Trace& data ){}
virtual void addSolid(const DRW_Solid& data ){}
virtual void addMText(const DRW_MText& data);
virtual void addDimAlign(const DRW_DimAligned *data ){}
virtual void addDimLinear(const DRW_DimLinear *data ){}
virtual void addDimRadial(const DRW_DimRadial *data ){}
virtual void addDimDiametric(const DRW_DimDiametric *data ){}
virtual void addDimAngular(const DRW_DimAngular *data ){}
virtual void addDimAngular3P(const DRW_DimAngular3p *data ){}
virtual void addDimOrdinate(const DRW_DimOrdinate *data ){}
virtual void addLeader(const DRW_Leader *data ){}
virtual void addHatch(const DRW_Hatch* data ){}
virtual void addImage(const DRW_Image* data ){}
virtual void linkImage(const DRW_ImageDef* data ){}
virtual void add3dFace(const DRW_3Dface& data ){}
virtual void addComment(const char*){}
virtual void addVport(const DRW_Vport& data) {}
virtual void addTextStyle(const DRW_Textstyle& data);
virtual void addViewport(const DRW_Viewport& data) {}
virtual void setBlock(const int handle) {}
static wxString toDxfString(const wxString& str);
static wxString toNativeString(const wxString& data);
// These functions are not used in Kicad.
// But because they are virtual pure in DRW_Interface, they should be defined
virtual void writeTextstyles() {}
virtual void writeVports() {}
virtual void writeHeader(DRW_Header& data) {}
virtual void writeEntities() {}
virtual void writeLTypes() {}
virtual void writeLayers() {}
virtual void writeBlockRecords() {}
virtual void writeBlocks() {}
virtual void writeDimstyles() {}
void writeLine();
void writeMtext();
};
#endif // FILTERDXFRW_H
/**
* @file invoke_pcb_dialog.h
*/
/* /* This program source code file is part of KiCad, a free EDA CAD application.
* This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2013 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2013 KiCad Developers, see change_log.txt for contributors.
...@@ -75,5 +77,14 @@ int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal, F ...@@ -75,5 +77,14 @@ int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal, F
void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller, void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller,
const wxString& aNickname, const wxString& aOptions, wxString* aResult ); const wxString& aNickname, const wxString& aOptions, wxString* aResult );
/**
* Function InvokePcbLibTableEditor
* shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables.
*
* @param aCaller is the wxTopLevelWindow which is invoking the dialog.
* @return true if the ilport was made.
*/
bool InvokeDXFDialogImport( PCB_EDIT_FRAME* aCaller );
#endif // INVOKE_A_DIALOG_H_ #endif // INVOKE_A_DIALOG_H_
...@@ -174,6 +174,11 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() ...@@ -174,6 +174,11 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
_( "Import a routed \"Specctra Session\" (*.ses) file" ), _( "Import a routed \"Specctra Session\" (*.ses) file" ),
KiBitmap( import_xpm ) ); KiBitmap( import_xpm ) );
AddMenuItem( submenuImport, ID_GEN_IMPORT_DXF_FILE,
_( "&DXF File" ),
_( "Import a 2D Drawing DXF file to Pcbnew on the Drawings layer" ),
KiBitmap( import_xpm ) );
AddMenuItem( filesMenu, submenuImport, AddMenuItem( filesMenu, submenuImport,
ID_GEN_IMPORT_FILE, _( "&Import" ), ID_GEN_IMPORT_FILE, _( "&Import" ),
_( "Import files" ), KiBitmap( import_xpm ) ); _( "Import files" ), KiBitmap( import_xpm ) );
......
...@@ -105,6 +105,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) ...@@ -105,6 +105,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_GEN_IMPORT_SPECCTRA_SESSION,PCB_EDIT_FRAME::ImportSpecctraSession ) EVT_MENU( ID_GEN_IMPORT_SPECCTRA_SESSION,PCB_EDIT_FRAME::ImportSpecctraSession )
EVT_MENU( ID_GEN_IMPORT_SPECCTRA_DESIGN, PCB_EDIT_FRAME::ImportSpecctraDesign ) EVT_MENU( ID_GEN_IMPORT_SPECCTRA_DESIGN, PCB_EDIT_FRAME::ImportSpecctraDesign )
EVT_MENU( ID_GEN_IMPORT_DXF_FILE, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_ARCHIVE_NEW_MODULES, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_MENU_ARCHIVE_NEW_MODULES, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_ARCHIVE_ALL_MODULES, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_MENU_ARCHIVE_ALL_MODULES, PCB_EDIT_FRAME::Process_Special_Functions )
......
...@@ -252,6 +252,7 @@ enum pcbnew_ids ...@@ -252,6 +252,7 @@ enum pcbnew_ids
ID_GEN_EXPORT_FILE_MODULE_REPORT, ID_GEN_EXPORT_FILE_MODULE_REPORT,
ID_GEN_IMPORT_SPECCTRA_SESSION, ID_GEN_IMPORT_SPECCTRA_SESSION,
ID_GEN_IMPORT_SPECCTRA_DESIGN, ID_GEN_IMPORT_SPECCTRA_DESIGN,
ID_GEN_IMPORT_DXF_FILE,
ID_TOOLBARH_PCB_MODE_MODULE, ID_TOOLBARH_PCB_MODE_MODULE,
ID_TOOLBARH_PCB_MODE_TRACKS, ID_TOOLBARH_PCB_MODE_TRACKS,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment