[libchamplain/libchamplain-0-4] Change the point drawing logic



commit 43431d1b1bd7ef893c616f267c9b037e544a3db9
Author: Pierre-Luc Beaudoin <pierre-luc pierlux com>
Date:   Tue Jan 5 12:57:56 2010 -0500

    Change the point drawing logic
    
    This is less efficient (you have to loop twice) but
    this is more accurate as the points are not part of the polygon.

 champlain/champlain-polygon.c |    4 ++--
 champlain/champlain-view.c    |   27 ++++++++++++++++++++++++---
 demos/launcher-gtk.c          |    3 +++
 3 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/champlain/champlain-polygon.c b/champlain/champlain-polygon.c
index 43ba16b..b2889fe 100644
--- a/champlain/champlain-polygon.c
+++ b/champlain/champlain-polygon.c
@@ -268,7 +268,7 @@ champlain_polygon_class_init (ChamplainPolygonClass *klass)
   *
   * Wether the polygons points should be marked for extra visibility.
   *
-  * Since: 0.X
+  * Since: 0.4.3
   */
   g_object_class_install_property (object_class,
       PROP_MARK_POINTS,
@@ -637,7 +637,7 @@ champlain_polygon_get_stroke_width (ChamplainPolygon *polygon)
  * Sets the property determining if the points in the polygon
  * should get marked for extra visibility when drawing the polygon.
  *
- * Since: 0.X
+ * Since: 0.4.3
  */
 void
 champlain_polygon_set_mark_points (ChamplainPolygon *polygon,
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index fc3e036..c22b556 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -428,9 +428,6 @@ draw_polygon (ChamplainView *view, ChamplainPolygon *polygon)
 
       cairo_line_to (cr, x, y);
 
-      if (polygon->priv->mark_points)
-        cairo_arc (cr, x, y, polygon->priv->stroke_width, 0, 2 * M_PI);
-
       list = list->next;
     }
 
@@ -457,6 +454,30 @@ draw_polygon (ChamplainView *view, ChamplainPolygon *polygon)
   if (polygon->priv->stroke)
     cairo_stroke (cr);
 
+  if (polygon->priv->mark_points)
+    {
+      /* Draw points */
+      GList *list = g_list_first (polygon->priv->points);
+      while (list != NULL)
+        {
+          ChamplainPoint *point = (ChamplainPoint*) list->data;
+          gfloat x, y;
+
+          x = champlain_map_source_get_x (priv->map_source, priv->zoom_level,
+              point->lon);
+          y = champlain_map_source_get_y (priv->map_source, priv->zoom_level,
+              point->lat);
+
+          x -= priv->viewport_size.x + priv->anchor.x;
+          y -= priv->viewport_size.y + priv->anchor.y;
+
+          cairo_arc (cr, x, y, polygon->priv->stroke_width * 1.5, 0, 2 * M_PI);
+          cairo_fill (cr);
+
+          list = list->next;
+        }
+    }
+
   cairo_destroy (cr);
 }
 
diff --git a/demos/launcher-gtk.c b/demos/launcher-gtk.c
index 305bca9..3172bb1 100644
--- a/demos/launcher-gtk.c
+++ b/demos/launcher-gtk.c
@@ -233,6 +233,9 @@ main (int argc,
   champlain_polygon_append_point (polygon, 45.4000, -73.1815);
   champlain_polygon_append_point (polygon, 45.4151, -73.1218);
   champlain_polygon_set_stroke_width (polygon, 5.0);
+  g_object_set (G_OBJECT (polygon),
+      "mark-points", TRUE,
+      NULL);
   champlain_view_add_polygon (CHAMPLAIN_VIEW (view), polygon);
   champlain_polygon_hide (polygon);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]