[docs] Improved the ADG docs
[adg.git] / adg / adg-adim.c
blob917f08a533bc073125374f035f1d527c8d442e2a
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.
21 /**
22 * SECTION:adg-adim
23 * @short_description: Angular dimensions
25 * The #AdgADim entity represents an angular dimension.
28 /**
29 * AdgADim:
31 * All fields are privates and should not be used directly.
32 * Use its public methods instead.
33 **/
36 #include "adg-adim.h"
37 #include "adg-adim-private.h"
38 #include "adg-container.h"
39 #include "adg-util.h"
40 #include "adg-intl.h"
43 enum {
44 PROP_0,
45 PROP_DIRECTION
49 static void finalize (GObject *object);
50 static void model_matrix_changed (AdgEntity *entity,
51 AdgMatrix *parent_matrix);
52 static void render (AdgEntity *entity,
53 cairo_t *cr);
54 static gchar * default_quote (AdgDim *dim);
57 G_DEFINE_TYPE(AdgADim, adg_adim, ADG_TYPE_DIM);
60 static void
61 adg_adim_class_init(AdgADimClass *klass)
63 GObjectClass *gobject_class;
64 AdgEntityClass *entity_class;
65 AdgDimClass *dim_class;
66 GParamSpec *param;
68 gobject_class = (GObjectClass *) klass;
69 entity_class = (AdgEntityClass *) klass;
70 dim_class = (AdgDimClass *) klass;
72 g_type_class_add_private(klass, sizeof(AdgADimPrivate));
74 gobject_class->finalize = finalize;
76 entity_class->model_matrix_changed = model_matrix_changed;
77 entity_class->render = render;
79 dim_class->default_quote = default_quote;
81 param = g_param_spec_double("direction",
82 P_("Direction"),
83 P_("The inclination angle of the extension lines"),
84 -G_MAXDOUBLE, G_MAXDOUBLE, ADG_DIR_RIGHT,
85 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
86 g_object_class_install_property(gobject_class, PROP_DIRECTION, param);
89 static void
90 adg_adim_init(AdgADim *adim)
92 AdgADimPrivate *data = G_TYPE_INSTANCE_GET_PRIVATE(adim, ADG_TYPE_ADIM,
93 AdgADimPrivate);
95 data->extension1.status = CAIRO_STATUS_SUCCESS;
96 data->extension1.data = NULL;
97 data->extension1.num_data = 4;
99 data->extension2.status = CAIRO_STATUS_SUCCESS;
100 data->extension2.data = NULL;
101 data->extension2.num_data = 4;
103 data->arrow_path.status = CAIRO_STATUS_SUCCESS;
104 data->arrow_path.data = NULL;
105 data->arrow_path.num_data = 4;
107 data->baseline.status = CAIRO_STATUS_SUCCESS;
108 data->baseline.data = NULL;
109 data->baseline.num_data = 4;
111 adim->data = data;
114 static void
115 finalize(GObject *object)
117 AdgADimPrivate *data = ((AdgADim *) object)->data;
119 g_free(data->extension1.data);
120 g_free(data->extension2.data);
121 g_free(data->arrow_path.data);
122 g_free(data->baseline.data);
125 static void
126 model_matrix_changed(AdgEntity *entity, AdgMatrix *parent_matrix)
128 AdgEntityClass *entity_class = (AdgEntityClass *) adg_adim_parent_class;
130 /* TODO */
132 if (entity_class->model_matrix_changed != NULL)
133 entity_class->model_matrix_changed(entity, parent_matrix);
136 static void
137 render(AdgEntity *entity, cairo_t *cr)
139 /* TODO */
142 static gchar *
143 default_quote(AdgDim *dim)
145 /* TODO */
146 return g_strdup("TODO");
152 * adg_adim_new:
154 * Creates a new - unreferenced - angular dimension. You must, at least, define
155 * the reference points with adg_dim_set_ref() and the position reference using
156 * adg_dim_set_pos().
158 * Return value: the new entity
160 AdgEntity *
161 adg_adim_new(void)
163 return (AdgEntity *) g_object_new(ADG_TYPE_ADIM, NULL);