1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009 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.
24 * @short_description: Angular dimensions
26 * The #AdgADim entity represents an angular dimension.
30 #include "adg-adim-private.h"
31 #include "adg-container.h"
42 static void finalize (GObject
*object
);
43 static void model_matrix_changed (AdgEntity
*entity
,
44 AdgMatrix
*parent_matrix
);
45 static void render (AdgEntity
*entity
,
47 static gchar
* default_quote (AdgDim
*dim
);
50 G_DEFINE_TYPE(AdgADim
, adg_adim
, ADG_TYPE_DIM
);
54 adg_adim_class_init(AdgADimClass
*klass
)
56 GObjectClass
*gobject_class
;
57 AdgEntityClass
*entity_class
;
58 AdgDimClass
*dim_class
;
61 gobject_class
= (GObjectClass
*) klass
;
62 entity_class
= (AdgEntityClass
*) klass
;
63 dim_class
= (AdgDimClass
*) klass
;
65 g_type_class_add_private(klass
, sizeof(AdgADimPrivate
));
67 gobject_class
->finalize
= finalize
;
69 entity_class
->model_matrix_changed
= model_matrix_changed
;
70 entity_class
->render
= render
;
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
, ADG_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
*entity_class
= (AdgEntityClass
*) adg_adim_parent_class
;
125 if (entity_class
->model_matrix_changed
!= NULL
)
126 entity_class
->model_matrix_changed(entity
, parent_matrix
);
130 render(AdgEntity
*entity
, cairo_t
*cr
)
136 default_quote(AdgDim
*dim
)
139 return g_strdup("TODO");
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
151 * Return value: the new entity
156 return (AdgEntity
*) g_object_new(ADG_TYPE_ADIM
, NULL
);