Commit 3e3869ed authored by jean-pierre charras's avatar jean-pierre charras

dxf import: minor enhancements in dialog. Update libdfxw from git, and...

dxf import: minor enhancements in dialog. Update libdfxw from git, and uncrustify it. add a test dfx file
parent f0b2565f
......@@ -18,8 +18,6 @@
#include <string>
#include <cmath>
using std::string;
#define UTF8STRING std::string
#define DRW_UNUSED( x ) (void) x
......@@ -203,7 +201,7 @@ public:
// string codepage;
private:
// DRW_VarContent content;
string data;
std::string data;
};
......
......@@ -21,8 +21,6 @@
class dxfReader;
class DRW_Polyline;
using std::string;
namespace DRW {
// ! Entity's type.
enum ETYPE {
......@@ -123,7 +121,7 @@ public:
double ltypeScale; /*!< linetype scale, code 48 */
bool visible; /*!< entity visibility, code 60 */
int color24; /*!< 24-bit color, code 420 */
string colorName; /*!< color name, code 430 */
std::string colorName; /*!< color name, code 430 */
int space; /*!< space indicator 0 = model, 1 paper, code 67*/
bool haveExtrusion; /*!< set to true if the entity have extrusion*/
private:
......@@ -891,7 +889,7 @@ public:
void parseCode( int code, dxfReader* reader );
public:
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 vy; /*!< V-vector of single pixel, y coordinate, code 22 */
double vz; /*!< V-vector of single pixel, z coordinate, code 32 */
......@@ -960,14 +958,14 @@ public:
void setDefPoint( const DRW_Coord p ) { defPoint = p; }
DRW_Coord getTextPoint() const { return textPoint; } /*!< Middle point of text, code 11, 21 & 31 */
void setTextPoint( const DRW_Coord p ) { textPoint = p; }
string getStyle() const { return style; } /*!< Dimension style, code 3 */
void setStyle( const string s ) { style = s; }
std::string getStyle() const { return style; } /*!< Dimension style, code 3 */
void setStyle( const std::string s ) { style = s; }
int getAlign() const { return align; } /*!< attachment point, code 71 */
void setAlign( const int a ) { align = a; }
int getTextLineStyle() const { return linesty; } /*!< Dimension text line spacing style, code 72, default 1 */
void setTextLineStyle( const int l ) { linesty = l; }
string getText() const { return text; } /*!< Dimension text explicitly entered by the user, code 1 */
void setText( const string t ) { text = t; }
std::string getText() const { return text; } /*!< Dimension text explicitly entered by the user, code 1 */
void setText( const std::string t ) { text = t; }
double getTextLineFactor() const { return linefactor; } /*!< Dimension text line spacing factor, code 41, default 1? */
void setTextLineFactor( const double l ) { linefactor = l; }
double getDir() const { return rot; } /*!< rotation angle of the dimension text, code 53 (optional) default 0 */
......@@ -975,8 +973,8 @@ public:
DRW_Coord getExtrusion() { return extPoint; } /*!< extrusion, code 210, 220 & 230 */
void setExtrusion( const DRW_Coord p ) { extPoint = p; }
string getName() { return name; } /*!< Name of the block that contains the entities, code 2 */
void setName( const string s ) { name = s; }
std::string getName() { return name; } /*!< Name of the block that contains the entities, code 2 */
void setName( const std::string s ) { name = s; }
// int getType(){ return type;} /*!< Dimension type, code 70 */
protected:
DRW_Coord getPt2() const { return clonePoint; }
......@@ -998,7 +996,7 @@ protected:
public:
int type; /*!< Dimension type, code 70 */
private:
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 textPoint; /*!< Middle point of text, code 11, 21 & 31 (OCS) */
UTF8STRING text; /*!< Dimension text explicitly entered by the user, code 1 */
......@@ -1253,7 +1251,7 @@ public:
double textwidth; /*!< Text annotation width, code 41 */
int vertnum; /*!< Number of vertices, code 76 */
int coloruse; /*!< Color to use if leader's DIMCLRD = BYBLOCK, code 77 */
string handle; /*!< Hard reference to associated annotation, code 340 */
std::string handle; /*!< Hard reference to associated annotation, code 340 */
DRW_Coord extrusionPoint; /*!< Normal vector, code 210, 220 & 230 */
DRW_Coord horizdir; /*!< "Horizontal" direction for leader, code 211, 221 & 231 */
DRW_Coord offsetblock; /*!< Offset of last leader vertex from block, code 212, 222 & 232 */
......
......@@ -679,7 +679,7 @@ void DRW_ImageDef::parseCode( int code, dxfReader* reader )
}
void DRW_Header::addComment( string c )
void DRW_Header::addComment( std::string c )
{
if( !comments.empty() )
comments += '\n';
......@@ -858,6 +858,9 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
writer->writeString( 1, varStr );
writer->setVersion( &varStr );
getStr( "$ACADVER", &varStr );
getStr( "$ACADMAINTVER", &varStr );
if( ver > DRW::AC1012 )
{
writer->writeString( 9, "$HANDSEED" );
......@@ -970,6 +973,18 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
else
writer->writeString( 7, "STANDARD" );
writer->writeString( 9, "$CLAYER" );
if( getStr( "$CLAYER", &varStr ) )
if( ver == DRW::AC1009 )
writer->writeUtf8Caps( 8, varStr );
else
writer->writeUtf8String( 8, varStr );
else
writer->writeString( 8, "0" );
writer->writeString( 9, "$DIMASZ" );
if( getDouble( "$DIMASZ", &varDouble ) )
......@@ -977,6 +992,13 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
else
writer->writeDouble( 40, 2.5 );
writer->writeString( 9, "$DIMLFAC" );
if( getDouble( "$DIMLFAC", &varDouble ) )
writer->writeDouble( 40, varDouble );
else
writer->writeDouble( 40, 1.0 );
writer->writeString( 9, "$DIMSCALE" );
if( getDouble( "$DIMSCALE", &varDouble ) )
......@@ -1210,16 +1232,20 @@ void DRW_Header::write( dxfWriter* writer, DRW::Version ver )
writer->writeDouble( 40, 0.0 );
}
#ifdef DRW_DBG
std::map<std::string, DRW_Variant*>::const_iterator it;
for( it = vars.begin(); it != vars.end(); it++ )
{
// QString key = QString::fromStdString((*it).first);
std::cerr << (*it).first << std::endl;
}
#endif
}
bool DRW_Header::getDouble( string key, double* varDouble )
bool DRW_Header::getDouble( std::string key, double* varDouble )
{
bool result = false;
std::map<std::string, DRW_Variant*>::iterator it;
......@@ -1243,7 +1269,7 @@ bool DRW_Header::getDouble( string key, double* varDouble )
}
bool DRW_Header::getInt( string key, int* varInt )
bool DRW_Header::getInt( std::string key, int* varInt )
{
bool result = false;
std::map<std::string, DRW_Variant*>::iterator it;
......@@ -1267,7 +1293,7 @@ bool DRW_Header::getInt( string key, int* varInt )
}
bool DRW_Header::getStr( string key, std::string* varStr )
bool DRW_Header::getStr( std::string key, std::string* varStr )
{
bool result = false;
std::map<std::string, DRW_Variant*>::iterator it;
......@@ -1291,7 +1317,7 @@ bool DRW_Header::getStr( string key, std::string* varStr )
}
bool DRW_Header::getCoord( string key, DRW_Coord* varCoord )
bool DRW_Header::getCoord( std::string key, DRW_Coord* varCoord )
{
bool result = false;
std::map<std::string, DRW_Variant*>::iterator it;
......
......@@ -22,8 +22,6 @@
class dxfReader;
class dxfWriter;
using std::string;
namespace DRW {
// ! Table entries type.
enum TTYPE {
......@@ -241,8 +239,8 @@ public:
int color24; /*!< 24-bit color, code 420 */
bool plotF; /*!< Plot flag, code 290 */
enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */
string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */
string handlePlotM; /*!< Hard-pointer ID/handle of materialstyle, code 347 */
std::string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */
std::string handlePlotM; /*!< Hard-pointer ID/handle of materialstyle, code 347 */
};
// ! Class to handle text style entries
......@@ -359,7 +357,7 @@ public:
void parseCode( int code, dxfReader* reader );
public:
string handle; /*!< entity identifier, code 5 */
std::string handle; /*!< entity identifier, code 5 */
UTF8STRING name; /*!< File name of image, code 1 */
int version; /*!< class version, code 90, 0=R14 version */
double u; /*!< image size in pixels U value, code 10 */
......@@ -369,7 +367,7 @@ public:
int loaded; /*!< image is loaded flag, code 280, 0=unloaded, 1=loaded */
int resolution; /*!< resolution units, code 281, 0=no, 2=centimeters, 5=inch */
std::map<string, string> reactors;
std::map<std::string, std::string> reactors;
};
......@@ -392,20 +390,20 @@ public:
void parseCode( int code, dxfReader* reader );
void write( dxfWriter* writer, DRW::Version ver );
void addComment( string c );
void addComment( std::string c );
string getComments() const { return comments; }
std::string getComments() const { return comments; }
private:
bool getDouble( string key, double* varDouble );
bool getInt( string key, int* varInt );
bool getStr( string key, string* varStr );
bool getCoord( string key, DRW_Coord* varStr );
bool getDouble( std::string key, double* varDouble );
bool getInt( std::string key, int* varInt );
bool getStr( std::string key, std::string* varStr );
bool getCoord( std::string key, DRW_Coord* varStr );
public:
std::map<string, DRW_Variant*> vars;
std::map<std::string, DRW_Variant*> vars;
private:
string comments;
string name;
std::string comments;
std::string name;
DRW_Variant* curr;
int version; // to use on read
};
......
This diff is collapsed.
......@@ -10,75 +10,89 @@ class DRW_TextCodec
public:
DRW_TextCodec();
~DRW_TextCodec();
std::string fromUtf8(std::string s);
std::string toUtf8(std::string s);
int getVersion(){return version;}
void setVersion(std::string *v);
void setVersion(int v){version = v;}
void setCodePage(std::string *c);
void setCodePage(std::string c){setCodePage(&c);}
std::string getCodePage(){return cp;}
std::string fromUtf8( std::string s );
std::string toUtf8( std::string s );
int getVersion() { return version; }
void setVersion( std::string* v );
void setVersion( int v ) { version = v; }
void setCodePage( std::string* c );
void setCodePage( std::string c ) { setCodePage( &c ); }
std::string getCodePage() { return cp; }
private:
std::string correctCodePage(const std::string& s);
std::string correctCodePage( const std::string& s );
private:
int version;
std::string cp;
DRW_Converter *conv;
DRW_Converter* conv;
};
class DRW_Converter
{
public:
DRW_Converter(const int *t, int l){table = t;
cpLenght = l;}
virtual ~DRW_Converter(){}
virtual std::string fromUtf8(std::string *s) {return *s;}
virtual std::string toUtf8(std::string *s);
std::string encodeText(std::string stmp);
std::string decodeText(int c);
std::string encodeNum(int c);
int decodeNum(std::string s, int *b);
const int *table;
DRW_Converter( const int* t, int l )
{
table = t;
cpLenght = l;
}
virtual ~DRW_Converter() {}
virtual std::string fromUtf8( std::string* s ) { return *s; }
virtual std::string toUtf8( std::string* s );
std::string encodeText( std::string stmp );
std::string decodeText( int c );
std::string encodeNum( int c );
int decodeNum( std::string s, int* b );
const int* table;
int cpLenght;
};
class DRW_ConvTable : public DRW_Converter {
class DRW_ConvTable : public DRW_Converter
{
public:
DRW_ConvTable(const int *t, int l):DRW_Converter(t, l) {}
virtual std::string fromUtf8(std::string *s);
virtual std::string toUtf8(std::string *s);
DRW_ConvTable( const int* t, int l ) : DRW_Converter( t, l ) {}
virtual std::string fromUtf8( std::string* s );
virtual std::string toUtf8( std::string* s );
};
class DRW_ConvDBCSTable : public DRW_Converter {
class DRW_ConvDBCSTable : public DRW_Converter
{
public:
DRW_ConvDBCSTable(const int *t, const int *lt, const int dt[][2], int l):DRW_Converter(t, l) {
DRW_ConvDBCSTable( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t,
l )
{
leadTable = lt;
doubleTable = dt;
}
virtual std::string fromUtf8(std::string *s);
virtual std::string toUtf8(std::string *s);
virtual std::string fromUtf8( std::string* s );
virtual std::string toUtf8( std::string* s );
private:
const int *leadTable;
const int* leadTable;
const int (*doubleTable)[2];
};
class DRW_Conv932Table : public DRW_Converter {
class DRW_Conv932Table : public DRW_Converter
{
public:
DRW_Conv932Table(const int *t, const int *lt, const int dt[][2], int l):DRW_Converter(t, l) {
DRW_Conv932Table( const int* t, const int* lt, const int dt[][2], int l ) : DRW_Converter( t,
l )
{
leadTable = lt;
doubleTable = dt;
}
virtual std::string fromUtf8(std::string *s);
virtual std::string toUtf8(std::string *s);
virtual std::string fromUtf8( std::string* s );
virtual std::string toUtf8( std::string* s );
private:
const int *leadTable;
const int* leadTable;
const int (*doubleTable)[2];
};
#endif // DRW_TEXTCODEC_H
This diff is collapsed.
......@@ -15,55 +15,61 @@
#include "drw_textcodec.h"
class dxfReader {
class dxfReader
{
public:
dxfReader(std::ifstream *stream){
dxfReader( std::ifstream* stream )
{
filestr = stream;
#ifdef DRW_DBG
count =0;
count = 0;
#endif
}
virtual ~dxfReader(){}
virtual bool readCode(int *code) = 0; //return true if sucesful (not EOF)
virtual bool readString(std::string *text) = 0;
virtual ~dxfReader() {}
virtual bool readCode( int* code ) = 0; // return true if sucesful (not EOF)
virtual bool readString( std::string* text ) = 0;
virtual bool readString() = 0;
bool readRec(int *code, bool skip);
bool readRec( int* code, bool skip );
virtual bool readInt() = 0;
virtual bool readInt32() = 0;
virtual bool readInt64() = 0;
virtual bool readDouble() = 0;
virtual bool readBool() = 0;
std::string getString() {return strData;}
int getHandleString();//Convert hex string to int
std::string toUtf8String(std::string t) {return decoder.toUtf8(t);}
std::string getUtf8String() {return decoder.toUtf8(strData);}
double getDouble() {return doubleData;}
int getInt32() {return intData;}
unsigned long long int getInt64() {return int64;}
bool getBool() { return (intData==0) ? false : true;}
int getVersion(){return decoder.getVersion();}
void setVersion(std::string *v){decoder.setVersion(v);}
void setCodePage(std::string *c){decoder.setCodePage(c);}
std::string getCodePage(){ return decoder.getCodePage();}
std::string getString() { return strData; }
int getHandleString(); // Convert hex string to int
std::string toUtf8String( std::string t ) { return decoder.toUtf8( t ); }
std::string getUtf8String() { return decoder.toUtf8( strData ); }
double getDouble() { return doubleData; }
int getInt32() { return intData; }
unsigned long long int getInt64() { return int64; }
bool getBool() { return (intData==0) ? false : true; }
int getVersion() { return decoder.getVersion(); }
void setVersion( std::string* v ) { decoder.setVersion( v ); }
void setCodePage( std::string* c ) { decoder.setCodePage( c ); }
std::string getCodePage() { return decoder.getCodePage(); }
#ifdef DRW_DBG
int count;//DBG
int count; // DBG
#endif
protected:
std::ifstream *filestr;
std::ifstream* filestr;
std::string strData;
double doubleData;
signed short intData; //16 bits integer
unsigned long long int int64; //64 bits integer
signed int intData; // 32 bits integer
unsigned long long int int64; // 64 bits integer
private:
DRW_TextCodec decoder;
};
class dxfReaderBinary : public dxfReader {
class dxfReaderBinary : public dxfReader
{
public:
dxfReaderBinary(std::ifstream *stream):dxfReader(stream){ }
dxfReaderBinary( std::ifstream* stream ) : dxfReader( stream ) { }
virtual ~dxfReaderBinary() {}
virtual bool readCode(int *code);
virtual bool readString(std::string *text);
virtual bool readCode( int* code );
virtual bool readString( std::string* text );
virtual bool readString();
virtual bool readInt();
virtual bool readInt32();
......@@ -72,12 +78,13 @@ public:
virtual bool readBool();
};
class dxfReaderAscii : public dxfReader {
class dxfReaderAscii : public dxfReader
{
public:
dxfReaderAscii(std::ifstream *stream):dxfReader(stream){ }
virtual ~dxfReaderAscii(){}
virtual bool readCode(int *code);
virtual bool readString(std::string *text);
dxfReaderAscii( std::ifstream* stream ) : dxfReader( stream ) { }
virtual ~dxfReaderAscii() {}
virtual bool readCode( int* code );
virtual bool readString( std::string* text );
virtual bool readString();
virtual bool readInt();
virtual bool readDouble();
......
This diff is collapsed.
......@@ -15,50 +15,55 @@
#include "drw_textcodec.h"
class dxfWriter {
class dxfWriter
{
public:
dxfWriter(std::ofstream *stream){filestr = stream; /*count =0;*/}
virtual ~dxfWriter(){}
virtual bool writeString(int code, std::string text) = 0;
bool writeUtf8String(int code, std::string text);
bool writeUtf8Caps(int code, std::string text);
std::string fromUtf8String(std::string t) {return encoder.fromUtf8(t);}
virtual bool writeInt16(int code, int data) = 0;
virtual bool writeInt32(int code, int data) = 0;
virtual bool writeInt64(int code, unsigned long long int data) = 0;
virtual bool writeDouble(int code, double data) = 0;
virtual bool writeBool(int code, bool data) = 0;
void setVersion(std::string *v){encoder.setVersion(v);}
void setCodePage(std::string *c){encoder.setCodePage(c);}
std::string getCodePage(){return encoder.getCodePage();}
dxfWriter( std::ofstream* stream ) { filestr = stream; /*count =0;*/ }
virtual ~dxfWriter() {}
virtual bool writeString( int code, std::string text ) = 0;
bool writeUtf8String( int code, std::string text );
bool writeUtf8Caps( int code, std::string text );
std::string fromUtf8String( std::string t ) { return encoder.fromUtf8( t ); }
virtual bool writeInt16( int code, int data ) = 0;
virtual bool writeInt32( int code, int data ) = 0;
virtual bool writeInt64( int code, unsigned long long int data ) = 0;
virtual bool writeDouble( int code, double data ) = 0;
virtual bool writeBool( int code, bool data ) = 0;
void setVersion( std::string* v ) { encoder.setVersion( v ); }
void setCodePage( std::string* c ) { encoder.setCodePage( c ); }
std::string getCodePage() { return encoder.getCodePage(); }
protected:
std::ofstream *filestr;
std::ofstream* filestr;
private:
DRW_TextCodec encoder;
};
class dxfWriterBinary : public dxfWriter {
class dxfWriterBinary : public dxfWriter
{
public:
dxfWriterBinary(std::ofstream *stream):dxfWriter(stream){ }
dxfWriterBinary( std::ofstream* stream ) : dxfWriter( stream ) { }
virtual ~dxfWriterBinary() {}
virtual bool writeString(int code, std::string text);
virtual bool writeInt16(int code, int data);
virtual bool writeInt32(int code, int data);
virtual bool writeInt64(int code, unsigned long long int data);
virtual bool writeDouble(int code, double data);
virtual bool writeBool(int code, bool data);
virtual bool writeString( int code, std::string text );
virtual bool writeInt16( int code, int data );
virtual bool writeInt32( int code, int data );
virtual bool writeInt64( int code, unsigned long long int data );
virtual bool writeDouble( int code, double data );
virtual bool writeBool( int code, bool data );
};
class dxfWriterAscii : public dxfWriter {
class dxfWriterAscii : public dxfWriter
{
public:
dxfWriterAscii(std::ofstream *stream):dxfWriter(stream){ }
virtual ~dxfWriterAscii(){}
virtual bool writeString(int code, std::string text);
virtual bool writeInt16(int code, int data);
virtual bool writeInt32(int code, int data);
virtual bool writeInt64(int code, unsigned long long int data);
virtual bool writeDouble(int code, double data);
virtual bool writeBool(int code, bool data);
dxfWriterAscii( std::ofstream* stream ) : dxfWriter( stream ) { }
virtual ~dxfWriterAscii() {}
virtual bool writeString( int code, std::string text );
virtual bool writeInt16( int code, int data );
virtual bool writeInt32( int code, int data );
virtual bool writeInt64( int code, unsigned long long int data );
virtual bool writeDouble( int code, double data );
virtual bool writeBool( int code, bool data );
};
#endif // DXFWRITER_H
......@@ -215,7 +215,7 @@ bool dxfRW::writeEntity( DRW_Entity* ent )
bool dxfRW::writeLineType( DRW_LType* ent )
{
string strname = ent->name;
std::string strname = ent->name;
transform( strname.begin(), strname.end(), strname.begin(), ::toupper );
......@@ -1322,7 +1322,12 @@ bool dxfRW::writeDimension( DRW_Dimension* ent )
writer->writeString( 0, "DIMENSION" );
writeEntity( ent );
writer->writeString( 100, "AcDbDimension" );
// writer->writeString(2, ent->name);
if( !ent->getName().empty() )
{
writer->writeString( 2, ent->getName() );
}
writer->writeDouble( 10, ent->getDefPoint().x );
writer->writeDouble( 20, ent->getDefPoint().y );
writer->writeDouble( 30, ent->getDefPoint().z );
......@@ -2129,8 +2134,13 @@ bool dxfRW::writeTables()
writer->writeInt16( 280, 1 );
writer->writeInt16( 281, 0 );
}
}
/* allways call writeBlockRecords to iface for prepare unnamed blocks */
iface->writeBlockRecords();
if( version > DRW::AC1009 )
{
writer->writeString( 0, "ENDTAB" );
}
......@@ -2312,7 +2322,7 @@ bool dxfRW::writeObjects()
for( unsigned int i = 0; i<imageDef.size(); i++ )
{
DRW_ImageDef* id = imageDef.at( i );
std::map<string, string>::iterator it;
std::map<std::string, std::string>::iterator it;
for( it = id->reactors.begin(); it != id->reactors.end(); it++ )
{
......@@ -2356,7 +2366,7 @@ bool dxfRW::writeObjects()
}
writer->writeString( 102, "{ACAD_REACTORS" );
std::map<string, string>::iterator it;
std::map<std::string, std::string>::iterator it;
for( it = id->reactors.begin(); it != id->reactors.end(); it++ )
{
......@@ -2392,7 +2402,7 @@ bool dxfRW::processDxf()
DBG( "dxfRW::processDxf() start processing dxf\n" );
int code;
bool more = true;
string sectionstr;
std::string sectionstr;
// section = secUnknown;
while( reader->readRec( &code, !binary ) )
......@@ -2469,7 +2479,7 @@ bool dxfRW::processHeader()
{
DBG( "dxfRW::processHeader\n" );
int code;
string sectionstr;
std::string sectionstr;
while( reader->readRec( &code, !binary ) )
{
......@@ -2500,7 +2510,7 @@ bool dxfRW::processTables()
{
DBG( "dxfRW::processTables\n" );
int code;
string sectionstr;
std::string sectionstr;
bool more = true;
while( reader->readRec( &code, !binary ) )
......@@ -2579,7 +2589,7 @@ bool dxfRW::processLType()
{
DBG( "dxfRW::processLType\n" );
int code;
string sectionstr;
std::string sectionstr;
bool reading = false;
DRW_LType ltype;
......@@ -2620,7 +2630,7 @@ bool dxfRW::processLayer()
{
DBG( "dxfRW::processLayer\n" );
int code;
string sectionstr;
std::string sectionstr;
bool reading = false;
DRW_Layer layer;
......@@ -2658,7 +2668,7 @@ bool dxfRW::processDimStyle()
{
DBG( "dxfRW::processDimStyle" );
int code;
string sectionstr;
std::string sectionstr;
bool reading = false;
DRW_Dimstyle dimSty;
......@@ -2696,7 +2706,7 @@ bool dxfRW::processTextStyle()
{
DBG( "dxfRW::processTextStyle" );
int code;
string sectionstr;
std::string sectionstr;
bool reading = false;
DRW_Textstyle TxtSty;
......@@ -2734,7 +2744,7 @@ bool dxfRW::processVports()
{
DBG( "dxfRW::processVports" );
int code;
string sectionstr;
std::string sectionstr;
bool reading = false;
DRW_Vport vp;
......@@ -2774,7 +2784,7 @@ bool dxfRW::processBlocks()
{
DBG( "dxfRW::processBlocks\n" );
int code;
string sectionstr;
std::string sectionstr;
while( reader->readRec( &code, !binary ) )
{
......
......@@ -127,7 +127,7 @@ private:
DRW_Interface* iface;
DRW_Header header;
// int section;
string nextentity;
std::string nextentity;
int entCount;
bool wlayer0;
bool dimstyleStd;
......
......@@ -27,16 +27,25 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <appl_wxstruct.h>
#include <dxf2brd_items.h>
#include <wxPcbStruct.h>
#include <convert_from_iu.h>
#include <dialog_dxf_import_base.h>
#include <class_pcb_layer_box_selector.h>
// Keys to store setup in config
#define DXF_IMPORT_LAYER_OPTION_KEY wxT("DxfImportBrdLayer")
#define DXF_IMPORT_COORD_ORIGIN_KEY wxT("DxfImportCoordOrigin")
#define DXF_IMPORT_LAST_FILE_KEY wxT("DxfImportLastFile")
class DIALOG_DXF_IMPORT : public DIALOG_DXF_IMPORT_BASE
{
private:
PCB_EDIT_FRAME * m_parent;
wxConfig* m_config; // Current config
static wxString m_dxfFilename;
static int m_offsetSelection;
static LAYER_NUM m_layer;
......@@ -64,6 +73,15 @@ DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_EDIT_FRAME* aParent )
: DIALOG_DXF_IMPORT_BASE( aParent )
{
m_parent = aParent;
m_config = wxGetApp().GetSettings();
if( m_config )
{
m_layer = m_config->Read( DXF_IMPORT_LAYER_OPTION_KEY, (long)DRAW_N );
m_offsetSelection = m_config->Read( DXF_IMPORT_COORD_ORIGIN_KEY, 3 );
m_dxfFilename = m_config->Read( DXF_IMPORT_LAST_FILE_KEY, wxEmptyString );
}
m_textCtrlFileName->SetValue( m_dxfFilename );
m_rbOffsetOption->SetSelection( m_offsetSelection );
......@@ -72,6 +90,7 @@ DIALOG_DXF_IMPORT::DIALOG_DXF_IMPORT( PCB_EDIT_FRAME* aParent )
m_SelLayerBox->SetLayerMask( ALL_CU_LAYERS ); // Do not use copper layers
m_SelLayerBox->SetBoardFrame( m_parent );
m_SelLayerBox->Resync();
if( m_SelLayerBox->SetLayerSelection( m_layer ) < 0 )
{
m_layer = DRAW_N;
......@@ -88,14 +107,28 @@ DIALOG_DXF_IMPORT::~DIALOG_DXF_IMPORT()
{
m_offsetSelection = m_rbOffsetOption->GetSelection();
m_layer = m_SelLayerBox->GetLayerSelection();
if( m_config )
{
m_config->Write( DXF_IMPORT_LAYER_OPTION_KEY, (long)m_layer );
m_config->Write( DXF_IMPORT_COORD_ORIGIN_KEY, m_offsetSelection );
m_config->Write( DXF_IMPORT_LAST_FILE_KEY, m_dxfFilename );
}
}
void DIALOG_DXF_IMPORT::OnBrowseDxfFiles( wxCommandEvent& event )
{
wxString path;
if( !m_dxfFilename.IsEmpty() )
{
wxFileName fn( m_dxfFilename );
path = fn.GetPath();
}
wxFileDialog dlg( m_parent,
wxT( "Open File" ),
wxEmptyString, wxEmptyString,
path, m_dxfFilename,
wxT( "dxf Files (*.dxf)|*.dxf|*.DXF" ),
wxFD_OPEN|wxFD_FILE_MUST_EXIST );
dlg.ShowModal();
......
This diff is collapsed.
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