[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18894] branches/blender2.5/blender/source /blender/editors/space_graph/graph_draw.c: Graph Editor - Drawing Tweaks

Joshua Leung aligorith at gmail.com
Tue Feb 10 00:46:13 CET 2009


Revision: 18894
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18894
Author:   aligorith
Date:     2009-02-10 00:46:13 +0100 (Tue, 10 Feb 2009)

Log Message:
-----------
Graph Editor - Drawing Tweaks

* Handles now draw with anti-aliased lines for a 'tidier' appearance at certain scales
* Added new drawing code for 'samples'

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c

Modified: branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c	2009-02-09 23:06:29 UTC (rev 18893)
+++ branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c	2009-02-09 23:46:13 UTC (rev 18894)
@@ -154,9 +154,16 @@
 	glTranslatef(x, y, 0.0f);
 	glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
 	
+	/* anti-aliased lines for more consistent appearance */
+	glEnable(GL_LINE_SMOOTH);
+	glEnable(GL_BLEND);
+	
 	/* draw! */
 	glCallList(displist);
 	
+	glDisable(GL_LINE_SMOOTH);
+	glDisable(GL_BLEND);
+	
 	/* restore view transform */
 	glScalef(xscale/hsize, yscale/hsize, 1.0);
 	glTranslatef(-x, -y, 0.0f);
@@ -323,6 +330,74 @@
 	}
 }
 
+/* Samples ---------------- */
+
+/* helper func - draw sample-range marker for an F-Curve as a cross */
+static void draw_fcurve_sample_control (float x, float y, float xscale, float yscale, float hsize)
+{
+	static GLuint displist=0;
+	
+	/* initialise X shape */
+	if (displist == 0) {
+		displist= glGenLists(1);
+		glNewList(displist, GL_COMPILE);
+		
+		glBegin(GL_LINES);
+			glVertex2f(-0.7f, -0.7f);
+			glVertex2f(+0.7f, +0.7f);
+			
+			glVertex2f(-0.7f, +0.7f);
+			glVertex2f(+0.7f, -0.7f);
+		glEnd(); // GL_LINES
+		
+		glEndList();
+	}
+	
+	/* adjust view transform before starting */
+	glTranslatef(x, y, 0.0f);
+	glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
+	
+	/* anti-aliased lines for more consistent appearance */
+		// XXX needed here?
+	glEnable(GL_LINE_SMOOTH);
+	glEnable(GL_BLEND);
+	
+	/* draw! */
+	glCallList(displist);
+	
+	glDisable(GL_BLEND);
+	glDisable(GL_LINE_SMOOTH);
+	
+	/* restore view transform */
+	glScalef(xscale/hsize, yscale/hsize, 1.0);
+	glTranslatef(-x, -y, 0.0f);
+}
+
+/* helper func - draw keyframe vertices only for an F-Curve */
+static void draw_fcurve_samples (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
+{
+	FPoint *first, *last;
+	float hsize, xscale, yscale;
+	
+	/* get view settings */
+	hsize= UI_GetThemeValuef(TH_VERTEX_SIZE);
+	UI_view2d_getscale(&ar->v2d, &xscale, &yscale);
+	
+	/* set vertex color */
+	if (fcu->flag & (FCURVE_ACTIVE|FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI);
+	else UI_ThemeColor(TH_TEXT);
+	
+	/* get verts */
+	first= fcu->fpt;
+	last= (first) ? (first + fcu->totvert) : (NULL);
+	
+	/* draw */
+	if (first && last) {
+		draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize);
+		draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize);
+	}
+}
+
 /* Curve ---------------- */
 
 /* helper func - draw one repeat of an F-Curve */
@@ -627,7 +702,7 @@
 		Object *nob= ANIM_nla_mapping_get(ac, ale);
 		float fac=0.0f; // dummy var
 		
-		/* map ipo-points for drawing if scaled F-Curve */
+		/* map keyframes for drawing if scaled F-Curve */
 		if (nob)
 			ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 0); 
 		
@@ -639,8 +714,15 @@
 			draw_fcurve_repeat(fcu, &ar->v2d, 0, 0, &fac); // XXX this call still needs a lot more work
 			
 			/* draw handles and vertices as appropriate */
-			draw_fcurve_handles(sipo, ar, fcu);
-			draw_fcurve_vertices(sipo, ar, fcu);
+			if (fcu->bezt) {
+				/* only draw handles/vertices on keyframes */
+				draw_fcurve_handles(sipo, ar, fcu);
+				draw_fcurve_vertices(sipo, ar, fcu);
+			}
+			else {
+				/* samples: should we only draw two indicators at either end as indicators? */
+				draw_fcurve_samples(sipo, ar, fcu);
+			}
 		}
 		
 		/* undo mapping of keyframes for drawing if scaled F-Curve */





More information about the Bf-blender-cvs mailing list