model.cpp

Sat, 16 Mar 2013 13:08:24 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 16 Mar 2013 13:08:24 +0200
changeset 18
a6732098fed8
parent 7
098e3c4949c6
child 19
6c5977e43e73
permissions
-rw-r--r--

Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code

#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#include "io.h"
#include "gui.h"
#include "draw.h"

// Clear everything from the model
void closeModel () {
	// Remove all loaded files and the objects they contain
	for (ushort i = 0; i < g_LoadedFiles.size(); i++) {
		OpenFile* f = g_LoadedFiles[i];
		
		for (ushort j = 0; j < f->objects.size(); ++j)
			delete f->objects[j];
		
		delete f;
	}
	
	// Clear the array
	g_LoadedFiles.clear();
	g_CurrentFile = NULL;
	
	g_qWindow->R->hardRefresh();
}

void newModel () {
	// Create a new anonymous file and set it to our current
	if (g_LoadedFiles.size())
		closeModel (); // Close any open file first, though
	
	OpenFile* f = new OpenFile;
	f->zFileName = "";
	g_LoadedFiles.push_back (f);
	g_CurrentFile = f;
	
	g_qWindow->R->hardRefresh();
}

mercurial