- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering

Sun, 27 Apr 2014 04:06:46 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sun, 27 Apr 2014 04:06:46 +0300
changeset 737
e58bdb21cc54
parent 736
0446af72b2ee
child 738
16b63398aa1f

- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering

src/glRenderer.cc file | annotate | diff | comparison | revisions
src/glRenderer.h file | annotate | diff | comparison | revisions
src/ldDocument.cc file | annotate | diff | comparison | revisions
--- a/src/glRenderer.cc	Sun Apr 27 03:53:57 2014 +0300
+++ b/src/glRenderer.cc	Sun Apr 27 04:06:46 2014 +0300
@@ -229,7 +229,6 @@
 	rot (X) = 30.0f;
 	rot (Y) = 325.f;
 	pan (X) = pan (Y) = rot (Z) = 0.0f;
-	zoomToFit();
 }
 
 // =============================================================================
@@ -363,6 +362,12 @@
 	if (document() == null)
 		return;
 
+	if (currentDocumentData().needZoomToFit)
+	{
+		currentDocumentData().needZoomToFit = false;
+		zoomAllToFit();
+	}
+
 	if (gl_wireframe && not isPicking())
 		glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
 
@@ -1366,6 +1371,8 @@
 			resetAllAngles();
 			currentDocumentData().init = true;
 		}
+
+		currentDocumentData().needZoomToFit = true;
 	}
 }
 
--- a/src/glRenderer.h	Sun Apr 27 03:53:57 2014 +0300
+++ b/src/glRenderer.h	Sun Apr 27 04:06:46 2014 +0300
@@ -77,8 +77,14 @@
 	double			depthValues[6];
 	LDGLOverlay		overlays[6];
 	bool			init;
+	bool			needZoomToFit;
 
-	LDGLData()
+	LDGLData() :
+		rotX (0.0),
+		rotY (0.0),
+		rotZ (0.0),
+		init (false),
+		needZoomToFit (true)
 	{
 		for (int i = 0; i < 7; ++i)
 		{
@@ -93,11 +99,6 @@
 			panX[i] = 0.0;
 			panY[i] = 0.0;
 		}
-
-		rotX = 0;
-		rotY = 0;
-		rotZ = 0;
-		init = false;
 	}
 };
 
--- a/src/ldDocument.cc	Sun Apr 27 03:53:57 2014 +0300
+++ b/src/ldDocument.cc	Sun Apr 27 04:06:46 2014 +0300
@@ -1399,8 +1399,8 @@
 		g_win->updateDocumentListItem (f);
 		g_win->buildObjList();
 		g_win->updateTitle();
+		g_win->R()->setDocument (f);
 		g_win->R()->compiler()->needMerge();
-		g_win->R()->setDocument (f);
 		print ("Changed file to %1", f->getDisplayName());
 	}
 }

mercurial