src/gui_editactions.cpp

changeset 376
4a89dd47535f
parent 369
0060d11e4991
child 377
271d1da66b7e
--- 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

mercurial