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.
32 * All fields are privates and should not be used directly.
33 * Use its public methods instead.
38 #include "adg-adim-private.h"
39 #include "adg-container.h"
50 static void finalize (GObject
*object
);
51 static void model_matrix_changed (AdgEntity
*entity
,
52 AdgMatrix
*parent_matrix
);
53 static void render (AdgEntity
*entity
,
55 static gchar
* default_quote (AdgDim
*dim
);
58 G_DEFINE_TYPE(AdgADim
, adg_adim
, ADG_TYPE_DIM
);
62 adg_adim_class_init(AdgADimClass
*klass
)
64 GObjectClass
*gobject_class
;
65 AdgEntityClass
*entity_class
;
66 AdgDimClass
*dim_class
;
69 gobject_class
= (GObjectClass
*) klass
;
70 entity_class
= (AdgEntityClass
*) klass
;
71 dim_class
= (AdgDimClass
*) klass
;
73 g_type_class_add_private(klass
, sizeof(AdgADimPrivate
));
75 gobject_class
->finalize
= finalize
;
77 entity_class
->model_matrix_changed
= model_matrix_changed
;
78 entity_class
->render
= render
;
80 dim_class
->default_quote
= default_quote
;
82 param
= g_param_spec_double("direction",
84 P_("The inclination angle of the extension lines"),
85 -G_MAXDOUBLE
, G_MAXDOUBLE
, ADG_DIR_RIGHT
,
86 G_PARAM_READWRITE
| G_PARAM_CONSTRUCT
);
87 g_object_class_install_property(gobject_class
, PROP_DIRECTION
, param
);
91 adg_adim_init(AdgADim
*adim
)
93 AdgADimPrivate
*data
= G_TYPE_INSTANCE_GET_PRIVATE(adim
, ADG_TYPE_ADIM
,
96 data
->extension1
.status
= CAIRO_STATUS_SUCCESS
;
97 data
->extension1
.data
= NULL
;
98 data
->extension1
.num_data
= 4;
100 data
->extension2
.status
= CAIRO_STATUS_SUCCESS
;
101 data
->extension2
.data
= NULL
;
102 data
->extension2
.num_data
= 4;
104 data
->arrow_path
.status
= CAIRO_STATUS_SUCCESS
;
105 data
->arrow_path
.data
= NULL
;
106 data
->arrow_path
.num_data
= 4;
108 data
->baseline
.status
= CAIRO_STATUS_SUCCESS
;
109 data
->baseline
.data
= NULL
;
110 data
->baseline
.num_data
= 4;
116 finalize(GObject
*object
)
118 AdgADimPrivate
*data
= ((AdgADim
*) object
)->data
;
120 g_free(data
->extension1
.data
);
121 g_free(data
->extension2
.data
);
122 g_free(data
->arrow_path
.data
);
123 g_free(data
->baseline
.data
);
127 model_matrix_changed(AdgEntity
*entity
, AdgMatrix
*parent_matrix
)
129 AdgEntityClass
*entity_class
= (AdgEntityClass
*) adg_adim_parent_class
;
133 if (entity_class
->model_matrix_changed
!= NULL
)
134 entity_class
->model_matrix_changed(entity
, parent_matrix
);
138 render(AdgEntity
*entity
, cairo_t
*cr
)
144 default_quote(AdgDim
*dim
)
147 return g_strdup("TODO");
155 * Creates a new - unreferenced - angular dimension. You must, at least, define
156 * the reference points with adg_dim_set_ref() and the position reference using
159 * Return value: the new entity
164 return (AdgEntity
*) g_object_new(ADG_TYPE_ADIM
, NULL
);