Reformatting..

Sat, 13 Jul 2013 17:35:38 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 13 Jul 2013 17:35:38 +0300
changeset 376
4a89dd47535f
parent 375
54c90b15d35c
child 377
271d1da66b7e

Reformatting..

src/file.h file | annotate | diff | comparison | revisions
src/gui.cpp file | annotate | diff | comparison | revisions
src/gui_actions.cpp file | annotate | diff | comparison | revisions
src/gui_editactions.cpp file | annotate | diff | comparison | revisions
src/history.cpp file | annotate | diff | comparison | revisions
src/ldtypes.cpp file | annotate | diff | comparison | revisions
src/ldtypes.h file | annotate | diff | comparison | revisions
--- a/src/file.h	Wed Jul 10 02:58:59 2013 +0300
+++ b/src/file.h	Sat Jul 13 17:35:38 2013 +0300
@@ -1,17 +1,17 @@
 /*
  *  LDForge: LDraw parts authoring CAD
  *  Copyright (C) 2013 Santeri Piippo
- *  
+ *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@ -28,13 +28,13 @@
 class OpenProgressDialog;
 
 namespace LDPaths {
-	void initPaths ();
+	void initPaths();
 	bool tryConfigure (str path);
 	
-	str ldconfig ();
-	str prims ();
-	str parts ();
-	str getError ();
+	str ldconfig();
+	str prims();
+	str parts();
+	str getError();
 }
 
 // =============================================================================
@@ -42,7 +42,7 @@
 //
 // The LDOpenFile class stores a file opened in LDForge either as a editable file
 // for the user or for subfile caching. Its methods handle file input and output.
-// 
+//
 // A file is implicit when they are opened automatically for caching purposes
 // and are hidden from the user. User-opened files are explicit (not implicit).
 // =============================================================================
@@ -59,14 +59,14 @@
 	typedef vector<LDObject*>::it it;
 	typedef vector<LDObject*>::c_it c_it;
 	
-	LDOpenFile ();
-	~LDOpenFile ();
+	LDOpenFile();
+	~LDOpenFile();
 	
 	// Saves this file to disk.
 	bool save (str zPath = "");
 	
 	// Perform safety checks. Do this before closing any files!
-	bool safeToClose ();
+	bool safeToClose();
 	
 	// Adds an object to this file at the end of the file.
 	ulong addObject (LDObject* obj);
@@ -75,58 +75,90 @@
 	void forgetObject (LDObject* obj);
 	
 	LDObject* object (ulong pos) const;
-	LDObject* obj (ulong pos) const { return object (pos); }
+	LDObject* obj (ulong pos) const {
+		return object (pos);
+	}
 	
 	void insertObj (const ulong pos, LDObject* obj);
-	ulong numObjs () const { return m_objs.size (); }
+	ulong numObjs() const {
+		return m_objs.size();
+	}
 	void setObject (ulong idx, LDObject* obj);
-	
+
 	LDOpenFile& operator<< (LDObject* obj) {
 		addObject (obj);
 		return *this;
 	}
 	
-	LDOpenFile& operator<<( vector<LDObject*> objs );
+	LDOpenFile& operator<< (vector<LDObject*> objs);
+	
+	it begin() {
+		return PROP_NAME (objs).begin();
+	}
+	
+	c_it begin() const {
+		return PROP_NAME (objs).begin();
+	}
 	
-	it begin () { return PROP_NAME( objs ).begin(); }
-	c_it begin () const { return PROP_NAME( objs ).begin(); }
-	it end () { return PROP_NAME( objs ).end(); }
-	c_it end () const { return PROP_NAME( objs ).end(); }
+	it end() {
+		return PROP_NAME (objs).end();
+	}
+	
+	c_it end() const {
+		return PROP_NAME (objs).end();
+	}
+	
+	static void closeUnused();
 	
-	static void closeUnused ();
+	void openHistory() {
+		m_history.open();
+	}
+	
+	void closeHistory() {
+		m_history.close();
+	}
+	
+	void undo() {
+		m_history.undo();
+	}
 	
-	void openHistory() { m_history.open (); }
-	void closeHistory() { m_history.close (); }
-	void undo() { m_history.undo (); }
-	void redo() { m_history.redo (); }
-	void clearHistory() { m_history.clear (); }
-	void addToHistory( AbstractHistoryEntry* entry ) { m_history << entry; }
+	void redo() {
+		m_history.redo();
+	}
+	
+	void clearHistory() {
+		m_history.clear();
+	}
+	
+	void addToHistory (AbstractHistoryEntry* entry) {
+		m_history << entry;
+	}
 };
 
 // Close all current loaded files and start off blank.
 void newFile();
 
 // Opens the given file as the main file. Everything is closed first.
-void openMainFile( str path );
+void openMainFile (str path);
 
 // Finds an OpenFile by name or null if not open
-LDOpenFile* findLoadedFile( str name );
+LDOpenFile* findLoadedFile (str name);
 
 // Opens the given file and parses the LDraw code within. Returns a pointer
 // to the opened file or null on error.
-LDOpenFile* openDATFile( str path, bool search );
+LDOpenFile* openDATFile (str path, bool search);
 
 // Opens the given file and returns a pointer to it, potentially looking in /parts and /p
-File* openLDrawFile( str relpath, bool subdirs );
+File* openLDrawFile (str relpath, bool subdirs);
 
 // Close all open files, whether user-opened or subfile caches.
 void closeAll();
 
 // Parses a string line containing an LDraw object and returns the object parsed.
-LDObject* parseLine( str line );
+LDObject* parseLine (str line);
 
 // Retrieves the pointer to - or loads - the given subfile.
-LDOpenFile* getFile( str filename );
+LDOpenFile* getFile (str filename);
 
 // Re-caches all subfiles.
 void reloadAllSubfiles();
@@ -134,30 +166,31 @@
 // Is it safe to close all files?
 bool safeToCloseAll();
 
-vector<LDObject*> loadFileContents( File* f, ulong* numWarnings, bool* ok = null );
+vector<LDObject*> loadFileContents (File* f, ulong* numWarnings, bool* ok = null);
 
 extern vector<LDOpenFile*> g_loadedFiles;
 
-str basename( str path );
-str dirname( str path );
+void addRecentFile (str path);
+str basename (str path);
+str dirname (str path);
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 // FileLoader
-// 
+//
 // Loads the given file and parses it to LDObjects using parseLine. It's a
 // separate class so as to be able to do the work in a separate thread.
 // =============================================================================
 class FileLoader : public QObject {
 	Q_OBJECT
-	READ_PROPERTY( vector<LDObject*>, objs, setObjects )
-	READ_PROPERTY( bool, done, setDone )
-	READ_PROPERTY( ulong, progress, setProgress )
-	READ_PROPERTY( bool, aborted, setAborted )
-	PROPERTY( vector<str>, lines, setLines )
-	PROPERTY( ulong*, warningsPointer, setWarningsPointer )
-	PROPERTY( bool, concurrent, setConcurrent )
+	READ_PROPERTY (vector<LDObject*>, objs, setObjects)
+	READ_PROPERTY (bool, done, setDone)
+	READ_PROPERTY (ulong, progress, setProgress)
+	READ_PROPERTY (bool, aborted, setAborted)
+	PROPERTY (vector<str>, lines, setLines)
+	PROPERTY (ulong*, warningsPointer, setWarningsPointer)
+	PROPERTY (bool, concurrent, setConcurrent)
 	
 public slots:
 	void start();
@@ -167,11 +200,12 @@
 	OpenProgressDialog* dlg;
 	
 private slots:
-	void work( ulong i );
+	void work (ulong i);
 	
 signals:
-	void progressUpdate( int progress );
+	void progressUpdate (int progress);
 	void workDone();
 };
 
-#endif // FILE_H
\ No newline at end of file
+#endif // FILE_H
+// kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 
--- a/src/gui.cpp	Wed Jul 10 02:58:59 2013 +0300
+++ b/src/gui.cpp	Sat Jul 13 17:35:38 2013 +0300
@@ -1007,13 +1007,12 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-void ForgeWindow::save( LDOpenFile* f, bool saveAs )
-{
+void ForgeWindow::save (LDOpenFile* f, bool saveAs) {
 	str path = f->name ();
 	
 	if (path.length () == 0 || saveAs) {
-		path = QFileDialog::getSaveFileName (g_win, tr( "Save As" ),
-			g_curfile->name (), tr( "LDraw files (*.dat *.ldr)" ));
+		path = QFileDialog::getSaveFileName (g_win, tr ("Save As"),
+			g_curfile->name (), tr ("LDraw files (*.dat *.ldr)"));
 		
 		if (path.length () == 0) {
 			// User didn't give a file name. This happens if the user cancelled
@@ -1022,33 +1021,33 @@
 		}
 	}
 	
-	if( f->save( path ))
-	{
+	if (f->save (path)) {
 		f->setName (path);
 		
-		if( f == g_curfile )
+		if (f == g_curfile)
 			g_win->updateTitle ();
 		
-		log( "Saved to %1.", path );
-	}
-	else
-	{
-		setlocale( LC_ALL, "C" );
+		log ("Saved to %1.", path);
 		
-		str message = fmt( tr( "Failed to save to %1: %2" ), path, strerror (errno));
+		// Add it to recent files
+		addRecentFile (path);
+	} else {
+		setlocale (LC_ALL, "C");
+		
+		str message = fmt (tr ("Failed to save to %1: %2"), path, strerror (errno));
 		
 		// Tell the user the save failed, and give the option for saving as with it.
-		QMessageBox dlg( QMessageBox::Critical, tr( "Save Failure" ), message,
-			QMessageBox::Close, g_win );
+		QMessageBox dlg (QMessageBox::Critical, tr ("Save Failure"), message,
+						 QMessageBox::Close, g_win);
 		
 		// Add a save-as button
-		QPushButton* saveAsBtn = new QPushButton( tr( "Save As" ));
-		saveAsBtn->setIcon( getIcon( "file-save-as" ));
-		dlg.addButton( saveAsBtn, QMessageBox::ActionRole );
-		dlg.setDefaultButton( QMessageBox::Close );
+		QPushButton* saveAsBtn = new QPushButton (tr ("Save As"));
+		saveAsBtn->setIcon (getIcon ("file-save-as"));
+		dlg.addButton (saveAsBtn, QMessageBox::ActionRole);
+		dlg.setDefaultButton (QMessageBox::Close);
 		dlg.exec();
 		
-		if( dlg.clickedButton () == saveAsBtn )
+		if (dlg.clickedButton () == saveAsBtn)
 			save (f, true); // yay recursion!
 	}
 }
--- a/src/gui_actions.cpp	Wed Jul 10 02:58:59 2013 +0300
+++ b/src/gui_actions.cpp	Sat Jul 13 17:35:38 2013 +0300
@@ -38,23 +38,23 @@
 #include "widgets.h"
 
 extern_cfg (bool, gl_wireframe);
-extern_cfg( bool, gl_colorbfc );
+extern_cfg (bool, gl_colorbfc);
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (newFile, "&New", "brick", "Create a new part model.", CTRL (N)) {
-	if (safeToCloseAll () == false)
+	if (safeToCloseAll() == false)
 		return;
 	
-	QDialog* dlg = new QDialog( g_win );
+	QDialog* dlg = new QDialog (g_win);
 	Ui::NewPartUI ui;
-	ui.setupUi( dlg );
+	ui.setupUi (dlg);
 	
-	if (dlg->exec () == false)
+	if (dlg->exec() == false)
 		return;
 	
-	newFile ();
+	newFile();
 	
 	const LDBFC::Type BFCType =
 		ui.rb_bfc_ccw->isChecked() ? LDBFC::CertifyCCW :
@@ -66,16 +66,16 @@
 		ui.rb_license_nonca->isChecked() ? NonCALicense :
 		                                   "";
 	
-	*g_curfile << new LDComment( ui.le_title->text() );
-	*g_curfile << new LDComment( "Name: <untitled>.dat" );
-	*g_curfile << new LDComment( fmt( "Author: %1", ui.le_author->text() ));
-	*g_curfile << new LDComment( fmt( "!LDRAW_ORG Unofficial_Part" ));
+	*g_curfile << new LDComment (ui.le_title->text());
+	*g_curfile << new LDComment ("Name: <untitled>.dat" );
+	*g_curfile << new LDComment (fmt ("Author: %1", ui.le_author->text()));
+	*g_curfile << new LDComment (fmt ("!LDRAW_ORG Unofficial_Part"));
 	
-	if( license != "" )
-		*g_curfile << new LDComment( license );
+	if (license != "")
+		*g_curfile << new LDComment (license);
 	
 	*g_curfile << new LDEmpty;
-	*g_curfile << new LDBFC( BFCType );
+	*g_curfile << new LDBFC (BFCType);
 	*g_curfile << new LDEmpty;
 	
 	g_win->fullRefresh();
@@ -85,44 +85,44 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (open, "&Open", "file-open", "Load a part model from a file.", CTRL (O)) {
-	if (safeToCloseAll () == false)
+	if (safeToCloseAll() == false)
 		return;
 	
 	str name = QFileDialog::getOpenFileName (g_win, "Open File", "", "LDraw files (*.dat *.ldr)");
 	
-	if (name.length () == 0)
+	if (name.length() == 0)
 		return;
 	
-	closeAll ();
+	closeAll();
 	openMainFile (name);
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-MAKE_ACTION( save, "&Save", "file-save", "Save the part model.", CTRL( S ))
+MAKE_ACTION (save, "&Save", "file-save", "Save the part model.", CTRL (S))
 {
-	g_win->save( g_curfile, false );
+	g_win->save (g_curfile, false);
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-MAKE_ACTION( saveAs, "Save &As", "file-save-as", "Save the part model to a specific file.", CTRL_SHIFT( S ))
+MAKE_ACTION (saveAs, "Save &As", "file-save-as", "Save the part model to a specific file.", CTRL_SHIFT (S))
 {
-	g_win->save( g_curfile, true );
+	g_win->save (g_curfile, true);
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (settings, "Settin&gs", "settings", "Edit the settings of " APPNAME ".", (0)) {
-	ConfigDialog::staticDialog ();
+	ConfigDialog::staticDialog();
 }
 
 MAKE_ACTION (setLDrawPath, "Set LDraw Path", "settings", "Change the LDraw directory path.", (0)) {
 	LDrawPathDialog dlg (true);
-	dlg.exec ();
+	dlg.exec();
 }
 
 // =============================================================================
@@ -167,17 +167,17 @@
 	AddObjectDialog::staticDialog (LDObject::Vertex, null);
 }
 
-MAKE_ACTION( makePrimitive, "Make a Primitive", "radial", "Generate a new circular primitive.", 0 )
+MAKE_ACTION (makePrimitive, "Make a Primitive", "radial", "Generate a new circular primitive.", 0)
 {
 	generatePrimitive();
 }
 
 MAKE_ACTION (editObject, "Edit Object", "edit-object", "Edits this object.", 0) {
-	if (g_win->sel ().size () != 1)
+	if (g_win->sel().size() != 1)
 		return;
 	
-	LDObject* obj = g_win->sel ()[0];
-	AddObjectDialog::staticDialog (obj->getType (), obj);
+	LDObject* obj = g_win->sel()[0];
+	AddObjectDialog::staticDialog (obj->getType(), obj);
 }
 
 MAKE_ACTION (help, "Help", "help", "Shows the " APPNAME " help manual.", KEY (F1)) {
@@ -191,7 +191,7 @@
 	"Shows information about " APPNAME ".", (0))
 {
 	AboutDialog dlg;
-	dlg.exec ();
+	dlg.exec();
 }
 
 MAKE_ACTION (aboutQt, "About Qt", "qt", "Shows information about Qt.", (0)) {
@@ -202,39 +202,39 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (selectAll, "Select All", "select-all", "Selects all objects.", CTRL (A)) {
-	g_win->sel ().clear ();
+	g_win->sel().clear();
 	
-	for (LDObject* obj : g_curfile->objs ())
-		g_win->sel () << obj;
+	for (LDObject* obj : g_curfile->objs())
+		g_win->sel() << obj;
 	
-	g_win->updateSelection ();
+	g_win->updateSelection();
 }
 
 // =============================================================================
 MAKE_ACTION (selectByColor, "Select by Color", "select-color",
 	"Select all objects by the given color.", CTRL_SHIFT (A))
 {
-	short colnum = g_win->getSelectedColor ();
+	short colnum = g_win->getSelectedColor();
 	
 	if (colnum == -1)
 		return; // no consensus on color
 	
-	g_win->sel ().clear ();
-	for (LDObject* obj : g_curfile->objs ())
-		if (obj->color () == colnum)
-			g_win->sel () << obj;
+	g_win->sel().clear();
+	for (LDObject* obj : g_curfile->objs())
+		if (obj->color() == colnum)
+			g_win->sel() << obj;
 	
-	g_win->updateSelection ();
+	g_win->updateSelection();
 }
 
 // =============================================================================
 MAKE_ACTION (selectByType, "Select by Type", "select-type",
 	"Select all objects by the given type.", (0))
 {
-	if (g_win->sel ().size () == 0)
+	if (g_win->sel().size() == 0)
 		return;
 	
-	LDObject::Type type = g_win->uniformSelectedType ();
+	LDObject::Type type = g_win->uniformSelectedType();
 	
 	if (type == LDObject::Unidentified)
 		return;
@@ -244,25 +244,25 @@
 	str refName;
 	
 	if (type == LDObject::Subfile) {
-		refName = static_cast<LDSubfile*> (g_win->sel ()[0])->fileInfo ()->name ();
+		refName = static_cast<LDSubfile*> (g_win->sel()[0])->fileInfo()->name();
 		
-		for (LDObject* obj : g_win->sel ())
-			if (static_cast<LDSubfile*> (obj)->fileInfo ()->name () != refName)
+		for (LDObject* obj : g_win->sel())
+			if (static_cast<LDSubfile*> (obj)->fileInfo()->name() != refName)
 				return;
 	}
 	
-	g_win->sel ().clear ();
-	for (LDObject* obj : g_curfile->objs ()) {
+	g_win->sel().clear();
+	for (LDObject* obj : g_curfile->objs()) {
 		if (obj->getType() != type)
 			continue;
 		
-		if (type == LDObject::Subfile && static_cast<LDSubfile*> (obj)->fileInfo ()->name () != refName)
+		if (type == LDObject::Subfile && static_cast<LDSubfile*> (obj)->fileInfo()->name() != refName)
 			continue;
 		
-		g_win->sel () << obj;
+		g_win->sel() << obj;
 	}
 	
-	g_win->updateSelection ();
+	g_win->updateSelection();
 }
 
 // =============================================================================
@@ -270,35 +270,35 @@
 // =============================================================================
 MAKE_ACTION (gridCoarse, "Coarse Grid", "grid-coarse", "Set the grid to Coarse", (0)) {
 	grid = Grid::Coarse;
-	g_win->updateGridToolBar ();
+	g_win->updateGridToolBar();
 }
 
 MAKE_ACTION (gridMedium, "Medium Grid", "grid-medium", "Set the grid to Medium", (0)) {
 	grid = Grid::Medium;
-	g_win->updateGridToolBar ();
+	g_win->updateGridToolBar();
 }
 
 MAKE_ACTION (gridFine, "Fine Grid", "grid-fine", "Set the grid to Fine", (0)) {
 	grid = Grid::Fine;
-	g_win->updateGridToolBar ();
+	g_win->updateGridToolBar();
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (resetView, "Reset View", "reset-view", "Reset view angles, pan and zoom", CTRL (0)) {
-	g_win->R ()->resetAngles ();
-	g_win->R ()->update ();
+	g_win->R()->resetAngles();
+	g_win->R()->update();
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (insertFrom, "Insert from File", "file-import", "Insert LDraw data from a file.", (0)) {
-	str fname = QFileDialog::getOpenFileName ();
-	ulong idx = g_win->getInsertionPoint ();
+	str fname = QFileDialog::getOpenFileName();
+	ulong idx = g_win->getInsertionPoint();
 	
-	if (!fname.length ())
+	if (!fname.length())
 		return;
 	
 	File f (fname, File::Read);
@@ -309,28 +309,28 @@
 	
 	vector<LDObject*> objs = loadFileContents (&f, null);
 	
-	g_win->sel ().clear ();
+	g_win->sel().clear();
 	
 	for (LDObject* obj : objs) {
 		g_curfile->insertObj (idx, obj);
-		g_win->sel () << obj;
+		g_win->sel() << obj;
 		
 		idx++;
 	}
 	
-	g_win->fullRefresh ();
-	g_win->scrollToSelection ();
+	g_win->fullRefresh();
+	g_win->scrollToSelection();
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (exportTo, "Export To File", "file-export", "Export current selection to file", (0)) {
-	if (g_win->sel ().size () == 0)
+	if (g_win->sel().size() == 0)
 		return;
 	
-	str fname = QFileDialog::getSaveFileName ();
-	if (fname.length () == 0)
+	str fname = QFileDialog::getSaveFileName();
+	if (fname.length() == 0)
 		return;
 	
 	QFile file (fname);
@@ -339,10 +339,10 @@
 		return;
 	}
 	
-	for (LDObject* obj : g_win->sel ()) {
-		str contents = obj->raw ();
-		QByteArray data = contents.toUtf8 ();
-		file.write (data, data.size ());
+	for (LDObject* obj : g_win->sel()) {
+		str contents = obj->raw();
+		QByteArray data = contents.toUtf8();
+		file.write (data, data.size());
 		file.write ("\r\n", 2);
 	}
 }
@@ -351,7 +351,7 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (insertRaw, "Insert Raw", "insert-raw", "Type in LDraw code to insert.", (0)) {
-	ulong idx = g_win->getInsertionPoint ();
+	ulong idx = g_win->getInsertionPoint();
 	
 	QDialog* const dlg = new QDialog;
 	QVBoxLayout* const layout = new QVBoxLayout;
@@ -362,24 +362,24 @@
 	layout->addWidget (bbx_buttons);
 	dlg->setLayout (layout);
 	dlg->setWindowTitle (APPNAME ": Insert Raw");
-	dlg->connect (bbx_buttons, SIGNAL (accepted ()), dlg, SLOT (accept ()));
-	dlg->connect (bbx_buttons, SIGNAL (rejected ()), dlg, SLOT (reject ()));
+	dlg->connect (bbx_buttons, SIGNAL (accepted()), dlg, SLOT (accept()));
+	dlg->connect (bbx_buttons, SIGNAL (rejected()), dlg, SLOT (reject()));
 	
-	if (dlg->exec () == false)
+	if (dlg->exec() == false)
 		return;
 	
-	g_win->sel ().clear ();
+	g_win->sel().clear();
 	
-	for (str line : str (te_edit->toPlainText ()).split ("\n")) {
+	for (str line : str (te_edit->toPlainText()).split ("\n")) {
 		LDObject* obj = parseLine (line);
 		
 		g_curfile->insertObj (idx, obj);
-		g_win->sel () << obj;
+		g_win->sel() << obj;
 		idx++;
 	}
 	
-	g_win->fullRefresh ();
-	g_win->scrollToSelection ();
+	g_win->fullRefresh();
+	g_win->scrollToSelection();
 }
 
 // =========================================================================================================================================
@@ -387,18 +387,18 @@
 	setlocale (LC_ALL, "C");
 	
 	ushort w, h;
-	uchar* imgdata = g_win->R ()->screencap (w, h);
+	uchar* imgdata = g_win->R()->screencap (w, h);
 	QImage img = imageFromScreencap (imgdata, w, h);
 	
-	str root = basename (g_curfile->name ());
+	str root = basename (g_curfile->name());
 	if (root.right (4) == ".dat")
 		root.chop (4);
 	
-	str defaultname = (root.length () > 0) ? fmt ("%1.png", root) : "";
+	str defaultname = (root.length() > 0) ? fmt ("%1.png", root) : "";
 	str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname,
 		"PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)");
 	
-	if (fname.length () > 0 && !img.save (fname))
+	if (fname.length() > 0 && !img.save (fname))
 		critical (fmt ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno)));
 	
 	delete[] imgdata;
@@ -409,56 +409,56 @@
 MAKE_ACTION (axes, "Draw Axes", "axes", "Toggles drawing of axes", (0)) {
 	gl_axes = !gl_axes;
 	ACTION (axes)->setChecked (gl_axes);
-	g_win->R ()->update ();
+	g_win->R()->update();
 }
 
 // =========================================================================================================================================
 MAKE_ACTION (visibility, "Toggle Visibility", "visibility", "Toggles visibility/hiding on objects.", (0)) {
-	for (LDObject* obj : g_win->sel ())
-		obj->setHidden (!obj->hidden ());
+	for (LDObject* obj : g_win->sel())
+		obj->setHidden (!obj->hidden());
 	
-	g_win->fullRefresh ();
+	g_win->fullRefresh();
 }
 
 MAKE_ACTION (wireframe, "Wireframe", "wireframe", "Toggle wireframe view", (0)) {
 	gl_wireframe = !gl_wireframe;
-	g_win->R ()->refresh ();
+	g_win->R()->refresh();
 }
 
-MAKE_ACTION( setOverlay, "Set Overlay Image", "overlay", "Set an overlay image", 0 )
+MAKE_ACTION (setOverlay, "Set Overlay Image", "overlay", "Set an overlay image", 0)
 {
 	OverlayDialog dlg;
 	
-	if (!dlg.exec ())
+	if (!dlg.exec())
 		return;
 	
-	g_win->R ()->setupOverlay( (GL::Camera) dlg.camera(), dlg.fpath(), dlg.ofsx(),
+	g_win->R()->setupOverlay ((GL::Camera) dlg.camera(), dlg.fpath(), dlg.ofsx(),
 		dlg.ofsy(), dlg.lwidth(), dlg.lheight() );
 }
 
 MAKE_ACTION (clearOverlay, "Clear Overlay Image", "overlay-clear", "Clear the overlay image.", (0)) {
-	g_win->R ()->clearOverlay ();
+	g_win->R()->clearOverlay();
 }
 
 MAKE_ACTION (modeSelect, "Select Mode", "mode-select", "Select objects from the camera view.", CTRL (1)) {
-	g_win->R ()->setEditMode (Select);
+	g_win->R()->setEditMode (Select);
 }
 
 MAKE_ACTION (modeDraw, "Draw Mode", "mode-draw", "Draw objects into the camera view.", CTRL (2)) {
-	g_win->R ()->setEditMode (Draw);
+	g_win->R()->setEditMode (Draw);
 }
 
 MAKE_ACTION (setDrawDepth, "Set Depth Value", "depth-value", "Set the depth coordinate of the current camera.", (0)) {
-	if (g_win->R ()->camera () == GL::Free)
+	if (g_win->R()->camera() == GL::Free)
 		return;
 	
 	bool ok;
 	double depth = QInputDialog::getDouble (g_win, "Set Draw Depth",
-		fmt ("Depth value for %1 Camera:", g_win->R ()->cameraName ()),
-		g_win->R ()->depthValue (), -10000.0f, 10000.0f, 3, &ok);
+		fmt ("Depth value for %1 Camera:", g_win->R()->cameraName()),
+		g_win->R()->depthValue(), -10000.0f, 10000.0f, 3, &ok);
 	
 	if (ok)
-		g_win->R ()->setDepthValue (depth);
+		g_win->R()->setDepthValue (depth);
 }
 
 #ifndef RELEASE
@@ -479,17 +479,17 @@
 	GLRenderer* rend = new GLRenderer;
 	rend->resize (64, 64);
 	rend->setAttribute (Qt::WA_DontShowOnScreen);
-	rend->show ();
+	rend->show();
 	rend->setFile (file);
 	rend->setDrawOnly (true);
-	rend->compileAllObjects ();
-	rend->initGLData ();
-	rend->drawGLScene ();
+	rend->compileAllObjects();
+	rend->initGLData();
+	rend->drawGLScene();
 	
 	uchar* imgdata = rend->screencap (w, h);
 	QImage img = imageFromScreencap (imgdata, w, h);
 	
-	if (img.isNull ()) {
+	if (img.isNull()) {
 		critical ("Failed to create the image!\n");
 	} else {
 		QLabel* label = new QLabel;
@@ -497,21 +497,21 @@
 		label->setPixmap (QPixmap::fromImage (img));
 		QVBoxLayout* layout = new QVBoxLayout (dlg);
 		layout->addWidget (label);
-		dlg->exec ();
+		dlg->exec();
 	}
 	
 	delete[] imgdata;
-	rend->deleteLater ();
+	rend->deleteLater();
 }
 #endif
 
 MAKE_ACTION (reloadPrimitives, "Scan Primitives", "", "", (0)) {
-	PrimitiveLister::start ();
+	PrimitiveLister::start();
 }
 
-MAKE_ACTION( colorbfc, "BFC Red/Green View", "bfc-view", "", SHIFT( B ))
+MAKE_ACTION (colorbfc, "BFC Red/Green View", "bfc-view", "", SHIFT (B))
 {
 	gl_colorbfc = !gl_colorbfc;
-	ACTION( colorbfc )->setChecked( gl_colorbfc );
-	g_win->R ()->refresh();
+	ACTION (colorbfc)->setChecked (gl_colorbfc);
+	g_win->R()->refresh();
 }
\ No newline at end of file
--- a/src/gui_editactions.cpp	Wed Jul 10 02:58:59 2013 +0300
+++ b/src/gui_editactions.cpp	Sat Jul 13 17:35:38 2013 +0300
@@ -1,17 +1,17 @@
 /*
  *  LDForge: LDraw parts authoring CAD
  *  Copyright (C) 2013 Santeri Piippo
- *  
+ *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@ -40,8 +40,8 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-static int copyToClipboard () {
-	vector<LDObject*> objs = g_win->sel ();
+static int copyToClipboard() {
+	vector<LDObject*> objs = g_win->sel();
 	int num = 0;
 	
 	// Clear the clipboard first.
@@ -49,16 +49,16 @@
 	
 	// Now, copy the contents into the clipboard.
 	str data;
+	
 	for (LDObject* obj : objs) {
-		if( data.length() > 0 )
+		if (data.length() > 0)
 			data += "\n";
 		
-		data += obj->raw ();
+		data += obj->raw();
 		++num;
 	}
 	
-	qApp->clipboard()->setText( data );
-	
+	qApp->clipboard()->setText (data);
 	return num;
 }
 
@@ -66,18 +66,17 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (cut, "Cut", "cut", "Cut the current selection to clipboard.", CTRL (X)) {
-	int num = copyToClipboard ();
-	g_win->deleteSelection ();
-	
-	log( ForgeWindow::tr( "%1 objects cut" ), num );
+	int num = copyToClipboard();
+	g_win->deleteSelection();
+	log (ForgeWindow::tr ("%1 objects cut"), num);
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (copy, "Copy", "copy", "Copy the current selection to clipboard.", CTRL (C)) {
-	int num = copyToClipboard ();
-	log( ForgeWindow::tr( "%1 objects copied" ), num );
+	int num = copyToClipboard();
+	log (ForgeWindow::tr ("%1 objects copied"), num);
 }
 
 // =============================================================================
@@ -85,42 +84,42 @@
 // =============================================================================
 MAKE_ACTION (paste, "Paste", "paste", "Paste clipboard contents.", CTRL (V)) {
 	const str clipboardText = qApp->clipboard()->text();
-	ulong idx = g_win->getInsertionPoint ();
-	g_win->sel ().clear ();
+	ulong idx = g_win->getInsertionPoint();
+	g_win->sel().clear();
 	int num = 0;
 	
-	for( str line : clipboardText.split( "\n" ))
-	{
+	for (str line : clipboardText.split ("\n")) {
 		LDObject* pasted = parseLine (line);
 		g_curfile->insertObj (idx++, pasted);
-		g_win->sel () << pasted;
-		g_win->R ()->compileObject (pasted);
+		g_win->sel() << pasted;
+		g_win->R()->compileObject (pasted);
 		++num;
 	}
 	
-	log( ForgeWindow::tr( "%1 objects pasted" ), num );
-	g_win->refresh ();
-	g_win->scrollToSelection ();
+	log (ForgeWindow::tr ("%1 objects pasted"), num);
+	g_win->refresh();
+	g_win->scrollToSelection();
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (del, "Delete", "delete", "Delete the selection", KEY (Delete)) {
-	int num = g_win->deleteSelection ();
-	log( ForgeWindow::tr( "%1 objects deleted" ), num );
+	int num = g_win->deleteSelection();
+	log (ForgeWindow::tr ("%1 objects deleted"), num);
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 static void doInline (bool deep) {
-	vector<LDObject*> sel = g_win->sel ();
+	vector<LDObject*> sel = g_win->sel();
 	
 	for (LDObject* obj : sel) {
 		// Get the index of the subfile so we know where to insert the
 		// inlined contents.
 		long idx = obj->getIndex (g_curfile);
+		
 		if (idx == -1)
 			continue;
 		
@@ -135,18 +134,18 @@
 		for (LDObject* inlineobj : objs) {
 			str line = inlineobj->raw();
 			delete inlineobj;
-			
-			LDObject* newobj = parseLine( line );
-			g_curfile->insertObj( idx++, newobj );
+		
+			LDObject* newobj = parseLine (line);
+			g_curfile->insertObj (idx++, newobj);
 			g_win->sel() << newobj;
 		}
 		
 		// Delete the subfile now as it's been inlined.
-		g_curfile->forgetObject( obj );
+		g_curfile->forgetObject (obj);
 		delete obj;
 	}
 	
-	g_win->fullRefresh ();
+	g_win->fullRefresh();
 }
 
 MAKE_ACTION (inlineContents, "Inline", "inline", "Inline selected subfiles.", CTRL (I)) {
@@ -163,7 +162,7 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // ===============================================================================================
 MAKE_ACTION (splitQuads, "Split Quads", "quad-split", "Split quads into triangles.", (0)) {
-	vector<LDObject*> objs = g_win->sel ();
+	vector<LDObject*> objs = g_win->sel();
 	int num = 0;
 	
 	for (LDObject* obj : objs) {
@@ -176,7 +175,7 @@
 		if (index == -1)
 			return;
 		
-		vector<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles ();
+		vector<LDTriangle*> triangles = static_cast<LDQuad*> (obj)->splitToTriangles();
 		
 		// Replace the quad with the first triangle and add the second triangle
 		// after the first one.
@@ -189,45 +188,42 @@
 		num++;
 	}
 	
-	log( "%1 quadrilaterals split", num );
-	
-	g_win->fullRefresh ();
+	log ("%1 quadrilaterals split", num);
+	g_win->fullRefresh();
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-MAKE_ACTION( setContents, "Edit LDraw Code", "set-contents", "Edit the LDraw code of this object.", KEY( F9 ))
-{
-	if( g_win->sel().size() != 1 )
+MAKE_ACTION (setContents, "Edit LDraw Code", "set-contents", "Edit the LDraw code of this object.", KEY (F9)) {
+	if (g_win->sel().size() != 1)
 		return;
 	
-	LDObject* obj = g_win->sel()[0];
+	LDObject* obj = g_win->sel() [0];
 	QDialog* dlg = new QDialog;
 	Ui::EditRawUI ui;
 	
-	ui.setupUi( dlg );
-	ui.code->setText( obj->raw() );
+	ui.setupUi (dlg);
+	ui.code->setText (obj->raw());
 	
-	if( obj->getType() == LDObject::Gibberish )
-		ui.errorDescription->setText( static_cast<LDGibberish*>( obj )->reason );
-	else
-	{
+	if (obj->getType() == LDObject::Gibberish)
+		ui.errorDescription->setText (static_cast<LDGibberish*> (obj)->reason);
+	else {
 		ui.errorDescription->hide();
 		ui.errorIcon->hide();
 	}
 	
-	if( !dlg->exec() )
+	if (!dlg->exec())
 		return;
 	
 	LDObject* oldobj = obj;
 	
 	// Reinterpret it from the text of the input field
-	obj = parseLine( ui.code->text() );
-	oldobj->replace( obj );
+	obj = parseLine (ui.code->text());
+	oldobj->replace (obj);
 	
 	// Refresh
-	g_win->R()->compileObject( obj );
+	g_win->R()->compileObject (obj);
 	g_win->refresh();
 }
 
@@ -235,29 +231,29 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (setColor, "Set Color", "palette", "Set the color on given objects.", KEY (C)) {
-	if (g_win->sel ().size () <= 0)
+	if (g_win->sel().size() <= 0)
 		return;
 	
 	short colnum;
 	short defcol = -1;
 	
-	vector<LDObject*> objs = g_win->sel ();
+	vector<LDObject*> objs = g_win->sel();
 	
 	// If all selected objects have the same color, said color is our default
 	// value to the color selection dialog.
-	defcol = g_win->getSelectedColor ();
+	defcol = g_win->getSelectedColor();
 	
 	// Show the dialog to the user now and ask for a color.
 	if (ColorSelector::getColor (colnum, defcol, g_win)) {
 		for (LDObject* obj : objs) {
-			if (obj->isColored () == false)
+			if (obj->isColored() == false)
 				continue;
 			
 			obj->setColor (colnum);
-			g_win->R ()->compileObject (obj);
+			g_win->R()->compileObject (obj);
 		}
 		
-		g_win->refresh ();
+		g_win->refresh();
 	}
 }
 
@@ -265,7 +261,7 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (makeBorders, "Make Borders", "make-borders", "Add borders around given polygons.", CTRL_SHIFT (B)) {
-	vector<LDObject*> objs = g_win->sel ();
+	vector<LDObject*> objs = g_win->sel();
 	int num = 0;
 	
 	for (LDObject* obj : objs) {
@@ -289,7 +285,7 @@
 			LDTriangle* tri = static_cast<LDTriangle*> (obj);
 			lines[0] = new LDLine (tri->getVertex (0), tri->getVertex (1));
 			lines[1] = new LDLine (tri->getVertex (1), tri->getVertex (2));
-			lines[2] = new LDLine (tri->getVertex (2), tri->getVertex (0)); 
+			lines[2] = new LDLine (tri->getVertex (2), tri->getVertex (0));
 		}
 		
 		for (short i = 0; i < numLines; ++i) {
@@ -297,14 +293,14 @@
 			
 			lines[i]->setColor (edgecolor);
 			g_curfile->insertObj (idx, lines[i]);
-			g_win->R ()->compileObject (lines[i]);
+			g_win->R()->compileObject (lines[i]);
 		}
 		
 		num += numLines;
 	}
 	
-	log( ForgeWindow::tr( "Added %1 border lines" ), num );
-	g_win->refresh ();
+	log (ForgeWindow::tr ("Added %1 border lines"), num);
+	g_win->refresh();
 }
 
 // =============================================================================
@@ -315,33 +311,34 @@
 {
 	int num = 0;
 	
-	for (LDObject* obj : g_win->sel ()) {
-		if (obj->vertices () < 2)
+	for (LDObject* obj : g_win->sel()) {
+		if (obj->vertices() < 2)
 			continue;
 		
 		ulong idx = obj->getIndex (g_curfile);
+		
 		for (short i = 0; i < obj->vertices(); ++i) {
 			LDVertex* vert = new LDVertex;
 			vert->pos = obj->getVertex (i);
-			vert->setColor (obj->color ());
+			vert->setColor (obj->color());
 			
 			g_curfile->insertObj (++idx, vert);
-			g_win->R ()->compileObject (vert);
+			g_win->R()->compileObject (vert);
 			++num;
 		}
 	}
 	
-	log( ForgeWindow::tr( "Added %1 vertices" ), num );
-	g_win->refresh ();
+	log (ForgeWindow::tr ("Added %1 vertices"), num);
+	g_win->refresh();
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 static void doMoveSelection (const bool up) {
-	vector<LDObject*> objs = g_win->sel ();
+	vector<LDObject*> objs = g_win->sel();
 	LDObject::moveObjects (objs, up);
-	g_win->buildObjList ();
+	g_win->buildObjList();
 }
 
 MAKE_ACTION (moveUp, "Move Up", "arrow-up", "Move the current selection up.", KEY (PageUp)) {
@@ -356,11 +353,11 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (undo, "Undo", "undo", "Undo a step.", CTRL (Z)) {
-	g_curfile->undo ();
+	g_curfile->undo();
 }
 
 MAKE_ACTION (redo, "Redo", "redo", "Redo a step.", CTRL_SHIFT (Z)) {
-	g_curfile->redo ();
+	g_curfile->redo();
 }
 
 // =============================================================================
@@ -368,52 +365,52 @@
 // =============================================================================
 void doMoveObjects (vertex vect) {
 	// Apply the grid values
-	vect[X] *= currentGrid ().confs[Grid::X]->value;
-	vect[Y] *= currentGrid ().confs[Grid::Y]->value;
-	vect[Z] *= currentGrid ().confs[Grid::Z]->value;
+	vect[X] *= currentGrid().confs[Grid::X]->value;
+	vect[Y] *= currentGrid().confs[Grid::Y]->value;
+	vect[Z] *= currentGrid().confs[Grid::Z]->value;
 	
-	for (LDObject* obj : g_win->sel ()) {
+	for (LDObject* obj : g_win->sel()) {
 		obj->move (vect);
-		g_win->R ()->compileObject (obj);
+		g_win->R()->compileObject (obj);
 	}
 	
-	g_win->refresh ();
+	g_win->refresh();
 }
 
 MAKE_ACTION (moveXNeg, "Move -X", "move-x-neg", "Move selected objects negative on the X axis.", KEY (Left)) {
-	doMoveObjects ({-1, 0, 0});
+	doMoveObjects ( { -1, 0, 0});
 }
 
 MAKE_ACTION (moveYNeg, "Move -Y", "move-y-neg", "Move selected objects negative on the Y axis.", KEY (Home)) {
-	doMoveObjects ({0, -1, 0});
+	doMoveObjects ( {0, -1, 0});
 }
 
 MAKE_ACTION (moveZNeg, "Move -Z", "move-z-neg", "Move selected objects negative on the Z axis.", KEY (Down)) {
-	doMoveObjects ({0, 0, -1});
+	doMoveObjects ( {0, 0, -1});
 }
 
 MAKE_ACTION (moveXPos, "Move +X", "move-x-pos", "Move selected objects positive on the X axis.", KEY (Right)) {
-	doMoveObjects ({1, 0, 0});
+	doMoveObjects ( {1, 0, 0});
 }
 
 MAKE_ACTION (moveYPos, "Move +Y", "move-y-pos", "Move selected objects positive on the Y axis.", KEY (End)) {
-	doMoveObjects ({0, 1, 0});
+	doMoveObjects ( {0, 1, 0});
 }
 
 MAKE_ACTION (moveZPos, "Move +Z", "move-z-pos", "Move selected objects positive on the Z axis.", KEY (Up)) {
-	doMoveObjects ({0, 0, 1});
+	doMoveObjects ( {0, 0, 1});
 }
 
 // =============================================================================
 MAKE_ACTION (invert, "Invert", "invert", "Reverse the winding of given objects.", CTRL_SHIFT (W)) {
-	vector<LDObject*> sel = g_win->sel ();
+	vector<LDObject*> sel = g_win->sel();
 	
 	for (LDObject* obj : sel) {
-		obj->invert ();
-		g_win->R ()->compileObject (obj);
+		obj->invert();
+		g_win->R()->compileObject (obj);
 	}
 	
-	g_win->refresh ();
+	g_win->refresh();
 }
 
 // =============================================================================
@@ -424,54 +421,54 @@
 }
 
 static void doRotate (const short l, const short m, const short n) {
-	vector<LDObject*> sel = g_win->sel ();
+	vector<LDObject*> sel = g_win->sel();
 	vector<vertex*> queue;
 	const vertex rotpoint = rotPoint (sel);
-	const double angle = (pi * currentGrid ().confs[Grid::Angle]->value) / 180;
+	const double angle = (pi * currentGrid().confs[Grid::Angle]->value) / 180;
 	
 	// ref: http://en.wikipedia.org/wiki/Transformation_matrix#Rotation_2
 	const double cosangle = cos (angle),
 		sinangle = sin (angle);
 	
-	matrix transform ({
-		(l * l * (1 - cosangle)) + cosangle,
-		(m * l * (1 - cosangle)) - (n * sinangle),
-		(n * l * (1 - cosangle)) + (m * sinangle),
+	matrix transform ( {
+		(l* l * (1 - cosangle)) + cosangle,
+		(m* l * (1 - cosangle)) - (n* sinangle),
+		(n* l * (1 - cosangle)) + (m* sinangle),
 		
-		(l * m * (1 - cosangle)) + (n * sinangle),
-		(m * m * (1 - cosangle)) + cosangle,
-		(n * m * (1 - cosangle)) - (l * sinangle),
+		(l* m * (1 - cosangle)) + (n* sinangle),
+		(m* m * (1 - cosangle)) + cosangle,
+		(n* m * (1 - cosangle)) - (l* sinangle),
 		
-		(l * n * (1 - cosangle)) - (m * sinangle),
-		(m * n * (1 - cosangle)) + (l * sinangle),
-		(n * n * (1 - cosangle)) + cosangle
+		(l* n * (1 - cosangle)) - (m* sinangle),
+		(m* n * (1 - cosangle)) + (l* sinangle),
+		(n* n * (1 - cosangle)) + cosangle
 	});
 	
 	// Apply the above matrix to everything
 	for (LDObject* obj : sel) {
-		if (obj->vertices ()) {
-			for (short i = 0; i < obj->vertices (); ++i) {
+		if (obj->vertices()) {
+			for (short i = 0; i < obj->vertices(); ++i) {
 				vertex v = obj->getVertex (i);
 				rotateVertex (v, rotpoint, transform);
 				obj->setVertex (i, v);
 			}
-		} elif (obj->hasMatrix ()) {
+		} elif (obj->hasMatrix()) {
 			LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj);
-			vertex v = mo->position ();
+			vertex v = mo->position();
 			rotateVertex (v, rotpoint, transform);
 			mo->setPosition (v);
-			mo->setTransform (mo->transform () * transform);
-		} elif (obj->getType () == LDObject::Vertex) {
+			mo->setTransform (mo->transform() * transform);
+		} elif (obj->getType() == LDObject::Vertex) {
 			LDVertex* vert = static_cast<LDVertex*> (obj);
 			vertex v = vert->pos;
 			rotateVertex (v, rotpoint, transform);
 			vert->pos = v;
 		}
 		
-		g_win->R ()->compileObject (obj);
+		g_win->R()->compileObject (obj);
 	}
 	
-	g_win->refresh ();
+	g_win->refresh();
 }
 
 MAKE_ACTION (rotateXPos, "Rotate +X", "rotate-x-pos", "Rotate objects around X axis", CTRL (Right)) {
@@ -499,7 +496,7 @@
 }
 
 MAKE_ACTION (rotpoint, "Set Rotation Point", "rotpoint", "Configure the rotation point.", (0)) {
-	configRotationPoint ();
+	configRotationPoint();
 }
 
 // =============================================================================
@@ -509,8 +506,8 @@
 	setlocale (LC_ALL, "C");
 	int num = 0;
 	
-	for (LDObject* obj : g_win->sel ())
-	for (short i = 0; i < obj->vertices (); ++i) {
+	for (LDObject* obj : g_win->sel())
+	for (short i = 0; i < obj->vertices(); ++i) {
 		vertex v = obj->getVertex (i);
 		
 		for (const Axis ax : g_Axes) {
@@ -524,8 +521,8 @@
 		num += 3;
 	}
 	
-	log( ForgeWindow::tr( "Rounded %1 coordinates" ), num );
-	g_win->fullRefresh ();
+	log (ForgeWindow::tr ("Rounded %1 coordinates"), num);
+	g_win->fullRefresh();
 }
 
 // =============================================================================
@@ -534,55 +531,55 @@
 MAKE_ACTION (uncolorize, "Uncolorize", "uncolorize", "Reduce colors of everything selected to main and edge colors", (0)) {
 	int num = 0;
 	
-	for (LDObject* obj : g_win->sel ()) {
-		if (obj->isColored () == false)
+	for (LDObject* obj : g_win->sel()) {
+		if (obj->isColored() == false)
 			continue;
 		
 		int col = maincolor;
-		if( obj->getType() == LDObject::Line || obj->getType() == LDObject::CondLine )
+		
+		if (obj->getType() == LDObject::Line || obj->getType() == LDObject::CondLine)
 			col = edgecolor;
 		
-		obj->setColor( col );
+		obj->setColor (col);
 		num++;
 	}
 	
-	log( ForgeWindow::tr( "%1 objects uncolored" ), num );
-	g_win->fullRefresh ();
+	log (ForgeWindow::tr ("%1 objects uncolored"), num);
+	g_win->fullRefresh();
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (ytruder, "Ytruder", "ytruder", "Extrude selected lines to a given plane", (0)) {
-	runYtruder ();
+	runYtruder();
 }
 
 MAKE_ACTION (rectifier, "Rectifier", "rectifier", "Optimizes quads into rect primitives.", (0)) {
-	runRectifier ();
+	runRectifier();
 }
 
 MAKE_ACTION (intersector, "Intersector", "intersector", "Perform clipping between two input groups.", (0)) {
-	runIntersector ();
+	runIntersector();
 }
 
 MAKE_ACTION (coverer, "Coverer", "coverer", "Fill the space between two line shapes", (0)) {
-	runCoverer ();
+	runCoverer();
 }
 
 MAKE_ACTION (isecalc, "Isecalc", "isecalc", "Compute intersection between objects", (0)) {
-	runIsecalc ();
+	runIsecalc();
 }
 
 // =============================================================================
-MAKE_ACTION( replaceCoords, "Replace Coordinates", "replace-coords", "Find and replace coordinate values", CTRL( R ))
-{
-	QDialog* dlg = new QDialog( g_win );
+MAKE_ACTION (replaceCoords, "Replace Coordinates", "replace-coords", "Find and replace coordinate values", CTRL (R)) {
+	QDialog* dlg = new QDialog (g_win);
 	Ui::ReplaceCoordsUI ui;
-	ui.setupUi( dlg );
-
-	if( !dlg->exec() )
+	ui.setupUi (dlg);
+	
+	if (!dlg->exec())
 		return;
-
+	
 	const double search = ui.search->value(),
 		replacement = ui.replacement->value();
 	const bool any = ui.any->isChecked(),
@@ -591,22 +588,19 @@
 	vector<Axis> sel;
 	int num = 0;
 	
-	if( ui.x->isChecked() ) sel << X;
-	if( ui.y->isChecked() ) sel << Y;
-	if( ui.z->isChecked() ) sel << Z;
-	
-	for( LDObject * obj : g_win->sel() )
-	for( short i = 0; i < obj->vertices(); ++i )
-	{
-		vertex v = obj->getVertex( i );
+	if (ui.x->isChecked()) sel << X;
+	if (ui.y->isChecked()) sel << Y;
+	if (ui.z->isChecked()) sel << Z;
+
+	for (LDObject* obj : g_win->sel())
+	for (short i = 0; i < obj->vertices(); ++i) {
+		vertex v = obj->getVertex (i);
 		
-		for( Axis ax : sel )
-		{
+		for (Axis ax : sel) {
 			double& coord = v[ax];
 			
-			if( any || coord == search )
-			{
-				if( !rel )
+			if (any || coord == search) {
+				if (!rel)
 					coord = 0;
 				
 				coord += replacement;
@@ -614,38 +608,36 @@
 			}
 		}
 		
-		obj->setVertex( i, v );
+		obj->setVertex (i, v);
 	}
 	
-	log( ForgeWindow::tr( "Altered %1 values" ), num );
+	log (ForgeWindow::tr ("Altered %1 values"), num);
 	g_win->fullRefresh();
 }
 
 // ================================================================================================
-MAKE_ACTION( flip, "Flip", "flip", "Flip coordinates", CTRL_SHIFT( F ))
-{
+MAKE_ACTION (flip, "Flip", "flip", "Flip coordinates", CTRL_SHIFT (F)) {
 	QDialog* dlg = new QDialog;
 	Ui::FlipUI ui;
-	ui.setupUi( dlg );
+	ui.setupUi (dlg);
 	
-	if( !dlg->exec() )
+	if (!dlg->exec())
 		return;
 	
 	vector<Axis> sel;
-	if( ui.x->isChecked() ) sel << X;
-	if( ui.y->isChecked() ) sel << Y;
-	if( ui.z->isChecked() ) sel << Z;
+	if (ui.x->isChecked()) sel << X;
+	if (ui.y->isChecked()) sel << Y;
+	if (ui.z->isChecked()) sel << Z;
 	
-	for( LDObject* obj : g_win->sel() )
-	for( short i = 0; i < obj->vertices(); ++i )
-	{
+	for (LDObject* obj : g_win->sel())
+	for (short i = 0; i < obj->vertices(); ++i) {
 		vertex v = obj->getVertex (i);
 		
-		for( Axis ax : sel )
+		for (Axis ax : sel)
 			v[ax] *= -1;
-		
+
 		obj->setVertex (i, v);
-		g_win->R()->compileObject( obj );
+		g_win->R()->compileObject (obj);
 	}
 	
 	g_win->refresh();
@@ -653,26 +645,26 @@
 
 // ================================================================================================
 MAKE_ACTION (demote, "Demote conditional lines", "demote", "Demote conditional lines down to normal lines.", (0)) {
-	vector<LDObject*> sel = g_win->sel ();
+	vector<LDObject*> sel = g_win->sel();
 	int num = 0;
 	
 	for (LDObject* obj : sel) {
-		if (obj->getType () != LDObject::CondLine)
+		if (obj->getType() != LDObject::CondLine)
 			continue;
 		
-		LDLine* repl = static_cast<LDCondLine*> (obj)->demote ();
-		g_win->R ()->compileObject (repl);
+		LDLine* repl = static_cast<LDCondLine*> (obj)->demote();
+		g_win->R()->compileObject (repl);
 		++num;
 	}
 	
-	log( ForgeWindow::tr( "Demoted %1 conditional lines" ), num );
-	g_win->refresh ();
+	log (ForgeWindow::tr ("Demoted %1 conditional lines"), num);
+	g_win->refresh();
 }
 
 // =================================================================================================
 static bool isColorUsed (short colnum) {
-	for (LDObject* obj : g_curfile->objs ())
-		if (obj->isColored () && obj->color () == colnum)
+	for (LDObject* obj : g_curfile->objs())
+		if (obj->isColored() && obj->color() == colnum)
 			return true;
 	
 	return false;
@@ -686,19 +678,18 @@
 	
 	if (colnum >= 512) {
 		//: Auto-colorer error message
-		critical( ForgeWindow::tr( "Out of unused colors! What are you doing?!" ));
+		critical (ForgeWindow::tr ("Out of unused colors! What are you doing?!"));
 		return;
 	}
 	
-	for (LDObject* obj : g_win->sel ()) {
-		if (obj->isColored () == false)
+	for (LDObject* obj : g_win->sel()) {
+		if (obj->isColored() == false)
 			continue;
 		
 		obj->setColor (colnum);
-		g_win->R ()->compileObject (obj);
+		g_win->R()->compileObject (obj);
 	}
 	
-	log( ForgeWindow::tr( "Auto-colored: new color is [%1] %2" ), colnum, getColor( colnum )->name );
-	
-	g_win->refresh ();
+	log (ForgeWindow::tr ("Auto-colored: new color is [%1] %2"), colnum, getColor (colnum)->name);
+	g_win->refresh();
 }
\ No newline at end of file
--- a/src/history.cpp	Wed Jul 10 02:58:59 2013 +0300
+++ b/src/history.cpp	Sat Jul 13 17:35:38 2013 +0300
@@ -23,32 +23,30 @@
 #include "gui.h"
 #include "gldraw.h"
 
-EXTERN_ACTION( undo )
-EXTERN_ACTION( redo )
+EXTERN_ACTION (undo)
+EXTERN_ACTION (redo)
 
 bool g_fullRefresh = false;
 
-History::History()
-{
-	setOpened( false );
-	setPos( -1 );
+History::History() {
+	setOpened (false);
+	setPos (-1);
 }
 
-void History::undo()
-{
-	if( m_changesets.size() == 0 || pos() == -1 )
+void History::undo() {
+	if (m_changesets.size() == 0 || pos() == -1)
 		return;
 	
-	const list& set = changeset( pos() );
+	const list& set = changeset (pos());
 	g_fullRefresh = false;
 	
 	// Iterate the list in reverse and undo all actions
-	for( const AbstractHistoryEntry* change : c_rev<AbstractHistoryEntry*>( set ))
+	for (const AbstractHistoryEntry * change : c_rev<AbstractHistoryEntry*> (set))
 		change->undo();
 	
-	setPos( pos() - 1 );
+	setPos (pos() - 1);
 	
-	if( !g_fullRefresh )
+	if (!g_fullRefresh)
 		g_win->refresh();
 	else
 		g_win->fullRefresh();
@@ -56,21 +54,20 @@
 	updateActions();
 }
 
-void History::redo()
-{
-	if( pos() == (long) m_changesets.size() )
+void History::redo() {
+	if (pos() == (long) m_changesets.size())
 		return;
 	
-	const list& set = changeset( pos() + 1 );
+	const list& set = changeset (pos() + 1);
 	g_fullRefresh = false;
 	
 	// Redo things - in the order as they were done in the first place
-	for( const AbstractHistoryEntry* change : set )
+	for (const AbstractHistoryEntry * change : set)
 		change->redo();
 	
-	setPos( pos() + 1 );
+	setPos (pos() + 1);
 	
-	if( !g_fullRefresh )
+	if (!g_fullRefresh)
 		g_win->refresh();
 	else
 		g_win->fullRefresh();
@@ -78,96 +75,86 @@
 	updateActions();
 }
 
-void History::clear()
-{
-	for( vector<AbstractHistoryEntry*> set : m_changesets )
-	for( AbstractHistoryEntry* change : set )
-		delete change;
+void History::clear() {
+	for (vector<AbstractHistoryEntry*> set : m_changesets)
+		for (AbstractHistoryEntry * change : set)
+			delete change;
 	
 	m_changesets.clear();
 }
 
-void History::updateActions() const
-{
-	ACTION( undo )->setEnabled( pos() != -1 );
-	ACTION( redo )->setEnabled( pos() < (long) m_changesets.size() - 1 );
+void History::updateActions() const {
+	ACTION (undo)->setEnabled (pos() != -1);
+	ACTION (redo)->setEnabled (pos() < (long) m_changesets.size() - 1);
 }
 
-void History::open()
-{
-	if( opened() )
+void History::open() {
+	if (opened())
 		return;
 	
-	setOpened( true );
+	setOpened (true);
 }
 
-void History::close()
-{
-	if( !opened() )
+void History::close() {
+	if (!opened())
 		return;
 	
-	setOpened( false );
+	setOpened (false);
 	
-	if( m_currentArchive.size() == 0 )
+	if (m_currentArchive.size() == 0)
 		return;
 	
-	while( pos() < size() - 1 )
-		m_changesets.erase( size() - 1 );
+	while (pos() < size() - 1)
+		m_changesets.erase (size() - 1);
 	
 	m_changesets << m_currentArchive;
 	m_currentArchive.clear();
-	setPos( pos() + 1 );
+	setPos (pos() + 1);
 	updateActions();
 }
 
-void History::add( AbstractHistoryEntry* entry )
-{
-	if( !opened() )
-	{
+void History::add (AbstractHistoryEntry* entry) {
+	if (!opened()) {
 		delete entry;
 		return;
 	}
 	
-	entry->setParent( this );
+	entry->setParent (this);
 	m_currentArchive << entry;
 }
 
 // =============================================================================
-void AddHistory::undo() const
-{
+void AddHistory::undo() const {
 	LDOpenFile* f = parent()->file();
-	LDObject* obj = f->object( index() );
-	f->forgetObject( obj );
+	LDObject* obj = f->object (index());
+	f->forgetObject (obj);
 	delete obj;
 	
 	g_fullRefresh = true;
 }
 
-void AddHistory::redo() const
-{
+void AddHistory::redo() const {
 	LDOpenFile* f = parent()->file();
-	LDObject* obj = parseLine( code() );
-	f->insertObj( index(), obj );
-	g_win->R()->compileObject( obj );
+	LDObject* obj = parseLine (code());
+	f->insertObj (index(), obj);
+	g_win->R()->compileObject (obj);
 }
 
 AddHistory::~AddHistory() {}
 
 // =============================================================================
 // heh
-void DelHistory::undo() const
-{
+void DelHistory::undo() const {
 	LDOpenFile* f = parent()->file();
-	LDObject* obj = parseLine( code() );
-	f->insertObj( index(), obj );
-	g_win->R()->compileObject( obj );
+	LDObject* obj = parseLine (code());
+	f->insertObj (index(), obj);
+	g_win->R()->compileObject (obj);
 }
 
-void DelHistory::redo() const
-{
+void DelHistory::redo() const {
 	LDOpenFile* f = parent()->file();
-	LDObject* obj = f->object( index() );
-	f->forgetObject( obj );
+	LDObject* obj = f->object (index());
+	f->forgetObject (obj);
 	delete obj;
 	
 	g_fullRefresh = true;
@@ -176,33 +163,29 @@
 DelHistory::~DelHistory() {}
 
 // =============================================================================
-void EditHistory::undo() const
-{
-	LDObject* obj = g_curfile->object( index() );
-	LDObject* newobj = parseLine( oldCode() );
-	obj->replace( newobj );
-	g_win->R()->compileObject( newobj );
+void EditHistory::undo() const {
+	LDObject* obj = g_curfile->object (index());
+	LDObject* newobj = parseLine (oldCode());
+	obj->replace (newobj);
+	g_win->R()->compileObject (newobj);
 }
 
-void EditHistory::redo() const
-{
-	LDObject* obj = g_curfile->object( index() );
-	LDObject* newobj = parseLine( newCode() );
-	obj->replace( newobj );
-	g_win->R()->compileObject( newobj );
+void EditHistory::redo() const {
+	LDObject* obj = g_curfile->object (index());
+	LDObject* newobj = parseLine (newCode());
+	obj->replace (newobj);
+	g_win->R()->compileObject (newobj);
 }
 
 EditHistory::~EditHistory() {}
 
 // =============================================================================
 
-void SwapHistory::undo() const
-{
-	LDObject::fromID( a )->swap( LDObject::fromID( b ));
+void SwapHistory::undo() const {
+	LDObject::fromID (a)->swap (LDObject::fromID (b));
 }
 
-void SwapHistory::redo() const
-{
+void SwapHistory::redo() const {
 	undo(); // :v
 }
 
--- a/src/ldtypes.cpp	Wed Jul 10 02:58:59 2013 +0300
+++ b/src/ldtypes.cpp	Sat Jul 13 17:35:38 2013 +0300
@@ -31,10 +31,9 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 // LDObject constructors
-LDObject::LDObject()
-{
+LDObject::LDObject() {
 	qObjListEntry = null;
-	setParent( null );
+	setParent (null);
 	m_hidden = false;
 	m_selected = false;
 	m_glinit = false;
@@ -42,94 +41,117 @@
 	// Determine ID
 	int id = 1; // 0 is invalid
 	
-	for( LDObject * obj : g_LDObjects )
-		if( obj->id() >= id )
+	for (LDObject* obj : g_LDObjects)
+		if (obj->id() >= id)
 			id = obj->id() + 1;
 	
-	setID( id );
-	
+	setID (id);
 	g_LDObjects << this;
 }
 
+// Default implementations for LDObject's virtual methods. These should never be
+// actually called, for a subclass-less LDObject should never come into existance.
+// These exist only to satisfy the linker.
+LDObject::Type LDObject::getType() const {
+	return LDObject::Unidentified;
+}
+
+bool LDObject::hasMatrix() const {
+	return false;
+}
+
+bool LDObject::isColored() const {
+	return false;
+}
+
+bool LDObject::isScemantic() const {
+	return false;
+}
+
+str LDObject::typeName() const {
+	return "";
+}
+
+short LDObject::vertices() const {
+	return 0;
+}
+
+// =============================================================================
+void LDObject::setVertexCoord (int i, Axis ax, double value) {
+	vertex v = getVertex (i);
+	v[ax] = value;
+	setVertex (i, v);
+}
+
 LDGibberish::LDGibberish() {}
-LDGibberish::LDGibberish( str contents, str reason ) : contents( contents ), reason( reason ) {}
+LDGibberish::LDGibberish (str contents, str reason) : contents (contents), reason (reason) {}
 
 // =============================================================================
-str LDComment::raw()
-{
-	return fmt( "0 %1", text );
+str LDComment::raw() {
+	return fmt ("0 %1", text);
 }
 
-str LDSubfile::raw()
-{
-	str val = fmt( "1 %1 %2 ", color(), position() );
+str LDSubfile::raw() {
+	str val = fmt ("1 %1 %2 ", color(), position());
 	val += transform().stringRep();
 	val += ' ';
 	val += fileInfo()->name();
 	return val;
 }
 
-str LDLine::raw()
-{
-	str val = fmt( "2 %1", color() );
+str LDLine::raw() {
+	str val = fmt ("2 %1", color());
 	
-	for( ushort i = 0; i < 2; ++i )
-		val += fmt( " %1", getVertex( i ) );
+	for (ushort i = 0; i < 2; ++i)
+		val += fmt (" %1", getVertex (i));
 	
 	return val;
 }
 
-str LDTriangle::raw()
-{
-	str val = fmt( "3 %1", color() );
+str LDTriangle::raw() {
+	str val = fmt ("3 %1", color());
 	
-	for( ushort i = 0; i < 3; ++i )
-		val += fmt( " %1", getVertex( i ) );
+	for (ushort i = 0; i < 3; ++i)
+		val += fmt (" %1", getVertex (i));
 	
 	return val;
 }
 
-str LDQuad::raw()
-{
-	str val = fmt( "4 %1", color() );
+str LDQuad::raw() {
+	str val = fmt ("4 %1", color());
 	
-	for( ushort i = 0; i < 4; ++i )
-		val += fmt( " %1", getVertex( i ) );
+	for (ushort i = 0; i < 4; ++i)
+		val += fmt (" %1", getVertex (i));
 	
 	return val;
 }
 
-str LDCondLine::raw()
-{
-	str val = fmt( "5 %1", color() );
+str LDCondLine::raw() {
+	str val = fmt ("5 %1", color());
 	
 	// Add the coordinates
-	for( ushort i = 0; i < 4; ++i )
-		val += fmt( " %1", getVertex( i ) );
+	for (ushort i = 0; i < 4; ++i)
+		val += fmt (" %1", getVertex (i));
 	
 	return val;
 }
 
-str LDGibberish::raw()
-{
+str LDGibberish::raw() {
 	return contents;
 }
 
-str LDVertex::raw()
-{
-	return fmt( "0 !LDFORGE VERTEX %1 %2", color(), pos );
+str LDVertex::raw() {
+	return fmt ("0 !LDFORGE VERTEX %1 %2", color(), pos);
 }
 
-str LDEmpty::raw()
-{
+str LDEmpty::raw() {
 	return "";
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-const char* LDBFC::statements[] =
-{
+const char* LDBFC::statements[] = {
 	"CERTIFY CCW",
 	"CCW",
 	"CERTIFY CW",
@@ -138,28 +160,26 @@
 	"INVERTNEXT",
 };
 
-str LDBFC::raw()
-{
-	return fmt( "0 BFC %1", LDBFC::statements[type] );
+str LDBFC::raw() {
+	return fmt ("0 BFC %1", LDBFC::statements[type]);
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-vector<LDTriangle*> LDQuad::splitToTriangles()
-{
+vector<LDTriangle*> LDQuad::splitToTriangles() {
 	// Create the two triangles based on this quadrilateral:
-	// 0---3     0---3    3
-	// |   |     |  /    /|
-	// |   |  =  | /    / |
-	// |   |     |/    /  |
-	// 1---2     1    1---2
-	LDTriangle* tri1 = new LDTriangle( getVertex( 0 ), getVertex( 1 ), getVertex( 3 ) );
-	LDTriangle* tri2 = new LDTriangle( getVertex( 1 ), getVertex( 2 ), getVertex( 3 ) );
+	// 0---3       0---3    3
+	// |   |       |  /    /|
+	// |   |  ==>  | /    / |
+	// |   |       |/    /  |
+	// 1---2       1    1---2
+	LDTriangle* tri1 = new LDTriangle (getVertex (0), getVertex (1), getVertex (3));
+	LDTriangle* tri2 = new LDTriangle (getVertex (1), getVertex (2), getVertex (3));
 	
 	// The triangles also inherit the quad's color
-	tri1->setColor( color() );
-	tri2->setColor( color() );
+	tri1->setColor (color());
+	tri2->setColor (color());
 	
 	vector<LDTriangle*> triangles;
 	triangles << tri1;
@@ -170,13 +190,12 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-void LDObject::replace( LDObject* replacement )
-{
-	long idx = getIndex( g_curfile );
-	assert( idx != -1 );
+void LDObject::replace (LDObject* other) {
+	long idx = getIndex (g_curfile);
+	assert (idx != -1);
 	
 	// Replace the instance of the old object with the new object
-	g_curfile->setObject( idx, replacement );
+	g_curfile->setObject (idx, other);
 	
 	// Remove the old object
 	delete this;
@@ -185,143 +204,126 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-void LDObject::swap( LDObject* other )
-{
-	for( LDObject*& obj : *g_curfile )
-	{
-		if( obj == this )
+void LDObject::swap (LDObject* other) {
+	for (LDObject*& obj : *g_curfile) {
+		if (obj == this)
 			obj = other;
-		elif( obj == other )
+		elif (obj == other)
 			obj = this;
 	}
-	
-	g_curfile->addToHistory( new SwapHistory( id(), other->id() ));
+
+	g_curfile->addToHistory (new SwapHistory (id(), other->id()));
 }
 
-LDLine::LDLine( vertex v1, vertex v2 )
-{
-	setVertex( 0, v1 );
-	setVertex( 1, v2 );
+LDLine::LDLine (vertex v1, vertex v2) {
+	setVertex (0, v1);
+	setVertex (1, v2);
 }
 
-LDObject::~LDObject()
-{
+LDObject::~LDObject() {
 	// Remove this object from the selection array if it is there.
-	for( ulong i = 0; i < g_win->sel().size(); ++i )
-		if( g_win->sel()[i] == this )
-			g_win->sel().erase( i );
+	for (ulong i = 0; i < g_win->sel().size(); ++i)
+		if (g_win->sel() [i] == this)
+			g_win->sel().erase (i);
 	
 	// Delete the GL lists
-	GL::deleteLists( this );
+	GL::deleteLists (this);
 	
 	// Remove this object from the list of LDObjects
-	ulong pos = g_LDObjects.find( this );
+	ulong pos = g_LDObjects.find (this);
 	
-	if( pos < g_LDObjects.size() )
-		g_LDObjects.erase( pos );
+	if (pos < g_LDObjects.size())
+		g_LDObjects.erase (pos);
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-static void transformObject( LDObject* obj, matrix transform, vertex pos, short parentcolor )
-{
-	switch( obj->getType() )
-	{
+static void transformObject (LDObject* obj, matrix transform, vertex pos, short parentcolor) {
+	switch (obj->getType()) {
 	case LDObject::Line:
 	case LDObject::CondLine:
 	case LDObject::Triangle:
 	case LDObject::Quad:
-		for( short i = 0; i < obj->vertices(); ++i )
-		{
-			vertex v = obj->getVertex( i );
-			v.transform( transform, pos );
-			obj->setVertex( i, v );
+		for (short i = 0; i < obj->vertices(); ++i) {
+			vertex v = obj->getVertex (i);
+			v.transform (transform, pos);
+			obj->setVertex (i, v);
 		}
+
 		break;
-	
+
 	case LDObject::Subfile:
 		{
-			LDSubfile* ref = static_cast<LDSubfile*>( obj );
+			LDSubfile* ref = static_cast<LDSubfile*> (obj);
 			matrix newMatrix = transform * ref->transform();
 			vertex newpos = ref->position();
 			
-			newpos.transform( transform, pos );
-			ref->setPosition( newpos );
-			ref->setTransform( newMatrix );
+			newpos.transform (transform, pos);
+			ref->setPosition (newpos);
+			ref->setTransform (newMatrix);
 		}
 		break;
-	
+
 	default:
 		break;
 	}
 	
-	if( obj->color() == maincolor )
-		obj->setColor( parentcolor );
+	if (obj->color() == maincolor)
+		obj->setColor (parentcolor);
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-vector<LDObject*> LDSubfile::inlineContents( bool deep, bool cache )
-{
+vector<LDObject*> LDSubfile::inlineContents (bool deep, bool cache) {
 	vector<LDObject*> objs, objcache;
-	
+
 	// If we have this cached, just clone that
-	if( deep && fileInfo()->cache().size() )
-	{
-		for( LDObject * obj : fileInfo()->cache() )
+	if (deep && fileInfo()->cache().size()) {
+		for (LDObject* obj : fileInfo()->cache())
 			objs << obj->clone();
-	}
-	else
-	{
-		if( !deep )
+	} else {
+		if (!deep)
 			cache = false;
-
-		for( LDObject * obj : *fileInfo() )
-		{
+		
+		for (LDObject* obj : *fileInfo()) {
 			// Skip those without scemantic meaning
-			if( !obj->isScemantic() )
+			if (!obj->isScemantic())
 				continue;
 			
 			// Got another sub-file reference, inline it if we're deep-inlining. If not,
 			// just add it into the objects normally. Also, we only cache immediate
 			// subfiles and this is not one. Yay, recursion!
-			if( deep && obj->getType() == LDObject::Subfile )
-			{
-				LDSubfile* ref = static_cast<LDSubfile*>( obj );
+			if (deep && obj->getType() == LDObject::Subfile) {
+				LDSubfile* ref = static_cast<LDSubfile*> (obj);
 				
-				vector<LDObject*> otherobjs = ref->inlineContents( true, false );
+				vector<LDObject*> otherobjs = ref->inlineContents (true, false);
 				
-				for( LDObject * otherobj : otherobjs )
-				{
+				for (LDObject* otherobj : otherobjs) {
 					// Cache this object, if desired
-					if( cache )
+					if (cache)
 						objcache << otherobj->clone();
 					
 					objs << otherobj;
 				}
-			}
-			else
-			{
-				if( cache )
+			} else {
+				if (cache)
 					objcache << obj->clone();
 				
 				objs << obj->clone();
 			}
 		}
 		
-		if( cache )
-			fileInfo()->setCache( objcache );
+		if (cache)
+			fileInfo()->setCache (objcache);
 	}
 	
 	// Transform the objects
-	for( LDObject * obj : objs )
-	{
+	for (LDObject* obj : objs) {
 		// Set the parent now so we know what inlined this.
-		obj->setParent( this );
-		
-		transformObject( obj, transform(), position(), color() );
+		obj->setParent (this);
+		transformObject (obj, transform(), position(), color());
 	}
 	
 	return objs;
@@ -330,10 +332,9 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-long LDObject::getIndex( LDOpenFile* file ) const
-{
-	for( ulong i = 0; i < file->numObjs(); ++i )
-		if( file->obj( i ) == this )
+long LDObject::getIndex (LDOpenFile* file) const {
+	for (ulong i = 0; i < file->numObjs(); ++i)
+		if (file->obj (i) == this)
 			return i;
 	
 	return -1;
@@ -342,47 +343,43 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-void LDObject::moveObjects( vector<LDObject*> objs, const bool up )
-{
+void LDObject::moveObjects (vector<LDObject*> objs, const bool up) {
 	// If we move down, we need to iterate the array in reverse order.
-	const long start = up ? 0 : ( objs.size() - 1 );
+	const long start = up ? 0 : (objs.size() - 1);
 	const long end = up ? objs.size() : -1;
 	const long incr = up ? 1 : -1;
 	vector<LDObject*> objsToCompile;
 	
-	for( long i = start; i != end; i += incr )
-	{
+	for (long i = start; i != end; i += incr) {
 		LDObject* obj = objs[i];
 		
-		const long idx = obj->getIndex( g_curfile ),
-				   target = idx + ( up ? -1 : 1 );
+		const long idx = obj->getIndex (g_curfile),
+			target = idx + (up ? -1 : 1);
 		
-		if(( up && idx == 0 ) || ( !up && idx == (long) ( g_curfile->objs().size() - 1 )) )
-		{
+		if ((up && idx == 0) || (!up && idx == (long) (g_curfile->objs().size() - 1))) {
 			// One of the objects hit the extrema. If this happens, this should be the first
 			// object to be iterated on. Thus, nothing has changed yet and it's safe to just
 			// abort the entire operation.
-			assert( i == start );
+			assert (i == start);
 			return;
 		}
 		
 		objsToCompile << obj;
-		objsToCompile << g_curfile->obj( target );
+		objsToCompile << g_curfile->obj (target);
 		
-		obj->swap( g_curfile->obj( target ) );
+		obj->swap (g_curfile->obj (target));
 	}
 	
 	objsToCompile.makeUnique();
 	
 	// The objects need to be recompiled, otherwise their pick lists are left with
 	// the wrong index colors which messes up selection.
-	for( LDObject * obj : objsToCompile )
-		g_win->R()->compileObject( obj );
+	for (LDObject* obj : objsToCompile)
+		g_win->R()->compileObject (obj);
 }
 
-str LDObject::typeName( LDObject::Type type )
-{
-	LDObject* obj = LDObject::getDefault( type );
+str LDObject::typeName (LDObject::Type type) {
+	LDObject* obj = LDObject::getDefault (type);
 	str name = obj->typeName();
 	delete obj;
 	return name;
@@ -391,36 +388,34 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-str LDObject::objectListContents( const vector<LDObject*>& objs )
-{
+str LDObject::objectListContents (const vector<LDObject*>& objs) {
 	bool firstDetails = true;
 	str text = "";
 	
-	if( objs.size() == 0 )
+	if (objs.size() == 0)
 		return "nothing"; // :)
 	
-	for( long i = 0; i < LDObject::NumTypes; ++i )
-	{
-		LDObject::Type objType = ( LDObject::Type ) i;
+	for (long i = 0; i < LDObject::NumTypes; ++i) {
+		LDObject::Type objType = (LDObject::Type) i;
 		ulong objCount = 0;
 		
-		for( LDObject * obj : objs )
-			if( obj->getType() == objType )
+		for (LDObject* obj : objs)
+			if (obj->getType() == objType)
 				objCount++;
 		
-		if( objCount == 0 )
+		if (objCount == 0)
 			continue;
 		
-		if( !firstDetails )
+		if (!firstDetails)
 			text += ", ";
 		
-		str noun = fmt( "%1%2", typeName( objType ), plural( objCount ) );
+		str noun = fmt ("%1%2", typeName (objType), plural (objCount));
 		
 		// Plural of "vertex" is "vertices". Stupid English.
-		if( objType == LDObject::Vertex && objCount != 1 )
+		if (objType == LDObject::Vertex && objCount != 1)
 			noun = "vertices";
 		
-		text += fmt( "%1 %2", objCount, noun );
+		text += fmt ("%1 %2", objCount, noun);
 		firstDetails = false;
 	}
 	
@@ -428,84 +423,75 @@
 }
 
 // =============================================================================
-LDObject* LDObject::topLevelParent()
-{
-	if( !parent() )
+LDObject* LDObject::topLevelParent() {
+	if (!parent())
 		return this;
 	
 	LDObject* it = this;
-	
-	while( it->parent() )
+		
+	while (it->parent())
 		it = it->parent();
-	
+
 	return it;
 }
 
 // =============================================================================
-LDObject* LDObject::next() const
-{
-	long idx = getIndex( g_curfile );
-	assert( idx != -1 );
+LDObject* LDObject::next() const {
+	long idx = getIndex (g_curfile);
+	assert (idx != -1);
 	
-	if( idx == ( long ) g_curfile->numObjs() - 1 )
+	if (idx == (long) g_curfile->numObjs() - 1)
 		return null;
 	
-	return g_curfile->obj( idx + 1 );
+	return g_curfile->obj (idx + 1);
 }
 
 // =============================================================================
-LDObject* LDObject::prev() const
-{
-	long idx = getIndex( g_curfile );
-	assert( idx != -1 );
+LDObject* LDObject::prev() const {
+	long idx = getIndex (g_curfile);
+	assert (idx != -1);
 	
-	if( idx == 0 )
+	if (idx == 0)
 		return null;
 	
-	return g_curfile->obj( idx - 1 );
+	return g_curfile->obj (idx - 1);
 }
 
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-void LDObject::move( vertex vect ) { (void) vect; }
-void LDEmpty::move( vertex vect ) { (void) vect; }
-void LDBFC::move( vertex vect ) { (void) vect; }
-void LDComment::move( vertex vect ) { (void) vect; }
-void LDGibberish::move( vertex vect ) { (void) vect; }
+void LDObject::move (vertex vect)    { (void) vect; }
+void LDEmpty::move (vertex vect)     { (void) vect; }
+void LDBFC::move (vertex vect)       { (void) vect; }
+void LDComment::move (vertex vect)   { (void) vect; }
+void LDGibberish::move (vertex vect) { (void) vect; }
 
-void LDVertex::move( vertex vect )
-{
+void LDVertex::move (vertex vect) {
 	pos += vect;
 }
 
-void LDSubfile::move( vertex vect )
-{
-	setPosition( position() + vect );
+void LDSubfile::move (vertex vect) {
+	setPosition (position() + vect);
 }
 
-void LDLine::move( vertex vect )
-{
-	for( short i = 0; i < 2; ++i )
-		setVertex( i, getVertex( i ) + vect );
+void LDLine::move (vertex vect) {
+	for (short i = 0; i < 2; ++i)
+		setVertex (i, getVertex (i) + vect);
 }
 
-void LDTriangle::move( vertex vect )
-{
-	for( short i = 0; i < 3; ++i )
-		setVertex( i, getVertex( i ) + vect );
+void LDTriangle::move (vertex vect) {
+	for (short i = 0; i < 3; ++i)
+		setVertex (i, getVertex (i) + vect);
 }
 
-void LDQuad::move( vertex vect )
-{
-	for( short i = 0; i < 4; ++i )
-		setVertex( i, getVertex( i ) + vect );
+void LDQuad::move (vertex vect) {
+	for (short i = 0; i < 4; ++i)
+		setVertex (i, getVertex (i) + vect);
 }
 
-void LDCondLine::move( vertex vect )
-{
-	for( short i = 0; i < 4; ++i )
-		setVertex( i, getVertex( i ) + vect );
+void LDCondLine::move (vertex vect) {
+	for (short i = 0; i < 4; ++i)
+		setVertex (i, getVertex (i) + vect);
 }
 
 // =============================================================================
@@ -515,20 +501,19 @@
 	if( type == LDObject::N ) \
 		return new LD##N;
 
-LDObject* LDObject::getDefault( const LDObject::Type type )
-{
-	CHECK_FOR_OBJ( Comment )
-	CHECK_FOR_OBJ( BFC )
-	CHECK_FOR_OBJ( Line )
-	CHECK_FOR_OBJ( CondLine )
-	CHECK_FOR_OBJ( Subfile )
-	CHECK_FOR_OBJ( Triangle )
-	CHECK_FOR_OBJ( Quad )
-	CHECK_FOR_OBJ( Empty )
-	CHECK_FOR_OBJ( BFC )
-	CHECK_FOR_OBJ( Gibberish )
-	CHECK_FOR_OBJ( Vertex )
-	CHECK_FOR_OBJ( Overlay )
+LDObject* LDObject::getDefault (const LDObject::Type type) {
+	CHECK_FOR_OBJ (Comment)
+	CHECK_FOR_OBJ (BFC)
+	CHECK_FOR_OBJ (Line)
+	CHECK_FOR_OBJ (CondLine)
+	CHECK_FOR_OBJ (Subfile)
+	CHECK_FOR_OBJ (Triangle)
+	CHECK_FOR_OBJ (Quad)
+	CHECK_FOR_OBJ (Empty)
+	CHECK_FOR_OBJ (BFC)
+	CHECK_FOR_OBJ (Gibberish)
+	CHECK_FOR_OBJ (Vertex)
+	CHECK_FOR_OBJ (Overlay)
 	return null;
 }
 
@@ -541,166 +526,146 @@
 void LDComment::invert() {}
 void LDGibberish::invert() {}
 
-void LDTriangle::invert()
-{
+void LDTriangle::invert() {
 	// Triangle goes 0 -> 1 -> 2, reversed: 0 -> 2 -> 1.
 	// Thus, we swap 1 and 2.
-	vertex tmp = getVertex( 1 );
-	setVertex( 1, getVertex( 2 ) );
-	setVertex( 2, tmp );
-	
+	vertex tmp = getVertex (1);
+	setVertex (1, getVertex (2));
+	setVertex (2, tmp);
+
 	return;
 }
 
-void LDQuad::invert()
-{
+void LDQuad::invert() {
 	// Quad: 0 -> 1 -> 2 -> 3
 	// rev:  0 -> 3 -> 2 -> 1
 	// Thus, we swap 1 and 3.
-	vertex tmp = getVertex( 1 );
-	setVertex( 1, getVertex( 3 ) );
-	setVertex( 3, tmp );
+	vertex tmp = getVertex (1);
+	setVertex (1, getVertex (3));
+	setVertex (3, tmp);
 }
 
-void LDSubfile::invert()
-{
+void LDSubfile::invert() {
 	// Subfiles are inverted when they're prefixed with
 	// a BFC INVERTNEXT statement. Thus we need to toggle this status.
 	// For flat primitives it's sufficient that the determinant is
 	// flipped but I don't have a method for checking flatness yet.
 	// Food for thought...
 	
-	ulong idx = getIndex( g_curfile );
+	ulong idx = getIndex (g_curfile);
 	
-	if( idx > 0 )
-	{
-		LDBFC* bfc = dynamic_cast<LDBFC*>( prev() );
+	if (idx > 0) {
+		LDBFC* bfc = dynamic_cast<LDBFC*> (prev());
 		
-		if( bfc && bfc->type == LDBFC::InvertNext )
-		{
+		if (bfc && bfc->type == LDBFC::InvertNext) {
 			// This is prefixed with an invertnext, thus remove it.
-			g_curfile->forgetObject( bfc );
+			g_curfile->forgetObject (bfc);
 			delete bfc;
 			return;
 		}
 	}
 	
 	// Not inverted, thus prefix it with a new invertnext.
-	LDBFC* bfc = new LDBFC( LDBFC::InvertNext );
-	g_curfile->insertObj( idx, bfc );
+	LDBFC* bfc = new LDBFC (LDBFC::InvertNext);
+	g_curfile->insertObj (idx, bfc);
 }
 
-static void invertLine( LDObject* line )
-{
+static void invertLine (LDObject* line) {
 	// For lines, we swap the vertices. I don't think that a
 	// cond-line's control points need to be swapped, do they?
-	vertex tmp = line->getVertex( 0 );
-	line->setVertex( 0, line->getVertex( 1 ) );
-	line->setVertex( 1, tmp );
+	vertex tmp = line->getVertex (0);
+	line->setVertex (0, line->getVertex (1));
+	line->setVertex (1, tmp);
 }
 
-void LDLine::invert()
-{
-	invertLine( this );
+void LDLine::invert() {
+	invertLine (this);
 }
 
-void LDCondLine::invert()
-{
-	invertLine( this );
+void LDCondLine::invert() {
+	invertLine (this);
 }
 
 void LDVertex::invert() {}
 
 // =============================================================================
-LDLine* LDCondLine::demote()
-{
+LDLine* LDCondLine::demote() {
 	LDLine* repl = new LDLine;
 	
-	for( int i = 0; i < repl->vertices(); ++i )
-		repl->setVertex( i, getVertex( i ) );
+	for (int i = 0; i < repl->vertices(); ++i)
+		repl->setVertex (i, getVertex (i));
 	
-	repl->setColor( color() );
+	repl->setColor (color());
 	
-	replace( repl );
+	replace (repl);
 	return repl;
 }
 
-LDObject* LDObject::fromID( int id )
-{
-	for( LDObject * obj : g_LDObjects )
-		if( obj->id() == id )
+LDObject* LDObject::fromID (int id) {
+	for (LDObject* obj : g_LDObjects)
+		if (obj->id() == id)
 			return obj;
 	
 	return null;
 }
 
 // =============================================================================
-str LDOverlay::raw()
-{
-	return fmt( "0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6",
-		filename(), camera(), x(), y(), width(), height() );
+str LDOverlay::raw() {
+	return fmt ("0 !LDFORGE OVERLAY %1 %2 %3 %4 %5 %6",
+		filename(), camera(), x(), y(), width(), height());
 }
 
-void LDOverlay::move( vertex vect )
-{
-	Q_UNUSED( vect )
+void LDOverlay::move (vertex vect) {
+	Q_UNUSED (vect)
 }
 
 void LDOverlay::invert() {}
 
 // =============================================================================
-template<class T> void changeProperty( LDObject* obj, T* ptr, const T& val )
-{
+// Hook the set accessors of certain properties to this changeProperty function.
+// It takes care of history management so we can capture low-level changes, this
+// makes history stuff work out of the box.
+template<class T> void changeProperty (LDObject* obj, T* ptr, const T& val) {
 	long idx;
 	
-	if(( idx = obj->getIndex( g_curfile )) != -1 )
-	{
+	if ((idx = obj->getIndex (g_curfile)) != -1) {
 		str before = obj->raw();
 		*ptr = val;
 		str after = obj->raw();
-
-		g_curfile->addToHistory( new EditHistory( idx, before, after ) );
-	}
-	else
+		
+		g_curfile->addToHistory (new EditHistory (idx, before, after));
+	} else
 		*ptr = val;
 }
 
-READ_ACCESSOR( short, LDObject::color )
-{
+READ_ACCESSOR (short, LDObject::color) {
 	return m_color;
 }
 
-SET_ACCESSOR( short, LDObject::setColor )
-{
-	changeProperty( this, &m_color, val );
+SET_ACCESSOR (short, LDObject::setColor) {
+	changeProperty (this, &m_color, val);
 }
 
-const vertex& LDObject::getVertex( int i ) const
-{
+const vertex& LDObject::getVertex (int i) const {
 	return m_coords[i];
 }
 
-void LDObject::setVertex( int i, const vertex& vert )
-{
-	changeProperty( this, &m_coords[i], vert );
+void LDObject::setVertex (int i, const vertex& vert) {
+	changeProperty (this, &m_coords[i], vert);
 }
 
-READ_ACCESSOR( vertex, LDMatrixObject::position )
-{
+READ_ACCESSOR (vertex, LDMatrixObject::position) {
 	return m_position;
 }
 
-SET_ACCESSOR( vertex, LDMatrixObject::setPosition )
-{
-	changeProperty( linkPointer(), &m_position, val );
+SET_ACCESSOR (vertex, LDMatrixObject::setPosition) {
+	changeProperty (linkPointer(), &m_position, val);
 }
 
-READ_ACCESSOR( matrix, LDMatrixObject::transform )
-{
+READ_ACCESSOR (matrix, LDMatrixObject::transform) {
 	return m_transform;
 }
 
-SET_ACCESSOR( matrix, LDMatrixObject::setTransform )
-{
-	changeProperty( linkPointer(), &m_transform, val );
+SET_ACCESSOR (matrix, LDMatrixObject::setTransform) {
+	changeProperty (linkPointer(), &m_transform, val);
 }
\ No newline at end of file
--- a/src/ldtypes.h	Wed Jul 10 02:58:59 2013 +0300
+++ b/src/ldtypes.h	Sat Jul 13 17:35:38 2013 +0300
@@ -1,17 +1,17 @@
 /*
  *  LDForge: LDraw parts authoring CAD
  *  Copyright (C) 2013 Santeri Piippo
- *  
+ *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
- *  
+ *
  *  This program is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *  
+ *
  *  You should have received a copy of the GNU General Public License
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@ -23,16 +23,16 @@
 #include "types.h"
 
 #define LDOBJ(T) \
-	virtual ~LD##T () {} \
-	virtual LDObject::Type getType () const override { \
+	virtual ~LD##T() {} \
+	virtual LDObject::Type getType() const override { \
 		return LDObject::T; \
 	} \
-	virtual str raw (); \
-	virtual LD##T* clone () { \
+	virtual str raw(); \
+	virtual LD##T* clone() { \
 		return new LD##T (*this); \
 	} \
 	virtual void move (vertex vVector); \
-	virtual void invert ();
+	virtual void invert();
 
 #define LDOBJ_NAME( N )        virtual str typeName() const override { return #N; }
 #define LDOBJ_VERTICES( V )    virtual short vertices() const override { return V; }
@@ -52,33 +52,9 @@
 class LDSubfile;
 
 // =============================================================================
-// LDMatrixObject
-// 
-// Common code for objects with matrices
-// =============================================================================
-class LDMatrixObject {
-	DECLARE_PROPERTY (matrix, transform, setTransform)
-	DECLARE_PROPERTY (vertex, position, setPosition)
-	PROPERTY (LDObject*, linkPointer, setLinkPointer)
-	
-public:
-	LDMatrixObject () {}
-	LDMatrixObject (const matrix& transform, const vertex& pos) :
-		PROP_NAME (transform) (transform), PROP_NAME (position) (pos) {}
-	
-	const double& setCoordinate (const Axis ax, double value) {
-		vertex v = position ();
-		v[ax] = value;
-		setPosition (v);
-		
-		return position ()[ax];
-	}
-};
-
-// =============================================================================
 // LDObject
-// 
-// Base class object for all LD* types. Each LDObject represents a single line
+//
+// Base class object for all object types. Each LDObject represents a single line
 // in the LDraw code file. The virtual method getType returns an enumerator
 // which is a token of the object's type. The object can be casted into
 // sub-classes based on this enumerator.
@@ -89,7 +65,7 @@
 	PROPERTY (LDObject*, parent, setParent)
 	READ_PROPERTY (int, id, setID)
 	DECLARE_PROPERTY (short, color, setColor)
-	
+
 public:
 	// Object type codes. Codes are sorted in order of significance.
 	enum Type {
@@ -107,84 +83,86 @@
 		Unidentified,   // Object is an uninitialized (SHOULD NEVER HAPPEN)
 		NumTypes        // Amount of object types
 	};
-	
-	LDObject ();
-	virtual ~LDObject ();
+
+	LDObject();
+	virtual ~LDObject();
 	
-	// Index (i.e. line number) of this object
-	long getIndex (LDOpenFile* pFile) const;
+	virtual LDObject* clone() {return 0;}      // Creates a new LDObject identical to this one.
+	long getIndex (LDOpenFile* file) const;     // Index (i.e. line number) of this object
+	virtual LDObject::Type getType() const;    // Type enumerator of this object
+	const vertex& getVertex (int i) const;      // Get a vertex by index
+	virtual bool hasMatrix() const;            // Does this object have a matrix and position? (see LDMatrixObject)
+	virtual void invert();                     // Inverts this object (winding is reversed)
+	virtual bool isColored() const;            // Is this object colored?
+	virtual bool isScemantic() const;          // Does this object have meaning in the part model?
+	virtual void move (vertex vect);            // Moves this object using the given vertex as a movement vector
+	LDObject* next() const;                    // Object after this in the current file
+	LDObject* prev() const;                    // Object prior to this in the current file
+	virtual str raw() { return ""; }           // This object as LDraw code
+	void replace (LDObject* other);             // Replace this LDObject with another LDObject. Object is deleted in the process.
+	void setVertex (int i, const vertex& vert); // Set a vertex to the given value
+	void setVertexCoord (int i, Axis ax, double value); // Set a single coordinate of a vertex
+	void swap (LDObject* other);                // Swap this object with another.
+	LDObject* topLevelParent();                // What object in the current file ultimately references this?
+	virtual str typeName() const;               // Type name of this object
+	virtual short vertices() const;            // Number of vertices this object has
 	
+	static str typeName (LDObject::Type type); // Get type name by enumerator
+	static LDObject* getDefault (const LDObject::Type type); // Returns a sample object by the given enumerator
+	static void moveObjects (vector<LDObject*> objs, const bool up); // TODO: move this to LDOpenFile?
+	static str objectListContents (const vector<LDObject*>& objs); // Get a description of a list of LDObjects
+	static LDObject* fromID (int id);
+	
+	// TODO: make these private!
 	// OpenGL list for this object
 	uint glLists[4];
 	
-	// Type enumerator of this object
-	virtual LDObject::Type getType () const {
-		return LDObject::Unidentified;
-	};
-	
-	// A string that represents this line
-	virtual str raw () {
-		return "";
-	}
-	
-	// Creates a new LDObject identical to this one and returns a pointer to it.
-	virtual LDObject* clone () {
-		return new LDObject (*this);
-	}
-	
-	// Replace this LDObject with another LDObject. This method deletes the
-	// object and any pointers to it become invalid.
-	void replace (LDObject* replacement);
-	
-	// Swap this object with another.
-	void swap (LDObject* other);
-	
-	// Moves this object using the given vertex as a movement vector
-	virtual void move (vertex vect);
-	
-	// What object in the current file ultimately references this?
-	LDObject* topLevelParent ();
-	
-	// Number of vertices this object has
-	virtual short vertices () const { return 0; }
-	
-	// Is this object colored?
-	virtual bool isColored () const { return false; }
-	
-	// Does this object have meaning in the part model?
-	virtual bool isScemantic () const { return false; }
-	
-	// Type name of this object
-	virtual str typeName() const { return "unknown"; }
-	static str typeName( LDObject::Type type );
-	
-	// Returns a sample object by the given value
-	static LDObject* getDefault (const LDObject::Type type);
-	
-	static void moveObjects (vector<LDObject*> objs, const bool bUp);
-	static str objectListContents (const vector<LDObject*>& objs);
-	static LDObject* fromID( int id );
-	
 	// Object list entry for this object
 	QListWidgetItem* qObjListEntry;
-	
-	virtual bool        hasMatrix       () const { return false; }
-	virtual void        invert          ();
-	LDObject*           next            () const;
-	LDObject*           prev            () const;
-	void                setVertex       (int i, const vertex& vert);
-	const vertex&       getVertex       (int i) const;
-	void                setVertexCoord  (int i, const Axis ax, double value);
 
 protected:
 	bool m_glinit;
 	friend class GLRenderer;
-	
+
 private:
 	vertex m_coords[4];
 };
 
 // =============================================================================
+// LDMatrixObject
+// =============================================================================
+//
+// Common code for objects with matrices. This class is multiple-derived in
+// and thus not used directly other than as a common storage point for matrices
+// and vertices.
+//
+// The link pointer is a pointer to this object's LDObject self - since this is
+// multiple-derived in, static_cast or dynamic_cast won't budge here.
+//
+// In 0.1-alpha, there was a separate 'radial' type which had a position and
+// matrix as well. Even though right now only LDSubfile uses this, I'm keeping
+// this class distinct in case I get new extension ideas. :)
+// =============================================================================
+class LDMatrixObject {
+	DECLARE_PROPERTY (matrix, transform, setTransform)
+	DECLARE_PROPERTY (vertex, position, setPosition)
+	PROPERTY (LDObject*, linkPointer, setLinkPointer)
+
+public:
+	LDMatrixObject() {}
+	LDMatrixObject (const matrix& transform, const vertex& pos) :
+		PROP_NAME (transform) (transform), PROP_NAME (position) (pos) {}
+
+	const double& setCoordinate (const Axis ax, double value) {
+		vertex v = position();
+		v[ax] = value;
+		setPosition (v);
+
+		return position() [ax];
+	}
+};
+
+// =============================================================================
 // LDGibberish
 //
 // Represents a line in the LDraw file that could not be properly parsed. It is
@@ -195,25 +173,25 @@
 class LDGibberish : public LDObject {
 public:
 	LDOBJ (Gibberish)
-	LDOBJ_NAME( error )
+	LDOBJ_NAME (error)
 	LDOBJ_VERTICES (0)
 	LDOBJ_UNCOLORED
 	LDOBJ_SCEMANTIC
 	LDOBJ_NO_MATRIX
-	
-	LDGibberish ();
+
+	LDGibberish();
 	LDGibberish (str _zContent, str _zReason);
-	
+
 	// Content of this unknown line
 	str contents;
-	
+
 	// Why is this gibberish?
 	str reason;
 };
 
 // =============================================================================
-// LDEmptyLine 
-// 
+// LDEmptyLine
+//
 // Represents an empty line in the LDraw code file.
 // =============================================================================
 class LDEmpty : public LDObject {
@@ -228,47 +206,47 @@
 // =============================================================================
 // LDComment
 //
-// Represents a code-0 comment in the LDraw code file. Member zText contains
+// Represents a code-0 comment in the LDraw code file. Member text contains
 // the text of the comment.
 // =============================================================================
 class LDComment : public LDObject {
 public:
 	LDOBJ (Comment)
-	LDOBJ_NAME( comment )
+	LDOBJ_NAME (comment)
 	LDOBJ_VERTICES (0)
 	LDOBJ_UNCOLORED
 	LDOBJ_NON_SCEMANTIC
 	LDOBJ_NO_MATRIX
-	
-	LDComment () {}
+
+	LDComment() {}
 	LDComment (str text) : text (text) {}
-	
+
 	str text; // The text of this comment
 };
 
 // =============================================================================
 // LDBFC
-// 
+//
 // Represents a 0 BFC statement in the LDraw code. eStatement contains the type
 // of this statement.
 // =============================================================================
 class LDBFC : public LDObject {
 public:
 	enum Type { CertifyCCW, CCW, CertifyCW, CW, NoCertify, InvertNext, NumStatements };
-	
+
 	LDOBJ (BFC)
-	LDOBJ_NAME( bfc )
+	LDOBJ_NAME (bfc)
 	LDOBJ_VERTICES (0)
 	LDOBJ_UNCOLORED
 	LDOBJ_CUSTOM_SCEMANTIC { return (type == InvertNext); }
 	LDOBJ_NO_MATRIX
-	
-	LDBFC () {}
+
+	LDBFC() {}
 	LDBFC (const LDBFC::Type type) : type (type) {}
-	
+
 	// Statement strings
 	static const char* statements[];
-	
+
 	Type type;
 };
 
@@ -279,19 +257,19 @@
 // =============================================================================
 class LDSubfile : public LDObject, public LDMatrixObject {
 	PROPERTY (LDOpenFile*, fileInfo, setFileInfo)
-	
+
 public:
 	LDOBJ (Subfile)
-	LDOBJ_NAME( subfile )
+	LDOBJ_NAME (subfile)
 	LDOBJ_VERTICES (0)
 	LDOBJ_COLORED
 	LDOBJ_SCEMANTIC
 	LDOBJ_HAS_MATRIX
-	
-	LDSubfile () {
+
+	LDSubfile() {
 		setLinkPointer (this);
 	}
-	
+
 	// Inlines this subfile. Note that return type is an array of heap-allocated
 	// LDObject-clones, they must be deleted one way or another.
 	vector<LDObject*> inlineContents (bool deep, bool cache);
@@ -307,13 +285,13 @@
 class LDLine : public LDObject {
 public:
 	LDOBJ (Line)
-	LDOBJ_NAME( line )
+	LDOBJ_NAME (line)
 	LDOBJ_VERTICES (2)
 	LDOBJ_COLORED
 	LDOBJ_SCEMANTIC
 	LDOBJ_NO_MATRIX
-	
-	LDLine () {}
+
+	LDLine() {}
 	LDLine (vertex v1, vertex v2);
 };
 
@@ -326,14 +304,14 @@
 class LDCondLine : public LDLine {
 public:
 	LDOBJ (CondLine)
-	LDOBJ_NAME( condline )
+	LDOBJ_NAME (condline)
 	LDOBJ_VERTICES (4)
 	LDOBJ_COLORED
 	LDOBJ_SCEMANTIC
 	LDOBJ_NO_MATRIX
-	
-	LDCondLine () {}
-	LDLine* demote ();
+
+	LDCondLine() {}
+	LDLine* demote();
 };
 
 // =============================================================================
@@ -346,13 +324,13 @@
 class LDTriangle : public LDObject {
 public:
 	LDOBJ (Triangle)
-	LDOBJ_NAME( triangle )
+	LDOBJ_NAME (triangle)
 	LDOBJ_VERTICES (3)
 	LDOBJ_COLORED
 	LDOBJ_SCEMANTIC
 	LDOBJ_NO_MATRIX
-	
-	LDTriangle () {}
+
+	LDTriangle() {}
 	LDTriangle (vertex v0, vertex v1, vertex v2) {
 		setVertex (0, v0);
 		setVertex (1, v1);
@@ -369,21 +347,21 @@
 class LDQuad : public LDObject {
 public:
 	LDOBJ (Quad)
-	LDOBJ_NAME( quad )
+	LDOBJ_NAME (quad)
 	LDOBJ_VERTICES (4)
 	LDOBJ_COLORED
 	LDOBJ_SCEMANTIC
 	LDOBJ_NO_MATRIX
-	
-	LDQuad () {}
-	
+
+	LDQuad() {}
+
 	// Split this quad into two triangles (note: heap-allocated)
-	vector<LDTriangle*> splitToTriangles ();
+	vector<LDTriangle*> splitToTriangles();
 };
 
 // =============================================================================
 // LDVertex
-// 
+//
 // The vertex is an LDForce-specific extension which represents a single
 // vertex which can be used as a parameter to tools or to store coordinates
 // with. Vertices are a part authoring tool and they should not appear in
@@ -392,38 +370,37 @@
 class LDVertex : public LDObject {
 public:
 	LDOBJ (Vertex)
-	LDOBJ_NAME( vertex )
+	LDOBJ_NAME (vertex)
 	LDOBJ_VERTICES (0) // TODO: move pos to vaCoords[0]
 	LDOBJ_COLORED
 	LDOBJ_NON_SCEMANTIC
 	LDOBJ_NO_MATRIX
-	
-	LDVertex () {}
-	
+
+	LDVertex() {}
+
 	vertex pos;
 };
 
 // =============================================================================
 // LDOverlay
-// 
+//
 // Overlay image meta, stored in the header of parts so as to preserve overlay
 // information.
 // =============================================================================
-class LDOverlay : public LDObject
-{
+class LDOverlay : public LDObject {
 public:
-	LDOBJ( Overlay )
-	LDOBJ_NAME( overlay )
-	LDOBJ_VERTICES( 0 )
+	LDOBJ (Overlay)
+	LDOBJ_NAME (overlay)
+	LDOBJ_VERTICES (0)
 	LDOBJ_UNCOLORED
 	LDOBJ_NON_SCEMANTIC
 	LDOBJ_NO_MATRIX
-	PROPERTY( int, camera, setCamera )
-	PROPERTY( int, x, setX )
-	PROPERTY( int, y, setY )
-	PROPERTY( int, width, setWidth )
-	PROPERTY( int, height, setHeight )
-	PROPERTY( str, filename, setFilename )
+	PROPERTY (int, camera, setCamera)
+	PROPERTY (int, x, setX)
+	PROPERTY (int, y, setY)
+	PROPERTY (int, width, setWidth)
+	PROPERTY (int, height, setHeight)
+	PROPERTY (str, filename, setFilename)
 };
 
 #endif // LDTYPES_H
\ No newline at end of file

mercurial