src/addObjectDialog.cc

changeset 733
cc39df788660
parent 662
2f1bd9112408
child 739
152b33a6d51b
--- a/src/addObjectDialog.cc	Wed Apr 23 15:39:42 2014 +0300
+++ b/src/addObjectDialog.cc	Wed Apr 23 18:25:09 2014 +0300
@@ -192,15 +192,17 @@
 		case LDObject::ECondLine:
 		case LDObject::ETriangle:
 		case LDObject::EQuad:
-
 			// Apply coordinates
-			if (obj)
+			if (obj != null)
 			{
 				for (int i = 0; i < coordCount / 3; ++i)
-					for (int j = 0; j < 3; ++j)
-						dsb_coords[ (i * 3) + j]->setValue (obj->vertex (i).getCoordinate (j));
+				{
+					obj->vertex (i).apply ([&](Axis ax, double value)
+					{
+						dsb_coords[(i * 3) + ax]->setValue (value);
+					});
+				}
 			}
-
 			break;
 
 		case LDObject::EComment:
@@ -230,10 +232,12 @@
 		// le_matrix->setValidator (new QDoubleValidator);
 		Matrix defaultMatrix = g_identity;
 
-		if (mo)
+		if (mo != null)
 		{
-			for_axes (ax)
-				dsb_coords[ax]->setValue (mo->position()[ax]);
+			mo->position().apply ([&](Axis ax, double value)
+			{
+				dsb_coords[ax]->setValue (value);
+			});
 
 			defaultMatrix = mo->transform();
 		}
@@ -380,8 +384,10 @@
 			{
 				Vertex v;
 
-				for_axes (ax)
-					v[ax] = dlg.dsb_coords[ (i * 3) + ax]->value();
+				v.apply ([&](Axis ax, double& value)
+				{
+					value = dlg.dsb_coords[(i * 3) + ax]->value();
+				});
 
 				obj->setVertex (i, v);
 			}
@@ -396,9 +402,7 @@
 		case LDObject::EVertex:
 		{
 			LDVertex* vert = initObj<LDVertex> (obj);
-
-			for_axes (ax)
-				vert->pos[ax] = dlg.dsb_coords[ax]->value();
+			vert->pos.apply ([&](Axis ax, double& value) { value = dlg.dsb_coords[ax]->value(); });
 		}
 		break;
 

mercurial