src/canvas.cpp

changeset 1199
613a981223a6
parent 1187
46dc716238fd
--- a/src/canvas.cpp	Mon Mar 06 00:43:43 2017 +0200
+++ b/src/canvas.cpp	Mon Mar 06 00:55:45 2017 +0200
@@ -98,11 +98,11 @@
 	// Find the top left corner of the grid
 	Vertex topLeft = currentCamera().idealize(currentCamera().convert2dTo3d({0, 0}));
 	Vertex bottomRight = currentCamera().idealize(currentCamera().convert2dTo3d({width(), height()}));
-	qreal gridSize = grid()->coordinateSnap();
+	qreal gridSize = Grid::coordinateSnap();
 	glEnable(GL_LINE_STIPPLE);
 	glBegin(GL_LINES);
 
-	switch (grid()->type())
+	switch (Grid::type())
 	{
 	case Grid::Cartesian:
 		{
@@ -148,8 +148,8 @@
 
 	case Grid::Polar:
 		{
-			const QPointF pole = grid()->pole();
-			const qreal size = grid()->coordinateSnap();
+			const QPointF pole = Grid::pole();
+			const qreal size = Grid::coordinateSnap();
 			Vertex topLeft = currentCamera().idealize(currentCamera().convert2dTo3d({0, 0}));
 			Vertex bottomRight = currentCamera().idealize(currentCamera().convert2dTo3d({width(), height()}));
 			QPointF topLeft2d {topLeft.x(), topLeft.y()};
@@ -171,9 +171,9 @@
 			glColor4f(0, 0, 0, 0.25);
 
 			// Render the axes
-			for (int i = 0; i < grid()->polarDivisions() / 2; ++i)
+			for (int i = 0; i < Grid::polarDivisions() / 2; ++i)
 			{
-				qreal azimuth = (2.0 * pi) * i / grid()->polarDivisions();
+				qreal azimuth = (2.0 * pi) * i / Grid::polarDivisions();
 
 				if (not poleIsOrigin or not isZero(fmod(azimuth, pi / 2)))
 				{
@@ -191,17 +191,17 @@
 				{
 					Vertex points[48];
 
-					for (int i = 0; i < grid()->polarDivisions(); ++i)
+					for (int i = 0; i < Grid::polarDivisions(); ++i)
 					{
-						qreal azimuth = (2.0 * pi) * i / grid()->polarDivisions();
+						qreal azimuth = (2.0 * pi) * i / Grid::polarDivisions();
 						QPointF point = pole + QPointF {radius * cos(azimuth), radius * sin(azimuth)};
 						points[i] = currentCamera().realize({point.x(), point.y(), 999});
 					}
 
-					for (int i = 0; i < grid()->polarDivisions(); ++i)
+					for (int i = 0; i < Grid::polarDivisions(); ++i)
 					{
 						glVertex(points[i]);
-						glVertex(ring(points, grid()->polarDivisions())[i + 1]);
+						glVertex(ring(points, Grid::polarDivisions())[i + 1]);
 					}
 				}
 			}
@@ -274,7 +274,7 @@
 void Canvas::mouseMoveEvent(QMouseEvent* event)
 {
 	// Calculate 3d position of the cursor
-	m_position3D = currentCamera().convert2dTo3d(mousePosition(), grid());
+	m_position3D = currentCamera().convert2dTo3d(mousePosition(), true);
 
 	if (not m_currentEditMode->mouseMoved(event))
 		GLRenderer::mouseMoveEvent(event);

mercurial