improve opening, don't auto-load 55966.dat (:P)

Fri, 15 Mar 2013 20:52:34 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 15 Mar 2013 20:52:34 +0200
changeset 4
758302636564
parent 3
2b78cf8634c3
child 5
727e02d6b87a

improve opening, don't auto-load 55966.dat (:P)

gui.cpp file | annotate | diff | comparison | revisions
io.cpp file | annotate | diff | comparison | revisions
io.h file | annotate | diff | comparison | revisions
main.cpp file | annotate | diff | comparison | revisions
--- a/gui.cpp	Fri Mar 15 20:39:29 2013 +0200
+++ b/gui.cpp	Fri Mar 15 20:52:34 2013 +0200
@@ -166,13 +166,13 @@
 }
 
 void LDForgeWindow::slot_open () {
-	str name = QFileDialog::getOpenFileName (this, "Open file",
+	str name = QFileDialog::getOpenFileName (this, "Open File",
 		"", "LDraw files (*.dat *.ldr)").toStdString().c_str();
 	
 	if (g_LoadedFiles.size())
 		closeModel ();
 	
-	IO_ParseLDFile (name);
+	IO_OpenLDrawFile (name);
 }
 
 void LDForgeWindow::slot_save () {
--- a/io.cpp	Fri Mar 15 20:39:29 2013 +0200
+++ b/io.cpp	Fri Mar 15 20:52:34 2013 +0200
@@ -4,6 +4,8 @@
 #include "io.h"
 #include "ldtypes.h"
 #include "misc.h"
+#include "gui.h"
+#include "bbox.h"
 
 // =============================================================================
 // IO_FindLoadedFile (str)
@@ -23,11 +25,11 @@
 }
 
 // =============================================================================
-// IO_ParseLDFile (str)
+// IO_OpenLDrawFile (str)
 //
 // Opens the given file and parses the LDraw code within.
 // =============================================================================
-OpenFile* IO_ParseLDFile (str path) {
+OpenFile* IO_OpenLDrawFile (str path) {
 	FILE* fp = fopen (path.chars (), "r");
 	
 	if (!fp) {
@@ -58,7 +60,15 @@
 		load->objects.push_back (ParseLine (lines[i]));
 	
 	g_LoadedFiles.push_back (load);
-	return g_LoadedFiles[g_LoadedFiles.size() - 1];
+	g_CurrentFile = g_LoadedFiles[g_LoadedFiles.size() - 1];
+	
+	// Recalculate the bounding box
+	g_BBox.calculate();
+	
+	// Rebuild the object tree view now.
+	g_qWindow->buildObjList ();
+	
+	return g_CurrentFile;
 }
 
 // =============================================================================
--- a/io.h	Fri Mar 15 20:39:29 2013 +0200
+++ b/io.h	Fri Mar 15 20:52:34 2013 +0200
@@ -7,7 +7,7 @@
 
 // PROTOTYPES
 OpenFile* IO_FindLoadedFile (str name);
-OpenFile* IO_ParseLDFile (str path);
+OpenFile* IO_OpenLDrawFile (str path);
 LDObject* ParseLine (str zLine);
 
 extern vector<OpenFile*> g_LoadedFiles;
--- a/main.cpp	Fri Mar 15 20:39:29 2013 +0200
+++ b/main.cpp	Fri Mar 15 20:52:34 2013 +0200
@@ -9,9 +9,6 @@
 bbox g_BBox;
 
 int main (int argc, char** argv) {
-	g_CurrentFile = IO_ParseLDFile ("55966.dat");
-	g_BBox.calculate();
-	
 	if (g_CurrentFile) {
 		printf ("bbox: (%.3f, %.3f, %.3f), (%.3f, %.3f, %.3f)\n",
 			FVERTEX (g_BBox.v0), FVERTEX (g_BBox.v1));
@@ -21,7 +18,6 @@
 	QApplication app (argc, argv);
 	LDForgeWindow* win = new LDForgeWindow;
 	g_qWindow = win;
-	g_qWindow->buildObjList ();
 	win->show ();
 	return app.exec ();
 }

mercurial