main.cpp

Fri, 15 Mar 2013 21:53:50 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 15 Mar 2013 21:53:50 +0200
changeset 7
098e3c4949c6
parent 4
758302636564
child 13
3955ff2a7d72
permissions
-rw-r--r--

Set window title dynamically based on filename

#include <QApplication>
#include "gui.h"
#include "io.h"
#include "bbox.h"

vector<OpenFile*> g_LoadedFiles;
OpenFile* g_CurrentFile = NULL;
LDForgeWindow* g_qWindow = NULL; 
bbox g_BBox;

int main (int argc, char** argv) {
	if (g_CurrentFile) {
		printf ("bbox: (%.3f, %.3f, %.3f), (%.3f, %.3f, %.3f)\n",
			FVERTEX (g_BBox.v0), FVERTEX (g_BBox.v1));
		printf ("%u objects\n", g_CurrentFile->objects.size());
	}
	
	QApplication app (argc, argv);
	LDForgeWindow* win = new LDForgeWindow;
	g_qWindow = win;
	win->show ();
	return app.exec ();
}

vertex vertex::midpoint (vertex& other) {
	vertex mid;
	mid.x = (x + other.x);
	mid.y = (y + other.y);
	mid.z = (z + other.z);
	return mid;
}

static str getCoordinateRep (double fCoord) {
	str zRep = str::mkfmt ("%.3f", fCoord);
	
	// Remove trailing zeroes
	while (zRep[~zRep - 1] == '0')
		zRep -= 1;
	
	// If there was only zeroes in the decimal place, remove
	// the decimal point now.
	if (zRep[~zRep - 1] == '.')
		zRep -= 1;
	
	return zRep;
}

str vertex::getStringRep () {
	return str::mkfmt ("(%s, %s, %s)",
		getCoordinateRep (x).chars(),
		getCoordinateRep (y).chars(),
		getCoordinateRep (z).chars());
}

mercurial