More refactor and removal of g_win uses

Mon, 31 Aug 2015 23:36:08 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 31 Aug 2015 23:36:08 +0300
changeset 977
dc3ceb65cda7
parent 976
b7aac3606b65
child 978
4603d8fd063e

More refactor and removal of g_win uses

src/editmodes/circleMode.cpp file | annotate | diff | comparison | revisions
src/editmodes/magicWandMode.cpp file | annotate | diff | comparison | revisions
src/editmodes/selectMode.cpp file | annotate | diff | comparison | revisions
src/guiutilities.cpp file | annotate | diff | comparison | revisions
--- a/src/editmodes/circleMode.cpp	Mon Aug 31 23:25:56 2015 +0300
+++ b/src/editmodes/circleMode.cpp	Mon Aug 31 23:36:08 2015 +0300
@@ -77,8 +77,8 @@
 void CircleMode::buildCircle()
 {
 	LDObjectList objs;
-	const int segments (g_win->ringToolSegments());
-	const int divisions (g_win->ringToolHiRes() ? HighResolution : LowResolution);
+	const int segments (m_window->ringToolSegments());
+	const int divisions (m_window->ringToolHiRes() ? HighResolution : LowResolution);
 	double dist0 (getCircleDrawDist (0));
 	double dist1 (getCircleDrawDist (1));
 	LDDocument* refFile;
@@ -186,7 +186,7 @@
 	if (m_drawedVerts.isEmpty())
 		return 0.0;
 
-	const int divisions (g_win->ringToolHiRes() ? HighResolution : LowResolution);
+	const int divisions (m_window->ringToolHiRes() ? HighResolution : LowResolution);
 	QPointF originspot (renderer()->coordconv3_2 (m_drawedVerts.first()));
 	QLineF bearing (originspot, renderer()->mousePositionF());
 	QLineF bearing2 (originspot, QPointF (originspot.x(), 0.0));
@@ -213,8 +213,8 @@
 	QVector<QPointF> innerverts2d, outerverts2d;
 	const double innerdistance (getCircleDrawDist (0));
 	const double outerdistance (m_drawedVerts.size() >= 2 ? getCircleDrawDist (1) : -1);
-	const int divisions (g_win->ringToolHiRes() ? HighResolution : LowResolution);
-	const int segments (g_win->ringToolSegments());
+	const int divisions (m_window->ringToolHiRes() ? HighResolution : LowResolution);
+	const int segments (m_window->ringToolSegments());
 	const double angleUnit (2 * Pi / divisions);
 	Axis relX, relY;
 	renderer()->getRelativeAxes (relX, relY);
--- a/src/editmodes/magicWandMode.cpp	Mon Aug 31 23:25:56 2015 +0300
+++ b/src/editmodes/magicWandMode.cpp	Mon Aug 31 23:36:08 2015 +0300
@@ -44,26 +44,26 @@
 {
 	// All boundaries obviously share vertices with the object, therefore they're all in the list
 	// of candidates.
-	for (auto it = candidates.begin(); it != candidates.end(); ++it)
+	for (LDObject* candidate : candidates)
 	{
-		if (not isOneOf ((*it)->type(), OBJ_Line, OBJ_CondLine) or (*it)->vertex (0) == (*it)->vertex (1))
+		if (not isOneOf (candidate->type(), OBJ_Line, OBJ_CondLine) or candidate->vertex (0) == candidate->vertex (1))
 			continue;
 
 		int matches = 0;
 
 		for (int i = 0; i < obj->numVertices(); ++i)
 		{
-			if (not isOneOf (obj->vertex (i), (*it)->vertex (0), (*it)->vertex (1)))
+			if (not isOneOf (obj->vertex (i), candidate->vertex (0), candidate->vertex (1)))
 				continue;
 
 			if (++matches == 2)
 			{
 				// Boundary found. If it's an edgeline, add it to the boundaries list, if a
 				// conditional line, select it.
-				if ((*it)->type() == OBJ_CondLine)
-					m_selection << *it;
+				if (candidate->type() == OBJ_CondLine)
+					m_selection << candidate;
 				else
-					boundaries.append (std::make_tuple ((*it)->vertex (0), (*it)->vertex (1)));
+					boundaries.append (std::make_tuple (candidate->vertex (0), candidate->vertex (1)));
 
 				break;
 			}
@@ -78,7 +78,7 @@
 		if (type == Set)
 		{
 			CurrentDocument()->clearSelection();
-			g_win->buildObjList();
+			m_window->buildObjList();
 		}
 
 		return;
@@ -178,24 +178,24 @@
 
 	switch (type)
 	{
-		case Set:
-			CurrentDocument()->clearSelection();
-		case Additive:
-			for (LDObject* obj : m_selection)
-				obj->select();
-			break;
+	case Set:
+		CurrentDocument()->clearSelection();
+	case Additive:
+		for (LDObject* obj : m_selection)
+			obj->select();
+		break;
 
-		case Subtractive:
-			for (LDObject* obj : m_selection)
-				obj->deselect();
-			break;
+	case Subtractive:
+		for (LDObject* obj : m_selection)
+			obj->deselect();
+		break;
 
-		case InternalRecursion:
-			break;
+	case InternalRecursion:
+		break;
 	}
 
 	if (type != InternalRecursion)
-		g_win->buildObjList();
+		m_window->buildObjList();
 }
 
 bool MagicWandMode::mouseReleased (MouseEventData const& data)
--- a/src/editmodes/selectMode.cpp	Mon Aug 31 23:25:56 2015 +0300
+++ b/src/editmodes/selectMode.cpp	Mon Aug 31 23:36:08 2015 +0300
@@ -123,7 +123,7 @@
 		if (obj != null)
 		{
 			AddObjectDialog::staticDialog (obj->type(), obj);
-			g_win->endAction();
+			m_window->endAction();
 			return true;
 		}
 	}
--- a/src/guiutilities.cpp	Mon Aug 31 23:25:56 2015 +0300
+++ b/src/guiutilities.cpp	Mon Aug 31 23:36:08 2015 +0300
@@ -74,7 +74,7 @@
 	while (it.hasNext())
 	{
 		it.next();
-		QIcon ico = g_win->guiUtilities()->makeColorIcon (it.key(), 16);
+		QIcon ico = makeColorIcon (it.key(), 16);
 		box->addItem (ico, format ("[%1] %2 (%3 object%4)",
 			it.key(), it.key().name(), it.value(), plural (it.value())));
 		box->setItemData (row, it.key().index());

mercurial