From 0a87365e8cacd5484d9ba84a09ce5657f5461d5e Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Fri, 16 Oct 2009 11:26:14 +0200 Subject: [PATCH] [AdgLDim] Added construction with named pairs Added adg_ldim_new_full_from_model() to construct a fully working linear dimension using directly named pairs from a model. --- adg/adg-ldim.c | 30 ++++++++++++++++++++++++++++++ adg/adg-ldim.h | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/adg/adg-ldim.c b/adg/adg-ldim.c index a3111878..1ec906f5 100644 --- a/adg/adg-ldim.c +++ b/adg/adg-ldim.c @@ -296,6 +296,36 @@ adg_ldim_new_full_explicit(gdouble ref1_x, gdouble ref1_y, } /** + * adg_ldim_new_full_from_model: + * @model: the model from which the named pairs are taken + * @ref1: the first reference point + * @ref2: the second reference point + * @pos: the position reference + * @direction: angle where to extend the dimension + * + * Creates a new linear dimension, specifing all the needed properties in + * one shot and using named pairs from @model. + * + * Returns: the newly created linear dimension entity + **/ +AdgLDim * +adg_ldim_new_full_from_model(AdgModel *model, + const gchar *ref1, const gchar *ref2, + const gchar *pos, gdouble direction) +{ + AdgLDim *ldim; + AdgDim *dim; + + ldim = g_object_new(ADG_TYPE_LDIM, "direction", direction, NULL); + dim = (AdgDim *) ldim; + + adg_dim_set_ref_from_model(dim, model, ref1, ref2); + adg_dim_set_pos_from_model(dim, model, pos); + + return ldim; +} + +/** * adg_ldim_get_direction: * @ldim: an #AdgLDim entity * diff --git a/adg/adg-ldim.h b/adg/adg-ldim.h index b3c6e9f8..aca557d8 100644 --- a/adg/adg-ldim.h +++ b/adg/adg-ldim.h @@ -63,6 +63,11 @@ AdgLDim * adg_ldim_new_full_explicit (gdouble ref1_x, gdouble pos_x, gdouble pos_y, gdouble direction); +AdgLDim * adg_ldim_new_full_from_model (AdgModel *model, + const gchar *ref1, + const gchar *ref2, + const gchar *pos, + gdouble direction); gdouble adg_ldim_get_direction (AdgLDim *ldim); void adg_ldim_set_direction (AdgLDim *ldim, -- 2.11.4.GIT