Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.

Wed, 20 Mar 2013 23:06:30 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 20 Mar 2013 23:06:30 +0200
changeset 52
d71226763607
parent 51
94c434a56961
child 53
170cdffe1056

Colorized polygons now appear colorized in the list view (unless disabled). GL rendered now draws transparent polygons properly.

cfgdef.h file | annotate | diff | comparison | revisions
gldraw.cpp file | annotate | diff | comparison | revisions
gldraw.h file | annotate | diff | comparison | revisions
gui.cpp file | annotate | diff | comparison | revisions
zz_configDialog.cpp file | annotate | diff | comparison | revisions
zz_configDialog.h file | annotate | diff | comparison | revisions
--- a/cfgdef.h	Wed Mar 20 21:47:33 2013 +0200
+++ b/cfgdef.h	Wed Mar 20 23:06:30 2013 +0200
@@ -25,4 +25,7 @@
 
 SECT (gl, GLRenderer)
 CFG (str, gl, bgcolor, "Background color", "#CCCCD9")
-CFG (str, gl, maincolor, "Main color", "#707078")
\ No newline at end of file
+CFG (str, gl, maincolor, "Main color", "#707078")
+
+SECT (lv, ListView)
+CFG (bool, lv, colorize, "Show colorized polygons in their color in the list view", true)
\ No newline at end of file
--- a/gldraw.cpp	Wed Mar 20 21:47:33 2013 +0200
+++ b/gldraw.cpp	Wed Mar 20 23:06:30 2013 +0200
@@ -23,6 +23,7 @@
 #include "file.h"
 #include "gldraw.h"
 #include "bbox.h"
+#include "colors.h"
 
 #define GL_VERTEX(V) glVertex3d (V.x, V.y, V.z);
 
@@ -42,7 +43,7 @@
 	glLoadIdentity();
 	glMatrixMode (GL_MODELVIEW);
 	
-	setColor (gl_bgcolor, &glClearColor);
+	setColor (gl_bgcolor.value, &glClearColor);
 	
 	glEnable (GL_POLYGON_OFFSET_FILL);
 	glPolygonOffset (1.0f, 1.0f);
@@ -65,10 +66,10 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-void renderer::setColor (strconfig& cfg,
+void renderer::setColor (str zColor,
 	void (*func) (float, float, float, float))
 {
-	QColor col (cfg.value.chars());
+	QColor col (zColor.chars());
 	
 	if (!col.isValid ())
 		return;
@@ -80,6 +81,22 @@
 		1.0f);
 }
 
+void renderer::setObjectColor (LDObject* obj) {
+	if (obj->dColor == dMainColor)
+		setColor (gl_maincolor, glColor4f);
+	else {
+		color* col = g_LDColors[obj->dColor];
+		QColor qCol (col->zColor.chars());
+		
+		if (qCol.isValid ())
+			glColor4f (
+				((double)qCol.red()) / 255.0f,
+				((double)qCol.green()) / 255.0f,
+				((double)qCol.blue()) / 255.0f,
+				col->fAlpha);
+	}
+}
+
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
@@ -174,7 +191,7 @@
 	case OBJ_Triangle:
 		{
 			LDTriangle* tri = static_cast<LDTriangle*> (obj);
-			setColor (gl_maincolor, glColor4f);
+			setObjectColor (obj);
 			glBegin (GL_TRIANGLES);
 			for (short i = 0; i < 3; ++i)
 				GL_VERTEX (tri->vaCoords[i])
@@ -185,7 +202,7 @@
 	case OBJ_Quad:
 		{
 			LDQuad* quad = static_cast<LDQuad*> (obj);
-			setColor (gl_maincolor, glColor4f);
+			setObjectColor (obj);
 			glBegin (GL_QUADS);
 			for (short i = 0; i < 4; ++i)
 				GL_VERTEX (quad->vaCoords[i])
--- a/gldraw.h	Wed Mar 20 21:47:33 2013 +0200
+++ b/gldraw.h	Wed Mar 20 23:06:30 2013 +0200
@@ -30,7 +30,7 @@
 	renderer (QWidget* parent = nullptr);
 	void hardRefresh ();
 	void compileObjects ();
-	void setColor (strconfig& cfg, void (*func) (float, float, float, float));
+	void setColor (str zColor, void (*func) (float, float, float, float));
 	
 	double fRotX, fRotY, fRotZ;
 	QPoint lastPos;
@@ -47,6 +47,7 @@
 	GLuint uObjList;
 	void compileOneObject (LDObject* obj);
 	void clampAngle (double& fAngle);
+	void setObjectColor (LDObject* obj);
 };
 
 #endif // __GLDRAW_H__
\ No newline at end of file
--- a/gui.cpp	Wed Mar 20 21:47:33 2013 +0200
+++ b/gui.cpp	Wed Mar 20 23:06:30 2013 +0200
@@ -542,6 +542,14 @@
 		if (obj->getType() == OBJ_Gibberish) {
 			item->setBackgroundColor (0, "#AA0000");
 			item->setForeground (0, QColor ("#FFAA00"));
+		} else if (lv_colorize &&
+			obj->dColor != -1 &&
+			obj->dColor != dMainColor &&
+			obj->dColor != dEdgeColor)
+		{
+			// If the object isn't in the main or edge color, draw this
+			// list entry in said color.
+			item->setForeground (0, QColor (g_LDColors[obj->dColor]->zColor.chars()));
 		}
 		
 		obj->qObjListEntry = item;
--- a/zz_configDialog.cpp	Wed Mar 20 21:47:33 2013 +0200
+++ b/zz_configDialog.cpp	Wed Mar 20 23:06:30 2013 +0200
@@ -53,6 +53,9 @@
 	connect (qGLForegroundButton, SIGNAL (clicked ()),
 		this, SLOT (slot_setGLForeground ()));
 	
+	qLVColorize = new QCheckBox ("Colorize polygons in list view");
+	qLVColorize->setCheckState (lv_colorize ? Qt::Checked : Qt::Unchecked);
+	
 	IMPLEMENT_DIALOG_BUTTONS
 	
 	QGridLayout* layout = new QGridLayout;
@@ -65,7 +68,9 @@
 	layout->addWidget (qGLForegroundLabel, 1, 2);
 	layout->addWidget (qGLForegroundButton, 1, 3);
 	
-	layout->addWidget (qButtons, 2, 2, 1, 2);
+	layout->addWidget (qLVColorize, 2, 0, 1, 2);
+	
+	layout->addWidget (qButtons, 3, 2, 1, 2);
 	setLayout (layout);
 	
 	setWindowTitle (APPNAME_DISPLAY " - editing settings");
@@ -133,6 +138,7 @@
 	
 	if (dlg.exec ()) {
 		io_ldpath = dlg.qLDrawPath->text();
+		lv_colorize = dlg.qLVColorize->checkState() == Qt::Checked;
 		
 		// Save the config
 		config::save ();
@@ -141,5 +147,6 @@
 		reloadAllSubfiles ();
 		
 		window->R->setColor (gl_bgcolor, glClearColor);
+		window->refresh ();
 	}
 }
\ No newline at end of file
--- a/zz_configDialog.h	Wed Mar 20 21:47:33 2013 +0200
+++ b/zz_configDialog.h	Wed Mar 20 23:06:30 2013 +0200
@@ -22,15 +22,18 @@
 #include <qlineedit.h>
 #include <qdialogbuttonbox.h>
 #include <qpushbutton.h>
+#include <qcheckbox.h>
 
 class ConfigDialog : public QDialog {
 	Q_OBJECT
 	
 public:
-	QLabel* qLDrawPathLabel, *qGLBackgroundLabel, *qGLForegroundLabel;
+	QLabel* qLDrawPathLabel;
+	QLabel* qGLBackgroundLabel, *qGLForegroundLabel;
 	QLineEdit* qLDrawPath;
 	QPushButton* qLDrawPathFindButton;
 	QPushButton* qGLBackgroundButton, *qGLForegroundButton;
+	QCheckBox* qLVColorize;
 	
 	QDialogButtonBox* qButtons;
 	

mercurial