[docs] Autogenerating cpml-sections.txt
[adg.git] / adg / adg-ldim.c
blobc82a6cfdd1911cc32fb947d5749b67cce527c34a
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.
21 /**
22 * SECTION:adg-ldim
23 * @short_description: Linear dimensions
25 * The #AdgLDim entity represents a linear dimension.
26 **/
28 /**
29 * AdgLDim:
31 * All fields are private and should not be used directly.
32 * Use its public methods instead.
33 **/
36 #include "adg-ldim.h"
37 #include "adg-ldim-private.h"
38 #include "adg-dim-style.h"
39 #include "adg-intl.h"
41 #define PARENT_OBJECT_CLASS ((GObjectClass *) adg_ldim_parent_class)
42 #define PARENT_ENTITY_CLASS ((AdgEntityClass *) adg_ldim_parent_class)
45 enum {
46 PROP_0,
47 PROP_DIRECTION,
48 PROP_HAS_EXTENSION1,
49 PROP_HAS_EXTENSION2
53 static void dispose (GObject *object);
54 static void get_property (GObject *object,
55 guint param_id,
56 GValue *value,
57 GParamSpec *pspec);
58 static void set_property (GObject *object,
59 guint param_id,
60 const GValue *value,
61 GParamSpec *pspec);
62 static void local_changed (AdgEntity *entity);
63 static void invalidate (AdgEntity *entity);
64 static void arrange (AdgEntity *entity);
65 static void render (AdgEntity *entity,
66 cairo_t *cr);
67 static gchar * default_value (AdgDim *dim);
68 static void update_geometry (AdgLDim *ldim);
69 static void update_shift (AdgLDim *ldim);
70 static void update_entities (AdgLDim *ldim);
71 static gboolean choose_outside (AdgLDim *ldim);
72 static void unset_trail (AdgLDim *ldim);
73 static void dispose_markers (AdgLDim *ldim);
74 static CpmlPath * trail_callback (AdgTrail *trail,
75 gpointer user_data);
78 G_DEFINE_TYPE(AdgLDim, adg_ldim, ADG_TYPE_DIM);
81 static void
82 adg_ldim_class_init(AdgLDimClass *klass)
84 GObjectClass *gobject_class;
85 AdgEntityClass *entity_class;
86 AdgDimClass *dim_class;
87 GParamSpec *param;
89 gobject_class = (GObjectClass *) klass;
90 entity_class = (AdgEntityClass *) klass;
91 dim_class = (AdgDimClass *) klass;
93 g_type_class_add_private(klass, sizeof(AdgLDimPrivate));
95 gobject_class->dispose = dispose;
96 gobject_class->get_property = get_property;
97 gobject_class->set_property = set_property;
99 entity_class->local_changed = local_changed;
100 entity_class->invalidate = invalidate;
101 entity_class->arrange = arrange;
102 entity_class->render = render;
104 dim_class->default_value = default_value;
106 param = g_param_spec_double("direction",
107 P_("Direction"),
108 P_("The inclination angle of the extension lines"),
109 -G_MAXDOUBLE, G_MAXDOUBLE, ADG_DIR_RIGHT,
110 G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
111 g_object_class_install_property(gobject_class, PROP_DIRECTION, param);
113 param = g_param_spec_boolean("has-extension1",
114 P_("Has First Extension Line flag"),
115 P_("Show (TRUE) or hide (FALSE) the first extension line"),
116 TRUE, G_PARAM_READWRITE);
117 g_object_class_install_property(gobject_class, PROP_HAS_EXTENSION1, param);
119 param = g_param_spec_boolean("has-extension2",
120 P_("Has Second Extension Line flag"),
121 P_("Show (TRUE) or hide (FALSE) the second extension line"),
122 TRUE, G_PARAM_READWRITE);
123 g_object_class_install_property(gobject_class, PROP_HAS_EXTENSION2, param);
126 static void
127 adg_ldim_init(AdgLDim *ldim)
129 AdgLDimPrivate *data;
130 cairo_path_data_t move_to, line_to;
132 data = G_TYPE_INSTANCE_GET_PRIVATE(ldim, ADG_TYPE_LDIM, AdgLDimPrivate);
133 move_to.header.type = CAIRO_PATH_MOVE_TO;
134 move_to.header.length = 2;
135 line_to.header.type = CAIRO_PATH_LINE_TO;
136 line_to.header.length = 2;
138 data->direction = 0;
139 data->has_extension1 = TRUE;
140 data->has_extension2 = TRUE;
142 data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA;
143 data->cpml.path.data = data->cpml.data;
144 data->cpml.path.num_data = G_N_ELEMENTS(data->cpml.data);
145 data->cpml.path.data[0] = move_to;
146 data->cpml.path.data[2] = line_to;
147 data->cpml.path.data[4] = move_to;
148 data->cpml.path.data[6] = line_to;
149 data->cpml.path.data[8] = move_to;
150 data->cpml.path.data[10] = line_to;
151 data->cpml.path.data[12] = move_to;
152 data->cpml.path.data[14] = line_to;
153 data->cpml.path.data[16] = move_to;
154 data->cpml.path.data[18] = line_to;
156 data->trail = NULL;
157 data->marker1 = NULL;
158 data->marker2 = NULL;
160 data->geometry.is_arranged = FALSE;
161 data->shift.is_arranged = FALSE;
163 ldim->data = data;
166 static void
167 dispose(GObject *object)
169 dispose_markers((AdgLDim *) object);
171 if (PARENT_OBJECT_CLASS->dispose != NULL)
172 PARENT_OBJECT_CLASS->dispose(object);
175 static void
176 get_property(GObject *object,
177 guint prop_id, GValue *value, GParamSpec *pspec)
179 AdgLDimPrivate *data = ((AdgLDim *) object)->data;
181 switch (prop_id) {
182 case PROP_DIRECTION:
183 g_value_set_double(value, data->direction);
184 break;
185 case PROP_HAS_EXTENSION1:
186 g_value_set_boolean(value, data->has_extension1);
187 break;
188 case PROP_HAS_EXTENSION2:
189 g_value_set_boolean(value, data->has_extension2);
190 break;
191 default:
192 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
193 break;
197 static void
198 set_property(GObject *object,
199 guint prop_id, const GValue *value, GParamSpec *pspec)
201 AdgLDimPrivate *data = ((AdgLDim *) object)->data;
203 switch (prop_id) {
204 case PROP_DIRECTION:
205 data->direction = g_value_get_double(value);
206 break;
207 case PROP_HAS_EXTENSION1:
208 data->has_extension1 = g_value_get_boolean(value);
209 break;
210 case PROP_HAS_EXTENSION2:
211 data->has_extension2 = g_value_get_boolean(value);
212 break;
213 default:
214 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
215 break;
221 * adg_ldim_new:
223 * Creates a new - undefined - linear dimension. You must, at least,
224 * define the reference points with adg_dim_set_ref(), the dimension
225 * direction with adg_ldim_set_direction() and the position reference
226 * using adg_dim_set_pos().
228 * Returns: the newly created linear dimension entity
230 AdgLDim *
231 adg_ldim_new(void)
233 return g_object_new(ADG_TYPE_LDIM, NULL);
237 * adg_ldim_new_full:
238 * @ref1: the first reference point
239 * @ref2: the second reference point
240 * @direction: angle where to extend the dimension
241 * @pos: the position reference
243 * Creates a new linear dimension, specifing all the needed properties in
244 * one shot.
246 * Returns: the newly created linear dimension entity
248 AdgLDim *
249 adg_ldim_new_full(const AdgPair *ref1, const AdgPair *ref2,
250 gdouble direction, const AdgPair *pos)
252 return g_object_new(ADG_TYPE_LDIM, "ref1", ref1, "ref2", ref2,
253 "direction", direction, "pos", pos, NULL);
257 * adg_ldim_new_full_explicit:
258 * @ref1_x: the x coordinate of the first reference point
259 * @ref1_y: the y coordinate of the first reference point
260 * @ref2_x: the x coordinate of the second reference point
261 * @ref2_y: the y coordinate of the second reference point
262 * @direction: angle where to extend the dimension
263 * @pos_x: the x coordinate of the position reference
264 * @pos_y: the y coordinate of the position reference
266 * Wrappes adg_ldim_new_full() with explicit values.
268 * Returns: the newly created linear dimension entity
270 AdgLDim *
271 adg_ldim_new_full_explicit(gdouble ref1_x, gdouble ref1_y,
272 gdouble ref2_x, gdouble ref2_y,
273 gdouble direction, gdouble pos_x, gdouble pos_y)
275 AdgPair ref1;
276 AdgPair ref2;
277 AdgPair pos;
279 ref1.x = ref1_x;
280 ref1.y = ref1_y;
281 ref2.x = ref2_x;
282 ref2.y = ref2_y;
283 pos.x = pos_x;
284 pos.y = pos_y;
286 return adg_ldim_new_full(&ref1, &ref2, direction, &pos);
290 * adg_ldim_get_direction:
291 * @ldim: an #AdgLDim entity
293 * Gets the direction where @ldim will extend.
295 * Returns: the direction angle in radians
297 gdouble
298 adg_ldim_get_direction(AdgLDim *ldim)
300 AdgLDimPrivate *data;
302 g_return_val_if_fail(ADG_IS_LDIM(ldim), 0);
304 data = ldim->data;
306 return data->direction;
310 * adg_ldim_set_direction:
311 * @ldim: an #AdgLDim entity
312 * @direction: an angle value, in radians
314 * Sets the direction angle where to extend @ldim.
316 void
317 adg_ldim_set_direction(AdgLDim *ldim, gdouble direction)
319 AdgLDimPrivate *data;
321 g_return_if_fail(ADG_IS_LDIM(ldim));
323 data = ldim->data;
324 data->direction = direction;
326 g_object_notify((GObject *) ldim, "direction");
330 * adg_ldim_has_extension1:
331 * @ldim: an #AdgLDim entity
333 * Checks if @ldim should render also the first extension line.
335 * Returns: %TRUE on first extension line presents, %FALSE otherwise
337 gboolean
338 adg_ldim_has_extension1(AdgLDim *ldim)
340 AdgLDimPrivate *data;
342 g_return_val_if_fail(ADG_IS_LDIM(ldim), FALSE);
344 data = ldim->data;
346 return data->has_extension1;
350 * adg_ldim_switch_extension1:
351 * @ldim: an #AdgLDim entity
352 * @state: the new state
354 * Shows (if @state is %TRUE) or hide (if @state is %FALSE) the first
355 * extension line of @ldim.
357 void
358 adg_ldim_switch_extension1(AdgLDim *ldim, gboolean state)
360 AdgLDimPrivate *data;
362 g_return_if_fail(ADG_IS_LDIM(ldim));
364 data = ldim->data;
366 data->has_extension1 = state;
367 g_object_notify((GObject *) ldim, "has-extension1");
371 * adg_ldim_has_extension2:
372 * @ldim: an #AdgLDim entity
374 * Checks if @ldim should render also the second extension line.
376 * Returns: %TRUE on first extension line presents, %FALSE otherwise
378 gboolean
379 adg_ldim_has_extension2(AdgLDim *ldim)
381 AdgLDimPrivate *data;
383 g_return_val_if_fail(ADG_IS_LDIM(ldim), FALSE);
385 data = ldim->data;
387 return data->has_extension2;
391 * adg_ldim_switch_extension2:
392 * @ldim: an #AdgLDim entity
393 * @state: the new state
395 * Shows (if @state is %TRUE) or hide (if @state is %FALSE) the second
396 * extension line of @ldim.
398 void
399 adg_ldim_switch_extension2(AdgLDim *ldim, gboolean state)
401 AdgLDimPrivate *data;
403 g_return_if_fail(ADG_IS_LDIM(ldim));
405 data = ldim->data;
407 data->has_extension2 = state;
408 g_object_notify((GObject *) ldim, "has-extension2");
412 static void
413 local_changed(AdgEntity *entity)
415 unset_trail((AdgLDim *) entity);
417 PARENT_ENTITY_CLASS->local_changed(entity);
420 static void
421 invalidate(AdgEntity *entity)
423 AdgLDim *ldim;
424 AdgLDimPrivate *data;
426 ldim = (AdgLDim *) entity;
427 data = ldim->data;
429 dispose_markers(ldim);
430 data->geometry.is_arranged = FALSE;
431 data->shift.is_arranged = FALSE;
432 unset_trail(ldim);
434 if (PARENT_ENTITY_CLASS->invalidate != NULL)
435 PARENT_ENTITY_CLASS->invalidate(entity);
438 static void
439 arrange(AdgEntity *entity)
441 AdgLDim *ldim;
442 AdgDim *dim;
443 AdgLDimPrivate *data;
444 AdgContainer *quote;
445 AdgDimStyle *dim_style;
446 gboolean outside;
447 const AdgMatrix *local;
448 AdgPair ref1, ref2, base1, base2;
449 AdgPair pair;
450 gint n;
452 PARENT_ENTITY_CLASS->arrange(entity);
454 ldim = (AdgLDim *) entity;
455 dim = (AdgDim *) ldim;
456 data = ldim->data;
457 quote = adg_dim_get_quote(dim);
459 update_geometry(ldim);
460 update_shift(ldim);
461 update_entities(ldim);
463 if (data->cpml.path.status == CAIRO_STATUS_SUCCESS) {
464 AdgEntity *quote_entity = (AdgEntity *) quote;
465 adg_entity_set_global_map(quote_entity, &data->quote.global_map);
466 adg_entity_set_local_map(quote_entity, &data->quote.local_map);
467 return;
470 dim_style = adg_dim_get_dim_style(dim);
472 switch (adg_dim_get_outside(dim)) {
473 case ADG_THREE_STATE_OFF:
474 outside = FALSE;
475 break;
476 case ADG_THREE_STATE_ON:
477 outside = TRUE;
478 break;
479 case ADG_THREE_STATE_UNKNOWN:
480 default:
481 outside = choose_outside(ldim);
482 break;
485 local = adg_entity_local_matrix(entity);
486 cpml_pair_copy(&ref1, adg_dim_get_ref1(dim));
487 cpml_pair_copy(&ref2, adg_dim_get_ref2(dim));
488 cpml_pair_copy(&base1, &data->geometry.base1);
489 cpml_pair_copy(&base2, &data->geometry.base2);
491 cpml_pair_transform(&ref1, local);
492 cpml_pair_transform(&ref2, local);
493 cpml_pair_transform(&base1, local);
494 cpml_pair_transform(&base2, local);
496 cpml_pair_add(cpml_pair_copy(&pair, &ref1), &data->shift.from);
497 cpml_pair_to_cairo(&pair, &data->cpml.data[13]);
499 cpml_pair_copy(&pair, &base1);
500 cpml_pair_add(&pair, &data->shift.base);
501 cpml_pair_to_cairo(&pair, &data->cpml.data[1]);
503 cpml_pair_add(&pair, &data->shift.to);
504 cpml_pair_to_cairo(&pair, &data->cpml.data[15]);
506 cpml_pair_add(cpml_pair_copy(&pair, &ref2), &data->shift.from);
507 cpml_pair_to_cairo(&pair, &data->cpml.data[17]);
509 cpml_pair_copy(&pair, &base2);
510 cpml_pair_add(&pair, &data->shift.base);
511 cpml_pair_to_cairo(&pair, &data->cpml.data[3]);
513 cpml_pair_add(&pair, &data->shift.to);
514 cpml_pair_to_cairo(&pair, &data->cpml.data[19]);
516 /* Calculate the outside segments */
517 if (outside) {
518 gdouble beyond;
519 CpmlVector vector;
521 beyond = adg_dim_style_get_beyond(dim_style);
522 cpml_pair_from_cairo(&pair, &data->cpml.data[1]);
524 cpml_pair_from_cairo(&vector, &data->cpml.data[3]);
525 cpml_pair_sub(&vector, &pair);
526 cpml_vector_set_length(&vector, beyond);
528 cpml_pair_from_cairo(&pair, &data->cpml.data[1]);
529 cpml_pair_to_cairo(&pair, &data->cpml.data[5]);
531 cpml_pair_sub(&pair, &vector);
532 cpml_pair_to_cairo(&pair, &data->cpml.data[7]);
534 cpml_pair_from_cairo(&pair, &data->cpml.data[3]);
535 cpml_pair_to_cairo(&pair, &data->cpml.data[11]);
537 cpml_pair_add(&pair, &vector);
538 cpml_pair_to_cairo(&pair, &data->cpml.data[9]);
540 data->cpml.data[2].header.length = 2;
541 data->cpml.data[10].header.length = 2;
542 n = 10;
543 } else {
544 data->cpml.data[2].header.length = 10;
545 n = 2;
548 /* Play with header lengths to show or hide the extension lines */
549 if (data->has_extension1) {
550 data->cpml.data[14].header.length = data->has_extension2 ? 2 : 6;
551 } else {
552 data->cpml.data[n].header.length += 4;
553 if (!data->has_extension2)
554 data->cpml.data[n].header.length += 4;
557 data->cpml.path.status = CAIRO_STATUS_SUCCESS;
559 if (quote != NULL) {
560 /* Update global and local map of the quote container */
561 AdgEntity *quote_entity;
562 gdouble angle;
563 AdgMatrix matrix;
565 quote_entity = (AdgEntity *) quote;
566 angle = adg_dim_quote_angle(dim, data->direction + G_PI_2);
567 adg_matrix_copy(&matrix, local);
568 cairo_matrix_invert(&matrix);
570 pair.x = (data->cpml.data[1].point.x + data->cpml.data[3].point.x) / 2;
571 pair.y = (data->cpml.data[1].point.y + data->cpml.data[3].point.y) / 2;
572 cairo_matrix_transform_point(&matrix, &pair.x, &pair.y);
573 cairo_matrix_init_translate(&matrix, pair.x, pair.y);
574 adg_entity_set_local_map(quote_entity, &matrix);
576 cairo_matrix_init_rotate(&matrix, angle);
577 adg_entity_transform_global_map(quote_entity, &matrix, ADG_TRANSFORM_BEFORE);
579 adg_entity_get_global_map(quote_entity, &data->quote.global_map);
580 adg_entity_get_local_map(quote_entity, &data->quote.local_map);
583 if (data->marker1 != NULL) {
584 adg_marker_set_segment(data->marker1, data->trail, outside ? 2 : 1);
585 adg_entity_local_changed((AdgEntity *) data->marker1);
588 if (data->marker2 != NULL) {
589 adg_marker_set_segment(data->marker2, data->trail, outside ? 3 : 1);
590 adg_entity_local_changed((AdgEntity *) data->marker2);
593 /* TODO: compute the extents */
596 static void
597 render(AdgEntity *entity, cairo_t *cr)
599 AdgLDim *ldim;
600 AdgDim *dim;
601 AdgLDimPrivate *data;
602 AdgDimStyle *dim_style;
603 AdgDress dress;
604 const cairo_path_t *cairo_path;
606 ldim = (AdgLDim *) entity;
607 dim = (AdgDim *) entity;
608 data = ldim->data;
609 dim_style = adg_dim_get_dim_style(dim);
611 dress = adg_dim_style_get_color_dress(dim_style);
612 adg_entity_apply_dress(entity, dress, cr);
614 if (data->marker1 != NULL)
615 adg_entity_render((AdgEntity *) data->marker1, cr);
617 if (data->marker2 != NULL)
618 adg_entity_render((AdgEntity *) data->marker2, cr);
620 adg_entity_render((AdgEntity *) adg_dim_get_quote(dim), cr);
622 dress = adg_dim_style_get_line_dress(dim_style);
623 adg_entity_apply_dress(entity, dress, cr);
625 cairo_path = adg_trail_get_cairo_path(data->trail);
626 cairo_append_path(cr, cairo_path);
627 cairo_stroke(cr);
630 static gchar *
631 default_value(AdgDim *dim)
633 AdgLDim *ldim;
634 AdgLDimPrivate *data;
635 AdgDimStyle *dim_style;
636 const gchar *format;
638 ldim = (AdgLDim *) dim;
639 data = ldim->data;
640 dim_style = adg_dim_get_dim_style(dim);
641 format = adg_dim_style_get_number_format(dim_style);
643 update_geometry(ldim);
645 return g_strdup_printf(format, data->geometry.distance);
648 static void
649 update_geometry(AdgLDim *ldim)
651 AdgLDimPrivate *data;
652 AdgDim *dim;
653 const AdgPair *ref1, *ref2;
654 const AdgPair *pos;
655 CpmlVector baseline, extension;
656 gdouble d, k;
658 data = ldim->data;
660 if (data->geometry.is_arranged)
661 return;
663 dim = (AdgDim *) ldim;
664 ref1 = adg_dim_get_ref1(dim);
665 ref2 = adg_dim_get_ref2(dim);
666 pos = adg_dim_get_pos(dim);
667 cpml_vector_from_angle(&extension, data->direction);
668 cpml_pair_copy(&baseline, &extension);
669 cpml_vector_normal(&baseline);
671 d = extension.y * baseline.x -
672 extension.x * baseline.y;
673 g_return_if_fail(d != 0);
675 k = ((pos->y - ref1->y) * baseline.x -
676 (pos->x - ref1->x) * baseline.y) / d;
677 data->geometry.base1.x = ref1->x + k * extension.x;
678 data->geometry.base1.y = ref1->y + k * extension.y;
680 k = ((pos->y - ref2->y) * baseline.x -
681 (pos->x - ref2->x) * baseline.y) / d;
682 data->geometry.base2.x = ref2->x + k * extension.x;
683 data->geometry.base2.y = ref2->y + k * extension.y;
685 data->geometry.distance = cpml_pair_distance(&data->geometry.base1,
686 &data->geometry.base2);
688 data->geometry.is_arranged = TRUE;
691 static void
692 update_shift(AdgLDim *ldim)
694 AdgLDimPrivate *data;
695 AdgDimStyle *dim_style;
696 gdouble from_offset, to_offset;
697 gdouble baseline_spacing, level;
698 CpmlVector vector;
700 data = ldim->data;
702 if (data->shift.is_arranged)
703 return;
705 dim_style = adg_dim_get_dim_style((AdgDim *) ldim);
706 from_offset = adg_dim_style_get_from_offset(dim_style);
707 to_offset = adg_dim_style_get_to_offset(dim_style);
708 baseline_spacing = adg_dim_style_get_baseline_spacing(dim_style);
709 level = adg_dim_get_level((AdgDim *) ldim);
711 cpml_vector_from_angle(&vector, data->direction);
713 cpml_vector_set_length(&vector, from_offset);
714 cpml_pair_copy(&data->shift.from, &vector);
716 cpml_vector_set_length(&vector, to_offset);
717 cpml_pair_copy(&data->shift.to, &vector);
719 cpml_vector_set_length(&vector, level * baseline_spacing);
720 cpml_pair_copy(&data->shift.base, &vector);
722 data->shift.is_arranged = TRUE;
725 static void
726 update_entities(AdgLDim *ldim)
728 AdgLDimPrivate *data;
729 AdgDimStyle *dim_style;
731 data = ldim->data;
732 dim_style = adg_dim_get_dim_style((AdgDim *) ldim);
734 if (data->trail == NULL)
735 data->trail = adg_trail_new(trail_callback, ldim);
737 if (data->marker1 == NULL)
738 data->marker1 = adg_dim_style_marker1_new(dim_style);
740 if (data->marker2 == NULL)
741 data->marker2 = adg_dim_style_marker2_new(dim_style);
744 static gboolean
745 choose_outside(AdgLDim *ldim)
747 AdgLDimPrivate *data;
748 AdgContainer *quote;
749 const AdgMatrix *local;
750 CpmlExtents extents;
751 gdouble marker1, marker2;
752 gdouble needed, available;
754 data = ldim->data;
755 quote = adg_dim_get_quote((AdgDim *) ldim);
756 local = adg_entity_local_matrix((AdgEntity *) ldim);
757 adg_entity_get_extents((AdgEntity *) quote, &extents);
758 marker1 = data->marker1 == NULL ? 0 : adg_marker_get_size(data->marker1);
759 marker2 = data->marker2 == NULL ? 0 : adg_marker_get_size(data->marker2);
761 needed = extents.size.x + marker1 + marker2;
762 available = data->geometry.distance * local->xx;
764 return needed > available;
767 static void
768 unset_trail(AdgLDim *ldim)
770 AdgLDimPrivate *data = ldim->data;
772 if (data->trail != NULL)
773 adg_model_clear((AdgModel *) data->trail);
775 data->cpml.path.status = CAIRO_STATUS_INVALID_PATH_DATA;
778 static void
779 dispose_markers(AdgLDim *ldim)
781 AdgLDimPrivate *data = ldim->data;
783 if (data->trail != NULL) {
784 g_object_unref(data->trail);
785 data->trail = NULL;
788 if (data->marker1 != NULL) {
789 g_object_unref(data->marker1);
790 data->marker1 = NULL;
793 if (data->marker2 != NULL) {
794 g_object_unref(data->marker2);
795 data->marker2 = NULL;
799 static CpmlPath *
800 trail_callback(AdgTrail *trail, gpointer user_data)
802 AdgLDim *ldim;
803 AdgLDimPrivate *data;
805 ldim = (AdgLDim *) user_data;
806 data = ldim->data;
808 return &data->cpml.path;