Implemented insertion of triangles, quads, condlines and comments

Tue, 19 Mar 2013 18:25:08 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 19 Mar 2013 18:25:08 +0200
changeset 38
20f5eaae8425
parent 37
a413d389b634
child 39
110669124caf

Implemented insertion of triangles, quads, condlines and comments

file.cpp file | annotate | diff | comparison | revisions
file.h file | annotate | diff | comparison | revisions
gui.cpp file | annotate | diff | comparison | revisions
--- a/file.cpp	Tue Mar 19 18:15:31 2013 +0200
+++ b/file.cpp	Tue Mar 19 18:25:08 2013 +0200
@@ -385,4 +385,12 @@
 		if (obj->getType() == OBJ_Gibberish)
 			obj->replace (parseLine (static_cast<LDGibberish*> (obj)->zContents));
 	}
+}
+
+// =============================================================================
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+// =============================================================================
+void OpenFile::addObject (LDObject* obj) {
+	const ulong ulSpot = g_qWindow->getInsertionPoint ();
+	objects.insert (objects.begin() + ulSpot, obj);
 }
\ No newline at end of file
--- a/file.h	Tue Mar 19 18:15:31 2013 +0200
+++ b/file.h	Tue Mar 19 18:25:08 2013 +0200
@@ -39,6 +39,7 @@
 	
 	// Saves this file to disk.
 	bool save (str zPath = "");
+	void addObject (LDObject* obj);
 };
 
 // Close all current loaded files and start off blank.
--- a/gui.cpp	Tue Mar 19 18:15:31 2013 +0200
+++ b/gui.cpp	Tue Mar 19 18:25:08 2013 +0200
@@ -120,10 +120,6 @@
 	// things not implemented yet
 	QAction* qaDisabledActions[] = {
 		qAct_newSubfile,
-		qAct_newTriangle,
-		qAct_newQuad,
-		qAct_newCondLine,
-		qAct_newComment,
 		qAct_newVector,
 		qAct_newVertex,
 		qAct_cut,
@@ -278,31 +274,49 @@
 
 void ForgeWindow::slot_newLine () {
 	LDLine* line = new LDLine;
-	const ulong ulSpot = getInsertionPoint ();
 	
 	memset (line->vaCoords, 0, sizeof line->vaCoords);
 	line->dColor = 24;
 	
-	g_CurrentFile->objects.insert (g_CurrentFile->objects.begin() + ulSpot, line);
-	
-	buildObjList ();
-	R->hardRefresh ();
+	g_CurrentFile->addObject (line);
+	refresh ();
 }
 
 void ForgeWindow::slot_newTriangle () {
+	LDTriangle* tri = new LDTriangle;
 	
+	memset (tri->vaCoords, 0, sizeof tri->vaCoords);
+	tri->dColor = 16;
+	
+	g_CurrentFile->addObject (tri);
+	refresh ();
 }
 
 void ForgeWindow::slot_newQuad () {
+	LDQuad* quad = new LDQuad;
 	
+	memset (quad->vaCoords, 0, sizeof quad->vaCoords);
+	quad->dColor = 16;
+	
+	g_CurrentFile->addObject (quad);
+	refresh ();
 }
 
 void ForgeWindow::slot_newCondLine () {
-
+	LDCondLine* line = new LDCondLine;
+	
+	memset (line->vaCoords, 0, sizeof line->vaCoords);
+	memset (line->vaControl, 0, sizeof line->vaControl);
+	line->dColor = 24;
+	
+	g_CurrentFile->addObject (line);
+	refresh ();
 }
 
 void ForgeWindow::slot_newComment () {
-
+	LDComment* comm = new LDComment;
+	g_CurrentFile->addObject (comm);
+	refresh ();
 }
 
 void ForgeWindow::slot_help () {

mercurial