Added insert vertex function and added vertex icons.

Wed, 20 Mar 2013 02:31:36 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 20 Mar 2013 02:31:36 +0200
changeset 41
4ca63da5546b
parent 40
215b9f8f0cd7
child 42
499c25af0303

Added insert vertex function and added vertex icons.

gui.cpp file | annotate | diff | comparison | revisions
icons/add-vertex.png file | annotate | diff | comparison | revisions
icons/vertex.png file | annotate | diff | comparison | revisions
ldtypes.cpp file | annotate | diff | comparison | revisions
zz_addObjectDialog.cpp file | annotate | diff | comparison | revisions
--- a/gui.cpp	Wed Mar 20 01:58:05 2013 +0200
+++ b/gui.cpp	Wed Mar 20 02:31:36 2013 +0200
@@ -123,7 +123,6 @@
 	QAction* qaDisabledActions[] = {
 		qAct_newSubfile,
 		qAct_newVector,
-		qAct_newVertex,
 		qAct_cut,
 		qAct_copy,
 		qAct_paste,
@@ -323,7 +322,7 @@
 }
 
 void ForgeWindow::slot_newVertex () {
-	
+	AddObjectDialog::staticDialog (OBJ_Vertex, this);
 }
 
 void ForgeWindow::slot_inline () {
@@ -463,11 +462,11 @@
 			break;
 		
 		case OBJ_Vector:
-			zText.format ("%s", static_cast<LDVector*> (obj)->vPos.getStringRep(true).chars());
+			zText.format ("%s", static_cast<LDVector*> (obj)->vPos.getStringRep (true).chars());
 			break;
 		
 		case OBJ_Vertex:
-			zText.format ("%s", static_cast<LDVertex*> (obj)->vPosition.getStringRep(true).chars());
+			zText.format ("%s", static_cast<LDVertex*> (obj)->vPosition.getStringRep (true).chars());
 			break;
 		
 		case OBJ_Subfile:
@@ -479,7 +478,8 @@
 				
 				for (short i = 0; i < 9; ++i)
 					zText.appendformat ("%s%s",
-						ftoa (ref->faMatrix[i]).chars(), (i != 8) ? " " : "");
+						ftoa (ref->faMatrix[i]).chars(),
+						(i != 8) ? " " : "");
 				
 				zText += ')';
 			}
@@ -492,7 +492,7 @@
 		
 		QTreeWidgetItem* item = new QTreeWidgetItem ((QTreeWidget*) (nullptr),
 			QStringList (zText.chars()), 0);
-		item->setIcon (0, QIcon (g_saObjTypeIcons[obj->getType ()]));
+		item->setIcon (0, QIcon (str::mkfmt ("icons/%s.png", g_saObjTypeIcons[obj->getType ()]).chars()));
 		
 		// Color gibberish red
 		if (obj->getType() == OBJ_Gibberish) {
Binary file icons/add-vertex.png has changed
Binary file icons/vertex.png has changed
--- a/ldtypes.cpp	Wed Mar 20 01:58:05 2013 +0200
+++ b/ldtypes.cpp	Wed Mar 20 02:31:36 2013 +0200
@@ -36,17 +36,17 @@
 };
 
 char const* g_saObjTypeIcons[] = {
-	"icons/error.png",
-	"icons/error.png",
-	"icons/empty.png",
-	"icons/comment.png",
-	"icons/subfile.png",
-	"icons/line.png",
-	"icons/triangle.png",
-	"icons/quad.png",
-	"icons/condline.png",
-	"icons/vector.png",
-	"icons/vertex.png"
+	"error",
+	"error",
+	"empty",
+	"comment",
+	"subfile",
+	"line",
+	"triangle",
+	"quad",
+	"condline",
+	"vector",
+	"vertex"
 };
 
 // =============================================================================
--- a/zz_addObjectDialog.cpp	Wed Mar 20 01:58:05 2013 +0200
+++ b/zz_addObjectDialog.cpp	Wed Mar 20 02:31:36 2013 +0200
@@ -53,6 +53,8 @@
 	case OBJ_CondLine:
 		dCoordCount = 12;
 		break;
+	case OBJ_Vertex:
+		dCoordCount = 3;
 	default:
 		break;
 	}
@@ -91,7 +93,7 @@
 	setWindowTitle (str::mkfmt (APPNAME_DISPLAY " - new %s",
 		g_saObjTypeNames[type]).chars());
 	
-	setWindowIcon (QIcon (g_saObjTypeIcons[type]));
+	setWindowIcon (QIcon (str::mkfmt ("icons/add-%s.png", g_saObjTypeIcons[type]).chars ()));
 }
 
 // =============================================================================
@@ -157,6 +159,20 @@
 				g_CurrentFile->addObject (line);
 				window->refresh ();
 			}
+			break;
+		
+		case OBJ_Vertex:
+			{
+				LDVertex* vert = new LDVertex;
+				vert->dColor = dMainColor;
+				vert->vPosition.x = dlg.qaCoordinates[0]->value ();
+				vert->vPosition.y = dlg.qaCoordinates[1]->value ();
+				vert->vPosition.z = dlg.qaCoordinates[2]->value ();
+				
+				g_CurrentFile->addObject (vert);
+				window->refresh ();
+			}
+			break;
 		
 		default:
 			break;

mercurial