Implemented adg_line_style_new()
[adg.git] / adg / adg-adim.c
blob3806d899f203389df62b73ebd446de0971243b6a
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);
87 static void
88 adg_adim_init (AdgADim *adim)
90 AdgADimPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (adim, ADG_TYPE_ADIM,
91 AdgADimPrivate);
93 priv->extension1.status = CAIRO_STATUS_SUCCESS;
94 priv->extension1.data = NULL;
95 priv->extension1.num_data = 4;
97 priv->extension2.status = CAIRO_STATUS_SUCCESS;
98 priv->extension2.data = NULL;
99 priv->extension2.num_data = 4;
101 priv->arrow_path.status = CAIRO_STATUS_SUCCESS;
102 priv->arrow_path.data = NULL;
103 priv->arrow_path.num_data = 4;
105 priv->baseline.status = CAIRO_STATUS_SUCCESS;
106 priv->baseline.data = NULL;
107 priv->baseline.num_data = 4;
109 adim->priv = priv;
112 static void
113 finalize (GObject *object)
115 AdgADimPrivate *priv = ((AdgADim *) object)->priv;
117 g_free (priv->extension1.data);
118 g_free (priv->extension2.data);
119 g_free (priv->arrow_path.data);
120 g_free (priv->baseline.data);
123 static void
124 model_matrix_changed (AdgEntity *entity,
125 AdgMatrix *parent_matrix)
127 ((AdgEntityClass *) PARENT_CLASS)->model_matrix_changed (entity, parent_matrix);
129 /* TODO */
132 static void
133 render (AdgEntity *entity,
134 cairo_t *cr)
136 /* TODO */
139 static gchar *
140 default_quote (AdgDim *dim)
142 /* TODO */
143 return g_strdup ("TODO");
149 * adg_adim_new:
151 * Creates a new - unreferenced - angular dimension. You must, at least, define
152 * the reference points with adg_dim_set_ref() and the position reference using
153 * adg_dim_set_pos().
155 * Return value: the new entity
157 AdgEntity *
158 adg_adim_new (void)
160 return (AdgEntity *) g_object_new (ADG_TYPE_ADIM, NULL);