minor improvements to primitive handling

Thu, 27 Jun 2013 14:12:12 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 27 Jun 2013 14:12:12 +0300
changeset 306
fef00a6cbff0
parent 305
401b9e3f2d10
child 307
c731a22899a3

minor improvements to primitive handling

src/addObjectDialog.cpp file | annotate | diff | comparison | revisions
src/gui.cpp file | annotate | diff | comparison | revisions
src/ldtypes.cpp file | annotate | diff | comparison | revisions
src/ldtypes.h file | annotate | diff | comparison | revisions
src/primitives.cpp file | annotate | diff | comparison | revisions
src/primitives.h file | annotate | diff | comparison | revisions
--- a/src/addObjectDialog.cpp	Thu Jun 27 12:29:54 2013 +0300
+++ b/src/addObjectDialog.cpp	Thu Jun 27 14:12:12 2013 +0300
@@ -95,6 +95,11 @@
 		{
 			coordCount = 3;
 			
+			// If the primitive lister is busy writing data, we have to wait
+			// for that to happen first. This should be quite considerably rare.
+			while (primitiveLoaderBusy())
+				;
+			
 			tw_subfileList = new QTreeWidget ();
 			tw_subfileList->setHeaderLabel ("Primitives");
 			
--- a/src/gui.cpp	Thu Jun 27 12:29:54 2013 +0300
+++ b/src/gui.cpp	Thu Jun 27 14:12:12 2013 +0300
@@ -1008,6 +1008,7 @@
 	m_primLoaderWidget->show ();
 	m_primLoaderBar->setRange (0, max);
 	m_primLoaderBar->setValue (0);
+	m_primLoaderBar->setFormat ("%p%");
 }
 
 void ForgeWindow::primitiveLoaderUpdate (ulong prog) {
@@ -1018,7 +1019,8 @@
 	QTimer* hidetimer = new QTimer;
 	connect (hidetimer, SIGNAL (timeout ()), m_primLoaderWidget, SLOT (hide ()));
 	hidetimer->setSingleShot (true);
-	hidetimer->start (2000);
+	hidetimer->start (1500);
+	m_primLoaderBar->setFormat ("Done");
 }
 
 // ============================================================================
--- a/src/ldtypes.cpp	Thu Jun 27 12:29:54 2013 +0300
+++ b/src/ldtypes.cpp	Thu Jun 27 14:12:12 2013 +0300
@@ -55,6 +55,9 @@
 	"error",
 };
 
+// List of all LDObjects
+vector<LDObject*> g_LDObjects;
+
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
@@ -65,6 +68,14 @@
 	m_hidden = false;
 	m_selected = false;
 	m_glinit = false;
+	
+	// Determine ID
+	int id = 1; // 0 is invalid
+	for( LDObject* obj : g_LDObjects )
+		if( obj->id() >= id )
+			id = obj->id() + 1;
+	
+	setID( id );
 }
 
 LDGibberish::LDGibberish () {}
--- a/src/ldtypes.h	Thu Jun 27 12:29:54 2013 +0300
+++ b/src/ldtypes.h	Thu Jun 27 14:12:12 2013 +0300
@@ -86,6 +86,7 @@
 	PROPERTY (bool, hidden, setHidden)
 	PROPERTY (bool, selected, setSelected)
 	PROPERTY (LDObject*, parent, setParent)
+	READ_PROPERTY (int, id, setID)
 	DECLARE_PROPERTY (short, color, setColor)
 	
 public:
--- a/src/primitives.cpp	Thu Jun 27 12:29:54 2013 +0300
+++ b/src/primitives.cpp	Thu Jun 27 14:12:12 2013 +0300
@@ -55,9 +55,9 @@
 			info.title = line.mid (space + 1);
 			g_primitives << info;
 		}
+		
+		populateCategories ();
 	}
-	
-	populateCategories ();
 }
 
 // =============================================================================
@@ -104,15 +104,13 @@
 			info.title = "";
 		
 		info.title = info.title.simplified ();
+		info.cat = null;
 		
 		if (info.title[0] == '0') {
 			info.title.remove (0, 1); // remove 0
 			info.title = info.title.simplified ();
 		}
 		
-		// Figure which category to use
-		info.cat = null;
-		
 		m_prims << info;
 		emit update (++i);
 	}
@@ -126,6 +124,7 @@
 	
 	g_primListerMutex = true;
 	g_primitives = m_prims;
+	populateCategories ();
 	g_primListerMutex = false;
 	g_activePrimLister = null;
 	emit workDone ();
@@ -268,4 +267,8 @@
 	PrimitiveCategory cat;
 	cat.setName ("Other");
 	g_PrimitiveCategories << cat;
+}
+
+bool primitiveLoaderBusy() {
+	return g_primListerMutex;
 }
\ No newline at end of file
--- a/src/primitives.h	Thu Jun 27 12:29:54 2013 +0300
+++ b/src/primitives.h	Thu Jun 27 14:12:12 2013 +0300
@@ -80,5 +80,6 @@
 extern vector<PrimitiveCategory> g_PrimitiveCategories;
 
 void loadPrimitives ();
+bool primitiveLoaderBusy ();
 
 #endif // PRIMITIVES_H
\ No newline at end of file

mercurial