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.
24 * @short_description: Angular dimensions
26 * The #AdgADim entity represents an angular dimension.
30 #include "adg-adim-private.h"
31 #include "adg-container.h"
35 #include <gcontainer/gcontainer.h>
37 #define PARENT_CLASS ((AdgDimClass *) adg_adim_parent_class)
47 static void finalize (GObject
*object
);
48 static void model_matrix_changed (AdgEntity
*entity
,
49 AdgMatrix
*parent_matrix
);
50 static void render (AdgEntity
*entity
,
52 static gchar
* default_quote (AdgDim
*dim
);
55 G_DEFINE_TYPE (AdgADim
, adg_adim
, ADG_TYPE_DIM
);
59 adg_adim_class_init (AdgADimClass
*klass
)
61 GObjectClass
*gobject_class
;
62 AdgEntityClass
*entity_class
;
63 AdgDimClass
*dim_class
;
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",
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
);
88 adg_adim_init (AdgADim
*adim
)
90 AdgADimPrivate
*priv
= G_TYPE_INSTANCE_GET_PRIVATE (adim
, ADG_TYPE_ADIM
,
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;
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
);
124 model_matrix_changed (AdgEntity
*entity
,
125 AdgMatrix
*parent_matrix
)
127 ((AdgEntityClass
*) PARENT_CLASS
)->model_matrix_changed (entity
, parent_matrix
);
133 render (AdgEntity
*entity
,
140 default_quote (AdgDim
*dim
)
143 return g_strdup ("TODO");
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
155 * Return value: the new entity
160 return (AdgEntity
*) g_object_new (ADG_TYPE_ADIM
, NULL
);