Commit ede0daf9 authored by jean-pierre charras's avatar jean-pierre charras

lib_dxf: Update to version 0.5.13 (previous: 0.5.11) due to a bug (memory...

lib_dxf: Update to version 0.5.13 (previous: 0.5.11) due to a bug (memory leak) fixed in 0.5.13, which has also more comments, and try to fix most of coverity warnings (not initialized class members).
These members are now initialized, which also fix some other more serious coverity issues.
parent d5e70c93
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#ifndef DRW_BASE_H #ifndef DRW_BASE_H
#define DRW_BASE_H #define DRW_BASE_H
#define DRW_VERSION "0.5.11" #define DRW_VERSION "0.5.13"
#include <string> #include <string>
#include <cmath> #include <cmath>
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
namespace DRW { namespace DRW {
// ! Version numbers for the DXF Format. // ! Version numbers for the DXF Format.
enum Version { enum Version
{
UNKNOWNV, /*!< UNKNOWN VERSION. */ UNKNOWNV, /*!< UNKNOWN VERSION. */
AC1006, /*!< R10. */ AC1006, /*!< R10. */
AC1009, /*!< R11 & R12. */ AC1009, /*!< R11 & R12. */
...@@ -54,7 +55,8 @@ enum Version { ...@@ -54,7 +55,8 @@ enum Version {
AC1024 /*!< ACAD 2010. */ AC1024 /*!< ACAD 2010. */
}; };
enum error { enum error
{
BAD_NONE, /*!< No error. */ BAD_NONE, /*!< No error. */
BAD_UNKNOWN, /*!< UNKNOWN. */ BAD_UNKNOWN, /*!< UNKNOWN. */
BAD_OPEN, /*!< error opening file. */ BAD_OPEN, /*!< error opening file. */
...@@ -76,7 +78,7 @@ enum error { ...@@ -76,7 +78,7 @@ enum error {
class DRW_Coord class DRW_Coord
{ {
public: public:
DRW_Coord() { x = 0; y = 0; z = 0; } DRW_Coord(): x(0), y(0), z(0) {}
DRW_Coord( double ix, double iy, double iz ) DRW_Coord( double ix, double iy, double iz )
{ {
x = ix; y = iy; z = iz; x = ix; y = iy; z = iz;
...@@ -121,15 +123,15 @@ public: ...@@ -121,15 +123,15 @@ public:
DRW_Vertex2D() DRW_Vertex2D()
{ {
// eType = DRW::LWPOLYLINE; // eType = DRW::LWPOLYLINE;
stawidth = endwidth = bulge = 0; x = y = stawidth = endwidth = bulge = 0.0;
} }
DRW_Vertex2D( double sx, double sy, double b ) DRW_Vertex2D( double sx, double sy, double b )
{ {
stawidth = endwidth = 0; stawidth = endwidth = 0;
x = sx; x = sx;
y = sy; y = sy;
bulge = b; bulge = b;
} }
public: public:
...@@ -149,7 +151,8 @@ public: ...@@ -149,7 +151,8 @@ public:
class DRW_Variant class DRW_Variant
{ {
public: public:
enum TYPE { enum TYPE
{
STRING, STRING,
INTEGER, INTEGER,
DOUBLE, DOUBLE,
...@@ -162,46 +165,63 @@ public: ...@@ -162,46 +165,63 @@ public:
type = INVALID; type = INVALID;
} }
~DRW_Variant() DRW_Variant( const DRW_Variant& d )
{ {
if( type == COORD ) code = d.code;
delete content.v; type = d.type;
if( d.type == COORD ) vdata = d.vdata;
if( d.type == STRING ) sdata = d.sdata;
content = d.content;
} }
enum TYPE type; DRW_Variant( int c, UTF8STRING s ) { addString( s ); code = c; }
DRW_Variant( int c, int i ) { addInt( i ); code = c; }
DRW_Variant( int c, double d ) { addDouble( d ); code = c; }
DRW_Variant( int c, double x, double y, double z )
{
setType( COORD ); vdata.x = x; vdata.y = y;
vdata.z = z; content.v = &vdata; code = c;
}
void addString( UTF8STRING s ) { setType( STRING ); data = s; content.s = &data; } ~DRW_Variant()
{
}
void addString( UTF8STRING s ) { setType( STRING ); sdata = s; content.s = &sdata; }
void addInt( int i ) { setType( INTEGER ); content.i = i; } void addInt( int i ) { setType( INTEGER ); content.i = i; }
void addDouble( double d ) { setType( DOUBLE ); content.d = d; } void addDouble( double d ) { setType( DOUBLE ); content.d = d; }
void addCoord( DRW_Coord* v ) { setType( COORD ); content.v = v; } void addCoord()
void setType( enum TYPE t )
{ {
if( type == COORD ) setType( COORD ); vdata.x = 0.0; vdata.y = 0.0; vdata.z = 0.0; content.v =
delete content.v; &vdata;
type = t;
} }
void setCoordX( double d ) { if( type == COORD ) content.v->x = d; } void addCoord( DRW_Coord v ) { setType( COORD ); vdata = v; content.v = &vdata; }
void setCoordY( double d ) { if( type == COORD ) content.v->y = d; } void setType( enum TYPE t ) { type = t; }
void setCoordZ( double d ) { if( type == COORD ) content.v->z = d; } void setCoordX( double d ) { if( type == COORD ) vdata.x = d; }
void setCoordY( double d ) { if( type == COORD ) vdata.y = d; }
void setCoordZ( double d ) { if( type == COORD ) vdata.z = d; }
private: private:
typedef union typedef union
{ {
UTF8STRING* s; UTF8STRING* s;
int i; int i;
double d; double d;
DRW_Coord* v; DRW_Coord* v;
} DRW_VarContent; } DRW_VarContent;
public: public:
DRW_VarContent content; DRW_VarContent content;
public: enum TYPE type;
int code; int code; /*!< dxf code of this value*/
// string version;
// string codepage;
private: private:
// DRW_VarContent content; std::string sdata;
std::string data; DRW_Coord vdata;
}; };
...@@ -215,7 +235,8 @@ private: ...@@ -215,7 +235,8 @@ private:
class DRW_LW_Conv class DRW_LW_Conv
{ {
public: public:
enum lineWidth { enum lineWidth
{
width00 = 0, /*!< 0.00mm (dxf 0)*/ width00 = 0, /*!< 0.00mm (dxf 0)*/
width01 = 1, /*!< 0.05mm (dxf 5)*/ width01 = 1, /*!< 0.05mm (dxf 5)*/
width02 = 2, /*!< 0.09mm (dxf 9)*/ width02 = 2, /*!< 0.09mm (dxf 9)*/
......
...@@ -22,23 +22,33 @@ ...@@ -22,23 +22,33 @@
*/ */
void DRW_Entity::calculateAxis( DRW_Coord extPoint ) void DRW_Entity::calculateAxis( DRW_Coord extPoint )
{ {
// Follow the arbitrary DXF definitions for extrusion axes.
if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 ) if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 )
{ {
// If we get here, implement Ax = Wy x N where Wy is [0,1,0] per the DXF spec.
// The cross product works out to Wy.y*N.z-Wy.z*N.y, Wy.z*N.x-Wy.x*N.z, Wy.x*N.y-Wy.y*N.x
// Factoring in the fixed values for Wy gives N.z,0,-N.x
extAxisX.x = extPoint.z; extAxisX.x = extPoint.z;
extAxisX.y = 0; extAxisX.y = 0;
extAxisX.z = -extPoint.x; extAxisX.z = -extPoint.x;
} }
else else
{ {
// Otherwise, implement Ax = Wz x N where Wz is [0,0,1] per the DXF spec.
// The cross product works out to Wz.y*N.z-Wz.z*N.y, Wz.z*N.x-Wz.x*N.z, Wz.x*N.y-Wz.y*N.x
// Factoring in the fixed values for Wz gives -N.y,N.x,0.
extAxisX.x = -extPoint.y; extAxisX.x = -extPoint.y;
extAxisX.y = extPoint.x; extAxisX.y = extPoint.x;
extAxisX.z = 0; extAxisX.z = 0;
} }
extAxisX.unitize(); extAxisX.unitize();
// Ay = N x Ax
extAxisY.x = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z); extAxisY.x = (extPoint.y * extAxisX.z) - (extAxisX.y * extPoint.z);
extAxisY.y = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x); extAxisY.y = (extPoint.z * extAxisX.x) - (extAxisX.z * extPoint.x);
extAxisY.z = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y); extAxisY.z = (extPoint.x * extAxisX.y) - (extAxisX.x * extPoint.y);
extAxisY.unitize(); extAxisY.unitize();
} }
...@@ -110,6 +120,58 @@ void DRW_Entity::parseCode( int code, dxfReader* reader ) ...@@ -110,6 +120,58 @@ void DRW_Entity::parseCode( int code, dxfReader* reader )
space = reader->getInt32(); space = reader->getInt32();
break; break;
case 1000:
case 1001:
case 1002:
case 1003:
case 1004:
case 1005:
extData.push_back( new DRW_Variant( code, reader->getString() ) );
break;
case 1010:
case 1011:
case 1012:
case 1013:
curr = new DRW_Variant();
curr->addCoord();
curr->setCoordX( reader->getDouble() );
curr->code = code;
extData.push_back( curr );
break;
case 1020:
case 1021:
case 1022:
case 1023:
if( curr )
curr->setCoordY( reader->getDouble() );
break;
case 1030:
case 1031:
case 1032:
case 1033:
if( curr )
curr->setCoordZ( reader->getDouble() );
curr = NULL;
break;
case 1040:
case 1041:
case 1042:
extData.push_back( new DRW_Variant( code, reader->getDouble() ) );
break;
case 1070:
case 1071:
extData.push_back( new DRW_Variant( code, reader->getInt32() ) );
break;
default: default:
break; break;
} }
...@@ -137,8 +199,8 @@ void DRW_Point::parseCode( int code, dxfReader* reader ) ...@@ -137,8 +199,8 @@ void DRW_Point::parseCode( int code, dxfReader* reader )
break; break;
case 210: case 210:
haveExtrusion = true; haveExtrusion = true;
extPoint.x = reader->getDouble(); extPoint.x = reader->getDouble();
break; break;
case 220: case 220:
...@@ -183,6 +245,8 @@ void DRW_Circle::applyExtrusion() ...@@ -183,6 +245,8 @@ void DRW_Circle::applyExtrusion()
{ {
if( haveExtrusion ) if( haveExtrusion )
{ {
// NOTE: Commenting these out causes the the arcs being tested to be located
// on the other side of the y axis (all x dimensions are negated).
calculateAxis( extPoint ); calculateAxis( extPoint );
extrudePoint( extPoint, &basePoint ); extrudePoint( extPoint, &basePoint );
} }
...@@ -204,6 +268,30 @@ void DRW_Circle::parseCode( int code, dxfReader* reader ) ...@@ -204,6 +268,30 @@ void DRW_Circle::parseCode( int code, dxfReader* reader )
} }
void DRW_Arc::applyExtrusion()
{
DRW_Circle::applyExtrusion();
if( haveExtrusion )
{
// If the extrusion vector has a z value less than 0, the angles for the arc
// have to be mirrored since DXF files use the right hand rule.
// Note that the following code only handles the special case where there is a 2D
// drawing with the z axis heading into the paper (or rather screen). An arbitrary
// extrusion axis (with x and y values greater than 1/64) may still have issues.
if( fabs( extPoint.x ) < 0.015625 && fabs( extPoint.y ) < 0.015625 && extPoint.z < 0.0 )
{
staangle = M_PI - staangle;
endangle = M_PI - endangle;
double temp = staangle;
staangle = endangle;
endangle = temp;
}
}
}
void DRW_Arc::parseCode( int code, dxfReader* reader ) void DRW_Arc::parseCode( int code, dxfReader* reader )
{ {
switch( code ) switch( code )
...@@ -309,9 +397,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts ) ...@@ -309,9 +397,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts )
radMajor = sqrt( secPoint.x * secPoint.x + secPoint.y * secPoint.y ); radMajor = sqrt( secPoint.x * secPoint.x + secPoint.y * secPoint.y );
radMinor = radMajor * ratio; radMinor = radMajor * ratio;
// calculate sin & cos of included angle // calculate sin & cos of included angle
incAngle = atan2( secPoint.y, secPoint.x ); incAngle = atan2( secPoint.y, secPoint.x );
cosRot = cos( incAngle ); cosRot = cos( incAngle );
sinRot = sin( incAngle ); sinRot = sin( incAngle );
incAngle = M_PIx2 / parts; incAngle = M_PIx2 / parts;
curAngle = staparam; curAngle = staparam;
int i = curAngle / incAngle; int i = curAngle / incAngle;
...@@ -336,9 +424,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts ) ...@@ -336,9 +424,9 @@ void DRW_Ellipse::toPolyline( DRW_Polyline* pol, int parts )
pol->flags = 1; pol->flags = 1;
} }
pol->layer = this->layer; pol->layer = this->layer;
pol->lineType = this->lineType; pol->lineType = this->lineType;
pol->color = this->color; pol->color = this->color;
pol->lWeight = this->lWeight; pol->lWeight = this->lWeight;
pol->extPoint = this->extPoint; pol->extPoint = this->extPoint;
} }
...@@ -487,8 +575,8 @@ void DRW_LWPolyline::applyExtrusion() ...@@ -487,8 +575,8 @@ void DRW_LWPolyline::applyExtrusion()
for( unsigned int i = 0; i<vertlist.size(); i++ ) for( unsigned int i = 0; i<vertlist.size(); i++ )
{ {
DRW_Vertex2D* vert = vertlist.at( i ); DRW_Vertex2D* vert = vertlist.at( i );
DRW_Coord v( vert->x, vert->y, elevation ); DRW_Coord v( vert->x, vert->y, elevation );
extrudePoint( extPoint, &v ); extrudePoint( extPoint, &v );
vert->x = v.x; vert->x = v.x;
vert->y = v.y; vert->y = v.y;
...@@ -502,12 +590,12 @@ void DRW_LWPolyline::parseCode( int code, dxfReader* reader ) ...@@ -502,12 +590,12 @@ void DRW_LWPolyline::parseCode( int code, dxfReader* reader )
switch( code ) switch( code )
{ {
case 10: case 10:
{ {
vertex = new DRW_Vertex2D(); vertex = new DRW_Vertex2D();
vertlist.push_back( vertex ); vertlist.push_back( vertex );
vertex->x = reader->getDouble(); vertex->x = reader->getDouble();
break; break;
} }
case 20: case 20:
...@@ -559,8 +647,8 @@ void DRW_LWPolyline::parseCode( int code, dxfReader* reader ) ...@@ -559,8 +647,8 @@ void DRW_LWPolyline::parseCode( int code, dxfReader* reader )
break; break;
case 210: case 210:
haveExtrusion = true; haveExtrusion = true;
extPoint.x = reader->getDouble(); extPoint.x = reader->getDouble();
break; break;
case 220: case 220:
...@@ -779,19 +867,19 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader ) ...@@ -779,19 +867,19 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader )
{ {
break; break;
} }
else if( reader->getInt32() == 1 ) // line else if( reader->getInt32() == 1 ) // line
{ {
addLine(); addLine();
} }
else if( reader->getInt32() == 2 ) // arc else if( reader->getInt32() == 2 ) // arc
{ {
addArc(); addArc();
} }
else if( reader->getInt32() == 3 ) // elliptic arc else if( reader->getInt32() == 3 ) // elliptic arc
{ {
addEllipse(); addEllipse();
} }
else if( reader->getInt32() == 4 ) // spline else if( reader->getInt32() == 4 ) // spline
{ {
addSpline(); addSpline();
} }
...@@ -804,8 +892,8 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader ) ...@@ -804,8 +892,8 @@ void DRW_Hatch::parseCode( int code, dxfReader* reader )
pt->basePoint.x = reader->getDouble(); pt->basePoint.x = reader->getDouble();
else if( pline ) else if( pline )
{ {
plvert = pline->addVertex(); plvert = pline->addVertex();
plvert->x = reader->getDouble(); plvert->x = reader->getDouble();
} }
break; break;
...@@ -1018,12 +1106,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader ) ...@@ -1018,12 +1106,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader )
break; break;
case 10: case 10:
{ {
controlpoint = new DRW_Coord(); controlpoint = new DRW_Coord();
controllist.push_back( controlpoint ); controllist.push_back( controlpoint );
controlpoint->x = reader->getDouble(); controlpoint->x = reader->getDouble();
break; break;
} }
case 20: case 20:
...@@ -1040,12 +1128,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader ) ...@@ -1040,12 +1128,12 @@ void DRW_Spline::parseCode( int code, dxfReader* reader )
break; break;
case 11: case 11:
{ {
fitpoint = new DRW_Coord(); fitpoint = new DRW_Coord();
fitlist.push_back( fitpoint ); fitlist.push_back( fitpoint );
fitpoint->x = reader->getDouble(); fitpoint->x = reader->getDouble();
break; break;
} }
case 21: case 21:
...@@ -1312,12 +1400,12 @@ void DRW_Leader::parseCode( int code, dxfReader* reader ) ...@@ -1312,12 +1400,12 @@ void DRW_Leader::parseCode( int code, dxfReader* reader )
break; break;
case 10: case 10:
{ {
vertexpoint = new DRW_Coord(); vertexpoint = new DRW_Coord();
vertexlist.push_back( vertexpoint ); vertexlist.push_back( vertexpoint );
vertexpoint->x = reader->getDouble(); vertexpoint->x = reader->getDouble();
break; break;
} }
case 20: case 20:
...@@ -1413,10 +1501,10 @@ void DRW_Viewport::parseCode( int code, dxfReader* reader ) ...@@ -1413,10 +1501,10 @@ void DRW_Viewport::parseCode( int code, dxfReader* reader )
break; break;
case 12: case 12:
{ {
centerPX = reader->getDouble(); centerPX = reader->getDouble();
break; break;
} }
case 22: case 22:
centerPY = reader->getDouble(); centerPY = reader->getDouble();
......
...@@ -23,7 +23,8 @@ class DRW_Polyline; ...@@ -23,7 +23,8 @@ class DRW_Polyline;
namespace DRW { namespace DRW {
// ! Entity's type. // ! Entity's type.
enum ETYPE { enum ETYPE
{
POINT, POINT,
LINE, LINE,
CIRCLE, CIRCLE,
...@@ -72,61 +73,73 @@ public: ...@@ -72,61 +73,73 @@ public:
// initializes default values // initializes default values
DRW_Entity() DRW_Entity()
{ {
eType = DRW::UNKNOWN; eType = DRW::UNKNOWN;
lineType = "BYLAYER"; lineType = "BYLAYER";
color = 256; // default BYLAYER (256) color = 256; // default BYLAYER (256)
ltypeScale = 1.0; ltypeScale = 1.0;
visible = true; visible = true;
layer = "0"; layer = "0";
lWeight = DRW_LW_Conv::widthByLayer; // default BYLAYER (dxf -1, dwg 29) lWeight = DRW_LW_Conv::widthByLayer; // default BYLAYER (dxf -1, dwg 29)
handleBlock = space = 0; // default ModelSpace (0) & handleBlock = no handle (0) handleBlock = space = 0; // default ModelSpace (0) & handleBlock = no handle (0)
haveExtrusion = false; haveExtrusion = false;
color24 = -1; // default -1 not set color24 = -1; // default -1 not set
handle = 0;
curr = NULL;
} }
virtual ~DRW_Entity() {} virtual ~DRW_Entity()
{
for( std::vector<DRW_Variant*>::iterator it = extData.begin(); it!=extData.end(); ++it )
delete *it;
extData.clear();
}
DRW_Entity( const DRW_Entity& d ) DRW_Entity( const DRW_Entity& d )
{ {
eType = d.eType; eType = d.eType;
handle = d.handle; handle = d.handle;
handleBlock = d.handleBlock; handleBlock = d.handleBlock;
layer = d.layer; layer = d.layer;
lineType = d.lineType; lineType = d.lineType;
color = d.color; color = d.color;
color24 = d.color24; color24 = d.color24;
colorName = d.colorName; colorName = d.colorName;
ltypeScale = d.ltypeScale; ltypeScale = d.ltypeScale;
visible = d.visible; visible = d.visible;
lWeight = d.lWeight; lWeight = d.lWeight;
space = d.space; space = d.space;
haveExtrusion = d.haveExtrusion; haveExtrusion = d.haveExtrusion;
curr = NULL;
} }
virtual void applyExtrusion() = 0; virtual void applyExtrusion() = 0;
protected: protected:
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
void calculateAxis( DRW_Coord extPoint ); void calculateAxis( DRW_Coord extPoint );
void extrudePoint( DRW_Coord extPoint, DRW_Coord* point ); void extrudePoint( DRW_Coord extPoint, DRW_Coord* point );
public: public:
enum DRW::ETYPE eType; /*!< enum: entity type, code 0 */ enum DRW::ETYPE eType; /*!< enum: entity type, code 0 */
int handle; /*!< entity identifier, code 5 */ int handle; /*!< entity identifier, code 5 */
int handleBlock; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */ int handleBlock; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */
UTF8STRING layer; /*!< layer name, code 8 */ UTF8STRING layer; /*!< layer name, code 8 */
UTF8STRING lineType; /*!< line type, code 6 */ UTF8STRING lineType; /*!< line type, code 6 */
int color; /*!< entity color, code 62 */ int color; /*!< entity color, code 62 */
enum DRW_LW_Conv::lineWidth lWeight; /*!< entity lineweight, code 370 */ enum DRW_LW_Conv::lineWidth lWeight; /*!< entity lineweight, code 370 */
double ltypeScale; /*!< linetype scale, code 48 */ double ltypeScale; /*!< linetype scale, code 48 */
bool visible; /*!< entity visibility, code 60 */ bool visible; /*!< entity visibility, code 60 */
int color24; /*!< 24-bit color, code 420 */ int color24; /*!< 24-bit color, code 420 */
std::string colorName; /*!< color name, code 430 */ std::string colorName; /*!< color name, code 430 */
int space; /*!< space indicator 0 = model, 1 paper, code 67*/ int space; /*!< space indicator 0 = model, 1 paper, code 67*/
bool haveExtrusion; /*!< set to true if the entity have extrusion*/ bool haveExtrusion; /*!< set to true if the entity have extrusion*/
std::vector<DRW_Variant*> extData; /*!< FIFO list of extended data, codes 1000 to 1071*/
private: private:
DRW_Coord extAxisX; DRW_Coord extAxisX;
DRW_Coord extAxisY; DRW_Coord extAxisY;
DRW_Variant* curr;
}; };
...@@ -143,7 +156,7 @@ public: ...@@ -143,7 +156,7 @@ public:
eType = DRW::POINT; eType = DRW::POINT;
basePoint.z = extPoint.x = extPoint.y = 0; basePoint.z = extPoint.x = extPoint.y = 0;
extPoint.z = 1; extPoint.z = 1;
thickness = 0; thickness = 0;
} }
virtual void applyExtrusion() {} virtual void applyExtrusion() {}
...@@ -151,9 +164,9 @@ public: ...@@ -151,9 +164,9 @@ public:
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */ DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */
double thickness; /*!< thickness, code 39 */ double thickness; /*!< thickness, code 39 */
DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */
}; };
// ! Class to handle line entity // ! Class to handle line entity
...@@ -216,6 +229,7 @@ public: ...@@ -216,6 +229,7 @@ public:
DRW_Circle() DRW_Circle()
{ {
eType = DRW::CIRCLE; eType = DRW::CIRCLE;
radious = 0.0;
} }
virtual void applyExtrusion(); virtual void applyExtrusion();
...@@ -237,15 +251,17 @@ public: ...@@ -237,15 +251,17 @@ public:
{ {
eType = DRW::ARC; eType = DRW::ARC;
isccw = 1; isccw = 1;
staangle = 0.0;
endangle = 0.0;
} }
virtual void applyExtrusion() { DRW_Circle::applyExtrusion(); } virtual void applyExtrusion();
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
double staangle; /*!< start angle, code 50 in radians*/ double staangle; /*!< start angle, code 50 in radians*/
double endangle; /*!< end angle, code 51 in radians */ double endangle; /*!< end angle, code 51 in radians */
int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */ int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */
}; };
// ! Class to handle ellipse entity // ! Class to handle ellipse entity
...@@ -262,6 +278,8 @@ public: ...@@ -262,6 +278,8 @@ public:
{ {
eType = DRW::ELLIPSE; eType = DRW::ELLIPSE;
isccw = 1; isccw = 1;
ratio = 1.0;
staparam = endparam = 0;
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
...@@ -273,7 +291,7 @@ public: ...@@ -273,7 +291,7 @@ public:
double ratio; /*!< ratio, code 40 */ double ratio; /*!< ratio, code 40 */
double staparam; /*!< start parameter, code 41, 0.0 for full ellipse*/ double staparam; /*!< start parameter, code 41, 0.0 for full ellipse*/
double endparam; /*!< end parameter, code 42, 2*PI 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 */ int isccw; /*!< is counter clockwise arc?, only used in hatch, code 73 */
}; };
// ! Class to handle trace entity // ! Class to handle trace entity
...@@ -356,8 +374,8 @@ public: ...@@ -356,8 +374,8 @@ public:
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
UTF8STRING name; /*!< block name, code 2 */ UTF8STRING name; /*!< block name, code 2 */
int flags; /*!< block type, code 70 */ int flags; /*!< block type, code 70 */
}; };
...@@ -371,11 +389,11 @@ class DRW_Insert : public DRW_Point ...@@ -371,11 +389,11 @@ class DRW_Insert : public DRW_Point
public: public:
DRW_Insert() DRW_Insert()
{ {
eType = DRW::INSERT; eType = DRW::INSERT;
xscale = 1; xscale = 1;
yscale = 1; yscale = 1;
zscale = 1; zscale = 1;
angle = 0; angle = 0;
colcount = 1; colcount = 1;
rowcount = 1; rowcount = 1;
colspace = 0; colspace = 0;
...@@ -386,15 +404,15 @@ public: ...@@ -386,15 +404,15 @@ public:
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
UTF8STRING name; /*!< block name, code 2 */ UTF8STRING name; /*!< block name, code 2 */
double xscale; /*!< x scale factor, code 41 */ double xscale; /*!< x scale factor, code 41 */
double yscale; /*!< y scale factor, code 42 */ double yscale; /*!< y scale factor, code 42 */
double zscale; /*!< z scale factor, code 43 */ double zscale; /*!< z scale factor, code 43 */
double angle; /*!< rotation angle, code 50 */ double angle; /*!< rotation angle, code 50 */
int colcount; /*!< column count, code 70 */ int colcount; /*!< column count, code 70 */
int rowcount; /*!< row count, code 71 */ int rowcount; /*!< row count, code 71 */
double colspace; /*!< column space, code 44 */ double colspace; /*!< column space, code 44 */
double rowspace; /*!< row space, code 45 */ double rowspace; /*!< row space, code 45 */
}; };
// ! Class to handle lwpolyline entity // ! Class to handle lwpolyline entity
...@@ -407,12 +425,13 @@ class DRW_LWPolyline : public DRW_Entity ...@@ -407,12 +425,13 @@ class DRW_LWPolyline : public DRW_Entity
public: public:
DRW_LWPolyline() DRW_LWPolyline()
{ {
eType = DRW::LWPOLYLINE; eType = DRW::LWPOLYLINE;
elevation = thickness = width = 0.0; elevation = thickness = width = 0.0;
flags = 0; flags = 0;
extPoint.x = extPoint.y = 0; extPoint.x = extPoint.y = 0;
extPoint.z = 1; extPoint.z = 1;
vertex = NULL; vertex = NULL;
vertexnum = 0;
} }
~DRW_LWPolyline() ~DRW_LWPolyline()
...@@ -433,7 +452,7 @@ public: ...@@ -433,7 +452,7 @@ public:
vert->y = v.y; vert->y = v.y;
vert->stawidth = v.stawidth; vert->stawidth = v.stawidth;
vert->endwidth = v.endwidth; vert->endwidth = v.endwidth;
vert->bulge = v.bulge; vert->bulge = v.bulge;
vertlist.push_back( vert ); vertlist.push_back( vert );
} }
...@@ -443,7 +462,7 @@ public: ...@@ -443,7 +462,7 @@ public:
vert->stawidth = 0; vert->stawidth = 0;
vert->endwidth = 0; vert->endwidth = 0;
vert->bulge = 0; vert->bulge = 0;
vertlist.push_back( vert ); vertlist.push_back( vert );
return vert; return vert;
} }
...@@ -451,13 +470,13 @@ public: ...@@ -451,13 +470,13 @@ public:
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
int vertexnum; /*!< number of vertex, code 90 */ int vertexnum; /*!< number of vertex, code 90 */
int flags; /*!< polyline flag, code 70, default 0 */ int flags; /*!< polyline flag, code 70, default 0 */
double width; /*!< constant width, code 43 */ double width; /*!< constant width, code 43 */
double elevation; /*!< elevation, code 38 */ double elevation; /*!< elevation, code 38 */
double thickness; /*!< thickness, code 39 */ double thickness; /*!< thickness, code 39 */
DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */
DRW_Vertex2D* vertex; /*!< current vertex to add data */ DRW_Vertex2D* vertex; /*!< current vertex to add data */
std::vector<DRW_Vertex2D*> vertlist; /*!< vertex list */ std::vector<DRW_Vertex2D*> vertlist; /*!< vertex list */
}; };
...@@ -470,7 +489,8 @@ class DRW_Text : public DRW_Line ...@@ -470,7 +489,8 @@ class DRW_Text : public DRW_Line
{ {
public: public:
// ! Vertical alignments. // ! Vertical alignments.
enum VAlign { enum VAlign
{
VBaseLine = 0, /*!< Top = 0 */ VBaseLine = 0, /*!< Top = 0 */
VBottom, /*!< Bottom = 1 */ VBottom, /*!< Bottom = 1 */
VMiddle, /*!< Middle = 2 */ VMiddle, /*!< Middle = 2 */
...@@ -478,7 +498,8 @@ public: ...@@ -478,7 +498,8 @@ public:
}; };
// ! Horizontal alignments. // ! Horizontal alignments.
enum HAlign { enum HAlign
{
HLeft = 0, /*!< Left = 0 */ HLeft = 0, /*!< Left = 0 */
HCenter, /*!< Centered = 1 */ HCenter, /*!< Centered = 1 */
HRight, /*!< Right = 2 */ HRight, /*!< Right = 2 */
...@@ -491,25 +512,26 @@ public: ...@@ -491,25 +512,26 @@ public:
{ {
eType = DRW::TEXT; eType = DRW::TEXT;
angle = 0; angle = 0;
widthscale = 1; widthscale = 1;
oblique = 0; oblique = 0;
style = "STANDARD"; style = "STANDARD";
textgen = 0; textgen = 0;
alignH = HLeft; alignH = HLeft;
alignV = VBaseLine; alignV = VBaseLine;
height = 0.0;
} }
virtual void applyExtrusion() {} // RLZ TODO virtual void applyExtrusion() {} // RLZ TODO
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
double height; /*!< height text, code 40 */ double height; /*!< height text, code 40 */
UTF8STRING text; /*!< text string, code 1 */ UTF8STRING text; /*!< text string, code 1 */
double angle; /*!< rotation angle in degrees (360), code 50 */ double angle; /*!< rotation angle in degrees (360), code 50 */
double widthscale; /*!< width factor, code 41 */ double widthscale; /*!< width factor, code 41 */
double oblique; /*!< oblique angle, code 51 */ double oblique; /*!< oblique angle, code 51 */
UTF8STRING style; /*!< style name, code 7 */ UTF8STRING style; /*!< style name, code 7 */
int textgen; /*!< text generation, code 71 */ int textgen; /*!< text generation, code 71 */
enum HAlign alignH; /*!< horizontal align, code 72 */ enum HAlign alignH; /*!< horizontal align, code 72 */
enum VAlign alignV; /*!< vertical align, code 73 */ enum VAlign alignV; /*!< vertical align, code 73 */
}; };
...@@ -523,7 +545,8 @@ class DRW_MText : public DRW_Text ...@@ -523,7 +545,8 @@ class DRW_MText : public DRW_Text
{ {
public: public:
// ! Attachments. // ! Attachments.
enum Attach { enum Attach
{
TopLeft = 1, TopLeft = 1,
TopCenter, TopCenter,
TopRight, TopRight,
...@@ -537,20 +560,21 @@ public: ...@@ -537,20 +560,21 @@ public:
DRW_MText() DRW_MText()
{ {
eType = DRW::MTEXT; eType = DRW::MTEXT;
interlin = 1; interlin = 1;
alignV = (VAlign) TopLeft; alignV = (VAlign) TopLeft;
textgen = 1; textgen = 1;
haveXAxis = false; // if true needed to recalculate angle haveXAxis = false; // if true needed to recalculate angle
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
void updateAngle(); // recalculate angle if 'haveXAxis' is true void updateAngle(); // recalculate angle if 'haveXAxis' is true
public: public:
double interlin; /*!< width factor, code 44 */ double interlin; /*!< width factor, code 44 */
private: private:
bool haveXAxis; bool haveXAxis;
}; };
// ! Class to handle vertex // ! Class to handle vertex
...@@ -563,21 +587,23 @@ class DRW_Vertex : public DRW_Point ...@@ -563,21 +587,23 @@ class DRW_Vertex : public DRW_Point
public: public:
DRW_Vertex() DRW_Vertex()
{ {
eType = DRW::VERTEX; eType = DRW::VERTEX;
stawidth = endwidth = bulge = 0; stawidth = endwidth = bulge = 0;
vindex1 = vindex2 = vindex3 = vindex4 = 0; vindex1 = vindex2 = vindex3 = vindex4 = 0;
flags = identifier = 0; flags = identifier = 0;
tgdir = 0.0;
} }
DRW_Vertex( double sx, double sy, double sz, double b ) DRW_Vertex( double sx, double sy, double sz, double b )
{ {
stawidth = endwidth = 0; stawidth = endwidth = 0;
vindex1 = vindex2 = vindex3 = vindex4 = 0; vindex1 = vindex2 = vindex3 = vindex4 = 0;
flags = identifier = 0; flags = identifier = 0;
basePoint.x = sx; basePoint.x = sx;
basePoint.y = sy; basePoint.y = sy;
basePoint.z = sz; basePoint.z = sz;
bulge = b; bulge = b;
tgdir = 0.0;
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
...@@ -587,13 +613,13 @@ public: ...@@ -587,13 +613,13 @@ public:
double endwidth; /*!< End width, code 41 */ double endwidth; /*!< End width, code 41 */
double bulge; /*!< bulge, code 42 */ double bulge; /*!< bulge, code 42 */
int flags; /*!< vertex flag, code 70, default 0 */ int flags; /*!< vertex flag, code 70, default 0 */
double tgdir; /*!< curve fit tangent direction, code 50 */ double tgdir; /*!< curve fit tangent direction, code 50 */
int vindex1; /*!< polyface mesh vertex index, code 71, default 0 */ int vindex1; /*!< polyface mesh vertex index, code 71, default 0 */
int vindex2; /*!< polyface mesh vertex index, code 72, default 0 */ int vindex2; /*!< polyface mesh vertex index, code 72, default 0 */
int vindex3; /*!< polyface mesh vertex index, code 73, default 0 */ int vindex3; /*!< polyface mesh vertex index, code 73, default 0 */
int vindex4; /*!< polyface mesh vertex index, code 74, default 0 */ int vindex4; /*!< polyface mesh vertex index, code 74, default 0 */
int identifier; /*!< vertex identifier, code 91, default 0 */ int identifier; /*!< vertex identifier, code 91, default 0 */
}; };
// ! Class to handle polyline entity // ! Class to handle polyline entity
...@@ -609,7 +635,7 @@ public: ...@@ -609,7 +635,7 @@ public:
eType = DRW::POLYLINE; eType = DRW::POLYLINE;
defstawidth = defendwidth = 0.0; defstawidth = defendwidth = 0.0;
basePoint.x = basePoint.y = 0.0; basePoint.x = basePoint.y = 0.0;
flags = vertexcount = facecount = 0; flags = vertexcount = facecount = 0;
smoothM = smoothN = curvetype = 0; smoothM = smoothN = curvetype = 0;
} }
...@@ -628,8 +654,8 @@ public: ...@@ -628,8 +654,8 @@ public:
vert->basePoint.x = v.basePoint.x; vert->basePoint.x = v.basePoint.x;
vert->basePoint.y = v.basePoint.y; vert->basePoint.y = v.basePoint.y;
vert->basePoint.z = v.basePoint.z; vert->basePoint.z = v.basePoint.z;
vert->stawidth = v.stawidth; vert->stawidth = v.stawidth;
vert->endwidth = v.endwidth; vert->endwidth = v.endwidth;
vert->bulge = v.bulge; vert->bulge = v.bulge;
vertlist.push_back( vert ); vertlist.push_back( vert );
} }
...@@ -642,14 +668,14 @@ public: ...@@ -642,14 +668,14 @@ public:
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
int flags; /*!< polyline flag, code 70, default 0 */ int flags; /*!< polyline flag, code 70, default 0 */
double defstawidth; /*!< Start width, code 40, default 0 */ double defstawidth; /*!< Start width, code 40, default 0 */
double defendwidth; /*!< End width, code 41, 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 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 facecount; /*!< polygon mesh N vertex or polyface face num, code 72, default 0 */
int smoothM; /*!< smooth surface M density, code 73, default 0 */ int smoothM; /*!< smooth surface M density, code 73, default 0 */
int smoothN; /*!< smooth surface M density, code 74, default 0 */ int smoothN; /*!< smooth surface M density, code 74, default 0 */
int curvetype; /*!< curves & smooth surface type, code 75, default 0 */ int curvetype; /*!< curves & smooth surface type, code 75, default 0 */
std::vector<DRW_Vertex*> vertlist; /*!< vertex list */ std::vector<DRW_Vertex*> vertlist; /*!< vertex list */
}; };
...@@ -667,9 +693,13 @@ public: ...@@ -667,9 +693,13 @@ public:
{ {
eType = DRW::SPLINE; eType = DRW::SPLINE;
flags = nknots = ncontrol = nfit = 0; flags = nknots = ncontrol = nfit = 0;
ex = ey = 0.0; ex = ey = 0.0;
ez = 1.0; ez = 1.0;
tolknot = tolcontrol = tolfit = 0.0000001; tolknot = tolcontrol = tolfit = 0.0000001;
tgsx = tgsy = tgsz = tgex = tgey = tgez = 0.0;
degree = 0;
controlpoint = 0;
fitpoint = 0;
} }
~DRW_Spline() ~DRW_Spline()
...@@ -699,21 +729,22 @@ public: ...@@ -699,21 +729,22 @@ public:
double tgex; /*!< end tangent x coordinate, code 13 */ double tgex; /*!< end tangent x coordinate, code 13 */
double tgey; /*!< end tangent y coordinate, code 23 */ double tgey; /*!< end tangent y coordinate, code 23 */
double tgez; /*!< end tangent z coordinate, code 33 */ double tgez; /*!< end tangent z coordinate, code 33 */
int flags; /*!< spline flag, code 70 */ int flags; /*!< spline flag, code 70 */
int degree; /*!< degree of the spline, code 71 */ int degree; /*!< degree of the spline, code 71 */
int nknots; /*!< number of knots, code 72, default 0 */ int nknots; /*!< number of knots, code 72, default 0 */
int ncontrol; /*!< number of control points, code 73, default 0 */ int ncontrol; /*!< number of control points, code 73, default 0 */
int nfit; /*!< number of fit points, code 74, default 0 */ int nfit; /*!< number of fit points, code 74, default 0 */
double tolknot; /*!< knot tolerance, code 42, default 0.0000001 */ double tolknot; /*!< knot tolerance, code 42, default 0.0000001 */
double tolcontrol; /*!< control point tolerance, code 43, default 0.0000001 */ double tolcontrol; /*!< control point tolerance, code 43, default 0.0000001 */
double tolfit; /*!< fit point tolerance, code 44, default 0.0000001 */ double tolfit; /*!< fit point tolerance, code 44, default 0.0000001 */
std::vector<double> knotslist; /*!< knots list, code 40 */ std::vector<double> knotslist; /*!< knots list, code 40 */
std::vector<DRW_Coord*> controllist; /*!< control points list, code 10, 20 & 30 */ std::vector<DRW_Coord*> controllist; /*!< control points list, code 10, 20 & 30 */
std::vector<DRW_Coord*> fitlist; /*!< fit points list, code 11, 21 & 31 */ std::vector<DRW_Coord*> fitlist; /*!< fit points list, code 11, 21 & 31 */
private: private:
DRW_Coord* controlpoint; /*!< current control point to add data */ DRW_Coord* controlpoint; /*!< current control point to add data */
DRW_Coord* fitpoint; /*!< current fit point to add data */ DRW_Coord* fitpoint; /*!< current fit point to add data */
}; };
// ! Class to handle hatch loop // ! Class to handle hatch loop
...@@ -726,8 +757,8 @@ class DRW_HatchLoop ...@@ -726,8 +757,8 @@ class DRW_HatchLoop
public: public:
DRW_HatchLoop( int t ) DRW_HatchLoop( int t )
{ {
type = t; type = t;
numedges = 0; numedges = 0;
} }
~DRW_HatchLoop() ~DRW_HatchLoop()
...@@ -768,11 +799,12 @@ public: ...@@ -768,11 +799,12 @@ public:
eType = DRW::HATCH; eType = DRW::HATCH;
angle = scale = 0.0; angle = scale = 0.0;
basePoint.x = basePoint.y = basePoint.z = 0.0; basePoint.x = basePoint.y = basePoint.z = 0.0;
loopsnum = hstyle = associative = 0; loopsnum = hstyle = associative = 0;
solid = hpattern = 1; solid = hpattern = 1;
deflines = doubleflag = 0; deflines = doubleflag = 0;
loop = NULL; loop = NULL;
clearEntities(); clearEntities();
ispol = false;
} }
~DRW_Hatch() ~DRW_Hatch()
...@@ -792,24 +824,25 @@ public: ...@@ -792,24 +824,25 @@ public:
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
UTF8STRING name; /*!< hatch pattern name, code 2 */ UTF8STRING name; /*!< hatch pattern name, code 2 */
int solid; /*!< solid fill flag, code 70, solid=1, pattern=0 */ int solid; /*!< solid fill flag, code 70, solid=1, pattern=0 */
int associative; /*!< associativity, code 71, associatve=1, non-assoc.=0 */ int associative; /*!< associativity, code 71, associatve=1, non-assoc.=0 */
int hstyle; /*!< hatch style, code 75 */ int hstyle; /*!< hatch style, code 75 */
int hpattern; /*!< hatch pattern type, code 76 */ int hpattern; /*!< hatch pattern type, code 76 */
int doubleflag; /*!< hatch pattern double flag, code 77, double=1, single=0 */ int doubleflag; /*!< hatch pattern double flag, code 77, double=1, single=0 */
int loopsnum; /*!< namber of boundary paths (loops), code 91 */ int loopsnum; /*!< namber of boundary paths (loops), code 91 */
double angle; /*!< hatch pattern angle, code 52 */ double angle; /*!< hatch pattern angle, code 52 */
double scale; /*!< hatch pattern scale, code 41 */ double scale; /*!< hatch pattern scale, code 41 */
int deflines; /*!< number of pattern definition lines, code 78 */ int deflines; /*!< number of pattern definition lines, code 78 */
std::vector<DRW_HatchLoop*> looplist; /*!< polyline list */ std::vector<DRW_HatchLoop*> looplist; /*!< polyline list */
private: private:
void clearEntities() void clearEntities()
{ {
pt = line = NULL; pt = line = NULL;
pline = NULL; pline = NULL;
arc = NULL; arc = NULL;
ellipse = NULL; ellipse = NULL;
spline = NULL; spline = NULL;
plvert = NULL; plvert = NULL;
...@@ -854,21 +887,21 @@ private: ...@@ -854,21 +887,21 @@ private:
if( loop ) if( loop )
{ {
pt = NULL; pt = NULL;
spline = new DRW_Spline; spline = new DRW_Spline;
loop->objlist.push_back( spline ); loop->objlist.push_back( spline );
} }
} }
DRW_HatchLoop* loop; /*!< current loop to add data */ DRW_HatchLoop* loop; /*!< current loop to add data */
DRW_Line* line; DRW_Line* line;
DRW_Arc* arc; DRW_Arc* arc;
DRW_Ellipse* ellipse; DRW_Ellipse* ellipse;
DRW_Spline* spline; DRW_Spline* spline;
DRW_LWPolyline* pline; DRW_LWPolyline* pline;
DRW_Point* pt; DRW_Point* pt;
DRW_Vertex2D* plvert; DRW_Vertex2D* plvert;
bool ispol; bool ispol;
}; };
// ! Class to handle image entity // ! Class to handle image entity
...@@ -881,25 +914,26 @@ class DRW_Image : public DRW_Line ...@@ -881,25 +914,26 @@ class DRW_Image : public DRW_Line
public: public:
DRW_Image() DRW_Image()
{ {
eType = DRW::IMAGE; eType = DRW::IMAGE;
vz = fade = clip = 0; vz = fade = clip = 0;
brightness = contrast = 50; brightness = contrast = 50;
vx = vy = sizeu = sizev = dz = 0.0;
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
std::string ref; /*!< Hard reference to imagedef object, code 340 */ std::string ref; /*!< Hard reference to imagedef object, code 340 */
double vx; /*!< V-vector of single pixel, x coordinate, code 12 */ double vx; /*!< V-vector of single pixel, x coordinate, code 12 */
double vy; /*!< V-vector of single pixel, y coordinate, code 22 */ double vy; /*!< V-vector of single pixel, y coordinate, code 22 */
double vz; /*!< V-vector of single pixel, z coordinate, code 32 */ double vz; /*!< V-vector of single pixel, z coordinate, code 32 */
double sizeu; /*!< image size in pixels, U value, code 13 */ double sizeu; /*!< image size in pixels, U value, code 13 */
double sizev; /*!< image size in pixels, V value, code 23 */ double sizev; /*!< image size in pixels, V value, code 23 */
double dz; /*!< z coordinate, code 33 */ double dz; /*!< z coordinate, code 33 */
int clip; /*!< Clipping state, code 280, 0=off 1=on */ int clip; /*!< Clipping state, code 280, 0=off 1=on */
int brightness; /*!< Brightness value, code 281, (0-100) default 50 */ int brightness; /*!< Brightness value, code 281, (0-100) default 50 */
int contrast; /*!< Brightness value, code 282, (0-100) default 50 */ int contrast; /*!< Brightness value, code 282, (0-100) default 50 */
int fade; /*!< Brightness value, code 283, (0-100) default 0 */ int fade; /*!< Brightness value, code 283, (0-100) default 0 */
}; };
...@@ -913,39 +947,41 @@ class DRW_Dimension : public DRW_Entity ...@@ -913,39 +947,41 @@ class DRW_Dimension : public DRW_Entity
public: public:
DRW_Dimension() DRW_Dimension()
{ {
eType = DRW::DIMENSION; eType = DRW::DIMENSION;
linesty = 1; linesty = 1;
linefactor = extPoint.z = 1.0; linefactor = extPoint.z = 1.0;
angle = oblique = rot = 0.0; angle = oblique = rot = 0.0;
align = 5; align = 5;
style = "STANDARD"; style = "STANDARD";
defPoint.z = extPoint.x = extPoint.y = 0; defPoint.z = extPoint.x = extPoint.y = 0;
textPoint.z = rot = 0; textPoint.z = rot = 0;
clonePoint.x = clonePoint.y = clonePoint.z = 0; clonePoint.x = clonePoint.y = clonePoint.z = 0;
type = 0;
length = 0.0;
} }
DRW_Dimension( const DRW_Dimension& d ) : DRW_Entity( d ) DRW_Dimension( const DRW_Dimension& d ) : DRW_Entity( d )
{ {
eType = DRW::DIMENSION; eType = DRW::DIMENSION;
type = d.type; type = d.type;
name = d.name; name = d.name;
defPoint = d.defPoint; defPoint = d.defPoint;
textPoint = d.textPoint; textPoint = d.textPoint;
text = d.text; text = d.text;
style = d.style; style = d.style;
align = d.align; align = d.align;
linesty = d.linesty; linesty = d.linesty;
linefactor = d.linefactor; linefactor = d.linefactor;
rot = d.rot; rot = d.rot;
extPoint = d.extPoint; extPoint = d.extPoint;
clonePoint = d.clonePoint; clonePoint = d.clonePoint;
def1 = d.def1; def1 = d.def1;
def2 = d.def2; def2 = d.def2;
angle = d.angle; angle = d.angle;
oblique = d.oblique; oblique = d.oblique;
arcPoint = d.arcPoint; arcPoint = d.arcPoint;
circlePoint = d.circlePoint; circlePoint = d.circlePoint;
length = d.length; length = d.length;
} }
virtual ~DRW_Dimension() {} virtual ~DRW_Dimension() {}
...@@ -955,68 +991,71 @@ public: ...@@ -955,68 +991,71 @@ public:
virtual void applyExtrusion() {} virtual void applyExtrusion() {}
DRW_Coord getDefPoint() const { return defPoint; } /*!< Definition point, code 10, 20 & 30 */ DRW_Coord getDefPoint() const { return defPoint; } /*!< Definition point, code 10, 20 & 30 */
void setDefPoint( const DRW_Coord p ) { defPoint = p; } void setDefPoint( const DRW_Coord& p ) { defPoint = p; }
DRW_Coord getTextPoint() const { return textPoint; } /*!< Middle point of text, code 11, 21 & 31 */ DRW_Coord getTextPoint() const { return textPoint; } /*!< Middle point of text, code 11, 21 & 31 */
void setTextPoint( const DRW_Coord p ) { textPoint = p; } void setTextPoint( const DRW_Coord& p ) { textPoint = p; }
std::string getStyle() const { return style; } /*!< Dimension style, code 3 */ std::string getStyle() const { return style; } /*!< Dimension style, code 3 */
void setStyle( const std::string s ) { style = s; } void setStyle( const std::string& s ) { style = s; }
int getAlign() const { return align; } /*!< attachment point, code 71 */ int getAlign() const { return align; } /*!< attachment point, code 71 */
void setAlign( const int a ) { align = a; } void setAlign( const int a ) { align = a; }
int getTextLineStyle() const { return linesty; } /*!< Dimension text line spacing style, code 72, default 1 */ int getTextLineStyle() const { return linesty; } /*!< Dimension text line spacing style, code 72, default 1 */
void setTextLineStyle( const int l ) { linesty = l; } void setTextLineStyle( const int l ) { linesty = l; }
std::string getText() const { return text; } /*!< Dimension text explicitly entered by the user, code 1 */ std::string getText() const { return text; } /*!< Dimension text explicitly entered by the user, code 1 */
void setText( const std::string t ) { text = t; } void setText( const std::string& t ) { text = t; }
double getTextLineFactor() const { return linefactor; } /*!< Dimension text line spacing factor, code 41, default 1? */ double getTextLineFactor() const { return linefactor; } /*!< Dimension text line spacing factor, code 41, default 1? */
void setTextLineFactor( const double l ) { linefactor = l; } void setTextLineFactor( const double l ) { linefactor = l; }
double getDir() const { return rot; } /*!< rotation angle of the dimension text, code 53 (optional) default 0 */ double getDir() const { return rot; } /*!< rotation angle of the dimension text, code 53 (optional) default 0 */
void setDir( const double d ) { rot = d; } void setDir( const double d ) { rot = d; }
DRW_Coord getExtrusion() { return extPoint; } /*!< extrusion, code 210, 220 & 230 */ DRW_Coord getExtrusion() { return extPoint; } /*!< extrusion, code 210, 220 & 230 */
void setExtrusion( const DRW_Coord p ) { extPoint = p; } void setExtrusion( const DRW_Coord& p ) { extPoint = p; }
std::string getName() { return name; } /*!< Name of the block that contains the entities, code 2 */ std::string getName() { return name; } /*!< Name of the block that contains the entities, code 2 */
void setName( const std::string s ) { name = s; } void setName( const std::string& s ) { name = s; }
// int getType(){ return type;} /*!< Dimension type, code 70 */ // int getType(){ return type;} /*!< Dimension type, code 70 */
protected: protected:
DRW_Coord getPt2() const { return clonePoint; } DRW_Coord getPt2() const { return clonePoint; }
void setPt2( const DRW_Coord p ) { clonePoint = p; } void setPt2( const DRW_Coord& p ) { clonePoint = p; }
DRW_Coord getPt3() const { return def1; } DRW_Coord getPt3() const { return def1; }
void setPt3( const DRW_Coord p ) { def1 = p; } void setPt3( const DRW_Coord& p ) { def1 = p; }
DRW_Coord getPt4() const { return def2; } DRW_Coord getPt4() const { return def2; }
void setPt4( const DRW_Coord p ) { def2 = p; } void setPt4( const DRW_Coord& p ) { def2 = p; }
DRW_Coord getPt5() const { return circlePoint; } DRW_Coord getPt5() const { return circlePoint; }
void setPt5( const DRW_Coord p ) { circlePoint = p; } void setPt5( const DRW_Coord& p ) { circlePoint = p; }
DRW_Coord getPt6() const { return arcPoint; } DRW_Coord getPt6() const { return arcPoint; }
void setPt6( const DRW_Coord p ) { arcPoint = p; } void setPt6( const DRW_Coord& p ) { arcPoint = p; }
double getAn50() const { return angle; } /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */ double getAn50() const { return angle; } /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
void setAn50( const double d ) { angle = d; } void setAn50( const double d ) { angle = d; }
double getOb52() const { return oblique; } /*!< oblique angle, code 52 */ double getOb52() const { return oblique; } /*!< oblique angle, code 52 */
void setOb52( const double d ) { oblique = d; } void setOb52( const double d ) { oblique = d; }
double getRa40() const { return length; } /*!< Leader length, code 40 */ double getRa40() const { return length; } /*!< Leader length, code 40 */
void setRa40( const double d ) { length = d; } void setRa40( const double d ) { length = d; }
public: public:
int type; /*!< Dimension type, code 70 */ int type; /*!< Dimension type, code 70 */
private: private:
std::string name; /*!< Name of the block that contains the entities, code 2 */ std::string name; /*!< Name of the block that contains the entities, code 2 */
DRW_Coord defPoint; /*!< definition point, code 10, 20 & 30 (WCS) */ DRW_Coord defPoint; /*!< definition point, code 10, 20 & 30 (WCS) */
DRW_Coord textPoint; /*!< Middle point of text, code 11, 21 & 31 (OCS) */ DRW_Coord textPoint; /*!< Middle point of text, code 11, 21 & 31 (OCS) */
UTF8STRING text; /*!< Dimension text explicitly entered by the user, code 1 */ UTF8STRING text; /*!< Dimension text explicitly entered by the user, code 1 */
UTF8STRING style; /*!< Dimension style, code 3 */ UTF8STRING style; /*!< Dimension style, code 3 */
int align; /*!< attachment point, code 71 */ int align; /*!< attachment point, code 71 */
int linesty; /*!< Dimension text line spacing style, code 72, default 1 */ 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 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 */ double rot; /*!< rotation angle of the dimension text, code 53 */
DRW_Coord extPoint; /*!< extrusion normal vector, code 210, 220 & 230 */ DRW_Coord extPoint; /*!< extrusion normal vector, code 210, 220 & 230 */
// double hdir; /*!< horizontal direction for the dimension, code 51, default ? */ // 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 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 def1; /*!< Definition point 1for linear & angular, code 13, 23 & 33 (WCS) */
DRW_Coord def2; /*!< Definition point 2, code 14, 24 & 34 (WCS) */ DRW_Coord def2; /*!< Definition point 2, code 14, 24 & 34 (WCS) */
double angle; /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */ double angle; /*!< Angle of rotated, horizontal, or vertical dimensions, code 50 */
double oblique; /*!< oblique angle, code 52 */ double oblique; /*!< oblique angle, code 52 */
DRW_Coord circlePoint; /*!< Definition point for diameter, radius & angular dims code 15, 25 & 35 (WCS) */ 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) */ DRW_Coord arcPoint; /*!< Point defining dimension arc, x coordinate, code 16, 26 & 36 (OCS) */
double length; /*!< Leader length, code 40 */ double length; /*!< Leader length, code 40 */
}; };
...@@ -1039,14 +1078,14 @@ public: ...@@ -1039,14 +1078,14 @@ public:
} }
DRW_Coord getClonepoint() const { return getPt2(); } /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */ DRW_Coord getClonepoint() const { return getPt2(); } /*!< Insertion for clones (Baseline & Continue), 12, 22 & 32 */
void setClonePoint( DRW_Coord c ) { setPt2( c ); } void setClonePoint( DRW_Coord& c ) { setPt2( c ); }
DRW_Coord getDimPoint() const { return getDefPoint(); } /*!< dim line location point, code 10, 20 & 30 */ DRW_Coord getDimPoint() const { return getDefPoint(); } /*!< dim line location point, code 10, 20 & 30 */
void setDimPoint( const DRW_Coord p ) { setDefPoint( p ); } void setDimPoint( const DRW_Coord& p ) { setDefPoint( p ); }
DRW_Coord getDef1Point() const { return getPt3(); } /*!< Definition point 1, code 13, 23 & 33 */ DRW_Coord getDef1Point() const { return getPt3(); } /*!< Definition point 1, code 13, 23 & 33 */
void setDef1Point( const DRW_Coord p ) { setPt3( p ); } void setDef1Point( const DRW_Coord& p ) { setPt3( p ); }
DRW_Coord getDef2Point() const { return getPt4(); } /*!< Definition point 2, code 14, 24 & 34 */ DRW_Coord getDef2Point() const { return getPt4(); } /*!< Definition point 2, code 14, 24 & 34 */
void setDef2Point( const DRW_Coord p ) { setPt4( p ); } void setDef2Point( const DRW_Coord& p ) { setPt4( p ); }
}; };
// ! Class to handle linear or rotated dimension entity // ! Class to handle linear or rotated dimension entity
...@@ -1092,9 +1131,9 @@ public: ...@@ -1092,9 +1131,9 @@ public:
} }
DRW_Coord getCenterPoint() const { return getDefPoint(); } /*!< center point, code 10, 20 & 30 */ DRW_Coord getCenterPoint() const { return getDefPoint(); } /*!< center point, code 10, 20 & 30 */
void setCenterPoint( const DRW_Coord p ) { setDefPoint( p ); } void setCenterPoint( const DRW_Coord& p ) { setDefPoint( p ); }
DRW_Coord getDiameterPoint() const { return getPt5(); } /*!< Definition point for radius, code 15, 25 & 35 */ DRW_Coord getDiameterPoint() const { return getPt5(); } /*!< Definition point for radius, code 15, 25 & 35 */
void setDiameterPoint( const DRW_Coord p ) { setPt5( p ); } void setDiameterPoint( const DRW_Coord& p ) { setPt5( p ); }
double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */ double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */
void setLeaderLength( const double d ) { setRa40( d ); } void setLeaderLength( const double d ) { setRa40( d ); }
}; };
...@@ -1118,9 +1157,9 @@ public: ...@@ -1118,9 +1157,9 @@ public:
} }
DRW_Coord getDiameter1Point() const { return getPt5(); } /*!< First definition point for diameter, code 15, 25 & 35 */ DRW_Coord getDiameter1Point() const { return getPt5(); } /*!< First definition point for diameter, code 15, 25 & 35 */
void setDiameter1Point( const DRW_Coord p ) { setPt5( p ); } void setDiameter1Point( const DRW_Coord& p ) { setPt5( p ); }
DRW_Coord getDiameter2Point() const { return getDefPoint(); } /*!< Oposite point for diameter, code 10, 20 & 30 */ DRW_Coord getDiameter2Point() const { return getDefPoint(); } /*!< Oposite point for diameter, code 10, 20 & 30 */
void setDiameter2Point( const DRW_Coord p ) { setDefPoint( p ); } void setDiameter2Point( const DRW_Coord& p ) { setDefPoint( p ); }
double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */ double getLeaderLength() const { return getRa40(); } /*!< Leader length, code 40 */
void setLeaderLength( const double d ) { setRa40( d ); } void setLeaderLength( const double d ) { setRa40( d ); }
}; };
...@@ -1144,15 +1183,15 @@ public: ...@@ -1144,15 +1183,15 @@ public:
} }
DRW_Coord getFirstLine1() const { return getPt3(); } /*!< Definition point line 1-1, code 13, 23 & 33 */ DRW_Coord getFirstLine1() const { return getPt3(); } /*!< Definition point line 1-1, code 13, 23 & 33 */
void setFirstLine1( const DRW_Coord p ) { setPt3( p ); } void setFirstLine1( const DRW_Coord& p ) { setPt3( p ); }
DRW_Coord getFirstLine2() const { return getPt4(); } /*!< Definition point line 1-2, code 14, 24 & 34 */ DRW_Coord getFirstLine2() const { return getPt4(); } /*!< Definition point line 1-2, code 14, 24 & 34 */
void setFirstLine2( const DRW_Coord p ) { setPt4( p ); } void setFirstLine2( const DRW_Coord& p ) { setPt4( p ); }
DRW_Coord getSecondLine1() const { return getPt5(); } /*!< Definition point line 2-1, code 15, 25 & 35 */ DRW_Coord getSecondLine1() const { return getPt5(); } /*!< Definition point line 2-1, code 15, 25 & 35 */
void setSecondLine1( const DRW_Coord p ) { setPt5( p ); } void setSecondLine1( const DRW_Coord& p ) { setPt5( p ); }
DRW_Coord getSecondLine2() const { return getDefPoint(); } /*!< Definition point line 2-2, code 10, 20 & 30 */ DRW_Coord getSecondLine2() const { return getDefPoint(); } /*!< Definition point line 2-2, code 10, 20 & 30 */
void setSecondLine2( const DRW_Coord p ) { setDefPoint( p ); } void setSecondLine2( const DRW_Coord& p ) { setDefPoint( p ); }
DRW_Coord getDimPoint() const { return getPt6(); } /*!< Dimension definition point, code 16, 26 & 36 */ DRW_Coord getDimPoint() const { return getPt6(); } /*!< Dimension definition point, code 16, 26 & 36 */
void setDimPoint( const DRW_Coord p ) { setPt6( p ); } void setDimPoint( const DRW_Coord& p ) { setPt6( p ); }
}; };
...@@ -1175,13 +1214,13 @@ public: ...@@ -1175,13 +1214,13 @@ public:
} }
DRW_Coord getFirstLine() const { return getPt3(); } /*!< Definition point line 1, code 13, 23 & 33 */ DRW_Coord getFirstLine() const { return getPt3(); } /*!< Definition point line 1, code 13, 23 & 33 */
void setFirstLine( const DRW_Coord p ) { setPt3( p ); } void setFirstLine( const DRW_Coord& p ) { setPt3( p ); }
DRW_Coord getSecondLine() const { return getPt4(); } /*!< Definition point line 2, code 14, 24 & 34 */ DRW_Coord getSecondLine() const { return getPt4(); } /*!< Definition point line 2, code 14, 24 & 34 */
void setSecondLine( const DRW_Coord p ) { setPt4( p ); } void setSecondLine( const DRW_Coord& p ) { setPt4( p ); }
DRW_Coord getVertexPoint() const { return getPt5(); } /*!< Vertex point, code 15, 25 & 35 */ DRW_Coord getVertexPoint() const { return getPt5(); } /*!< Vertex point, code 15, 25 & 35 */
void SetVertexPoint( const DRW_Coord p ) { setPt5( p ); } void SetVertexPoint( const DRW_Coord& p ) { setPt5( p ); }
DRW_Coord getDimPoint() const { return getDefPoint(); } /*!< Dimension definition point, code 10, 20 & 30 */ DRW_Coord getDimPoint() const { return getDefPoint(); } /*!< Dimension definition point, code 10, 20 & 30 */
void setDimPoint( const DRW_Coord p ) { setDefPoint( p ); } void setDimPoint( const DRW_Coord& p ) { setDefPoint( p ); }
}; };
// ! Class to handle ordinate dimension entity // ! Class to handle ordinate dimension entity
...@@ -1203,11 +1242,11 @@ public: ...@@ -1203,11 +1242,11 @@ public:
} }
DRW_Coord getOriginPoint() const { return getDefPoint(); } /*!< Origin definition point, code 10, 20 & 30 */ DRW_Coord getOriginPoint() const { return getDefPoint(); } /*!< Origin definition point, code 10, 20 & 30 */
void setOriginPoint( const DRW_Coord p ) { setDefPoint( p ); } void setOriginPoint( const DRW_Coord& p ) { setDefPoint( p ); }
DRW_Coord getFirstLine() const { return getPt3(); } /*!< Feature location point, code 13, 23 & 33 */ DRW_Coord getFirstLine() const { return getPt3(); } /*!< Feature location point, code 13, 23 & 33 */
void setFirstLine( const DRW_Coord p ) { setPt3( p ); } void setFirstLine( const DRW_Coord& p ) { setPt3( p ); }
DRW_Coord getSecondLine() const { return getPt4(); } /*!< Leader end point, code 14, 24 & 34 */ DRW_Coord getSecondLine() const { return getPt4(); } /*!< Leader end point, code 14, 24 & 34 */
void setSecondLine( const DRW_Coord p ) { setPt4( p ); } void setSecondLine( const DRW_Coord& p ) { setPt4( p ); }
}; };
...@@ -1221,12 +1260,16 @@ class DRW_Leader : public DRW_Entity ...@@ -1221,12 +1260,16 @@ class DRW_Leader : public DRW_Entity
public: public:
DRW_Leader() DRW_Leader()
{ {
eType = DRW::LEADER; eType = DRW::LEADER;
flag = 3; flag = 3;
hookflag = vertnum = leadertype = 0; hookflag = vertnum = leadertype = 0;
extrusionPoint.x = extrusionPoint.y = 0.0; extrusionPoint.x = extrusionPoint.y = 0.0;
arrow = 1; arrow = 1;
extrusionPoint.z = 1.0; extrusionPoint.z = 1.0;
hookline = 0;
textheight = textwidth = 0.0;
coloruse = 0;
vertexpoint = NULL;
} }
~DRW_Leader() ~DRW_Leader()
...@@ -1241,25 +1284,26 @@ public: ...@@ -1241,25 +1284,26 @@ public:
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
UTF8STRING style; /*!< Dimension style name, code 3 */ UTF8STRING style; /*!< Dimension style name, code 3 */
int arrow; /*!< Arrowhead flag, code 71, 0=Disabled; 1=Enabled */ int arrow; /*!< Arrowhead flag, code 71, 0=Disabled; 1=Enabled */
int leadertype; /*!< Leader path type, code 72, 0=Straight line segments; 1=Spline */ int leadertype; /*!< Leader path type, code 72, 0=Straight line segments; 1=Spline */
int flag; /*!< Leader creation flag, code 73, default 3 */ int flag; /*!< Leader creation flag, code 73, default 3 */
int hookline; /*!< Hook line direction flag, code 74, default 1 */ int hookline; /*!< Hook line direction flag, code 74, default 1 */
int hookflag; /*!< Hook line flag, code 75 */ int hookflag; /*!< Hook line flag, code 75 */
double textheight; /*!< Text annotation height, code 40 */ double textheight; /*!< Text annotation height, code 40 */
double textwidth; /*!< Text annotation width, code 41 */ double textwidth; /*!< Text annotation width, code 41 */
int vertnum; /*!< Number of vertices, code 76 */ int vertnum; /*!< Number of vertices, code 76 */
int coloruse; /*!< Color to use if leader's DIMCLRD = BYBLOCK, code 77 */ int coloruse; /*!< Color to use if leader's DIMCLRD = BYBLOCK, code 77 */
std::string handle; /*!< Hard reference to associated annotation, code 340 */ std::string handle; /*!< Hard reference to associated annotation, code 340 */
DRW_Coord extrusionPoint; /*!< Normal vector, code 210, 220 & 230 */ DRW_Coord extrusionPoint; /*!< Normal vector, code 210, 220 & 230 */
DRW_Coord horizdir; /*!< "Horizontal" direction for leader, code 211, 221 & 231 */ 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 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 */ 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 */ std::vector<DRW_Coord*> vertexlist; /*!< vertex points list, code 10, 20 & 30 */
private: private:
DRW_Coord* vertexpoint; /*!< current control point to add data */ DRW_Coord* vertexpoint; /*!< current control point to add data */
}; };
// ! Class to handle viewport entity // ! Class to handle viewport entity
...@@ -1272,8 +1316,8 @@ class DRW_Viewport : public DRW_Point ...@@ -1272,8 +1316,8 @@ class DRW_Viewport : public DRW_Point
public: public:
DRW_Viewport() DRW_Viewport()
{ {
eType = DRW::VIEWPORT; eType = DRW::VIEWPORT;
vpstatus = 0; vpID = vpstatus = 0;
pswidth = 205; pswidth = 205;
psheight = 156; psheight = 156;
centerPX = 128.5; centerPX = 128.5;
...@@ -1286,8 +1330,8 @@ public: ...@@ -1286,8 +1330,8 @@ public:
public: public:
double pswidth; /*!< Width in paper space units, code 40 */ double pswidth; /*!< Width in paper space units, code 40 */
double psheight; /*!< Height in paper space units, code 41 */ double psheight; /*!< Height in paper space units, code 41 */
int vpstatus; /*!< Viewport status, code 68 */ int vpstatus; /*!< Viewport status, code 68 */
int vpID; /*!< Viewport ID, code 69 */ int vpID; /*!< Viewport ID, code 69 */
double centerPX; /*!< view center piont X, code 12 */ double centerPX; /*!< view center piont X, code 12 */
double centerPY; /*!< view center piont Y, code 22 */ double centerPY; /*!< view center piont Y, code 22 */
}; };
......
...@@ -40,22 +40,25 @@ public: ...@@ -40,22 +40,25 @@ public:
} }
/** Called when header is parsed. */ /** Called when header is parsed. */
virtual void addHeader( const DRW_Header* data ) = 0; virtual void addHeader( const DRW_Header* data ) = 0;
/** Called for every line Type. */ /** Called for every line Type. */
virtual void addLType( const DRW_LType& data ) = 0; virtual void addLType( const DRW_LType& data ) = 0;
/** Called for every layer. */ /** Called for every layer. */
virtual void addLayer( const DRW_Layer& data ) = 0; virtual void addLayer( const DRW_Layer& data ) = 0;
/** Called for every dim style. */ /** Called for every dim style. */
virtual void addDimStyle( const DRW_Dimstyle& data ) = 0; virtual void addDimStyle( const DRW_Dimstyle& data ) = 0;
/** Called for every VPORT table. */ /** Called for every VPORT table. */
virtual void addVport( const DRW_Vport& data ) = 0; virtual void addVport( const DRW_Vport& data ) = 0;
/** Called for every text style. */ /** Called for every text style. */
virtual void addTextStyle( const DRW_Textstyle& data ) = 0; virtual void addTextStyle( const DRW_Textstyle& data ) = 0;
/** Called for every AppId entry. */
virtual void addAppId( const DRW_AppId& data ) = 0;
/** /**
* Called for every block. Note: all entities added after this * Called for every block. Note: all entities added after this
...@@ -63,7 +66,7 @@ public: ...@@ -63,7 +66,7 @@ public:
* *
* @see endBlock() * @see endBlock()
*/ */
virtual void addBlock( const DRW_Block& data ) = 0; virtual void addBlock( const DRW_Block& data ) = 0;
/** /**
* In DWG called when the following entities corresponding to a * In DWG called when the following entities corresponding to a
...@@ -72,127 +75,127 @@ public: ...@@ -72,127 +75,127 @@ public:
* *
* int handle are the value of DRW_Block::handleBlock added with addBlock() * int handle are the value of DRW_Block::handleBlock added with addBlock()
*/ */
virtual void setBlock( const int handle ) = 0; virtual void setBlock( const int handle ) = 0;
/** Called to end the current block */ /** Called to end the current block */
virtual void endBlock() = 0; virtual void endBlock() = 0;
/** Called for every point */ /** Called for every point */
virtual void addPoint( const DRW_Point& data ) = 0; virtual void addPoint( const DRW_Point& data ) = 0;
/** Called for every line */ /** Called for every line */
virtual void addLine( const DRW_Line& data ) = 0; virtual void addLine( const DRW_Line& data ) = 0;
/** Called for every ray */ /** Called for every ray */
virtual void addRay( const DRW_Ray& data ) = 0; virtual void addRay( const DRW_Ray& data ) = 0;
/** Called for every xline */ /** Called for every xline */
virtual void addXline( const DRW_Xline& data ) = 0; virtual void addXline( const DRW_Xline& data ) = 0;
/** Called for every arc */ /** Called for every arc */
virtual void addArc( const DRW_Arc& data ) = 0; virtual void addArc( const DRW_Arc& data ) = 0;
/** Called for every circle */ /** Called for every circle */
virtual void addCircle( const DRW_Circle& data ) = 0; virtual void addCircle( const DRW_Circle& data ) = 0;
/** Called for every ellipse */ /** Called for every ellipse */
virtual void addEllipse( const DRW_Ellipse& data ) = 0; virtual void addEllipse( const DRW_Ellipse& data ) = 0;
/** Called for every lwpolyline */ /** Called for every lwpolyline */
virtual void addLWPolyline( const DRW_LWPolyline& data ) = 0; virtual void addLWPolyline( const DRW_LWPolyline& data ) = 0;
/** Called for every polyline start */ /** Called for every polyline start */
virtual void addPolyline( const DRW_Polyline& data ) = 0; virtual void addPolyline( const DRW_Polyline& data ) = 0;
/** Called for every spline */ /** Called for every spline */
virtual void addSpline( const DRW_Spline* data ) = 0; virtual void addSpline( const DRW_Spline* data ) = 0;
/** Called for every spline knot value */ /** Called for every spline knot value */
virtual void addKnot( const DRW_Entity& data ) = 0; virtual void addKnot( const DRW_Entity& data ) = 0;
/** Called for every insert. */ /** Called for every insert. */
virtual void addInsert( const DRW_Insert& data ) = 0; virtual void addInsert( const DRW_Insert& data ) = 0;
/** Called for every trace start */ /** Called for every trace start */
virtual void addTrace( const DRW_Trace& data ) = 0; virtual void addTrace( const DRW_Trace& data ) = 0;
/** Called for every 3dface start */ /** Called for every 3dface start */
virtual void add3dFace( const DRW_3Dface& data ) = 0; virtual void add3dFace( const DRW_3Dface& data ) = 0;
/** Called for every solid start */ /** Called for every solid start */
virtual void addSolid( const DRW_Solid& data ) = 0; virtual void addSolid( const DRW_Solid& data ) = 0;
/** Called for every Multi Text entity. */ /** Called for every Multi Text entity. */
virtual void addMText( const DRW_MText& data ) = 0; virtual void addMText( const DRW_MText& data ) = 0;
/** Called for every Text entity. */ /** Called for every Text entity. */
virtual void addText( const DRW_Text& data ) = 0; virtual void addText( const DRW_Text& data ) = 0;
/** /**
* Called for every aligned dimension entity. * Called for every aligned dimension entity.
*/ */
virtual void addDimAlign( const DRW_DimAligned* data ) = 0; virtual void addDimAlign( const DRW_DimAligned* data ) = 0;
/** /**
* Called for every linear or rotated dimension entity. * Called for every linear or rotated dimension entity.
*/ */
virtual void addDimLinear( const DRW_DimLinear* data ) = 0; virtual void addDimLinear( const DRW_DimLinear* data ) = 0;
/** /**
* Called for every radial dimension entity. * Called for every radial dimension entity.
*/ */
virtual void addDimRadial( const DRW_DimRadial* data ) = 0; virtual void addDimRadial( const DRW_DimRadial* data ) = 0;
/** /**
* Called for every diametric dimension entity. * Called for every diametric dimension entity.
*/ */
virtual void addDimDiametric( const DRW_DimDiametric* data ) = 0; virtual void addDimDiametric( const DRW_DimDiametric* data ) = 0;
/** /**
* Called for every angular dimension (2 lines version) entity. * Called for every angular dimension (2 lines version) entity.
*/ */
virtual void addDimAngular( const DRW_DimAngular* data ) = 0; virtual void addDimAngular( const DRW_DimAngular* data ) = 0;
/** /**
* Called for every angular dimension (3 points version) entity. * Called for every angular dimension (3 points version) entity.
*/ */
virtual void addDimAngular3P( const DRW_DimAngular3p* data ) = 0; virtual void addDimAngular3P( const DRW_DimAngular3p* data ) = 0;
/** /**
* Called for every ordinate dimension entity. * Called for every ordinate dimension entity.
*/ */
virtual void addDimOrdinate( const DRW_DimOrdinate* data ) = 0; virtual void addDimOrdinate( const DRW_DimOrdinate* data ) = 0;
/** /**
* Called for every leader start. * Called for every leader start.
*/ */
virtual void addLeader( const DRW_Leader* data ) = 0; virtual void addLeader( const DRW_Leader* data ) = 0;
/** /**
* Called for every hatch entity. * Called for every hatch entity.
*/ */
virtual void addHatch( const DRW_Hatch* data ) = 0; virtual void addHatch( const DRW_Hatch* data ) = 0;
/** /**
* Called for every viewport entity. * Called for every viewport entity.
*/ */
virtual void addViewport( const DRW_Viewport& data ) = 0; virtual void addViewport( const DRW_Viewport& data ) = 0;
/** /**
* Called for every image entity. * Called for every image entity.
*/ */
virtual void addImage( const DRW_Image* data ) = 0; virtual void addImage( const DRW_Image* data ) = 0;
/** /**
* Called for every image definition. * Called for every image definition.
*/ */
virtual void linkImage( const DRW_ImageDef* data ) = 0; virtual void linkImage( const DRW_ImageDef* data ) = 0;
/** /**
* Called for every comment in the DXF file (code 999). * Called for every comment in the DXF file (code 999).
*/ */
virtual void addComment( const char* comment ) = 0; virtual void addComment( const char* comment ) = 0;
/** Sets the current attributes for entities. */ /** Sets the current attributes for entities. */
/* void setExtrusion(double dx, double dy, double dz, double elevation) { /* void setExtrusion(double dx, double dy, double dz, double elevation) {
...@@ -208,12 +211,13 @@ public: ...@@ -208,12 +211,13 @@ public:
virtual void writeHeader( DRW_Header& data ) = 0; virtual void writeHeader( DRW_Header& data ) = 0;
virtual void writeBlocks() = 0; virtual void writeBlocks() = 0;
virtual void writeBlockRecords() = 0; virtual void writeBlockRecords() = 0;
virtual void writeEntities() = 0; virtual void writeEntities() = 0;
virtual void writeLTypes() = 0; virtual void writeLTypes() = 0;
virtual void writeLayers() = 0; virtual void writeLayers() = 0;
virtual void writeTextstyles() = 0; virtual void writeTextstyles() = 0;
virtual void writeVports() = 0; virtual void writeVports() = 0;
virtual void writeDimstyles() = 0; virtual void writeDimstyles() = 0;
virtual void writeAppId() = 0;
protected: protected:
// DL_Attributes attributes; // DL_Attributes attributes;
......
...@@ -41,6 +41,58 @@ void DRW_TableEntry::parseCode( int code, dxfReader* reader ) ...@@ -41,6 +41,58 @@ void DRW_TableEntry::parseCode( int code, dxfReader* reader )
flags = reader->getInt32(); flags = reader->getInt32();
break; break;
case 1000:
case 1001:
case 1002:
case 1003:
case 1004:
case 1005:
extData.push_back( new DRW_Variant( code, reader->getString() ) );
break;
case 1010:
case 1011:
case 1012:
case 1013:
curr = new DRW_Variant();
curr->addCoord();
curr->setCoordX( reader->getDouble() );
curr->code = code;
extData.push_back( curr );
break;
case 1020:
case 1021:
case 1022:
case 1023:
if( curr )
curr->setCoordY( reader->getDouble() );
break;
case 1030:
case 1031:
case 1032:
case 1033:
if( curr )
curr->setCoordZ( reader->getDouble() );
curr = NULL;
break;
case 1040:
case 1041:
case 1042:
extData.push_back( new DRW_Variant( code, reader->getDouble() ) );
break;
case 1070:
case 1071:
extData.push_back( new DRW_Variant( code, reader->getInt32() ) );
break;
default: default:
break; break;
} }
...@@ -747,7 +799,7 @@ void DRW_Header::parseCode( int code, dxfReader* reader ) ...@@ -747,7 +799,7 @@ void DRW_Header::parseCode( int code, dxfReader* reader )
break; break;
case 10: case 10:
curr->addCoord( new DRW_Coord() ); curr->addCoord();
curr->setCoordX( reader->getDouble() ); curr->setCoordX( reader->getDouble() );
curr->code = code; curr->code = code;
break; break;
...@@ -815,8 +867,8 @@ void DRW_Header::parseCode( int code, dxfReader* reader ) ...@@ -815,8 +867,8 @@ void DRW_Header::parseCode( int code, dxfReader* reader )
void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
{ {
/*RLZ: TODO complete all vars to AC1024*/ /*RLZ: TODO complete all vars to AC1024*/
double varDouble; double varDouble;
int varInt; int varInt;
std::string varStr; std::string varStr;
DRW_Coord varCoord; DRW_Coord varCoord;
...@@ -970,6 +1022,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -970,6 +1022,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
writer->writeUtf8String( 7, varStr ); writer->writeUtf8String( 7, varStr );
else else
writer->writeString( 7, "STANDARD" ); writer->writeString( 7, "STANDARD" );
...@@ -982,6 +1036,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -982,6 +1036,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
writer->writeUtf8String( 8, varStr ); writer->writeUtf8String( 8, varStr );
else else
writer->writeString( 8, "0" ); writer->writeString( 8, "0" );
...@@ -1082,6 +1138,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -1082,6 +1138,8 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
writer->writeUtf8String( 2, varStr ); writer->writeUtf8String( 2, varStr );
else else
writer->writeString( 2, "STANDARD" ); writer->writeString( 2, "STANDARD" );
...@@ -1235,7 +1293,7 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -1235,7 +1293,7 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
#ifdef DRW_DBG #ifdef DRW_DBG
std::map<std::string, DRW_Variant*>::const_iterator it; std::map<std::string, DRW_Variant*>::const_iterator it;
for( it = vars.begin(); it != vars.end(); it++ ) for( it = vars.begin(); it != vars.end(); ++it )
{ {
// QString key = QString::fromStdString((*it).first); // QString key = QString::fromStdString((*it).first);
std::cerr << (*it).first << std::endl; std::cerr << (*it).first << std::endl;
...@@ -1245,6 +1303,42 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver ) ...@@ -1245,6 +1303,42 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
} }
void DRW_Header::addDouble( std::string key, double value, int code )
{
curr = new DRW_Variant();
curr->addDouble( value );
curr->code = code;
vars[key] = curr;
}
void DRW_Header::addInt( std::string key, int value, int code )
{
curr = new DRW_Variant();
curr->addInt( value );
curr->code = code;
vars[key] = curr;
}
void DRW_Header::addStr( std::string key, std::string value, int code )
{
curr = new DRW_Variant();
curr->addString( value );
curr->code = code;
vars[key] = curr;
}
void DRW_Header::addCoord( std::string key, DRW_Coord value, int code )
{
curr = new DRW_Variant();
curr->addCoord( value );
curr->code = code;
vars[key] = curr;
}
bool DRW_Header::getDouble( std::string key, double* varDouble ) bool DRW_Header::getDouble( std::string key, double* varDouble )
{ {
bool result = false; bool result = false;
...@@ -1258,8 +1352,8 @@ bool DRW_Header::getDouble( std::string key, double* varDouble ) ...@@ -1258,8 +1352,8 @@ bool DRW_Header::getDouble( std::string key, double* varDouble )
if( var->type == DRW_Variant::DOUBLE ) if( var->type == DRW_Variant::DOUBLE )
{ {
*varDouble = var->content.d; *varDouble = var->content.d;
result = true; result = true;
} }
vars.erase( it ); vars.erase( it );
...@@ -1330,8 +1424,8 @@ bool DRW_Header::getCoord( std::string key, DRW_Coord* varCoord ) ...@@ -1330,8 +1424,8 @@ bool DRW_Header::getCoord( std::string key, DRW_Coord* varCoord )
if( var->type == DRW_Variant::COORD ) if( var->type == DRW_Variant::COORD )
{ {
*varCoord = *var->content.v; *varCoord = *var->content.v;
result = true; result = true;
} }
vars.erase( it ); vars.erase( it );
......
...@@ -24,14 +24,16 @@ class dxfWriter; ...@@ -24,14 +24,16 @@ class dxfWriter;
namespace DRW { namespace DRW {
// ! Table entries type. // ! Table entries type.
enum TTYPE { enum TTYPE
{
UNKNOWNT, UNKNOWNT,
LTYPE, LTYPE,
LAYER, LAYER,
STYLE, STYLE,
DIMSTYLE, DIMSTYLE,
VPORT, VPORT,
BLOCK_RECORD BLOCK_RECORD,
APPID
}; };
} }
...@@ -48,18 +50,42 @@ public: ...@@ -48,18 +50,42 @@ public:
{ {
tType = DRW::UNKNOWNT; tType = DRW::UNKNOWNT;
flags = 0; flags = 0;
curr = NULL;
handle = 0;
handleBlock = 0;
}
virtual ~DRW_TableEntry()
{
for( std::vector<DRW_Variant*>::iterator it = extData.begin(); it!=extData.end(); ++it )
delete *it;
extData.clear();
} }
virtual ~DRW_TableEntry() {}
protected: protected:
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
void reset()
{
flags = 0;
for( std::vector<DRW_Variant*>::iterator it = extData.begin(); it!=extData.end(); ++it )
delete *it;
extData.clear();
}
public: public:
enum DRW::TTYPE tType; /*!< enum: entity type, code 0 */ enum DRW::TTYPE tType; /*!< enum: entity type, code 0 */
int handle; /*!< entity identifier, code 5 */ int handle; /*!< entity identifier, code 5 */
int handleBlock; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */ int handleBlock; /*!< Soft-pointer ID/handle to owner BLOCK_RECORD object, code 330 */
UTF8STRING name; /*!< entry name, code 2 */ UTF8STRING name; /*!< entry name, code 2 */
int flags; /*!< Flags relevant to entry, code 70 */ int flags; /*!< Flags relevant to entry, code 70 */
std::vector<DRW_Variant*> extData; /*!< FIFO list of extended data, codes 1000 to 1071*/
private:
DRW_Variant* curr;
}; };
...@@ -75,27 +101,28 @@ public: ...@@ -75,27 +101,28 @@ public:
void reset() void reset()
{ {
tType = DRW::DIMSTYLE; tType = DRW::DIMSTYLE;
dimasz = dimtxt = dimexe = 0.18; dimasz = dimtxt = dimexe = 0.18;
dimexo = 0.0625; dimexo = 0.0625;
dimgap = dimcen = 0.09; dimgap = dimcen = 0.09;
dimtxsty = "Standard"; dimtxsty = "Standard";
dimscale = dimlfac = dimtfac = 1.0; dimscale = dimlfac = dimtfac = 1.0;
dimdli = 0.38; dimdli = 0.38;
dimrnd = dimdle = dimtp = dimtm = dimtsz = dimtvp = 0.0; dimrnd = dimdle = dimtp = dimtm = dimtsz = dimtvp = 0.0;
dimaltf = 25.4; dimaltf = 25.4;
dimtol = dimlim = dimse1 = dimse2 = dimtad = dimzin = 0; dimtol = dimlim = dimse1 = dimse2 = dimtad = dimzin = 0;
dimtoh = dimtolj = 1; dimtoh = dimtolj = 1;
dimalt = dimtofl = dimsah = dimtix = dimsoxd = 0; dimalt = dimtofl = dimsah = dimtix = dimsoxd = 0;
dimaltd = dimunit = dimaltu = dimalttd = dimlunit = 2; dimaltd = dimunit = dimaltu = dimalttd = dimlunit = 2;
dimclrd = dimclre = dimclrt = dimjust = dimupt = 0; dimclrd = dimclre = dimclrt = dimjust = dimupt = 0;
dimazin = dimaltz = dimaltttz = dimtzin = dimfrac = 0; dimazin = dimaltz = dimaltttz = dimtzin = dimfrac = 0;
dimtih = dimadec = dimaunit = dimsd1 = dimsd2 = dimtmove = 0; dimtih = dimadec = dimaunit = dimsd1 = dimsd2 = dimtmove = 0;
dimaltrnd = 0.0; dimaltrnd = 0.0;
dimdec = dimtdec = 4; dimdec = dimtdec = 4;
dimfit = dimatfit = 3; dimfit = dimatfit = 3;
dimdsep = '.'; dimdsep = '.';
dimlwd = dimlwe = -2; dimlwd = dimlwe = -2;
DRW_TableEntry::reset();
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
...@@ -108,67 +135,67 @@ public: ...@@ -108,67 +135,67 @@ public:
UTF8STRING dimblk; /*!< code 5, code 342 V2000+ */ UTF8STRING dimblk; /*!< code 5, code 342 V2000+ */
UTF8STRING dimblk1; /*!< code 6, code 343 V2000+ */ UTF8STRING dimblk1; /*!< code 6, code 343 V2000+ */
UTF8STRING dimblk2; /*!< code 7, code 344 V2000+ */ UTF8STRING dimblk2; /*!< code 7, code 344 V2000+ */
double dimscale; /*!< code 40 */ double dimscale; /*!< code 40 */
double dimasz; /*!< code 41 */ double dimasz; /*!< code 41 */
double dimexo; /*!< code 42 */ double dimexo; /*!< code 42 */
double dimdli; /*!< code 43 */ double dimdli; /*!< code 43 */
double dimexe; /*!< code 44 */ double dimexe; /*!< code 44 */
double dimrnd; /*!< code 45 */ double dimrnd; /*!< code 45 */
double dimdle; /*!< code 46 */ double dimdle; /*!< code 46 */
double dimtp; /*!< code 47 */ double dimtp; /*!< code 47 */
double dimtm; /*!< code 48 */ double dimtm; /*!< code 48 */
double dimtxt; /*!< code 140 */ double dimtxt; /*!< code 140 */
double dimcen; /*!< code 141 */ double dimcen; /*!< code 141 */
double dimtsz; /*!< code 142 */ double dimtsz; /*!< code 142 */
double dimaltf; /*!< code 143 */ double dimaltf; /*!< code 143 */
double dimlfac; /*!< code 144 */ double dimlfac; /*!< code 144 */
double dimtvp; /*!< code 145 */ double dimtvp; /*!< code 145 */
double dimtfac; /*!< code 146 */ double dimtfac; /*!< code 146 */
double dimgap; /*!< code 147 */ double dimgap; /*!< code 147 */
double dimaltrnd; /*!< code 148 V2000+ */ double dimaltrnd; /*!< code 148 V2000+ */
int dimtol; /*!< code 71 */ int dimtol; /*!< code 71 */
int dimlim; /*!< code 72 */ int dimlim; /*!< code 72 */
int dimtih; /*!< code 73 */ int dimtih; /*!< code 73 */
int dimtoh; /*!< code 74 */ int dimtoh; /*!< code 74 */
int dimse1; /*!< code 75 */ int dimse1; /*!< code 75 */
int dimse2; /*!< code 76 */ int dimse2; /*!< code 76 */
int dimtad; /*!< code 77 */ int dimtad; /*!< code 77 */
int dimzin; /*!< code 78 */ int dimzin; /*!< code 78 */
int dimazin; /*!< code 79 V2000+ */ int dimazin; /*!< code 79 V2000+ */
int dimalt; /*!< code 170 */ int dimalt; /*!< code 170 */
int dimaltd; /*!< code 171 */ int dimaltd; /*!< code 171 */
int dimtofl; /*!< code 172 */ int dimtofl; /*!< code 172 */
int dimsah; /*!< code 173 */ int dimsah; /*!< code 173 */
int dimtix; /*!< code 174 */ int dimtix; /*!< code 174 */
int dimsoxd; /*!< code 175 */ int dimsoxd; /*!< code 175 */
int dimclrd; /*!< code 176 */ int dimclrd; /*!< code 176 */
int dimclre; /*!< code 177 */ int dimclre; /*!< code 177 */
int dimclrt; /*!< code 178 */ int dimclrt; /*!< code 178 */
int dimadec; /*!< code 179 V2000+ */ int dimadec; /*!< code 179 V2000+ */
int dimunit; /*!< code 270 R13+ (obsolete 2000+, use dimlunit & dimfrac) */ int dimunit; /*!< code 270 R13+ (obsolete 2000+, use dimlunit & dimfrac) */
int dimdec; /*!< code 271 R13+ */ int dimdec; /*!< code 271 R13+ */
int dimtdec; /*!< code 272 R13+ */ int dimtdec; /*!< code 272 R13+ */
int dimaltu; /*!< code 273 R13+ */ int dimaltu; /*!< code 273 R13+ */
int dimalttd; /*!< code 274 R13+ */ int dimalttd; /*!< code 274 R13+ */
int dimaunit; /*!< code 275 R13+ */ int dimaunit; /*!< code 275 R13+ */
int dimfrac; /*!< code 276 V2000+ */ int dimfrac; /*!< code 276 V2000+ */
int dimlunit; /*!< code 277 V2000+ */ int dimlunit; /*!< code 277 V2000+ */
int dimdsep; /*!< code 278 V2000+ */ int dimdsep; /*!< code 278 V2000+ */
int dimtmove; /*!< code 279 V2000+ */ int dimtmove; /*!< code 279 V2000+ */
int dimjust; /*!< code 280 R13+ */ int dimjust; /*!< code 280 R13+ */
int dimsd1; /*!< code 281 R13+ */ int dimsd1; /*!< code 281 R13+ */
int dimsd2; /*!< code 282 R13+ */ int dimsd2; /*!< code 282 R13+ */
int dimtolj; /*!< code 283 R13+ */ int dimtolj; /*!< code 283 R13+ */
int dimtzin; /*!< code 284 R13+ */ int dimtzin; /*!< code 284 R13+ */
int dimaltz; /*!< code 285 R13+ */ int dimaltz; /*!< code 285 R13+ */
int dimaltttz; /*!< code 286 R13+ */ int dimaltttz; /*!< code 286 R13+ */
int dimfit; /*!< code 287 R13+ (obsolete 2000+, use dimatfit & dimtmove)*/ int dimfit; /*!< code 287 R13+ (obsolete 2000+, use dimatfit & dimtmove)*/
int dimupt; /*!< code 288 R13+ */ int dimupt; /*!< code 288 R13+ */
int dimatfit; /*!< code 289 V2000+ */ int dimatfit; /*!< code 289 V2000+ */
UTF8STRING dimtxsty; /*!< code 340 R13+ */ UTF8STRING dimtxsty; /*!< code 340 R13+ */
UTF8STRING dimldrblk; /*!< code 341 V2000+ */ UTF8STRING dimldrblk; /*!< code 341 V2000+ */
int dimlwd; /*!< code 371 V2000+ */ int dimlwd; /*!< code 371 V2000+ */
int dimlwe; /*!< code 372 V2000+ */ int dimlwe; /*!< code 372 V2000+ */
}; };
...@@ -190,24 +217,22 @@ public: ...@@ -190,24 +217,22 @@ public:
size = 0; size = 0;
length = 0.0; length = 0.0;
pathIdx = 0; pathIdx = 0;
/* color = 256; // default BYLAYER (256) DRW_TableEntry::reset();
* plotF = true; // default TRUE (plot yes)
* lWeight = -1; // default BYLAYER (-1)*/
// align = 65; //always 65
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
void update(); void update();
public: public:
UTF8STRING desc; /*!< descriptive string, code 3 */ UTF8STRING desc; /*!< descriptive string, code 3 */
// int align; /*!< align code, always 65 ('A') code 72 */ // int align; /*!< align code, always 65 ('A') code 72 */
int size; /*!< element number, code 73 */ int size; /*!< element number, code 73 */
double length; /*!< total length of pattern, code 40 */ double length; /*!< total length of pattern, code 40 */
// int haveShape; /*!< complex linetype type, code 74 */ // int haveShape; /*!< complex linetype type, code 74 */
std::vector<double> path; /*!< trace, point or space length sequence, code 49 */ std::vector<double> path; /*!< trace, point or space length sequence, code 49 */
private: private:
int pathIdx; int pathIdx;
}; };
...@@ -223,21 +248,22 @@ public: ...@@ -223,21 +248,22 @@ public:
void reset() void reset()
{ {
tType = DRW::LAYER; tType = DRW::LAYER;
lineType = "CONTINUOUS"; lineType = "CONTINUOUS";
color = 7; // default BYLAYER (256) color = 7; // default BYLAYER (256)
plotF = true; // default TRUE (plot yes) plotF = true; // default TRUE (plot yes)
lWeight = DRW_LW_Conv::widthDefault; // default BYDEFAULT (dxf -3, dwg 31) lWeight = DRW_LW_Conv::widthDefault; // default BYDEFAULT (dxf -3, dwg 31)
color24 = -1; // default -1 not set color24 = -1; // default -1 not set
DRW_TableEntry::reset();
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
UTF8STRING lineType; /*!< line type, code 6 */ UTF8STRING lineType; /*!< line type, code 6 */
int color; /*!< layer color, code 62 */ int color; /*!< layer color, code 62 */
int color24; /*!< 24-bit color, code 420 */ int color24; /*!< 24-bit color, code 420 */
bool plotF; /*!< Plot flag, code 290 */ bool plotF; /*!< Plot flag, code 290 */
enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */ enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */
std::string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */ std::string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */
std::string handlePlotM; /*!< Hard-pointer ID/handle of materialstyle, code 347 */ std::string handlePlotM; /*!< Hard-pointer ID/handle of materialstyle, code 347 */
...@@ -255,25 +281,26 @@ public: ...@@ -255,25 +281,26 @@ public:
void reset() void reset()
{ {
tType = DRW::STYLE; tType = DRW::STYLE;
height = oblique = 0.0; height = oblique = 0.0;
width = lastHeight = 1.0; width = lastHeight = 1.0;
font = "txt"; font = "txt";
genFlag = 0; // 2= X mirror, 4= Y mirror genFlag = 0; // 2= X mirror, 4= Y mirror
fontFamily = 0; fontFamily = 0;
DRW_TableEntry::reset();
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
public: public:
double height; /*!< Fixed text height (0 not set), code 40 */ double height; /*!< Fixed text height (0 not set), code 40 */
double width; /*!< Width factor, code 41 */ double width; /*!< Width factor, code 41 */
double oblique; /*!< Oblique angle, code 50 */ double oblique; /*!< Oblique angle, code 50 */
int genFlag; /*!< Text generation flags, code 71 */ int genFlag; /*!< Text generation flags, code 71 */
double lastHeight; /*!< Last height used, code 42 */ double lastHeight; /*!< Last height used, code 42 */
UTF8STRING font; /*!< primary font file name, code 3 */ UTF8STRING font; /*!< primary font file name, code 3 */
UTF8STRING bigFont; /*!< bigfont file name or blank if none, code 4 */ UTF8STRING bigFont; /*!< bigfont file name or blank if none, code 4 */
int fontFamily; /*!< ttf font family, italic and bold flags, code 1071 */ int fontFamily; /*!< ttf font family, italic and bold flags, code 1071 */
}; };
// ! Class to handle vport entries // ! Class to handle vport entries
...@@ -290,19 +317,20 @@ public: ...@@ -290,19 +317,20 @@ public:
{ {
UpperRight.x = UpperRight.y = 1.0; UpperRight.x = UpperRight.y = 1.0;
snapSpacing.x = snapSpacing.y = 10.0; snapSpacing.x = snapSpacing.y = 10.0;
gridSpacing = snapSpacing; gridSpacing = snapSpacing;
center.x = 0.651828; center.x = 0.651828;
center.y = -0.16; center.y = -0.16;
viewDir.z = 1; viewDir.z = 1;
height = 5.13732; height = 5.13732;
ratio = 2.4426877; ratio = 2.4426877;
lensHeight = 50; lensHeight = 50;
frontClip = backClip = snapAngle = twistAngle = 0.0; frontClip = backClip = snapAngle = twistAngle = 0.0;
viewMode = snap = grid = snapStyle = snapIsopair = 0; viewMode = snap = grid = snapStyle = snapIsopair = 0;
fastZoom = 1; fastZoom = 1;
circleZoom = 100; circleZoom = 100;
ucsIcon = 3; ucsIcon = 3;
gridBehavior = 7; gridBehavior = 7;
DRW_TableEntry::reset();
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
...@@ -316,22 +344,22 @@ public: ...@@ -316,22 +344,22 @@ public:
DRW_Coord gridSpacing; /*!< grid Spacing, code 15 & 25 */ DRW_Coord gridSpacing; /*!< grid Spacing, code 15 & 25 */
DRW_Coord viewDir; /*!< view direction from target point, code 16, 26 & 36 */ DRW_Coord viewDir; /*!< view direction from target point, code 16, 26 & 36 */
DRW_Coord viewTarget; /*!< view target point, code 17, 27 & 37 */ DRW_Coord viewTarget; /*!< view target point, code 17, 27 & 37 */
double height; /*!< view height, code 40 */ double height; /*!< view height, code 40 */
double ratio; /*!< viewport aspect ratio, code 41 */ double ratio; /*!< viewport aspect ratio, code 41 */
double lensHeight; /*!< lens height, code 42 */ double lensHeight; /*!< lens height, code 42 */
double frontClip; /*!< front clipping plane, code 43 */ double frontClip; /*!< front clipping plane, code 43 */
double backClip; /*!< back clipping plane, code 44 */ double backClip; /*!< back clipping plane, code 44 */
double snapAngle; /*!< snap rotation angle, code 50 */ double snapAngle; /*!< snap rotation angle, code 50 */
double twistAngle; /*!< view twist angle, code 51 */ double twistAngle; /*!< view twist angle, code 51 */
int viewMode; /*!< view mode, code 71 */ int viewMode; /*!< view mode, code 71 */
int circleZoom; /*!< circle zoom percent, code 72 */ int circleZoom; /*!< circle zoom percent, code 72 */
int fastZoom; /*!< fast zoom setting, code 73 */ int fastZoom; /*!< fast zoom setting, code 73 */
int ucsIcon; /*!< UCSICON setting, code 74 */ int ucsIcon; /*!< UCSICON setting, code 74 */
int snap; /*!< snap on/off, code 75 */ int snap; /*!< snap on/off, code 75 */
int grid; /*!< grid on/off, code 76 */ int grid; /*!< grid on/off, code 76 */
int snapStyle; /*!< snap style, code 77 */ int snapStyle; /*!< snap style, code 77 */
int snapIsopair; /*!< snap isopair, code 78 */ int snapIsopair; /*!< snap isopair, code 78 */
int gridBehavior; /*!< grid behavior, code 60, undocummented */ int gridBehavior; /*!< grid behavior, code 60, undocummented */
/** code 60, bit coded possible value are /** code 60, bit coded possible value are
* bit 1 (1) show out of limits * bit 1 (1) show out of limits
* bit 2 (2) adaptive grid * bit 2 (2) adaptive grid
...@@ -352,6 +380,9 @@ public: ...@@ -352,6 +380,9 @@ public:
DRW_ImageDef() DRW_ImageDef()
{ {
version = 0; version = 0;
u = v = up = vp = 0.0;
loaded = 0;
resolution = 0;
} }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
...@@ -359,13 +390,13 @@ public: ...@@ -359,13 +390,13 @@ public:
public: public:
std::string handle; /*!< entity identifier, code 5 */ std::string handle; /*!< entity identifier, code 5 */
UTF8STRING name; /*!< File name of image, code 1 */ UTF8STRING name; /*!< File name of image, code 1 */
int version; /*!< class version, code 90, 0=R14 version */ int version; /*!< class version, code 90, 0=R14 version */
double u; /*!< image size in pixels U value, code 10 */ double u; /*!< image size in pixels U value, code 10 */
double v; /*!< image size in pixels V value, code 20 */ double v; /*!< image size in pixels V value, code 20 */
double up; /*!< default size of one pixel U value, code 11 */ 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*/ 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 loaded; /*!< image is loaded flag, code 280, 0=unloaded, 1=loaded */
int resolution; /*!< resolution units, code 281, 0=no, 2=centimeters, 5=inch */ int resolution; /*!< resolution units, code 281, 0=no, 2=centimeters, 5=inch */
std::map<std::string, std::string> reactors; std::map<std::string, std::string> reactors;
}; };
...@@ -373,7 +404,9 @@ public: ...@@ -373,7 +404,9 @@ public:
// ! Class to handle header entries // ! Class to handle header entries
/*! /*!
* Class to handle layer symbol table entries * Class to handle header vars, to read iterate over "std::map vars"
* to write add a DRW_Variant* into "std::map vars" (do not delete it, are cleared in dtor)
* or use add* helper functions.
* @author Rallaz * @author Rallaz
*/ */
class DRW_Header class DRW_Header
...@@ -381,18 +414,29 @@ class DRW_Header ...@@ -381,18 +414,29 @@ class DRW_Header
public: public:
DRW_Header() DRW_Header()
{ {
version = 0;
curr = 0;
} }
~DRW_Header() ~DRW_Header()
{ {
for( std::map<std::string, DRW_Variant*>::iterator it = vars.begin(); it!=vars.end(); ++it )
delete it->second;
vars.clear(); vars.clear();
} }
void addDouble( std::string key, double value, int code );
void addInt( std::string key, int value, int code );
void addStr( std::string key, std::string value, int code );
void addCoord( std::string key, DRW_Coord value, int code );
std::string getComments() const { return comments; }
void parseCode( int code, dxfReader* reader ); void parseCode( int code, dxfReader* reader );
void write( dxfWriter* writer, DRW::Version ver ); void write( dxfWriter* writer, DRW::Version ver );
void addComment( std::string c ); void addComment( std::string c );
std::string getComments() const { return comments; }
private: private:
bool getDouble( std::string key, double* varDouble ); bool getDouble( std::string key, double* varDouble );
bool getInt( std::string key, int* varInt ); bool getInt( std::string key, int* varInt );
...@@ -401,11 +445,32 @@ private: ...@@ -401,11 +445,32 @@ private:
public: public:
std::map<std::string, DRW_Variant*> vars; std::map<std::string, DRW_Variant*> vars;
private: private:
std::string comments; std::string comments;
std::string name; std::string name;
DRW_Variant* curr; DRW_Variant* curr;
int version; // to use on read int version; // to use on read
};
// ! Class to handle AppId entries
/*!
* Class to handle AppId symbol table entries
* @author Rallaz
*/
class DRW_AppId : public DRW_TableEntry
{
public:
DRW_AppId() { reset(); }
void reset()
{
tType = DRW::APPID;
flags = 0;
name = "";
}
void parseCode( int code, dxfReader* reader ) { DRW_TableEntry::parseCode( code, reader ); }
}; };
namespace DRW { namespace DRW {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
DRW_TextCodec::DRW_TextCodec() DRW_TextCodec::DRW_TextCodec()
{ {
version = DRW::AC1021; version = DRW::AC1021;
conv = new DRW_Converter( NULL, 0 ); conv = new DRW_Converter( NULL, 0 );
} }
...@@ -62,16 +62,16 @@ void DRW_TextCodec::setCodePage( std::string* c ) ...@@ -62,16 +62,16 @@ void DRW_TextCodec::setCodePage( std::string* c )
conv = new DRW_ConvTable( DRW_Table874, CPLENGHTCOMMON ); conv = new DRW_ConvTable( DRW_Table874, CPLENGHTCOMMON );
else if( cp == "ANSI_932" ) else if( cp == "ANSI_932" )
conv = new DRW_Conv932Table( DRW_Table932, DRW_LeadTable932, conv = new DRW_Conv932Table( DRW_Table932, DRW_LeadTable932,
DRW_DoubleTable932, CPLENGHT932 ); DRW_DoubleTable932, CPLENGHT932 );
else if( cp == "ANSI_936" ) else if( cp == "ANSI_936" )
conv = new DRW_ConvDBCSTable( DRW_Table936, DRW_LeadTable936, conv = new DRW_ConvDBCSTable( DRW_Table936, DRW_LeadTable936,
DRW_DoubleTable936, CPLENGHT936 ); DRW_DoubleTable936, CPLENGHT936 );
else if( cp == "ANSI_949" ) else if( cp == "ANSI_949" )
conv = new DRW_ConvDBCSTable( DRW_Table949, DRW_LeadTable949, conv = new DRW_ConvDBCSTable( DRW_Table949, DRW_LeadTable949,
DRW_DoubleTable949, CPLENGHT949 ); DRW_DoubleTable949, CPLENGHT949 );
else if( cp == "ANSI_950" ) else if( cp == "ANSI_950" )
conv = new DRW_ConvDBCSTable( DRW_Table950, DRW_LeadTable950, conv = new DRW_ConvDBCSTable( DRW_Table950, DRW_LeadTable950,
DRW_DoubleTable950, CPLENGHT950 ); DRW_DoubleTable950, CPLENGHT950 );
else if( cp == "ANSI_1250" ) else if( cp == "ANSI_1250" )
conv = new DRW_ConvTable( DRW_Table1250, CPLENGHTCOMMON ); conv = new DRW_ConvTable( DRW_Table1250, CPLENGHTCOMMON );
else if( cp == "ANSI_1251" ) else if( cp == "ANSI_1251" )
...@@ -117,9 +117,9 @@ std::string DRW_TextCodec::fromUtf8( std::string s ) ...@@ -117,9 +117,9 @@ std::string DRW_TextCodec::fromUtf8( std::string s )
std::string DRW_Converter::toUtf8( std::string* s ) std::string DRW_Converter::toUtf8( std::string* s )
{ {
std::string result; std::string result;
int j = 0; int j = 0;
unsigned int i = 0; unsigned int i = 0;
for( i = 0; i < s->length(); i++ ) for( i = 0; i < s->length(); i++ )
{ {
...@@ -127,8 +127,7 @@ std::string DRW_Converter::toUtf8( std::string* s ) ...@@ -127,8 +127,7 @@ std::string DRW_Converter::toUtf8( std::string* s )
if( c < 0x80 ) // ascii check for /U+???? if( c < 0x80 ) // ascii check for /U+????
{ {
if( c == '\\' && i + 6 < s->length() && s->at( i + 1 ) == 'U' && s->at( i + 2 ) == if( c == '\\' && i + 6 < s->length() && s->at( i + 1 ) == 'U' && s->at( i + 2 ) == '+' )
'+' )
{ {
result += s->substr( j, i - j ); result += s->substr( j, i - j );
result += encodeText( s->substr( i, 7 ) ); result += encodeText( s->substr( i, 7 ) );
...@@ -159,10 +158,10 @@ std::string DRW_Converter::toUtf8( std::string* s ) ...@@ -159,10 +158,10 @@ std::string DRW_Converter::toUtf8( std::string* s )
std::string DRW_ConvTable::fromUtf8( std::string* s ) std::string DRW_ConvTable::fromUtf8( std::string* s )
{ {
std::string result; std::string result;
bool notFound; bool notFound;
int code; int code;
int j = 0; int j = 0;
for( unsigned int i = 0; i < s->length(); i++ ) for( unsigned int i = 0; i < s->length(); i++ )
{ {
...@@ -172,17 +171,17 @@ std::string DRW_ConvTable::fromUtf8( std::string* s ) ...@@ -172,17 +171,17 @@ std::string DRW_ConvTable::fromUtf8( std::string* s )
{ {
result += s->substr( j, i - j ); result += s->substr( j, i - j );
std::string part1 = s->substr( i, 4 ); std::string part1 = s->substr( i, 4 );
int l; int l;
code = decodeNum( part1, &l ); code = decodeNum( part1, &l );
j = i + l; j = i + l;
i = j - 1; i = j - 1;
notFound = true; notFound = true;
for( int k = 0; k<cpLenght; k++ ) for( int k = 0; k<cpLenght; k++ )
{ {
if( table[k] == code ) if( table[k] == code )
{ {
result += CPOFFSET + k; // translate from table result += CPOFFSET + k; // translate from table
notFound = false; notFound = false;
break; break;
} }
...@@ -201,10 +200,10 @@ std::string DRW_ConvTable::fromUtf8( std::string* s ) ...@@ -201,10 +200,10 @@ std::string DRW_ConvTable::fromUtf8( std::string* s )
std::string DRW_ConvTable::toUtf8( std::string* s ) std::string DRW_ConvTable::toUtf8( std::string* s )
{ {
std::string res; std::string res;
std::string::iterator it; std::string::iterator it;
for( it = s->begin(); it < s->end(); it++ ) for( it = s->begin(); it < s->end(); ++it )
{ {
unsigned char c = *it; unsigned char c = *it;
...@@ -313,21 +312,21 @@ std::string DRW_Converter::encodeNum( int c ) ...@@ -313,21 +312,21 @@ std::string DRW_Converter::encodeNum( int c )
**/ **/
int DRW_Converter::decodeNum( std::string s, int* b ) int DRW_Converter::decodeNum( std::string s, int* b )
{ {
int code = 0; int code = 0;
unsigned char c = s.at( 0 ); unsigned char c = s.at( 0 );
if( (c & 0xE0) == 0xC0 ) // 2 bytes if( (c & 0xE0) == 0xC0 ) // 2 bytes
{ {
code = ( c & 0x1F) << 6; code = ( c & 0x1F) << 6;
code = (s.at( 1 ) & 0x3F) | code; code = (s.at( 1 ) & 0x3F) | code;
*b = 2; *b = 2;
} }
else if( (c & 0xF0) == 0xE0 ) // 3 bytes else if( (c & 0xF0) == 0xE0 ) // 3 bytes
{ {
code = ( c & 0x0F) << 12; code = ( c & 0x0F) << 12;
code = ( (s.at( 1 ) & 0x3F) << 6 ) | code; code = ( (s.at( 1 ) & 0x3F) << 6 ) | code;
code = (s.at( 2 ) & 0x3F) | code; code = (s.at( 2 ) & 0x3F) | code;
*b = 3; *b = 3;
} }
else if( (c & 0xF8) == 0xF0 ) // 4 bytes else if( (c & 0xF8) == 0xF0 ) // 4 bytes
{ {
...@@ -335,7 +334,7 @@ int DRW_Converter::decodeNum( std::string s, int* b ) ...@@ -335,7 +334,7 @@ int DRW_Converter::decodeNum( std::string s, int* b )
code = ( (s.at( 1 ) & 0x3F) << 12 ) | code; code = ( (s.at( 1 ) & 0x3F) << 12 ) | code;
code = ( (s.at( 2 ) & 0x3F) << 6 ) | code; code = ( (s.at( 2 ) & 0x3F) << 6 ) | code;
code = (s.at( 3 ) & 0x3F) | code; code = (s.at( 3 ) & 0x3F) | code;
*b = 4; *b = 4;
} }
return code; return code;
...@@ -345,10 +344,10 @@ int DRW_Converter::decodeNum( std::string s, int* b ) ...@@ -345,10 +344,10 @@ int DRW_Converter::decodeNum( std::string s, int* b )
std::string DRW_ConvDBCSTable::fromUtf8( std::string* s ) std::string DRW_ConvDBCSTable::fromUtf8( std::string* s )
{ {
std::string result; std::string result;
bool notFound; bool notFound;
int code; int code;
int j = 0; int j = 0;
for( unsigned int i = 0; i < s->length(); i++ ) for( unsigned int i = 0; i < s->length(); i++ )
{ {
...@@ -358,21 +357,21 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s ) ...@@ -358,21 +357,21 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s )
{ {
result += s->substr( j, i - j ); result += s->substr( j, i - j );
std::string part1 = s->substr( i, 4 ); std::string part1 = s->substr( i, 4 );
int l; int l;
code = decodeNum( part1, &l ); code = decodeNum( part1, &l );
j = i + l; j = i + l;
i = j - 1; i = j - 1;
notFound = true; notFound = true;
for( int k = 0; k<cpLenght; k++ ) for( int k = 0; k<cpLenght; k++ )
{ {
if( doubleTable[k][1] == code ) if( doubleTable[k][1] == code )
{ {
int data = doubleTable[k][0]; int data = doubleTable[k][0];
char d[3]; char d[3];
d[0] = data >> 8; d[0] = data >> 8;
d[1] = data & 0xFF; d[1] = data & 0xFF;
d[2] = '\0'; d[2] = '\0';
result += d; // translate from table result += d; // translate from table
notFound = false; notFound = false;
break; break;
...@@ -392,13 +391,13 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s ) ...@@ -392,13 +391,13 @@ std::string DRW_ConvDBCSTable::fromUtf8( std::string* s )
std::string DRW_ConvDBCSTable::toUtf8( std::string* s ) std::string DRW_ConvDBCSTable::toUtf8( std::string* s )
{ {
std::string res; std::string res;
std::string::iterator it; std::string::iterator it;
for( it = s->begin(); it < s->end(); it++ ) for( it = s->begin(); it < s->end(); ++it )
{ {
bool notFound = true; bool notFound = true;
unsigned char c = *it; unsigned char c = *it;
if( c < 0x80 ) if( c < 0x80 )
{ {
...@@ -455,10 +454,10 @@ std::string DRW_ConvDBCSTable::toUtf8( std::string* s ) ...@@ -455,10 +454,10 @@ std::string DRW_ConvDBCSTable::toUtf8( std::string* s )
std::string DRW_Conv932Table::fromUtf8( std::string* s ) std::string DRW_Conv932Table::fromUtf8( std::string* s )
{ {
std::string result; std::string result;
bool notFound; bool notFound;
int code; int code;
int j = 0; int j = 0;
for( unsigned int i = 0; i < s->length(); i++ ) for( unsigned int i = 0; i < s->length(); i++ )
{ {
...@@ -468,16 +467,16 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s ) ...@@ -468,16 +467,16 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s )
{ {
result += s->substr( j, i - j ); result += s->substr( j, i - j );
std::string part1 = s->substr( i, 4 ); std::string part1 = s->substr( i, 4 );
int l; int l;
code = decodeNum( part1, &l ); code = decodeNum( part1, &l );
j = i + l; j = i + l;
i = j - 1; i = j - 1;
notFound = true; notFound = true;
// 1 byte table // 1 byte table
if( code > 0xff60 && code < 0xFFA0 ) if( code > 0xff60 && code < 0xFFA0 )
{ {
result += code - CPOFFSET932; // translate from table result += code - CPOFFSET932; // translate from table
notFound = false; notFound = false;
} }
...@@ -488,12 +487,12 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s ) ...@@ -488,12 +487,12 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s )
{ {
if( doubleTable[k][1] == code ) if( doubleTable[k][1] == code )
{ {
int data = doubleTable[k][0]; int data = doubleTable[k][0];
char d[3]; char d[3];
d[0] = data >> 8; d[0] = data >> 8;
d[1] = data & 0xFF; d[1] = data & 0xFF;
d[2] = '\0'; d[2] = '\0';
result += d; // translate from table result += d; // translate from table
notFound = false; notFound = false;
break; break;
} }
...@@ -513,13 +512,13 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s ) ...@@ -513,13 +512,13 @@ std::string DRW_Conv932Table::fromUtf8( std::string* s )
std::string DRW_Conv932Table::toUtf8( std::string* s ) std::string DRW_Conv932Table::toUtf8( std::string* s )
{ {
std::string res; std::string res;
std::string::iterator it; std::string::iterator it;
for( it = s->begin(); it < s->end(); it++ ) for( it = s->begin(); it < s->end(); ++it )
{ {
bool notFound = true; bool notFound = true;
unsigned char c = *it; unsigned char c = *it;
if( c < 0x80 ) if( c < 0x80 )
{ {
...@@ -661,7 +660,7 @@ std::string DRW_TextCodec::correctCodePage( const std::string& s ) ...@@ -661,7 +660,7 @@ std::string DRW_TextCodec::correctCodePage( const std::string& s )
} }
else if( cp=="ANSI_936" || cp=="GBK" || cp=="GB2312" || cp=="CHINESE" || cp=="CN-GB" else if( cp=="ANSI_936" || cp=="GBK" || cp=="GB2312" || cp=="CHINESE" || cp=="CN-GB"
|| cp=="CSGB2312" || cp=="CSGB231280" || cp=="CSISO58BG231280" || cp=="CSGB2312" || cp=="CSGB231280" || cp=="CSISO58BG231280"
|| cp=="GB_2312-80" || cp=="GB231280" || cp=="GB2312-80" || cp=="GBK" || cp=="GB_2312-80" || cp=="GB231280" || cp=="GB2312-80"
|| cp=="ISO-IR-58" || cp=="GB18030" ) || cp=="ISO-IR-58" || cp=="GB18030" )
{ {
return "ANSI_936"; return "ANSI_936";
......
...@@ -14,20 +14,21 @@ public: ...@@ -14,20 +14,21 @@ public:
std::string toUtf8( std::string s ); std::string toUtf8( std::string s );
int getVersion() { return version; } int getVersion() { return version; }
void setVersion( std::string* v ); void setVersion( std::string* v );
void setVersion( int v ) { version = v; } void setVersion( int v ) { version = v; }
void setCodePage( std::string* c ); void setCodePage( std::string* c );
void setCodePage( std::string c ) { setCodePage( &c ); } void setCodePage( std::string c ) { setCodePage( &c ); }
std::string getCodePage() { return cp; } std::string getCodePage() { return cp; }
private: private:
std::string correctCodePage( const std::string& s ); std::string correctCodePage( const std::string& s );
private: private:
int version; int version;
std::string cp; std::string cp;
DRW_Converter* conv; DRW_Converter* conv;
}; };
class DRW_Converter class DRW_Converter
...@@ -47,8 +48,8 @@ public: ...@@ -47,8 +48,8 @@ public:
std::string encodeNum( int c ); std::string encodeNum( int c );
int decodeNum( std::string s, int* b ); int decodeNum( std::string s, int* b );
const int* table; const int* table;
int cpLenght; int cpLenght;
}; };
class DRW_ConvTable : public DRW_Converter class DRW_ConvTable : public DRW_Converter
...@@ -63,9 +64,9 @@ class DRW_ConvDBCSTable : public DRW_Converter ...@@ -63,9 +64,9 @@ class DRW_ConvDBCSTable : public DRW_Converter
{ {
public: public:
DRW_ConvDBCSTable( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t, DRW_ConvDBCSTable( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t,
l ) l )
{ {
leadTable = lt; leadTable = lt;
doubleTable = dt; doubleTable = dt;
} }
...@@ -81,9 +82,9 @@ class DRW_Conv932Table : public DRW_Converter ...@@ -81,9 +82,9 @@ class DRW_Conv932Table : public DRW_Converter
{ {
public: public:
DRW_Conv932Table( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t, DRW_Conv932Table( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t,
l ) l )
{ {
leadTable = lt; leadTable = lt;
doubleTable = dt; doubleTable = dt;
} }
......
...@@ -127,7 +127,7 @@ int dxfReader::getHandleString() ...@@ -127,7 +127,7 @@ int dxfReader::getHandleString()
bool dxfReaderBinary::readCode( int* code ) bool dxfReaderBinary::readCode( int* code )
{ {
unsigned short* int16p; unsigned short* int16p;
char buffer[2]; char buffer[2];
filestr->read( buffer, 2 ); filestr->read( buffer, 2 );
int16p = (unsigned short*) buffer; int16p = (unsigned short*) buffer;
...@@ -179,8 +179,8 @@ bool dxfReaderBinary::readInt() ...@@ -179,8 +179,8 @@ bool dxfReaderBinary::readInt()
bool dxfReaderBinary::readInt32() bool dxfReaderBinary::readInt32()
{ {
unsigned int* int32p; unsigned int* int32p;
char buffer[4]; char buffer[4];
filestr->read( buffer, 4 ); filestr->read( buffer, 4 );
int32p = (unsigned int*) buffer; int32p = (unsigned int*) buffer;
...@@ -206,11 +206,11 @@ bool dxfReaderBinary::readInt64() ...@@ -206,11 +206,11 @@ bool dxfReaderBinary::readInt64()
bool dxfReaderBinary::readDouble() bool dxfReaderBinary::readDouble()
{ {
double* result; double* result;
char buffer[8]; char buffer[8];
filestr->read( buffer, 8 ); filestr->read( buffer, 8 );
result = (double*) buffer; result = (double*) buffer;
doubleData = *result; doubleData = *result;
DBG( doubleData ); DBG( "\n" ); DBG( doubleData ); DBG( "\n" );
return filestr->good(); return filestr->good();
} }
......
...@@ -21,6 +21,9 @@ public: ...@@ -21,6 +21,9 @@ public:
dxfReader( std::ifstream* stream ) dxfReader( std::ifstream* stream )
{ {
filestr = stream; filestr = stream;
doubleData = 0.0;
intData = 0;
int64 = 0;
#ifdef DRW_DBG #ifdef DRW_DBG
count = 0; count = 0;
#endif #endif
...@@ -31,14 +34,14 @@ public: ...@@ -31,14 +34,14 @@ public:
virtual bool readString( std::string* text ) = 0; virtual bool readString( std::string* text ) = 0;
virtual bool readString() = 0; virtual bool readString() = 0;
bool readRec( int* code, bool skip ); bool readRec( int* code, bool skip );
virtual bool readInt() = 0; virtual bool readInt() = 0;
virtual bool readInt32() = 0; virtual bool readInt32() = 0;
virtual bool readInt64() = 0; virtual bool readInt64() = 0;
virtual bool readDouble() = 0; virtual bool readDouble() = 0;
virtual bool readBool() = 0; virtual bool readBool() = 0;
std::string getString() { return strData; } std::string getString() { return strData; }
int getHandleString(); // Convert hex string to int int getHandleString(); // Convert hex string to int
std::string toUtf8String( std::string t ) { return decoder.toUtf8( t ); } std::string toUtf8String( std::string t ) { return decoder.toUtf8( t ); }
std::string getUtf8String() { return decoder.toUtf8( strData ); } std::string getUtf8String() { return decoder.toUtf8( strData ); }
...@@ -51,22 +54,24 @@ public: ...@@ -51,22 +54,24 @@ public:
void setCodePage( std::string* c ) { decoder.setCodePage( c ); } void setCodePage( std::string* c ) { decoder.setCodePage( c ); }
std::string getCodePage() { return decoder.getCodePage(); } std::string getCodePage() { return decoder.getCodePage(); }
#ifdef DRW_DBG #ifdef DRW_DBG
int count; // DBG int count; // DBG
#endif #endif
protected: protected:
std::ifstream* filestr; std::ifstream* filestr;
std::string strData; std::string strData;
double doubleData; double doubleData;
signed int intData; // 32 bits integer signed int intData; // 32 bits integer
unsigned long long int int64; // 64 bits integer unsigned long long int int64; // 64 bits integer
private: private:
DRW_TextCodec decoder; DRW_TextCodec decoder;
}; };
class dxfReaderBinary : public dxfReader class dxfReaderBinary : public dxfReader
{ {
public: public:
dxfReaderBinary( std::ifstream* stream ) : dxfReader( stream ) { } dxfReaderBinary( std::ifstream* stream ) : dxfReader( stream ) {}
virtual ~dxfReaderBinary() {} virtual ~dxfReaderBinary() {}
virtual bool readCode( int* code ); virtual bool readCode( int* code );
virtual bool readString( std::string* text ); virtual bool readString( std::string* text );
...@@ -81,7 +86,7 @@ public: ...@@ -81,7 +86,7 @@ public:
class dxfReaderAscii : public dxfReader class dxfReaderAscii : public dxfReader
{ {
public: public:
dxfReaderAscii( std::ifstream* stream ) : dxfReader( stream ) { } dxfReaderAscii( std::ifstream* stream ) : dxfReader( stream ) {}
virtual ~dxfReaderAscii() {} virtual ~dxfReaderAscii() {}
virtual bool readCode( int* code ); virtual bool readCode( int* code );
virtual bool readString( std::string* text ); virtual bool readString( std::string* text );
......
...@@ -28,22 +28,24 @@ public: ...@@ -28,22 +28,24 @@ public:
virtual bool writeInt16( int code, int data ) = 0; virtual bool writeInt16( int code, int data ) = 0;
virtual bool writeInt32( 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 writeInt64( int code, unsigned long long int data ) = 0;
virtual bool writeDouble( int code, double data ) = 0; virtual bool writeDouble( int code, double data ) = 0;
virtual bool writeBool( int code, bool data ) = 0; virtual bool writeBool( int code, bool data ) = 0;
void setVersion( std::string* v ) { encoder.setVersion( v ); } void setVersion( std::string* v ) { encoder.setVersion( v ); }
void setCodePage( std::string* c ) { encoder.setCodePage( c ); } void setCodePage( std::string* c ) { encoder.setCodePage( c ); }
std::string getCodePage() { return encoder.getCodePage(); } std::string getCodePage() { return encoder.getCodePage(); }
protected: protected:
std::ofstream* filestr; std::ofstream* filestr;
private: private:
DRW_TextCodec encoder; DRW_TextCodec encoder;
}; };
class dxfWriterBinary : public dxfWriter class dxfWriterBinary : public dxfWriter
{ {
public: public:
dxfWriterBinary( std::ofstream* stream ) : dxfWriter( stream ) { } dxfWriterBinary( std::ofstream* stream ) : dxfWriter( stream ) {}
virtual ~dxfWriterBinary() {} virtual ~dxfWriterBinary() {}
virtual bool writeString( int code, std::string text ); virtual bool writeString( int code, std::string text );
virtual bool writeInt16( int code, int data ); virtual bool writeInt16( int code, int data );
...@@ -56,7 +58,7 @@ public: ...@@ -56,7 +58,7 @@ public:
class dxfWriterAscii : public dxfWriter class dxfWriterAscii : public dxfWriter
{ {
public: public:
dxfWriterAscii( std::ofstream* stream ) : dxfWriter( stream ) { } dxfWriterAscii( std::ofstream* stream ) : dxfWriter( stream ) {}
virtual ~dxfWriterAscii() {} virtual ~dxfWriterAscii() {}
virtual bool writeString( int code, std::string text ); virtual bool writeString( int code, std::string text );
virtual bool writeInt16( int code, int data ); virtual bool writeInt16( int code, int data );
......
...@@ -40,11 +40,19 @@ ...@@ -40,11 +40,19 @@
dxfRW::dxfRW( const char* name ) dxfRW::dxfRW( const char* name )
{ {
fileName = name; fileName = name;
reader = NULL; reader = NULL;
writer = NULL; writer = NULL;
applyExt = false; applyExt = false;
elParts = 128; // parts munber when convert ellipse to polyline elParts = 128; // parts munber when convert ellipse to polyline
binary = false;
iface = NULL;
entCount = 0;
wlayer0 = false;
dimstyleStd = false;
writingBlock = false;
currHandle = 0;
} }
...@@ -52,15 +60,23 @@ dxfRW::~dxfRW() ...@@ -52,15 +60,23 @@ dxfRW::~dxfRW()
{ {
if( reader != NULL ) if( reader != NULL )
delete reader; delete reader;
if( writer != NULL )
delete writer;
for( std::vector<DRW_ImageDef*>::iterator it = imageDef.begin(); it!=imageDef.end(); ++it )
delete *it;
imageDef.clear();
} }
bool dxfRW::read( DRW_Interface* interface_, bool ext ) bool dxfRW::read( DRW_Interface* interface_, bool ext )
{ {
assert( fileName.empty() == false ); assert( fileName.empty() == false );
bool isOk = false; bool isOk = false;
applyExt = ext; applyExt = ext;
std::ifstream filestr; std::ifstream filestr;
if( interface_ == NULL ) if( interface_ == NULL )
return isOk; return isOk;
...@@ -109,12 +125,12 @@ bool dxfRW::read( DRW_Interface* interface_, bool ext ) ...@@ -109,12 +125,12 @@ bool dxfRW::read( DRW_Interface* interface_, bool ext )
bool dxfRW::write( DRW_Interface* interface_, DRW::Version ver, bool bin ) bool dxfRW::write( DRW_Interface* interface_, DRW::Version ver, bool bin )
{ {
bool isOk = false; bool isOk = false;
std::ofstream filestr; std::ofstream filestr;
version = ver; version = ver;
binary = bin; binary = bin;
iface = interface_; iface = interface_;
if( binary ) if( binary )
{ {
...@@ -322,6 +338,11 @@ bool dxfRW::writeLayer( DRW_Layer* ent ) ...@@ -322,6 +338,11 @@ bool dxfRW::writeLayer( DRW_Layer* ent )
else else
writer->writeUtf8Caps( 6, ent->lineType ); writer->writeUtf8Caps( 6, ent->lineType );
if( !ent->extData.empty() )
{
writeExtData( ent->extData );
}
// writer->writeString(347, "10012"); // writer->writeString(347, "10012");
return true; return true;
} }
...@@ -391,7 +412,7 @@ bool dxfRW::writeVport( DRW_Vport* ent ) ...@@ -391,7 +412,7 @@ bool dxfRW::writeVport( DRW_Vport* ent )
{ {
if( !dimstyleStd ) if( !dimstyleStd )
{ {
ent->name = "*ACTIVE"; ent->name = "*ACTIVE";
dimstyleStd = true; dimstyleStd = true;
} }
...@@ -638,6 +659,33 @@ bool dxfRW::writeDimstyle( DRW_Dimstyle* ent ) ...@@ -638,6 +659,33 @@ bool dxfRW::writeDimstyle( DRW_Dimstyle* ent )
} }
bool dxfRW::writeAppId( DRW_AppId* ent )
{
writer->writeString( 0, "APPID" );
if( version > DRW::AC1009 )
{
writer->writeString( 5, toHexStr( ++entCount ) );
if( version > DRW::AC1014 )
{
writer->writeString( 330, "9" );
}
writer->writeString( 100, "AcDbSymbolTableRecord" );
writer->writeString( 100, "AcDbRegAppTableRecord" );
writer->writeUtf8String( 2, ent->name );
}
else
{
writer->writeUtf8Caps( 2, ent->name );
}
writer->writeInt16( 70, ent->flags );
return true;
}
bool dxfRW::writePoint( DRW_Point* ent ) bool dxfRW::writePoint( DRW_Point* ent )
{ {
writer->writeString( 0, "POINT" ); writer->writeString( 0, "POINT" );
...@@ -1202,44 +1250,44 @@ bool dxfRW::writeHatch( DRW_Hatch* ent ) ...@@ -1202,44 +1250,44 @@ bool dxfRW::writeHatch( DRW_Hatch* ent )
switch( ( loop->objlist.at( j ) )->eType ) switch( ( loop->objlist.at( j ) )->eType )
{ {
case DRW::LINE: case DRW::LINE:
{ {
writer->writeInt16( 72, 1 ); writer->writeInt16( 72, 1 );
DRW_Line* l = (DRW_Line*) loop->objlist.at( j ); DRW_Line* l = (DRW_Line*) loop->objlist.at( j );
writer->writeDouble( 10, l->basePoint.x ); writer->writeDouble( 10, l->basePoint.x );
writer->writeDouble( 20, l->basePoint.y ); writer->writeDouble( 20, l->basePoint.y );
writer->writeDouble( 11, l->secPoint.x ); writer->writeDouble( 11, l->secPoint.x );
writer->writeDouble( 21, l->secPoint.y ); writer->writeDouble( 21, l->secPoint.y );
break; break;
} }
case DRW::ARC: case DRW::ARC:
{ {
writer->writeInt16( 72, 2 ); writer->writeInt16( 72, 2 );
DRW_Arc* a = (DRW_Arc*) loop->objlist.at( j ); DRW_Arc* a = (DRW_Arc*) loop->objlist.at( j );
writer->writeDouble( 10, a->basePoint.x ); writer->writeDouble( 10, a->basePoint.x );
writer->writeDouble( 20, a->basePoint.y ); writer->writeDouble( 20, a->basePoint.y );
writer->writeDouble( 40, a->radious ); writer->writeDouble( 40, a->radious );
writer->writeDouble( 50, a->staangle * ARAD ); writer->writeDouble( 50, a->staangle * ARAD );
writer->writeDouble( 51, a->endangle * ARAD ); writer->writeDouble( 51, a->endangle * ARAD );
writer->writeInt16( 73, a->isccw ); writer->writeInt16( 73, a->isccw );
break; break;
} }
case DRW::ELLIPSE: case DRW::ELLIPSE:
{ {
writer->writeInt16( 72, 3 ); writer->writeInt16( 72, 3 );
DRW_Ellipse* a = (DRW_Ellipse*) loop->objlist.at( j ); DRW_Ellipse* a = (DRW_Ellipse*) loop->objlist.at( j );
a->correctAxis(); a->correctAxis();
writer->writeDouble( 10, a->basePoint.x ); writer->writeDouble( 10, a->basePoint.x );
writer->writeDouble( 20, a->basePoint.y ); writer->writeDouble( 20, a->basePoint.y );
writer->writeDouble( 11, a->secPoint.x ); writer->writeDouble( 11, a->secPoint.x );
writer->writeDouble( 21, a->secPoint.y ); writer->writeDouble( 21, a->secPoint.y );
writer->writeDouble( 40, a->ratio ); writer->writeDouble( 40, a->ratio );
writer->writeDouble( 50, a->staparam * ARAD ); writer->writeDouble( 50, a->staparam * ARAD );
writer->writeDouble( 51, a->endparam * ARAD ); writer->writeDouble( 51, a->endparam * ARAD );
writer->writeInt16( 73, a->isccw ); writer->writeInt16( 73, a->isccw );
break; break;
} }
case DRW::SPLINE: case DRW::SPLINE:
// RLZ: spline boundary writeme // RLZ: spline boundary writeme
...@@ -1364,109 +1412,109 @@ bool dxfRW::writeDimension( DRW_Dimension* ent ) ...@@ -1364,109 +1412,109 @@ bool dxfRW::writeDimension( DRW_Dimension* ent )
{ {
case DRW::DIMALIGNED: case DRW::DIMALIGNED:
case DRW::DIMLINEAR: case DRW::DIMLINEAR:
{ {
DRW_DimAligned* dd = (DRW_DimAligned*) ent; DRW_DimAligned* dd = (DRW_DimAligned*) ent;
writer->writeString( 100, "AcDbAlignedDimension" ); writer->writeString( 100, "AcDbAlignedDimension" );
DRW_Coord crd = dd->getClonepoint(); 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 ); if( crd.x != 0 || crd.y != 0 || crd.z != 0 )
writer->writeDouble( 23, dd->getDef1Point().y ); {
writer->writeDouble( 33, dd->getDef1Point().z ); writer->writeDouble( 12, crd.x );
writer->writeDouble( 14, dd->getDef2Point().x ); writer->writeDouble( 22, crd.y );
writer->writeDouble( 24, dd->getDef2Point().y ); writer->writeDouble( 32, crd.z );
writer->writeDouble( 34, dd->getDef2Point().z ); }
if( ent->eType == DRW::DIMLINEAR ) writer->writeDouble( 13, dd->getDef1Point().x );
{ writer->writeDouble( 23, dd->getDef1Point().y );
DRW_DimLinear* dl = (DRW_DimLinear*) ent; 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( dl->getAngle() != 0 ) if( ent->eType == DRW::DIMLINEAR )
writer->writeDouble( 50, dl->getAngle() ); {
DRW_DimLinear* dl = (DRW_DimLinear*) ent;
if( dl->getOblique() != 0 ) if( dl->getAngle() != 0 )
writer->writeDouble( 52, dl->getOblique() ); writer->writeDouble( 50, dl->getAngle() );
writer->writeString( 100, "AcDbRotatedDimension" ); if( dl->getOblique() != 0 )
} writer->writeDouble( 52, dl->getOblique() );
break; writer->writeString( 100, "AcDbRotatedDimension" );
} }
break;
}
case DRW::DIMRADIAL: case DRW::DIMRADIAL:
{ {
DRW_DimRadial* dd = (DRW_DimRadial*) ent; DRW_DimRadial* dd = (DRW_DimRadial*) ent;
writer->writeString( 100, "AcDbRadialDimension" ); writer->writeString( 100, "AcDbRadialDimension" );
writer->writeDouble( 15, dd->getDiameterPoint().x ); writer->writeDouble( 15, dd->getDiameterPoint().x );
writer->writeDouble( 25, dd->getDiameterPoint().y ); writer->writeDouble( 25, dd->getDiameterPoint().y );
writer->writeDouble( 35, dd->getDiameterPoint().z ); writer->writeDouble( 35, dd->getDiameterPoint().z );
writer->writeDouble( 40, dd->getLeaderLength() ); writer->writeDouble( 40, dd->getLeaderLength() );
break; break;
} }
case DRW::DIMDIAMETRIC: case DRW::DIMDIAMETRIC:
{ {
DRW_DimDiametric* dd = (DRW_DimDiametric*) ent; DRW_DimDiametric* dd = (DRW_DimDiametric*) ent;
writer->writeString( 100, "AcDbDiametricDimension" ); writer->writeString( 100, "AcDbDiametricDimension" );
writer->writeDouble( 15, dd->getDiameter1Point().x ); writer->writeDouble( 15, dd->getDiameter1Point().x );
writer->writeDouble( 25, dd->getDiameter1Point().y ); writer->writeDouble( 25, dd->getDiameter1Point().y );
writer->writeDouble( 35, dd->getDiameter1Point().z ); writer->writeDouble( 35, dd->getDiameter1Point().z );
writer->writeDouble( 40, dd->getLeaderLength() ); writer->writeDouble( 40, dd->getLeaderLength() );
break; break;
} }
case DRW::DIMANGULAR: case DRW::DIMANGULAR:
{ {
DRW_DimAngular* dd = (DRW_DimAngular*) ent; DRW_DimAngular* dd = (DRW_DimAngular*) ent;
writer->writeString( 100, "AcDb2LineAngularDimension" ); writer->writeString( 100, "AcDb2LineAngularDimension" );
writer->writeDouble( 13, dd->getFirstLine1().x ); writer->writeDouble( 13, dd->getFirstLine1().x );
writer->writeDouble( 23, dd->getFirstLine1().y ); writer->writeDouble( 23, dd->getFirstLine1().y );
writer->writeDouble( 33, dd->getFirstLine1().z ); writer->writeDouble( 33, dd->getFirstLine1().z );
writer->writeDouble( 14, dd->getFirstLine2().x ); writer->writeDouble( 14, dd->getFirstLine2().x );
writer->writeDouble( 24, dd->getFirstLine2().y ); writer->writeDouble( 24, dd->getFirstLine2().y );
writer->writeDouble( 34, dd->getFirstLine2().z ); writer->writeDouble( 34, dd->getFirstLine2().z );
writer->writeDouble( 15, dd->getSecondLine1().x ); writer->writeDouble( 15, dd->getSecondLine1().x );
writer->writeDouble( 25, dd->getSecondLine1().y ); writer->writeDouble( 25, dd->getSecondLine1().y );
writer->writeDouble( 35, dd->getSecondLine1().z ); writer->writeDouble( 35, dd->getSecondLine1().z );
writer->writeDouble( 16, dd->getDimPoint().x ); writer->writeDouble( 16, dd->getDimPoint().x );
writer->writeDouble( 26, dd->getDimPoint().y ); writer->writeDouble( 26, dd->getDimPoint().y );
writer->writeDouble( 36, dd->getDimPoint().z ); writer->writeDouble( 36, dd->getDimPoint().z );
break; break;
} }
case DRW::DIMANGULAR3P: case DRW::DIMANGULAR3P:
{ {
DRW_DimAngular3p* dd = (DRW_DimAngular3p*) ent; DRW_DimAngular3p* dd = (DRW_DimAngular3p*) ent;
writer->writeDouble( 13, dd->getFirstLine().x ); writer->writeDouble( 13, dd->getFirstLine().x );
writer->writeDouble( 23, dd->getFirstLine().y ); writer->writeDouble( 23, dd->getFirstLine().y );
writer->writeDouble( 33, dd->getFirstLine().z ); writer->writeDouble( 33, dd->getFirstLine().z );
writer->writeDouble( 14, dd->getSecondLine().x ); writer->writeDouble( 14, dd->getSecondLine().x );
writer->writeDouble( 24, dd->getSecondLine().y ); writer->writeDouble( 24, dd->getSecondLine().y );
writer->writeDouble( 34, dd->getSecondLine().z ); writer->writeDouble( 34, dd->getSecondLine().z );
writer->writeDouble( 15, dd->getVertexPoint().x ); writer->writeDouble( 15, dd->getVertexPoint().x );
writer->writeDouble( 25, dd->getVertexPoint().y ); writer->writeDouble( 25, dd->getVertexPoint().y );
writer->writeDouble( 35, dd->getVertexPoint().z ); writer->writeDouble( 35, dd->getVertexPoint().z );
break; break;
} }
case DRW::DIMORDINATE: case DRW::DIMORDINATE:
{ {
DRW_DimOrdinate* dd = (DRW_DimOrdinate*) ent; DRW_DimOrdinate* dd = (DRW_DimOrdinate*) ent;
writer->writeString( 100, "AcDbOrdinateDimension" ); writer->writeString( 100, "AcDbOrdinateDimension" );
writer->writeDouble( 13, dd->getFirstLine().x ); writer->writeDouble( 13, dd->getFirstLine().x );
writer->writeDouble( 23, dd->getFirstLine().y ); writer->writeDouble( 23, dd->getFirstLine().y );
writer->writeDouble( 33, dd->getFirstLine().z ); writer->writeDouble( 33, dd->getFirstLine().z );
writer->writeDouble( 14, dd->getSecondLine().x ); writer->writeDouble( 14, dd->getSecondLine().x );
writer->writeDouble( 24, dd->getSecondLine().y ); writer->writeDouble( 24, dd->getSecondLine().y );
writer->writeDouble( 34, dd->getSecondLine().z ); writer->writeDouble( 34, dd->getSecondLine().z );
break; break;
} }
default: default:
break; break;
...@@ -1582,7 +1630,7 @@ bool dxfRW::writeMText( DRW_MText* ent ) ...@@ -1582,7 +1630,7 @@ bool dxfRW::writeMText( DRW_MText* ent )
writer->writeInt16( 72, ent->alignH ); writer->writeInt16( 72, ent->alignH );
std::string text = writer->fromUtf8String( ent->text ); std::string text = writer->fromUtf8String( ent->text );
int i; int i;
for( i = 0; (text.size() - i) > 250; ) for( i = 0; (text.size() - i) > 250; )
{ {
...@@ -2045,6 +2093,7 @@ bool dxfRW::writeTables() ...@@ -2045,6 +2093,7 @@ bool dxfRW::writeTables()
writer->writeString( 2, "ACAD" ); writer->writeString( 2, "ACAD" );
writer->writeInt16( 70, 0 ); writer->writeInt16( 70, 0 );
iface->writeAppId();
writer->writeString( 0, "ENDTAB" ); writer->writeString( 0, "ENDTAB" );
writer->writeString( 0, "TABLE" ); writer->writeString( 0, "TABLE" );
...@@ -2324,7 +2373,7 @@ bool dxfRW::writeObjects() ...@@ -2324,7 +2373,7 @@ bool dxfRW::writeObjects()
DRW_ImageDef* id = imageDef.at( i ); DRW_ImageDef* id = imageDef.at( i );
std::map<std::string, std::string>::iterator it; std::map<std::string, std::string>::iterator it;
for( it = id->reactors.begin(); it != id->reactors.end(); it++ ) for( it = id->reactors.begin(); it != id->reactors.end(); ++it )
{ {
writer->writeString( 0, "IMAGEDEF_REACTOR" ); writer->writeString( 0, "IMAGEDEF_REACTOR" );
writer->writeString( 5, (*it).first ); writer->writeString( 5, (*it).first );
...@@ -2368,7 +2417,7 @@ bool dxfRW::writeObjects() ...@@ -2368,7 +2417,7 @@ bool dxfRW::writeObjects()
writer->writeString( 102, "{ACAD_REACTORS" ); writer->writeString( 102, "{ACAD_REACTORS" );
std::map<std::string, std::string>::iterator it; std::map<std::string, std::string>::iterator it;
for( it = id->reactors.begin(); it != id->reactors.end(); it++ ) for( it = id->reactors.begin(); it != id->reactors.end(); ++it )
{ {
writer->writeString( 330, (*it).first ); writer->writeString( 330, (*it).first );
} }
...@@ -2395,13 +2444,81 @@ bool dxfRW::writeObjects() ...@@ -2395,13 +2444,81 @@ bool dxfRW::writeObjects()
} }
bool dxfRW::writeExtData( const std::vector<DRW_Variant*>& ed )
{
for( std::vector<DRW_Variant*>::const_iterator it = ed.begin(); it!=ed.end(); ++it )
{
switch( (*it)->code )
{
case 1000:
case 1001:
case 1002:
case 1003:
case 1004:
case 1005:
{
int cc = (*it)->code;
if( (*it)->type == DRW_Variant::STRING )
writer->writeUtf8String( cc, *(*it)->content.s );
// writer->writeUtf8String((*it)->code, (*it)->content.s);
break;
}
case 1010:
case 1011:
case 1012:
case 1013:
if( (*it)->type == DRW_Variant::COORD )
{
writer->writeDouble( (*it)->code, (*it)->content.v->x );
writer->writeDouble( (*it)->code + 10, (*it)->content.v->y );
writer->writeDouble( (*it)->code + 20, (*it)->content.v->z );
}
break;
case 1040:
case 1041:
case 1042:
if( (*it)->type == DRW_Variant::DOUBLE )
writer->writeDouble( (*it)->code, (*it)->content.d );
break;
case 1070:
if( (*it)->type == DRW_Variant::INTEGER )
writer->writeInt16( (*it)->code, (*it)->content.i );
break;
case 1071:
if( (*it)->type == DRW_Variant::INTEGER )
writer->writeInt32( (*it)->code, (*it)->content.i );
break;
default:
break;
}
}
return true;
}
/********* Reader Process *********/ /********* Reader Process *********/
bool dxfRW::processDxf() bool dxfRW::processDxf()
{ {
DBG( "dxfRW::processDxf() start processing dxf\n" ); DBG( "dxfRW::processDxf() start processing dxf\n" );
int code; int code;
bool more = true; bool more = true;
std::string sectionstr; std::string sectionstr;
// section = secUnknown; // section = secUnknown;
...@@ -2478,7 +2595,7 @@ bool dxfRW::processDxf() ...@@ -2478,7 +2595,7 @@ bool dxfRW::processDxf()
bool dxfRW::processHeader() bool dxfRW::processHeader()
{ {
DBG( "dxfRW::processHeader\n" ); DBG( "dxfRW::processHeader\n" );
int code; int code;
std::string sectionstr; std::string sectionstr;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
...@@ -2509,9 +2626,9 @@ bool dxfRW::processHeader() ...@@ -2509,9 +2626,9 @@ bool dxfRW::processHeader()
bool dxfRW::processTables() bool dxfRW::processTables()
{ {
DBG( "dxfRW::processTables\n" ); DBG( "dxfRW::processTables\n" );
int code; int code;
std::string sectionstr; std::string sectionstr;
bool more = true; bool more = true;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -2562,7 +2679,7 @@ bool dxfRW::processTables() ...@@ -2562,7 +2679,7 @@ bool dxfRW::processTables()
} }
else if( sectionstr == "APPID" ) else if( sectionstr == "APPID" )
{ {
// processAppId(); processAppId();
} }
else if( sectionstr == "DIMSTYLE" ) else if( sectionstr == "DIMSTYLE" )
{ {
...@@ -2588,10 +2705,10 @@ bool dxfRW::processTables() ...@@ -2588,10 +2705,10 @@ bool dxfRW::processTables()
bool dxfRW::processLType() bool dxfRW::processLType()
{ {
DBG( "dxfRW::processLType\n" ); DBG( "dxfRW::processLType\n" );
int code; int code;
std::string sectionstr; std::string sectionstr;
bool reading = false; bool reading = false;
DRW_LType ltype; DRW_LType ltype;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -2629,10 +2746,10 @@ bool dxfRW::processLType() ...@@ -2629,10 +2746,10 @@ bool dxfRW::processLType()
bool dxfRW::processLayer() bool dxfRW::processLayer()
{ {
DBG( "dxfRW::processLayer\n" ); DBG( "dxfRW::processLayer\n" );
int code; int code;
std::string sectionstr; std::string sectionstr;
bool reading = false; bool reading = false;
DRW_Layer layer; DRW_Layer layer;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -2667,10 +2784,10 @@ bool dxfRW::processLayer() ...@@ -2667,10 +2784,10 @@ bool dxfRW::processLayer()
bool dxfRW::processDimStyle() bool dxfRW::processDimStyle()
{ {
DBG( "dxfRW::processDimStyle" ); DBG( "dxfRW::processDimStyle" );
int code; int code;
std::string sectionstr; std::string sectionstr;
bool reading = false; bool reading = false;
DRW_Dimstyle dimSty; DRW_Dimstyle dimSty;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -2705,10 +2822,10 @@ bool dxfRW::processDimStyle() ...@@ -2705,10 +2822,10 @@ bool dxfRW::processDimStyle()
bool dxfRW::processTextStyle() bool dxfRW::processTextStyle()
{ {
DBG( "dxfRW::processTextStyle" ); DBG( "dxfRW::processTextStyle" );
int code; int code;
std::string sectionstr; std::string sectionstr;
bool reading = false; bool reading = false;
DRW_Textstyle TxtSty; DRW_Textstyle TxtSty;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -2743,10 +2860,10 @@ bool dxfRW::processTextStyle() ...@@ -2743,10 +2860,10 @@ bool dxfRW::processTextStyle()
bool dxfRW::processVports() bool dxfRW::processVports()
{ {
DBG( "dxfRW::processVports" ); DBG( "dxfRW::processVports" );
int code; int code;
std::string sectionstr; std::string sectionstr;
bool reading = false; bool reading = false;
DRW_Vport vp; DRW_Vport vp;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -2778,12 +2895,50 @@ bool dxfRW::processVports() ...@@ -2778,12 +2895,50 @@ bool dxfRW::processVports()
} }
bool dxfRW::processAppId()
{
DBG( "dxfRW::processAppId" );
int code;
std::string sectionstr;
bool reading = false;
DRW_AppId vp;
while( reader->readRec( &code, !binary ) )
{
DBG( code ); DBG( "\n" );
if( code == 0 )
{
if( reading )
iface->addAppId( vp );
sectionstr = reader->getString();
DBG( sectionstr ); DBG( "\n" );
if( sectionstr == "APPID" )
{
reading = true;
vp.reset();
}
else if( sectionstr == "ENDTAB" )
{
return true; // found ENDTAB terminate
}
}
else if( reading )
vp.parseCode( code, reader );
}
return true;
}
/********* Block Section *********/ /********* Block Section *********/
bool dxfRW::processBlocks() bool dxfRW::processBlocks()
{ {
DBG( "dxfRW::processBlocks\n" ); DBG( "dxfRW::processBlocks\n" );
int code; int code;
std::string sectionstr; std::string sectionstr;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
...@@ -2813,8 +2968,8 @@ bool dxfRW::processBlocks() ...@@ -2813,8 +2968,8 @@ bool dxfRW::processBlocks()
bool dxfRW::processBlock() bool dxfRW::processBlock()
{ {
DBG( "dxfRW::processBlock" ); DBG( "dxfRW::processBlock" );
int code; int code;
DRW_Block block; DRW_Block block;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -2823,23 +2978,23 @@ bool dxfRW::processBlock() ...@@ -2823,23 +2978,23 @@ bool dxfRW::processBlock()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addBlock( block ); iface->addBlock( block );
if( nextentity == "ENDBLK" ) if( nextentity == "ENDBLK" )
{ {
iface->endBlock(); iface->endBlock();
return true; // found ENDBLK, terminate return true; // found ENDBLK, terminate
}
else
{
processEntities( true );
iface->endBlock();
return true; // found ENDBLK, terminate
}
} }
else
{
processEntities( true );
iface->endBlock();
return true; // found ENDBLK, terminate
}
}
default: default:
block.parseCode( code, reader ); block.parseCode( code, reader );
...@@ -2982,7 +3137,7 @@ bool dxfRW::processEntities( bool isblock ) ...@@ -2982,7 +3137,7 @@ bool dxfRW::processEntities( bool isblock )
bool dxfRW::processEllipse() bool dxfRW::processEllipse()
{ {
DBG( "dxfRW::processEllipse" ); DBG( "dxfRW::processEllipse" );
int code; int code;
DRW_Ellipse ellipse; DRW_Ellipse ellipse;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
...@@ -2992,16 +3147,16 @@ bool dxfRW::processEllipse() ...@@ -2992,16 +3147,16 @@ bool dxfRW::processEllipse()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
if( applyExt ) if( applyExt )
ellipse.applyExtrusion(); ellipse.applyExtrusion();
iface->addEllipse( ellipse ); iface->addEllipse( ellipse );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
ellipse.parseCode( code, reader ); ellipse.parseCode( code, reader );
...@@ -3016,8 +3171,8 @@ bool dxfRW::processEllipse() ...@@ -3016,8 +3171,8 @@ bool dxfRW::processEllipse()
bool dxfRW::processTrace() bool dxfRW::processTrace()
{ {
DBG( "dxfRW::processTrace" ); DBG( "dxfRW::processTrace" );
int code; int code;
DRW_Trace trace; DRW_Trace trace;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3026,16 +3181,16 @@ bool dxfRW::processTrace() ...@@ -3026,16 +3181,16 @@ bool dxfRW::processTrace()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
if( applyExt ) if( applyExt )
trace.applyExtrusion(); trace.applyExtrusion();
iface->addTrace( trace ); iface->addTrace( trace );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
trace.parseCode( code, reader ); trace.parseCode( code, reader );
...@@ -3050,8 +3205,8 @@ bool dxfRW::processTrace() ...@@ -3050,8 +3205,8 @@ bool dxfRW::processTrace()
bool dxfRW::processSolid() bool dxfRW::processSolid()
{ {
DBG( "dxfRW::processSolid" ); DBG( "dxfRW::processSolid" );
int code; int code;
DRW_Solid solid; DRW_Solid solid;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3060,16 +3215,16 @@ bool dxfRW::processSolid() ...@@ -3060,16 +3215,16 @@ bool dxfRW::processSolid()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
if( applyExt ) if( applyExt )
solid.applyExtrusion(); solid.applyExtrusion();
iface->addSolid( solid ); iface->addSolid( solid );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
solid.parseCode( code, reader ); solid.parseCode( code, reader );
...@@ -3084,8 +3239,8 @@ bool dxfRW::processSolid() ...@@ -3084,8 +3239,8 @@ bool dxfRW::processSolid()
bool dxfRW::process3dface() bool dxfRW::process3dface()
{ {
DBG( "dxfRW::process3dface" ); DBG( "dxfRW::process3dface" );
int code; int code;
DRW_3Dface face; DRW_3Dface face;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3094,12 +3249,12 @@ bool dxfRW::process3dface() ...@@ -3094,12 +3249,12 @@ bool dxfRW::process3dface()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->add3dFace( face ); iface->add3dFace( face );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
face.parseCode( code, reader ); face.parseCode( code, reader );
...@@ -3114,8 +3269,8 @@ bool dxfRW::process3dface() ...@@ -3114,8 +3269,8 @@ bool dxfRW::process3dface()
bool dxfRW::processViewport() bool dxfRW::processViewport()
{ {
DBG( "dxfRW::processViewport" ); DBG( "dxfRW::processViewport" );
int code; int code;
DRW_Viewport vp; DRW_Viewport vp;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3124,12 +3279,12 @@ bool dxfRW::processViewport() ...@@ -3124,12 +3279,12 @@ bool dxfRW::processViewport()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addViewport( vp ); iface->addViewport( vp );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
vp.parseCode( code, reader ); vp.parseCode( code, reader );
...@@ -3144,8 +3299,8 @@ bool dxfRW::processViewport() ...@@ -3144,8 +3299,8 @@ bool dxfRW::processViewport()
bool dxfRW::processPoint() bool dxfRW::processPoint()
{ {
DBG( "dxfRW::processPoint\n" ); DBG( "dxfRW::processPoint\n" );
int code; int code;
DRW_Point point; DRW_Point point;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3154,12 +3309,12 @@ bool dxfRW::processPoint() ...@@ -3154,12 +3309,12 @@ bool dxfRW::processPoint()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addPoint( point ); iface->addPoint( point );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
point.parseCode( code, reader ); point.parseCode( code, reader );
...@@ -3174,8 +3329,8 @@ bool dxfRW::processPoint() ...@@ -3174,8 +3329,8 @@ bool dxfRW::processPoint()
bool dxfRW::processLine() bool dxfRW::processLine()
{ {
DBG( "dxfRW::processLine\n" ); DBG( "dxfRW::processLine\n" );
int code; int code;
DRW_Line line; DRW_Line line;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3184,12 +3339,12 @@ bool dxfRW::processLine() ...@@ -3184,12 +3339,12 @@ bool dxfRW::processLine()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addLine( line ); iface->addLine( line );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
line.parseCode( code, reader ); line.parseCode( code, reader );
...@@ -3204,7 +3359,7 @@ bool dxfRW::processLine() ...@@ -3204,7 +3359,7 @@ bool dxfRW::processLine()
bool dxfRW::processRay() bool dxfRW::processRay()
{ {
DBG( "dxfRW::processRay\n" ); DBG( "dxfRW::processRay\n" );
int code; int code;
DRW_Ray line; DRW_Ray line;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
...@@ -3214,12 +3369,12 @@ bool dxfRW::processRay() ...@@ -3214,12 +3369,12 @@ bool dxfRW::processRay()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addRay( line ); iface->addRay( line );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
line.parseCode( code, reader ); line.parseCode( code, reader );
...@@ -3234,8 +3389,8 @@ bool dxfRW::processRay() ...@@ -3234,8 +3389,8 @@ bool dxfRW::processRay()
bool dxfRW::processXline() bool dxfRW::processXline()
{ {
DBG( "dxfRW::processXline\n" ); DBG( "dxfRW::processXline\n" );
int code; int code;
DRW_Xline line; DRW_Xline line;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3244,12 +3399,12 @@ bool dxfRW::processXline() ...@@ -3244,12 +3399,12 @@ bool dxfRW::processXline()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addXline( line ); iface->addXline( line );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
line.parseCode( code, reader ); line.parseCode( code, reader );
...@@ -3264,8 +3419,8 @@ bool dxfRW::processXline() ...@@ -3264,8 +3419,8 @@ bool dxfRW::processXline()
bool dxfRW::processCircle() bool dxfRW::processCircle()
{ {
DBG( "dxfRW::processPoint\n" ); DBG( "dxfRW::processPoint\n" );
int code; int code;
DRW_Circle circle; DRW_Circle circle;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3274,16 +3429,16 @@ bool dxfRW::processCircle() ...@@ -3274,16 +3429,16 @@ bool dxfRW::processCircle()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
if( applyExt ) if( applyExt )
circle.applyExtrusion(); circle.applyExtrusion();
iface->addCircle( circle ); iface->addCircle( circle );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
circle.parseCode( code, reader ); circle.parseCode( code, reader );
...@@ -3298,7 +3453,7 @@ bool dxfRW::processCircle() ...@@ -3298,7 +3453,7 @@ bool dxfRW::processCircle()
bool dxfRW::processArc() bool dxfRW::processArc()
{ {
DBG( "dxfRW::processPoint\n" ); DBG( "dxfRW::processPoint\n" );
int code; int code;
DRW_Arc arc; DRW_Arc arc;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
...@@ -3308,16 +3463,16 @@ bool dxfRW::processArc() ...@@ -3308,16 +3463,16 @@ bool dxfRW::processArc()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
if( applyExt ) if( applyExt )
arc.applyExtrusion(); arc.applyExtrusion();
iface->addArc( arc ); iface->addArc( arc );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
arc.parseCode( code, reader ); arc.parseCode( code, reader );
...@@ -3332,8 +3487,8 @@ bool dxfRW::processArc() ...@@ -3332,8 +3487,8 @@ bool dxfRW::processArc()
bool dxfRW::processInsert() bool dxfRW::processInsert()
{ {
DBG( "dxfRW::processInsert" ); DBG( "dxfRW::processInsert" );
int code; int code;
DRW_Insert insert; DRW_Insert insert;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3342,12 +3497,12 @@ bool dxfRW::processInsert() ...@@ -3342,12 +3497,12 @@ bool dxfRW::processInsert()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addInsert( insert ); iface->addInsert( insert );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
insert.parseCode( code, reader ); insert.parseCode( code, reader );
...@@ -3362,8 +3517,8 @@ bool dxfRW::processInsert() ...@@ -3362,8 +3517,8 @@ bool dxfRW::processInsert()
bool dxfRW::processLWPolyline() bool dxfRW::processLWPolyline()
{ {
DBG( "dxfRW::processLWPolyline" ); DBG( "dxfRW::processLWPolyline" );
int code; int code;
DRW_LWPolyline pl; DRW_LWPolyline pl;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3372,16 +3527,16 @@ bool dxfRW::processLWPolyline() ...@@ -3372,16 +3527,16 @@ bool dxfRW::processLWPolyline()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
if( applyExt ) if( applyExt )
pl.applyExtrusion(); pl.applyExtrusion();
iface->addLWPolyline( pl ); iface->addLWPolyline( pl );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
pl.parseCode( code, reader ); pl.parseCode( code, reader );
...@@ -3396,8 +3551,8 @@ bool dxfRW::processLWPolyline() ...@@ -3396,8 +3551,8 @@ bool dxfRW::processLWPolyline()
bool dxfRW::processPolyline() bool dxfRW::processPolyline()
{ {
DBG( "dxfRW::processPolyline" ); DBG( "dxfRW::processPolyline" );
int code; int code;
DRW_Polyline pl; DRW_Polyline pl;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3406,20 +3561,20 @@ bool dxfRW::processPolyline() ...@@ -3406,20 +3561,20 @@ bool dxfRW::processPolyline()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
if( nextentity != "VERTEX" ) if( nextentity != "VERTEX" )
{ {
iface->addPolyline( pl ); iface->addPolyline( pl );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
else else
{ {
processVertex( &pl ); processVertex( &pl );
}
} }
}
default: default:
pl.parseCode( code, reader ); pl.parseCode( code, reader );
...@@ -3434,7 +3589,7 @@ bool dxfRW::processPolyline() ...@@ -3434,7 +3589,7 @@ bool dxfRW::processPolyline()
bool dxfRW::processVertex( DRW_Polyline* pl ) bool dxfRW::processVertex( DRW_Polyline* pl )
{ {
DBG( "dxfRW::processVertex" ); DBG( "dxfRW::processVertex" );
int code; int code;
DRW_Vertex* v = new DRW_Vertex(); DRW_Vertex* v = new DRW_Vertex();
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
...@@ -3444,20 +3599,20 @@ bool dxfRW::processVertex( DRW_Polyline* pl ) ...@@ -3444,20 +3599,20 @@ bool dxfRW::processVertex( DRW_Polyline* pl )
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
pl->appendVertex( v ); pl->appendVertex( v );
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
if( nextentity == "SEQEND" ) if( nextentity == "SEQEND" )
{ {
return true; // found SEQEND no more vertex, terminate return true; // found SEQEND no more vertex, terminate
}
else if( nextentity == "VERTEX" )
{
v = new DRW_Vertex(); // another vertex
}
} }
else if( nextentity == "VERTEX" )
{
v = new DRW_Vertex(); // another vertex
}
}
default: default:
v->parseCode( code, reader ); v->parseCode( code, reader );
...@@ -3472,8 +3627,8 @@ bool dxfRW::processVertex( DRW_Polyline* pl ) ...@@ -3472,8 +3627,8 @@ bool dxfRW::processVertex( DRW_Polyline* pl )
bool dxfRW::processText() bool dxfRW::processText()
{ {
DBG( "dxfRW::processText" ); DBG( "dxfRW::processText" );
int code; int code;
DRW_Text txt; DRW_Text txt;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3482,12 +3637,12 @@ bool dxfRW::processText() ...@@ -3482,12 +3637,12 @@ bool dxfRW::processText()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addText( txt ); iface->addText( txt );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
txt.parseCode( code, reader ); txt.parseCode( code, reader );
...@@ -3502,8 +3657,8 @@ bool dxfRW::processText() ...@@ -3502,8 +3657,8 @@ bool dxfRW::processText()
bool dxfRW::processMText() bool dxfRW::processMText()
{ {
DBG( "dxfRW::processMText" ); DBG( "dxfRW::processMText" );
int code; int code;
DRW_MText txt; DRW_MText txt;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3512,13 +3667,13 @@ bool dxfRW::processMText() ...@@ -3512,13 +3667,13 @@ bool dxfRW::processMText()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
txt.updateAngle(); txt.updateAngle();
iface->addMText( txt ); iface->addMText( txt );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
txt.parseCode( code, reader ); txt.parseCode( code, reader );
...@@ -3533,8 +3688,8 @@ bool dxfRW::processMText() ...@@ -3533,8 +3688,8 @@ bool dxfRW::processMText()
bool dxfRW::processHatch() bool dxfRW::processHatch()
{ {
DBG( "dxfRW::processHatch" ); DBG( "dxfRW::processHatch" );
int code; int code;
DRW_Hatch hatch; DRW_Hatch hatch;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3543,12 +3698,12 @@ bool dxfRW::processHatch() ...@@ -3543,12 +3698,12 @@ bool dxfRW::processHatch()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addHatch( &hatch ); iface->addHatch( &hatch );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
hatch.parseCode( code, reader ); hatch.parseCode( code, reader );
...@@ -3563,8 +3718,8 @@ bool dxfRW::processHatch() ...@@ -3563,8 +3718,8 @@ bool dxfRW::processHatch()
bool dxfRW::processSpline() bool dxfRW::processSpline()
{ {
DBG( "dxfRW::processSpline" ); DBG( "dxfRW::processSpline" );
int code; int code;
DRW_Spline sp; DRW_Spline sp;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3573,12 +3728,12 @@ bool dxfRW::processSpline() ...@@ -3573,12 +3728,12 @@ bool dxfRW::processSpline()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addSpline( &sp ); iface->addSpline( &sp );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
sp.parseCode( code, reader ); sp.parseCode( code, reader );
...@@ -3593,8 +3748,8 @@ bool dxfRW::processSpline() ...@@ -3593,8 +3748,8 @@ bool dxfRW::processSpline()
bool dxfRW::processImage() bool dxfRW::processImage()
{ {
DBG( "dxfRW::processImage" ); DBG( "dxfRW::processImage" );
int code; int code;
DRW_Image img; DRW_Image img;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3603,12 +3758,12 @@ bool dxfRW::processImage() ...@@ -3603,12 +3758,12 @@ bool dxfRW::processImage()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addImage( &img ); iface->addImage( &img );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
img.parseCode( code, reader ); img.parseCode( code, reader );
...@@ -3623,8 +3778,8 @@ bool dxfRW::processImage() ...@@ -3623,8 +3778,8 @@ bool dxfRW::processImage()
bool dxfRW::processDimension() bool dxfRW::processDimension()
{ {
DBG( "dxfRW::processDimension" ); DBG( "dxfRW::processDimension" );
int code; int code;
DRW_Dimension dim; DRW_Dimension dim;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3633,65 +3788,65 @@ bool dxfRW::processDimension() ...@@ -3633,65 +3788,65 @@ bool dxfRW::processDimension()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
int type = dim.type & 0x0F; int type = dim.type & 0x0F;
switch( type )
{
case 0:
{
DRW_DimLinear d( dim );
iface->addDimLinear( &d );
break;
}
case 1: switch( type )
{ {
DRW_DimAligned d( dim ); case 0:
iface->addDimAlign( &d ); {
break; DRW_DimLinear d( dim );
} iface->addDimLinear( &d );
break;
}
case 2: case 1:
{ {
DRW_DimAngular d( dim ); DRW_DimAligned d( dim );
iface->addDimAngular( &d ); iface->addDimAlign( &d );
break; break;
} }
case 3: case 2:
{ {
DRW_DimDiametric d( dim ); DRW_DimAngular d( dim );
iface->addDimDiametric( &d ); iface->addDimAngular( &d );
break; break;
} }
case 4: case 3:
{ {
DRW_DimRadial d( dim ); DRW_DimDiametric d( dim );
iface->addDimRadial( &d ); iface->addDimDiametric( &d );
break; break;
} }
case 5: case 4:
{ {
DRW_DimAngular3p d( dim ); DRW_DimRadial d( dim );
iface->addDimAngular3P( &d ); iface->addDimRadial( &d );
break; break;
} }
case 6: case 5:
{ {
DRW_DimOrdinate d( dim ); DRW_DimAngular3p d( dim );
iface->addDimOrdinate( &d ); iface->addDimAngular3P( &d );
break; break;
} }
}
return true; // found new entity or ENDSEC, terminate case 6:
{
DRW_DimOrdinate d( dim );
iface->addDimOrdinate( &d );
break;
} }
}
return true; // found new entity or ENDSEC, terminate
}
default: default:
dim.parseCode( code, reader ); dim.parseCode( code, reader );
...@@ -3706,8 +3861,8 @@ bool dxfRW::processDimension() ...@@ -3706,8 +3861,8 @@ bool dxfRW::processDimension()
bool dxfRW::processLeader() bool dxfRW::processLeader()
{ {
DBG( "dxfRW::processLeader" ); DBG( "dxfRW::processLeader" );
int code; int code;
DRW_Leader leader; DRW_Leader leader;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3716,12 +3871,12 @@ bool dxfRW::processLeader() ...@@ -3716,12 +3871,12 @@ bool dxfRW::processLeader()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->addLeader( &leader ); iface->addLeader( &leader );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
leader.parseCode( code, reader ); leader.parseCode( code, reader );
...@@ -3784,8 +3939,8 @@ bool dxfRW::processObjects() ...@@ -3784,8 +3939,8 @@ bool dxfRW::processObjects()
bool dxfRW::processImageDef() bool dxfRW::processImageDef()
{ {
DBG( "dxfRW::processImageDef" ); DBG( "dxfRW::processImageDef" );
int code; int code;
DRW_ImageDef img; DRW_ImageDef img;
while( reader->readRec( &code, !binary ) ) while( reader->readRec( &code, !binary ) )
{ {
...@@ -3794,12 +3949,12 @@ bool dxfRW::processImageDef() ...@@ -3794,12 +3949,12 @@ bool dxfRW::processImageDef()
switch( code ) switch( code )
{ {
case 0: case 0:
{ {
nextentity = reader->getString(); nextentity = reader->getString();
DBG( nextentity ); DBG( "\n" ); DBG( nextentity ); DBG( "\n" );
iface->linkImage( &img ); iface->linkImage( &img );
return true; // found new entity or ENDSEC, terminate return true; // found new entity or ENDSEC, terminate
} }
default: default:
img.parseCode( code, reader ); img.parseCode( code, reader );
......
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
* @param ext should the extrusion be applied to convert in 2D? * @param ext should the extrusion be applied to convert in 2D?
* @return true for success * @return true for success
*/ */
bool read( DRW_Interface* interface_, bool ext ); bool read( DRW_Interface* interface_, bool ext );
void setBinary( bool b ) { binary = b; } void setBinary( bool b ) { binary = b; }
...@@ -45,6 +45,7 @@ public: ...@@ -45,6 +45,7 @@ public:
bool writeDimstyle( DRW_Dimstyle* ent ); bool writeDimstyle( DRW_Dimstyle* ent );
bool writeTextstyle( DRW_Textstyle* ent ); bool writeTextstyle( DRW_Textstyle* ent );
bool writeVport( DRW_Vport* ent ); bool writeVport( DRW_Vport* ent );
bool writeAppId( DRW_AppId* ent );
bool writePoint( DRW_Point* ent ); bool writePoint( DRW_Point* ent );
bool writeLine( DRW_Line* ent ); bool writeLine( DRW_Line* ent );
bool writeRay( DRW_Ray* ent ); bool writeRay( DRW_Ray* ent );
...@@ -70,74 +71,77 @@ public: ...@@ -70,74 +71,77 @@ public:
bool writeDimension( DRW_Dimension* ent ); bool writeDimension( DRW_Dimension* ent );
void setEllipseParts( int parts ) { elParts = parts; } /*!< set parts munber when convert ellipse to polyline */ void setEllipseParts( int parts ) { elParts = parts; } /*!< set parts munber when convert ellipse to polyline */
private: private:
/// used by read() to parse the content of the file /// used by read() to parse the content of the file
bool processDxf(); bool processDxf();
bool processHeader(); bool processHeader();
bool processTables(); bool processTables();
bool processBlocks(); bool processBlocks();
bool processBlock(); bool processBlock();
bool processEntities( bool isblock ); bool processEntities( bool isblock );
bool processObjects(); bool processObjects();
bool processLType(); bool processLType();
bool processLayer(); bool processLayer();
bool processDimStyle(); bool processDimStyle();
bool processTextStyle(); bool processTextStyle();
bool processVports(); bool processVports();
bool processAppId();
bool processPoint(); bool processPoint();
bool processLine(); bool processLine();
bool processRay(); bool processRay();
bool processXline(); bool processXline();
bool processCircle(); bool processCircle();
bool processArc(); bool processArc();
bool processEllipse(); bool processEllipse();
bool processTrace(); bool processTrace();
bool processSolid(); bool processSolid();
bool processInsert(); bool processInsert();
bool processLWPolyline(); bool processLWPolyline();
bool processPolyline(); bool processPolyline();
bool processVertex( DRW_Polyline* pl ); bool processVertex( DRW_Polyline* pl );
bool processText(); bool processText();
bool processMText(); bool processMText();
bool processHatch(); bool processHatch();
bool processSpline(); bool processSpline();
bool process3dface(); bool process3dface();
bool processViewport(); bool processViewport();
bool processImage(); bool processImage();
bool processImageDef(); bool processImageDef();
bool processDimension(); bool processDimension();
bool processLeader(); bool processLeader();
// bool writeHeader(); // bool writeHeader();
bool writeEntity( DRW_Entity* ent ); bool writeEntity( DRW_Entity* ent );
bool writeTables(); bool writeTables();
bool writeBlocks(); bool writeBlocks();
bool writeObjects(); bool writeObjects();
std::string toHexStr( int n ); bool writeExtData( const std::vector<DRW_Variant*>& ed );
std::string toHexStr( int n );
private: private:
DRW::Version version; DRW::Version version;
std::string fileName; std::string fileName;
std::string codePage; std::string codePage;
bool binary; bool binary;
dxfReader* reader; dxfReader* reader;
dxfWriter* writer; dxfWriter* writer;
DRW_Interface* iface; DRW_Interface* iface;
DRW_Header header; DRW_Header header;
// int section; // int section;
std::string nextentity; std::string nextentity;
int entCount; int entCount;
bool wlayer0; bool wlayer0;
bool dimstyleStd; bool dimstyleStd;
bool applyExt; bool applyExt;
bool writingBlock; bool writingBlock;
int elParts; /*!< parts munber when convert ellipse to polyline */ int elParts; /*!< parts munber when convert ellipse to polyline */
std::map<std::string, int> blockMap; std::map<std::string, int> blockMap;
std::vector<DRW_ImageDef*> imageDef; /*!< imageDef list */ std::vector<DRW_ImageDef*> imageDef; /*!< imageDef list */
int currHandle; int currHandle;
}; };
#endif // LIBDXFRW_H #endif // LIBDXFRW_H
...@@ -165,6 +165,9 @@ private: ...@@ -165,6 +165,9 @@ private:
void writeLine(); void writeLine();
void writeMtext(); void writeMtext();
virtual void addAppId( const DRW_AppId& data ) {}
virtual void writeAppId() {}
}; };
#endif // FILTERDXFRW_H #endif // FILTERDXFRW_H
...@@ -91,6 +91,8 @@ private: ...@@ -91,6 +91,8 @@ private:
virtual void writeTextstyles(){} virtual void writeTextstyles(){}
virtual void writeVports(){} virtual void writeVports(){}
virtual void writeDimstyles(){} virtual void writeDimstyles(){}
virtual void addAppId( const DRW_AppId& data ) {}
virtual void writeAppId() {}
}; };
#endif // DXF2IDF_H #endif // DXF2IDF_H
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