Merge branch 'ntd'
[adg.git] / adg / adg-adim.c
blob83af4bd77e9bba00938cd6d2d63fd1cf49da3c94
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2008, 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:adim
22 * @title: AdgADim
23 * @short_description: Angular dimensions
25 * The #AdgADim entity represents an angular dimension.
28 #include "adg-adim.h"
29 #include "adg-adim-private.h"
30 #include "adg-container.h"
31 #include "adg-util.h"
32 #include "adg-intl.h"
34 #define PARENT_CLASS ((AdgDimClass *) adg_adim_parent_class)
37 enum {
38 PROP_0,
39 PROP_DIRECTION
43 static void finalize (GObject *object);
44 static void model_matrix_changed (AdgEntity *entity,
45 AdgMatrix *parent_matrix);
46 static void render (AdgEntity *entity,
47 cairo_t *cr);
48 static gchar * default_quote (AdgDim *dim);
51 G_DEFINE_TYPE(AdgADim, adg_adim, ADG_TYPE_DIM);
54 static void
55 adg_adim_class_init(AdgADimClass *klass)
57 GObjectClass *gobject_class;
58 AdgEntityClass *entity_class;
59 AdgDimClass *dim_class;
60 GParamSpec *param;
62 gobject_class = (GObjectClass *) klass;
63 entity_class = (AdgEntityClass *) klass;
64 dim_class = (AdgDimClass *) klass;
66 g_type_class_add_private(klass, sizeof(AdgADimPrivate));
68 gobject_class->finalize = finalize;
70 entity_class->model_matrix_changed = model_matrix_changed;
72 dim_class->default_quote = default_quote;
74 param = g_param_spec_double("direction",
75 P_("Direction"),
76 P_("The inclination angle of the extension lines"),
77 -G_MAXDOUBLE, G_MAXDOUBLE, CPML_DIR_RIGHT,
78 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
79 g_object_class_install_property(gobject_class, PROP_DIRECTION, param);
82 static void
83 adg_adim_init(AdgADim *adim)
85 AdgADimPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(adim, ADG_TYPE_ADIM,
86 AdgADimPrivate);
88 priv->extension1.status = CAIRO_STATUS_SUCCESS;
89 priv->extension1.data = NULL;
90 priv->extension1.num_data = 4;
92 priv->extension2.status = CAIRO_STATUS_SUCCESS;
93 priv->extension2.data = NULL;
94 priv->extension2.num_data = 4;
96 priv->arrow_path.status = CAIRO_STATUS_SUCCESS;
97 priv->arrow_path.data = NULL;
98 priv->arrow_path.num_data = 4;
100 priv->baseline.status = CAIRO_STATUS_SUCCESS;
101 priv->baseline.data = NULL;
102 priv->baseline.num_data = 4;
104 adim->priv = priv;
107 static void
108 finalize(GObject *object)
110 AdgADimPrivate *priv = ((AdgADim *) object)->priv;
112 g_free(priv->extension1.data);
113 g_free(priv->extension2.data);
114 g_free(priv->arrow_path.data);
115 g_free(priv->baseline.data);
118 static void
119 model_matrix_changed(AdgEntity *entity, AdgMatrix *parent_matrix)
121 ((AdgEntityClass *) PARENT_CLASS)->model_matrix_changed(entity,
122 parent_matrix);
124 /* TODO */
127 static void
128 render(AdgEntity *entity, cairo_t *cr)
130 /* TODO */
133 static gchar *
134 default_quote(AdgDim *dim)
136 /* TODO */
137 return g_strdup("TODO");
143 * adg_adim_new:
145 * Creates a new - unreferenced - angular dimension. You must, at least, define
146 * the reference points with adg_dim_set_ref() and the position reference using
147 * adg_dim_set_pos().
149 * Return value: the new entity
151 AdgEntity *
152 adg_adim_new(void)
154 return (AdgEntity *) g_object_new(ADG_TYPE_ADIM, NULL);