1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2015 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...
35 * All fields are private and should not be used directly.
36 * Use its public methods instead.
42 #include "adg-internal.h"
43 #include "adg-style.h"
44 #include "adg-font-style.h"
46 #include "adg-line-style.h"
47 #include "adg-model.h"
48 #include "adg-trail.h"
49 #include "adg-marker.h"
50 #include "adg-dress.h"
51 #include "adg-param-dress.h"
53 #include "adg-dim-style.h"
54 #include "adg-dim-style-private.h"
57 G_DEFINE_TYPE(AdgDimStyle
, adg_dim_style
, ADG_TYPE_STYLE
)
71 PROP_BASELINE_SPACING
,
80 static void _adg_finalize (GObject
*object
);
81 static void _adg_get_property (GObject
*object
,
85 static void _adg_set_property (GObject
*object
,
89 static void _adg_apply (AdgStyle
*style
,
92 static AdgMarker
* _adg_marker_new (const AdgMarkerData
94 static void _adg_set_marker (AdgMarkerData
*marker_data
,
96 static void _adg_free_marker (AdgMarkerData
*marker_data
);
100 adg_dim_style_class_init(AdgDimStyleClass
*klass
)
102 GObjectClass
*gobject_class
;
103 AdgStyleClass
*style_class
;
106 gobject_class
= (GObjectClass
*) klass
;
107 style_class
= (AdgStyleClass
*) klass
;
109 g_type_class_add_private(klass
, sizeof(AdgDimStylePrivate
));
111 gobject_class
->finalize
= _adg_finalize
;
112 gobject_class
->get_property
= _adg_get_property
;
113 gobject_class
->set_property
= _adg_set_property
;
115 style_class
->apply
= _adg_apply
;
117 param
= g_param_spec_object("marker1",
119 P_("The template entity to use as first marker"),
122 g_object_class_install_property(gobject_class
, PROP_MARKER1
, param
);
124 param
= g_param_spec_object("marker2",
126 P_("The template entity to use as second marker"),
129 g_object_class_install_property(gobject_class
, PROP_MARKER2
, param
);
131 param
= adg_param_spec_dress("color-dress",
133 P_("Color dress for the whole dimension"),
134 ADG_DRESS_COLOR_DIMENSION
,
136 g_object_class_install_property(gobject_class
, PROP_COLOR_DRESS
, param
);
138 param
= adg_param_spec_dress("value-dress",
140 P_("Font dress for the nominal value of the dimension"),
141 ADG_DRESS_FONT_QUOTE_TEXT
,
143 g_object_class_install_property(gobject_class
, PROP_VALUE_DRESS
, param
);
145 param
= adg_param_spec_dress("min-dress",
146 P_("Minimum Limit Dress"),
147 P_("Font dress for the lower limit value"),
148 ADG_DRESS_FONT_QUOTE_ANNOTATION
,
150 g_object_class_install_property(gobject_class
, PROP_MIN_DRESS
, param
);
152 param
= adg_param_spec_dress("max-dress",
153 P_("Maximum Limit Dress"),
154 P_("Font dress for the upper limit value"),
155 ADG_DRESS_FONT_QUOTE_ANNOTATION
,
157 g_object_class_install_property(gobject_class
, PROP_MAX_DRESS
, param
);
159 param
= adg_param_spec_dress("line-dress",
161 P_("Line dress for the baseline and the extension lines"),
162 ADG_DRESS_LINE_DIMENSION
,
164 g_object_class_install_property(gobject_class
, PROP_LINE_DRESS
, param
);
166 param
= g_param_spec_double("from-offset",
168 P_("Offset (in global space) of the extension lines from the path to the quote"),
171 g_object_class_install_property(gobject_class
, PROP_FROM_OFFSET
, param
);
173 param
= g_param_spec_double("to-offset",
175 P_("How many extend (in global space) the extension lines after hitting the baseline"),
178 g_object_class_install_property(gobject_class
, PROP_TO_OFFSET
, param
);
180 param
= g_param_spec_double("beyond",
182 P_("How much the baseline should be extended (in global space) beyond the extension lines on dimensions with outside markers"),
185 g_object_class_install_property(gobject_class
, PROP_BEYOND
, param
);
187 param
= g_param_spec_double("baseline-spacing",
188 P_("Baseline Spacing"),
189 P_("Distance between two consecutive baselines while stacking dimensions"),
192 g_object_class_install_property(gobject_class
, PROP_BASELINE_SPACING
, param
);
194 param
= g_param_spec_double("limits-spacing",
195 P_("Limits Spacing"),
196 P_("Distance between limits/tolerances"),
199 g_object_class_install_property(gobject_class
, PROP_LIMITS_SPACING
, param
);
201 param
= g_param_spec_boxed("quote-shift",
203 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)"),
206 g_object_class_install_property(gobject_class
, PROP_QUOTE_SHIFT
, param
);
208 param
= g_param_spec_boxed("limits-shift",
210 P_("Used to specify a smooth displacement (in global space) for the limits/tolerances by taking as reference the perfect compact position"),
213 g_object_class_install_property(gobject_class
, PROP_LIMITS_SHIFT
, param
);
215 param
= g_param_spec_string("number-format",
217 P_("The format (in printf style) of the numeric component of the basic value"),
220 g_object_class_install_property(gobject_class
, PROP_NUMBER_FORMAT
, param
);
222 param
= g_param_spec_string("number-tag",
224 P_("The tag to substitute inside the value template string"),
227 g_object_class_install_property(gobject_class
, PROP_NUMBER_TAG
, param
);
231 adg_dim_style_init(AdgDimStyle
*dim_style
)
233 AdgDimStylePrivate
*data
= G_TYPE_INSTANCE_GET_PRIVATE(dim_style
,
237 data
->marker1
.type
= 0;
238 data
->marker1
.n_parameters
= 0;
239 data
->marker1
.parameters
= NULL
;
240 data
->marker2
.type
= 0;
241 data
->marker2
.n_parameters
= 0;
242 data
->marker2
.parameters
= NULL
;
243 data
->color_dress
= ADG_DRESS_COLOR_DIMENSION
;
244 data
->value_dress
= ADG_DRESS_FONT_QUOTE_TEXT
;
245 data
->min_dress
= ADG_DRESS_FONT_QUOTE_ANNOTATION
;
246 data
->max_dress
= ADG_DRESS_FONT_QUOTE_ANNOTATION
;
247 data
->line_dress
= ADG_DRESS_LINE_DIMENSION
;
248 data
->marker_dress
= ADG_DRESS_UNDEFINED
;
249 data
->from_offset
= 6;
252 data
->baseline_spacing
= 32;
253 data
->limits_spacing
= 0;
254 data
->quote_shift
.x
= 4;
255 data
->quote_shift
.y
= -1;
256 data
->limits_shift
.x
= +2;
257 data
->limits_shift
.y
= +2;
258 data
->number_format
= g_strdup("%-.7g");
259 data
->number_tag
= g_strdup("<>");
261 dim_style
->data
= data
;
265 _adg_finalize(GObject
*object
)
267 AdgDimStylePrivate
*data
= ((AdgDimStyle
*) object
)->data
;
269 _adg_free_marker(&data
->marker1
);
270 _adg_free_marker(&data
->marker2
);
272 g_free(data
->number_format
);
273 data
->number_format
= NULL
;
275 g_free(data
->number_tag
);
276 data
->number_tag
= NULL
;
280 _adg_get_property(GObject
*object
, guint prop_id
,
281 GValue
*value
, GParamSpec
*pspec
)
283 AdgDimStylePrivate
*data
= ((AdgDimStyle
*) object
)->data
;
286 case PROP_COLOR_DRESS
:
287 g_value_set_enum(value
, data
->color_dress
);
289 case PROP_VALUE_DRESS
:
290 g_value_set_enum(value
, data
->value_dress
);
293 g_value_set_enum(value
, data
->min_dress
);
296 g_value_set_enum(value
, data
->max_dress
);
298 case PROP_LINE_DRESS
:
299 g_value_set_enum(value
, data
->line_dress
);
301 case PROP_FROM_OFFSET
:
302 g_value_set_double(value
, data
->from_offset
);
305 g_value_set_double(value
, data
->to_offset
);
308 g_value_set_double(value
, data
->beyond
);
310 case PROP_BASELINE_SPACING
:
311 g_value_set_double(value
, data
->baseline_spacing
);
313 case PROP_LIMITS_SPACING
:
314 g_value_set_double(value
, data
->limits_spacing
);
316 case PROP_QUOTE_SHIFT
:
317 g_value_set_boxed(value
, &data
->quote_shift
);
319 case PROP_LIMITS_SHIFT
:
320 g_value_set_boxed(value
, &data
->limits_shift
);
322 case PROP_NUMBER_FORMAT
:
323 g_value_set_string(value
, data
->number_format
);
325 case PROP_NUMBER_TAG
:
326 g_value_set_string(value
, data
->number_tag
);
329 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
335 _adg_set_property(GObject
*object
, guint prop_id
,
336 const GValue
*value
, GParamSpec
*pspec
)
338 AdgDimStyle
*dim_style
;
339 AdgDimStylePrivate
*data
;
341 dim_style
= (AdgDimStyle
*) object
;
342 data
= dim_style
->data
;
346 _adg_set_marker(&data
->marker1
, g_value_get_object(value
));
349 _adg_set_marker(&data
->marker2
, g_value_get_object(value
));
351 case PROP_COLOR_DRESS
:
352 data
->color_dress
= g_value_get_enum(value
);
354 case PROP_VALUE_DRESS
:
355 data
->value_dress
= g_value_get_enum(value
);
358 data
->min_dress
= g_value_get_enum(value
);
361 data
->max_dress
= g_value_get_enum(value
);
363 case PROP_LINE_DRESS
:
364 data
->line_dress
= g_value_get_enum(value
);
366 case PROP_FROM_OFFSET
:
367 data
->from_offset
= g_value_get_double(value
);
370 data
->to_offset
= g_value_get_double(value
);
373 data
->beyond
= g_value_get_double(value
);
375 case PROP_BASELINE_SPACING
:
376 data
->baseline_spacing
= g_value_get_double(value
);
378 case PROP_LIMITS_SPACING
:
379 data
->limits_spacing
= g_value_get_double(value
);
381 case PROP_QUOTE_SHIFT
:
382 cpml_pair_copy(&data
->quote_shift
, g_value_get_boxed(value
));
384 case PROP_LIMITS_SHIFT
:
385 cpml_pair_copy(&data
->limits_shift
, g_value_get_boxed(value
));
387 case PROP_NUMBER_FORMAT
:
388 g_free(data
->number_format
);
389 data
->number_format
= g_value_dup_string(value
);
391 case PROP_NUMBER_TAG
:
392 g_free(data
->number_tag
);
393 data
->number_tag
= g_value_dup_string(value
);
396 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
405 * Constructs a new empty dimension style initialized with default params.
407 * Returns: (transfer full): a newly created dimension style.
412 adg_dim_style_new(void)
414 return g_object_new(ADG_TYPE_DIM_STYLE
, NULL
);
418 * adg_dim_style_set_marker1:
419 * @dim_style: an #AdgStyle
420 * @marker: an #AdgMarker derived entity
422 * Uses @marker as entity template to generate a new marker entity
423 * when a call to adg_dim_style_marker1_new() is made. It is allowed
424 * to pass <constant>NULL</constant> as @marker, in which case the
425 * template data of the first marker are unset.
427 * This method duplicates internally the property values of @marker,
428 * so any further change to @marker does not affect @dim_style anymore.
429 * This also means @marker could be destroyed without problems after
430 * this call because @dim_style uses only its property values and does
431 * not add any references to @marker.
436 adg_dim_style_set_marker1(AdgDimStyle
*dim_style
, AdgMarker
*marker
)
438 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
439 g_object_set(dim_style
, "marker1", marker
, NULL
);
443 * adg_dim_style_marker1_new:
444 * @dim_style: an #AdgDimStyle
446 * Creates a new marker entity by cloning the #AdgDimStyle:marker1
447 * object. The returned entity should be unreferenced with
448 * g_object_unref() when no longer needed.
450 * Returns: (transfer full): a newly created marker or <constant>NULL</constant> if the #AdgDimStyle:marker1 property is not set or on errors.
455 adg_dim_style_marker1_new(AdgDimStyle
*dim_style
)
457 AdgDimStylePrivate
*data
;
459 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
461 data
= dim_style
->data
;
463 return _adg_marker_new(&data
->marker1
);
467 * adg_dim_style_set_marker2:
468 * @dim_style: an #AdgStyle
469 * @marker: an #AdgMarker derived entity
471 * Uses @marker as entity template to generate a new marker entity
472 * when a call to adg_dim_style_marker2_new() is made. It is allowed
473 * to pass <constant>NULL</constant> as @marker, in which case the
474 * template data of the second marker are unset.
476 * This method duplicates internally the property values of @marker,
477 * so any further change to @marker does not affect @dim_style anymore.
478 * This also means @marker could be destroyed without problems after
479 * this call because @dim_style uses only its property values and does
480 * not add any references to @marker.
485 adg_dim_style_set_marker2(AdgDimStyle
*dim_style
, AdgMarker
*marker
)
487 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
488 g_object_set(dim_style
, "marker2", marker
, NULL
);
492 * adg_dim_style_marker2_new:
493 * @dim_style: an #AdgDimStyle
495 * Creates a new marker entity by cloning the #AdgDimStyle:marker2
496 * object. The returned entity should be unreferenced with
497 * g_object_unref() when no longer needed.
499 * Returns: (transfer full): a newly created marker or <constant>NULL</constant> if the #AdgDimStyle:marker2 property is not set or on errors.
504 adg_dim_style_marker2_new(AdgDimStyle
*dim_style
)
506 AdgDimStylePrivate
*data
;
508 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
510 data
= dim_style
->data
;
512 return _adg_marker_new(&data
->marker2
);
516 * adg_dim_style_set_color_dress:
517 * @dim_style: an #AdgDimStyle object
518 * @dress: the new color dress
520 * Sets a new color dress on @dim_style.
525 adg_dim_style_set_color_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
527 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
528 g_object_set(dim_style
, "color-dress", dress
, NULL
);
532 * adg_dim_style_get_color_dress:
533 * @dim_style: an #AdgDimStyle object
535 * Gets the @dim_style color dress to be used. This dress should be
536 * intended as a fallback color as it could be overriden by more
537 * specific dresses, such as a color explicitely specified on the
538 * #AdgDimStyle:value-dress.
540 * Returns: (transfer none): the color dress.
545 adg_dim_style_get_color_dress(AdgDimStyle
*dim_style
)
547 AdgDimStylePrivate
*data
;
549 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
551 data
= dim_style
->data
;
553 return data
->color_dress
;
557 * adg_dim_style_set_value_dress:
558 * @dim_style: an #AdgDimStyle object
559 * @dress: the new basic value font style
561 * Sets a new dress on @dim_style for the basic value.
566 adg_dim_style_set_value_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
568 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
569 g_object_set(dim_style
, "value-dress", dress
, NULL
);
573 * adg_dim_style_get_value_dress:
574 * @dim_style: an #AdgDimStyle object
576 * Gets the font dress to be used for the basic value of dimensions
579 * Returns: (transfer none): the font dress.
584 adg_dim_style_get_value_dress(AdgDimStyle
*dim_style
)
586 AdgDimStylePrivate
*data
;
588 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
590 data
= dim_style
->data
;
592 return data
->value_dress
;
596 * adg_dim_style_set_min_dress:
597 * @dim_style: an #AdgDimStyle object
598 * @dress: the new lower limit dress
600 * Sets a new dress on @dim_style for the lower limit value.
605 adg_dim_style_set_min_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
607 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
608 g_object_set(dim_style
, "min-dress", dress
, NULL
);
612 * adg_dim_style_get_min_dress:
613 * @dim_style: an #AdgDimStyle object
615 * Gets the @dim_style dress to be used for the lower limit.
617 * Returns: (transfer none): the lower limit dress.
622 adg_dim_style_get_min_dress(AdgDimStyle
*dim_style
)
624 AdgDimStylePrivate
*data
;
626 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
628 data
= dim_style
->data
;
630 return data
->min_dress
;
634 * adg_dim_style_set_max_dress:
635 * @dim_style: an #AdgDimStyle object
636 * @dress: the new upper limit dress
638 * Sets a new dress on @dim_style for the upper limit value.
643 adg_dim_style_set_max_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
645 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
646 g_object_set(dim_style
, "max-dress", dress
, NULL
);
650 * adg_dim_style_get_max_dress:
651 * @dim_style: an #AdgDimStyle object
653 * Gets the @dim_style dress to be used for the upper limit.
655 * Returns: (transfer none): the upper limit dress.
660 adg_dim_style_get_max_dress(AdgDimStyle
*dim_style
)
662 AdgDimStylePrivate
*data
;
664 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
666 data
= dim_style
->data
;
668 return data
->max_dress
;
672 * adg_dim_style_set_line_dress:
673 * @dim_style: an #AdgDimStyle object
674 * @dress: the new line dress
676 * Sets a new line dress on @dim_style.
681 adg_dim_style_set_line_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
683 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
684 g_object_set(dim_style
, "line-dress", dress
, NULL
);
688 * adg_dim_style_get_line_dress:
689 * @dim_style: an #AdgDimStyle object
691 * Gets the line dress to be used for rendering the base and
692 * the extension lines with @dim_style.
694 * Returns: (transfer none): the line dress.
699 adg_dim_style_get_line_dress(AdgDimStyle
*dim_style
)
701 AdgDimStylePrivate
*data
;
703 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
705 data
= dim_style
->data
;
707 return data
->line_dress
;
711 * adg_dim_style_set_from_offset:
712 * @dim_style: an #AdgDimStyle object
713 * @offset: the new offset
715 * Sets a new value in the #AdgDimStyle:from-offset property.
720 adg_dim_style_set_from_offset(AdgDimStyle
*dim_style
, gdouble offset
)
722 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
723 g_object_set(dim_style
, "from-offset", offset
, NULL
);
727 * adg_dim_style_get_from_offset:
728 * @dim_style: an #AdgDimStyle object
730 * Gets the distance (in global space) the extension lines must keep from the
733 * Returns: the requested distance.
738 adg_dim_style_get_from_offset(AdgDimStyle
*dim_style
)
740 AdgDimStylePrivate
*data
;
742 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
744 data
= dim_style
->data
;
746 return data
->from_offset
;
750 * adg_dim_style_set_to_offset:
751 * @dim_style: an #AdgDimStyle object
752 * @offset: the new offset
754 * Sets a new value in the #AdgDimStyle:to-offset property.
759 adg_dim_style_set_to_offset(AdgDimStyle
*dim_style
, gdouble offset
)
761 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
762 g_object_set(dim_style
, "to-offset", offset
, NULL
);
766 * adg_dim_style_get_to_offset:
767 * @dim_style: an #AdgDimStyle object
769 * Gets how much (in global space) the extension lines must extend after
770 * crossing the baseline.
772 * Returns: the requested distance.
777 adg_dim_style_get_to_offset(AdgDimStyle
*dim_style
)
779 AdgDimStylePrivate
*data
;
781 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
783 data
= dim_style
->data
;
785 return data
->to_offset
;
789 * adg_dim_style_set_beyond:
790 * @dim_style: an #AdgDimStyle object
791 * @beyond: the new length
793 * Sets a new value in the #AdgDimStyle:beyond property.
798 adg_dim_style_set_beyond(AdgDimStyle
*dim_style
, gdouble beyond
)
800 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
801 g_object_set(dim_style
, "beyond", beyond
, NULL
);
805 * adg_dim_style_get_beyond:
806 * @dim_style: an #AdgDimStyle object
808 * Gets how much (in global space) the baseline should extend beyond
809 * the extension lines on dimension with outside markers.
811 * Returns: the requested beyond length.
816 adg_dim_style_get_beyond(AdgDimStyle
*dim_style
)
818 AdgDimStylePrivate
*data
;
820 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
822 data
= dim_style
->data
;
828 * adg_dim_style_set_baseline_spacing:
829 * @dim_style: an #AdgDimStyle object
830 * @spacing: the new spacing
832 * Sets a new value in the #AdgDimStyle:baseline-spacing value.
837 adg_dim_style_set_baseline_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
839 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
840 g_object_set(dim_style
, "baseline-spacing", spacing
, NULL
);
844 * adg_dim_style_get_baseline_spacing:
845 * @dim_style: an #AdgDimStyle object
847 * Gets the distance between two consecutive baselines
848 * while stacking dimensions.
850 * Returns: the requested spacing.
855 adg_dim_style_get_baseline_spacing(AdgDimStyle
*dim_style
)
857 AdgDimStylePrivate
*data
;
859 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
861 data
= dim_style
->data
;
863 return data
->baseline_spacing
;
867 * adg_dim_style_set_limits_spacing:
868 * @dim_style: an #AdgDimStyle object
869 * @spacing: the new spacing
871 * Sets a new #AdgDimStyle:limits-spacing value.
876 adg_dim_style_set_limits_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
878 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
879 g_object_set(dim_style
, "limits-spacing", spacing
, NULL
);
883 * adg_dim_style_get_limits_spacing:
884 * @dim_style: an #AdgDimStyle object
886 * Gets the distance (in global space) between the limits/tolerances.
888 * Returns: the requested spacing.
893 adg_dim_style_get_limits_spacing(AdgDimStyle
*dim_style
)
895 AdgDimStylePrivate
*data
;
897 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
899 data
= dim_style
->data
;
901 return data
->limits_spacing
;
905 * adg_dim_style_set_quote_shift:
906 * @dim_style: an #AdgDimStyle object
907 * @shift: the new displacement
909 * Sets a new #AdgDimStyle:quote-shift value.
914 adg_dim_style_set_quote_shift(AdgDimStyle
*dim_style
, const CpmlPair
*shift
)
916 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
917 g_object_set(dim_style
, "quote-shift", shift
, NULL
);
921 * adg_dim_style_get_quote_shift:
922 * @dim_style: an #AdgDimStyle object
924 * Gets the smooth displacement of the quote. The returned pointer refers
925 * to an internal allocated struct and must not be modified or freed.
927 * Returns: (transfer none): the requested shift.
932 adg_dim_style_get_quote_shift(AdgDimStyle
*dim_style
)
934 AdgDimStylePrivate
*data
;
936 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
938 data
= dim_style
->data
;
940 return &data
->quote_shift
;
944 * adg_dim_style_set_limits_shift:
945 * @dim_style: an #AdgDimStyle object
946 * @shift: the new displacement
948 * Sets a new #AdgDimStyle:limits-shift value.
953 adg_dim_style_set_limits_shift(AdgDimStyle
*dim_style
, const CpmlPair
*shift
)
955 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
956 g_object_set(dim_style
, "limits-shift", shift
, NULL
);
960 * adg_dim_style_get_limits_shift:
961 * @dim_style: an #AdgDimStyle object
963 * Gets the smooth displacement for the limits. The returned pointer
964 * refers to an internal allocated struct and must not be modified or freed.
966 * Returns: (transfer none): the requested shift.
971 adg_dim_style_get_limits_shift(AdgDimStyle
*dim_style
)
973 AdgDimStylePrivate
*data
;
975 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
977 data
= dim_style
->data
;
979 return &data
->limits_shift
;
983 * adg_dim_style_set_number_format:
984 * @dim_style: an #AdgDimStyle object
985 * @format: the new format to adopt
987 * Sets a new value in the #AdgDimStyle:number-format property.
992 adg_dim_style_set_number_format(AdgDimStyle
*dim_style
, const gchar
*format
)
994 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
995 g_object_set(dim_style
, "number-format", format
, NULL
);
999 * adg_dim_style_get_number_format:
1000 * @dim_style: an #AdgDimStyle object
1002 * Gets the number format (in printf style) of this quoting style. The
1003 * returned pointer refers to internally managed text that must not be
1004 * modified or freed.
1006 * Returns: (transfer none): the requested format.
1011 adg_dim_style_get_number_format(AdgDimStyle
*dim_style
)
1013 AdgDimStylePrivate
*data
;
1015 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
1017 data
= dim_style
->data
;
1019 return data
->number_format
;
1023 * adg_dim_style_set_number_tag:
1024 * @dim_style: an #AdgDimStyle object
1027 * Sets a new tag in the #AdgDimStyle:number-tag property.
1032 adg_dim_style_set_number_tag(AdgDimStyle
*dim_style
, const gchar
*tag
)
1034 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
1035 g_object_set(dim_style
, "number-tag", tag
, NULL
);
1039 * adg_dim_style_get_number_tag:
1040 * @dim_style: an #AdgDimStyle object
1042 * Gets the number tag of @dim_style. This tag will be used while
1043 * generating the set values of the dimensions bound to this style:
1044 * check the #AdgDim:value documentation for further details.
1046 * The returned pointer refers to internally managed text that
1047 * must not be modified or freed.
1049 * Returns: (transfer none): the requested tag.
1054 adg_dim_style_get_number_tag(AdgDimStyle
*dim_style
)
1056 AdgDimStylePrivate
*data
;
1058 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
1060 data
= dim_style
->data
;
1062 return data
->number_tag
;
1067 _adg_apply(AdgStyle
*style
, AdgEntity
*entity
, cairo_t
*cr
)
1069 AdgDimStylePrivate
*data
= ((AdgDimStyle
*) style
)->data
;
1070 adg_entity_apply_dress(entity
, data
->color_dress
, cr
);
1074 _adg_marker_new(const AdgMarkerData
*marker_data
)
1076 if (marker_data
->type
== 0)
1079 return g_object_newv(marker_data
->type
,
1080 marker_data
->n_parameters
,
1081 marker_data
->parameters
);
1085 _adg_set_marker(AdgMarkerData
*marker_data
, AdgMarker
*marker
)
1087 g_return_if_fail(marker
== NULL
|| ADG_IS_MARKER(marker
));
1089 /* Free the previous marker data, if any */
1090 _adg_free_marker(marker_data
);
1096 GParameter
*parameter
;
1099 object
= (GObject
*) marker
;
1100 specs
= g_object_class_list_properties(G_OBJECT_GET_CLASS(marker
),
1101 &marker_data
->n_parameters
);
1103 marker_data
->type
= G_TYPE_FROM_INSTANCE(marker
);
1104 marker_data
->parameters
= g_new0(GParameter
, marker_data
->n_parameters
);
1106 for (n
= 0; n
< marker_data
->n_parameters
; ++n
) {
1108 parameter
= &marker_data
->parameters
[n
];
1110 /* Using intern strings because GParameter:name is const.
1111 * GObject properties are internally managed using non-static
1112 * GQuark, so g_intern_string() is the way to go */
1113 parameter
->name
= g_intern_string(spec
->name
);
1115 g_value_init(¶meter
->value
, spec
->value_type
);
1116 g_object_get_property(object
, spec
->name
, ¶meter
->value
);
1124 _adg_free_marker(AdgMarkerData
*marker_data
)
1128 for (n
= 0; n
< marker_data
->n_parameters
; ++n
)
1129 g_value_unset(&marker_data
->parameters
[n
].value
);
1131 marker_data
->type
= 0;
1132 marker_data
->n_parameters
= 0;
1133 marker_data
->parameters
= NULL
;