[AdgRotable] Removed from ADG
[adg.git] / adg / adg-point.c
blobc725a0c31501cba177a023fdb3b123605ced7fba
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.
20 /**
21 * SECTION:adg-point
22 * @title: AdgPoint
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.
32 **/
34 #include "adg-point.h"
36 #include <string.h>
39 GType
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,
47 g_free);
49 return point_type;
52 /**
53 * adg_point_dup:
54 * @point: an #AdgPoint structure
56 * Duplicates @point.
58 * Return value: the duplicate of @point: must be freed with g_free()
59 * when no longer needed.
60 **/
61 AdgPoint *
62 adg_point_dup(const AdgPoint *point)
64 return g_memdup(point, sizeof(AdgPoint));
67 /**
68 * adg_point_copy:
69 * @point: an #AdgPoint structure
70 * @src: the source point
72 * Shortcut to copy @src to @point.
73 **/
74 void
75 adg_point_copy(AdgPoint *point, const AdgPoint *src)
77 memcpy(point, src, sizeof(AdgPoint));
80 /**
81 * adg_point_set:
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.
87 **/
88 void
89 adg_point_set(AdgPoint *point, const AdgPair *model, const AdgPair *paper)
91 if (model) {
92 memcpy(&point->model, model, sizeof(AdgPair));
94 if (paper) {
95 memcpy(&point->paper, paper, sizeof(AdgPair));
99 /**
100 * adg_point_unset:
101 * @point: an #AdgPoint structure
103 * Fills the AdgPoint struct with 0.
105 void
106 adg_point_unset(AdgPoint *point)
108 memset(point, 0, sizeof(AdgPoint));