]> Shamusworld >> Repos - architektonas/blobdiff - src/fileio.cpp
Added base units & display style to drawing.
[architektonas] / src / fileio.cpp
index 1b11902e37b672f1f6a72bd6dc443894acce5efd..3ce447040014fe9ea7e53bb5d4be90bda16f0521 100644 (file)
@@ -108,11 +108,8 @@ OTHER CONSIDERATIONS:
   - Need to figure out how to store the Layer list (should layer list be optional?)
   - Need to figure out how to store the Block list and blocks
 
-
 */
 
-//enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFLine, OTFCircle, OTFArc,
-//     OTFDimension, OTFPolygon, OTFText, OTFImage, OTFBlock, OTFEndOfFile };
 enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile };
 
 // Instantiate class variables
@@ -127,6 +124,12 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile };
           Container, otherwise it enumerates all objects within itself. */
 
        fprintf(file, "ARCHITEKTONAS DRAWING V1.2\n");
+       fprintf(file, "PROPERTIES 4\n");
+       fprintf(file, "BASE_UNIT %i\n", c->baseUnit);
+       fprintf(file, "UNIT_STYLE %i\n", c->unitStyle);
+       fprintf(file, "DEC_PREC %i\n", c->decimalPrecision);
+       fprintf(file, "FRAC_PREC %i\n", c->fractionalPrecision);
+
        fprintf(file, "LAYERS %i\n", Global::numLayers);
 
        for(int i=0; i<Global::numLayers; i++)
@@ -156,7 +159,6 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile };
        else if (version == 1.2f)
                return LoadVersion1_2(file, drawing);
 
-//printf("LoadAtnsFile: Could not locate version! (version=%f)\n", version);
        return false;
 }
 
@@ -272,10 +274,21 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile };
 
 /*static*/ bool FileIO::LoadVersion1_2(FILE * file, Container * drawing)
 {
-       int hidden, locked;
+       int hidden, locked, props = 0;
        char textBuffer[65536];
 
-       // Load layer information first
+       // Load drawing properties, if any, first
+       fscanf(file, "PROPERTIES %i\n", &props);
+
+       if (props == 4)
+       {
+               fscanf(file, "BASE_UNIT %i\n", &(drawing->baseUnit));
+               fscanf(file, "UNIT_STYLE %i\n", &(drawing->unitStyle));
+               fscanf(file, "DEC_PREC %i\n", &(drawing->decimalPrecision));
+               fscanf(file, "FRAC_PREC %i\n", &(drawing->fractionalPrecision));
+       }
+
+       // Load layer information next
        fscanf(file, "LAYERS %i\n", &Global::numLayers);
 
        for(int i=0; i<Global::numLayers; i++)
@@ -466,7 +479,6 @@ if (errno)
        case OTPolygon:
                break;
        case OTDimension:
-//             fprintf(file, "DIMENSION %i (%lf,%lf) (%lf,%lf) %i\n", layer, position.x, position.y, endpoint.x, endpoint.y, dimensionType);
                fprintf(file, "DIMENSION %i (%lf,%lf) (%lf,%lf) %i %lf", obj->layer, obj->p[0].x, obj->p[0].y, obj->p[1].x, obj->p[1].y, ((Dimension *)obj)->subtype, ((Dimension *)obj)->offset);
                break;
        case OTSpline: