- added ability to draw with random colors

Tue, 22 Apr 2014 20:40:19 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 22 Apr 2014 20:40:19 +0300
changeset 725
37b71daf4cb5
parent 724
7a82693d971a
child 726
9a53d9a379de

- added ability to draw with random colors
- toned down BFC red/green view colors
- fixed another case of known vertices going out of sync

src/actions.cc file | annotate | diff | comparison | revisions
src/glCompiler.cc file | annotate | diff | comparison | revisions
src/glRenderer.cc file | annotate | diff | comparison | revisions
src/glShared.h file | annotate | diff | comparison | revisions
src/ldObject.cc file | annotate | diff | comparison | revisions
src/ldObject.h file | annotate | diff | comparison | revisions
src/mainWindow.h file | annotate | diff | comparison | revisions
ui/ldforge.ui file | annotate | diff | comparison | revisions
--- a/src/actions.cc	Sat Apr 19 14:12:30 2014 +0300
+++ b/src/actions.cc	Tue Apr 22 20:40:19 2014 +0300
@@ -44,6 +44,7 @@
 extern_cfg (String,	ld_defaultuser);
 extern_cfg (Int,		ld_defaultlicense);
 extern_cfg (Bool,		gl_drawangles);
+extern_cfg (Bool,		gl_randomcolors)
 
 // =============================================================================
 //
@@ -868,3 +869,9 @@
 		delete doc;
 	}
 }
+
+DEFINE_ACTION (RandomColors, CTRL_SHIFT (R))
+{
+	gl_randomcolors = not gl_randomcolors;
+	R()->refresh();
+}
\ No newline at end of file
--- a/src/glCompiler.cc	Sat Apr 19 14:12:30 2014 +0300
+++ b/src/glCompiler.cc	Tue Apr 22 20:40:19 2014 +0300
@@ -50,8 +50,8 @@
 extern_cfg (String, gl_bgcolor);
 
 static QList<int>		g_warnedColors;
-static const QColor		g_BFCFrontColor (40, 192, 40);
-static const QColor		g_BFCBackColor (224, 40, 40);
+static const QColor		g_BFCFrontColor (64, 192, 80);
+static const QColor		g_BFCBackColor (208, 64, 64);
 
 // static QMap<LDObject*, QString> g_objectOrigins;
 
@@ -349,6 +349,12 @@
 					break;
 				}
 
+				case VBOCM_RandomColors:
+				{
+					writeColor (vbodata, topobj->randomColor());
+					break;
+				}
+
 				case VBOCM_NumComplements:
 					break;
 			}
--- a/src/glRenderer.cc	Sat Apr 19 14:12:30 2014 +0300
+++ b/src/glRenderer.cc	Tue Apr 22 20:40:19 2014 +0300
@@ -76,6 +76,7 @@
 cfg (Bool,		gl_aa,					true)
 cfg (Bool,		gl_linelengths,			true)
 cfg (Bool,		gl_drawangles,			false)
+cfg (Bool,		gl_randomcolors,		false)
 
 // argh
 const char* g_CameraNames[7] =
@@ -429,8 +430,16 @@
 		}
 		else
 		{
-			drawVBOs (VBOSF_Triangles, VBOCM_NormalColors, GL_TRIANGLES);
-			drawVBOs (VBOSF_Quads, VBOCM_NormalColors, GL_QUADS);
+			if (gl_randomcolors)
+			{
+				drawVBOs (VBOSF_Triangles, VBOCM_RandomColors, GL_TRIANGLES);
+				drawVBOs (VBOSF_Quads, VBOCM_RandomColors, GL_QUADS);
+			}
+			else
+			{
+				drawVBOs (VBOSF_Triangles, VBOCM_NormalColors, GL_TRIANGLES);
+				drawVBOs (VBOSF_Quads, VBOCM_NormalColors, GL_QUADS);
+			}
 		}
 
 		drawVBOs (VBOSF_Lines, VBOCM_NormalColors, GL_LINES);
--- a/src/glShared.h	Sat Apr 19 14:12:30 2014 +0300
+++ b/src/glShared.h	Tue Apr 22 20:40:19 2014 +0300
@@ -51,6 +51,7 @@
 	VBOCM_PickColors,
 	VBOCM_BFCFrontColors,
 	VBOCM_BFCBackColors,
+	VBOCM_RandomColors,
 	VBOCM_NumComplements
 };
 
--- a/src/ldObject.cc	Sat Apr 19 14:12:30 2014 +0300
+++ b/src/ldObject.cc	Tue Apr 22 20:40:19 2014 +0300
@@ -48,6 +48,7 @@
 	memset (m_coords, 0, sizeof m_coords);
 	chooseID();
 	g_LDObjects << this;
+	setRandomColor (QColor::fromRgb (rand()));
 }
 
 // =============================================================================
@@ -887,6 +888,9 @@
 //
 void LDSubfile::setFileInfo (const LDDocumentPointer& a)
 {
+	if (document() != null)
+		document()->removeKnownVerticesOf (this);
+
 	m_fileInfo = a;
 
 	// If it's an immediate subfile reference (i.e. this subfile belongs in an
@@ -898,4 +902,7 @@
 	{
 		a->initializeCachedData();
 	}
+
+	if (document() != null)
+		document()->addKnownVerticesOf (this);
 };
--- a/src/ldObject.h	Sat Apr 19 14:12:30 2014 +0300
+++ b/src/ldObject.h	Tue Apr 22 20:40:19 2014 +0300
@@ -73,6 +73,7 @@
 	PROPERTY (private,		int,			id,				setID,			STOCK_WRITE)
 	PROPERTY (public,		int,			color,			setColor,		CUSTOM_WRITE)
 	PROPERTY (public,		bool,			isGLInit,		setGLInit,		STOCK_WRITE)
+	PROPERTY (private,		QColor,			randomColor,	setRandomColor,	STOCK_WRITE)
 
 	public:
 		// Object type codes.
--- a/src/mainWindow.h	Sat Apr 19 14:12:30 2014 +0300
+++ b/src/mainWindow.h	Tue Apr 22 20:40:19 2014 +0300
@@ -290,6 +290,7 @@
 		void slot_actionJumpTo();
 		void slot_actionSubfileSelection();
 		void slot_actionDrawAngles();
+		void slot_actionRandomColors();
 
 	protected:
 		void closeEvent (QCloseEvent* ev);
--- a/ui/ldforge.ui	Sat Apr 19 14:12:30 2014 +0300
+++ b/ui/ldforge.ui	Tue Apr 22 20:40:19 2014 +0300
@@ -60,7 +60,7 @@
      <x>0</x>
      <y>0</y>
      <width>1010</width>
-     <height>26</height>
+     <height>27</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
@@ -107,6 +107,7 @@
     <addaction name="actionWireframe"/>
     <addaction name="actionBFCView"/>
     <addaction name="actionDrawAngles"/>
+    <addaction name="actionRandomColors"/>
     <addaction name="separator"/>
     <addaction name="actionSetOverlay"/>
     <addaction name="actionClearOverlay"/>
@@ -1348,6 +1349,14 @@
     <string>Draw angle information when drawing lines</string>
    </property>
   </action>
+  <action name="actionRandomColors">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Random colors</string>
+   </property>
+  </action>
  </widget>
  <resources>
   <include location="../ldforge.qrc"/>

mercurial