[Tomoe-cvs 1068] CVS update: libtomoe-gtk/src

Back to archive index

Hiroyuki Ikezoe ikezo****@users*****
2006年 11月 27日 (月) 12:06:22 JST


Index: libtomoe-gtk/src/tomoe-canvas.c
diff -u libtomoe-gtk/src/tomoe-canvas.c:1.35 libtomoe-gtk/src/tomoe-canvas.c:1.36
--- libtomoe-gtk/src/tomoe-canvas.c:1.35	Mon Nov 27 11:58:39 2006
+++ libtomoe-gtk/src/tomoe-canvas.c	Mon Nov 27 12:06:21 2006
@@ -104,11 +104,6 @@
                                                  gint               dy);
 
 static void   _init_gc                          (TomoeCanvas       *canvas);
-static gint   get_distance                      (GList             *first_node,
-                                                 GList             *last_node,
-                                                 GList            **most_node);
-static GList *get_vertex                        (GList             *first_node,
-                                                 GList             *last_node);
 static void   draw_stroke                       (GList             *points,
                                                  TomoeCanvas       *canvas,
                                                  guint              index);
@@ -444,40 +439,6 @@
     return retval;
 }
 
-static TomoeWriting *
-create_sparse_writing (TomoeCanvas *canvas)
-{
-    TomoeWriting *new;
-    TomoeCanvasPriv *priv;
-    const GList *strokes, *list;
-
-    g_return_val_if_fail (TOMOE_IS_CANVAS (canvas), NULL);
-
-    priv = TOMOE_CANVAS_GET_PRIVATE (canvas);
-    new = tomoe_writing_new ();
-
-    strokes = tomoe_writing_get_strokes (priv->writing);
-    for (list = strokes; list; list = g_list_next (list)) {
-        GList *points = (GList *) list->data;
-        GList *point, *new_points;
-        TomoePoint *start_point = (TomoePoint *) points->data;
-
-        tomoe_writing_move_to (new, start_point->x, start_point->y);
-    
-        new_points = g_list_prepend (get_vertex(points, g_list_last(points)),
-                                     points->data);
-    
-        for (point = new_points; point; point = g_list_next (point)) {
-            TomoePoint *p = (TomoePoint *) point->data;
-            gint x, y;
-            x = p->x * ((gdouble)TOMOE_WRITING_DEFAULT_SIZE / priv->size);
-            y = p->y * ((gdouble)TOMOE_WRITING_DEFAULT_SIZE / priv->size);
-            tomoe_writing_line_to (new, x, y);
-        }
-    }
-
-    return new;
-}
 
 static void
 tomoe_canvas_real_find (TomoeCanvas *canvas)
@@ -497,8 +458,7 @@
 
     _init_gc (canvas);
 
-    /* create a new writing which has more sparse points */
-    writing = create_sparse_writing (canvas);
+    writing = priv->writing;
 
     /* draw thin red lines and annotations for sparse points */
     strokes = tomoe_writing_get_strokes (writing);
@@ -528,7 +488,6 @@
     tomoe_query_set_writing (query, writing);
     priv->candidates = tomoe_context_search (priv->context, query);
     g_object_unref (query);
-    g_object_unref (writing);
 
     gdk_draw_drawable(widget->window,
                       widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
@@ -1105,69 +1064,6 @@
     }
 }
 
-static gint
-get_distance (GList *first_node, GList *last_node, GList **most_node)
-{
-    /* Getting distance 
-     * MAX( |aw - bv + c| )
-     * a = x-p : b = y-q : c = py - qx
-     * first = (p, q) : last = (x, y) : other = (v, w)
-     */
-
-    GList *dot;
-    gint a, b, c;
-    gint dist = 0;
-    gint max  = 0;
-    gint denom;
-    TomoePoint *first = (TomoePoint*) first_node->data;
-    TomoePoint *last  = (TomoePoint*) last_node->data;
-    TomoePoint *p;
-
-    *most_node = NULL;
-    if (first_node == last_node) {
-        return 0;
-    }
-
-    a = last->x - first->x;
-    b = last->y - first->y;
-    c = last->y * first->x - last->x * first->y;
-
-    for (dot = first_node; dot != last_node; dot = dot->next) {
-        p = (TomoePoint*) dot->data;
-        dist = abs((a * p->y) - (b * p->x) + c);
-        if (dist > max) {
-            max = dist;
-            *most_node = dot;
-        }
-    }
-
-    denom = a * a + b * b;
-
-    if (denom == 0)
-        return 0;
-    else
-        return max * max / denom;
-}
-
-static GList*
-get_vertex (GList *first_node, GList *last_node)
-{
-    GList *rv = NULL;
-    GList *most_node;
-    gint dist;
-    gint error = 300 * 300 / 400; /* 5% */
-
-    dist = get_distance(first_node, last_node, &most_node);
-
-    if (dist > error) {
-        rv = g_list_concat(get_vertex(first_node, most_node),
-                           get_vertex(most_node, last_node));
-    } else {
-        rv = g_list_append(rv, last_node->data);
-    }
-    return rv;
-}
-
 static void
 draw_stroke (GList *points, TomoeCanvas *canvas, guint index)
 {


tomoe-cvs メーリングリストの案内
Back to archive index