Tab expansion in all the source files
[adg.git] / adg / adg-adim.c
blobed83e09cbd93631f69047a60c2e9b1c6a7f0626d
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 Library 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 * Library 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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, 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 #include <gcontainer/gcontainer.h>
36 #define PARENT_CLASS ((AdgDimClass *) adg_adim_parent_class)
39 enum {
40 PROP_0,
41 PROP_DIRECTION
45 static void finalize (GObject *object);
46 static void model_matrix_changed (AdgEntity *entity,
47 AdgMatrix *parent_matrix);
48 static void render (AdgEntity *entity,
49 cairo_t *cr);
50 static gchar * default_quote (AdgDim *dim);
53 G_DEFINE_TYPE(AdgADim, adg_adim, ADG_TYPE_DIM);
56 static void
57 adg_adim_class_init(AdgADimClass *klass)
59 GObjectClass *gobject_class;
60 AdgEntityClass *entity_class;
61 AdgDimClass *dim_class;
62 GParamSpec *param;
64 gobject_class = (GObjectClass *) klass;
65 entity_class = (AdgEntityClass *) klass;
66 dim_class = (AdgDimClass *) klass;
68 g_type_class_add_private(klass, sizeof(AdgADimPrivate));
70 gobject_class->finalize = finalize;
72 entity_class->model_matrix_changed = model_matrix_changed;
74 dim_class->default_quote = default_quote;
76 param = g_param_spec_double("direction",
77 P_("Direction"),
78 P_("The inclination angle of the extension lines"),
79 -G_MAXDOUBLE, G_MAXDOUBLE, CPML_DIR_RIGHT,
80 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
81 g_object_class_install_property(gobject_class, PROP_DIRECTION, param);
84 static void
85 adg_adim_init(AdgADim *adim)
87 AdgADimPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE(adim, ADG_TYPE_ADIM,
88 AdgADimPrivate);
90 priv->extension1.status = CAIRO_STATUS_SUCCESS;
91 priv->extension1.data = NULL;
92 priv->extension1.num_data = 4;
94 priv->extension2.status = CAIRO_STATUS_SUCCESS;
95 priv->extension2.data = NULL;
96 priv->extension2.num_data = 4;
98 priv->arrow_path.status = CAIRO_STATUS_SUCCESS;
99 priv->arrow_path.data = NULL;
100 priv->arrow_path.num_data = 4;
102 priv->baseline.status = CAIRO_STATUS_SUCCESS;
103 priv->baseline.data = NULL;
104 priv->baseline.num_data = 4;
106 adim->priv = priv;
109 static void
110 finalize(GObject *object)
112 AdgADimPrivate *priv = ((AdgADim *) object)->priv;
114 g_free(priv->extension1.data);
115 g_free(priv->extension2.data);
116 g_free(priv->arrow_path.data);
117 g_free(priv->baseline.data);
120 static void
121 model_matrix_changed(AdgEntity *entity, AdgMatrix *parent_matrix)
123 ((AdgEntityClass *) PARENT_CLASS)->model_matrix_changed(entity,
124 parent_matrix);
126 /* TODO */
129 static void
130 render(AdgEntity *entity, cairo_t *cr)
132 /* TODO */
135 static gchar *
136 default_quote(AdgDim *dim)
138 /* TODO */
139 return g_strdup("TODO");
145 * adg_adim_new:
147 * Creates a new - unreferenced - angular dimension. You must, at least, define
148 * the reference points with adg_dim_set_ref() and the position reference using
149 * adg_dim_set_pos().
151 * Return value: the new entity
153 AdgEntity *
154 adg_adim_new(void)
156 return (AdgEntity *) g_object_new(ADG_TYPE_ADIM, NULL);