1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
23 * @short_description: A generic point with model and paper space components
25 * The AdgPoint is quite different from what usually expected: to get the
26 * common (x, y) struct take a look to the #AdgPair object.
28 * In ADG, points have usually two components, being the component an usual
29 * (x, y) struct (an AdgPair object in this implementation). The model
30 * matrix is applied only to the model component while the paper matrix
31 * affects only the paper component.
34 #include "adg-point.h"
40 adg_point_get_type(void)
42 static int point_type
= 0;
44 if (G_UNLIKELY(point_type
== 0))
45 point_type
= g_boxed_type_register_static("AdgPoint",
46 (GBoxedCopyFunc
) adg_point_dup
,
54 * @point: an #AdgPoint structure
58 * Return value: the duplicate of @point: must be freed with g_free()
59 * when no longer needed.
62 adg_point_dup(const AdgPoint
*point
)
64 return g_memdup(point
, sizeof(AdgPoint
));
69 * @point: an #AdgPoint structure
70 * @src: the source point
72 * Shortcut to copy @src to @point.
75 adg_point_copy(AdgPoint
*point
, const AdgPoint
*src
)
77 memcpy(point
, src
, sizeof(AdgPoint
));
82 * @point: an #AdgPoint structure
83 * @model: the model component
84 * @paper: the paper component
86 * Fills the component of @point using the provided ones.
89 adg_point_set(AdgPoint
*point
, const AdgPair
*model
, const AdgPair
*paper
)
92 memcpy(&point
->model
, model
, sizeof(AdgPair
));
95 memcpy(&point
->paper
, paper
, sizeof(AdgPair
));
101 * @point: an #AdgPoint structure
103 * Fills the AdgPoint struct with 0.
106 adg_point_unset(AdgPoint
*point
)
108 memset(point
, 0, sizeof(AdgPoint
));