Implemented stlye slots on AdgArrowStyle
[adg.git] / adg / adg-adim.c
blob6c460a5a14cc943dc07b2015afb690cf71f0994c
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.
21 /**
22 * SECTION:adim
23 * @title: AdgADim
24 * @short_description: Angular dimensions
26 * The #AdgADim entity represents an angular dimension.
29 #include "adg-adim.h"
30 #include "adg-adim-private.h"
31 #include "adg-container.h"
32 #include "adg-util.h"
33 #include "adg-intl.h"
35 #include <gcontainer/gcontainer.h>
37 #define PARENT_CLASS ((AdgDimClass *) adg_adim_parent_class)
40 enum
42 PROP_0,
43 PROP_DIRECTION
47 static void finalize (GObject *object);
48 static void model_matrix_changed (AdgEntity *entity,
49 AdgMatrix *parent_matrix);
50 static void render (AdgEntity *entity,
51 cairo_t *cr);
52 static gchar * default_quote (AdgDim *dim);
55 G_DEFINE_TYPE (AdgADim, adg_adim, ADG_TYPE_DIM);
58 static void
59 adg_adim_class_init (AdgADimClass *klass)
61 GObjectClass *gobject_class;
62 AdgEntityClass *entity_class;
63 AdgDimClass *dim_class;
64 GParamSpec *param;
66 gobject_class = (GObjectClass *) klass;
67 entity_class = (AdgEntityClass *) klass;
68 dim_class = (AdgDimClass *) klass;
70 g_type_class_add_private (klass, sizeof (AdgADimPrivate));
72 gobject_class->finalize = finalize;
74 entity_class->model_matrix_changed = model_matrix_changed;
76 dim_class->default_quote = default_quote;
78 param = g_param_spec_double ("direction",
79 P_("Direction"),
80 P_("The inclination angle of the extension lines"),
81 -G_MAXDOUBLE, G_MAXDOUBLE, CPML_DIR_RIGHT,
82 G_PARAM_READWRITE|G_PARAM_CONSTRUCT);
83 g_object_class_install_property (gobject_class, PROP_DIRECTION, param);
86 static void
87 adg_adim_init (AdgADim *adim)
89 AdgADimPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (adim, ADG_TYPE_ADIM,
90 AdgADimPrivate);
92 priv->extension1.status = CAIRO_STATUS_SUCCESS;
93 priv->extension1.data = NULL;
94 priv->extension1.num_data = 4;
96 priv->extension2.status = CAIRO_STATUS_SUCCESS;
97 priv->extension2.data = NULL;
98 priv->extension2.num_data = 4;
100 priv->arrow_path.status = CAIRO_STATUS_SUCCESS;
101 priv->arrow_path.data = NULL;
102 priv->arrow_path.num_data = 4;
104 priv->baseline.status = CAIRO_STATUS_SUCCESS;
105 priv->baseline.data = NULL;
106 priv->baseline.num_data = 4;
108 adim->priv = priv;
111 static void
112 finalize (GObject *object)
114 AdgADimPrivate *priv = ((AdgADim *) object)->priv;
116 g_free (priv->extension1.data);
117 g_free (priv->extension2.data);
118 g_free (priv->arrow_path.data);
119 g_free (priv->baseline.data);
122 static void
123 model_matrix_changed (AdgEntity *entity,
124 AdgMatrix *parent_matrix)
126 ((AdgEntityClass *) PARENT_CLASS)->model_matrix_changed (entity, parent_matrix);
128 /* TODO */
131 static void
132 render (AdgEntity *entity,
133 cairo_t *cr)
135 /* TODO */
138 static gchar *
139 default_quote (AdgDim *dim)
141 /* TODO */
142 return g_strdup ("TODO");
148 * adg_adim_new:
150 * Creates a new - unreferenced - angular dimension. You must, at least, define
151 * the reference points with adg_dim_set_ref() and the position reference using
152 * adg_dim_set_pos().
154 * Return value: the new entity
156 AdgEntity *
157 adg_adim_new (void)
159 return (AdgEntity *) g_object_new (ADG_TYPE_ADIM, NULL);