[dia] dxf: changing scales during import to the reciprocal
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] dxf: changing scales during import to the reciprocal
- Date: Sun, 19 Jun 2011 18:22:43 +0000 (UTC)
commit 15deb6b1cfa5b190e3f3637d5b8013ba46a9e8ca
Author: Hans Breuer <hans breuer org>
Date: Sun Jun 19 19:33:25 2011 +0200
dxf: changing scales during import to the reciprocal
AFAICT this is all not documented by the DXF specification,
but with the original values some files I've tested are coming
out much too huge.
plug-ins/dxf/dxf-import.c | 37 +++++++++++++++++++++++++++++++++++--
1 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/dxf/dxf-import.c b/plug-ins/dxf/dxf-import.c
index 0b10d26..f8ab2b1 100644
--- a/plug-ins/dxf/dxf-import.c
+++ b/plug-ins/dxf/dxf-import.c
@@ -56,7 +56,7 @@ Point extent_min, extent_max;
Point limit_min, limit_max;
/* maximum line length */
-#define DXF_LINE_LENGTH 256
+#define DXF_LINE_LENGTH 257
typedef struct _DxfLayerData
{
@@ -985,6 +985,8 @@ read_entity_scale_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
{
case 40:
coord_scale = g_ascii_strtod(data->value, NULL);
+ if (coord_scale > 0.0)
+ coord_scale = 1.0 / coord_scale;
g_message("Scale: %f", coord_scale );
break;
@@ -994,6 +996,30 @@ read_entity_scale_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
}
+static void
+read_entitiy_lengthunit_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
+{
+ real e; /* undocumented ... */
+
+ if(read_dxf_codes(filedxf, data) == FALSE)
+ return;
+
+ switch(data->code)
+ {
+ case 70:
+ /* 1 = Scientific; 2 = Decimal; 3 = Engineering;
+ * 4 = Architectural; 5 = Fractional; 6 = Windows desktop
+ */
+ e = atoi(data->value);
+ g_message("LengthUnit: %f", coord_scale );
+ break;
+
+ default:
+ break;
+ }
+
+}
+
/* reads a scale entity from the dxf file */
static void
read_entity_measurement_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
@@ -1029,6 +1055,8 @@ read_entity_textsize_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
{
case 40:
text_scale = g_ascii_strtod(data->value, NULL);
+ if (text_scale > 0.0)
+ text_scale = 1.0 / text_scale;
/*printf( "Text Size: %f\n", text_scale );*/
break;
default:
@@ -1047,6 +1075,9 @@ read_section_header_dxf(FILE *filedxf, DxfData *data, DiagramData *dia)
do {
if((data->code == 9) && (strcmp(data->value, "$DIMSCALE") == 0)) {
read_entity_scale_dxf(filedxf, data, dia);
+ } else if((data->code == 9) && (strcmp(data->value, "DIMLUNIT") == 0)) {
+ /* nothing documented */
+ read_entitiy_lengthunit_dxf(filedxf, data, dia);
} else if((data->code == 9) && (strcmp(data->value, "$TEXTSIZE") == 0)) {
read_entity_textsize_dxf(filedxf, data, dia);
} else if((data->code == 9) && (strcmp(data->value, "$MEASUREMENT") == 0)) {
@@ -1297,7 +1328,9 @@ import_dxf(const gchar *filename, DiagramData *dia, void* user_data)
}
/* reads a code/value pair from the DXF file */
-gboolean read_dxf_codes(FILE *filedxf, DxfData *data){
+static gboolean
+read_dxf_codes(FILE *filedxf, DxfData *data)
+{
int i;
char *c;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]