From ca26fc332ac46d9453108e290396c3fc76dc33eb Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Fri, 9 Jan 2009 01:28:00 +0100 Subject: [PATCH] [AdgEntity] Implemented adg_entity_point_to_pair() alternatives --- adg/adg-entity.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- adg/adg-entity.h | 6 ++++++ docs/adg-sections.txt | 2 ++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/adg/adg-entity.c b/adg/adg-entity.c index 28051f61..03bf5fa6 100644 --- a/adg/adg-entity.c +++ b/adg/adg-entity.c @@ -654,7 +654,8 @@ adg_entity_apply(AdgEntity *entity, AdgStyleSlot style_slot, cairo_t *cr) * @point: the source #AdgPoint * @pair: the destination #AdgPair * - * Converts @point to @pair using the model and paper matrix of @entity. + * Converts @point to @pair using the model and paper matrix of @entity, + * as if the current matrix is an identity matrix. **/ void adg_entity_point_to_pair(AdgEntity *entity, @@ -682,6 +683,52 @@ adg_entity_point_to_pair(AdgEntity *entity, } /** + * adg_entity_point_to_model_pair: + * @entity: an #AdgEntity + * @point: the source #AdgPoint + * @pair: the destination #AdgPair + * + * Converts @point to @pair in model space. + **/ +void +adg_entity_point_to_model_pair(AdgEntity *entity, + const AdgPoint *point, AdgPair *pair) +{ + const AdgMatrix *paper_matrix; + + g_return_if_fail(ADG_IS_ENTITY(entity)); + g_return_if_fail(point != NULL); + g_return_if_fail(pair != NULL); + + paper_matrix = ADG_ENTITY_GET_CLASS(entity)->get_paper_matrix(entity); + adg_pair_copy(pair, &point->paper); + cpml_pair_transform(pair, paper_matrix); +} + +/** + * adg_entity_point_to_paper_pair: + * @entity: an #AdgEntity + * @point: the source #AdgPoint + * @pair: the destination #AdgPair + * + * Converts @point to @pair in paper space. + **/ +void +adg_entity_point_to_paper_pair(AdgEntity *entity, + const AdgPoint *point, AdgPair *pair) +{ + const AdgMatrix *model_matrix; + + g_return_if_fail(ADG_IS_ENTITY(entity)); + g_return_if_fail(point != NULL); + g_return_if_fail(pair != NULL); + + model_matrix = ADG_ENTITY_GET_CLASS(entity)->get_model_matrix(entity); + adg_pair_copy(pair, &point->model); + cpml_pair_transform(pair, model_matrix); +} + +/** * adg_entity_model_matrix_applied: * @entity: an #AdgEntity * diff --git a/adg/adg-entity.h b/adg/adg-entity.h index c60b4871..75d0b0fb 100644 --- a/adg/adg-entity.h +++ b/adg/adg-entity.h @@ -120,6 +120,12 @@ void adg_entity_apply (AdgEntity *entity, void adg_entity_point_to_pair (AdgEntity *entity, const AdgPoint *point, AdgPair *pair); +void adg_entity_point_to_model_pair (AdgEntity *entity, + const AdgPoint *point, + AdgPair *pair); +void adg_entity_point_to_paper_pair (AdgEntity *entity, + const AdgPoint *point, + AdgPair *pair); gboolean adg_entity_model_matrix_applied (AdgEntity *entity); gboolean adg_entity_paper_matrix_applied (AdgEntity *entity); gboolean adg_entity_model_applied (AdgEntity *entity); diff --git a/docs/adg-sections.txt b/docs/adg-sections.txt index 5b921bb7..50efebe5 100644 --- a/docs/adg-sections.txt +++ b/docs/adg-sections.txt @@ -305,6 +305,8 @@ adg_entity_build_paper2model adg_entity_scale_to_model adg_entity_scale_to_paper adg_entity_point_to_pair +adg_entity_point_to_model_pair +adg_entity_point_to_paper_pair adg_entity_render adg_entity_invalidate -- 2.11.4.GIT