X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffileio.cpp;h=1b11902e37b672f1f6a72bd6dc443894acce5efd;hb=742d2aa9bb46bce4f690474fa22f5980e175e55e;hp=ace5bfa247713a3adc4aabee61f0dc3871a4c0aa;hpb=790c1a6d97f73f7457c7fad7e82fa29e5b6accd5;p=architektonas diff --git a/src/fileio.cpp b/src/fileio.cpp index ace5bfa..1b11902 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -61,7 +61,7 @@ Connect() function. Or, instead of a point, a parameter value? Doing that, with the Line and a parameter "t", if t == 0 we have endpoint 1. if t == 1, then we have endpoint 2. With a Circle, the parameter is a number -between 0 and 1 (scaled to 0 to 2π). With an Arc, the parameter goes from 0 to +between 0 and 1 (scaled to 0 to tau). With an Arc, the parameter goes from 0 to 1, 0 being enpoint 1 and 1 being endpoint 2. How does this work for moving objects that are connected? Again, with the Line @@ -115,11 +115,9 @@ OTHER CONSIDERATIONS: // OTFDimension, OTFPolygon, OTFText, OTFImage, OTFBlock, OTFEndOfFile }; enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile }; - // Instantiate class variables /*static*/ int FileIO::objectFileType = OTFObject; - /*static*/ bool FileIO::SaveAtnsFile(FILE * file, Container * c) { /* Approach: loop through the container, doing a depth-first traversal. Any @@ -140,7 +138,6 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile }; return true; } - /*static*/ bool FileIO::LoadAtnsFile(FILE * file, Container * drawing) { float version; @@ -163,7 +160,6 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile }; return false; } - /*static*/ void FileIO::ResetLayerVectors(void) { // Set up layer vectors @@ -174,7 +170,6 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile }; Global::activeLayer = 0; } - /*static*/ bool FileIO::LoadVersion1_0(FILE * file, Container * drawing) { // Approach: read each object in the file, one by one. If the object is a @@ -222,7 +217,6 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile }; return false; } - /*static*/ bool FileIO::LoadVersion1_1(FILE * file, Container * drawing) { // Approach: read each object in the file, one by one. If the object is a @@ -276,7 +270,6 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile }; return false; } - /*static*/ bool FileIO::LoadVersion1_2(FILE * file, Container * drawing) { int hidden, locked; @@ -304,7 +297,7 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile }; while (!feof(file)) { // Reconstruct the object (extended format!) - Object * obj = GetObjectFromFile(file, true); + Object * obj = GetObjectFromFile(file, true, true); // objectFileType is set in GetObjectFromFile()... if (objectFileType == OTFObject) @@ -345,8 +338,7 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFObject, OTFEndOfFile }; return false; } - -/*static*/ Object * FileIO::GetObjectFromFile(FILE * file, bool extended/*= false*/) +/*static*/ Object * FileIO::GetObjectFromFile(FILE * file, bool extended/*= false*/, bool ext2/*= false*/) { char buffer[256]; char textBuffer[65536]; @@ -415,8 +407,13 @@ if (errno) { Point p1, p2; DimensionType type; + double offset = 0; fscanf(file, "(%lf,%lf) (%lf,%lf) %i", &p1.x, &p1.y, &p2.x, &p2.y, (int *)&type); - obj = (Object *)new Dimension(p1, p2, type); + + if (ext2) + fscanf(file, " %lf", &offset); + + obj = (Object *)new Dimension(p1, p2, type, offset); } else if (strcmp(buffer, "CONTAINER") == 0) { @@ -440,14 +437,13 @@ if (errno) if (extended && (obj->type != OTContainer)) { - fscanf(file, " (%i, %f, %i)", &obj->color, &obj->thickness, &obj->style); + fscanf(file, " (%i, %f, %i)\n", &obj->color, &obj->thickness, &obj->style); } } return obj; } - /*static*/ bool FileIO::WriteObjectToFile(FILE * file, Object * obj) { // Sanity check @@ -471,7 +467,7 @@ if (errno) 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", obj->layer, obj->p[0].x, obj->p[0].y, obj->p[1].x, obj->p[1].y, ((Dimension *)obj)->subtype); + 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: break; @@ -504,4 +500,3 @@ if (errno) return true; } -