From 608436e2fffe58ad3e59228ce88ed37fea43ca04 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Tue, 23 Jun 2009 21:52:48 +0200 Subject: [PATCH] [AdgPath] Stub implementation of adg_path_chamfer() The actual chamfer method is only a placeholder to remind what must be done. --- adg/adg-path-private.h | 28 +++++++++++++++++++++++----- adg/adg-path.c | 29 +++++++++++++++++++++++++++++ adg/adg-path.h | 3 +++ 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/adg/adg-path-private.h b/adg/adg-path-private.h index 6604af11..35788236 100644 --- a/adg/adg-path-private.h +++ b/adg/adg-path-private.h @@ -26,12 +26,30 @@ G_BEGIN_DECLS +typedef enum { + ADG_OPERATOR_NONE, + ADG_OPERATOR_CHAMFER, + ADG_OPERATOR_FILLET +} AdgOperator; + +typedef union { + struct { + gdouble delta1; + gdouble delta2; + } chamfer; + struct { + gdouble radius; + } fillet; +} AdgOperatorData; + struct _AdgPathPrivate { - gboolean cp_is_valid; - AdgPair cp; - GArray *path; - cairo_path_t cpml_path; - cairo_path_t cairo_path; + gboolean cp_is_valid; + AdgPair cp; + GArray *path; + cairo_path_t cpml_path; + cairo_path_t cairo_path; + AdgOperator operator; + AdgOperatorData operator_data; }; G_END_DECLS diff --git a/adg/adg-path.c b/adg/adg-path.c index 453d8a95..5a7b58ef 100644 --- a/adg/adg-path.c +++ b/adg/adg-path.c @@ -94,6 +94,7 @@ adg_path_init(AdgPath *path) priv->cairo_path.status = CAIRO_STATUS_INVALID_PATH_DATA; priv->cairo_path.data = NULL; priv->cairo_path.num_data = 0; + priv->operator = ADG_OPERATOR_NONE; path->priv = priv; } @@ -571,6 +572,34 @@ adg_path_arc(AdgPath *path, gdouble xc, gdouble yc, gdouble r, adg_path_append(path, CAIRO_PATH_ARC_TO, &p[1], &p[2]); } +/** + * adg_path_chamfer + * @path: an #AdgPath + * @delta1: the distance from the intersection point of the current primitive + * @delta2: the distance from the intersection point of the next primitive + * + * A binary operator that generates a chamfer between two primitives. + * The first primitive involved is the current primitive, the second will + * be the next primitive appended to @path after this call. The second + * primitive is required: if the chamfer operation is not properly + * terminated not providing the second primitive, any API accessing the + * path in reading mode will fail. + **/ +void +adg_path_chamfer(AdgPath *path, gdouble delta1, gdouble delta2) +{ + g_return_if_fail(ADG_IS_PATH(path)); + + if (!path->priv->cp_is_valid) { + g_warning("Requested a chamfer operation without a current primitive"); + return; + } + + path->priv->operator = ADG_OPERATOR_CHAMFER; + path->priv->operator_data.chamfer.delta1 = delta1; + path->priv->operator_data.chamfer.delta2 = delta2; +} + /** * adg_path_dump: diff --git a/adg/adg-path.h b/adg/adg-path.h index 4f445e2e..c3d7d724 100644 --- a/adg/adg-path.h +++ b/adg/adg-path.h @@ -96,6 +96,9 @@ void adg_path_arc (AdgPath *path, gdouble r, gdouble start, gdouble end); +void adg_path_chamfer (AdgPath *path, + gdouble delta1, + gdouble delta2); void adg_path_dump (AdgPath *path); -- 2.11.4.GIT