Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-02-10 02:46:13 +0300
committerJoshua Leung <aligorith@gmail.com>2009-02-10 02:46:13 +0300
commit181068454f7f6f18eba72b52339a65058945ff25 (patch)
tree8833ddcc20d3b658b6516e83c14cd49c650a1828 /source/blender/editors/space_graph/graph_draw.c
parent97c5d50cffd5fcd3d96808392e29444a257d8a99 (diff)
Graph Editor - Drawing Tweaks
* Handles now draw with anti-aliased lines for a 'tidier' appearance at certain scales * Added new drawing code for 'samples'
Diffstat (limited to 'source/blender/editors/space_graph/graph_draw.c')
-rw-r--r--source/blender/editors/space_graph/graph_draw.c88
1 files changed, 85 insertions, 3 deletions
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 8de273c9428..1924fc0b508 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -154,9 +154,16 @@ static void draw_fcurve_handle_control (float x, float y, float xscale, float ys
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 @@ static void draw_fcurve_handles (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
}
}
+/* 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 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
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 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
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 */