From 9884106d521a12bfed3a778111740f42d5afd964 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Tue, 12 Aug 2008 19:54:25 +0200 Subject: [PATCH] Tab expansion in all the source files --- adg/adg-adim-private.h | 8 +- adg/adg-adim.c | 24 +-- adg/adg-adim.h | 6 +- adg/adg-arrow-style-private.h | 8 +- adg/adg-arrow-style.c | 262 ++++++++++++++-------------- adg/adg-arrow-style.h | 46 ++--- adg/adg-canvas.c | 8 +- adg/adg-canvas.h | 6 +- adg/adg-container-private.h | 10 +- adg/adg-container.c | 144 ++++++++-------- adg/adg-container.h | 20 +-- adg/adg-context-private.h | 6 +- adg/adg-context.c | 48 +++--- adg/adg-context.h | 22 +-- adg/adg-dim-private.h | 30 ++-- adg/adg-dim-style-private.h | 28 +-- adg/adg-dim-style.c | 328 +++++++++++++++++------------------ adg/adg-dim-style.h | 112 ++++++------ adg/adg-dim.c | 364 +++++++++++++++++++-------------------- adg/adg-dim.h | 14 +- adg/adg-entity-private.h | 6 +- adg/adg-entity.c | 198 ++++++++++----------- adg/adg-entity.h | 50 +++--- adg/adg-enums.h | 2 +- adg/adg-font-style-private.h | 16 +- adg/adg-font-style.c | 264 ++++++++++++++-------------- adg/adg-font-style.h | 64 +++---- adg/adg-ldim-private.h | 10 +- adg/adg-ldim.c | 118 ++++++------- adg/adg-ldim.h | 6 +- adg/adg-line-style-private.h | 2 +- adg/adg-line-style.c | 196 ++++++++++----------- adg/adg-line-style.h | 42 ++--- adg/adg-matrix.c | 6 +- adg/adg-matrix.h | 18 +- adg/adg-model-private.h | 6 +- adg/adg-model.c | 88 +++++----- adg/adg-model.h | 8 +- adg/adg-pair.c | 6 +- adg/adg-pair.h | 4 +- adg/adg-path-private.h | 10 +- adg/adg-path.c | 388 +++++++++++++++++++++--------------------- adg/adg-path.h | 6 +- adg/adg-pattern.c | 6 +- adg/adg-pattern.h | 2 +- adg/adg-style-private.h | 2 +- adg/adg-style.c | 64 +++---- adg/adg-style.h | 34 ++-- adg/adg-util.h | 6 +- cpml/cpml-pair.c | 72 ++++---- cpml/cpml-pair.h | 34 ++-- cpml/cpml-path.c | 164 +++++++++--------- cpml/cpml-path.h | 52 +++--- demo/adg-demo.c | 62 +++---- demo/ldim.c | 4 +- 55 files changed, 1755 insertions(+), 1755 deletions(-) diff --git a/adg/adg-adim-private.h b/adg/adg-adim-private.h index d320ddc4..34e3426b 100644 --- a/adg/adg-adim-private.h +++ b/adg/adg-adim-private.h @@ -28,10 +28,10 @@ G_BEGIN_DECLS struct _AdgADimPrivate { /* Cache */ - cairo_path_t extension1; - cairo_path_t extension2; - cairo_path_t arrow_path; - cairo_path_t baseline; + cairo_path_t extension1; + cairo_path_t extension2; + cairo_path_t arrow_path; + cairo_path_t baseline; }; G_END_DECLS diff --git a/adg/adg-adim.c b/adg/adg-adim.c index 8fec6a9d..ed83e09c 100644 --- a/adg/adg-adim.c +++ b/adg/adg-adim.c @@ -42,12 +42,12 @@ enum { }; -static void finalize (GObject *object); -static void model_matrix_changed (AdgEntity *entity, - AdgMatrix *parent_matrix); -static void render (AdgEntity *entity, - cairo_t *cr); -static gchar * default_quote (AdgDim *dim); +static void finalize (GObject *object); +static void model_matrix_changed (AdgEntity *entity, + AdgMatrix *parent_matrix); +static void render (AdgEntity *entity, + cairo_t *cr); +static gchar * default_quote (AdgDim *dim); G_DEFINE_TYPE(AdgADim, adg_adim, ADG_TYPE_DIM); @@ -74,10 +74,10 @@ adg_adim_class_init(AdgADimClass *klass) dim_class->default_quote = default_quote; param = g_param_spec_double("direction", - P_("Direction"), - P_("The inclination angle of the extension lines"), - -G_MAXDOUBLE, G_MAXDOUBLE, CPML_DIR_RIGHT, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + P_("Direction"), + P_("The inclination angle of the extension lines"), + -G_MAXDOUBLE, G_MAXDOUBLE, CPML_DIR_RIGHT, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property(gobject_class, PROP_DIRECTION, param); } @@ -85,7 +85,7 @@ static void adg_adim_init(AdgADim *adim) { AdgADimPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(adim, ADG_TYPE_ADIM, - AdgADimPrivate); + AdgADimPrivate); priv->extension1.status = CAIRO_STATUS_SUCCESS; priv->extension1.data = NULL; @@ -121,7 +121,7 @@ static void model_matrix_changed(AdgEntity *entity, AdgMatrix *parent_matrix) { ((AdgEntityClass *) PARENT_CLASS)->model_matrix_changed(entity, - parent_matrix); + parent_matrix); /* TODO */ } diff --git a/adg/adg-adim.h b/adg/adg-adim.h index 8dc4b73f..cf0eb233 100644 --- a/adg/adg-adim.h +++ b/adg/adg-adim.h @@ -39,13 +39,13 @@ typedef struct _AdgADimClass AdgADimClass; typedef struct _AdgADimPrivate AdgADimPrivate; struct _AdgADim { - AdgDim dim; + AdgDim dim; /*< private >*/ - AdgADimPrivate *priv; + AdgADimPrivate *priv; }; struct _AdgADimClass { - AdgDimClass parent_class; + AdgDimClass parent_class; }; diff --git a/adg/adg-arrow-style-private.h b/adg/adg-arrow-style-private.h index 4a5b3975..5a0f78a8 100644 --- a/adg/adg-arrow-style-private.h +++ b/adg/adg-arrow-style-private.h @@ -27,10 +27,10 @@ G_BEGIN_DECLS struct _AdgArrowStylePrivate { - gdouble size; - gdouble angle; - gdouble margin; - AdgArrowRenderer renderer; + gdouble size; + gdouble angle; + gdouble margin; + AdgArrowRenderer renderer; }; G_END_DECLS diff --git a/adg/adg-arrow-style.c b/adg/adg-arrow-style.c index d35c86a9..accc9fc8 100644 --- a/adg/adg-arrow-style.c +++ b/adg/adg-arrow-style.c @@ -44,42 +44,42 @@ enum { }; -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static GPtrArray * get_pool (void); -static void arrow_renderer (AdgArrowStyle *arrow_style, - cairo_t *cr, - CpmlPath *segment); -static void triangle_renderer (AdgArrowStyle *arrow_style, - cairo_t *cr, - CpmlPath *segment); -static void dot_renderer (AdgArrowStyle *arrow_style, - cairo_t *cr, - CpmlPath *segment); -static void circle_renderer (AdgArrowStyle *arrow_style, - cairo_t *cr, - CpmlPath *segment); -static void block_renderer (AdgArrowStyle *arrow_style, - cairo_t *cr, - CpmlPath *segment); -static void square_renderer (AdgArrowStyle *arrow_style, - cairo_t *cr, - CpmlPath *segment); -static void tick_renderer (AdgArrowStyle *arrow_style, - cairo_t *cr, - CpmlPath *segment); -static void draw_triangle (cairo_t *cr, - AdgArrowStyle *arrow_style, - CpmlPath *segment); -static void draw_circle (cairo_t *cr, - AdgArrowStyle *arrow_style, - CpmlPath *segment); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static GPtrArray * get_pool (void); +static void arrow_renderer (AdgArrowStyle *arrow_style, + cairo_t *cr, + CpmlPath *segment); +static void triangle_renderer (AdgArrowStyle *arrow_style, + cairo_t *cr, + CpmlPath *segment); +static void dot_renderer (AdgArrowStyle *arrow_style, + cairo_t *cr, + CpmlPath *segment); +static void circle_renderer (AdgArrowStyle *arrow_style, + cairo_t *cr, + CpmlPath *segment); +static void block_renderer (AdgArrowStyle *arrow_style, + cairo_t *cr, + CpmlPath *segment); +static void square_renderer (AdgArrowStyle *arrow_style, + cairo_t *cr, + CpmlPath *segment); +static void tick_renderer (AdgArrowStyle *arrow_style, + cairo_t *cr, + CpmlPath *segment); +static void draw_triangle (cairo_t *cr, + AdgArrowStyle *arrow_style, + CpmlPath *segment); +static void draw_circle (cairo_t *cr, + AdgArrowStyle *arrow_style, + CpmlPath *segment); G_DEFINE_TYPE(AdgArrowStyle, adg_arrow_style, ADG_TYPE_STYLE) @@ -103,34 +103,34 @@ adg_arrow_style_class_init(AdgArrowStyleClass *klass) style_class->get_pool = get_pool; param = g_param_spec_double("size", - P_("Arrow Size"), - P_ - ("The size of the arrow, a renderer dependent parameter"), - -G_MAXDOUBLE, G_MAXDOUBLE, 14., - G_PARAM_READWRITE); + P_("Arrow Size"), + P_ + ("The size of the arrow, a renderer dependent parameter"), + -G_MAXDOUBLE, G_MAXDOUBLE, 14., + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_SIZE, param); param = g_param_spec_double("angle", - P_("Arrow Angle"), - P_ - ("The angle of the arrow, a renderer dependent parameter"), - -G_MAXDOUBLE, G_MAXDOUBLE, G_PI / 6., - G_PARAM_READWRITE); + P_("Arrow Angle"), + P_ + ("The angle of the arrow, a renderer dependent parameter"), + -G_MAXDOUBLE, G_MAXDOUBLE, G_PI / 6., + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_ANGLE, param); param = g_param_spec_double("margin", - P_("Arrow Margin"), - P_ - ("The margin of the arrow, a renderer dependent parameter"), - -G_MAXDOUBLE, G_MAXDOUBLE, 14., - G_PARAM_READWRITE); + P_("Arrow Margin"), + P_ + ("The margin of the arrow, a renderer dependent parameter"), + -G_MAXDOUBLE, G_MAXDOUBLE, 14., + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_MARGIN, param); param = g_param_spec_pointer("renderer", - P_("Renderer Callback"), - P_ - ("The callback to call to renderer this arrow type"), - G_PARAM_READWRITE); + P_("Renderer Callback"), + P_ + ("The callback to call to renderer this arrow type"), + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_RENDERER, param); } @@ -138,8 +138,8 @@ static void adg_arrow_style_init(AdgArrowStyle *arrow_style) { AdgArrowStylePrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(arrow_style, - ADG_TYPE_ARROW_STYLE, - AdgArrowStylePrivate); + ADG_TYPE_ARROW_STYLE, + AdgArrowStylePrivate); priv->size = 14.; priv->angle = G_PI / 6.; @@ -156,45 +156,45 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) switch (prop_id) { case PROP_SIZE: - g_value_set_double(value, arrow_style->priv->size); - break; + g_value_set_double(value, arrow_style->priv->size); + break; case PROP_ANGLE: - g_value_set_double(value, arrow_style->priv->angle); - break; + g_value_set_double(value, arrow_style->priv->angle); + break; case PROP_MARGIN: - g_value_set_double(value, arrow_style->priv->margin); - break; + g_value_set_double(value, arrow_style->priv->margin); + break; case PROP_RENDERER: - g_value_set_pointer(value, arrow_style->priv->renderer); - break; + g_value_set_pointer(value, arrow_style->priv->renderer); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgArrowStyle *arrow_style = (AdgArrowStyle *) object; switch (prop_id) { case PROP_SIZE: - arrow_style->priv->size = g_value_get_double(value); - break; + arrow_style->priv->size = g_value_get_double(value); + break; case PROP_ANGLE: - arrow_style->priv->angle = g_value_get_double(value); - break; + arrow_style->priv->angle = g_value_get_double(value); + break; case PROP_MARGIN: - arrow_style->priv->margin = g_value_get_double(value); - break; + arrow_style->priv->margin = g_value_get_double(value); + break; case PROP_RENDERER: - arrow_style->priv->renderer = g_value_get_pointer(value); - break; + arrow_style->priv->renderer = g_value_get_pointer(value); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } @@ -212,7 +212,7 @@ adg_arrow_style_get_slot(void) static AdgStyleSlot slot = -1; if (G_UNLIKELY(slot < 0)) - slot = adg_context_get_slot(ADG_TYPE_ARROW_STYLE); + slot = adg_context_get_slot(ADG_TYPE_ARROW_STYLE); return slot; } @@ -241,7 +241,7 @@ adg_arrow_style_new(void) **/ void adg_arrow_style_render(AdgArrowStyle *arrow_style, - cairo_t *cr, CpmlPath *segment) + cairo_t *cr, CpmlPath *segment) { g_return_if_fail(arrow_style != NULL); g_return_if_fail(cr != NULL); @@ -249,7 +249,7 @@ adg_arrow_style_render(AdgArrowStyle *arrow_style, /* NULL renderer */ if (arrow_style->priv->renderer == NULL) - return; + return; PARENT_CLASS->apply((AdgStyle *) arrow_style, cr); arrow_style->priv->renderer(arrow_style, cr, segment); @@ -377,7 +377,7 @@ adg_arrow_style_get_renderer(AdgArrowStyle *arrow_style) **/ void adg_arrow_style_set_renderer(AdgArrowStyle *arrow_style, - AdgArrowRenderer renderer) + AdgArrowRenderer renderer) { g_return_if_fail(ADG_IS_ARROW_STYLE(arrow_style)); @@ -392,34 +392,34 @@ get_pool(void) static GPtrArray *pool = NULL; if (G_UNLIKELY(pool == NULL)) { - pool = g_ptr_array_sized_new(ADG_ARROW_STYLE_LAST); - - pool->pdata[ADG_ARROW_STYLE_ARROW] = - g_object_new(ADG_TYPE_ARROW_STYLE, "renderer", arrow_renderer, - NULL); - pool->pdata[ADG_ARROW_STYLE_TRIANGLE] = - g_object_new(ADG_TYPE_ARROW_STYLE, "renderer", - triangle_renderer, NULL); - pool->pdata[ADG_ARROW_STYLE_DOT] = - g_object_new(ADG_TYPE_ARROW_STYLE, "size", 5., "angle", 0., - "margin", 2.5, "renderer", dot_renderer, NULL); - pool->pdata[ADG_ARROW_STYLE_CIRCLE] = - g_object_new(ADG_TYPE_ARROW_STYLE, "size", 10., "angle", 0., - "margin", 5., "renderer", circle_renderer, NULL); - pool->pdata[ADG_ARROW_STYLE_BLOCK] = - g_object_new(ADG_TYPE_ARROW_STYLE, "size", 10., "angle", 0., - "margin", 5., "renderer", block_renderer, NULL); - pool->pdata[ADG_ARROW_STYLE_SQUARE] = - g_object_new(ADG_TYPE_ARROW_STYLE, "size", 10., "angle", 0., - "margin", -0.1, "renderer", square_renderer, - NULL); - pool->pdata[ADG_ARROW_STYLE_TICK] = - g_object_new(ADG_TYPE_ARROW_STYLE, "size", 20., "angle", - G_PI / 3., "margin", 0., "renderer", - tick_renderer, NULL); - - pool->len = ADG_ARROW_STYLE_LAST; - } + pool = g_ptr_array_sized_new(ADG_ARROW_STYLE_LAST); + + pool->pdata[ADG_ARROW_STYLE_ARROW] = + g_object_new(ADG_TYPE_ARROW_STYLE, "renderer", arrow_renderer, + NULL); + pool->pdata[ADG_ARROW_STYLE_TRIANGLE] = + g_object_new(ADG_TYPE_ARROW_STYLE, "renderer", + triangle_renderer, NULL); + pool->pdata[ADG_ARROW_STYLE_DOT] = + g_object_new(ADG_TYPE_ARROW_STYLE, "size", 5., "angle", 0., + "margin", 2.5, "renderer", dot_renderer, NULL); + pool->pdata[ADG_ARROW_STYLE_CIRCLE] = + g_object_new(ADG_TYPE_ARROW_STYLE, "size", 10., "angle", 0., + "margin", 5., "renderer", circle_renderer, NULL); + pool->pdata[ADG_ARROW_STYLE_BLOCK] = + g_object_new(ADG_TYPE_ARROW_STYLE, "size", 10., "angle", 0., + "margin", 5., "renderer", block_renderer, NULL); + pool->pdata[ADG_ARROW_STYLE_SQUARE] = + g_object_new(ADG_TYPE_ARROW_STYLE, "size", 10., "angle", 0., + "margin", -0.1, "renderer", square_renderer, + NULL); + pool->pdata[ADG_ARROW_STYLE_TICK] = + g_object_new(ADG_TYPE_ARROW_STYLE, "size", 20., "angle", + G_PI / 3., "margin", 0., "renderer", + tick_renderer, NULL); + + pool->len = ADG_ARROW_STYLE_LAST; + } return pool; } @@ -484,35 +484,35 @@ draw_triangle(cairo_t *cr, AdgArrowStyle *arrow_style, CpmlPath *segment) switch (segment->cairo_path.data[0].header.type) { case CAIRO_PATH_LINE_TO: - cpml_primitive_get_pair(segment, &vector, CPML_FIRST); - vector.x -= segment->org.x; - vector.y -= segment->org.y; - cpml_vector_from_pair(&vector, &vector); + cpml_primitive_get_pair(segment, &vector, CPML_FIRST); + vector.x -= segment->org.x; + vector.y -= segment->org.y; + cpml_vector_from_pair(&vector, &vector); - tail.x = vector.x * length + segment->org.x; - tail.y = vector.y * length + segment->org.y; + tail.x = vector.x * length + segment->org.x; + tail.y = vector.y * length + segment->org.y; - tmp = vector.x; - vector.x = -vector.y * height_2; - vector.y = tmp * height_2; + tmp = vector.x; + vector.x = -vector.y * height_2; + vector.y = tmp * height_2; - tail1.x = tail.x + vector.x; - tail1.y = tail.y + vector.y; + tail1.x = tail.x + vector.x; + tail1.y = tail.y + vector.y; - tail2.x = tail.x - vector.x; - tail2.y = tail.y - vector.y; + tail2.x = tail.x - vector.x; + tail2.y = tail.y - vector.y; - cairo_move_to(cr, segment->org.x, segment->org.y); - cairo_line_to(cr, tail1.x, tail1.y); - cairo_line_to(cr, tail2.x, tail2.y); - cairo_close_path(cr); + cairo_move_to(cr, segment->org.x, segment->org.y); + cairo_line_to(cr, tail1.x, tail1.y); + cairo_line_to(cr, tail2.x, tail2.y); + cairo_close_path(cr); - break; + break; case CAIRO_PATH_CURVE_TO: - ADG_STUB(); - break; + ADG_STUB(); + break; default: - g_assert_not_reached(); + g_assert_not_reached(); } } diff --git a/adg/adg-arrow-style.h b/adg/adg-arrow-style.h index 1dbd36ec..fc80fea8 100644 --- a/adg/adg-arrow-style.h +++ b/adg/adg-arrow-style.h @@ -50,42 +50,42 @@ typedef struct _AdgArrowStylePrivate AdgArrowStylePrivate; * If you need an ending arrow, you should reverse the segment and recall * this function. **/ -typedef void (*AdgArrowRenderer) (AdgArrowStyle *arrow_style, - cairo_t *cr, - CpmlPath *segment); +typedef void (*AdgArrowRenderer) (AdgArrowStyle *arrow_style, + cairo_t *cr, + CpmlPath *segment); struct _AdgArrowStyle { - AdgStyle style; + AdgStyle style; /*< private >*/ AdgArrowStylePrivate *priv; }; struct _AdgArrowStyleClass { - AdgStyleClass parent_class; + AdgStyleClass parent_class; }; -GType adg_arrow_style_get_type (void) G_GNUC_CONST; -AdgStyleSlot adg_arrow_style_get_slot (void) G_GNUC_CONST; -AdgStyle * adg_arrow_style_new (void); +GType adg_arrow_style_get_type (void) G_GNUC_CONST; +AdgStyleSlot adg_arrow_style_get_slot (void) G_GNUC_CONST; +AdgStyle * adg_arrow_style_new (void); -void adg_arrow_style_render (AdgArrowStyle *arrow_style, - cairo_t *cr, - CpmlPath *segment); +void adg_arrow_style_render (AdgArrowStyle *arrow_style, + cairo_t *cr, + CpmlPath *segment); -gdouble adg_arrow_style_get_size (AdgArrowStyle *arrow_style); -void adg_arrow_style_set_size (AdgArrowStyle *arrow_style, - gdouble size); -gdouble adg_arrow_style_get_angle (AdgArrowStyle *arrow_style); -void adg_arrow_style_set_angle (AdgArrowStyle *arrow_style, - gdouble angle); -gdouble adg_arrow_style_get_margin (AdgArrowStyle *arrow_style); -void adg_arrow_style_set_margin (AdgArrowStyle *arrow_style, - gdouble margin); +gdouble adg_arrow_style_get_size (AdgArrowStyle *arrow_style); +void adg_arrow_style_set_size (AdgArrowStyle *arrow_style, + gdouble size); +gdouble adg_arrow_style_get_angle (AdgArrowStyle *arrow_style); +void adg_arrow_style_set_angle (AdgArrowStyle *arrow_style, + gdouble angle); +gdouble adg_arrow_style_get_margin (AdgArrowStyle *arrow_style); +void adg_arrow_style_set_margin (AdgArrowStyle *arrow_style, + gdouble margin); const AdgArrowRenderer - adg_arrow_style_get_renderer (AdgArrowStyle *arrow_style); -void adg_arrow_style_set_renderer (AdgArrowStyle *arrow_style, - AdgArrowRenderer renderer); + adg_arrow_style_get_renderer (AdgArrowStyle *arrow_style); +void adg_arrow_style_set_renderer (AdgArrowStyle *arrow_style, + AdgArrowRenderer renderer); G_END_DECLS diff --git a/adg/adg-canvas.c b/adg/adg-canvas.c index 5d7c1f81..93f4baa2 100644 --- a/adg/adg-canvas.c +++ b/adg/adg-canvas.c @@ -39,8 +39,8 @@ #define PARENT_CLASS ((AdgContainerClass *) adg_canvas_parent_class) -static AdgStyle * context_filler (AdgStyleClass *style_class, - gpointer user_data); +static AdgStyle * context_filler (AdgStyleClass *style_class, + gpointer user_data); G_DEFINE_TYPE(AdgCanvas, adg_canvas, ADG_TYPE_CONTAINER); @@ -57,8 +57,8 @@ adg_canvas_init(AdgCanvas *canvas) { AdgContext *context; AdgCanvasPrivate *priv = - G_TYPE_INSTANCE_GET_PRIVATE(canvas, ADG_TYPE_CANVAS, - AdgCanvasPrivate); + G_TYPE_INSTANCE_GET_PRIVATE(canvas, ADG_TYPE_CANVAS, + AdgCanvasPrivate); canvas->priv = priv; diff --git a/adg/adg-canvas.h b/adg/adg-canvas.h index e6ad42c0..3a548193 100644 --- a/adg/adg-canvas.h +++ b/adg/adg-canvas.h @@ -40,13 +40,13 @@ typedef struct _AdgCanvasPrivate AdgCanvasPrivate; struct _AdgCanvas { - AdgContainer container; + AdgContainer container; /*< private >*/ - AdgCanvasPrivate *priv; + AdgCanvasPrivate *priv; }; struct _AdgCanvasClass { - AdgContainerClass parent_class; + AdgContainerClass parent_class; }; diff --git a/adg/adg-container-private.h b/adg/adg-container-private.h index 41b4933b..b8cbf3cd 100644 --- a/adg/adg-container-private.h +++ b/adg/adg-container-private.h @@ -28,12 +28,12 @@ G_BEGIN_DECLS struct _AdgContainerPrivate { - GSList *children; - AdgMatrix model_transformation; - AdgMatrix paper_transformation; + GSList *children; + AdgMatrix model_transformation; + AdgMatrix paper_transformation; /* Cached data */ - AdgMatrix model_matrix; - AdgMatrix paper_matrix; + AdgMatrix model_matrix; + AdgMatrix paper_matrix; }; G_END_DECLS diff --git a/adg/adg-container.c b/adg/adg-container.c index 988d56e3..d6b608c1 100644 --- a/adg/adg-container.c +++ b/adg/adg-container.c @@ -50,35 +50,35 @@ enum { }; -static void containerable_init (GContainerableIface *iface); -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static const AdgMatrix *get_model_matrix (AdgEntity *entity); -static const AdgMatrix *get_paper_matrix (AdgEntity *entity); -static void model_matrix_changed (AdgEntity *entity, - AdgMatrix *parent_matrix); -static void paper_matrix_changed (AdgEntity *entity, - AdgMatrix *parent_matrix); -static GSList * get_children (GContainerable *containerable); -static gboolean add (GContainerable *containerable, - GChildable *childable); -static gboolean remove (GContainerable *containerable, - GChildable *childable); -static void invalidate (AdgEntity *entity); -static void render (AdgEntity *entity, - cairo_t *cr); +static void containerable_init (GContainerableIface *iface); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static const AdgMatrix *get_model_matrix (AdgEntity *entity); +static const AdgMatrix *get_paper_matrix (AdgEntity *entity); +static void model_matrix_changed (AdgEntity *entity, + AdgMatrix *parent_matrix); +static void paper_matrix_changed (AdgEntity *entity, + AdgMatrix *parent_matrix); +static GSList * get_children (GContainerable *containerable); +static gboolean add (GContainerable *containerable, + GChildable *childable); +static gboolean remove (GContainerable *containerable, + GChildable *childable); +static void invalidate (AdgEntity *entity); +static void render (AdgEntity *entity, + cairo_t *cr); G_DEFINE_TYPE_EXTENDED(AdgContainer, adg_container, - ADG_TYPE_ENTITY, 0, - G_IMPLEMENT_INTERFACE(G_TYPE_CONTAINERABLE, - containerable_init)) + ADG_TYPE_ENTITY, 0, + G_IMPLEMENT_INTERFACE(G_TYPE_CONTAINERABLE, + containerable_init)) static void @@ -107,18 +107,18 @@ adg_container_class_init(AdgContainerClass *klass) g_object_class_override_property(gobject_class, PROP_CHILD, "child"); param = g_param_spec_boxed("model-transformation", - P_("The model transformation"), - P_("The model transformation to be applied to this container and its children entities"), - ADG_TYPE_MATRIX, G_PARAM_READWRITE); + P_("The model transformation"), + P_("The model transformation to be applied to this container and its children entities"), + ADG_TYPE_MATRIX, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, - PROP_MODEL_TRANSFORMATION, param); + PROP_MODEL_TRANSFORMATION, param); param = g_param_spec_boxed("paper-transformation", - P_("The paper transformation"), - P_("The paper transformation to be applied to this container and its children entities"), - ADG_TYPE_MATRIX, G_PARAM_READWRITE); + P_("The paper transformation"), + P_("The paper transformation to be applied to this container and its children entities"), + ADG_TYPE_MATRIX, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, - PROP_PAPER_TRANSFORMATION, param); + PROP_PAPER_TRANSFORMATION, param); } static void @@ -133,8 +133,8 @@ static void adg_container_init(AdgContainer *container) { AdgContainerPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(container, - ADG_TYPE_CONTAINER, - AdgContainerPrivate); + ADG_TYPE_CONTAINER, + AdgContainerPrivate); priv->children = NULL; cairo_matrix_init_identity(&priv->model_transformation); @@ -152,38 +152,38 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) switch (prop_id) { case PROP_MODEL_TRANSFORMATION: - g_value_set_boxed(value, &container->priv->model_transformation); - break; + g_value_set_boxed(value, &container->priv->model_transformation); + break; case PROP_PAPER_TRANSFORMATION: - g_value_set_boxed(value, &container->priv->paper_transformation); - break; + g_value_set_boxed(value, &container->priv->paper_transformation); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgContainer *container = (AdgContainer *) object; switch (prop_id) { case PROP_CHILD: - g_containerable_add((GContainerable *) container, - g_value_get_object(value)); - break; + g_containerable_add((GContainerable *) container, + g_value_get_object(value)); + break; case PROP_MODEL_TRANSFORMATION: - adg_matrix_set(&container->priv->model_transformation, - g_value_get_boxed(value)); - break; + adg_matrix_set(&container->priv->model_transformation, + g_value_get_boxed(value)); + break; case PROP_PAPER_TRANSFORMATION: - adg_matrix_set(&container->priv->paper_transformation, - g_value_get_boxed(value)); - break; + adg_matrix_set(&container->priv->paper_transformation, + g_value_get_boxed(value)); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } } @@ -202,7 +202,7 @@ add(GContainerable *containerable, GChildable *childable) AdgContainer *container = (AdgContainer *) containerable; container->priv->children = - g_slist_append(container->priv->children, childable); + g_slist_append(container->priv->children, childable); return TRUE; } @@ -216,10 +216,10 @@ remove(GContainerable *containerable, GChildable *childable) node = g_slist_find(container->priv->children, childable); if (!node) - return FALSE; + return FALSE; container->priv->children = - g_slist_delete_link(container->priv->children, node); + g_slist_delete_link(container->priv->children, node); return TRUE; } @@ -232,16 +232,16 @@ model_matrix_changed(AdgEntity *entity, AdgMatrix *parent_matrix) PARENT_CLASS->model_matrix_changed(entity, parent_matrix); if (parent_matrix) - cairo_matrix_multiply(&container->priv->model_matrix, - parent_matrix, - &container->priv->model_transformation); + cairo_matrix_multiply(&container->priv->model_matrix, + parent_matrix, + &container->priv->model_transformation); else - adg_matrix_set(&container->priv->model_matrix, - &container->priv->model_transformation); + adg_matrix_set(&container->priv->model_matrix, + &container->priv->model_transformation); g_containerable_propagate_by_name((GContainerable *) entity, - "model-matrix-changed", - &container->priv->model_matrix); + "model-matrix-changed", + &container->priv->model_matrix); } static void @@ -252,16 +252,16 @@ paper_matrix_changed(AdgEntity *entity, AdgMatrix *parent_matrix) PARENT_CLASS->paper_matrix_changed(entity, parent_matrix); if (parent_matrix) - cairo_matrix_multiply(&container->priv->paper_matrix, - parent_matrix, - &container->priv->paper_transformation); + cairo_matrix_multiply(&container->priv->paper_matrix, + parent_matrix, + &container->priv->paper_transformation); else - adg_matrix_set(&container->priv->paper_matrix, - &container->priv->paper_transformation); + adg_matrix_set(&container->priv->paper_matrix, + &container->priv->paper_transformation); g_containerable_propagate_by_name((GContainerable *) entity, - "paper-matrix-changed", - &container->priv->paper_matrix); + "paper-matrix-changed", + &container->priv->paper_matrix); } static const AdgMatrix * @@ -303,7 +303,7 @@ adg_container_get_model_transformation(AdgContainer *container) void adg_container_set_model_transformation(AdgContainer *container, - AdgMatrix *transformation) + AdgMatrix *transformation) { AdgEntity *entity; AdgEntity *parent; @@ -329,7 +329,7 @@ adg_container_get_paper_transformation(AdgContainer *container) void adg_container_set_paper_transformation(AdgContainer *container, - AdgMatrix *transformation) + AdgMatrix *transformation) { AdgEntity *entity; AdgEntity *parent; diff --git a/adg/adg-container.h b/adg/adg-container.h index 09accffc..c3233500 100644 --- a/adg/adg-container.h +++ b/adg/adg-container.h @@ -39,23 +39,23 @@ typedef struct _AdgContainerClass AdgContainerClass; typedef struct _AdgContainerPrivate AdgContainerPrivate; struct _AdgContainer { - AdgEntity entity; + AdgEntity entity; /*< private >*/ - AdgContainerPrivate *priv; + AdgContainerPrivate *priv; }; struct _AdgContainerClass { - AdgEntityClass parent_class; + AdgEntityClass parent_class; }; -GType adg_container_get_type (void) G_GNUC_CONST; -const AdgMatrix *adg_container_get_model_transformation (AdgContainer *container); -void adg_container_set_model_transformation (AdgContainer *container, - AdgMatrix *transformation); -const AdgMatrix *adg_container_get_paper_transformation (AdgContainer *container); -void adg_container_set_paper_transformation (AdgContainer *container, - AdgMatrix *transformation); +GType adg_container_get_type (void) G_GNUC_CONST; +const AdgMatrix *adg_container_get_model_transformation (AdgContainer *container); +void adg_container_set_model_transformation (AdgContainer *container, + AdgMatrix *transformation); +const AdgMatrix *adg_container_get_paper_transformation (AdgContainer *container); +void adg_container_set_paper_transformation (AdgContainer *container, + AdgMatrix *transformation); G_END_DECLS diff --git a/adg/adg-context-private.h b/adg/adg-context-private.h index c1cf69e4..1abcaf30 100644 --- a/adg/adg-context-private.h +++ b/adg/adg-context-private.h @@ -31,9 +31,9 @@ G_BEGIN_DECLS struct _AdgContextPrivate { - GPtrArray *style_slots; - AdgContextFiller context_filler; - gpointer user_data; + GPtrArray *style_slots; + AdgContextFiller context_filler; + gpointer user_data; }; diff --git a/adg/adg-context.c b/adg/adg-context.c index 22ae9b60..2e7e7014 100644 --- a/adg/adg-context.c +++ b/adg/adg-context.c @@ -54,10 +54,10 @@ #define PARENT_CLASS ((AdgEntityClass *) adg_context_parent_class) -static AdgStyle * context_filler (AdgStyleClass *style_class, - gpointer user_data); -static void fill_style_slots (AdgContext *context, - guint last_slot); +static AdgStyle * context_filler (AdgStyleClass *style_class, + gpointer user_data); +static void fill_style_slots (AdgContext *context, + guint last_slot); static GPtrArray *class_slots = NULL; @@ -75,11 +75,11 @@ static void adg_context_init(AdgContext *context) { AdgContextPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(context, - ADG_TYPE_CONTEXT, - AdgContextPrivate); + ADG_TYPE_CONTEXT, + AdgContextPrivate); priv->style_slots = g_ptr_array_sized_new(class_slots ? - class_slots->len : 10); + class_slots->len : 10); priv->context_filler = context_filler; priv->user_data = NULL; @@ -105,12 +105,12 @@ adg_context_get_slot(GType type) g_return_val_if_fail(ADG_IS_STYLE_CLASS(klass), -1); if (G_UNLIKELY(class_slots == NULL)) { - class_slots = g_ptr_array_sized_new(10); + class_slots = g_ptr_array_sized_new(10); } else { - guint n; - for (n = 0; n < class_slots->len; ++n) - if (class_slots->pdata[n] == klass) - return n; + guint n; + for (n = 0; n < class_slots->len; ++n) + if (class_slots->pdata[n] == klass) + return n; } g_ptr_array_add(class_slots, klass); @@ -133,8 +133,8 @@ adg_context_new(AdgContextFiller context_filler, gpointer user_data) AdgContext *context = g_object_new(ADG_TYPE_CONTEXT, NULL); if (context_filler) { - context->priv->context_filler = context_filler; - context->priv->user_data = user_data; + context->priv->context_filler = context_filler; + context->priv->user_data = user_data; } return context; @@ -160,7 +160,7 @@ adg_context_get_style(AdgContext *context, AdgStyleSlot slot) style_slots = context->priv->style_slots; if (G_UNLIKELY(slot >= style_slots->len)) - fill_style_slots(context, slot); + fill_style_slots(context, slot); return (AdgStyle *) g_ptr_array_index(style_slots, slot); } @@ -188,11 +188,11 @@ adg_context_set_style(AdgContext *context, AdgStyle *style) g_object_ref(style); if (G_LIKELY(slot < style_slots->len)) { - g_object_unref(style_slots->pdata[slot]); - style_slots->pdata[slot] = style; + g_object_unref(style_slots->pdata[slot]); + style_slots->pdata[slot] = style; } else { - fill_style_slots(context, slot - 1); - g_ptr_array_add(style_slots, style); + fill_style_slots(context, slot - 1); + g_ptr_array_add(style_slots, style); } } @@ -214,10 +214,10 @@ fill_style_slots(AdgContext *context, guint last_slot) style_slots = context->priv->style_slots; for (n = style_slots->len; n <= last_slot; ++n) { - klass = (AdgStyleClass *) g_ptr_array_index(class_slots, n); - style = - context->priv->context_filler(klass, context->priv->user_data); - g_object_ref((GObject *) style); - g_ptr_array_add(style_slots, style); + klass = (AdgStyleClass *) g_ptr_array_index(class_slots, n); + style = + context->priv->context_filler(klass, context->priv->user_data); + g_object_ref((GObject *) style); + g_ptr_array_add(style_slots, style); } } diff --git a/adg/adg-context.h b/adg/adg-context.h index 2999caff..c85045ec 100644 --- a/adg/adg-context.h +++ b/adg/adg-context.h @@ -40,25 +40,25 @@ typedef struct _AdgContextPrivate AdgContextPrivate; typedef AdgStyle * (*AdgContextFiller) (AdgStyleClass *style_class, gpointer user_data); struct _AdgContext { - GObject object; + GObject object; /*< private >*/ - AdgContextPrivate *priv; + AdgContextPrivate *priv; }; struct _AdgContextClass { - GObjectClass object_class; + GObjectClass object_class; }; -GType adg_context_get_type (void) G_GNUC_CONST; -AdgStyleSlot adg_context_get_slot (GType type); +GType adg_context_get_type (void) G_GNUC_CONST; +AdgStyleSlot adg_context_get_slot (GType type); -AdgContext * adg_context_new (AdgContextFiller context_filler, - gpointer user_data); -AdgStyle * adg_context_get_style (AdgContext *context, - AdgStyleSlot slot); -void adg_context_set_style (AdgContext *context, - AdgStyle *style); +AdgContext * adg_context_new (AdgContextFiller context_filler, + gpointer user_data); +AdgStyle * adg_context_get_style (AdgContext *context, + AdgStyleSlot slot); +void adg_context_set_style (AdgContext *context, + AdgStyle *style); G_END_DECLS diff --git a/adg/adg-dim-private.h b/adg/adg-dim-private.h index 1d170850..e6aaa8d1 100644 --- a/adg/adg-dim-private.h +++ b/adg/adg-dim-private.h @@ -29,23 +29,23 @@ G_BEGIN_DECLS struct _AdgDimPrivate { /* Properties */ - AdgPair ref1; - AdgPair ref2; - AdgPair pos1; - AdgPair pos2; - gdouble level; - gchar *quote; - gchar *tolerance_up; - gchar *tolerance_down; - gchar *note; + AdgPair ref1; + AdgPair ref2; + AdgPair pos1; + AdgPair pos2; + gdouble level; + gchar *quote; + gchar *tolerance_up; + gchar *tolerance_down; + gchar *note; /* Cache */ - CpmlPair quote_org; - gdouble quote_angle; - CpmlPair quote_shift; - CpmlPair tolerance_up_shift; - CpmlPair tolerance_down_shift; - CpmlPair note_shift; + CpmlPair quote_org; + gdouble quote_angle; + CpmlPair quote_shift; + CpmlPair tolerance_up_shift; + CpmlPair tolerance_down_shift; + CpmlPair note_shift; }; G_END_DECLS diff --git a/adg/adg-dim-style-private.h b/adg/adg-dim-style-private.h index aafd0c9b..27a8cb71 100644 --- a/adg/adg-dim-style-private.h +++ b/adg/adg-dim-style-private.h @@ -27,20 +27,20 @@ G_BEGIN_DECLS struct _AdgDimStylePrivate { - AdgStyle *quote_style; - AdgStyle *tolerance_style; - AdgStyle *note_style; - AdgStyle *line_style; - AdgStyle *arrow_style; - gdouble from_offset; - gdouble to_offset; - gdouble baseline_spacing; - gdouble tolerance_spacing; - AdgPair quote_shift; - AdgPair tolerance_shift; - AdgPair note_shift; - gchar *number_format; - gchar *number_tag; + AdgStyle *quote_style; + AdgStyle *tolerance_style; + AdgStyle *note_style; + AdgStyle *line_style; + AdgStyle *arrow_style; + gdouble from_offset; + gdouble to_offset; + gdouble baseline_spacing; + gdouble tolerance_spacing; + AdgPair quote_shift; + AdgPair tolerance_shift; + AdgPair note_shift; + gchar *number_format; + gchar *number_tag; }; G_END_DECLS diff --git a/adg/adg-dim-style.c b/adg/adg-dim-style.c index 379e2e16..a7a376db 100644 --- a/adg/adg-dim-style.c +++ b/adg/adg-dim-style.c @@ -58,35 +58,35 @@ enum { }; -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static GPtrArray * get_pool (void); -static void set_quote_style (AdgDimStyle *dim_style, - AdgFontStyle *style); -static void set_tolerance_style (AdgDimStyle *dim_style, - AdgFontStyle *style); -static void set_note_style (AdgDimStyle *dim_style, - AdgFontStyle *style); -static void set_line_style (AdgDimStyle *dim_style, - AdgLineStyle *style); -static void set_arrow_style (AdgDimStyle *dim_style, - AdgArrowStyle *style); -static void set_quote_shift (AdgDimStyle *dim_style, - const AdgPair *shift); -static void set_tolerance_shift (AdgDimStyle *dim_style, - const AdgPair *shift); -static void set_note_shift (AdgDimStyle *dim_style, - const AdgPair *shift); -static void set_number_format (AdgDimStyle *dim_style, - const gchar *format); -static void set_number_tag (AdgDimStyle *dim_style, - const gchar *tag); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static GPtrArray * get_pool (void); +static void set_quote_style (AdgDimStyle *dim_style, + AdgFontStyle *style); +static void set_tolerance_style (AdgDimStyle *dim_style, + AdgFontStyle *style); +static void set_note_style (AdgDimStyle *dim_style, + AdgFontStyle *style); +static void set_line_style (AdgDimStyle *dim_style, + AdgLineStyle *style); +static void set_arrow_style (AdgDimStyle *dim_style, + AdgArrowStyle *style); +static void set_quote_shift (AdgDimStyle *dim_style, + const AdgPair *shift); +static void set_tolerance_shift (AdgDimStyle *dim_style, + const AdgPair *shift); +static void set_note_shift (AdgDimStyle *dim_style, + const AdgPair *shift); +static void set_number_format (AdgDimStyle *dim_style, + const gchar *format); +static void set_number_tag (AdgDimStyle *dim_style, + const gchar *tag); G_DEFINE_TYPE(AdgDimStyle, adg_dim_style, ADG_TYPE_STYLE) @@ -110,96 +110,96 @@ adg_dim_style_class_init(AdgDimStyleClass *klass) style_class->get_pool = get_pool; param = g_param_spec_object("quote-style", - P_("Quote Style"), - P_("Font style for the quote"), - ADG_TYPE_STYLE, G_PARAM_READWRITE); + P_("Quote Style"), + P_("Font style for the quote"), + ADG_TYPE_STYLE, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_QUOTE_STYLE, - param); + param); param = g_param_spec_object("tolerance-style", - P_("Tolerance Style"), - P_("Font style for the tolerances"), - ADG_TYPE_STYLE, G_PARAM_READWRITE); + P_("Tolerance Style"), + P_("Font style for the tolerances"), + ADG_TYPE_STYLE, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_TOLERANCE_STYLE, - param); + param); param = g_param_spec_object("note-style", - P_("Note Style"), - P_("Font style for the note (the text after or under the quote)"), - ADG_TYPE_STYLE, G_PARAM_READWRITE); + P_("Note Style"), + P_("Font style for the note (the text after or under the quote)"), + ADG_TYPE_STYLE, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_NOTE_STYLE, param); param = g_param_spec_object("line-style", - P_("Line Style"), - P_("Line style for the baseline and the extension lines"), - ADG_TYPE_STYLE, G_PARAM_READWRITE); + P_("Line Style"), + P_("Line style for the baseline and the extension lines"), + ADG_TYPE_STYLE, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_LINE_STYLE, param); param = g_param_spec_object("arrow-style", - P_("Arrow Style"), - P_("Arrow style to use on the baseline"), - ADG_TYPE_STYLE, G_PARAM_READWRITE); + P_("Arrow Style"), + P_("Arrow style to use on the baseline"), + ADG_TYPE_STYLE, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_ARROW_STYLE, - param); + param); param = g_param_spec_double("from-offset", - P_("From Offset"), - P_("Offset (in paper space) of the extension lines from the path to quote"), - 0., G_MAXDOUBLE, 5., G_PARAM_READWRITE); + P_("From Offset"), + P_("Offset (in paper space) of the extension lines from the path to quote"), + 0., G_MAXDOUBLE, 5., G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_FROM_OFFSET, - param); + param); param = g_param_spec_double("to-offset", - P_("To Offset"), - P_("How many extend (in paper space) the extension lines after hitting the baseline"), - 0., G_MAXDOUBLE, 5., G_PARAM_READWRITE); + P_("To Offset"), + P_("How many extend (in paper space) the extension lines after hitting the baseline"), + 0., G_MAXDOUBLE, 5., G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_TO_OFFSET, param); param = g_param_spec_double("baseline-spacing", - P_("Baseline Spacing"), - P_("Distance between two consecutive baselines while stacking dimensions"), - 0., G_MAXDOUBLE, 30., G_PARAM_READWRITE); + P_("Baseline Spacing"), + P_("Distance between two consecutive baselines while stacking dimensions"), + 0., G_MAXDOUBLE, 30., G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_BASELINE_SPACING, - param); + param); param = g_param_spec_double("tolerance-spacing", - P_("Tolerance Spacing"), - P_("Distance between up and down tolerance text"), - 0., G_MAXDOUBLE, 2., G_PARAM_READWRITE); + P_("Tolerance Spacing"), + P_("Distance between up and down tolerance text"), + 0., G_MAXDOUBLE, 2., G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_TOLERANCE_SPACING, - param); + param); param = g_param_spec_boxed("quote-shift", - P_("Quote Shift"), - P_("Used to specify a smooth displacement (in paper units) for the quote text by taking as reference the perfect compact position (the middle of the baseline on common linear quotes, for instance)"), - ADG_TYPE_PAIR, G_PARAM_READWRITE); + P_("Quote Shift"), + P_("Used to specify a smooth displacement (in paper units) for the quote text by taking as reference the perfect compact position (the middle of the baseline on common linear quotes, for instance)"), + ADG_TYPE_PAIR, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_QUOTE_SHIFT, - param); + param); param = g_param_spec_boxed("tolerance-shift", - P_("Tolerance Shift"), - P_("Used to specify a smooth displacement (in paper units) for the tolerance text by taking as reference the perfect compact position"), - ADG_TYPE_PAIR, G_PARAM_READWRITE); + P_("Tolerance Shift"), + P_("Used to specify a smooth displacement (in paper units) for the tolerance text by taking as reference the perfect compact position"), + ADG_TYPE_PAIR, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_TOLERANCE_SHIFT, - param); + param); param = g_param_spec_boxed("note-shift", - P_("Note Shift"), - P_("Used to specify a smooth displacement (in paper units) for the note text by taking as reference the perfect compact position"), - ADG_TYPE_PAIR, G_PARAM_READWRITE); + P_("Note Shift"), + P_("Used to specify a smooth displacement (in paper units) for the note text by taking as reference the perfect compact position"), + ADG_TYPE_PAIR, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_NOTE_SHIFT, param); param = g_param_spec_string("number-format", - P_("Number Format"), - P_("The format (in printf style) of the numeric component of the quote"), - "%-.7g", G_PARAM_READWRITE); + P_("Number Format"), + P_("The format (in printf style) of the numeric component of the quote"), + "%-.7g", G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_NUMBER_FORMAT, - param); + param); param = g_param_spec_string("number-tag", - P_("Number Tag"), - P_("The tag to substitute inside the quote pattern"), - "<>", G_PARAM_READWRITE); + P_("Number Tag"), + P_("The tag to substitute inside the quote pattern"), + "<>", G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_NUMBER_TAG, param); } @@ -207,19 +207,19 @@ static void adg_dim_style_init(AdgDimStyle *dim_style) { AdgDimStylePrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(dim_style, - ADG_TYPE_DIM_STYLE, - AdgDimStylePrivate); + ADG_TYPE_DIM_STYLE, + AdgDimStylePrivate); priv->quote_style = adg_style_from_id(ADG_TYPE_FONT_STYLE, - ADG_FONT_STYLE_QUOTE); + ADG_FONT_STYLE_QUOTE); priv->tolerance_style = adg_style_from_id(ADG_TYPE_FONT_STYLE, - ADG_FONT_STYLE_TOLERANCE); + ADG_FONT_STYLE_TOLERANCE); priv->note_style = adg_style_from_id(ADG_TYPE_FONT_STYLE, - ADG_FONT_STYLE_NOTE); + ADG_FONT_STYLE_NOTE); priv->line_style = adg_style_from_id(ADG_TYPE_LINE_STYLE, - ADG_LINE_STYLE_DIM); + ADG_LINE_STYLE_DIM); priv->arrow_style = adg_style_from_id(ADG_TYPE_ARROW_STYLE, - ADG_ARROW_STYLE_ARROW); + ADG_ARROW_STYLE_ARROW); priv->from_offset = 5.; priv->to_offset = 5.; priv->baseline_spacing = 30.; @@ -243,105 +243,105 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) switch (prop_id) { case PROP_QUOTE_STYLE: - g_value_set_object(value, dim_style->priv->quote_style); - break; + g_value_set_object(value, dim_style->priv->quote_style); + break; case PROP_TOLERANCE_STYLE: - g_value_set_object(value, dim_style->priv->tolerance_style); - break; + g_value_set_object(value, dim_style->priv->tolerance_style); + break; case PROP_NOTE_STYLE: - g_value_set_object(value, dim_style->priv->note_style); - break; + g_value_set_object(value, dim_style->priv->note_style); + break; case PROP_LINE_STYLE: - g_value_set_object(value, dim_style->priv->line_style); - break; + g_value_set_object(value, dim_style->priv->line_style); + break; case PROP_ARROW_STYLE: - g_value_set_object(value, dim_style->priv->arrow_style); - break; + g_value_set_object(value, dim_style->priv->arrow_style); + break; case PROP_FROM_OFFSET: - g_value_set_double(value, dim_style->priv->from_offset); - break; + g_value_set_double(value, dim_style->priv->from_offset); + break; case PROP_TO_OFFSET: - g_value_set_double(value, dim_style->priv->to_offset); - break; + g_value_set_double(value, dim_style->priv->to_offset); + break; case PROP_BASELINE_SPACING: - g_value_set_double(value, dim_style->priv->baseline_spacing); - break; + g_value_set_double(value, dim_style->priv->baseline_spacing); + break; case PROP_TOLERANCE_SPACING: - g_value_set_double(value, dim_style->priv->tolerance_spacing); - break; + g_value_set_double(value, dim_style->priv->tolerance_spacing); + break; case PROP_QUOTE_SHIFT: - g_value_set_boxed(value, &dim_style->priv->quote_shift); - break; + g_value_set_boxed(value, &dim_style->priv->quote_shift); + break; case PROP_TOLERANCE_SHIFT: - g_value_set_boxed(value, &dim_style->priv->tolerance_shift); - break; + g_value_set_boxed(value, &dim_style->priv->tolerance_shift); + break; case PROP_NOTE_SHIFT: - g_value_set_boxed(value, &dim_style->priv->note_shift); - break; + g_value_set_boxed(value, &dim_style->priv->note_shift); + break; case PROP_NUMBER_FORMAT: - g_value_set_string(value, dim_style->priv->number_format); - break; + g_value_set_string(value, dim_style->priv->number_format); + break; case PROP_NUMBER_TAG: - g_value_set_string(value, dim_style->priv->number_tag); - break; + g_value_set_string(value, dim_style->priv->number_tag); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgDimStyle *dim_style = (AdgDimStyle *) object; switch (prop_id) { case PROP_QUOTE_STYLE: - set_quote_style(dim_style, g_value_get_object(value)); - break; + set_quote_style(dim_style, g_value_get_object(value)); + break; case PROP_TOLERANCE_STYLE: - set_tolerance_style(dim_style, g_value_get_object(value)); - break; + set_tolerance_style(dim_style, g_value_get_object(value)); + break; case PROP_NOTE_STYLE: - set_note_style(dim_style, g_value_get_object(value)); - break; + set_note_style(dim_style, g_value_get_object(value)); + break; case PROP_LINE_STYLE: - set_line_style(dim_style, g_value_get_object(value)); - break; + set_line_style(dim_style, g_value_get_object(value)); + break; case PROP_ARROW_STYLE: - set_arrow_style(dim_style, g_value_get_object(value)); - break; + set_arrow_style(dim_style, g_value_get_object(value)); + break; case PROP_FROM_OFFSET: - dim_style->priv->from_offset = g_value_get_double(value); - break; + dim_style->priv->from_offset = g_value_get_double(value); + break; case PROP_TO_OFFSET: - dim_style->priv->to_offset = g_value_get_double(value); - break; + dim_style->priv->to_offset = g_value_get_double(value); + break; case PROP_BASELINE_SPACING: - dim_style->priv->baseline_spacing = g_value_get_double(value); - break; + dim_style->priv->baseline_spacing = g_value_get_double(value); + break; case PROP_TOLERANCE_SPACING: - dim_style->priv->tolerance_spacing = g_value_get_double(value); - break; + dim_style->priv->tolerance_spacing = g_value_get_double(value); + break; case PROP_QUOTE_SHIFT: - set_quote_shift(dim_style, g_value_get_boxed(value)); - break; + set_quote_shift(dim_style, g_value_get_boxed(value)); + break; case PROP_TOLERANCE_SHIFT: - set_tolerance_shift(dim_style, g_value_get_boxed(value)); - break; + set_tolerance_shift(dim_style, g_value_get_boxed(value)); + break; case PROP_NOTE_SHIFT: - set_note_shift(dim_style, g_value_get_boxed(value)); - break; + set_note_shift(dim_style, g_value_get_boxed(value)); + break; case PROP_NUMBER_FORMAT: - set_number_format(dim_style, g_value_get_string(value)); - break; + set_number_format(dim_style, g_value_get_string(value)); + break; case PROP_NUMBER_TAG: - set_number_tag(dim_style, g_value_get_string(value)); - break; + set_number_tag(dim_style, g_value_get_string(value)); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } @@ -359,7 +359,7 @@ adg_dim_style_get_slot(void) static AdgStyleSlot slot = -1; if (G_UNLIKELY(slot < 0)) - slot = adg_context_get_slot(ADG_TYPE_DIM_STYLE); + slot = adg_context_get_slot(ADG_TYPE_DIM_STYLE); return slot; } @@ -857,19 +857,19 @@ get_pool(void) static GPtrArray *pool = NULL; if (G_UNLIKELY(pool == NULL)) { - cairo_pattern_t *pattern; + cairo_pattern_t *pattern; - pool = g_ptr_array_sized_new(ADG_DIM_STYLE_LAST); + pool = g_ptr_array_sized_new(ADG_DIM_STYLE_LAST); - /* No need to specify further params: the default is already ISO */ - pattern = cairo_pattern_create_rgb(1., 0., 0.); - pool->pdata[ADG_DIM_STYLE_ISO] = g_object_new(ADG_TYPE_DIM_STYLE, - "pattern", pattern, - NULL); - cairo_pattern_destroy(pattern); + /* No need to specify further params: the default is already ISO */ + pattern = cairo_pattern_create_rgb(1., 0., 0.); + pool->pdata[ADG_DIM_STYLE_ISO] = g_object_new(ADG_TYPE_DIM_STYLE, + "pattern", pattern, + NULL); + cairo_pattern_destroy(pattern); - pool->len = ADG_DIM_STYLE_LAST; - } + pool->len = ADG_DIM_STYLE_LAST; + } return pool; } @@ -878,7 +878,7 @@ static void set_quote_style(AdgDimStyle *dim_style, AdgFontStyle *style) { if (dim_style->priv->quote_style) - g_object_unref(dim_style->priv->quote_style); + g_object_unref(dim_style->priv->quote_style); g_object_ref(style); dim_style->priv->quote_style = (AdgStyle *) style; @@ -888,7 +888,7 @@ static void set_tolerance_style(AdgDimStyle *dim_style, AdgFontStyle *style) { if (dim_style->priv->tolerance_style) - g_object_unref(dim_style->priv->tolerance_style); + g_object_unref(dim_style->priv->tolerance_style); g_object_ref(style); dim_style->priv->tolerance_style = (AdgStyle *) style; @@ -898,7 +898,7 @@ static void set_note_style(AdgDimStyle *dim_style, AdgFontStyle *style) { if (dim_style->priv->note_style) - g_object_unref(dim_style->priv->note_style); + g_object_unref(dim_style->priv->note_style); g_object_ref(style); dim_style->priv->note_style = (AdgStyle *) style; @@ -908,7 +908,7 @@ static void set_line_style(AdgDimStyle *dim_style, AdgLineStyle *style) { if (dim_style->priv->line_style) - g_object_unref(dim_style->priv->line_style); + g_object_unref(dim_style->priv->line_style); g_object_ref(style); dim_style->priv->line_style = (AdgStyle *) style; @@ -918,7 +918,7 @@ static void set_arrow_style(AdgDimStyle *dim_style, AdgArrowStyle *style) { if (dim_style->priv->arrow_style) - g_object_unref(dim_style->priv->arrow_style); + g_object_unref(dim_style->priv->arrow_style); g_object_ref(style); dim_style->priv->arrow_style = (AdgStyle *) style; diff --git a/adg/adg-dim-style.h b/adg/adg-dim-style.h index 6d74ee77..1a46d816 100644 --- a/adg/adg-dim-style.h +++ b/adg/adg-dim-style.h @@ -44,70 +44,70 @@ typedef struct _AdgDimStyleClass AdgDimStyleClass; typedef struct _AdgDimStylePrivate AdgDimStylePrivate; struct _AdgDimStyle { - AdgStyle style; + AdgStyle style; /*< private >*/ - AdgDimStylePrivate *priv; + AdgDimStylePrivate *priv; }; struct _AdgDimStyleClass { - AdgStyleClass parent_class; + AdgStyleClass parent_class; }; -GType adg_dim_style_get_type (void) G_GNUC_CONST; -AdgStyleSlot adg_dim_style_get_slot (void) G_GNUC_CONST; -AdgStyle * adg_dim_style_new (void); +GType adg_dim_style_get_type (void) G_GNUC_CONST; +AdgStyleSlot adg_dim_style_get_slot (void) G_GNUC_CONST; +AdgStyle * adg_dim_style_new (void); -AdgStyle * adg_dim_style_get_quote_style (AdgDimStyle *dim_style); -void adg_dim_style_set_quote_style (AdgDimStyle *dim_style, - AdgFontStyle *style); -AdgStyle * adg_dim_style_get_tolerance_style - (AdgDimStyle *dim_style); -void adg_dim_style_set_tolerance_style - (AdgDimStyle *dim_style, - AdgFontStyle *style); -AdgStyle * adg_dim_style_get_note_style (AdgDimStyle *dim_style); -void adg_dim_style_set_note_style (AdgDimStyle *dim_style, - AdgFontStyle *style); -AdgStyle * adg_dim_style_get_line_style (AdgDimStyle *dim_style); -void adg_dim_style_set_line_style (AdgDimStyle *dim_style, - AdgLineStyle *style); -AdgStyle * adg_dim_style_get_arrow_style (AdgDimStyle *dim_style); -void adg_dim_style_set_arrow_style (AdgDimStyle *dim_style, - AdgArrowStyle *style); -gdouble adg_dim_style_get_from_offset (AdgDimStyle *dim_style); -void adg_dim_style_set_from_offset (AdgDimStyle *dim_style, - gdouble offset); -gdouble adg_dim_style_get_to_offset (AdgDimStyle *dim_style); -void adg_dim_style_set_to_offset (AdgDimStyle *dim_style, - gdouble offset); -gdouble adg_dim_style_get_baseline_spacing - (AdgDimStyle *dim_style); -void adg_dim_style_set_baseline_spacing - (AdgDimStyle *dim_style, - gdouble spacing); -gdouble adg_dim_style_get_tolerance_spacing - (AdgDimStyle *dim_style); -void adg_dim_style_set_tolerance_spacing - (AdgDimStyle *dim_style, - gdouble spacing); -const AdgPair * adg_dim_style_get_quote_shift (AdgDimStyle *dim_style); -void adg_dim_style_set_quote_shift (AdgDimStyle *dim_style, - const AdgPair *shift); -const AdgPair * adg_dim_style_get_tolerance_shift - (AdgDimStyle *dim_style); -void adg_dim_style_set_tolerance_shift - (AdgDimStyle *dim_style, - const AdgPair *shift); -const AdgPair * adg_dim_style_get_note_shift (AdgDimStyle *dim_style); -void adg_dim_style_set_note_shift (AdgDimStyle *dim_style, - const AdgPair *shift); -const gchar * adg_dim_style_get_number_format (AdgDimStyle *dim_style); -void adg_dim_style_set_number_format (AdgDimStyle *dim_style, - const gchar *format); -const gchar * adg_dim_style_get_number_tag (AdgDimStyle *dim_style); -void adg_dim_style_set_number_tag (AdgDimStyle *dim_style, - const gchar *tag); +AdgStyle * adg_dim_style_get_quote_style (AdgDimStyle *dim_style); +void adg_dim_style_set_quote_style (AdgDimStyle *dim_style, + AdgFontStyle *style); +AdgStyle * adg_dim_style_get_tolerance_style + (AdgDimStyle *dim_style); +void adg_dim_style_set_tolerance_style + (AdgDimStyle *dim_style, + AdgFontStyle *style); +AdgStyle * adg_dim_style_get_note_style (AdgDimStyle *dim_style); +void adg_dim_style_set_note_style (AdgDimStyle *dim_style, + AdgFontStyle *style); +AdgStyle * adg_dim_style_get_line_style (AdgDimStyle *dim_style); +void adg_dim_style_set_line_style (AdgDimStyle *dim_style, + AdgLineStyle *style); +AdgStyle * adg_dim_style_get_arrow_style (AdgDimStyle *dim_style); +void adg_dim_style_set_arrow_style (AdgDimStyle *dim_style, + AdgArrowStyle *style); +gdouble adg_dim_style_get_from_offset (AdgDimStyle *dim_style); +void adg_dim_style_set_from_offset (AdgDimStyle *dim_style, + gdouble offset); +gdouble adg_dim_style_get_to_offset (AdgDimStyle *dim_style); +void adg_dim_style_set_to_offset (AdgDimStyle *dim_style, + gdouble offset); +gdouble adg_dim_style_get_baseline_spacing + (AdgDimStyle *dim_style); +void adg_dim_style_set_baseline_spacing + (AdgDimStyle *dim_style, + gdouble spacing); +gdouble adg_dim_style_get_tolerance_spacing + (AdgDimStyle *dim_style); +void adg_dim_style_set_tolerance_spacing + (AdgDimStyle *dim_style, + gdouble spacing); +const AdgPair * adg_dim_style_get_quote_shift (AdgDimStyle *dim_style); +void adg_dim_style_set_quote_shift (AdgDimStyle *dim_style, + const AdgPair *shift); +const AdgPair * adg_dim_style_get_tolerance_shift + (AdgDimStyle *dim_style); +void adg_dim_style_set_tolerance_shift + (AdgDimStyle *dim_style, + const AdgPair *shift); +const AdgPair * adg_dim_style_get_note_shift (AdgDimStyle *dim_style); +void adg_dim_style_set_note_shift (AdgDimStyle *dim_style, + const AdgPair *shift); +const gchar * adg_dim_style_get_number_format (AdgDimStyle *dim_style); +void adg_dim_style_set_number_format (AdgDimStyle *dim_style, + const gchar *format); +const gchar * adg_dim_style_get_number_tag (AdgDimStyle *dim_style); +void adg_dim_style_set_number_tag (AdgDimStyle *dim_style, + const gchar *tag); G_END_DECLS diff --git a/adg/adg-dim.c b/adg/adg-dim.c index e71c9236..53d18906 100644 --- a/adg/adg-dim.c +++ b/adg/adg-dim.c @@ -47,20 +47,20 @@ enum { }; -static void finalize (GObject *object); -static void get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void invalidate (AdgDim *dim); -static void invalidate_quote (AdgDim *dim); -static gchar * default_quote (AdgDim *dim); -static void quote_layout (AdgDim *dim, - cairo_t *cr); +static void finalize (GObject *object); +static void get_property (GObject *object, + guint param_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint param_id, + const GValue *value, + GParamSpec *pspec); +static void invalidate (AdgDim *dim); +static void invalidate_quote (AdgDim *dim); +static gchar * default_quote (AdgDim *dim); +static void quote_layout (AdgDim *dim, + cairo_t *cr); G_DEFINE_ABSTRACT_TYPE(AdgDim, adg_dim, ADG_TYPE_ENTITY); @@ -86,62 +86,62 @@ adg_dim_class_init(AdgDimClass *klass) klass->quote_layout = quote_layout; param = g_param_spec_boxed("ref1", - P_("Reference 1"), - P_("First reference point of the dimension"), - ADG_TYPE_PAIR, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + P_("Reference 1"), + P_("First reference point of the dimension"), + ADG_TYPE_PAIR, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property(gobject_class, PROP_REF1, param); param = g_param_spec_boxed("ref2", - P_("Reference 2"), - P_("Second reference point of the dimension"), - ADG_TYPE_PAIR, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + P_("Reference 2"), + P_("Second reference point of the dimension"), + ADG_TYPE_PAIR, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property(gobject_class, PROP_REF2, param); param = g_param_spec_boxed("pos1", - P_("Position 1"), - P_("First position point: it will be computed with the level property to get the real dimension position"), - ADG_TYPE_PAIR, G_PARAM_READWRITE); + P_("Position 1"), + P_("First position point: it will be computed with the level property to get the real dimension position"), + ADG_TYPE_PAIR, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_POS1, param); param = g_param_spec_boxed("pos2", - P_("Position 2"), - P_("Second position point: it will be computed with the level property to get the real dimension position"), - ADG_TYPE_PAIR, G_PARAM_READWRITE); + P_("Position 2"), + P_("Second position point: it will be computed with the level property to get the real dimension position"), + ADG_TYPE_PAIR, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_POS2, param); param = g_param_spec_double("level", - P_("Level"), - P_("The dimension level, that is the factor to multiply dim_style->baseline_spacing to get the offset (in device units) from pos1..pos2 where render the dimension baseline"), - -G_MAXDOUBLE, G_MAXDOUBLE, 1.0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + P_("Level"), + P_("The dimension level, that is the factor to multiply dim_style->baseline_spacing to get the offset (in device units) from pos1..pos2 where render the dimension baseline"), + -G_MAXDOUBLE, G_MAXDOUBLE, 1.0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property(gobject_class, PROP_LEVEL, param); param = g_param_spec_string("quote", - P_("Quote"), - P_("The quote to display: set to NULL to get the default quote"), - NULL, G_PARAM_READWRITE); + P_("Quote"), + P_("The quote to display: set to NULL to get the default quote"), + NULL, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_QUOTE, param); param = g_param_spec_string("tolerance-up", - P_("Up Tolerance"), - P_("The up tolerance of the quote: set to NULL to suppress"), - NULL, G_PARAM_READWRITE); + P_("Up Tolerance"), + P_("The up tolerance of the quote: set to NULL to suppress"), + NULL, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_TOLERANCE_UP, - param); + param); param = g_param_spec_string("tolerance-down", - P_("Down Tolerance"), - P_("The down tolerance of the quote: set to NULL to suppress"), - NULL, G_PARAM_READWRITE); + P_("Down Tolerance"), + P_("The down tolerance of the quote: set to NULL to suppress"), + NULL, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_TOLERANCE_DOWN, - param); + param); param = g_param_spec_string("note", - P_("Note"), - P_("A custom note appended to the dimension quote"), - NULL, G_PARAM_READWRITE); + P_("Note"), + P_("A custom note appended to the dimension quote"), + NULL, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_NOTE, param); } @@ -149,7 +149,7 @@ static void adg_dim_init(AdgDim *dim) { AdgDimPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(dim, ADG_TYPE_DIM, - AdgDimPrivate); + AdgDimPrivate); priv->ref1.x = priv->ref1.y = 0.; priv->ref2.x = priv->ref2.y = 0.; @@ -184,92 +184,92 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) switch (prop_id) { case PROP_REF1: - g_value_set_boxed(value, &dim->priv->ref1); - break; + g_value_set_boxed(value, &dim->priv->ref1); + break; case PROP_REF2: - g_value_set_boxed(value, &dim->priv->ref2); - break; + g_value_set_boxed(value, &dim->priv->ref2); + break; case PROP_POS1: - g_value_set_boxed(value, &dim->priv->pos1); - break; + g_value_set_boxed(value, &dim->priv->pos1); + break; case PROP_POS2: - g_value_set_boxed(value, &dim->priv->pos1); - break; + g_value_set_boxed(value, &dim->priv->pos1); + break; case PROP_LEVEL: - g_value_set_double(value, dim->priv->level); - break; + g_value_set_double(value, dim->priv->level); + break; case PROP_QUOTE: - g_value_set_string(value, dim->priv->quote); - break; + g_value_set_string(value, dim->priv->quote); + break; case PROP_TOLERANCE_UP: - g_value_set_string(value, dim->priv->tolerance_up); - break; + g_value_set_string(value, dim->priv->tolerance_up); + break; case PROP_TOLERANCE_DOWN: - g_value_set_string(value, dim->priv->tolerance_down); - break; + g_value_set_string(value, dim->priv->tolerance_down); + break; case PROP_NOTE: - g_value_set_string(value, dim->priv->note); - break; + g_value_set_string(value, dim->priv->note); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgDim *dim = (AdgDim *) object; switch (prop_id) { case PROP_REF1: - cpml_pair_copy(&dim->priv->ref1, - (AdgPair *) g_value_get_boxed(value)); - invalidate(dim); - break; + cpml_pair_copy(&dim->priv->ref1, + (AdgPair *) g_value_get_boxed(value)); + invalidate(dim); + break; case PROP_REF2: - cpml_pair_copy(&dim->priv->ref2, - (AdgPair *) g_value_get_boxed(value)); - invalidate(dim); - break; + cpml_pair_copy(&dim->priv->ref2, + (AdgPair *) g_value_get_boxed(value)); + invalidate(dim); + break; case PROP_POS1: - cpml_pair_copy(&dim->priv->pos1, - (AdgPair *) g_value_get_boxed(value)); - invalidate(dim); - break; + cpml_pair_copy(&dim->priv->pos1, + (AdgPair *) g_value_get_boxed(value)); + invalidate(dim); + break; case PROP_POS2: - cpml_pair_copy(&dim->priv->pos2, - (AdgPair *) g_value_get_boxed(value)); - invalidate(dim); - break; + cpml_pair_copy(&dim->priv->pos2, + (AdgPair *) g_value_get_boxed(value)); + invalidate(dim); + break; case PROP_LEVEL: - dim->priv->level = g_value_get_double(value); - invalidate(dim); - break; + dim->priv->level = g_value_get_double(value); + invalidate(dim); + break; case PROP_QUOTE: - g_free(dim->priv->quote); - dim->priv->quote = g_value_dup_string(value); - invalidate_quote(dim); - break; + g_free(dim->priv->quote); + dim->priv->quote = g_value_dup_string(value); + invalidate_quote(dim); + break; case PROP_TOLERANCE_UP: - g_free(dim->priv->tolerance_up); - dim->priv->tolerance_up = g_value_dup_string(value); - invalidate_quote(dim); - break; + g_free(dim->priv->tolerance_up); + dim->priv->tolerance_up = g_value_dup_string(value); + invalidate_quote(dim); + break; case PROP_TOLERANCE_DOWN: - g_free(dim->priv->tolerance_down); - dim->priv->tolerance_down = g_value_dup_string(value); - invalidate_quote(dim); - break; + g_free(dim->priv->tolerance_down); + dim->priv->tolerance_down = g_value_dup_string(value); + invalidate_quote(dim); + break; case PROP_NOTE: - g_free(dim->priv->note); - dim->priv->note = g_value_dup_string(value); - invalidate_quote(dim); - break; + g_free(dim->priv->note); + dim->priv->note = g_value_dup_string(value); + invalidate_quote(dim); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } @@ -288,7 +288,7 @@ invalidate_quote(AdgDim *dim) dim->priv->quote_shift.x = dim->priv->quote_shift.y = 0.; dim->priv->tolerance_up_shift.x = dim->priv->tolerance_up_shift.y = 0.; dim->priv->tolerance_down_shift.x = dim->priv->tolerance_down_shift.y = - 0.; + 0.; dim->priv->note_shift.x = dim->priv->note_shift.y = 0.; } @@ -297,7 +297,7 @@ static gchar * default_quote(AdgDim *dim) { g_warning("AdgDim::default_quote not implemented for `%s'", - g_type_name(G_TYPE_FROM_INSTANCE(dim))); + g_type_name(G_TYPE_FROM_INSTANCE(dim))); return g_strdup("undef"); } @@ -310,7 +310,7 @@ quote_layout(AdgDim *dim, cairo_t *cr) cairo_text_extents_t extents; dim_style = (AdgDimStyle *) adg_entity_get_style((AdgEntity *) dim, - ADG_SLOT_DIM_STYLE); + ADG_SLOT_DIM_STYLE); /* Compute the quote */ adg_style_apply(adg_dim_style_get_quote_style(dim_style), cr); @@ -322,55 +322,55 @@ quote_layout(AdgDim *dim, cairo_t *cr) /* Compute the tolerances */ if (dim->priv->tolerance_up != NULL - || dim->priv->tolerance_down != NULL) { - double width; - double midspacing; - - adg_style_apply(adg_dim_style_get_tolerance_style(dim_style), cr); - - width = 0.0; - midspacing = adg_dim_style_get_tolerance_spacing(dim_style) / 2.; - cpml_pair_copy(&offset, - adg_dim_style_get_tolerance_shift(dim_style)); - cp.x += offset.x; - - if (dim->priv->tolerance_up != NULL) { - cairo_text_extents(cr, dim->priv->tolerance_up, &extents); - cairo_user_to_device_distance(cr, &extents.width, - &extents.height); - dim->priv->tolerance_up_shift.x = cp.x; - dim->priv->tolerance_up_shift.y = cp.y + offset.y - midspacing; - width = extents.width; - } - - if (dim->priv->tolerance_down != NULL) { - cairo_text_extents(cr, dim->priv->tolerance_down, &extents); - cairo_user_to_device_distance(cr, &extents.width, - &extents.height); - dim->priv->tolerance_down_shift.x = cp.x; - dim->priv->tolerance_down_shift.y = - cp.y + offset.y + midspacing + extents.height; - - if (extents.width > width) - width = extents.width; - } - - cp.x += width; + || dim->priv->tolerance_down != NULL) { + double width; + double midspacing; + + adg_style_apply(adg_dim_style_get_tolerance_style(dim_style), cr); + + width = 0.0; + midspacing = adg_dim_style_get_tolerance_spacing(dim_style) / 2.; + cpml_pair_copy(&offset, + adg_dim_style_get_tolerance_shift(dim_style)); + cp.x += offset.x; + + if (dim->priv->tolerance_up != NULL) { + cairo_text_extents(cr, dim->priv->tolerance_up, &extents); + cairo_user_to_device_distance(cr, &extents.width, + &extents.height); + dim->priv->tolerance_up_shift.x = cp.x; + dim->priv->tolerance_up_shift.y = cp.y + offset.y - midspacing; + width = extents.width; + } + + if (dim->priv->tolerance_down != NULL) { + cairo_text_extents(cr, dim->priv->tolerance_down, &extents); + cairo_user_to_device_distance(cr, &extents.width, + &extents.height); + dim->priv->tolerance_down_shift.x = cp.x; + dim->priv->tolerance_down_shift.y = + cp.y + offset.y + midspacing + extents.height; + + if (extents.width > width) + width = extents.width; + } + + cp.x += width; } /* Compute the note */ if (dim->priv->note != NULL) { - adg_style_apply(adg_dim_style_get_note_style(dim_style), cr); + adg_style_apply(adg_dim_style_get_note_style(dim_style), cr); - cpml_pair_copy(&offset, adg_dim_style_get_note_shift(dim_style)); - cp.x += offset.x; + cpml_pair_copy(&offset, adg_dim_style_get_note_shift(dim_style)); + cp.x += offset.x; - cairo_text_extents(cr, dim->priv->note, &extents); - cairo_user_to_device_distance(cr, &extents.width, &extents.height); - dim->priv->note_shift.x = cp.x; - dim->priv->note_shift.y = cp.y + offset.y + extents.height / 2.; + cairo_text_extents(cr, dim->priv->note, &extents); + cairo_user_to_device_distance(cr, &extents.width, &extents.height); + dim->priv->note_shift.x = cp.x; + dim->priv->note_shift.y = cp.y + offset.y + extents.height / 2.; - cp.x += extents.width; + cp.x += extents.width; } /* Calculating the offsets */ @@ -416,19 +416,19 @@ adg_dim_set_ref(AdgDim *dim, const AdgPair *ref1, const AdgPair *ref2) object = G_OBJECT(dim); if (ref1 != NULL) { - dim->priv->ref1 = *ref1; - g_object_notify(object, "ref1"); + dim->priv->ref1 = *ref1; + g_object_notify(object, "ref1"); } if (ref2 != NULL) { - dim->priv->ref2 = *ref2; - g_object_notify(object, "ref2"); + dim->priv->ref2 = *ref2; + g_object_notify(object, "ref2"); } } void adg_dim_set_ref_explicit(AdgDim *dim, double ref1_x, double ref1_y, - double ref2_x, double ref2_y) + double ref2_x, double ref2_y) { AdgPair ref1; AdgPair ref2; @@ -469,13 +469,13 @@ adg_dim_set_pos(AdgDim *dim, AdgPair *pos1, AdgPair *pos2) g_object_freeze_notify(object); if (pos1 != NULL) { - dim->priv->pos1 = *pos1; - g_object_notify(object, "pos1"); + dim->priv->pos1 = *pos1; + g_object_notify(object, "pos1"); } if (pos2 != NULL) { - dim->priv->pos2 = *pos2; - g_object_notify(object, "pos2"); + dim->priv->pos2 = *pos2; + g_object_notify(object, "pos2"); } g_object_thaw_notify(object); @@ -483,7 +483,7 @@ adg_dim_set_pos(AdgDim *dim, AdgPair *pos1, AdgPair *pos2) void adg_dim_set_pos_explicit(AdgDim *dim, double pos1_x, double pos1_y, - double pos2_x, double pos2_y) + double pos2_x, double pos2_y) { AdgPair pos1; AdgPair pos2; @@ -575,7 +575,7 @@ adg_dim_set_tolerance_down(AdgDim *dim, const gchar *tolerance_down) void adg_dim_set_tolerances(AdgDim *dim, - const gchar *tolerance_up, const gchar *tolerance_down) + const gchar *tolerance_up, const gchar *tolerance_down) { GObject *object; @@ -639,12 +639,12 @@ adg_dim_render_quote(AdgDim *dim, cairo_t *cr) g_return_if_fail(ADG_IS_DIM(dim)); dim_style = (AdgDimStyle *) adg_entity_get_style((AdgEntity *) dim, - ADG_SLOT_DIM_STYLE); + ADG_SLOT_DIM_STYLE); if (dim->priv->quote == NULL) { - dim->priv->quote = ADG_DIM_GET_CLASS(dim)->default_quote(dim); - invalidate_quote(dim); - g_object_notify((GObject *) dim, "quote"); + dim->priv->quote = ADG_DIM_GET_CLASS(dim)->default_quote(dim); + invalidate_quote(dim); + g_object_notify((GObject *) dim, "quote"); } ADG_DIM_GET_CLASS(dim)->quote_layout(dim, cr); @@ -653,11 +653,11 @@ adg_dim_render_quote(AdgDim *dim, cairo_t *cr) cairo_device_to_user_distance(cr, "e_shift.x, "e_shift.y); cpml_pair_copy(&tolerance_up_shift, &dim->priv->tolerance_up_shift); cairo_device_to_user_distance(cr, &tolerance_up_shift.x, - &tolerance_up_shift.y); + &tolerance_up_shift.y); cpml_pair_copy(&tolerance_down_shift, - &dim->priv->tolerance_down_shift); + &dim->priv->tolerance_down_shift); cairo_device_to_user_distance(cr, &tolerance_down_shift.x, - &tolerance_down_shift.y); + &tolerance_down_shift.y); cairo_save(cr); cairo_translate(cr, dim->priv->quote_org.x, dim->priv->quote_org.y); @@ -670,24 +670,24 @@ adg_dim_render_quote(AdgDim *dim, cairo_t *cr) /* Rendering tolerances */ if (dim->priv->tolerance_up != NULL - || dim->priv->tolerance_down != NULL) { - adg_style_apply(adg_dim_style_get_tolerance_style(dim_style), cr); - - if (dim->priv->tolerance_up != NULL) { - cairo_move_to(cr, tolerance_up_shift.x, tolerance_up_shift.y); - cairo_show_text(cr, dim->priv->tolerance_up); - } - if (dim->priv->tolerance_down != NULL) { - cairo_move_to(cr, tolerance_down_shift.x, - tolerance_down_shift.y); - cairo_show_text(cr, dim->priv->tolerance_down); - } + || dim->priv->tolerance_down != NULL) { + adg_style_apply(adg_dim_style_get_tolerance_style(dim_style), cr); + + if (dim->priv->tolerance_up != NULL) { + cairo_move_to(cr, tolerance_up_shift.x, tolerance_up_shift.y); + cairo_show_text(cr, dim->priv->tolerance_up); + } + if (dim->priv->tolerance_down != NULL) { + cairo_move_to(cr, tolerance_down_shift.x, + tolerance_down_shift.y); + cairo_show_text(cr, dim->priv->tolerance_down); + } } /* Rendering note */ if (dim->priv->note != NULL) { - cairo_move_to(cr, note_shift.x, note_shift.y); - cairo_show_text(cr, dim->priv->note); + cairo_move_to(cr, note_shift.x, note_shift.y); + cairo_show_text(cr, dim->priv->note); } cairo_restore(cr); diff --git a/adg/adg-dim.h b/adg/adg-dim.h index 0928fe07..fee19c47 100644 --- a/adg/adg-dim.h +++ b/adg/adg-dim.h @@ -39,17 +39,17 @@ typedef struct _AdgDimClass AdgDimClass; typedef struct _AdgDimPrivate AdgDimPrivate; struct _AdgDim { - AdgEntity entity; + AdgEntity entity; /*< private >*/ - AdgDimPrivate *priv; + AdgDimPrivate *priv; }; struct _AdgDimClass { - AdgEntityClass parent_class; + AdgEntityClass parent_class; /* Virtual Table */ - gchar * (*default_quote) (AdgDim *dim); - void (*quote_layout) (AdgDim *dim, - cairo_t *cr); + gchar * (*default_quote) (AdgDim *dim); + void (*quote_layout) (AdgDim *dim, + cairo_t *cr); }; @@ -92,7 +92,7 @@ void adg_dim_set_tolerances (AdgDim *dim, const gchar * adg_dim_get_note (AdgDim *dim); void adg_dim_set_note (AdgDim *dim, const gchar *note); -void adg_dim_render_quote (AdgDim *dim, +void adg_dim_render_quote (AdgDim *dim, cairo_t *cr); G_END_DECLS diff --git a/adg/adg-entity-private.h b/adg/adg-entity-private.h index b2935b17..06a3120d 100644 --- a/adg/adg-entity-private.h +++ b/adg/adg-entity-private.h @@ -34,9 +34,9 @@ typedef enum { struct _AdgEntityPrivate { - AdgEntity *parent; - AdgEntityFlags flags; - AdgContext *context; + AdgEntity *parent; + AdgEntityFlags flags; + AdgContext *context; }; G_END_DECLS diff --git a/adg/adg-entity.c b/adg/adg-entity.c index de6731c9..d37b61ef 100644 --- a/adg/adg-entity.c +++ b/adg/adg-entity.c @@ -52,38 +52,38 @@ enum { }; -static void childable_init (GChildableIface*iface); -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static GContainerable * get_parent (GChildable *childable); -static void set_parent (GChildable *childable, - GContainerable *parent); -static void parent_set (GChildable *childable, - GContainerable *old_parent); -static void set_context (AdgEntity *entity, - AdgContext *context); -static void model_matrix_changed (AdgEntity *entity, - AdgMatrix *parent_matrix); -static void paper_matrix_changed (AdgEntity *entity, - AdgMatrix *parent_matrix); -static void render (AdgEntity *entity, - cairo_t *cr); -static const AdgMatrix *get_model_matrix (AdgEntity *entity); -static const AdgMatrix *get_paper_matrix (AdgEntity *entity); +static void childable_init (GChildableIface*iface); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static GContainerable * get_parent (GChildable *childable); +static void set_parent (GChildable *childable, + GContainerable *parent); +static void parent_set (GChildable *childable, + GContainerable *old_parent); +static void set_context (AdgEntity *entity, + AdgContext *context); +static void model_matrix_changed (AdgEntity *entity, + AdgMatrix *parent_matrix); +static void paper_matrix_changed (AdgEntity *entity, + AdgMatrix *parent_matrix); +static void render (AdgEntity *entity, + cairo_t *cr); +static const AdgMatrix *get_model_matrix (AdgEntity *entity); +static const AdgMatrix *get_paper_matrix (AdgEntity *entity); static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE_EXTENDED(AdgEntity, adg_entity, - G_TYPE_INITIALLY_UNOWNED, G_TYPE_FLAG_ABSTRACT, - G_IMPLEMENT_INTERFACE(G_TYPE_CHILDABLE, - childable_init)); + G_TYPE_INITIALLY_UNOWNED, G_TYPE_FLAG_ABSTRACT, + G_IMPLEMENT_INTERFACE(G_TYPE_CHILDABLE, + childable_init)); static void @@ -110,9 +110,9 @@ adg_entity_class_init(AdgEntityClass *klass) g_object_class_override_property(gobject_class, PROP_PARENT, "parent"); param = g_param_spec_object("context", - P_("Context"), - P_("The context associated to this entity or NULL to inherit the parent context"), - ADG_TYPE_CONTEXT, G_PARAM_READWRITE); + P_("Context"), + P_("The context associated to this entity or NULL to inherit the parent context"), + ADG_TYPE_CONTEXT, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_CONTEXT, param); /** @@ -122,13 +122,13 @@ adg_entity_class_init(AdgEntityClass *klass) * Clears the cached data of @entity. */ signals[INVALIDATE] = - g_signal_new("invalidate", - G_OBJECT_CLASS_TYPE(gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET(AdgEntityClass, invalidate), - NULL, NULL, - g_cclosure_marshal_VOID__BOOLEAN, - G_TYPE_NONE, 0); + g_signal_new("invalidate", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(AdgEntityClass, invalidate), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 0); /** * AdgEntity::render: @@ -138,13 +138,13 @@ adg_entity_class_init(AdgEntityClass *klass) * Causes the rendering of @entity on @cr. */ signals[RENDER] = - g_signal_new("render", - G_OBJECT_CLASS_TYPE(gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET(AdgEntityClass, render), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); + g_signal_new("render", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(AdgEntityClass, render), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, 1, G_TYPE_POINTER); /** * AdgEntity::model-matrix-changed: @@ -154,14 +154,14 @@ adg_entity_class_init(AdgEntityClass *klass) * Emitted after the current model matrix has changed. */ signals[MODEL_MATRIX_CHANGED] = - g_signal_new("model-matrix-changed", - G_OBJECT_CLASS_TYPE(gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET(AdgEntityClass, model_matrix_changed), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, - ADG_TYPE_MATRIX | G_SIGNAL_TYPE_STATIC_SCOPE); + g_signal_new("model-matrix-changed", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(AdgEntityClass, model_matrix_changed), + NULL, NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, + ADG_TYPE_MATRIX | G_SIGNAL_TYPE_STATIC_SCOPE); /** * AdgEntity::paper-matrix-changed: @@ -171,14 +171,14 @@ adg_entity_class_init(AdgEntityClass *klass) * Emitted after the current paper matrix has changed. */ signals[PAPER_MATRIX_CHANGED] = - g_signal_new("paper-matrix-changed", - G_OBJECT_CLASS_TYPE(gobject_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET(AdgEntityClass, paper_matrix_changed), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, - ADG_TYPE_MATRIX | G_SIGNAL_TYPE_STATIC_SCOPE); + g_signal_new("paper-matrix-changed", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(AdgEntityClass, paper_matrix_changed), + NULL, NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, + ADG_TYPE_MATRIX | G_SIGNAL_TYPE_STATIC_SCOPE); } static void @@ -193,8 +193,8 @@ static void adg_entity_init(AdgEntity *entity) { AdgEntityPrivate *priv = - G_TYPE_INSTANCE_GET_PRIVATE(entity, ADG_TYPE_ENTITY, - AdgEntityPrivate); + G_TYPE_INSTANCE_GET_PRIVATE(entity, ADG_TYPE_ENTITY, + AdgEntityPrivate); priv->parent = NULL; priv->flags = 0; @@ -210,33 +210,33 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) switch (prop_id) { case PROP_PARENT: - g_value_set_object(value, entity->priv->parent); - break; + g_value_set_object(value, entity->priv->parent); + break; case PROP_CONTEXT: - g_value_set_object(value, entity->priv->context); - break; + g_value_set_object(value, entity->priv->context); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgEntity *entity = (AdgEntity *) object; switch (prop_id) { case PROP_PARENT: - entity->priv->parent = (AdgEntity *) g_value_get_object(value); - break; + entity->priv->parent = (AdgEntity *) g_value_get_object(value); + break; case PROP_CONTEXT: - set_context(entity, g_value_get_object(value)); - break; + set_context(entity, g_value_get_object(value)); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } @@ -256,10 +256,10 @@ adg_entity_get_context(AdgEntity *entity) g_return_val_if_fail(ADG_IS_ENTITY(entity), NULL); if (entity->priv->context) - return entity->priv->context; + return entity->priv->context; if (entity->priv->parent) - return adg_entity_get_context(entity->priv->parent); + return adg_entity_get_context(entity->priv->parent); return NULL; } @@ -298,11 +298,11 @@ adg_entity_get_canvas(AdgEntity *entity) g_return_val_if_fail(ADG_IS_ENTITY(entity), NULL); while (entity) { - if (ADG_IS_CANVAS(entity)) - return (AdgCanvas *) entity; + if (ADG_IS_CANVAS(entity)) + return (AdgCanvas *) entity; - entity = - (AdgEntity *) g_childable_get_parent((GChildable *) entity); + entity = + (AdgEntity *) g_childable_get_parent((GChildable *) entity); } return NULL; @@ -349,7 +349,7 @@ adg_entity_get_paper_matrix(AdgEntity *entity) */ void adg_entity_model_matrix_changed(AdgEntity *entity, - const AdgMatrix *parent_matrix) + const AdgMatrix *parent_matrix) { g_return_if_fail(ADG_IS_ENTITY(entity)); @@ -367,7 +367,7 @@ adg_entity_model_matrix_changed(AdgEntity *entity, */ void adg_entity_paper_matrix_changed(AdgEntity *entity, - const AdgMatrix *parent_matrix) + const AdgMatrix *parent_matrix) { g_return_if_fail(ADG_IS_ENTITY(entity)); @@ -391,14 +391,14 @@ adg_entity_get_style(AdgEntity *entity, AdgStyleSlot style_slot) g_return_if_fail(ADG_IS_ENTITY(entity)); if (entity->priv->context) { - AdgStyle *style = adg_context_get_style(entity->priv->context, - style_slot); - if (style) - return style; + AdgStyle *style = adg_context_get_style(entity->priv->context, + style_slot); + if (style) + return style; } if (entity->priv->parent) - return adg_entity_get_style(entity->priv->parent, style_slot); + return adg_entity_get_style(entity->priv->parent, style_slot); return NULL; } @@ -417,7 +417,7 @@ adg_entity_apply(AdgEntity *entity, AdgStyleSlot style_slot, cairo_t *cr) AdgStyle *style = adg_entity_get_style(entity, style_slot); if (style) - adg_style_apply(style, cr); + adg_style_apply(style, cr); } /** @@ -508,16 +508,16 @@ static void parent_set(GChildable *childable, GContainerable *old_parent) { if (ADG_IS_CONTAINER(old_parent)) { - AdgEntity *entity; - const AdgMatrix *old_model; - const AdgMatrix *old_paper; + AdgEntity *entity; + const AdgMatrix *old_model; + const AdgMatrix *old_paper; - entity = (AdgEntity *) childable; - old_model = adg_entity_get_model_matrix((AdgEntity *) old_parent); - old_paper = adg_entity_get_paper_matrix((AdgEntity *) old_parent); + entity = (AdgEntity *) childable; + old_model = adg_entity_get_model_matrix((AdgEntity *) old_parent); + old_paper = adg_entity_get_paper_matrix((AdgEntity *) old_parent); - adg_entity_model_matrix_changed(entity, old_model); - adg_entity_paper_matrix_changed(entity, old_paper); + adg_entity_model_matrix_changed(entity, old_model); + adg_entity_paper_matrix_changed(entity, old_paper); } } @@ -525,7 +525,7 @@ static void set_context(AdgEntity *entity, AdgContext *context) { if (entity->priv->context) - g_object_unref((GObject *) entity->priv->context); + g_object_unref((GObject *) entity->priv->context); g_object_ref((GObject *) context); entity->priv->context = context; @@ -547,7 +547,7 @@ static void render(AdgEntity *entity, cairo_t *cr) { ADG_SET(entity->priv->flags, - MODEL_MATRIX_APPLIED | PAPER_MATRIX_APPLIED | MODEL_APPLIED); + MODEL_MATRIX_APPLIED | PAPER_MATRIX_APPLIED | MODEL_APPLIED); } static const AdgMatrix * diff --git a/adg/adg-entity.h b/adg/adg-entity.h index 58cdf089..276d259f 100644 --- a/adg/adg-entity.h +++ b/adg/adg-entity.h @@ -49,29 +49,29 @@ typedef struct _AdgEntityPrivate AdgEntityPrivate; struct _AdgEntity { - GInitiallyUnowned initially_unowned; + GInitiallyUnowned initially_unowned; /*< private >*/ - AdgEntityPrivate *priv; + AdgEntityPrivate *priv; }; struct _AdgEntityClass { GInitiallyUnownedClass parent_class; /* Signals */ - void (*model_matrix_changed) (AdgEntity *entity, - AdgMatrix *parent_matrix); - void (*paper_matrix_changed) (AdgEntity *entity, - AdgMatrix *parent_matrix); - void (*invalidate) (AdgEntity *entity); - void (*render) (AdgEntity *entity, - cairo_t *cr); + void (*model_matrix_changed) (AdgEntity *entity, + AdgMatrix *parent_matrix); + void (*paper_matrix_changed) (AdgEntity *entity, + AdgMatrix *parent_matrix); + void (*invalidate) (AdgEntity *entity); + void (*render) (AdgEntity *entity, + cairo_t *cr); /* Virtual Table */ - const AdgMatrix * (*get_model_matrix) (AdgEntity *entity); - const AdgMatrix * (*get_paper_matrix) (AdgEntity *entity); + const AdgMatrix * (*get_model_matrix) (AdgEntity *entity); + const AdgMatrix * (*get_paper_matrix) (AdgEntity *entity); }; -#define ADG_CALLBACK(f) ((AdgCallback) (f)) +#define ADG_CALLBACK(f) ((AdgCallback) (f)) typedef void (*AdgCallback) (AdgEntity *entity, gpointer user_data); @@ -80,23 +80,23 @@ typedef void (*AdgCallback) (AdgEntity *entity, gpointer user_data); GType adg_entity_get_type (void) G_GNUC_CONST; AdgCanvas * adg_entity_get_canvas (AdgEntity *entity); -AdgContext * adg_entity_get_context (AdgEntity *entity); -void adg_entity_set_context (AdgEntity *entity, - AdgContext *context); -const AdgMatrix*adg_entity_get_model_matrix (AdgEntity *entity); -const AdgMatrix*adg_entity_get_paper_matrix (AdgEntity *entity); +AdgContext * adg_entity_get_context (AdgEntity *entity); +void adg_entity_set_context (AdgEntity *entity, + AdgContext *context); +const AdgMatrix*adg_entity_get_model_matrix (AdgEntity *entity); +const AdgMatrix*adg_entity_get_paper_matrix (AdgEntity *entity); void adg_entity_model_matrix_changed (AdgEntity *entity, const AdgMatrix*parent_matrix); void adg_entity_paper_matrix_changed (AdgEntity *entity, const AdgMatrix*parent_matrix); -AdgStyle * adg_entity_get_style (AdgEntity *entity, - AdgStyleSlot style_slot); -void adg_entity_apply (AdgEntity *entity, - AdgStyleSlot style_slot, - cairo_t *cr); -gboolean adg_entity_model_matrix_applied (AdgEntity *entity); -gboolean adg_entity_paper_matrix_applied (AdgEntity *entity); -gboolean adg_entity_model_applied (AdgEntity *entity); +AdgStyle * adg_entity_get_style (AdgEntity *entity, + AdgStyleSlot style_slot); +void adg_entity_apply (AdgEntity *entity, + AdgStyleSlot style_slot, + cairo_t *cr); +gboolean adg_entity_model_matrix_applied (AdgEntity *entity); +gboolean adg_entity_paper_matrix_applied (AdgEntity *entity); +gboolean adg_entity_model_applied (AdgEntity *entity); void adg_entity_invalidate (AdgEntity *entity); void adg_entity_render (AdgEntity *entity, cairo_t *cr); diff --git a/adg/adg-enums.h b/adg/adg-enums.h index a23beef8..954c3295 100644 --- a/adg/adg-enums.h +++ b/adg/adg-enums.h @@ -103,4 +103,4 @@ typedef enum { G_END_DECLS -#endif /* __ADG_ENUMS_H__ */ +#endif /* __ADG_ENUMS_H__ */ diff --git a/adg/adg-font-style-private.h b/adg/adg-font-style-private.h index 1f44c8f7..e489269d 100644 --- a/adg/adg-font-style-private.h +++ b/adg/adg-font-style-private.h @@ -27,14 +27,14 @@ G_BEGIN_DECLS struct _AdgFontStylePrivate { - gchar *family; - cairo_font_slant_t slant; - cairo_font_weight_t weight; - gdouble size; - cairo_antialias_t antialias; - cairo_subpixel_order_t subpixel_order; - cairo_hint_style_t hint_style; - cairo_hint_metrics_t hint_metrics; + gchar *family; + cairo_font_slant_t slant; + cairo_font_weight_t weight; + gdouble size; + cairo_antialias_t antialias; + cairo_subpixel_order_t subpixel_order; + cairo_hint_style_t hint_style; + cairo_hint_metrics_t hint_metrics; }; G_END_DECLS diff --git a/adg/adg-font-style.c b/adg/adg-font-style.c index f30846d7..2537a9ec 100644 --- a/adg/adg-font-style.c +++ b/adg/adg-font-style.c @@ -47,19 +47,19 @@ enum { }; -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static GPtrArray * get_pool (void); -static void apply (AdgStyle *style, - cairo_t *cr); -static void set_family (AdgFontStyle *font_style, - const gchar *family); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static GPtrArray * get_pool (void); +static void apply (AdgStyle *style, + cairo_t *cr); +static void set_family (AdgFontStyle *font_style, + const gchar *family); G_DEFINE_TYPE(AdgFontStyle, adg_font_style, ADG_TYPE_STYLE) @@ -84,77 +84,77 @@ adg_font_style_class_init(AdgFontStyleClass *klass) style_class->apply = apply; param = g_param_spec_string("family", - P_("Font Family"), - P_ - ("The font family name, encoded in UTF-8"), - NULL, G_PARAM_READWRITE); + P_("Font Family"), + P_ + ("The font family name, encoded in UTF-8"), + NULL, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_FAMILY, param); param = g_param_spec_int("slant", - P_("Font Slant"), - P_ - ("Variant of a font face based on its slant"), - G_MININT, G_MAXINT, CAIRO_FONT_SLANT_NORMAL, - G_PARAM_READWRITE); + P_("Font Slant"), + P_ + ("Variant of a font face based on its slant"), + G_MININT, G_MAXINT, CAIRO_FONT_SLANT_NORMAL, + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_SLANT, param); param = g_param_spec_int("weight", - P_("Font Weight"), - P_ - ("Variant of a font face based on its weight"), - G_MININT, G_MAXINT, CAIRO_FONT_WEIGHT_NORMAL, - G_PARAM_READWRITE); + P_("Font Weight"), + P_ + ("Variant of a font face based on its weight"), + G_MININT, G_MAXINT, CAIRO_FONT_WEIGHT_NORMAL, + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_WEIGHT, param); param = g_param_spec_double("size", - P_("Font Size"), - P_("Font size in user space units"), - 0., G_MAXDOUBLE, 10., G_PARAM_READWRITE); + P_("Font Size"), + P_("Font size in user space units"), + 0., G_MAXDOUBLE, 10., G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_SIZE, param); param = g_param_spec_int("antialias", - P_("Font Antialiasing Mode"), - P_ - ("Type of antialiasing to do when rendering text"), - G_MININT, G_MAXINT, CAIRO_ANTIALIAS_DEFAULT, - G_PARAM_READWRITE); + P_("Font Antialiasing Mode"), + P_ + ("Type of antialiasing to do when rendering text"), + G_MININT, G_MAXINT, CAIRO_ANTIALIAS_DEFAULT, + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_ANTIALIAS, param); param = g_param_spec_int("subpixel-order", - P_("Font Subpixel Order"), - P_ - ("The order of color elements within each pixel on the display device when rendering with subpixel antialiasing mode"), - G_MININT, G_MAXINT, - CAIRO_SUBPIXEL_ORDER_DEFAULT, - G_PARAM_READWRITE); + P_("Font Subpixel Order"), + P_ + ("The order of color elements within each pixel on the display device when rendering with subpixel antialiasing mode"), + G_MININT, G_MAXINT, + CAIRO_SUBPIXEL_ORDER_DEFAULT, + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_SUBPIXEL_ORDER, - param); + param); param = g_param_spec_int("hint-style", - P_("Type of Hinting"), - P_ - ("How outlines must fit to the pixel grid in order to improve the glyph appearance"), - G_MININT, G_MAXINT, CAIRO_HINT_STYLE_DEFAULT, - G_PARAM_READWRITE); + P_("Type of Hinting"), + P_ + ("How outlines must fit to the pixel grid in order to improve the glyph appearance"), + G_MININT, G_MAXINT, CAIRO_HINT_STYLE_DEFAULT, + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_HINT_STYLE, param); param = g_param_spec_int("hint-metrics", - P_("Font Metric Hinting"), - P_ - ("Whether to hint font metrics, that is align them to integer values in device space"), - G_MININT, G_MAXINT, - CAIRO_HINT_METRICS_DEFAULT, - G_PARAM_READWRITE); + P_("Font Metric Hinting"), + P_ + ("Whether to hint font metrics, that is align them to integer values in device space"), + G_MININT, G_MAXINT, + CAIRO_HINT_METRICS_DEFAULT, + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_HINT_METRICS, - param); + param); } static void adg_font_style_init(AdgFontStyle *font_style) { AdgFontStylePrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(font_style, - ADG_TYPE_FONT_STYLE, - AdgFontStylePrivate); + ADG_TYPE_FONT_STYLE, + AdgFontStylePrivate); priv->family = NULL; priv->slant = CAIRO_FONT_SLANT_NORMAL; @@ -175,69 +175,69 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) switch (prop_id) { case PROP_FAMILY: - g_value_set_string(value, font_style->priv->family); - break; + g_value_set_string(value, font_style->priv->family); + break; case PROP_SLANT: - g_value_set_int(value, font_style->priv->slant); - break; + g_value_set_int(value, font_style->priv->slant); + break; case PROP_WEIGHT: - g_value_set_int(value, font_style->priv->weight); - break; + g_value_set_int(value, font_style->priv->weight); + break; case PROP_SIZE: - g_value_set_double(value, font_style->priv->size); - break; + g_value_set_double(value, font_style->priv->size); + break; case PROP_ANTIALIAS: - g_value_set_int(value, font_style->priv->antialias); - break; + g_value_set_int(value, font_style->priv->antialias); + break; case PROP_SUBPIXEL_ORDER: - g_value_set_int(value, font_style->priv->subpixel_order); - break; + g_value_set_int(value, font_style->priv->subpixel_order); + break; case PROP_HINT_STYLE: - g_value_set_int(value, font_style->priv->hint_style); - break; + g_value_set_int(value, font_style->priv->hint_style); + break; case PROP_HINT_METRICS: - g_value_set_int(value, font_style->priv->hint_metrics); - break; + g_value_set_int(value, font_style->priv->hint_metrics); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgFontStyle *font_style = (AdgFontStyle *) object; switch (prop_id) { case PROP_FAMILY: - set_family(font_style, g_value_get_string(value)); - break; + set_family(font_style, g_value_get_string(value)); + break; case PROP_SLANT: - font_style->priv->slant = g_value_get_int(value); - break; + font_style->priv->slant = g_value_get_int(value); + break; case PROP_WEIGHT: - font_style->priv->weight = g_value_get_int(value); - break; + font_style->priv->weight = g_value_get_int(value); + break; case PROP_SIZE: - font_style->priv->size = g_value_get_double(value); - break; + font_style->priv->size = g_value_get_double(value); + break; case PROP_ANTIALIAS: - font_style->priv->antialias = g_value_get_int(value); - break; + font_style->priv->antialias = g_value_get_int(value); + break; case PROP_SUBPIXEL_ORDER: - font_style->priv->subpixel_order = g_value_get_int(value); - break; + font_style->priv->subpixel_order = g_value_get_int(value); + break; case PROP_HINT_STYLE: - font_style->priv->hint_style = g_value_get_int(value); - break; + font_style->priv->hint_style = g_value_get_int(value); + break; case PROP_HINT_METRICS: - font_style->priv->hint_metrics = g_value_get_int(value); - break; + font_style->priv->hint_metrics = g_value_get_int(value); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } @@ -255,7 +255,7 @@ adg_font_style_get_slot(void) static AdgStyleSlot slot = -1; if (G_UNLIKELY(slot < 0)) - slot = adg_context_get_slot(ADG_TYPE_FONT_STYLE); + slot = adg_context_get_slot(ADG_TYPE_FONT_STYLE); return slot; } @@ -318,7 +318,7 @@ cairo_font_slant_t adg_font_style_get_slant(AdgFontStyle *font_style) { g_return_val_if_fail(ADG_IS_FONT_STYLE(font_style), - CAIRO_FONT_SLANT_NORMAL); + CAIRO_FONT_SLANT_NORMAL); return font_style->priv->slant; } @@ -332,7 +332,7 @@ adg_font_style_get_slant(AdgFontStyle *font_style) **/ void adg_font_style_set_slant(AdgFontStyle *font_style, - cairo_font_slant_t slant) + cairo_font_slant_t slant) { g_return_if_fail(ADG_IS_FONT_STYLE(font_style)); @@ -352,7 +352,7 @@ cairo_font_weight_t adg_font_style_get_weight(AdgFontStyle *font_style) { g_return_val_if_fail(ADG_IS_FONT_STYLE(font_style), - CAIRO_FONT_WEIGHT_NORMAL); + CAIRO_FONT_WEIGHT_NORMAL); return font_style->priv->weight; } @@ -366,7 +366,7 @@ adg_font_style_get_weight(AdgFontStyle *font_style) **/ void adg_font_style_set_weight(AdgFontStyle *font_style, - cairo_font_weight_t weight) + cairo_font_weight_t weight) { g_return_if_fail(ADG_IS_FONT_STYLE(font_style)); @@ -418,7 +418,7 @@ cairo_antialias_t adg_font_style_get_antialias(AdgFontStyle *font_style) { g_return_val_if_fail(ADG_IS_FONT_STYLE(font_style), - CAIRO_ANTIALIAS_DEFAULT); + CAIRO_ANTIALIAS_DEFAULT); return font_style->priv->antialias; } @@ -432,7 +432,7 @@ adg_font_style_get_antialias(AdgFontStyle *font_style) **/ void adg_font_style_set_antialias(AdgFontStyle *font_style, - cairo_antialias_t antialias) + cairo_antialias_t antialias) { g_return_if_fail(ADG_IS_FONT_STYLE(font_style)); @@ -454,7 +454,7 @@ cairo_subpixel_order_t adg_font_style_get_subpixel_order(AdgFontStyle *font_style) { g_return_val_if_fail(ADG_IS_FONT_STYLE(font_style), - CAIRO_SUBPIXEL_ORDER_DEFAULT); + CAIRO_SUBPIXEL_ORDER_DEFAULT); return font_style->priv->subpixel_order; } @@ -468,7 +468,7 @@ adg_font_style_get_subpixel_order(AdgFontStyle *font_style) **/ void adg_font_style_set_subpixel_order(AdgFontStyle *font_style, - cairo_subpixel_order_t subpixel_order) + cairo_subpixel_order_t subpixel_order) { g_return_if_fail(ADG_IS_FONT_STYLE(font_style)); @@ -489,7 +489,7 @@ cairo_hint_style_t adg_font_style_get_hint_style(AdgFontStyle *font_style) { g_return_val_if_fail(ADG_IS_FONT_STYLE(font_style), - CAIRO_HINT_STYLE_DEFAULT); + CAIRO_HINT_STYLE_DEFAULT); return font_style->priv->hint_style; } @@ -503,7 +503,7 @@ adg_font_style_get_hint_style(AdgFontStyle *font_style) **/ void adg_font_style_set_hint_style(AdgFontStyle *font_style, - cairo_hint_style_t hint_style) + cairo_hint_style_t hint_style) { g_return_if_fail(ADG_IS_FONT_STYLE(font_style)); @@ -523,7 +523,7 @@ cairo_hint_metrics_t adg_font_style_get_hint_metrics(AdgFontStyle *font_style) { g_return_val_if_fail(ADG_IS_FONT_STYLE(font_style), - CAIRO_HINT_METRICS_DEFAULT); + CAIRO_HINT_METRICS_DEFAULT); return font_style->priv->hint_metrics; } @@ -537,7 +537,7 @@ adg_font_style_get_hint_metrics(AdgFontStyle *font_style) **/ void adg_font_style_set_hint_metrics(AdgFontStyle *font_style, - cairo_hint_metrics_t hint_metrics) + cairo_hint_metrics_t hint_metrics) { g_return_if_fail(ADG_IS_FONT_STYLE(font_style)); @@ -552,23 +552,23 @@ get_pool(void) static GPtrArray *pool = NULL; if (G_UNLIKELY(pool == NULL)) { - pool = g_ptr_array_sized_new(ADG_FONT_STYLE_LAST); - - pool->pdata[ADG_FONT_STYLE_TEXT] = - g_object_new(ADG_TYPE_FONT_STYLE, "family", "Serif", "size", - 14., NULL); - pool->pdata[ADG_FONT_STYLE_QUOTE] = - g_object_new(ADG_TYPE_FONT_STYLE, "family", "Sans", "size", - 12., "weight", CAIRO_FONT_WEIGHT_BOLD, NULL); - pool->pdata[ADG_FONT_STYLE_TOLERANCE] = - g_object_new(ADG_TYPE_FONT_STYLE, "family", "Sans", "size", 8., - NULL); - pool->pdata[ADG_FONT_STYLE_NOTE] = - g_object_new(ADG_TYPE_FONT_STYLE, "family", "Sans", "size", - 12., NULL); - - pool->len = ADG_FONT_STYLE_LAST; - } + pool = g_ptr_array_sized_new(ADG_FONT_STYLE_LAST); + + pool->pdata[ADG_FONT_STYLE_TEXT] = + g_object_new(ADG_TYPE_FONT_STYLE, "family", "Serif", "size", + 14., NULL); + pool->pdata[ADG_FONT_STYLE_QUOTE] = + g_object_new(ADG_TYPE_FONT_STYLE, "family", "Sans", "size", + 12., "weight", CAIRO_FONT_WEIGHT_BOLD, NULL); + pool->pdata[ADG_FONT_STYLE_TOLERANCE] = + g_object_new(ADG_TYPE_FONT_STYLE, "family", "Sans", "size", 8., + NULL); + pool->pdata[ADG_FONT_STYLE_NOTE] = + g_object_new(ADG_TYPE_FONT_STYLE, "family", "Sans", "size", + 12., NULL); + + pool->len = ADG_FONT_STYLE_LAST; + } return pool; } @@ -589,25 +589,25 @@ apply(AdgStyle *style, cairo_t *cr) PARENT_CLASS->apply(style, cr); if (font_style->priv->family) - cairo_select_font_face(cr, font_style->priv->family, - font_style->priv->slant, - font_style->priv->weight); + cairo_select_font_face(cr, font_style->priv->family, + font_style->priv->slant, + font_style->priv->weight); cairo_matrix_init_scale(&font_matrix, - size / (matrix.xx - matrix.yx), - size / (matrix.yy + matrix.xy)); + size / (matrix.xx - matrix.yx), + size / (matrix.yy + matrix.xy)); cairo_set_font_matrix(cr, &font_matrix); options = cairo_font_options_create(); cairo_font_options_set_antialias(options, font_style->priv->antialias); cairo_font_options_set_subpixel_order(options, - font_style->priv-> - subpixel_order); + font_style->priv-> + subpixel_order); cairo_font_options_set_hint_style(options, - font_style->priv->hint_style); + font_style->priv->hint_style); cairo_font_options_set_hint_metrics(options, - font_style->priv->hint_metrics); + font_style->priv->hint_metrics); cairo_set_font_options(cr, options); cairo_font_options_destroy(options); diff --git a/adg/adg-font-style.h b/adg/adg-font-style.h index 3707f3ba..ac773157 100644 --- a/adg/adg-font-style.h +++ b/adg/adg-font-style.h @@ -40,52 +40,52 @@ typedef struct _AdgFontStyleClass AdgFontStyleClass; typedef struct _AdgFontStylePrivate AdgFontStylePrivate; struct _AdgFontStyle { - AdgStyle style; + AdgStyle style; /*< private >*/ - AdgFontStylePrivate *priv; + AdgFontStylePrivate *priv; }; struct _AdgFontStyleClass { - AdgStyleClass parent_class; + AdgStyleClass parent_class; }; -GType adg_font_style_get_type (void) G_GNUC_CONST; -AdgStyleSlot adg_font_style_get_slot (void) G_GNUC_CONST; -AdgStyle * adg_font_style_new (void); +GType adg_font_style_get_type (void) G_GNUC_CONST; +AdgStyleSlot adg_font_style_get_slot (void) G_GNUC_CONST; +AdgStyle * adg_font_style_new (void); -const gchar * adg_font_style_get_family (AdgFontStyle *font_style); -void adg_font_style_set_family (AdgFontStyle *font_style, - const gchar *family); +const gchar * adg_font_style_get_family (AdgFontStyle *font_style); +void adg_font_style_set_family (AdgFontStyle *font_style, + const gchar *family); cairo_font_slant_t - adg_font_style_get_slant (AdgFontStyle *font_style); -void adg_font_style_set_slant (AdgFontStyle *font_style, - cairo_font_slant_t slant); + adg_font_style_get_slant (AdgFontStyle *font_style); +void adg_font_style_set_slant (AdgFontStyle *font_style, + cairo_font_slant_t slant); cairo_font_weight_t - adg_font_style_get_weight (AdgFontStyle *font_style); -void adg_font_style_set_weight (AdgFontStyle *font_style, - cairo_font_weight_t weight); -gdouble adg_font_style_get_size (AdgFontStyle *font_style); -void adg_font_style_set_size (AdgFontStyle *font_style, - gdouble size); + adg_font_style_get_weight (AdgFontStyle *font_style); +void adg_font_style_set_weight (AdgFontStyle *font_style, + cairo_font_weight_t weight); +gdouble adg_font_style_get_size (AdgFontStyle *font_style); +void adg_font_style_set_size (AdgFontStyle *font_style, + gdouble size); cairo_antialias_t - adg_font_style_get_antialias (AdgFontStyle *font_style); -void adg_font_style_set_antialias (AdgFontStyle *font_style, - cairo_antialias_t antialias); + adg_font_style_get_antialias (AdgFontStyle *font_style); +void adg_font_style_set_antialias (AdgFontStyle *font_style, + cairo_antialias_t antialias); cairo_subpixel_order_t - adg_font_style_get_subpixel_order - (AdgFontStyle *font_style); -void adg_font_style_set_subpixel_order - (AdgFontStyle *font_style, - cairo_subpixel_order_t subpixel_order); + adg_font_style_get_subpixel_order + (AdgFontStyle *font_style); +void adg_font_style_set_subpixel_order + (AdgFontStyle *font_style, + cairo_subpixel_order_t subpixel_order); cairo_hint_style_t - adg_font_style_get_hint_style (AdgFontStyle *font_style); -void adg_font_style_set_hint_style (AdgFontStyle *font_style, - cairo_hint_style_t hint_style); + adg_font_style_get_hint_style (AdgFontStyle *font_style); +void adg_font_style_set_hint_style (AdgFontStyle *font_style, + cairo_hint_style_t hint_style); cairo_hint_metrics_t - adg_font_style_get_hint_metrics (AdgFontStyle *font_style); -void adg_font_style_set_hint_metrics (AdgFontStyle *font_style, - cairo_hint_metrics_t hint_metrics); + adg_font_style_get_hint_metrics (AdgFontStyle *font_style); +void adg_font_style_set_hint_metrics (AdgFontStyle *font_style, + cairo_hint_metrics_t hint_metrics); G_END_DECLS diff --git a/adg/adg-ldim-private.h b/adg/adg-ldim-private.h index a6f6378e..28bf21d4 100644 --- a/adg/adg-ldim-private.h +++ b/adg/adg-ldim-private.h @@ -28,13 +28,13 @@ G_BEGIN_DECLS struct _AdgLDimPrivate { /* Properties */ - double direction; + double direction; /* Cache */ - cairo_path_t extension1; - cairo_path_t extension2; - cairo_path_t arrow_path; - cairo_path_t baseline; + cairo_path_t extension1; + cairo_path_t extension2; + cairo_path_t arrow_path; + cairo_path_t baseline; }; G_END_DECLS diff --git a/adg/adg-ldim.c b/adg/adg-ldim.c index 02ccf1cc..c29ac4a7 100644 --- a/adg/adg-ldim.c +++ b/adg/adg-ldim.c @@ -42,19 +42,19 @@ enum { }; -static void finalize (GObject *object); -static void get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void update (AdgEntity *entity); -static void render (AdgEntity *entity, - cairo_t *cr); -static gchar * default_quote (AdgDim *dim); +static void finalize (GObject *object); +static void get_property (GObject *object, + guint param_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint param_id, + const GValue *value, + GParamSpec *pspec); +static void update (AdgEntity *entity); +static void render (AdgEntity *entity, + cairo_t *cr); +static gchar * default_quote (AdgDim *dim); G_DEFINE_TYPE(AdgLDim, adg_ldim, ADG_TYPE_DIM); @@ -83,10 +83,10 @@ adg_ldim_class_init(AdgLDimClass *klass) dim_class->default_quote = default_quote; param = g_param_spec_double("direction", - P_("Direction"), - P_("The inclination angle of the extension lines"), - -G_MAXDOUBLE, G_MAXDOUBLE, CPML_DIR_RIGHT, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT); + P_("Direction"), + P_("The inclination angle of the extension lines"), + -G_MAXDOUBLE, G_MAXDOUBLE, CPML_DIR_RIGHT, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT); g_object_class_install_property(gobject_class, PROP_DIRECTION, param); } @@ -94,7 +94,7 @@ static void adg_ldim_init(AdgLDim *ldim) { AdgLDimPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(ldim, ADG_TYPE_LDIM, - AdgLDimPrivate); + AdgLDimPrivate); priv->direction = CPML_DIR_RIGHT; @@ -130,33 +130,33 @@ finalize(GObject *object) static void get_property(GObject *object, - guint prop_id, GValue *value, GParamSpec *pspec) + guint prop_id, GValue *value, GParamSpec *pspec) { AdgLDim *ldim = ADG_LDIM(object); switch (prop_id) { case PROP_DIRECTION: - g_value_set_double(value, ldim->priv->direction); - break; + g_value_set_double(value, ldim->priv->direction); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgLDim *ldim = ADG_LDIM(object); switch (prop_id) { case PROP_DIRECTION: - ldim->priv->direction = g_value_get_double(value); - break; + ldim->priv->direction = g_value_get_double(value); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } @@ -180,14 +180,14 @@ update(AdgEntity *entity) dim = (AdgDim *) entity; ldim = (AdgLDim *) entity; dim_style = - (AdgDimStyle *) adg_entity_get_style(entity, ADG_SLOT_DIM_STYLE); + (AdgDimStyle *) adg_entity_get_style(entity, ADG_SLOT_DIM_STYLE); arrow_style = - (AdgArrowStyle *) adg_dim_style_get_arrow_style(dim_style); + (AdgArrowStyle *) adg_dim_style_get_arrow_style(dim_style); /* Get the inverted transformation matrix */ adg_matrix_set(&device2user, adg_entity_get_model_matrix(entity)); g_return_if_fail(cairo_matrix_invert(&device2user) == - CAIRO_STATUS_SUCCESS); + CAIRO_STATUS_SUCCESS); /* Set vector to the director of the extension lines */ cpml_vector_from_angle(&vector, ldim->priv->direction); @@ -204,11 +204,11 @@ update(AdgEntity *entity) /* Calculate arrow1 and arrow2 */ offset.x = - vector.x * adg_dim_style_get_baseline_spacing(dim_style) * - dim->priv->level; + vector.x * adg_dim_style_get_baseline_spacing(dim_style) * + dim->priv->level; offset.y = - vector.y * adg_dim_style_get_baseline_spacing(dim_style) * - dim->priv->level; + vector.y * adg_dim_style_get_baseline_spacing(dim_style) * + dim->priv->level; cairo_matrix_transform_distance(&device2user, &offset.x, &offset.y); arrow1.x = dim->priv->pos1.x + offset.x; @@ -249,7 +249,7 @@ update(AdgEntity *entity) /* Set extension1 */ if (ldim->priv->extension1.data == NULL) - ldim->priv->extension1.data = g_new(cairo_path_data_t, 4); + ldim->priv->extension1.data = g_new(cairo_path_data_t, 4); path_data = ldim->priv->extension1.data; path_data[0].header.type = CAIRO_PATH_MOVE_TO; @@ -263,7 +263,7 @@ update(AdgEntity *entity) /* Set extension2 */ if (ldim->priv->extension2.data == NULL) - ldim->priv->extension2.data = g_new(cairo_path_data_t, 4); + ldim->priv->extension2.data = g_new(cairo_path_data_t, 4); path_data = ldim->priv->extension2.data; path_data[0].header.type = CAIRO_PATH_MOVE_TO; @@ -277,7 +277,7 @@ update(AdgEntity *entity) /* Set arrow_path */ if (ldim->priv->arrow_path.data == NULL) - ldim->priv->arrow_path.data = g_new(cairo_path_data_t, 4); + ldim->priv->arrow_path.data = g_new(cairo_path_data_t, 4); path_data = ldim->priv->arrow_path.data; path_data[0].header.type = CAIRO_PATH_MOVE_TO; @@ -291,7 +291,7 @@ update(AdgEntity *entity) /* Set baseline */ if (ldim->priv->baseline.data == NULL) - ldim->priv->baseline.data = g_new(cairo_path_data_t, 4); + ldim->priv->baseline.data = g_new(cairo_path_data_t, 4); path_data = ldim->priv->baseline.data; path_data[0].header.type = CAIRO_PATH_MOVE_TO; @@ -317,10 +317,10 @@ render(AdgEntity *entity, cairo_t *cr) dim = (AdgDim *) entity; ldim = (AdgLDim *) entity; dim_style = - (AdgDimStyle *) adg_entity_get_style(entity, ADG_SLOT_DIM_STYLE); + (AdgDimStyle *) adg_entity_get_style(entity, ADG_SLOT_DIM_STYLE); line_style = adg_dim_style_get_line_style(dim_style); arrow_style = - (AdgArrowStyle *) adg_dim_style_get_arrow_style(dim_style); + (AdgArrowStyle *) adg_dim_style_get_arrow_style(dim_style); /* TODO: caching if (!adg_entity_model_applied (entity)) */ @@ -331,9 +331,9 @@ render(AdgEntity *entity, cairo_t *cr) /* Arrows */ if (cpml_path_from_cairo(&primitive, &ldim->priv->arrow_path, NULL)) { - adg_arrow_style_render(arrow_style, cr, &primitive); - if (cpml_primitive_reverse(&primitive)) - adg_arrow_style_render(arrow_style, cr, &primitive); + adg_arrow_style_render(arrow_style, cr, &primitive); + if (cpml_primitive_reverse(&primitive)) + adg_arrow_style_render(arrow_style, cr, &primitive); } /* Lines */ @@ -359,12 +359,12 @@ default_quote(AdgDim *dim) gdouble number; if (!cpml_pair_distance(&dim->priv->pos2, &dim->priv->pos1, &number)) - return NULL; + return NULL; dim_style = (AdgDimStyle *) adg_entity_get_style((AdgEntity *) dim, - ADG_SLOT_DIM_STYLE); + ADG_SLOT_DIM_STYLE); return g_strdup_printf(adg_dim_style_get_number_format(dim_style), - number); + number); } @@ -398,13 +398,13 @@ adg_ldim_new(void) */ AdgEntity * adg_ldim_new_full(const AdgPair *ref1, const AdgPair *ref2, - double direction, const AdgPair *pos) + double direction, const AdgPair *pos) { AdgEntity *entity = (AdgEntity *) g_object_new(ADG_TYPE_LDIM, - "ref1", ref1, - "ref2", ref2, - "direction", direction, - NULL); + "ref1", ref1, + "ref2", ref2, + "direction", direction, + NULL); adg_ldim_set_pos((AdgLDim *) entity, pos); return entity; } @@ -425,10 +425,10 @@ adg_ldim_new_full(const AdgPair *ref1, const AdgPair *ref2, */ AdgEntity * adg_ldim_new_full_explicit(double ref1_x, - double ref1_y, - double ref2_x, - double ref2_y, - double direction, double pos_x, double pos_y) + double ref1_y, + double ref2_x, + double ref2_y, + double direction, double pos_x, double pos_y) { AdgPair ref1; AdgPair ref2; @@ -476,16 +476,16 @@ adg_ldim_set_pos(AdgLDim *ldim, const AdgPair *pos) baseline_vector.y = extension_vector.x; d = extension_vector.y * baseline_vector.x - - extension_vector.x * baseline_vector.y; + extension_vector.x * baseline_vector.y; g_return_if_fail(d != 0.); k = ((pos->y - dim->priv->ref1.y) * baseline_vector.x - - (pos->x - dim->priv->ref1.x) * baseline_vector.y) / d; + (pos->x - dim->priv->ref1.x) * baseline_vector.y) / d; dim->priv->pos1.x = dim->priv->ref1.x + k * extension_vector.x; dim->priv->pos1.y = dim->priv->ref1.y + k * extension_vector.y; k = ((pos->y - dim->priv->ref2.y) * baseline_vector.x - - (pos->x - dim->priv->ref2.x) * baseline_vector.y) / d; + (pos->x - dim->priv->ref2.x) * baseline_vector.y) / d; dim->priv->pos2.x = dim->priv->ref2.x + k * extension_vector.x; dim->priv->pos2.y = dim->priv->ref2.y + k * extension_vector.y; diff --git a/adg/adg-ldim.h b/adg/adg-ldim.h index 63829a4e..fa2511a8 100644 --- a/adg/adg-ldim.h +++ b/adg/adg-ldim.h @@ -39,13 +39,13 @@ typedef struct _AdgLDimClass AdgLDimClass; typedef struct _AdgLDimPrivate AdgLDimPrivate; struct _AdgLDim { - AdgDim dim; + AdgDim dim; /*< private >*/ - AdgLDimPrivate *priv; + AdgLDimPrivate *priv; }; struct _AdgLDimClass { - AdgDimClass parent_class; + AdgDimClass parent_class; }; diff --git a/adg/adg-line-style-private.h b/adg/adg-line-style-private.h index 0fb02c37..38b67aab 100644 --- a/adg/adg-line-style-private.h +++ b/adg/adg-line-style-private.h @@ -31,7 +31,7 @@ struct _AdgLineStylePrivate { cairo_line_cap_t cap; cairo_line_join_t join; double miter_limit; - cairo_antialias_t antialias; + cairo_antialias_t antialias; double *dashes; int num_dashes; double dash_offset; diff --git a/adg/adg-line-style.c b/adg/adg-line-style.c index 869a36db..ca85b58a 100644 --- a/adg/adg-line-style.c +++ b/adg/adg-line-style.c @@ -46,17 +46,17 @@ enum { }; -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static GPtrArray * get_pool (void); -static void apply (AdgStyle *style, - cairo_t *cr); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static GPtrArray * get_pool (void); +static void apply (AdgStyle *style, + cairo_t *cr); G_DEFINE_TYPE(AdgLineStyle, adg_line_style, ADG_TYPE_STYLE) @@ -81,39 +81,39 @@ adg_line_style_class_init(AdgLineStyleClass *klass) style_class->apply = apply; param = g_param_spec_double("width", - P_("Line Width"), - P_("The line thickness in device unit"), - 0., G_MAXDOUBLE, 2., G_PARAM_READWRITE); + P_("Line Width"), + P_("The line thickness in device unit"), + 0., G_MAXDOUBLE, 2., G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_WIDTH, param); param = g_param_spec_int("cap", - P_("Line Cap"), - P_("The line cap mode"), - G_MININT, G_MAXINT, CAIRO_LINE_CAP_ROUND, - G_PARAM_READWRITE); + P_("Line Cap"), + P_("The line cap mode"), + G_MININT, G_MAXINT, CAIRO_LINE_CAP_ROUND, + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_CAP, param); param = g_param_spec_int("join", - P_("Line Join"), - P_("The line join mode"), - G_MININT, G_MAXINT, CAIRO_LINE_JOIN_MITER, - G_PARAM_READWRITE); + P_("Line Join"), + P_("The line join mode"), + G_MININT, G_MAXINT, CAIRO_LINE_JOIN_MITER, + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_JOIN, param); param = g_param_spec_double("miter-limit", - P_("Miter Limit"), - P_ - ("Whether the lines should be joined with a bevel instead of a miter"), - 0., G_MAXDOUBLE, 10., G_PARAM_READWRITE); + P_("Miter Limit"), + P_ + ("Whether the lines should be joined with a bevel instead of a miter"), + 0., G_MAXDOUBLE, 10., G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_MITER_LIMIT, - param); + param); param = g_param_spec_int("antialias", - P_("Antialiasing Mode"), - P_ - ("Type of antialiasing to do when rendering lines"), - G_MININT, G_MAXINT, CAIRO_ANTIALIAS_DEFAULT, - G_PARAM_READWRITE); + P_("Antialiasing Mode"), + P_ + ("Type of antialiasing to do when rendering lines"), + G_MININT, G_MAXINT, CAIRO_ANTIALIAS_DEFAULT, + G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_ANTIALIAS, param); /* TODO: PROP_DASH (PROP_DASHES, PROP_NUM_DASHES, PROP_DASH_OFFSET) */ @@ -123,8 +123,8 @@ static void adg_line_style_init(AdgLineStyle *line_style) { AdgLineStylePrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(line_style, - ADG_TYPE_LINE_STYLE, - AdgLineStylePrivate); + ADG_TYPE_LINE_STYLE, + AdgLineStylePrivate); priv->width = 2.; priv->cap = CAIRO_LINE_CAP_ROUND; @@ -140,63 +140,63 @@ adg_line_style_init(AdgLineStyle *line_style) static void get_property(GObject *object, - guint prop_id, GValue *value, GParamSpec *pspec) + guint prop_id, GValue *value, GParamSpec *pspec) { AdgLineStyle *line_style = (AdgLineStyle *) object; switch (prop_id) { case PROP_WIDTH: - g_value_set_double(value, line_style->priv->width); - break; + g_value_set_double(value, line_style->priv->width); + break; case PROP_CAP: - g_value_set_int(value, line_style->priv->cap); - break; + g_value_set_int(value, line_style->priv->cap); + break; case PROP_JOIN: - g_value_set_int(value, line_style->priv->join); - break; + g_value_set_int(value, line_style->priv->join); + break; case PROP_MITER_LIMIT: - g_value_set_double(value, line_style->priv->miter_limit); - break; + g_value_set_double(value, line_style->priv->miter_limit); + break; case PROP_ANTIALIAS: - g_value_set_int(value, line_style->priv->antialias); - break; + g_value_set_int(value, line_style->priv->antialias); + break; case PROP_DASH: - /* TODO */ - break; + /* TODO */ + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgLineStyle *line_style = (AdgLineStyle *) object; switch (prop_id) { case PROP_WIDTH: - line_style->priv->width = g_value_get_double(value); - break; + line_style->priv->width = g_value_get_double(value); + break; case PROP_CAP: - line_style->priv->cap = g_value_get_int(value); - break; + line_style->priv->cap = g_value_get_int(value); + break; case PROP_JOIN: - line_style->priv->join = g_value_get_int(value); - break; + line_style->priv->join = g_value_get_int(value); + break; case PROP_MITER_LIMIT: - line_style->priv->miter_limit = g_value_get_double(value); - break; + line_style->priv->miter_limit = g_value_get_double(value); + break; case PROP_ANTIALIAS: - line_style->priv->antialias = g_value_get_int(value); - break; + line_style->priv->antialias = g_value_get_int(value); + break; case PROP_DASH: - /* TODO */ - break; + /* TODO */ + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } @@ -214,7 +214,7 @@ adg_line_style_get_slot(void) static AdgStyleSlot slot = -1; if (G_UNLIKELY(slot < 0)) - slot = adg_context_get_slot(ADG_TYPE_LINE_STYLE); + slot = adg_context_get_slot(ADG_TYPE_LINE_STYLE); return slot; } @@ -276,7 +276,7 @@ cairo_line_cap_t adg_line_style_get_cap(AdgLineStyle *line_style) { g_return_val_if_fail(ADG_IS_LINE_STYLE(line_style), - CAIRO_LINE_CAP_BUTT); + CAIRO_LINE_CAP_BUTT); return line_style->priv->cap; } @@ -309,7 +309,7 @@ cairo_line_join_t adg_line_style_get_join(AdgLineStyle *line_style) { g_return_val_if_fail(ADG_IS_LINE_STYLE(line_style), - CAIRO_LINE_JOIN_MITER); + CAIRO_LINE_JOIN_MITER); return line_style->priv->join; } @@ -356,7 +356,7 @@ adg_line_style_get_miter_limit(AdgLineStyle *line_style) **/ void adg_line_style_set_miter_limit(AdgLineStyle *line_style, - gdouble miter_limit) + gdouble miter_limit) { g_return_if_fail(ADG_IS_LINE_STYLE(line_style)); @@ -376,7 +376,7 @@ cairo_antialias_t adg_line_style_get_antialias(AdgLineStyle *line_style) { g_return_val_if_fail(ADG_IS_LINE_STYLE(line_style), - CAIRO_ANTIALIAS_DEFAULT); + CAIRO_ANTIALIAS_DEFAULT); return line_style->priv->antialias; } @@ -390,7 +390,7 @@ adg_line_style_get_antialias(AdgLineStyle *line_style) **/ void adg_line_style_set_antialias(AdgLineStyle *line_style, - cairo_antialias_t antialias) + cairo_antialias_t antialias) { g_return_if_fail(ADG_IS_LINE_STYLE(line_style)); @@ -405,37 +405,37 @@ get_pool(void) static GPtrArray *pool = NULL; if (G_UNLIKELY(pool == NULL)) { - cairo_pattern_t *pattern; + cairo_pattern_t *pattern; - pool = g_ptr_array_sized_new(ADG_LINE_STYLE_LAST); + pool = g_ptr_array_sized_new(ADG_LINE_STYLE_LAST); - pool->pdata[ADG_LINE_STYLE_DRAW] = - g_object_new(ADG_TYPE_LINE_STYLE, "width", 2., NULL); + pool->pdata[ADG_LINE_STYLE_DRAW] = + g_object_new(ADG_TYPE_LINE_STYLE, "width", 2., NULL); - pattern = cairo_pattern_create_rgb(0., 1., 0.); - pool->pdata[ADG_LINE_STYLE_CENTER] = - g_object_new(ADG_TYPE_LINE_STYLE, "pattern", pattern, "width", - 0.75, NULL); - cairo_pattern_destroy(pattern); + pattern = cairo_pattern_create_rgb(0., 1., 0.); + pool->pdata[ADG_LINE_STYLE_CENTER] = + g_object_new(ADG_TYPE_LINE_STYLE, "pattern", pattern, "width", + 0.75, NULL); + cairo_pattern_destroy(pattern); - pattern = cairo_pattern_create_rgba(0., 0., 0., 0.5); - pool->pdata[ADG_LINE_STYLE_HIDDEN] = - g_object_new(ADG_TYPE_LINE_STYLE, "pattern", pattern, "width", - 0.75, NULL); - cairo_pattern_destroy(pattern); + pattern = cairo_pattern_create_rgba(0., 0., 0., 0.5); + pool->pdata[ADG_LINE_STYLE_HIDDEN] = + g_object_new(ADG_TYPE_LINE_STYLE, "pattern", pattern, "width", + 0.75, NULL); + cairo_pattern_destroy(pattern); - pattern = cairo_pattern_create_rgb(0., 0., 1.); - pool->pdata[ADG_LINE_STYLE_XATCH] = - g_object_new(ADG_TYPE_LINE_STYLE, "pattern", pattern, "width", - 1.25, NULL); - cairo_pattern_destroy(pattern); + pattern = cairo_pattern_create_rgb(0., 0., 1.); + pool->pdata[ADG_LINE_STYLE_XATCH] = + g_object_new(ADG_TYPE_LINE_STYLE, "pattern", pattern, "width", + 1.25, NULL); + cairo_pattern_destroy(pattern); - pool->pdata[ADG_LINE_STYLE_DIM] = g_object_new(ADG_TYPE_LINE_STYLE, - "width", 0.75, - NULL); + pool->pdata[ADG_LINE_STYLE_DIM] = g_object_new(ADG_TYPE_LINE_STYLE, + "width", 0.75, + NULL); - pool->len = ADG_LINE_STYLE_LAST; - } + pool->len = ADG_LINE_STYLE_LAST; + } return pool; } @@ -461,10 +461,10 @@ apply(AdgStyle *style, cairo_t *cr) cairo_set_antialias(cr, line_style->priv->antialias); if (line_style->priv->num_dashes > 0) { - g_return_if_fail(line_style->priv->dashes != NULL); + g_return_if_fail(line_style->priv->dashes != NULL); - cairo_set_dash(cr, line_style->priv->dashes, - line_style->priv->num_dashes, - line_style->priv->dash_offset); + cairo_set_dash(cr, line_style->priv->dashes, + line_style->priv->num_dashes, + line_style->priv->dash_offset); } } diff --git a/adg/adg-line-style.h b/adg/adg-line-style.h index b5b97638..e041ea16 100644 --- a/adg/adg-line-style.h +++ b/adg/adg-line-style.h @@ -40,38 +40,38 @@ typedef struct _AdgLineStyleClass AdgLineStyleClass; typedef struct _AdgLineStylePrivate AdgLineStylePrivate; struct _AdgLineStyle { - AdgStyle style; + AdgStyle style; /*< private >*/ - AdgLineStylePrivate *priv; + AdgLineStylePrivate *priv; }; struct _AdgLineStyleClass { - AdgStyleClass parent_class; + AdgStyleClass parent_class; }; -GType adg_line_style_get_type (void) G_GNUC_CONST; -AdgStyleSlot adg_line_style_get_slot (void) G_GNUC_CONST; -AdgStyle * adg_line_style_new (void); +GType adg_line_style_get_type (void) G_GNUC_CONST; +AdgStyleSlot adg_line_style_get_slot (void) G_GNUC_CONST; +AdgStyle * adg_line_style_new (void); -gdouble adg_line_style_get_width (AdgLineStyle *line_style); -void adg_line_style_set_width (AdgLineStyle *line_style, - gdouble width); +gdouble adg_line_style_get_width (AdgLineStyle *line_style); +void adg_line_style_set_width (AdgLineStyle *line_style, + gdouble width); cairo_line_cap_t - adg_line_style_get_cap (AdgLineStyle *line_style); -void adg_line_style_set_cap (AdgLineStyle *line_style, - cairo_line_cap_t cap); + adg_line_style_get_cap (AdgLineStyle *line_style); +void adg_line_style_set_cap (AdgLineStyle *line_style, + cairo_line_cap_t cap); cairo_line_join_t - adg_line_style_get_join (AdgLineStyle *line_style); -void adg_line_style_set_join (AdgLineStyle *line_style, - cairo_line_join_t join); -gdouble adg_line_style_get_miter_limit (AdgLineStyle *line_style); -void adg_line_style_set_miter_limit (AdgLineStyle *line_style, - gdouble miter_limit); + adg_line_style_get_join (AdgLineStyle *line_style); +void adg_line_style_set_join (AdgLineStyle *line_style, + cairo_line_join_t join); +gdouble adg_line_style_get_miter_limit (AdgLineStyle *line_style); +void adg_line_style_set_miter_limit (AdgLineStyle *line_style, + gdouble miter_limit); cairo_antialias_t - adg_line_style_get_antialias (AdgLineStyle *line_style); -void adg_line_style_set_antialias (AdgLineStyle *line_style, - cairo_antialias_t antialias); + adg_line_style_get_antialias (AdgLineStyle *line_style); +void adg_line_style_set_antialias (AdgLineStyle *line_style, + cairo_antialias_t antialias); G_END_DECLS diff --git a/adg/adg-matrix.c b/adg/adg-matrix.c index f5123332..aec8815c 100644 --- a/adg/adg-matrix.c +++ b/adg/adg-matrix.c @@ -39,9 +39,9 @@ adg_matrix_get_type(void) static int matrix_type = 0; if (G_UNLIKELY(matrix_type == 0)) - matrix_type = g_boxed_type_register_static("AdgMatrix", - (GBoxedCopyFunc) adg_matrix_dup, - g_free); + matrix_type = g_boxed_type_register_static("AdgMatrix", + (GBoxedCopyFunc) adg_matrix_dup, + g_free); return matrix_type; } diff --git a/adg/adg-matrix.h b/adg/adg-matrix.h index a7872005..82e8f698 100644 --- a/adg/adg-matrix.h +++ b/adg/adg-matrix.h @@ -33,15 +33,15 @@ G_BEGIN_DECLS typedef cairo_matrix_t AdgMatrix; -GType adg_matrix_get_type (void) G_GNUC_CONST; -AdgMatrix * adg_matrix_dup (const AdgMatrix *matrix); -const AdgMatrix * adg_matrix_get_fallback (void) G_GNUC_CONST; -AdgMatrix * adg_matrix_set (AdgMatrix *matrix, - const AdgMatrix *src); -void adg_matrix_init_null (AdgMatrix *matrix); -gboolean adg_matrix_is_null (const AdgMatrix *matrix); -gboolean adg_matrix_equal (const AdgMatrix *matrix1, - const AdgMatrix *matrix2); +GType adg_matrix_get_type (void) G_GNUC_CONST; +AdgMatrix * adg_matrix_dup (const AdgMatrix *matrix); +const AdgMatrix * adg_matrix_get_fallback (void) G_GNUC_CONST; +AdgMatrix * adg_matrix_set (AdgMatrix *matrix, + const AdgMatrix *src); +void adg_matrix_init_null (AdgMatrix *matrix); +gboolean adg_matrix_is_null (const AdgMatrix *matrix); +gboolean adg_matrix_equal (const AdgMatrix *matrix1, + const AdgMatrix *matrix2); G_END_DECLS diff --git a/adg/adg-model-private.h b/adg/adg-model-private.h index 6614fb5f..8db26deb 100644 --- a/adg/adg-model-private.h +++ b/adg/adg-model-private.h @@ -27,9 +27,9 @@ G_BEGIN_DECLS struct _AdgModelPrivate { - gchar *name; - gchar *material; - gchar *treatment; + gchar *name; + gchar *material; + gchar *treatment; }; G_END_DECLS diff --git a/adg/adg-model.c b/adg/adg-model.c index a309dd9b..75b59246 100644 --- a/adg/adg-model.c +++ b/adg/adg-model.c @@ -50,21 +50,21 @@ enum { }; -static void finalize (GObject *object); -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void set_name (AdgModel *model, - const gchar *name); -static void set_material (AdgModel *model, - const gchar *material); -static void set_treatment (AdgModel *model, - const gchar *treatment); +static void finalize (GObject *object); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void set_name (AdgModel *model, + const gchar *name); +static void set_material (AdgModel *model, + const gchar *material); +static void set_treatment (AdgModel *model, + const gchar *treatment); static guint model_signals[LAST_SIGNAL] = { 0 }; @@ -87,21 +87,21 @@ adg_model_class_init(AdgModelClass *klass) gobject_class->finalize = finalize; param = g_param_spec_string("name", - P_("Part Name"), - P_("Descriptive name of this part"), - NULL, G_PARAM_READWRITE); + P_("Part Name"), + P_("Descriptive name of this part"), + NULL, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_NAME, param); param = g_param_spec_string("material", - P_("Material"), - P_("Material this part is done with"), - NULL, G_PARAM_READWRITE); + P_("Material"), + P_("Material this part is done with"), + NULL, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_MATERIAL, param); param = g_param_spec_string("treatment", - P_("Treatment"), - P_("Treatment this part must receive"), - NULL, G_PARAM_READWRITE); + P_("Treatment"), + P_("Treatment this part must receive"), + NULL, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_TREATMENT, param); } @@ -109,8 +109,8 @@ static void adg_model_init(AdgModel *model) { AdgModelPrivate *priv = - G_TYPE_INSTANCE_GET_PRIVATE(model, ADG_TYPE_MODEL, - AdgModelPrivate); + G_TYPE_INSTANCE_GET_PRIVATE(model, ADG_TYPE_MODEL, + AdgModelPrivate); priv->name = NULL; priv->material = NULL; priv->treatment = NULL; @@ -133,45 +133,45 @@ finalize(GObject *object) static void get_property(GObject *object, - guint prop_id, GValue *value, GParamSpec *pspec) + guint prop_id, GValue *value, GParamSpec *pspec) { AdgModelPrivate *priv = ((AdgModel *) object)->priv; switch (prop_id) { case PROP_NAME: - g_value_set_string(value, priv->name); - break; + g_value_set_string(value, priv->name); + break; case PROP_MATERIAL: - g_value_set_string(value, priv->material); - break; + g_value_set_string(value, priv->material); + break; case PROP_TREATMENT: - g_value_set_string(value, priv->treatment); - break; + g_value_set_string(value, priv->treatment); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgModel *model = ADG_MODEL(object); switch (prop_id) { case PROP_NAME: - set_name(model, g_value_get_string(value)); - break; + set_name(model, g_value_get_string(value)); + break; case PROP_MATERIAL: - set_material(model, g_value_get_string(value)); - break; + set_material(model, g_value_get_string(value)); + break; case PROP_TREATMENT: - set_treatment(model, g_value_get_string(value)); - break; + set_treatment(model, g_value_get_string(value)); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } diff --git a/adg/adg-model.h b/adg/adg-model.h index 519ce599..bdd3f416 100644 --- a/adg/adg-model.h +++ b/adg/adg-model.h @@ -38,17 +38,17 @@ typedef struct _AdgModelClass AdgModelClass; typedef struct _AdgModelPrivate AdgModelPrivate; struct _AdgModel { - GObject object; + GObject object; /*< private >*/ - AdgModelPrivate *priv; + AdgModelPrivate *priv; }; struct _AdgModelClass { - GObjectClass parent_class; + GObjectClass parent_class; }; -GType adg_model_get_type (void) G_GNUC_CONST; +GType adg_model_get_type (void) G_GNUC_CONST; gchar * adg_model_get_name (AdgModel *model); void adg_model_set_name (AdgModel *model, diff --git a/adg/adg-pair.c b/adg/adg-pair.c index d4fc7c7f..89a10fa9 100644 --- a/adg/adg-pair.c +++ b/adg/adg-pair.c @@ -34,9 +34,9 @@ adg_pair_get_type(void) static int pair_type = 0; if (G_UNLIKELY(pair_type == 0)) - pair_type = g_boxed_type_register_static("AdgPair", - (GBoxedCopyFunc) adg_pair_dup, - g_free); + pair_type = g_boxed_type_register_static("AdgPair", + (GBoxedCopyFunc) adg_pair_dup, + g_free); return pair_type; } diff --git a/adg/adg-pair.h b/adg/adg-pair.h index a36ed15d..142710be 100644 --- a/adg/adg-pair.h +++ b/adg/adg-pair.h @@ -33,8 +33,8 @@ G_BEGIN_DECLS typedef CpmlPair AdgPair; -GType adg_pair_get_type (void) G_GNUC_CONST; -AdgPair * adg_pair_dup (const AdgPair *pair); +GType adg_pair_get_type (void) G_GNUC_CONST; +AdgPair * adg_pair_dup (const AdgPair *pair); G_END_DECLS diff --git a/adg/adg-path-private.h b/adg/adg-path-private.h index 1c2ddbcd..9fb782eb 100644 --- a/adg/adg-path-private.h +++ b/adg/adg-path-private.h @@ -30,11 +30,11 @@ G_BEGIN_DECLS struct _AdgPathPrivate { - cairo_path_t cairo_path; - GArray *portions; - AdgPair cp; - AdgCallback create_func; - gpointer user_data; + cairo_path_t cairo_path; + GArray *portions; + AdgPair cp; + AdgCallback create_func; + gpointer user_data; }; G_END_DECLS diff --git a/adg/adg-path.c b/adg/adg-path.c index 69b68b56..045b085f 100644 --- a/adg/adg-path.c +++ b/adg/adg-path.c @@ -46,32 +46,32 @@ enum _Direction { }; -static void finalize (GObject *object); -static void render (AdgEntity *entity, - cairo_t *cr); -static void add_portion (AdgPath *path, - cairo_path_data_type_t type, - ...); +static void finalize (GObject *object); +static void render (AdgEntity *entity, + cairo_t *cr); +static void add_portion (AdgPath *path, + cairo_path_data_type_t type, + ...); /* Adapted from cairo-1.3.8 */ -static double arc_error_normalized (double angle); -static double arc_max_angle_for_tolerance_normalized - (double tolerance); -static int arc_segments_needed (double angle, - double radius, - double tolerance); -static void arc_segment (AdgPath *path, - double xc, - double yc, - double radius, - double angle_A, - double angle_B); -static void arc_in_direction (AdgPath *path, - double xc, - double yc, - double radius, - double angle_min, - double angle_max, - Direction dir); +static double arc_error_normalized (double angle); +static double arc_max_angle_for_tolerance_normalized + (double tolerance); +static int arc_segments_needed (double angle, + double radius, + double tolerance); +static void arc_segment (AdgPath *path, + double xc, + double yc, + double radius, + double angle_A, + double angle_B); +static void arc_in_direction (AdgPath *path, + double xc, + double yc, + double radius, + double angle_min, + double angle_max, + Direction dir); G_DEFINE_TYPE(AdgPath, adg_path, ADG_TYPE_ENTITY); @@ -97,7 +97,7 @@ static void adg_path_init(AdgPath *path) { AdgPathPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(path, ADG_TYPE_PATH, - AdgPathPrivate); + AdgPathPrivate); priv->cairo_path.status = CAIRO_STATUS_SUCCESS; priv->cairo_path.data = NULL; @@ -124,8 +124,8 @@ render(AdgEntity *entity, cairo_t *cr) AdgPath *path = (AdgPath *) entity; if (!adg_entity_model_applied(entity) - && path->priv->create_func != NULL) - path->priv->create_func(entity, path->priv->user_data); + && path->priv->create_func != NULL) + path->priv->create_func(entity, path->priv->user_data); adg_entity_apply(entity, ADG_SLOT_LINE_STYLE, cr); cairo_append_path(cr, &path->priv->cairo_path); @@ -142,52 +142,52 @@ add_portion(AdgPath *path, cairo_path_data_type_t type, ...) va_list var_args; if (!priv->portions) - priv->portions = g_array_sized_new(FALSE, FALSE, - sizeof(cairo_path_data_t), 10); + priv->portions = g_array_sized_new(FALSE, FALSE, + sizeof(cairo_path_data_t), 10); portion.header.type = type; va_start(var_args, type); switch (type) { case CAIRO_PATH_CLOSE_PATH: - portion.header.length = 1; - priv->portions = g_array_append_val(priv->portions, portion); - portion.point.x = 0.; - portion.point.y = 0.; - break; + portion.header.length = 1; + priv->portions = g_array_append_val(priv->portions, portion); + portion.point.x = 0.; + portion.point.y = 0.; + break; case CAIRO_PATH_MOVE_TO: - portion.header.length = 2; - priv->portions = g_array_append_val(priv->portions, portion); - portion.point.x = va_arg(var_args, double); - portion.point.y = va_arg(var_args, double); - priv->portions = g_array_append_val(priv->portions, portion); - break; + portion.header.length = 2; + priv->portions = g_array_append_val(priv->portions, portion); + portion.point.x = va_arg(var_args, double); + portion.point.y = va_arg(var_args, double); + priv->portions = g_array_append_val(priv->portions, portion); + break; case CAIRO_PATH_LINE_TO: - portion.header.length = 2; - priv->portions = g_array_append_val(priv->portions, portion); - portion.point.x = va_arg(var_args, double); - portion.point.y = va_arg(var_args, double); - priv->portions = g_array_append_val(priv->portions, portion); - break; + portion.header.length = 2; + priv->portions = g_array_append_val(priv->portions, portion); + portion.point.x = va_arg(var_args, double); + portion.point.y = va_arg(var_args, double); + priv->portions = g_array_append_val(priv->portions, portion); + break; case CAIRO_PATH_CURVE_TO: - portion.header.length = 4; - priv->portions = g_array_append_val(priv->portions, portion); - portion.point.x = va_arg(var_args, double); - portion.point.y = va_arg(var_args, double); - priv->portions = g_array_append_val(priv->portions, portion); - portion.point.x = va_arg(var_args, double); - portion.point.y = va_arg(var_args, double); - priv->portions = g_array_append_val(priv->portions, portion); - portion.point.x = va_arg(var_args, double); - portion.point.y = va_arg(var_args, double); - priv->portions = g_array_append_val(priv->portions, portion); - break; + portion.header.length = 4; + priv->portions = g_array_append_val(priv->portions, portion); + portion.point.x = va_arg(var_args, double); + portion.point.y = va_arg(var_args, double); + priv->portions = g_array_append_val(priv->portions, portion); + portion.point.x = va_arg(var_args, double); + portion.point.y = va_arg(var_args, double); + priv->portions = g_array_append_val(priv->portions, portion); + portion.point.x = va_arg(var_args, double); + portion.point.y = va_arg(var_args, double); + priv->portions = g_array_append_val(priv->portions, portion); + break; default: - g_assert_not_reached(); + g_assert_not_reached(); } priv->cairo_path.data = (cairo_path_data_t *) priv->portions->data; @@ -271,14 +271,14 @@ adg_path_chain_ymirror(AdgPath *path) g_return_if_fail(cairo_path->data->header.type == CAIRO_PATH_MOVE_TO); src = - g_memdup(cairo_path->data, - cairo_path->num_data * sizeof(cairo_path_data_t)); + g_memdup(cairo_path->data, + cairo_path->num_data * sizeof(cairo_path_data_t)); priv->portions = - g_array_set_size(priv->portions, cairo_path->num_data * 2); + g_array_set_size(priv->portions, cairo_path->num_data * 2); p_src = src; p_dst = - (cairo_path_data_t *) priv->portions->data + - cairo_path->num_data * 2; + (cairo_path_data_t *) priv->portions->data + + cairo_path->num_data * 2; n_data = 2; ++p_src; @@ -289,24 +289,24 @@ adg_path_chain_ymirror(AdgPath *path) ++p_src; while (n_data < cairo_path->num_data) { - length = p_src->header.length; - p_dst -= length; - p_dst->header.type = p_src->header.type; - p_dst->header.length = length; - ++p_src; - - for (n_point = 1; n_point < length - 1; ++n_point) { - p_dst[length - n_point - 1].point.x = p_src->point.x; - p_dst[length - n_point - 1].point.y = -p_src->point.y; - ++p_src; - } - - p_dst[length - 1].point.x = last_x; - p_dst[length - 1].point.y = -last_y; - last_x = p_src->point.x; - last_y = p_src->point.y; - ++p_src; - n_data += length; + length = p_src->header.length; + p_dst -= length; + p_dst->header.type = p_src->header.type; + p_dst->header.length = length; + ++p_src; + + for (n_point = 1; n_point < length - 1; ++n_point) { + p_dst[length - n_point - 1].point.x = p_src->point.x; + p_dst[length - n_point - 1].point.y = -p_src->point.y; + ++p_src; + } + + p_dst[length - 1].point.x = last_x; + p_dst[length - 1].point.y = -last_y; + last_x = p_src->point.x; + last_y = p_src->point.y; + ++p_src; + n_data += length; } p_dst -= 2; @@ -331,32 +331,32 @@ adg_path_dump(AdgPath *path) g_return_if_fail(ADG_IS_PATH(path)); for (n_data = 0; n_data < path->priv->cairo_path.num_data; ++n_data) { - data = path->priv->cairo_path.data + n_data; - - switch (data->header.type) { - case CAIRO_PATH_MOVE_TO: - g_print("Move to "); - break; - case CAIRO_PATH_LINE_TO: - g_print("Line to "); - break; - case CAIRO_PATH_CURVE_TO: - g_print("Curve to "); - break; - case CAIRO_PATH_CLOSE_PATH: - g_print("Path close"); - break; - default: - g_print("Unknown entity (%d)", data->header.type); - break; - } - - for (n_point = 1; n_point < data->header.length; ++n_point) - g_print("(%lf, %lf) ", data[n_point].point.x, - data[n_point].point.y); - - n_data += n_point - 1; - g_print("\n"); + data = path->priv->cairo_path.data + n_data; + + switch (data->header.type) { + case CAIRO_PATH_MOVE_TO: + g_print("Move to "); + break; + case CAIRO_PATH_LINE_TO: + g_print("Line to "); + break; + case CAIRO_PATH_CURVE_TO: + g_print("Curve to "); + break; + case CAIRO_PATH_CLOSE_PATH: + g_print("Path close"); + break; + default: + g_print("Unknown entity (%d)", data->header.type); + break; + } + + for (n_point = 1; n_point < data->header.length; ++n_point) + g_print("(%lf, %lf) ", data[n_point].point.x, + data[n_point].point.y); + + n_data += n_point - 1; + g_print("\n"); } } @@ -373,10 +373,10 @@ adg_path_get_current_point(AdgPath *path, double *x, double *y) priv = path->priv; if (x != NULL) - *x = priv->cp.x; + *x = priv->cp.x; if (y != NULL) - *y = priv->cp.y; + *y = priv->cp.y; return TRUE; } @@ -391,43 +391,43 @@ adg_path_close(AdgPath *path) void adg_path_arc(AdgPath *path, - double x, - double y, double radius, double angle1, double angle2) + double x, + double y, double radius, double angle1, double angle2) { g_return_if_fail(ADG_IS_PATH(path)); g_return_if_fail(radius > 0.0); while (angle2 < angle1) - angle2 += 2 * G_PI; + angle2 += 2 * G_PI; adg_path_line_to(path, x + radius * cos(angle1), - y + radius * sin(angle1)); + y + radius * sin(angle1)); arc_in_direction(path, x, y, radius, angle1, angle2, - DIRECTION_FORWARD); + DIRECTION_FORWARD); } void adg_path_arc_negative(AdgPath *path, - double x, - double y, - double radius, double angle1, double angle2) + double x, + double y, + double radius, double angle1, double angle2) { g_return_if_fail(ADG_IS_PATH(path)); g_return_if_fail(radius > 0.0); while (angle2 > angle1) - angle2 -= 2 * G_PI; + angle2 -= 2 * G_PI; adg_path_line_to(path, x + radius * cos(angle1), - y + radius * sin(angle1)); + y + radius * sin(angle1)); arc_in_direction(path, x, y, radius, angle2, angle1, - DIRECTION_REVERSE); + DIRECTION_REVERSE); } void adg_path_curve_to(AdgPath *path, - double x1, - double y1, double x2, double y2, double x3, double y3) + double x1, + double y1, double x2, double y2, double x3, double y3) { g_return_if_fail(ADG_IS_PATH(path)); @@ -452,7 +452,7 @@ adg_path_move_to(AdgPath *path, double x, double y) void adg_path_rectangle(AdgPath *path, - double x, double y, double width, double height) + double x, double y, double width, double height) { g_return_if_fail(ADG_IS_PATH(path)); @@ -465,9 +465,9 @@ adg_path_rectangle(AdgPath *path, void adg_path_rel_curve_to(AdgPath *path, - double dx1, - double dy1, - double dx2, double dy2, double dx3, double dy3) + double dx1, + double dy1, + double dx2, double dy2, double dx3, double dy3) { double x, y; @@ -475,7 +475,7 @@ adg_path_rel_curve_to(AdgPath *path, g_return_if_fail(adg_path_get_current_point(path, &x, &y)); adg_path_curve_to(path, x + dx1, y + dy1, x + dx2, y + dy2, x + dx3, - y + dy3); + y + dy3); } void @@ -517,31 +517,31 @@ arc_max_angle_for_tolerance_normalized(double tolerance) /* Use table lookup to reduce search time in most cases. */ struct { - double angle; - double error; + double angle; + double error; } table[] = { - { - M_PI / 1.0, 0.0185185185185185036127}, { - M_PI / 2.0, 0.000272567143730179811158}, { - M_PI / 3.0, 2.38647043651461047433e-05}, { - M_PI / 4.0, 4.2455377443222443279e-06}, { - M_PI / 5.0, 1.11281001494389081528e-06}, { - M_PI / 6.0, 3.72662000942734705475e-07}, { - M_PI / 7.0, 1.47783685574284411325e-07}, { - M_PI / 8.0, 6.63240432022601149057e-08}, { - M_PI / 9.0, 3.2715520137536980553e-08}, { - M_PI / 10.0, 1.73863223499021216974e-08}, { + { + M_PI / 1.0, 0.0185185185185185036127}, { + M_PI / 2.0, 0.000272567143730179811158}, { + M_PI / 3.0, 2.38647043651461047433e-05}, { + M_PI / 4.0, 4.2455377443222443279e-06}, { + M_PI / 5.0, 1.11281001494389081528e-06}, { + M_PI / 6.0, 3.72662000942734705475e-07}, { + M_PI / 7.0, 1.47783685574284411325e-07}, { + M_PI / 8.0, 6.63240432022601149057e-08}, { + M_PI / 9.0, 3.2715520137536980553e-08}, { + M_PI / 10.0, 1.73863223499021216974e-08}, { M_PI / 11.0, 9.81410988043554039085e-09},}; int table_size = (sizeof(table) / sizeof(table[0])); for (i = 0; i < table_size; i++) - if (table[i].error < tolerance) - return table[i].angle; + if (table[i].error < tolerance) + return table[i].angle; ++i; do { - angle = M_PI / i++; - error = arc_error_normalized(angle); + angle = M_PI / i++; + error = arc_error_normalized(angle); } while (error > tolerance); @@ -565,8 +565,8 @@ arc_segments_needed(double angle, double radius, double tolerance) static void arc_segment(AdgPath *path, - double xc, - double yc, double radius, double angle_A, double angle_B) + double xc, + double yc, double radius, double angle_A, double angle_B) { double r_sin_A, r_cos_A; double r_sin_B, r_cos_B; @@ -580,61 +580,61 @@ arc_segment(AdgPath *path, h = 4.0 / 3.0 * tan((angle_B - angle_A) / 4.0); adg_path_curve_to(path, - xc + r_cos_A - h * r_sin_A, - yc + r_sin_A + h * r_cos_A, - xc + r_cos_B + h * r_sin_B, - yc + r_sin_B - h * r_cos_B, - xc + r_cos_B, yc + r_sin_B); + xc + r_cos_A - h * r_sin_A, + yc + r_sin_A + h * r_cos_A, + xc + r_cos_B + h * r_sin_B, + yc + r_sin_B - h * r_cos_B, + xc + r_cos_B, yc + r_sin_B); } static void arc_in_direction(AdgPath *path, - double xc, - double yc, - double radius, - double angle_min, double angle_max, Direction dir) + double xc, + double yc, + double radius, + double angle_min, double angle_max, Direction dir) { while (angle_max - angle_min > 4 * M_PI) - angle_max -= 2 * M_PI; + angle_max -= 2 * M_PI; /* Recurse if drawing arc larger than pi */ if (angle_max - angle_min > M_PI) { - double angle_mid = angle_min + (angle_max - angle_min) / 2.0; - /* XXX: Something tells me this block could be condensed. */ - if (dir == DIRECTION_FORWARD) { - arc_in_direction(path, xc, yc, radius, - angle_min, angle_mid, dir); - - arc_in_direction(path, xc, yc, radius, - angle_mid, angle_max, dir); - } else { - arc_in_direction(path, xc, yc, radius, - angle_mid, angle_max, dir); - - arc_in_direction(path, xc, yc, radius, - angle_min, angle_mid, dir); - } + double angle_mid = angle_min + (angle_max - angle_min) / 2.0; + /* XXX: Something tells me this block could be condensed. */ + if (dir == DIRECTION_FORWARD) { + arc_in_direction(path, xc, yc, radius, + angle_min, angle_mid, dir); + + arc_in_direction(path, xc, yc, radius, + angle_mid, angle_max, dir); + } else { + arc_in_direction(path, xc, yc, radius, + angle_mid, angle_max, dir); + + arc_in_direction(path, xc, yc, radius, + angle_min, angle_mid, dir); + } } else { - int i, segments; - double angle, angle_step; - - /* XXX: 22-12-2006 Fontana Nicola - * Used the ARC_TOLERANCE constant instead of the cairo context - * dependent variable, because I do not have any cairo context here. - */ - segments = - arc_segments_needed(angle_max - angle_min, radius, - ARC_TOLERANCE); - angle_step = (angle_max - angle_min) / (double) segments; - - if (dir == DIRECTION_FORWARD) { - angle = angle_min; - } else { - angle = angle_max; - angle_step = -angle_step; - } - - for (i = 0; i < segments; i++, angle += angle_step) - arc_segment(path, xc, yc, radius, angle, angle + angle_step); + int i, segments; + double angle, angle_step; + + /* XXX: 22-12-2006 Fontana Nicola + * Used the ARC_TOLERANCE constant instead of the cairo context + * dependent variable, because I do not have any cairo context here. + */ + segments = + arc_segments_needed(angle_max - angle_min, radius, + ARC_TOLERANCE); + angle_step = (angle_max - angle_min) / (double) segments; + + if (dir == DIRECTION_FORWARD) { + angle = angle_min; + } else { + angle = angle_max; + angle_step = -angle_step; + } + + for (i = 0; i < segments; i++, angle += angle_step) + arc_segment(path, xc, yc, radius, angle, angle + angle_step); } } diff --git a/adg/adg-path.h b/adg/adg-path.h index 9f0c1f82..d88ff651 100644 --- a/adg/adg-path.h +++ b/adg/adg-path.h @@ -38,13 +38,13 @@ typedef struct _AdgPathClass AdgPathClass; typedef struct _AdgPathPrivate AdgPathPrivate; struct _AdgPath { - AdgEntity entity; + AdgEntity entity; /*< private >*/ - AdgPathPrivate *priv; + AdgPathPrivate *priv; }; struct _AdgPathClass { - AdgEntityClass parent_class; + AdgEntityClass parent_class; }; diff --git a/adg/adg-pattern.c b/adg/adg-pattern.c index a625962a..f0a34ad6 100644 --- a/adg/adg-pattern.c +++ b/adg/adg-pattern.c @@ -35,9 +35,9 @@ adg_pattern_get_type(void) static int pattern_type = 0; if (G_UNLIKELY(pattern_type == 0)) - pattern_type = g_boxed_type_register_static("AdgPattern", - (GBoxedCopyFunc) cairo_pattern_reference, - (GBoxedFreeFunc) cairo_pattern_destroy); + pattern_type = g_boxed_type_register_static("AdgPattern", + (GBoxedCopyFunc) cairo_pattern_reference, + (GBoxedFreeFunc) cairo_pattern_destroy); return pattern_type; } diff --git a/adg/adg-pattern.h b/adg/adg-pattern.h index 952aa58a..fa968c26 100644 --- a/adg/adg-pattern.h +++ b/adg/adg-pattern.h @@ -33,7 +33,7 @@ G_BEGIN_DECLS typedef cairo_pattern_t AdgPattern; -GType adg_pattern_get_type (void) G_GNUC_CONST; +GType adg_pattern_get_type (void) G_GNUC_CONST; G_END_DECLS diff --git a/adg/adg-style-private.h b/adg/adg-style-private.h index 39ec3289..d3d7711b 100644 --- a/adg/adg-style-private.h +++ b/adg/adg-style-private.h @@ -25,7 +25,7 @@ G_BEGIN_DECLS struct _AdgStylePrivate { - AdgPattern *pattern; + AdgPattern *pattern; }; G_END_DECLS diff --git a/adg/adg-style.c b/adg/adg-style.c index 9eb39ed5..0a41b3ee 100644 --- a/adg/adg-style.c +++ b/adg/adg-style.c @@ -46,19 +46,19 @@ enum { }; -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static GPtrArray * get_pool (void); -static void apply (AdgStyle *style, - cairo_t *cr); -static void set_pattern (AdgStyle *style, - AdgPattern *pattern); +static void get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); +static void set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static GPtrArray * get_pool (void); +static void apply (AdgStyle *style, + cairo_t *cr); +static void set_pattern (AdgStyle *style, + AdgPattern *pattern); G_DEFINE_ABSTRACT_TYPE(AdgStyle, adg_style, G_TYPE_OBJECT) @@ -81,9 +81,9 @@ adg_style_class_init(AdgStyleClass *klass) klass->apply = apply; param = g_param_spec_boxed("pattern", - P_("Pattern"), - P_("The pattern associated to this style"), - ADG_TYPE_PATTERN, G_PARAM_READWRITE); + P_("Pattern"), + P_("The pattern associated to this style"), + ADG_TYPE_PATTERN, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_PATTERN, param); } @@ -91,8 +91,8 @@ static void adg_style_init(AdgStyle *style) { AdgStylePrivate *priv = - G_TYPE_INSTANCE_GET_PRIVATE(style, ADG_TYPE_STYLE, - AdgStylePrivate); + G_TYPE_INSTANCE_GET_PRIVATE(style, ADG_TYPE_STYLE, + AdgStylePrivate); priv->pattern = NULL; @@ -101,33 +101,33 @@ adg_style_init(AdgStyle *style) static void get_property(GObject *object, - guint prop_id, GValue *value, GParamSpec *pspec) + guint prop_id, GValue *value, GParamSpec *pspec) { AdgStyle *style = (AdgStyle *) object; switch (prop_id) { case PROP_PATTERN: - g_value_set_boxed(value, style->priv->pattern); - break; + g_value_set_boxed(value, style->priv->pattern); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } static void set_property(GObject *object, - guint prop_id, const GValue *value, GParamSpec *pspec) + guint prop_id, const GValue *value, GParamSpec *pspec) { AdgStyle *style = (AdgStyle *) object; switch (prop_id) { case PROP_PATTERN: - set_pattern(style, g_value_get_boxed(value)); - break; + set_pattern(style, g_value_get_boxed(value)); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; } } @@ -178,7 +178,7 @@ adg_style_from_id(GType type, AdgStyleId id) g_type_class_unref(klass); if (id > pool->len) - return NULL; + return NULL; return (AdgStyle *) g_ptr_array_index(pool, id); } @@ -262,17 +262,17 @@ static void apply(AdgStyle *style, cairo_t *cr) { if (style->priv->pattern != NULL) - cairo_set_source(cr, style->priv->pattern); + cairo_set_source(cr, style->priv->pattern); } static void set_pattern(AdgStyle *style, AdgPattern *pattern) { if (style->priv->pattern != NULL) - cairo_pattern_destroy(style->priv->pattern); + cairo_pattern_destroy(style->priv->pattern); if (pattern != NULL) - cairo_pattern_reference(pattern); + cairo_pattern_reference(pattern); style->priv->pattern = pattern; } diff --git a/adg/adg-style.h b/adg/adg-style.h index 50951a65..0e1b5b3e 100644 --- a/adg/adg-style.h +++ b/adg/adg-style.h @@ -41,30 +41,30 @@ typedef gint AdgStyleId; typedef gint AdgStyleSlot; struct _AdgStyle { - GObject object; + GObject object; /*< private >*/ - AdgStylePrivate *priv; + AdgStylePrivate *priv; }; struct _AdgStyleClass { - GObjectClass parent_class; + GObjectClass parent_class; /* Virtual table */ - GPtrArray * (*get_pool) (void); - void (*apply) (AdgStyle *style, - cairo_t *cr); + GPtrArray * (*get_pool) (void); + void (*apply) (AdgStyle *style, + cairo_t *cr); }; -GType adg_style_get_type (void) G_GNUC_CONST; -AdgStyleId adg_style_register_id (AdgStyle *style); -AdgStyle * adg_style_from_id (GType type, - AdgStyleId id); -AdgStyle * adg_style_get_default (AdgStyleClass *klass); - -void adg_style_apply (AdgStyle *style, - cairo_t *cr); -const AdgPattern * adg_style_get_pattern (AdgStyle *style); -void adg_style_set_pattern (AdgStyle *style, - AdgPattern *pattern); +GType adg_style_get_type (void) G_GNUC_CONST; +AdgStyleId adg_style_register_id (AdgStyle *style); +AdgStyle * adg_style_from_id (GType type, + AdgStyleId id); +AdgStyle * adg_style_get_default (AdgStyleClass *klass); + +void adg_style_apply (AdgStyle *style, + cairo_t *cr); +const AdgPattern * adg_style_get_pattern (AdgStyle *style); +void adg_style_set_pattern (AdgStyle *style, + AdgPattern *pattern); G_END_DECLS diff --git a/adg/adg-util.h b/adg/adg-util.h index cf428151..372d3e70 100644 --- a/adg/adg-util.h +++ b/adg/adg-util.h @@ -25,9 +25,9 @@ #include #include -#define ADG_ISSET(flags,mask) (((flags) & (mask)) != 0 ? TRUE : FALSE) -#define ADG_SET(flags,mask) G_STMT_START{ (flags) |= (mask); }G_STMT_END -#define ADG_UNSET(flags,mask) G_STMT_START{ (flags) &= ~(mask); }G_STMT_END +#define ADG_ISSET(flags,mask) (((flags) & (mask)) != 0 ? TRUE : FALSE) +#define ADG_SET(flags,mask) G_STMT_START{ (flags) |= (mask); }G_STMT_END +#define ADG_UNSET(flags,mask) G_STMT_START{ (flags) &= ~(mask); }G_STMT_END #define ADG_CHECKPOINT_WITH_MESSAGE(message) \ diff --git a/cpml/cpml-pair.c b/cpml/cpml-pair.c index d0ee5169..5dc8b06a 100644 --- a/cpml/cpml-pair.c +++ b/cpml/cpml-pair.c @@ -90,10 +90,10 @@ cpml_pair_copy(CpmlPair *pair, const CpmlPair *src) */ cairo_bool_t cpml_pair_distance(const CpmlPair *from, const CpmlPair *to, - double *distance) + double *distance) { if (!cpml_pair_square_distance(from, to, distance)) - return 0; + return 0; *distance = sqrt(*distance); return 1; @@ -116,14 +116,14 @@ cpml_pair_distance(const CpmlPair *from, const CpmlPair *to, */ cairo_bool_t cpml_pair_square_distance(const CpmlPair *from, const CpmlPair *to, - double *distance) + double *distance) { double x, y; if (from == NULL) - from = &fallback_pair; + from = &fallback_pair; if (to == NULL) - to = &fallback_pair; + to = &fallback_pair; x = to->x - from->x; y = to->y - from->y; @@ -152,35 +152,35 @@ cpml_pair_angle(const CpmlPair *from, const CpmlPair *to, double *angle) CpmlPair pair; if (from == NULL) - from = &fallback_pair; + from = &fallback_pair; if (to == NULL) - to = &fallback_pair; + to = &fallback_pair; pair.x = to->x - from->x; pair.y = to->y - from->y; /* Check for cached result */ if (pair.x == cached_pair.x && pair.y == cached_pair.y) { - *angle = cached_angle; + *angle = cached_angle; } else if (pair.y == 0.) { - *angle = pair.x >= 0. ? CPML_DIR_RIGHT : CPML_DIR_LEFT; + *angle = pair.x >= 0. ? CPML_DIR_RIGHT : CPML_DIR_LEFT; } else if (pair.x == 0.) { - *angle = pair.y > 0. ? CPML_DIR_UP : CPML_DIR_DOWN; + *angle = pair.y > 0. ? CPML_DIR_UP : CPML_DIR_DOWN; } else if (pair.x == pair.y) { - *angle = pair.x > 0. ? M_PI / 4. : 5. * M_PI / 4.; + *angle = pair.x > 0. ? M_PI / 4. : 5. * M_PI / 4.; } else if (pair.x == -pair.y) { - *angle = pair.x > 0. ? 7. * M_PI / 4. : 3. * M_PI / 4.; + *angle = pair.x > 0. ? 7. * M_PI / 4. : 3. * M_PI / 4.; } else { - *angle = atan(pair.y / pair.x); + *angle = atan(pair.y / pair.x); - if (pair.x < 0.0) - *angle += M_PI; - else if (pair.y < 0.0) - *angle += 2.0 * M_PI; + if (pair.x < 0.0) + *angle += M_PI; + else if (pair.y < 0.0) + *angle += 2.0 * M_PI; - /* Cache registration */ - cached_angle = *angle; - cpml_pair_copy(&cached_pair, &pair); + /* Cache registration */ + cached_angle = *angle; + cpml_pair_copy(&cached_pair, &pair); } return 1; @@ -205,7 +205,7 @@ cpml_vector_from_pair(CpmlPair *vector, const CpmlPair *pair) double length; if (!cpml_pair_distance(pair, NULL, &length) || length == 0.) - return 0; + return 0; vector->x = pair->x / length; vector->y = pair->y / length; @@ -230,27 +230,27 @@ cpml_vector_from_angle(CpmlPair *vector, double angle) /* Check for cached result */ if (angle == cached_angle) { - vector->x = cached_vector.x; - vector->y = cached_vector.y; + vector->x = cached_vector.x; + vector->y = cached_vector.y; } else if (angle == CPML_DIR_RIGHT) { - vector->x = +1.; - vector->y = 0.; + vector->x = +1.; + vector->y = 0.; } else if (angle == CPML_DIR_UP) { - vector->x = 0.; - vector->y = -1.; + vector->x = 0.; + vector->y = -1.; } else if (angle == CPML_DIR_LEFT) { - vector->x = -1.; - vector->y = 0.; + vector->x = -1.; + vector->y = 0.; } else if (angle == CPML_DIR_DOWN) { - vector->x = 0.; - vector->y = +1.; + vector->x = 0.; + vector->y = +1.; } else { - vector->x = cos(angle); - vector->y = sin(angle); + vector->x = cos(angle); + vector->y = sin(angle); - /* Cache registration */ - cached_angle = angle; - cpml_pair_copy(&cached_vector, vector); + /* Cache registration */ + cached_angle = angle; + cpml_pair_copy(&cached_vector, vector); } return 1; diff --git a/cpml/cpml-pair.h b/cpml/cpml-pair.h index 08623679..84400f0d 100644 --- a/cpml/cpml-pair.h +++ b/cpml/cpml-pair.h @@ -32,28 +32,28 @@ CAIRO_BEGIN_DECLS -typedef struct _CpmlPair CpmlPair; +typedef struct _CpmlPair CpmlPair; struct _CpmlPair { - double x, y; + double x, y; }; -cairo_bool_t cpml_pair_copy (CpmlPair *pair, - const CpmlPair *src); -cairo_bool_t cpml_pair_distance (const CpmlPair *from, - const CpmlPair *to, - double *distance); -cairo_bool_t cpml_pair_square_distance (const CpmlPair *from, - const CpmlPair *to, - double *distance); -cairo_bool_t cpml_pair_angle (const CpmlPair *from, - const CpmlPair *to, - double *angle); -cairo_bool_t cpml_vector_from_pair (CpmlPair *vector, - const CpmlPair *pair); -cairo_bool_t cpml_vector_from_angle (CpmlPair *vector, - double angle); +cairo_bool_t cpml_pair_copy (CpmlPair *pair, + const CpmlPair *src); +cairo_bool_t cpml_pair_distance (const CpmlPair *from, + const CpmlPair *to, + double *distance); +cairo_bool_t cpml_pair_square_distance (const CpmlPair *from, + const CpmlPair *to, + double *distance); +cairo_bool_t cpml_pair_angle (const CpmlPair *from, + const CpmlPair *to, + double *angle); +cairo_bool_t cpml_vector_from_pair (CpmlPair *vector, + const CpmlPair *pair); +cairo_bool_t cpml_vector_from_angle (CpmlPair *vector, + double angle); CAIRO_END_DECLS diff --git a/cpml/cpml-path.c b/cpml/cpml-path.c index fed5649e..f351626c 100644 --- a/cpml/cpml-path.c +++ b/cpml/cpml-path.c @@ -22,11 +22,11 @@ #include -static cairo_bool_t strip_leadings (CpmlPath *path); -static cairo_bool_t path_to_segment (CpmlPath *segment, - const CpmlPath *path); -static cairo_bool_t path_to_primitive (CpmlPath *primitive, - const CpmlPath *path); +static cairo_bool_t strip_leadings (CpmlPath *path); +static cairo_bool_t path_to_segment (CpmlPath *segment, + const CpmlPath *path); +static cairo_bool_t path_to_primitive (CpmlPath *primitive, + const CpmlPath *path); /** * cpml_path_from_cairo: @@ -50,7 +50,7 @@ cpml_path_from_cairo(CpmlPath *path, const cairo_path_t *src, cairo_t *cr) CpmlPair org = { 0., 0. }; if (cr && cairo_has_current_point(cr)) - cairo_get_current_point(cr, &org.x, &org.y); + cairo_get_current_point(cr, &org.x, &org.y); return cpml_path_from_cairo_explicit(path, src, &org); } @@ -72,22 +72,22 @@ cpml_path_from_cairo(CpmlPath *path, const cairo_path_t *src, cairo_t *cr) */ cairo_bool_t cpml_path_from_cairo_explicit(CpmlPath *path, const cairo_path_t *src, - const CpmlPair *org) + const CpmlPair *org) { if (src->status != CAIRO_STATUS_SUCCESS) - return 0; + return 0; if (path != (CpmlPath *) src) - memcpy(path, src, sizeof(cairo_path_t)); + memcpy(path, src, sizeof(cairo_path_t)); if (strip_leadings(path)) { - /* org taken from leadings MOVE_TO */ + /* org taken from leadings MOVE_TO */ } else if (path->cairo_path.status != CAIRO_STATUS_SUCCESS) { - /* Error: probably an empty path provided */ - return 0; + /* Error: probably an empty path provided */ + return 0; } else if (org) { - /* Use the provided org */ - cpml_pair_copy(&path->org, org); + /* Use the provided org */ + cpml_pair_copy(&path->org, org); } return 1; @@ -106,7 +106,7 @@ cpml_path_from_cairo_explicit(CpmlPath *path, const cairo_path_t *src, CpmlPath *cpml_path_copy(CpmlPath *path, const CpmlPath *src) { if (path == NULL || src == NULL) - return NULL; + return NULL; return memcpy(path, src, sizeof(CpmlPath)); } @@ -129,22 +129,22 @@ cpml_segment_from_path(CpmlPath *segment, const CpmlPath *path, int index) int i; if (!cpml_path_copy(&residue, path)) - return 0; + return 0; i = 0; do { - if (!path_to_segment(&result, &residue)) - return index == CPML_LAST && i > 0; + if (!path_to_segment(&result, &residue)) + return index == CPML_LAST && i > 0; - residue.cairo_path.data += result.cairo_path.num_data; - residue.cairo_path.num_data -= result.cairo_path.num_data; - ++i; + residue.cairo_path.data += result.cairo_path.num_data; + residue.cairo_path.num_data -= result.cairo_path.num_data; + ++i; - if (index == CPML_LAST) { - cpml_path_copy(segment, &result); - continue; - } + if (index == CPML_LAST) { + cpml_path_copy(segment, &result); + continue; + } } while (i < index); cpml_path_copy(segment, &result); @@ -169,22 +169,22 @@ cpml_primitive_from_path(CpmlPath *primitive, const CpmlPath *path, int index) int i; if (!cpml_path_copy(&residue, path)) - return 0; + return 0; i = 0; do { - if (!path_to_primitive(&result, &residue)) - return index == CPML_LAST && i > 0; + if (!path_to_primitive(&result, &residue)) + return index == CPML_LAST && i > 0; - residue.cairo_path.data += result.cairo_path.num_data; - residue.cairo_path.num_data -= result.cairo_path.num_data; - ++i; + residue.cairo_path.data += result.cairo_path.num_data; + residue.cairo_path.num_data -= result.cairo_path.num_data; + ++i; - if (index == CPML_LAST) { - cpml_path_copy(primitive, &result); - continue; - } + if (index == CPML_LAST) { + cpml_path_copy(primitive, &result); + continue; + } } while (i < index); cpml_path_copy(primitive, &result); @@ -207,7 +207,7 @@ cpml_primitive_get_pair(const CpmlPath *primitive, CpmlPair *pair, int index) cairo_path_data_t *data = primitive->cairo_path.data; if (index == 0 || index > data[0].header.length) - return 0; + return 0; pair->x = data[index].point.x; pair->y = data[index].point.y; @@ -230,7 +230,7 @@ cpml_primitive_set_pair(CpmlPath *primitive, const CpmlPair *pair, int index) cairo_path_data_t *data = primitive->cairo_path.data; if (index == 0 || index > data[0].header.length) - return 0; + return 0; data[index].point.x = pair->x; data[index].point.y = pair->y; @@ -253,15 +253,15 @@ cpml_primitive_get_point(const CpmlPath *primitive, CpmlPair *point, double pos) int type = primitive->cairo_path.data[0].header.type; if (type != CAIRO_PATH_CLOSE_PATH && type != CAIRO_PATH_LINE_TO && - type != CAIRO_PATH_CURVE_TO) - return 0; + type != CAIRO_PATH_CURVE_TO) + return 0; /* Common cases */ if (type == CAIRO_PATH_CLOSE_PATH || pos == 0.) { - return cpml_pair_copy(point, &primitive->org); + return cpml_pair_copy(point, &primitive->org); } else if (pos == 1.0) { - int n = type == CAIRO_PATH_LINE_TO ? 1 : 3; - return cpml_primitive_get_pair(primitive, point, n); + int n = type == CAIRO_PATH_LINE_TO ? 1 : 3; + return cpml_primitive_get_pair(primitive, point, n); } /* TODO */ @@ -282,24 +282,24 @@ cairo_bool_t cpml_primitive_reverse(CpmlPath *primitive) switch (primitive->cairo_path.data[0].header.type) { case CAIRO_PATH_LINE_TO: - cpml_pair_copy(&tmp, &primitive->org); - cpml_primitive_get_pair(primitive, &primitive->org, 1); - cpml_primitive_set_pair(primitive, &tmp, 1); - break; + cpml_pair_copy(&tmp, &primitive->org); + cpml_primitive_get_pair(primitive, &primitive->org, 1); + cpml_primitive_set_pair(primitive, &tmp, 1); + break; case CAIRO_PATH_CURVE_TO: - cpml_pair_copy(&tmp, &primitive->org); - cpml_primitive_get_pair(primitive, &primitive->org, 3); - cpml_primitive_set_pair(primitive, &tmp, 3); - - cpml_primitive_get_pair(primitive, &tmp, 2); - primitive->cairo_path.data[2].point.x = - primitive->cairo_path.data[3].point.x; - primitive->cairo_path.data[2].point.y = - primitive->cairo_path.data[3].point.y; - cpml_primitive_set_pair(primitive, &tmp, 3); - break; + cpml_pair_copy(&tmp, &primitive->org); + cpml_primitive_get_pair(primitive, &primitive->org, 3); + cpml_primitive_set_pair(primitive, &tmp, 3); + + cpml_primitive_get_pair(primitive, &tmp, 2); + primitive->cairo_path.data[2].point.x = + primitive->cairo_path.data[3].point.x; + primitive->cairo_path.data[2].point.y = + primitive->cairo_path.data[3].point.y; + cpml_primitive_set_pair(primitive, &tmp, 3); + break; default: - return 0; + return 0; } return 1; @@ -318,18 +318,18 @@ cairo_bool_t cpml_primitive_reverse(CpmlPath *primitive) static cairo_bool_t strip_leadings(CpmlPath *path) { if (path->cairo_path.data[0].header.type != CAIRO_PATH_MOVE_TO) - return 0; + return 0; do { - ++path->cairo_path.data; - path->org.x = path->cairo_path.data->point.x; - path->org.y = path->cairo_path.data->point.y; - ++path->cairo_path.data; - path->cairo_path.num_data -= 2; - if (path->cairo_path.num_data <= 0) { - path->cairo_path.status = CAIRO_STATUS_INVALID_PATH_DATA; - return 0; - } + ++path->cairo_path.data; + path->org.x = path->cairo_path.data->point.x; + path->org.y = path->cairo_path.data->point.y; + ++path->cairo_path.data; + path->cairo_path.num_data -= 2; + if (path->cairo_path.num_data <= 0) { + path->cairo_path.status = CAIRO_STATUS_INVALID_PATH_DATA; + return 0; + } } while (path->cairo_path.data->header.type == CAIRO_PATH_MOVE_TO); return 1; @@ -351,24 +351,24 @@ path_to_segment(CpmlPath *segment, const CpmlPath *path) int i; if (segment != path) - cpml_path_copy(segment, path); + cpml_path_copy(segment, path); if (!strip_leadings(segment) && - segment->cairo_path.status != CAIRO_STATUS_SUCCESS) - return 0; + segment->cairo_path.status != CAIRO_STATUS_SUCCESS) + return 0; path_data = segment->cairo_path.data; i = 0; do { - if (path_data->header.type == CAIRO_PATH_MOVE_TO) { - --i; - break; - } else if (path_data->header.type == CAIRO_PATH_CLOSE_PATH) { - break; - } - i += path_data->header.length; - path_data += path_data->header.length; + if (path_data->header.type == CAIRO_PATH_MOVE_TO) { + --i; + break; + } else if (path_data->header.type == CAIRO_PATH_CLOSE_PATH) { + break; + } + i += path_data->header.length; + path_data += path_data->header.length; } while (i < segment->cairo_path.num_data); segment->cairo_path.num_data = i; @@ -390,11 +390,11 @@ path_to_primitive(CpmlPath *primitive, const CpmlPath *path) cairo_path_data_t *path_data; if (primitive != path) - cpml_path_copy(primitive, path); + cpml_path_copy(primitive, path); if (!strip_leadings(primitive) && - primitive->cairo_path.status != CAIRO_STATUS_SUCCESS) - return 0; + primitive->cairo_path.status != CAIRO_STATUS_SUCCESS) + return 0; primitive->cairo_path.num_data = 1; return 1; diff --git a/cpml/cpml-path.h b/cpml/cpml-path.h index 8d88ec2c..c55f49dc 100644 --- a/cpml/cpml-path.h +++ b/cpml/cpml-path.h @@ -22,8 +22,8 @@ #include -#define CPML_LAST 0 -#define CPML_FIRST 1 +#define CPML_LAST 0 +#define CPML_FIRST 1 CAIRO_BEGIN_DECLS @@ -32,33 +32,33 @@ CAIRO_BEGIN_DECLS typedef struct _CpmlPath CpmlPath; struct _CpmlPath { - cairo_path_t cairo_path; - CpmlPair org; + cairo_path_t cairo_path; + CpmlPair org; }; -cairo_bool_t cpml_path_from_cairo (CpmlPath *path, - const cairo_path_t *src, - cairo_t *cr); -cairo_bool_t cpml_path_from_cairo_explicit (CpmlPath *path, - const cairo_path_t *src, - const CpmlPair *org); -CpmlPath * cpml_path_copy (CpmlPath *path, - const CpmlPath *src); -cairo_bool_t cpml_segment_from_path (CpmlPath *segment, - const CpmlPath *path, - int index); -cairo_bool_t cpml_primitive_from_path (CpmlPath *primitive, - const CpmlPath *path, - int index); -cairo_bool_t cpml_primitive_get_pair (const CpmlPath *primitive, - CpmlPair *pair, int index); -cairo_bool_t cpml_primitive_set_pair (CpmlPath *primitive, - const CpmlPair *pair, - int index); -cairo_bool_t cpml_primitive_get_point (const CpmlPath *primitive, - CpmlPair *point, double pos); -cairo_bool_t cpml_primitive_reverse (CpmlPath *primitive); +cairo_bool_t cpml_path_from_cairo (CpmlPath *path, + const cairo_path_t *src, + cairo_t *cr); +cairo_bool_t cpml_path_from_cairo_explicit (CpmlPath *path, + const cairo_path_t *src, + const CpmlPair *org); +CpmlPath * cpml_path_copy (CpmlPath *path, + const CpmlPath *src); +cairo_bool_t cpml_segment_from_path (CpmlPath *segment, + const CpmlPath *path, + int index); +cairo_bool_t cpml_primitive_from_path (CpmlPath *primitive, + const CpmlPath *path, + int index); +cairo_bool_t cpml_primitive_get_pair (const CpmlPath *primitive, + CpmlPair *pair, int index); +cairo_bool_t cpml_primitive_set_pair (CpmlPath *primitive, + const CpmlPair *pair, + int index); +cairo_bool_t cpml_primitive_get_point (const CpmlPath *primitive, + CpmlPair *point, double pos); +cairo_bool_t cpml_primitive_reverse (CpmlPath *primitive); CAIRO_END_DECLS diff --git a/demo/adg-demo.c b/demo/adg-demo.c index 574e51e8..e7f7d08e 100644 --- a/demo/adg-demo.c +++ b/demo/adg-demo.c @@ -78,7 +78,7 @@ main(gint argc, gchar **argv) widget = gtk_button_new_from_stock(GTK_STOCK_PRINT); g_signal_connect_swapped(widget, "clicked", G_CALLBACK(piston_to_ps), - canvas); + canvas); gtk_container_add(GTK_CONTAINER(button_box), widget); widget = gtk_button_new_from_stock(GTK_STOCK_QUIT); @@ -155,16 +155,16 @@ static void add_piston_dimensions(AdgCanvas *canvas, Piston *piston) /* LD2 */ entity = - adg_ldim_new_full_explicit(A - B - LD2, -D1 / 2.0, A - B, - -D3 / 2.0 + CHAMFER, CPML_DIR_UP, 0.0, - -D3 / 2.0); + adg_ldim_new_full_explicit(A - B - LD2, -D1 / 2.0, A - B, + -D3 / 2.0 + CHAMFER, CPML_DIR_UP, 0.0, + -D3 / 2.0); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); /* LD3 */ entity = - adg_ldim_new_full_explicit(A - B, -D3 / 2.0 + CHAMFER, A - B + LD3, - -D3 / 2.0 + CHAMFER, CPML_DIR_UP, 0.0, - -D3 / 2.0); + adg_ldim_new_full_explicit(A - B, -D3 / 2.0 + CHAMFER, A - B + LD3, + -D3 / 2.0 + CHAMFER, CPML_DIR_UP, 0.0, + -D3 / 2.0); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); @@ -172,15 +172,15 @@ static void add_piston_dimensions(AdgCanvas *canvas, Piston *piston) /* B */ entity = - adg_ldim_new_full_explicit(A - B, D3 / 2.0 - CHAMFER, A, D7 / 2.0, - CPML_DIR_DOWN, 0.0, D3 / 2.0); + adg_ldim_new_full_explicit(A - B, D3 / 2.0 - CHAMFER, A, D7 / 2.0, + CPML_DIR_DOWN, 0.0, D3 / 2.0); adg_dim_set_tolerances(ADG_DIM(entity), "+0.1", NULL); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); /* A */ entity = - adg_ldim_new_full_explicit(0.0, D1 / 2.0, A, D7 / 2.0, - CPML_DIR_DOWN, 0.0, D3 / 2.0); + adg_ldim_new_full_explicit(0.0, D1 / 2.0, A, D7 / 2.0, + CPML_DIR_DOWN, 0.0, D3 / 2.0); adg_dim_set_tolerances(ADG_DIM(entity), "+0.05", "-0.05"); adg_dim_set_level(ADG_DIM(entity), 2.0); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); @@ -191,8 +191,8 @@ static void add_piston_dimensions(AdgCanvas *canvas, Piston *piston) /* D3 */ x = A - B + LD3 - CHAMFER; entity = - adg_ldim_new_full_explicit(x, -D3 / 2.0, x, D3 / 2.0, - CPML_DIR_RIGHT, A, 0.0); + adg_ldim_new_full_explicit(x, -D3 / 2.0, x, D3 / 2.0, + CPML_DIR_RIGHT, A, 0.0); adg_dim_set_tolerances(ADG_DIM(entity), "-0.25", NULL); adg_dim_set_level(ADG_DIM(entity), 5.0); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); @@ -200,8 +200,8 @@ static void add_piston_dimensions(AdgCanvas *canvas, Piston *piston) /* D6 */ x = A - C + LD6; entity = - adg_ldim_new_full_explicit(x, -D6 / 2.0, x, D6 / 2.0, - CPML_DIR_RIGHT, A, 0.0); + adg_ldim_new_full_explicit(x, -D6 / 2.0, x, D6 / 2.0, + CPML_DIR_RIGHT, A, 0.0); adg_dim_set_tolerances(ADG_DIM(entity), "-0.1", NULL); adg_dim_set_level(ADG_DIM(entity), 4.0); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); @@ -209,24 +209,24 @@ static void add_piston_dimensions(AdgCanvas *canvas, Piston *piston) /* D4 */ x = A - C - LD5; entity = - adg_ldim_new_full_explicit(x, -D4 / 2.0, x, D4 / 2.0, - CPML_DIR_RIGHT, A, 0.0); + adg_ldim_new_full_explicit(x, -D4 / 2.0, x, D4 / 2.0, + CPML_DIR_RIGHT, A, 0.0); adg_dim_set_level(ADG_DIM(entity), 3.0); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); /* D5 */ x = A - C; entity = - adg_ldim_new_full_explicit(x, -D5 / 2.0, x, D5 / 2.0, - CPML_DIR_RIGHT, A, 0.0); + adg_ldim_new_full_explicit(x, -D5 / 2.0, x, D5 / 2.0, + CPML_DIR_RIGHT, A, 0.0); adg_dim_set_tolerances(ADG_DIM(entity), "-0.1", NULL); adg_dim_set_level(ADG_DIM(entity), 2.0); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); /* D7 */ entity = - adg_ldim_new_full_explicit(A, -D7 / 2.0, A, D7 / 2.0, - CPML_DIR_RIGHT, A, 0.0); + adg_ldim_new_full_explicit(A, -D7 / 2.0, A, D7 / 2.0, + CPML_DIR_RIGHT, A, 0.0); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); @@ -234,8 +234,8 @@ static void add_piston_dimensions(AdgCanvas *canvas, Piston *piston) /* D1 */ entity = - adg_ldim_new_full_explicit(0.0, -D1 / 2.0, 0.0, D1 / 2.0, - CPML_DIR_LEFT, 0.0, 0.0); + adg_ldim_new_full_explicit(0.0, -D1 / 2.0, 0.0, D1 / 2.0, + CPML_DIR_LEFT, 0.0, 0.0); adg_dim_set_tolerances(ADG_DIM(entity), "+0.05", "-0.05"); adg_dim_set_level(ADG_DIM(entity), 2.0); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); @@ -244,8 +244,8 @@ static void add_piston_dimensions(AdgCanvas *canvas, Piston *piston) y = (D1 - D2) / 2.0; x = A - B - LD2 + y * G_SQRT3; entity = - adg_ldim_new_full_explicit(x, -D2 / 2.0, x, D2 / 2.0, - CPML_DIR_LEFT, 0.0, 0.0); + adg_ldim_new_full_explicit(x, -D2 / 2.0, x, D2 / 2.0, + CPML_DIR_LEFT, 0.0, 0.0); adg_dim_set_tolerances(ADG_DIM(entity), "-0.1", NULL); g_containerable_add(G_CONTAINERABLE(canvas), G_CHILDABLE(entity)); } @@ -310,7 +310,7 @@ static void piston_path_extern(AdgEntity *entity, Piston *piston) static void piston_expose(GtkWidget *widget, - GdkEventExpose *event, AdgCanvas *canvas) + GdkEventExpose *event, AdgCanvas *canvas) { cairo_t *cr; gint width, height; @@ -323,7 +323,7 @@ piston_expose(GtkWidget *widget, scale = (double) (width - 80.0) / 80.0; cairo_matrix_init(&matrix, scale, 0.0, 0.0, scale, scale + 71.0, - 12.0 * scale); + 12.0 * scale); adg_container_set_model_transformation(ADG_CONTAINER(canvas), &matrix); /* Rendering process */ @@ -342,23 +342,23 @@ static void piston_to_ps(AdgCanvas *canvas) /* Surface creation: A4 size */ surface = cairo_ps_surface_create("test.ps", 595, 842); cairo_ps_surface_dsc_comment(surface, - "%%Title: Automatic Drawing Generation (Adg) demo"); + "%%Title: Automatic Drawing Generation (Adg) demo"); cairo_ps_surface_dsc_comment(surface, - "%%Copyright: Copyright (C) 2006 Fontana Nicola"); + "%%Copyright: Copyright (C) 2006 Fontana Nicola"); cairo_ps_surface_dsc_comment(surface, "%%Orientation: Portrait"); cairo_ps_surface_dsc_begin_setup(surface); cairo_ps_surface_dsc_begin_page_setup(surface); cairo_ps_surface_dsc_comment(surface, - "%%IncludeFeature: *PageSize A4"); + "%%IncludeFeature: *PageSize A4"); cr = cairo_create(surface); cairo_surface_destroy(surface); scale = 9.0; cairo_matrix_init(&matrix, scale, 0.0, 0.0, scale, 100.0, - 4.5 * scale + 100.0); + 4.5 * scale + 100.0); adg_container_set_model_transformation(ADG_CONTAINER(canvas), &matrix); cairo_scale(cr, 70.0, 70.0); diff --git a/demo/ldim.c b/demo/ldim.c index 65c40545..3e533381 100644 --- a/demo/ldim.c +++ b/demo/ldim.c @@ -42,7 +42,7 @@ main(gint argc, gchar ** argv) widget = gtk_drawing_area_new(); g_signal_connect(widget, "expose-event", G_CALLBACK(drawing_expose), - canvas); + canvas); gtk_container_add(GTK_CONTAINER(window), widget); gtk_widget_show_all(window); @@ -79,7 +79,7 @@ drawing_expose(GtkWidget *widget, GdkEventExpose *event, AdgCanvas *canvas) scale = (double) (width - 10.) / 10.; cairo_matrix_init(&matrix, scale, 0., 0., scale, 5., - 75. + 10. * scale); + 75. + 10. * scale); adg_container_set_model_transformation(ADG_CONTAINER(canvas), &matrix); /* Rendering process */ -- 2.11.4.GIT