return g_object_new (CHAMPLAIN_TYPE_POLYGON, NULL);
}
-void
-champlain_polygon_add_point (ChamplainPolygon *self,
+/**
+ * champlain_polygon_append_point:
+ * @polygon: The polygon
+ * @lat: the latitude
+ * @lon: the longitude
+ *
+ * Adds point at the end of the list of points in the polygon
+ *
+ * Returns the added point, should not be freed.
+ *
+ * Since: 0.4
+ */
+ChamplainPoint *
+champlain_polygon_append_point (ChamplainPolygon *self,
gdouble lat,
gdouble lon)
{
- g_return_if_fail (CHAMPLAIN_IS_POLYGON (self));
+ g_return_val_if_fail (CHAMPLAIN_IS_POLYGON (self), NULL);
ChamplainPoint *point = g_new0 (ChamplainPoint, 1);
point->lat = lat;
point->lon = lon;
self->priv->points = g_list_append (self->priv->points, point);
+ return point;
}
+/**
+ * champlain_polygon_insert_point:
+ * @polygon: The polygon
+ * @lat: the latitude
+ * @lon: the longitude
+ * @pos: where to insert the point
+ *
+ * Adds point at the given position in the list of points in the polygon
+ *
+ * Returns the added point, should not be freed.
+ *
+ * Since: 0.4
+ */
+ChamplainPoint *
+champlain_polygon_insert_point (ChamplainPolygon *self,
+ gdouble lat,
+ gdouble lon,
+ gint pos)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_POLYGON (self), NULL);
+
+ ChamplainPoint *point = g_new0 (ChamplainPoint, 1);
+ point->lat = lat;
+ point->lon = lon;
+
+ self->priv->points = g_list_insert (self->priv->points, point, pos);
+ return point;
+}
+
+/**
+ * champlain_polygon_clear_points:
+ * @polygon: The polygon
+ *
+ * Remove all points from the polygon
+ *
+ * Since: 0.4
+ */
void
champlain_polygon_clear_points (ChamplainPolygon *self)
{
g_list_free (self->priv->points);
}
+/**
+ * champlain_polygon_get_points:
+ * @polygon: The polygon
+ *
+ * Returns a list of all points from the polygon, it shouldn't be freed.
+ *
+ * Since: 0.4
+ */
+GList *
+champlain_polygon_get_points (ChamplainPolygon *self)
+{
+ g_return_val_if_fail (CHAMPLAIN_IS_POLYGON (self), NULL);
+
+ return self->priv->points;
+}
+
/**
* champlain_polygon_set_fill_color:
* @polygon: The polygon
GType champlain_polygon_get_type (void);
-ChamplainPolygon* champlain_polygon_new (void);
+ChamplainPolygon * champlain_polygon_new (void);
-void champlain_polygon_add_point (ChamplainPolygon *polygon,
+ChamplainPoint * champlain_polygon_append_point (ChamplainPolygon *polygon,
gdouble lat,
gdouble lon);
-
+ChamplainPoint * champlain_polygon_insert_point (ChamplainPolygon *polygon,
+ gdouble lat,
+ gdouble lon,
+ gint pos);
void champlain_polygon_clear_points (ChamplainPolygon *polygon);
+GList *champlain_polygon_get_points (ChamplainPolygon *polygon);
+
void champlain_polygon_set_fill_color (ChamplainPolygon *polygon,
const ClutterColor *color);
void champlain_polygon_set_stroke_color (ChamplainPolygon *polygon,
/* draw a line */
polygon = champlain_polygon_new ();
/* Cheap approx of Highway 10 */
- champlain_polygon_add_point (polygon, 45.4095, -73.3197);
- champlain_polygon_add_point (polygon, 45.4104, -73.2846);
- champlain_polygon_add_point (polygon, 45.4178, -73.2239);
- champlain_polygon_add_point (polygon, 45.4176, -73.2181);
- champlain_polygon_add_point (polygon, 45.4151, -73.2126);
- champlain_polygon_add_point (polygon, 45.4016, -73.1926);
- champlain_polygon_add_point (polygon, 45.3994, -73.1877);
- champlain_polygon_add_point (polygon, 45.4000, -73.1815);
- champlain_polygon_add_point (polygon, 45.4151, -73.1218);
+ champlain_polygon_append_point (polygon, 45.4095, -73.3197);
+ champlain_polygon_append_point (polygon, 45.4104, -73.2846);
+ champlain_polygon_append_point (polygon, 45.4178, -73.2239);
+ champlain_polygon_append_point (polygon, 45.4176, -73.2181);
+ champlain_polygon_append_point (polygon, 45.4151, -73.2126);
+ champlain_polygon_append_point (polygon, 45.4016, -73.1926);
+ champlain_polygon_append_point (polygon, 45.3994, -73.1877);
+ 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);
champlain_view_add_polygon (CHAMPLAIN_VIEW (actor), polygon);
/* draw a polygon */
polygon = champlain_polygon_new ();
- champlain_polygon_add_point (polygon, 45.1386, -73.9196);
- champlain_polygon_add_point (polygon, 45.1229, -73.8991);
- champlain_polygon_add_point (polygon, 45.0946, -73.9531);
- champlain_polygon_add_point (polygon, 45.1085, -73.9714);
- champlain_polygon_add_point (polygon, 45.1104, -73.9761);
+ champlain_polygon_append_point (polygon, 45.1386, -73.9196);
+ champlain_polygon_append_point (polygon, 45.1229, -73.8991);
+ champlain_polygon_append_point (polygon, 45.0946, -73.9531);
+ champlain_polygon_append_point (polygon, 45.1085, -73.9714);
+ champlain_polygon_append_point (polygon, 45.1104, -73.9761);
champlain_view_add_polygon (CHAMPLAIN_VIEW (actor), polygon);
g_object_set (polygon, "closed-path", TRUE, NULL);
g_object_set (polygon, "fill", TRUE, NULL);