Container, otherwise it enumerates all objects within itself. */
fprintf(file, "ARCHITEKTONAS DRAWING V1.1\n");
-#if 0
- object->Enumerate(file);
-#else
WriteObjectToFile(file, (Object *)c);
-#endif
fprintf(file, "END\n");
return true;
}
fscanf(file, "ARCHITEKTONAS DRAWING V%f", &version);
-//printf("Load: version = %f\n", version);
-// if (version != 1.0)
-// return false;
-
- if (version == 1.0)
+ if (version == 1.0f)
return LoadVersion1_0(file, drawing);
- else if (version == 1.1)
+ else if (version == 1.1f)
return LoadVersion1_1(file, drawing);
+//printf("LoadAtnsFile: Could not locate version! (version=%f)\n", version);
return false;
- /* Approach: read each object in the file, one by one. If the object is a
- Container, add objects to it until an "endContainer" marker is found.
- This will require a stack to maintain the current Container. */
-
-#if 0
- std::vector<Container *> containerStack;
- Container * currentTopContainer = drawing;//new Container(Vector(0, 0));
- Object * object;
-// ObjectType objectType;
- int objectType;
-
- while (!feof(file))
- {
- if (FileIO::GetObjectFromFile(file, currentTopContainer, &object, &objectType) == false)
- return false;
-
- // object->type down below can be replaced with objType.
- // Above could be: bool FileIO::GetObjectFromFile(FILE *, Object *,
- // ObjectType *); where the return value tells if it's a valid object,
- // Object * returns the reconstructed object and ObjectType * returns
- // the object type.
-
- if (objectType == OTFEndOfFile)
- {
-//printf("Load: container size = %li\n", drawing->objects.size());
- return true;
- }
- else if (objectType == OTFContainer)
- {
- containerStack.push_back(currentTopContainer);
- currentTopContainer = new Container(Vector(0, 0), currentTopContainer);
- }
- else if (objectType == OTFContainerEnd)
- {
- Container * containerToAdd = currentTopContainer;
- currentTopContainer = containerStack.back();
- containerStack.pop_back();
- currentTopContainer->Add(containerToAdd);
- }
- else
- {
- currentTopContainer->Add(object);
-//printf("Load: Adding object. Container size = %li (%li)\n", drawing->objects.size(), currentTopContainer->objects.size());
- }
- }
-
- return false;
-#else
- return false;
-#endif
}
/*static*/ Object * FileIO::GetObjectFromFile(FILE * file, bool extended/*= false*/)
{
char buffer[256];
+ char textBuffer[65536];
int foundLayer = 0;
/*int num =*/ fscanf(file, "%s", buffer);
Object * obj = NULL;
fscanf(file, "(%lf,%lf) %lf, %lf, %lf", &p.x, &p.y, &r, &a1, &a2);
obj = (Object *)new Arc(p, r, a1, a2);
}
+ else if (strcmp(buffer, "TEXT") == 0)
+ {
+ Point p;
+ fscanf(file, "(%lf,%lf) \"%[^\"]\"", &p.x, &p.y, textBuffer);
+ obj = (Object *)new Text(p, textBuffer);
+ }
else if (strcmp(buffer, "DIMENSION") == 0)
{
Point p1, p2;
{
objectFileType = OTFEndOfFile;
}
+ else
+ printf("Unknown object type '%s'...\n", buffer);
if (obj != NULL)
{