From 2bed7538da300a7690101763b817b0612bb5569e Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Tue, 9 Mar 2010 20:54:49 +0100 Subject: [PATCH] [AdgDim] "pos" and "ref1", "ref2" should be handled as AdgPoint The basic APIs (setter and getter) must handle the property in its native format, that is AdgPoint boxed type for the above properties. Further convenient wrappers could be implemented, but should be treated as additional methods. --- adg/adg-adim.c | 29 ++-- adg/adg-dim.c | 416 ++++++++++++++++++++++++++++++++++++--------------------- adg/adg-dim.h | 37 +++-- adg/adg-ldim.c | 28 ++-- adg/adg-rdim.c | 24 ++-- 5 files changed, 337 insertions(+), 197 deletions(-) diff --git a/adg/adg-adim.c b/adg/adg-adim.c index ba376c5c..23624d26 100644 --- a/adg/adg-adim.c +++ b/adg/adg-adim.c @@ -251,6 +251,17 @@ set_property(GObject *object, guint prop_id, * * Returns: the newly created angular dimension entity **/ +/** + * adg_adim_new: + * + * Creates a new - undefined - angular dimension. You must, at least, + * define the first line by setting #AdgADim:org1 (start point) and + * #AdgDim:ref1 (end point), the second line by setting #AdgADim:org2 + * (start point) and #AdgDim:ref2 (end point) and the position of + * the quote with #AdgDim:pos. + * + * Returns: the newly created angular dimension entity + **/ AdgADim * adg_adim_new(void) { @@ -280,9 +291,10 @@ adg_adim_new_full(const AdgPair *ref1, const AdgPair *ref2, adim = g_object_new(ADG_TYPE_ADIM, NULL); dim = (AdgDim *) adim; - adg_dim_set_ref(dim, ref1, ref2); + adg_dim_set_ref1_from_pair(dim, ref1); + adg_dim_set_ref2_from_pair(dim, ref2); + adg_dim_set_pos_from_pair(dim, pos); adg_adim_set_org(adim, org1, org2); - adg_dim_set_pos(dim, pos); return adim; } @@ -350,7 +362,8 @@ adg_adim_new_full_from_model(AdgModel *model, adim = g_object_new(ADG_TYPE_ADIM, NULL); dim = (AdgDim *) adim; - adg_dim_set_ref_from_model(dim, model, ref1, ref2); + adg_dim_set_ref1_from_model(dim, model, ref1); + adg_dim_set_ref2_from_model(dim, model, ref2); adg_dim_set_pos_from_model(dim, model, pos); adg_adim_set_org_from_model(adim, model, org1, org2); @@ -588,8 +601,8 @@ arrange(AdgEntity *entity) } local = adg_entity_get_local_matrix(entity); - cpml_pair_copy(&ref1, adg_dim_get_ref1(dim)); - cpml_pair_copy(&ref2, adg_dim_get_ref2(dim)); + cpml_pair_copy(&ref1, adg_point_get_pair(adg_dim_get_ref1(dim))); + cpml_pair_copy(&ref2, adg_point_get_pair(adg_dim_get_ref2(dim))); cpml_pair_copy(&base1, &data->point.base1); cpml_pair_copy(&base12, &data->point.base12); cpml_pair_copy(&base2, &data->point.base2); @@ -863,8 +876,8 @@ get_info(AdgADim *adim, CpmlVector vector[], dim = (AdgDim *) adim; data = adim->data; - ref1 = adg_dim_get_ref1(dim); - ref2 = adg_dim_get_ref2(dim); + ref1 = adg_point_get_pair(adg_dim_get_ref1(dim)); + ref2 = adg_point_get_pair(adg_dim_get_ref2(dim)); org1 = adg_point_get_pair(data->org1); org2 = adg_point_get_pair(data->org2); @@ -882,7 +895,7 @@ get_info(AdgADim *adim, CpmlVector vector[], center->x = ref1->x + vector[0].x * factor; center->y = ref1->y + vector[0].y * factor; - *distance = cpml_pair_distance(center, adg_dim_get_pos(dim)); + *distance = cpml_pair_distance(center, adg_point_get_pair(adg_dim_get_pos(dim))); data->angle1 = cpml_vector_angle(&vector[0]); data->angle2 = cpml_vector_angle(&vector[2]); while (data->angle2 < data->angle1) diff --git a/adg/adg-dim.c b/adg/adg-dim.c index fda17d08..5740d164 100644 --- a/adg/adg-dim.c +++ b/adg/adg-dim.c @@ -78,6 +78,12 @@ static gchar * default_value (AdgDim *dim); static gdouble quote_angle (gdouble angle); static gboolean set_dim_dress (AdgDim *dim, AdgDress dress); +static gboolean set_ref1 (AdgDim *dim, + const AdgPoint *ref1); +static gboolean set_ref2 (AdgDim *dim, + const AdgPoint *ref2); +static gboolean set_pos (AdgDim *dim, + const AdgPoint *pos); static gboolean set_outside (AdgDim *dim, AdgThreeState outside); static gboolean set_detached (AdgDim *dim, @@ -88,6 +94,8 @@ static gboolean set_min (AdgDim *dim, const gchar *min); static gboolean set_max (AdgDim *dim, const gchar *max); +static gboolean set_point (AdgPoint **point, + const AdgPoint *new_point); G_DEFINE_ABSTRACT_TYPE(AdgDim, adg_dim, ADG_TYPE_ENTITY); @@ -141,7 +149,7 @@ adg_dim_class_init(AdgDimClass *klass) param = g_param_spec_boxed("pos", P_("Position"), - P_("The reference position in local space of the quote: it will be combined with \"level\" to get the real quote position"), + P_("The reference position of the quote: it will be combined with \"level\" to get the real quote position"), ADG_TYPE_POINT, G_PARAM_READWRITE); g_object_class_install_property(gobject_class, PROP_POS, param); @@ -305,19 +313,13 @@ set_property(GObject *object, guint prop_id, set_dim_dress(dim, g_value_get_int(value)); break; case PROP_REF1: - if (data->ref1 != NULL) - adg_point_destroy(data->ref1); - data->ref1 = g_value_dup_boxed(value); + set_ref1(dim, g_value_get_boxed(value)); break; case PROP_REF2: - if (data->ref2 != NULL) - adg_point_destroy(data->ref2); - data->ref2 = g_value_dup_boxed(value); + set_ref2(dim, g_value_get_boxed(value)); break; case PROP_POS: - if (data->pos != NULL) - adg_point_destroy(data->pos); - data->pos = g_value_dup_boxed(value); + set_pos(dim, g_value_get_boxed(value)); break; case PROP_LEVEL: data->level = g_value_get_double(value); @@ -387,167 +389,214 @@ adg_dim_get_dim_dress(AdgDim *dim) } /** - * adg_dim_set_ref: + * adg_dim_set_ref1: * @dim: an #AdgDim - * @ref1: the ref1 coordinates - * @ref2: the ref2 coordinates + * @ref1: the new point to use as first reference * - * Sets the #AdgDim:ref1 and #AdgDim:ref2 reference points - * using @ref1 and @ref2 pairs. @ref1 or @ref2 could be - * %NULL (but not both), in which case only the non-null - * reference point is changed. + * Sets the #AdgDim:ref1 property to @ref1. The old point + * is silently discarded, unreferencing its model if that + * point was bound to a named pair (hence, possibly destroying + * the model if this was the last reference). + * + * @ref1 can be %NULL, in which case the point is unset. **/ void -adg_dim_set_ref(AdgDim *dim, const AdgPair *ref1, const AdgPair *ref2) +adg_dim_set_ref1(AdgDim *dim, const AdgPoint *ref1) { - GObject *object; - AdgDimPrivate *data; - g_return_if_fail(ADG_IS_DIM(dim)); - g_return_if_fail(ref1 != NULL || ref2 != NULL); - - data = dim->data; - object = (GObject *) dim; - - g_object_freeze_notify(object); - if (ref1 != NULL) { - if (data->ref1 == NULL) - data->ref1 = adg_point_new(); - - adg_point_set_pair(data->ref1, ref1); + if (set_ref1(dim, ref1)) + g_object_notify((GObject *) dim, "ref1"); +} - g_object_notify(object, "ref1"); - } +/** + * adg_dim_set_ref1_explicit: + * @dim: an #AdgDim + * @x: x coordinate of the first reference point + * @y: y coordinate of the first reference point + * + * Sets the #AdgDim:ref1 property to the (@x, @y) explicit + * coordinates. The old point is silently discarded, + * unreferencing its model if that point was bound to a named + * pair (hence, possibly destroying the model if this was the + * last reference). + **/ +void +adg_dim_set_ref1_explicit(AdgDim *dim, gdouble x, gdouble y) +{ + AdgPoint *point = adg_point_new(); - if (ref2 != NULL) { - if (data->ref2 == NULL) - data->ref2 = adg_point_new(); + adg_point_set_pair_explicit(point, x, y); + adg_dim_set_ref1(dim, point); - adg_point_set_pair(data->ref2, ref2); + adg_point_destroy(point); +} - g_object_notify(object, "ref2"); - } +/** + * adg_dim_set_ref1_from_pair: + * @dim: an #AdgDim + * @ref1: the coordinates pair of the first reference point + * + * Convenient function to set the #AdgDim:ref1 property using a + * pair instead of explicit coordinates. + **/ +void +adg_dim_set_ref1_from_pair(AdgDim *dim, const AdgPair *ref1) +{ + g_return_if_fail(ref1 != NULL); - g_object_thaw_notify(object); + adg_dim_set_ref1_explicit(dim, ref1->x, ref1->y); } /** - * adg_dim_set_ref_explicit: + * adg_dim_set_ref1_from_model: * @dim: an #AdgDim - * @ref1_x: x coordinate of ref1 - * @ref1_y: y coordinate of ref1 - * @ref2_x: x coordinate of ref2 - * @ref2_y: y coordinate of ref2 + * @model: the source #AdgModel + * @ref1: a named pair in @model + * + * Binds #AdgDim:ref1 to the @ref1 named pair of @model. If @model + * is %NULL, the point will be unset. In any case, the old point + * is silently discarded, unreferencing its model if that point + * was bound to a named pair (hence, possibly destroying the model + * if this was the last reference). * - * Works in the same way as adg_dim_set_ref() but using - * explicit coordinates instead of #AdgPair args. The - * notable difference is that, by using gdouble values, - * you can't set only a single reference point. + * The assignment is lazy so @ref1 could be not be present in @model. + * Anyway, at the first access to this point an error will be raised + * if the named pair is still missing. **/ void -adg_dim_set_ref_explicit(AdgDim *dim, - gdouble ref1_x, gdouble ref1_y, - gdouble ref2_x, gdouble ref2_y) +adg_dim_set_ref1_from_model(AdgDim *dim, AdgModel *model, const gchar *ref1) { - AdgPair ref1, ref2; + AdgPoint *point = adg_point_new(); - ref1.x = ref1_x; - ref1.y = ref1_y; - ref2.x = ref2_x; - ref2.y = ref2_y; + adg_point_set_pair_from_model(point, model, ref1); + adg_dim_set_ref1(dim, point); - adg_dim_set_ref(dim, &ref1, &ref2); + adg_point_destroy(point); } /** - * adg_dim_set_ref_from_model: + * adg_dim_get_ref1: * @dim: an #AdgDim - * @model: the source #AdgModel - * @ref1: name of the pair in @model to use as ref1 - * @ref2: name of the pair in @model to use as ref2 * - * Sets #AdgDim:ref1 and #AdgDim:ref2 properties by linking - * them to the @ref1 and @ref2 named pairs in @model. @ref1 - * or @ref2 could be %NULL (but not both), in which case - * only the non-null reference point is changed. + * Gets the #AdgDim:ref1 point. The returned point is internally owned + * and must not be freed or modified. Anyway, it is not const because + * adg_point_get_pair() must be able to modify the internal cache of + * the returned point. * - * Using this function twice you can also link the reference - * points to named pairs taken from different models: - * - * |[ - * adg_dim_set_ref_from_model(dim, model1, ref1, NULL); - * adg_dim_set_ref_from_model(dim, model2, NULL, ref2); - * ]| + * Returns: the first reference point **/ -void -adg_dim_set_ref_from_model(AdgDim *dim, AdgModel *model, - const gchar *ref1, const gchar *ref2) +AdgPoint * +adg_dim_get_ref1(AdgDim *dim) { - GObject *object; AdgDimPrivate *data; - g_return_if_fail(ADG_IS_DIM(dim)); - g_return_if_fail(ADG_IS_MODEL(model)); - g_return_if_fail(ref1 != NULL || ref2 != NULL); + g_return_val_if_fail(ADG_IS_DIM(dim), NULL); - object = (GObject *) dim; data = dim->data; - g_object_freeze_notify(object); + return data->ref1; +} - if (ref1 != NULL) { - if (data->ref1 == NULL) - data->ref1 = adg_point_new(); +/** + * adg_dim_set_ref2: + * @dim: an #AdgDim + * @ref2: the new point to use as second reference + * + * Sets the #AdgDim:ref2 property to @ref2. The old point + * is silently discarded, unreferencing its model if that + * point was bound to a named pair (hence, possibly destroying + * the model if it was the last reference). + * + * @ref2 can be %NULL, in which case the point is unset. + **/ +void +adg_dim_set_ref2(AdgDim *dim, const AdgPoint *ref2) +{ + g_return_if_fail(ADG_IS_DIM(dim)); - adg_point_set_pair_from_model(data->ref1, model, ref1); + if (set_ref2(dim, ref2)) + g_object_notify((GObject *) dim, "ref2"); +} - g_object_notify(object, "ref1"); - } +/** + * adg_dim_set_ref2_explicit: + * @dim: an #AdgDim + * @x: x coordinate of the second reference point + * @y: y coordinate of the second reference point + * + * Sets the #AdgDim:ref2 property to the (@x, @y) explicit + * coordinates. The old point is silently discarded, + * unreferencing its model if that point was bound to a named + * pair (hence, possibly destroying the model if this was the + * last reference). + **/ +void +adg_dim_set_ref2_explicit(AdgDim *dim, gdouble x, gdouble y) +{ + AdgPoint *point = adg_point_new(); - if (ref2 != NULL) { - if (data->ref2 == NULL) - data->ref2 = adg_point_new(); + adg_point_set_pair_explicit(point, x, y); + adg_dim_set_ref2(dim, point); - adg_point_set_pair_from_model(data->ref2, model, ref2); + adg_point_destroy(point); +} - g_object_notify(object, "ref2"); - } +/** + * adg_dim_set_ref2_from_pair: + * @dim: an #AdgDim + * @ref2: the coordinates pair of the second reference point + * + * Convenient function to set the #AdgDim:ref2 property using a + * pair instead of explicit coordinates. + **/ +void +adg_dim_set_ref2_from_pair(AdgDim *dim, const AdgPair *ref2) +{ + g_return_if_fail(ref2 != NULL); - g_object_thaw_notify(object); + adg_dim_set_ref2_explicit(dim, ref2->x, ref2->y); } /** - * adg_dim_get_ref1: + * adg_dim_set_ref2_from_model: * @dim: an #AdgDim + * @model: the source #AdgModel + * @ref2: a named pair in @model * - * Gets the ref1 coordinates. The returned pair is internally owned - * and must not be freed or modified. + * Binds #AdgDim:ref2 to the @ref2 named pair of @model. If @model + * is %NULL, the point will be unset. In any case, the old point + * is silently discarded, unreferencing its model if that point + * was bound to a named pair (hence, possibly destroying the model + * if this was the last reference). * - * Returns: the ref1 coordinates + * The assignment is lazy so @ref2 could be not be present in @model. + * Anyway, at the first access to this point an error will be raised + * if the named pair is still missing. **/ -const AdgPair * -adg_dim_get_ref1(AdgDim *dim) +void +adg_dim_set_ref2_from_model(AdgDim *dim, AdgModel *model, const gchar *ref2) { - AdgDimPrivate *data; - - g_return_val_if_fail(ADG_IS_DIM(dim), NULL); + AdgPoint *point = adg_point_new(); - data = dim->data; + adg_point_set_pair_from_model(point, model, ref2); + adg_dim_set_ref2(dim, point); - return adg_point_get_pair(data->ref1); + adg_point_destroy(point); } /** * adg_dim_get_ref2: * @dim: an #AdgDim * - * Gets the ref2 coordinates. The returned pair is internally owned - * and must not be freed or modified. + * Gets the #AdgDim:ref2 point. The returned point is internally owned + * and must not be freed or modified. Anyway, it is not const because + * adg_point_get_pair() must be able to modify the internal cache of + * the returned point. * - * Returns: the ref2 coordinates + * Returns: the second reference point **/ -const AdgPair * +AdgPoint * adg_dim_get_ref2(AdgDim *dim) { AdgDimPrivate *data; @@ -556,91 +605,108 @@ adg_dim_get_ref2(AdgDim *dim) data = dim->data; - return adg_point_get_pair(data->ref2); + return data->ref2; } /** * adg_dim_set_pos: * @dim: an #AdgDim - * @pos: the pos coordinates + * @pos: the new point to use as position + * + * Sets the #AdgDim:pos property to @pos. The old point + * is silently discarded, unreferencing its model if that + * point was bound to a named pair (hence, possibly destroying + * the model if it was the last reference). * - * Sets a new #AdgDim:pos position. + * @pos can be %NULL, in which case the point is unset. **/ void -adg_dim_set_pos(AdgDim *dim, const AdgPair *pos) +adg_dim_set_pos(AdgDim *dim, const AdgPoint *pos) { - AdgDimPrivate *data; - g_return_if_fail(ADG_IS_DIM(dim)); - g_return_if_fail(pos != NULL); - - data = dim->data; - - if (data->pos == NULL) - data->pos = adg_point_new(); - adg_point_set_pair(data->pos, pos); - - g_object_notify((GObject *) dim, "pos"); + if (set_pos(dim, pos)) + g_object_notify((GObject *) dim, "pos"); } /** * adg_dim_set_pos_explicit: * @dim: an #AdgDim - * @pos_x: x coordinate of pos - * @pos_y: y coordinate of pos + * @x: x coordinate of the position + * @y: y coordinate of the position * - * Shortcut to set #AdgDim:pos using explicit coordinates. + * Sets the #AdgDim:pos property to the (@x, @y) explicit + * coordinates. The old point is silently discarded, + * unreferencing its model if that point was bound to a named + * pair (hence, possibly destroying the model if this was the + * last reference). **/ void adg_dim_set_pos_explicit(AdgDim *dim, gdouble x, gdouble y) { - AdgPair pos; + AdgPoint *point = adg_point_new(); - pos.x = x; - pos.y = y; + adg_point_set_pair_explicit(point, x, y); + adg_dim_set_pos(dim, point); - adg_dim_set_pos(dim, &pos); + adg_point_destroy(point); } /** - * adg_dim_set_pos_from_model: + * adg_dim_set_pos_from_pair: * @dim: an #AdgDim - * @model: the source #AdgModel - * @ref1: name of the pair in @model to use as pos + * @pos: the coordinates pair of the position point * - * Sets #AdgDim:pos by linking it to the @pos named pair - * in @model. + * Convenient function to set the #AdgDim:pos property using a + * pair instead of explicit coordinates. **/ void -adg_dim_set_pos_from_model(AdgDim *dim, AdgModel *model, const gchar *pos) +adg_dim_set_pos_from_pair(AdgDim *dim, const AdgPair *pos) { - AdgDimPrivate *data; - - g_return_if_fail(ADG_IS_DIM(dim)); - g_return_if_fail(ADG_IS_MODEL(model)); g_return_if_fail(pos != NULL); - data = dim->data; + adg_dim_set_pos_explicit(dim, pos->x, pos->y); +} - if (data->pos == NULL) - data->pos = adg_point_new(); +/** + * adg_dim_set_pos_from_model: + * @dim: an #AdgDim + * @model: the source #AdgModel + * @pos: a named pair in @model + * + * Binds #AdgDim:pos to the @pos named pair of @model. If @model + * is %NULL, the point will be unset. In any case, the old point + * is silently discarded, unreferencing its model if that point + * was bound to a named pair (hence, possibly destroying the model + * if this was the last reference). + * + * The assignment is lazy so @pos could be not be present in @model. + * Anyway, at the first access to this point an error will be raised + * if the named pair is still missing. + **/ +void +adg_dim_set_pos_from_model(AdgDim *dim, AdgModel *model, const gchar *pos) +{ + AdgPoint *point = adg_point_new(); - adg_point_set_pair_from_model(data->pos, model, pos); + adg_point_set_pair_from_model(point, model, pos); + adg_dim_set_pos(dim, point); - g_object_notify((GObject *) dim, "pos"); + adg_point_destroy(point); } /** * adg_dim_get_pos: * @dim: an #AdgDim * - * Gets the position coordinates. The returned pair is internally owned - * and must not be freed or modified. + * Gets the #AdgDim:pos point. The returned point is internally owned + * and must not be freed or modified. Anyway, it is not const because + * adg_point_get_pair() must be able to modify the internal cache of + * the returned point. * - * Returns: the pos coordinates + * Returns: the position point **/ -const AdgPair * +AdgPoint * adg_dim_get_pos(AdgDim *dim) { AdgDimPrivate *data; @@ -649,7 +715,7 @@ adg_dim_get_pos(AdgDim *dim) data = dim->data; - return adg_point_get_pair(data->pos); + return data->pos; } /** @@ -1167,6 +1233,30 @@ set_dim_dress(AdgDim *dim, AdgDress dress) } static gboolean +set_ref1(AdgDim *dim, const AdgPoint *ref1) +{ + AdgDimPrivate *data = dim->data; + + return set_point(&data->ref1, ref1); +} + +static gboolean +set_ref2(AdgDim *dim, const AdgPoint *ref2) +{ + AdgDimPrivate *data = dim->data; + + return set_point(&data->ref2, ref2); +} + +static gboolean +set_pos(AdgDim *dim, const AdgPoint *pos) +{ + AdgDimPrivate *data = dim->data; + + return set_point(&data->pos, pos); +} + +static gboolean set_outside(AdgDim *dim, AdgThreeState outside) { AdgDimPrivate *data; @@ -1260,3 +1350,23 @@ set_max(AdgDim *dim, const gchar *max) return TRUE; } + +static gboolean +set_point(AdgPoint **point, const AdgPoint *new_point) +{ + if ((*point == new_point) || + (*point && new_point && adg_point_equal(*point, new_point))) + return FALSE; + + if (*point == NULL) + *point = adg_point_new(); + + if (new_point) { + adg_point_copy(*point, new_point); + } else { + adg_point_destroy(*point); + *point = NULL; + } + + return TRUE; +} diff --git a/adg/adg-dim.h b/adg/adg-dim.h index 462c07a3..54bb0c0b 100644 --- a/adg/adg-dim.h +++ b/adg/adg-dim.h @@ -26,6 +26,7 @@ #ifndef __ADG_DIM_H__ #define __ADG_DIM_H__ +#include #include #include #include @@ -63,29 +64,39 @@ GType adg_dim_get_type (void) G_GNUC_CONST; AdgDress adg_dim_get_dim_dress (AdgDim *dim); void adg_dim_set_dim_dress (AdgDim *dim, AdgDress dress); -void adg_dim_set_ref (AdgDim *dim, - const AdgPair *ref1, +void adg_dim_set_ref1 (AdgDim *dim, + const AdgPoint *ref1); +void adg_dim_set_ref1_explicit (AdgDim *dim, + gdouble x, + gdouble y); +void adg_dim_set_ref1_from_pair (AdgDim *dim, + const AdgPair *ref2); +void adg_dim_set_ref1_from_model (AdgDim *dim, + AdgModel *model, + const gchar *ref1); +AdgPoint * adg_dim_get_ref1 (AdgDim *dim); +void adg_dim_set_ref2 (AdgDim *dim, + const AdgPoint *ref2); +void adg_dim_set_ref2_explicit (AdgDim *dim, + gdouble x, + gdouble y); +void adg_dim_set_ref2_from_pair (AdgDim *dim, const AdgPair *ref2); -void adg_dim_set_ref_explicit (AdgDim *dim, - gdouble ref1_x, - gdouble ref1_y, - gdouble ref2_x, - gdouble ref2_y); -void adg_dim_set_ref_from_model (AdgDim *dim, +void adg_dim_set_ref2_from_model (AdgDim *dim, AdgModel *model, - const gchar *ref1, const gchar *ref2); -const AdgPair * adg_dim_get_ref1 (AdgDim *dim); -const AdgPair * adg_dim_get_ref2 (AdgDim *dim); +AdgPoint * adg_dim_get_ref2 (AdgDim *dim); void adg_dim_set_pos (AdgDim *dim, - const AdgPair *pos); + const AdgPoint *pos); void adg_dim_set_pos_explicit (AdgDim *dim, gdouble x, gdouble y); +void adg_dim_set_pos_from_pair (AdgDim *dim, + const AdgPair *pos); void adg_dim_set_pos_from_model (AdgDim *dim, AdgModel *model, const gchar *pos); -const AdgPair * adg_dim_get_pos (AdgDim *dim); +AdgPoint * adg_dim_get_pos (AdgDim *dim); void adg_dim_set_level (AdgDim *dim, gdouble level); gdouble adg_dim_get_level (AdgDim *dim); diff --git a/adg/adg-ldim.c b/adg/adg-ldim.c index dfdc4e10..8dd688ee 100644 --- a/adg/adg-ldim.c +++ b/adg/adg-ldim.c @@ -224,9 +224,11 @@ set_property(GObject *object, * adg_ldim_new: * * Creates a new - undefined - linear dimension. You must, at least, - * define the reference points with adg_dim_set_ref(), the dimension - * direction with adg_ldim_set_direction() and the position reference - * using adg_dim_set_pos(). + * define the start of the dimension in #AdgDim:ref1, the end in + * #AdgDim:ref2 and the position of the quote in #AdgDim:pos using + * any valid #AdgDim method. The director of the dimension (that is, + * if it is horizontal, vertical or oblique at a specific angle) + * should be specified with adg_ldim_set_direction(). * * Returns: the newly created linear dimension entity **/ @@ -258,8 +260,9 @@ adg_ldim_new_full(const AdgPair *ref1, const AdgPair *ref2, ldim = g_object_new(ADG_TYPE_LDIM, "direction", direction, NULL); dim = (AdgDim *) ldim; - adg_dim_set_ref(dim, ref1, ref2); - adg_dim_set_pos(dim, pos); + adg_dim_set_ref1_from_pair(dim, ref1); + adg_dim_set_ref2_from_pair(dim, ref2); + adg_dim_set_pos_from_pair(dim, pos); return ldim; } @@ -321,7 +324,8 @@ adg_ldim_new_full_from_model(AdgModel *model, 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_ref1_from_model(dim, model, ref1); + adg_dim_set_ref2_from_model(dim, model, ref2); adg_dim_set_pos_from_model(dim, model, pos); return ldim; @@ -520,8 +524,8 @@ arrange(AdgEntity *entity) dim_style = GET_DIM_STYLE(dim); local = adg_entity_get_local_matrix(entity); - cpml_pair_copy(&ref1, adg_dim_get_ref1(dim)); - cpml_pair_copy(&ref2, adg_dim_get_ref2(dim)); + cpml_pair_copy(&ref1, adg_point_get_pair(adg_dim_get_ref1(dim))); + cpml_pair_copy(&ref2, adg_point_get_pair(adg_dim_get_ref2(dim))); cpml_pair_copy(&base1, &data->geometry.base1); cpml_pair_copy(&base2, &data->geometry.base2); @@ -612,7 +616,7 @@ arrange(AdgEntity *entity) cairo_path_data_t *to_extend; /* Set "pair" to the properly converted "pos" coordinates */ - cpml_pair_copy(&pair, adg_dim_get_pos(dim)); + cpml_pair_copy(&pair, adg_point_get_pair(adg_dim_get_pos(dim))); cpml_pair_transform(&pair, local); pair.x += data->shift.base.x; pair.y += data->shift.base.y; @@ -786,9 +790,9 @@ update_geometry(AdgLDim *ldim) return; dim = (AdgDim *) ldim; - ref1 = adg_dim_get_ref1(dim); - ref2 = adg_dim_get_ref2(dim); - pos = adg_dim_get_pos(dim); + ref1 = adg_point_get_pair(adg_dim_get_ref1(dim)); + ref2 = adg_point_get_pair(adg_dim_get_ref2(dim)); + pos = adg_point_get_pair(adg_dim_get_pos(dim)); cpml_vector_from_angle(&extension, data->direction); cpml_pair_copy(&baseline, &extension); cpml_vector_normal(&baseline); diff --git a/adg/adg-rdim.c b/adg/adg-rdim.c index 390f2089..62c78369 100644 --- a/adg/adg-rdim.c +++ b/adg/adg-rdim.c @@ -128,9 +128,9 @@ dispose(GObject *object) * adg_rdim_new: * * Creates a new uninitialized radial dimension. To be useful, you - * need at least define the center of the arc to quote (ref1) and - * a point on the arc (ref2) with adg_dim_set_ref() and the - * position of the quote with adg_dim_set_pos(). + * need at least define the center of the arc to quote in #AdgDim:ref1, + * a point on the arc in #AdgDim:ref2 and the position of the quote + * in #AdgDim:pos using any valid #AdgDim method. * * Returns: a newly created quote **/ @@ -161,8 +161,9 @@ adg_rdim_new_full(const AdgPair *center, const AdgPair *radius, rdim = adg_rdim_new(); dim = (AdgDim *) rdim; - adg_dim_set_ref(dim, center, radius); - adg_dim_set_pos(dim, pos); + adg_dim_set_ref1_from_pair(dim, center); + adg_dim_set_ref2_from_pair(dim, radius); + adg_dim_set_pos_from_pair(dim, pos); return rdim; } @@ -217,7 +218,8 @@ adg_rdim_new_full_from_model(AdgModel *model, const gchar *center, { AdgDim *dim = g_object_new(ADG_TYPE_RDIM, NULL); - adg_dim_set_ref_from_model(dim, model, center, radius); + adg_dim_set_ref1_from_model(dim, model, center); + adg_dim_set_ref2_from_model(dim, model, radius); adg_dim_set_pos_from_model(dim, model, pos); return (AdgRDim *) dim; @@ -286,8 +288,8 @@ arrange(AdgEntity *entity) outside = ADG_THREE_STATE_OFF; local = adg_entity_get_local_matrix(entity); - cpml_pair_copy(&ref1, adg_dim_get_ref1(dim)); - cpml_pair_copy(&ref2, adg_dim_get_ref2(dim)); + cpml_pair_copy(&ref1, adg_point_get_pair(adg_dim_get_ref1(dim))); + cpml_pair_copy(&ref2, adg_point_get_pair(adg_dim_get_ref2(dim))); cpml_pair_copy(&base, &data->point.base); cpml_pair_transform(&ref1, local); @@ -402,9 +404,9 @@ update_geometry(AdgRDim *rdim) dim = (AdgDim *) rdim; dim_style = GET_DIM_STYLE(rdim); - ref1 = adg_dim_get_ref1(dim); - ref2 = adg_dim_get_ref2(dim); - pos = adg_dim_get_pos(dim); + ref1 = adg_point_get_pair(adg_dim_get_ref1(dim)); + ref2 = adg_point_get_pair(adg_dim_get_ref2(dim)); + pos = adg_point_get_pair(adg_dim_get_pos(dim)); spacing = adg_dim_style_get_baseline_spacing(dim_style); level = adg_dim_get_level(dim); pos_distance = cpml_pair_distance(pos, ref1); -- 2.11.4.GIT