1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009,2010,2011 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.
22 * SECTION:adg-dim-style
23 * @short_description: Dimension style related stuff
25 * Contains parameters on how to build dimensions such as the different font
26 * styles (for value and limits), line style, offsets of the various
27 * dimension components etc...
33 * All fields are private and should not be used directly.
34 * Use its public methods instead.
38 #include "adg-internal.h"
39 #include "adg-style.h"
40 #include "adg-font-style.h"
41 #include "adg-line-style.h"
42 #include "adg-dress.h"
43 #include "adg-dress-builtins.h"
44 #include "adg-model.h"
45 #include "adg-trail.h"
46 #include "adg-marker.h"
48 #include "adg-dim-style.h"
49 #include "adg-dim-style-private.h"
52 G_DEFINE_TYPE(AdgDimStyle
, adg_dim_style
, ADG_TYPE_STYLE
)
66 PROP_BASELINE_SPACING
,
75 static void _adg_finalize (GObject
*object
);
76 static void _adg_get_property (GObject
*object
,
80 static void _adg_set_property (GObject
*object
,
84 static void _adg_apply (AdgStyle
*style
,
87 static AdgMarker
* _adg_marker_new (const AdgMarkerData
89 static void _adg_set_marker (AdgMarkerData
*marker_data
,
91 static void _adg_free_marker (AdgMarkerData
*marker_data
);
95 adg_dim_style_class_init(AdgDimStyleClass
*klass
)
97 GObjectClass
*gobject_class
;
98 AdgStyleClass
*style_class
;
101 gobject_class
= (GObjectClass
*) klass
;
102 style_class
= (AdgStyleClass
*) klass
;
104 g_type_class_add_private(klass
, sizeof(AdgDimStylePrivate
));
106 gobject_class
->finalize
= _adg_finalize
;
107 gobject_class
->get_property
= _adg_get_property
;
108 gobject_class
->set_property
= _adg_set_property
;
110 style_class
->apply
= _adg_apply
;
112 param
= g_param_spec_object("marker1",
114 P_("The template entity to use as first marker"),
117 g_object_class_install_property(gobject_class
, PROP_MARKER1
, param
);
119 param
= g_param_spec_object("marker2",
121 P_("The template entity to use as second marker"),
124 g_object_class_install_property(gobject_class
, PROP_MARKER2
, param
);
126 param
= adg_param_spec_dress("color-dress",
128 P_("Color dress for the whole dimension"),
129 ADG_DRESS_COLOR_DIMENSION
,
131 g_object_class_install_property(gobject_class
, PROP_COLOR_DRESS
, param
);
133 param
= adg_param_spec_dress("value-dress",
135 P_("Font dress for the nominal value of the dimension"),
136 ADG_DRESS_FONT_QUOTE_TEXT
,
138 g_object_class_install_property(gobject_class
, PROP_VALUE_DRESS
, param
);
140 param
= adg_param_spec_dress("min-dress",
141 P_("Minimum Limit Dress"),
142 P_("Font dress for the lower limit value"),
143 ADG_DRESS_FONT_QUOTE_ANNOTATION
,
145 g_object_class_install_property(gobject_class
, PROP_MIN_DRESS
, param
);
147 param
= adg_param_spec_dress("max-dress",
148 P_("Maximum Limit Dress"),
149 P_("Font dress for the upper limit value"),
150 ADG_DRESS_FONT_QUOTE_ANNOTATION
,
152 g_object_class_install_property(gobject_class
, PROP_MAX_DRESS
, param
);
154 param
= adg_param_spec_dress("line-dress",
156 P_("Line dress for the baseline and the extension lines"),
157 ADG_DRESS_LINE_DIMENSION
,
159 g_object_class_install_property(gobject_class
, PROP_LINE_DRESS
, param
);
161 param
= g_param_spec_double("from-offset",
163 P_("Offset (in global space) of the extension lines from the path to the quote"),
166 g_object_class_install_property(gobject_class
, PROP_FROM_OFFSET
, param
);
168 param
= g_param_spec_double("to-offset",
170 P_("How many extend (in global space) the extension lines after hitting the baseline"),
173 g_object_class_install_property(gobject_class
, PROP_TO_OFFSET
, param
);
175 param
= g_param_spec_double("beyond",
177 P_("How much the baseline should be extended (in global space) beyond the extension lines on dimensions with outside markers"),
180 g_object_class_install_property(gobject_class
, PROP_BEYOND
, param
);
182 param
= g_param_spec_double("baseline-spacing",
183 P_("Baseline Spacing"),
184 P_("Distance between two consecutive baselines while stacking dimensions"),
187 g_object_class_install_property(gobject_class
, PROP_BASELINE_SPACING
, param
);
189 param
= g_param_spec_double("limits-spacing",
190 P_("Limits Spacing"),
191 P_("Distance between limits/tolerances"),
194 g_object_class_install_property(gobject_class
, PROP_LIMITS_SPACING
, param
);
196 param
= g_param_spec_boxed("quote-shift",
198 P_("Used to specify a smooth displacement (in global space) of the quote by taking as reference the perfect compact position (the middle of the baseline on common linear dimension, for instance)"),
201 g_object_class_install_property(gobject_class
, PROP_QUOTE_SHIFT
, param
);
203 param
= g_param_spec_boxed("limits-shift",
205 P_("Used to specify a smooth displacement (in global space) for the limits/tolerances by taking as reference the perfect compact position"),
208 g_object_class_install_property(gobject_class
, PROP_LIMITS_SHIFT
, param
);
210 param
= g_param_spec_string("number-format",
212 P_("The format (in printf style) of the numeric component of the basic value"),
215 g_object_class_install_property(gobject_class
, PROP_NUMBER_FORMAT
, param
);
217 param
= g_param_spec_string("number-tag",
219 P_("The tag to substitute inside the value template string"),
222 g_object_class_install_property(gobject_class
, PROP_NUMBER_TAG
, param
);
226 adg_dim_style_init(AdgDimStyle
*dim_style
)
228 AdgDimStylePrivate
*data
= G_TYPE_INSTANCE_GET_PRIVATE(dim_style
,
232 data
->marker1
.type
= 0;
233 data
->marker1
.n_parameters
= 0;
234 data
->marker1
.parameters
= NULL
;
235 data
->marker2
.type
= 0;
236 data
->marker2
.n_parameters
= 0;
237 data
->marker2
.parameters
= NULL
;
238 data
->color_dress
= ADG_DRESS_COLOR_DIMENSION
;
239 data
->value_dress
= ADG_DRESS_FONT_QUOTE_TEXT
;
240 data
->min_dress
= ADG_DRESS_FONT_QUOTE_ANNOTATION
;
241 data
->max_dress
= ADG_DRESS_FONT_QUOTE_ANNOTATION
;
242 data
->line_dress
= ADG_DRESS_LINE_DIMENSION
;
243 data
->marker_dress
= ADG_DRESS_UNDEFINED
;
244 data
->from_offset
= 6;
247 data
->baseline_spacing
= 32;
248 data
->limits_spacing
= 0;
249 data
->quote_shift
.x
= 4;
250 data
->quote_shift
.y
= -1;
251 data
->limits_shift
.x
= +2;
252 data
->limits_shift
.y
= +2;
253 data
->number_format
= g_strdup("%-.7g");
254 data
->number_tag
= g_strdup("<>");
256 dim_style
->data
= data
;
260 _adg_finalize(GObject
*object
)
262 AdgDimStylePrivate
*data
= ((AdgDimStyle
*) object
)->data
;
264 _adg_free_marker(&data
->marker1
);
265 _adg_free_marker(&data
->marker2
);
267 g_free(data
->number_format
);
268 data
->number_format
= NULL
;
270 g_free(data
->number_tag
);
271 data
->number_tag
= NULL
;
275 _adg_get_property(GObject
*object
, guint prop_id
,
276 GValue
*value
, GParamSpec
*pspec
)
278 AdgDimStylePrivate
*data
= ((AdgDimStyle
*) object
)->data
;
281 case PROP_COLOR_DRESS
:
282 g_value_set_int(value
, data
->color_dress
);
284 case PROP_VALUE_DRESS
:
285 g_value_set_int(value
, data
->value_dress
);
288 g_value_set_int(value
, data
->min_dress
);
291 g_value_set_int(value
, data
->max_dress
);
293 case PROP_LINE_DRESS
:
294 g_value_set_int(value
, data
->line_dress
);
296 case PROP_FROM_OFFSET
:
297 g_value_set_double(value
, data
->from_offset
);
300 g_value_set_double(value
, data
->to_offset
);
303 g_value_set_double(value
, data
->beyond
);
305 case PROP_BASELINE_SPACING
:
306 g_value_set_double(value
, data
->baseline_spacing
);
308 case PROP_LIMITS_SPACING
:
309 g_value_set_double(value
, data
->limits_spacing
);
311 case PROP_QUOTE_SHIFT
:
312 g_value_set_boxed(value
, &data
->quote_shift
);
314 case PROP_LIMITS_SHIFT
:
315 g_value_set_boxed(value
, &data
->limits_shift
);
317 case PROP_NUMBER_FORMAT
:
318 g_value_set_string(value
, data
->number_format
);
320 case PROP_NUMBER_TAG
:
321 g_value_set_string(value
, data
->number_tag
);
324 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
330 _adg_set_property(GObject
*object
, guint prop_id
,
331 const GValue
*value
, GParamSpec
*pspec
)
333 AdgDimStyle
*dim_style
;
334 AdgDimStylePrivate
*data
;
336 dim_style
= (AdgDimStyle
*) object
;
337 data
= dim_style
->data
;
341 _adg_set_marker(&data
->marker1
, g_value_get_object(value
));
344 _adg_set_marker(&data
->marker2
, g_value_get_object(value
));
346 case PROP_COLOR_DRESS
:
347 data
->color_dress
= g_value_get_int(value
);
349 case PROP_VALUE_DRESS
:
350 data
->value_dress
= g_value_get_int(value
);
353 data
->min_dress
= g_value_get_int(value
);
356 data
->max_dress
= g_value_get_int(value
);
358 case PROP_LINE_DRESS
:
359 data
->line_dress
= g_value_get_int(value
);
361 case PROP_FROM_OFFSET
:
362 data
->from_offset
= g_value_get_double(value
);
365 data
->to_offset
= g_value_get_double(value
);
368 data
->beyond
= g_value_get_double(value
);
370 case PROP_BASELINE_SPACING
:
371 data
->baseline_spacing
= g_value_get_double(value
);
373 case PROP_LIMITS_SPACING
:
374 data
->limits_spacing
= g_value_get_double(value
);
376 case PROP_QUOTE_SHIFT
:
377 adg_pair_copy(&data
->quote_shift
, g_value_get_boxed(value
));
379 case PROP_LIMITS_SHIFT
:
380 adg_pair_copy(&data
->limits_shift
, g_value_get_boxed(value
));
382 case PROP_NUMBER_FORMAT
:
383 g_free(data
->number_format
);
384 data
->number_format
= g_value_dup_string(value
);
386 case PROP_NUMBER_TAG
:
387 g_free(data
->number_tag
);
388 data
->number_tag
= g_value_dup_string(value
);
391 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
400 * Constructs a new empty dimension style initialized with default params.
402 * Returns: a newly created dimension style
405 adg_dim_style_new(void)
407 return g_object_new(ADG_TYPE_DIM_STYLE
, NULL
);
411 * adg_dim_style_set_marker1:
412 * @dim_style: an #AdgStyle
413 * @marker: an #AdgMarker derived entity
415 * Uses @marker as entity template to generate a new marker entity
416 * when a call to adg_dim_style_marker1_new() is made. It is allowed
417 * to pass %NULL as @marker, in which case the template data of the
418 * first marker are unset.
420 * This method duplicates internally the property values of @marker,
421 * so any further change to @marker does not affect @dim_style anymore.
422 * This also means @marker could be destroyed without problems after
423 * this call because @dim_style uses only its property values and does
424 * not add any references to @marker.
427 adg_dim_style_set_marker1(AdgDimStyle
*dim_style
, AdgMarker
*marker
)
429 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
430 g_object_set(dim_style
, "marker1", marker
, NULL
);
434 * adg_dim_style_marker1_new:
435 * @dim_style: an #AdgDimStyle
437 * Creates a new marker entity by cloning the #AdgMarker:marker1
438 * object. The returned entity should be unreferenced with
439 * g_object_unref() when no longer needed.
441 * Returns: a newly created marker or %NULL if the #AdgDimStyle:marker1
442 * property is not set or on errors
445 adg_dim_style_marker1_new(AdgDimStyle
*dim_style
)
447 AdgDimStylePrivate
*data
;
449 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
451 data
= dim_style
->data
;
453 return _adg_marker_new(&data
->marker1
);
457 * adg_dim_style_set_marker2:
458 * @dim_style: an #AdgStyle
459 * @marker: an #AdgMarker derived entity
461 * Uses @marker as entity template to generate a new marker entity
462 * when a call to adg_dim_style_marker2_new() is made. It is allowed
463 * to pass %NULL as @marker, in which case the template data of the
464 * second marker are unset.
466 * This method duplicates internally the property values of @marker,
467 * so any further change to @marker does not affect @dim_style anymore.
468 * This also means @marker could be destroyed without problems after
469 * this call because @dim_style uses only its property values and does
470 * not add any references to @marker.
473 adg_dim_style_set_marker2(AdgDimStyle
*dim_style
, AdgMarker
*marker
)
475 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
476 g_object_set(dim_style
, "marker2", marker
, NULL
);
480 * adg_dim_style_marker2_new:
481 * @dim_style: an #AdgDimStyle
483 * Creates a new marker entity by cloning the #AdgMarker:marker2
484 * object. The returned entity should be unreferenced with
485 * g_object_unref() when no longer needed.
487 * Returns: a newly created marker or %NULL if the #AdgDimStyle:marker2
488 * property is not set or on errors
491 adg_dim_style_marker2_new(AdgDimStyle
*dim_style
)
493 AdgDimStylePrivate
*data
;
495 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
497 data
= dim_style
->data
;
499 return _adg_marker_new(&data
->marker2
);
503 * adg_dim_style_set_color_dress:
504 * @dim_style: an #AdgDimStyle object
505 * @dress: the new color dress
507 * Sets a new color dress on @dim_style.
510 adg_dim_style_set_color_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
512 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
513 g_object_set(dim_style
, "color-dress", dress
, NULL
);
517 * adg_dim_style_get_color_dress:
518 * @dim_style: an #AdgDimStyle object
520 * Gets the @dim_style color dress to be used. This dress should be
521 * intended as a fallback color as it could be overriden by more
522 * specific dresses, such as a color explicitely specified on the
523 * #AdgDimStyle:value-dress.
525 * Returns: the color dress
528 adg_dim_style_get_color_dress(AdgDimStyle
*dim_style
)
530 AdgDimStylePrivate
*data
;
532 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
534 data
= dim_style
->data
;
536 return data
->color_dress
;
540 * adg_dim_style_set_value_dress:
541 * @dim_style: an #AdgDimStyle object
542 * @dress: the new basic value font style
544 * Sets a new dress on @dim_style for the basic value.
547 adg_dim_style_set_value_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
549 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
550 g_object_set(dim_style
, "value-dress", dress
, NULL
);
554 * adg_dim_style_get_value_dress:
555 * @dim_style: an #AdgDimStyle object
557 * Gets the font dress to be used for the basic value of dimensions
560 * Returns: the font dress
563 adg_dim_style_get_value_dress(AdgDimStyle
*dim_style
)
565 AdgDimStylePrivate
*data
;
567 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
569 data
= dim_style
->data
;
571 return data
->value_dress
;
575 * adg_dim_style_set_min_dress:
576 * @dim_style: an #AdgDimStyle object
577 * @dress: the new lower limit dress
579 * Sets a new dress on @dim_style for the lower limit value.
582 adg_dim_style_set_min_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
584 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
585 g_object_set(dim_style
, "min-dress", dress
, NULL
);
589 * adg_dim_style_get_min_dress:
590 * @dim_style: an #AdgDimStyle object
592 * Gets the @dim_style dress to be used for the lower limit.
594 * Returns: the lower limit dress
597 adg_dim_style_get_min_dress(AdgDimStyle
*dim_style
)
599 AdgDimStylePrivate
*data
;
601 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
603 data
= dim_style
->data
;
605 return data
->min_dress
;
609 * adg_dim_style_set_max_dress:
610 * @dim_style: an #AdgDimStyle object
611 * @dress: the new upper limit dress
613 * Sets a new dress on @dim_style for the upper limit value.
616 adg_dim_style_set_max_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
618 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
619 g_object_set(dim_style
, "max-dress", dress
, NULL
);
623 * adg_dim_style_get_max_dress:
624 * @dim_style: an #AdgDimStyle object
626 * Gets the @dim_style dress to be used for the upper limit.
628 * Returns: the upper limit dress
631 adg_dim_style_get_max_dress(AdgDimStyle
*dim_style
)
633 AdgDimStylePrivate
*data
;
635 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
637 data
= dim_style
->data
;
639 return data
->max_dress
;
643 * adg_dim_style_set_line_dress:
644 * @dim_style: an #AdgDimStyle object
645 * @dress: the new line dress
647 * Sets a new line dress on @dim_style.
650 adg_dim_style_set_line_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
652 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
653 g_object_set(dim_style
, "line-dress", dress
, NULL
);
657 * adg_dim_style_get_line_dress:
658 * @dim_style: an #AdgDimStyle object
660 * Gets the line dress to be used for rendering the base and
661 * the extension lines with @dim_style.
663 * Returns: the line dress
666 adg_dim_style_get_line_dress(AdgDimStyle
*dim_style
)
668 AdgDimStylePrivate
*data
;
670 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
672 data
= dim_style
->data
;
674 return data
->line_dress
;
678 * adg_dim_style_set_from_offset:
679 * @dim_style: an #AdgDimStyle object
680 * @offset: the new offset
682 * Sets a new value in the #AdgDimStyle:from-offset property.
685 adg_dim_style_set_from_offset(AdgDimStyle
*dim_style
, gdouble offset
)
687 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
688 g_object_set(dim_style
, "from-offset", offset
, NULL
);
692 * adg_dim_style_get_from_offset:
693 * @dim_style: an #AdgDimStyle object
695 * Gets the distance (in global space) the extension lines must keep from the
698 * Returns: the requested distance
701 adg_dim_style_get_from_offset(AdgDimStyle
*dim_style
)
703 AdgDimStylePrivate
*data
;
705 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
707 data
= dim_style
->data
;
709 return data
->from_offset
;
713 * adg_dim_style_set_to_offset:
714 * @dim_style: an #AdgDimStyle object
715 * @offset: the new offset
717 * Sets a new value in the #AdgDimStyle:to-offset property.
720 adg_dim_style_set_to_offset(AdgDimStyle
*dim_style
, gdouble offset
)
722 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
723 g_object_set(dim_style
, "to-offset", offset
, NULL
);
727 * adg_dim_style_get_to_offset:
728 * @dim_style: an #AdgDimStyle object
730 * Gets how much (in global space) the extension lines must extend after
731 * crossing the baseline.
733 * Returns: the requested distance
736 adg_dim_style_get_to_offset(AdgDimStyle
*dim_style
)
738 AdgDimStylePrivate
*data
;
740 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
742 data
= dim_style
->data
;
744 return data
->to_offset
;
748 * adg_dim_style_set_beyond:
749 * @dim_style: an #AdgDimStyle object
750 * @beyond: the new length
752 * Sets a new value in the #AdgDimStyle:beyond property.
755 adg_dim_style_set_beyond(AdgDimStyle
*dim_style
, gdouble beyond
)
757 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
758 g_object_set(dim_style
, "beyond", beyond
, NULL
);
762 * adg_dim_style_get_beyond:
763 * @dim_style: an #AdgDimStyle object
765 * Gets how much (in global space) the baseline should extend beyond
766 * the extension lines on dimension with outside markers.
768 * Returns: the requested beyond length
771 adg_dim_style_get_beyond(AdgDimStyle
*dim_style
)
773 AdgDimStylePrivate
*data
;
775 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
777 data
= dim_style
->data
;
783 * adg_dim_style_set_baseline_spacing:
784 * @dim_style: an #AdgDimStyle object
785 * @spacing: the new spacing
787 * Sets a new value in the #AdgDimStyle:baseline-spacing value.
790 adg_dim_style_set_baseline_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
792 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
793 g_object_set(dim_style
, "baseline-spacing", spacing
, NULL
);
797 * adg_dim_style_get_baseline_spacing:
798 * @dim_style: an #AdgDimStyle object
800 * Gets the distance between two consecutive baselines
801 * while stacking dimensions.
803 * Returns: the requested spacing
806 adg_dim_style_get_baseline_spacing(AdgDimStyle
*dim_style
)
808 AdgDimStylePrivate
*data
;
810 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
812 data
= dim_style
->data
;
814 return data
->baseline_spacing
;
818 * adg_dim_style_set_limits_spacing:
819 * @dim_style: an #AdgDimStyle object
820 * @spacing: the new spacing
822 * Sets a new #AdgDimStyle:limits-spacing value.
825 adg_dim_style_set_limits_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
827 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
828 g_object_set(dim_style
, "limits-spacing", spacing
, NULL
);
832 * adg_dim_style_get_limits_spacing:
833 * @dim_style: an #AdgDimStyle object
835 * Gets the distance (in global space) between the limits/tolerances.
837 * Returns: the requested spacing
840 adg_dim_style_get_limits_spacing(AdgDimStyle
*dim_style
)
842 AdgDimStylePrivate
*data
;
844 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
846 data
= dim_style
->data
;
848 return data
->limits_spacing
;
852 * adg_dim_style_set_quote_shift:
853 * @dim_style: an #AdgDimStyle object
854 * @shift: the new displacement
856 * Sets a new #AdgDimStyle:quote-shift value.
859 adg_dim_style_set_quote_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
861 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
862 g_object_set(dim_style
, "quote-shift", shift
, NULL
);
866 * adg_dim_style_get_quote_shift:
867 * @dim_style: an #AdgDimStyle object
869 * Gets the smooth displacement of the quote. The returned pointer refers
870 * to an internal allocated struct and must not be modified or freed.
872 * Returns: the requested shift
875 adg_dim_style_get_quote_shift(AdgDimStyle
*dim_style
)
877 AdgDimStylePrivate
*data
;
879 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
881 data
= dim_style
->data
;
883 return &data
->quote_shift
;
887 * adg_dim_style_set_limits_shift:
888 * @dim_style: an #AdgDimStyle object
889 * @shift: the new displacement
891 * Sets a new #AdgDimStyle:limits-shift value.
894 adg_dim_style_set_limits_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
896 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
897 g_object_set(dim_style
, "limits-shift", shift
, NULL
);
901 * adg_dim_style_get_limits_shift:
902 * @dim_style: an #AdgDimStyle object
904 * Gets the smooth displacement for the limits. The returned pointer
905 * refers to an internal allocated struct and must not be modified or freed.
907 * Returns: the requested shift
910 adg_dim_style_get_limits_shift(AdgDimStyle
*dim_style
)
912 AdgDimStylePrivate
*data
;
914 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
916 data
= dim_style
->data
;
918 return &data
->limits_shift
;
922 * adg_dim_style_set_number_format:
923 * @dim_style: an #AdgDimStyle object
924 * @format: the new format to adopt
926 * Sets a new value in the #AdgDimStyle:number-format property.
929 adg_dim_style_set_number_format(AdgDimStyle
*dim_style
, const gchar
*format
)
931 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
932 g_object_set(dim_style
, "number-format", format
, NULL
);
936 * adg_dim_style_get_number_format:
937 * @dim_style: an #AdgDimStyle object
939 * Gets the number format (in printf style) of this quoting style. The
940 * returned pointer refers to internally managed text that must not be
943 * Returns: the requested format
946 adg_dim_style_get_number_format(AdgDimStyle
*dim_style
)
948 AdgDimStylePrivate
*data
;
950 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
952 data
= dim_style
->data
;
954 return data
->number_format
;
958 * adg_dim_style_set_number_tag:
959 * @dim_style: an #AdgDimStyle object
962 * Sets a new tag in the #AdgDimStyle:number-tag property.
965 adg_dim_style_set_number_tag(AdgDimStyle
*dim_style
, const gchar
*tag
)
967 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
968 g_object_set(dim_style
, "number-tag", tag
, NULL
);
972 * adg_dim_style_get_number_tag:
973 * @dim_style: an #AdgDimStyle object
975 * Gets the number tag of @dim_style. This tag will be used while
976 * generating the set values of the dimensions bound to this style:
977 * check the #AdgDim:value documentation for further details.
979 * The returned pointer refers to internally managed text that
980 * must not be modified or freed.
982 * Returns: the requested tag
985 adg_dim_style_get_number_tag(AdgDimStyle
*dim_style
)
987 AdgDimStylePrivate
*data
;
989 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
991 data
= dim_style
->data
;
993 return data
->number_tag
;
998 _adg_apply(AdgStyle
*style
, AdgEntity
*entity
, cairo_t
*cr
)
1000 AdgDimStylePrivate
*data
= ((AdgDimStyle
*) style
)->data
;
1001 adg_entity_apply_dress(entity
, data
->color_dress
, cr
);
1005 _adg_marker_new(const AdgMarkerData
*marker_data
)
1007 if (marker_data
->type
== 0)
1010 return g_object_newv(marker_data
->type
,
1011 marker_data
->n_parameters
,
1012 marker_data
->parameters
);
1016 _adg_set_marker(AdgMarkerData
*marker_data
, AdgMarker
*marker
)
1018 g_return_if_fail(marker
== NULL
|| ADG_IS_MARKER(marker
));
1020 /* Free the previous marker data, if any */
1021 _adg_free_marker(marker_data
);
1027 GParameter
*parameter
;
1030 object
= (GObject
*) marker
;
1031 specs
= g_object_class_list_properties(G_OBJECT_GET_CLASS(marker
),
1032 &marker_data
->n_parameters
);
1034 marker_data
->type
= G_TYPE_FROM_INSTANCE(marker
);
1035 marker_data
->parameters
= g_new0(GParameter
, marker_data
->n_parameters
);
1037 for (n
= 0; n
< marker_data
->n_parameters
; ++n
) {
1039 parameter
= &marker_data
->parameters
[n
];
1041 /* Using intern strings because GParameter:name is const.
1042 * GObject properties are internally managed using non-static
1043 * GQuark, so g_intern_string() is the way to go */
1044 parameter
->name
= g_intern_string(spec
->name
);
1046 g_value_init(¶meter
->value
, spec
->value_type
);
1047 g_object_get_property(object
, spec
->name
, ¶meter
->value
);
1055 _adg_free_marker(AdgMarkerData
*marker_data
)
1059 for (n
= 0; n
< marker_data
->n_parameters
; ++n
)
1060 g_value_unset(&marker_data
->parameters
[n
].value
);
1062 marker_data
->type
= 0;
1063 marker_data
->n_parameters
= 0;
1064 marker_data
->parameters
= NULL
;