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.
23 * @short_description: Angular dimensions
25 * The #AdgADim entity represents an angular dimension.
29 #include "adg-adim-private.h"
30 #include "adg-container.h"
34 #define PARENT_CLASS ((AdgDimClass *) adg_adim_parent_class)
43 static void finalize (GObject
*object
);
44 static void model_matrix_changed (AdgEntity
*entity
,
45 AdgMatrix
*parent_matrix
);
46 static void render (AdgEntity
*entity
,
48 static gchar
* default_quote (AdgDim
*dim
);
51 G_DEFINE_TYPE(AdgADim
, adg_adim
, ADG_TYPE_DIM
);
55 adg_adim_class_init(AdgADimClass
*klass
)
57 GObjectClass
*gobject_class
;
58 AdgEntityClass
*entity_class
;
59 AdgDimClass
*dim_class
;
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",
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
);
83 adg_adim_init(AdgADim
*adim
)
85 AdgADimPrivate
*priv
= G_TYPE_INSTANCE_GET_PRIVATE(adim
, ADG_TYPE_ADIM
,
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;
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
);
119 model_matrix_changed(AdgEntity
*entity
, AdgMatrix
*parent_matrix
)
121 ((AdgEntityClass
*) PARENT_CLASS
)->model_matrix_changed(entity
,
128 render(AdgEntity
*entity
, cairo_t
*cr
)
134 default_quote(AdgDim
*dim
)
137 return g_strdup("TODO");
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
149 * Return value: the new entity
154 return (AdgEntity
*) g_object_new(ADG_TYPE_ADIM
, NULL
);