- merged experimental with default experimental

Thu, 06 Nov 2014 15:44:11 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Thu, 06 Nov 2014 15:44:11 +0200
branch
experimental
changeset 912
3feb4d20092d
parent 890
903ec1e46298 (current diff)
parent 909
f025ab5e57ac (diff)
child 913
d93a42b07e28
child 915
c64c83cede6e
child 916
bf08a6b42102

- merged experimental with default

.gitignore file | annotate | diff | comparison | revisions
--- a/.gitignore	Tue Sep 09 01:16:24 2014 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-build
-build_shared
-build_debug
-build_release
-*.kdev4
-Makefile
-Makefile.*
-ldforge
-ldforge_debug
-*.dat
-debug_lastOutput
-debug_lastInput
-.kdev_include_paths
-*.cfg
-Git.h
-.kdev4
--- a/.hgignore	Tue Sep 09 01:16:24 2014 +0300
+++ b/.hgignore	Thu Nov 06 15:44:11 2014 +0200
@@ -16,3 +16,4 @@
 .kdev4
 .*~
 *.orig
+CMakeLists.txt.user
--- a/changelog.txt	Tue Sep 09 01:16:24 2014 +0300
+++ b/changelog.txt	Thu Nov 06 15:44:11 2014 +0200
@@ -1,6 +1,14 @@
 
 
 
+		Changes in version 0.4
+
+
+
++	- Pressing Ctrl while drawing now causes the new line to become locked to cardinal directions, ala Gimp.
+-	- Selecting an invertnext'd object no longer selects the invertnext (reverted feature from 0.3, caused too many problems).
+
+
 		Changes in version 0.3
 
 
--- a/src/actions.cc	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/actions.cc	Thu Nov 06 15:44:11 2014 +0200
@@ -268,9 +268,6 @@
 {
 	for (LDObjectPtr obj : CurrentDocument()->objects())
 		obj->select();
-
-	ui->objectList->selectAll();
-	refresh();
 }
 
 // =============================================================================
@@ -296,9 +293,6 @@
 		if (colors.contains (obj->color()))
 			obj->select();
 	}
-
-	updateSelection();
-	refresh();
 }
 
 // =============================================================================
@@ -336,9 +330,6 @@
 
 		obj->select();
 	}
-
-	updateSelection();
-	refresh();
 }
 
 // =============================================================================
--- a/src/editmodes/drawMode.cc	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/editmodes/drawMode.cc	Thu Nov 06 15:44:11 2014 +0200
@@ -21,6 +21,7 @@
 #include "drawMode.h"
 #include "../ldObject.h"
 #include "../glRenderer.h"
+#include "../miscallenous.h"
 
 DrawMode::DrawMode (GLRenderer* renderer) :
 	Super (renderer) {}
@@ -40,7 +41,7 @@
 
 	// Draw the cursor vertex as the last one in the list.
 	if (poly.size() < 4)
-		poly << renderer()->position3D();
+		poly << getCursorVertex();
 
 	renderPolygon (painter, poly, true, true);
 }
@@ -74,7 +75,7 @@
 			return true;
 		}
 
-		addDrawnVertex (renderer()->position3D());
+		addDrawnVertex (getCursorVertex());
 		return true;
 	}
 
@@ -127,3 +128,36 @@
 
 	finishDraw (objs);
 }
+
+template<typename _Type>
+_Type IntervalClamp (_Type a, _Type interval)
+{
+	_Type remainder = a % interval;
+
+	if (remainder >= float (interval / 2))
+		a += interval;
+
+	a -= remainder;
+	return a;
+}
+
+Vertex DrawMode::getCursorVertex() const
+{
+	Vertex result = renderer()->position3D();
+
+	if (renderer()->keyboardModifiers() & Qt::ControlModifier
+		and not m_drawedVerts.isEmpty())
+	{
+		Vertex const& v0 = m_drawedVerts.last();
+		Vertex const& v1 = result;
+		Axis relX, relY;
+
+		renderer()->getRelativeAxes (relX, relY);
+		QLineF ln (v0[relX], v0[relY], v1[relX], v1[relY]);
+		ln.setAngle (IntervalClamp<int> (ln.angle(), 45));
+		result.setCoordinate (relX, Grid::Snap (ln.x2(), Grid::Coordinate));
+		result.setCoordinate (relY, Grid::Snap (ln.y2(), Grid::Coordinate));
+	}
+
+	return result;
+}
--- a/src/editmodes/drawMode.h	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/editmodes/drawMode.h	Thu Nov 06 15:44:11 2014 +0200
@@ -32,4 +32,5 @@
 	bool mouseReleased (MouseEventData const& data) override;
 	void endDraw();
 	bool preAddVertex (Vertex const&);
+	Vertex getCursorVertex() const;
 };
--- a/src/glRenderer.cc	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/glRenderer.cc	Thu Nov 06 15:44:11 2014 +0200
@@ -1296,10 +1296,7 @@
 //
 void GLRenderer::zoomNotch (bool inward)
 {
-	if (zoom() > 15)
-		zoom() *= inward ? 0.833f : 1.2f;
-	else
-		zoom() += inward ? -1.2f : 1.2f;
+	zoom() *= inward ? 0.833f : 1.2f;
 }
 
 // =============================================================================
@@ -1313,14 +1310,10 @@
 
 	bool lastfilled = false;
 	bool firstrun = true;
-	const uint32 white = 0xFFFFFFFF;
+	enum { black = 0xFF000000 };
 	bool inward = true;
-	const int w = m_width, h = m_height;
 	int runaway = 50;
 
-	glClearColor (1.0, 1.0, 1.0, 1.0);
-	glDisable (GL_DITHER);
-
 	// Use the pick list while drawing the scene, this way we can tell whether borders
 	// are background or not.
 	setPicking (true);
@@ -1329,24 +1322,22 @@
 	{
 		if (zoom() > 10000.0 or zoom() < 0.0)
 		{
-			// Obviously, there's nothing to draw if we get here.
-			// Default to 30.0f and break out.
+			// Nothing to draw if we get here.
 			zoom() = 30.0;
 			break;
 		}
 
 		zoomNotch (inward);
-
-		uchar* cap = new uchar[4 * w * h];
+		QVector<unsigned char> capture (4 * m_width * m_height);
 		drawGLScene();
-		glReadPixels (0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, cap);
-		uint32* imgdata = reinterpret_cast<uint32*> (cap);
+		glReadPixels (0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, capture.data());
+		QImage image (capture.constData(), m_width, m_height, QImage::Format_ARGB32);
 		bool filled = false;
 
 		// Check the top and bottom rows
-		for (int i = 0; i < w; ++i)
+		for (int i = 0; i < image.width(); ++i)
 		{
-			if (imgdata[i] != white or imgdata[((h - 1) * w) + i] != white)
+			if (image.pixel (i, 0) != black or image.pixel (i, m_height - 1) != black)
 			{
 				filled = true;
 				break;
@@ -1356,9 +1347,9 @@
 		// Left and right edges
 		if (filled == false)
 		{
-			for (int i = 0; i < h; ++i)
+			for (int i = 0; i < image.height(); ++i)
 			{
-				if (imgdata[i * w] != white or imgdata[(i * w) + w - 1] != white)
+				if (image.pixel (0, i) != black or image.pixel (m_width - 1, i) != black)
 				{
 					filled = true;
 					break;
@@ -1366,8 +1357,6 @@
 			}
 		}
 
-		delete[] cap;
-
 		if (firstrun)
 		{
 			// If this is the first run, we don't know enough to determine
@@ -1397,7 +1386,6 @@
 		lastfilled = filled;
 	}
 
-	setBackground();
 	setPicking (false);
 }
 
@@ -1405,15 +1393,7 @@
 //
 void GLRenderer::zoomAllToFit()
 {
-	ECamera oldcam = camera();
-
-	for (ECamera cam = EFirstCamera; cam < ENumCameras; ++cam)
-	{
-		setCamera (cam);
-		zoomToFit();
-	}
-
-	setCamera (oldcam);
+	zoomToFit();
 }
 
 // =============================================================================
@@ -1650,6 +1630,11 @@
 	return g_FixedCameras[camera()].negatedDepth ? -1 : 1;
 }
 
+Qt::KeyboardModifiers GLRenderer::keyboardModifiers() const
+{
+	return m_keymods;
+}
+
 LDFixedCamera const& GetFixedCamera (ECamera cam)
 {
 	assert (cam != EFreeCamera);
--- a/src/glRenderer.h	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/glRenderer.h	Thu Nov 06 15:44:11 2014 +0200
@@ -169,6 +169,7 @@
 	Axis					getRelativeZ() const;
 	LDGLOverlay&			getOverlay (int newcam);
 	uchar*					getScreencap (int& w, int& h);
+	Qt::KeyboardModifiers	keyboardModifiers() const;
 	void					hardRefresh();
 	void					highlightCursorObject();
 	void					initGLData();
--- a/src/ldDocument.cc	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/ldDocument.cc	Thu Nov 06 15:44:11 2014 +0200
@@ -168,13 +168,11 @@
 
 // =============================================================================
 //
-extern QMap<long, LDObjectWeakPtr>	g_allObjects;
 void LDDocument::setImplicit (bool const& a)
 {
 	if (m_isImplicit != a)
 	{
 		m_isImplicit = a;
-		print ("Setting implicity of %1 to %2\n", this, a ? "true" : "false");
 
 		if (a == false)
 		{
@@ -188,9 +186,7 @@
 		}
 		else
 		{
-			print ("Removing %1 from explicit documents...\n", this);
 			g_explicitDocuments.removeOne (self().toStrongRef());
-			print ("Removed %1", this);
 			print ("Closed %1", name());
 		}
 
--- a/src/ldObject.cc	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/ldObject.cc	Thu Nov 06 15:44:11 2014 +0200
@@ -880,10 +880,12 @@
 	document().toStrongRef()->addToSelection (self());
 
 	// If this object is inverted with INVERTNEXT, pick the INVERTNEXT as well.
+	/*
 	LDBFCPtr invertnext;
 
 	if (previousIsInvertnext (invertnext))
 		invertnext->select();
+	*/
 }
 
 // =============================================================================
--- a/src/mainWindow.cc	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/mainWindow.cc	Thu Nov 06 15:44:11 2014 +0200
@@ -58,6 +58,7 @@
 CFGENTRY (Bool, ColorizeObjectsList, true)
 CFGENTRY (String, QuickColorToolbar, "4:25:14:27:2:3:11:1:22:|:0:72:71:15")
 CFGENTRY (Bool, ListImplicitFiles, false)
+CFGENTRY (List, HiddenToolbars, {})
 EXTERN_CFGENTRY (List, RecentFiles)
 EXTERN_CFGENTRY (Bool, DrawAxes)
 EXTERN_CFGENTRY (String, MainColor)
@@ -125,6 +126,14 @@
 	connect (ui->ringToolSegments, SIGNAL (valueChanged (int)),
 		this, SLOT (circleToolSegmentsChanged()));
 	circleToolSegmentsChanged(); // invoke it manually for initial label text
+
+	for (QVariant const& toolbarname : cfg::HiddenToolbars)
+	{
+		QToolBar* toolbar = findChild<QToolBar*> (toolbarname.toString());
+
+		if (toolbar != null)
+			toolbar->hide();
+	}
 }
 
 MainWindow::~MainWindow()
@@ -562,17 +571,41 @@
 void MainWindow::updateSelection()
 {
 	g_isSelectionLocked = true;
-
-	ui->objectList->clearSelection();
+	QItemSelection itemselect;
+	int top = -1;
+	int bottom = -1;
 
 	for (LDObjectPtr obj : Selection())
 	{
 		if (obj->qObjListEntry == null)
 			continue;
 
-		obj->qObjListEntry->setSelected (true);
+		int row = ui->objectList->row (obj->qObjListEntry);
+
+		if (top == -1)
+		{
+			top = bottom = row;
+		}
+		else
+		{
+			if (row != bottom + 1)
+			{
+				itemselect.select (ui->objectList->model()->index (top, 0),
+					ui->objectList->model()->index (bottom, 0));
+				top = -1;
+			}
+
+			bottom = row;
+		}
 	}
 
+	if (top != -1)
+	{
+		itemselect.select (ui->objectList->model()->index (top, 0),
+			ui->objectList->model()->index (bottom, 0));
+	}
+
+	ui->objectList->selectionModel()->select (itemselect, QItemSelectionModel::ClearAndSelect);
 	g_isSelectionLocked = false;
 }
 
@@ -608,10 +641,17 @@
 		return;
 	}
 
-	// Save the configuration before leaving so that, for instance, grid choice
-	// is preserved across instances.
+	// Save the toolbar set
+	cfg::HiddenToolbars.clear();
+
+	for (QToolBar* toolbar : findChildren<QToolBar*>())
+	{
+		if (toolbar->isHidden())
+			cfg::HiddenToolbars << toolbar->objectName();
+	}
+
+	// Save the configuration before leaving.
 	Config::Save();
-
 	ev->accept();
 }
 
--- a/src/version.h	Tue Sep 09 01:16:24 2014 +0300
+++ b/src/version.h	Thu Nov 06 15:44:11 2014 +0200
@@ -28,7 +28,7 @@
 // Version number
 //
 #define VERSION_MAJOR	0
-#define VERSION_MINOR	3
+#define VERSION_MINOR	4
 #define VERSION_PATCH	0
 
 //

mercurial