X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffileio.cpp;h=503ccc109322dcd41f68b6cc629ad38abc663484;hb=ea7712f342020baf61cf33ba98b12140da6aecf7;hp=b64e5bd200fa05ac1223dd337133abe522c19896;hpb=ba6723b86d8dd67ebc7b11b245de3e7ff64f06b1;p=architektonas diff --git a/src/fileio.cpp b/src/fileio.cpp index b64e5bd..503ccc1 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -15,14 +15,11 @@ #include "fileio.h" //#include +#include #include #include #include -#include "arc.h" -#include "circle.h" -#include "container.h" -#include "dimension.h" -#include "line.h" +#include "structs.h" /* How to handle connected objects @@ -101,10 +98,18 @@ perpendicular, or an arbitrary angle. How to encode that information? It's not intrinsic to either the Line or the Circle, but is a function of the relationship between them by virtue of their connection. + +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, OTFLine, OTFCircle, OTFArc, + OTFDimension, OTFPolygon, OTFText, OTFImage, OTFBlock, OTFEndOfFile }; /*static*/ bool FileIO::SaveAtnsFile(FILE * file, Container * object) @@ -116,7 +121,7 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFLine, OTFCircle, OTFArc, enumerates all objects within itself. */ fprintf(file, "ARCHITEKTONAS DRAWING V1.0\n"); -#if 1 +#if 0 object->Enumerate(file); fprintf(file, "END\n"); return true; @@ -140,7 +145,7 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFLine, OTFCircle, OTFArc, add objects to it until an "endContainer" marker is found. This will require a stack to maintain the current Container. */ -#if 1 +#if 0 std::vector containerStack; Container * currentTopContainer = drawing;//new Container(Vector(0, 0)); Object * object; @@ -159,7 +164,7 @@ enum ObjectTypeFile { OTFContainer, OTFContainerEnd, OTFLine, OTFCircle, OTFArc, if (objectType == OTFEndOfFile) { -printf("Load: container size = %li\n", drawing->objects.size()); +//printf("Load: container size = %li\n", drawing->objects.size()); return true; } else if (objectType == OTFContainer) @@ -177,7 +182,7 @@ printf("Load: container size = %li\n", drawing->objects.size()); else { currentTopContainer->Add(object); -printf("Load: Adding object. Container size = %li (%li)\n", drawing->objects.size(), currentTopContainer->objects.size()); +//printf("Load: Adding object. Container size = %li (%li)\n", drawing->objects.size(), currentTopContainer->objects.size()); } } @@ -190,10 +195,40 @@ printf("Load: Adding object. Container size = %li (%li)\n", drawing->objects.siz /*static*/ bool FileIO::GetObjectFromFile(FILE * file, Object * parent, Object ** object, int * objectType) { +#if 0 char buffer[256]; - fscanf(file, "%s ", buffer); + int foundLayer = 0; + int num = fscanf(file, "%s", buffer); bool recognized = false; -//printf("Load: buffer = \"%s\"\n", buffer); + *object = NULL; +//printf("FileIO: fscanf returned %i, buffer = \"%s\"\n", num, buffer); + +// The following fugliness is for troubleshooting. Can remove later. + if ((strcmp(buffer, "END") != 0) && (strcmp(buffer, "ENDCONTAINER") != 0)) +{ +errno = 0; + num = fscanf(file, " %i ", &foundLayer); +//printf("FileIO: fscanf returned %i, foundLayer = %i\n", num, foundLayer); +if (errno) +{ + if (errno == EAGAIN) + printf("EAGAIN\n"); + else if (errno == EBADF) + printf("EBADF\n"); + else if (errno == EILSEQ) + printf("EILSEQ\n"); + else if (errno == EINTR) + printf("EINTR\n"); + else if (errno == EINVAL) + printf("EINVAL\n"); + else if (errno == ENOMEM) + printf("ENOMEM\n"); + else if (errno == ERANGE) + printf("ERANGE\n"); + else + printf("errno = %i\n", errno); +} +} if (strcmp(buffer, "LINE") == 0) { @@ -248,6 +283,12 @@ printf("Load: Adding object. Container size = %li (%li)\n", drawing->objects.siz *objectType = OTFEndOfFile; } + if (*object) + (*object)->layer = foundLayer; + return recognized; +#else + return false; +#endif }