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.
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, tolerance and note), 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-dim-style.h"
39 #include "adg-dim-style-private.h"
40 #include "adg-font-style.h"
41 #include "adg-line-style.h"
56 PROP_BASELINE_SPACING
,
57 PROP_TOLERANCE_SPACING
,
66 static void get_property (GObject
*object
,
70 static void set_property (GObject
*object
,
74 static void apply (AdgStyle
*style
,
76 static void set_quote_shift (AdgDimStyle
*dim_style
,
77 const AdgPair
*shift
);
78 static void set_tolerance_shift (AdgDimStyle
*dim_style
,
79 const AdgPair
*shift
);
80 static void set_note_shift (AdgDimStyle
*dim_style
,
81 const AdgPair
*shift
);
82 static void set_number_format (AdgDimStyle
*dim_style
,
84 static void set_number_tag (AdgDimStyle
*dim_style
,
88 G_DEFINE_TYPE(AdgDimStyle
, adg_dim_style
, ADG_TYPE_STYLE
);
92 adg_dim_style_class_init(AdgDimStyleClass
*klass
)
94 GObjectClass
*gobject_class
;
95 AdgStyleClass
*style_class
;
98 gobject_class
= (GObjectClass
*) klass
;
99 style_class
= (AdgStyleClass
*) klass
;
101 g_type_class_add_private(klass
, sizeof(AdgDimStylePrivate
));
103 gobject_class
->get_property
= get_property
;
104 gobject_class
->set_property
= set_property
;
106 style_class
->apply
= apply
;
108 param
= adg_param_spec_dress("value-dress",
110 P_("Font dress for the nominal value of the dimension"),
111 ADG_DRESS_TEXT_VALUE
,
113 g_object_class_install_property(gobject_class
, PROP_VALUE_DRESS
, param
);
115 param
= adg_param_spec_dress("up-dress",
116 P_("Up-limit Dress"),
117 P_("Font dress for the upper limit value"),
118 ADG_DRESS_TEXT_LIMIT
,
120 g_object_class_install_property(gobject_class
, PROP_UP_DRESS
, param
);
122 param
= adg_param_spec_dress("down-dress",
123 P_("Down-limit Dress"),
124 P_("Font dress for the lower limit value"),
125 ADG_DRESS_TEXT_LIMIT
,
127 g_object_class_install_property(gobject_class
, PROP_DOWN_DRESS
, param
);
129 param
= adg_param_spec_dress("note-dress",
131 P_("Font dress for the note"),
132 ADG_DRESS_TEXT_VALUE
,
134 g_object_class_install_property(gobject_class
, PROP_NOTE_DRESS
, param
);
136 param
= adg_param_spec_dress("line-dress",
138 P_("Line dress for the baseline and the extension lines"),
139 ADG_DRESS_LINE_DIMENSION
,
141 g_object_class_install_property(gobject_class
, PROP_LINE_DRESS
, param
);
143 param
= g_param_spec_double("from-offset",
145 P_("Offset (in global space) of the extension lines from the path to the quote"),
148 g_object_class_install_property(gobject_class
, PROP_FROM_OFFSET
, param
);
150 param
= g_param_spec_double("to-offset",
152 P_("How many extend (in global space) the extension lines after hitting the baseline"),
155 g_object_class_install_property(gobject_class
, PROP_TO_OFFSET
, param
);
157 param
= g_param_spec_double("beyond",
159 P_("How much the baseline should be extended (in global space) beyond the extension lines on dimensions with outside markers: 0 means to automatically compute this value at run-time as 3*marker-size (got from the binded array-style)"),
162 g_object_class_install_property(gobject_class
, PROP_BEYOND
, param
);
164 param
= g_param_spec_double("baseline-spacing",
165 P_("Baseline Spacing"),
166 P_("Distance between two consecutive baselines while stacking dimensions"),
169 g_object_class_install_property(gobject_class
, PROP_BASELINE_SPACING
, param
);
171 param
= g_param_spec_double("tolerance-spacing",
172 P_("Tolerance Spacing"),
173 P_("Distance between up and down tolerance text"),
176 g_object_class_install_property(gobject_class
, PROP_TOLERANCE_SPACING
, param
);
178 param
= g_param_spec_boxed("quote-shift",
180 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)"),
181 ADG_TYPE_PAIR
, G_PARAM_READWRITE
);
182 g_object_class_install_property(gobject_class
, PROP_QUOTE_SHIFT
, param
);
184 param
= g_param_spec_boxed("tolerance-shift",
185 P_("Tolerance Shift"),
186 P_("Used to specify a smooth displacement (in global space) for the tolerance text by taking as reference the perfect compact position"),
187 ADG_TYPE_PAIR
, G_PARAM_READWRITE
);
188 g_object_class_install_property(gobject_class
, PROP_TOLERANCE_SHIFT
,
191 param
= g_param_spec_boxed("note-shift",
193 P_("Used to specify a smooth displacement (in global space) for the note text by taking as reference the perfect compact position"),
194 ADG_TYPE_PAIR
, G_PARAM_READWRITE
);
195 g_object_class_install_property(gobject_class
, PROP_NOTE_SHIFT
, param
);
197 param
= g_param_spec_string("number-format",
199 P_("The format (in printf style) of the numeric component of the basic value"),
200 "%-.7g", G_PARAM_READWRITE
);
201 g_object_class_install_property(gobject_class
, PROP_NUMBER_FORMAT
,
204 param
= g_param_spec_string("number-tag",
206 P_("The tag to substitute inside the basic value pattern"),
207 "<>", G_PARAM_READWRITE
);
208 g_object_class_install_property(gobject_class
, PROP_NUMBER_TAG
, param
);
212 adg_dim_style_init(AdgDimStyle
*dim_style
)
214 AdgDimStylePrivate
*data
= G_TYPE_INSTANCE_GET_PRIVATE(dim_style
,
218 data
->value_dress
= ADG_DRESS_TEXT_VALUE
;
219 data
->up_dress
= ADG_DRESS_TEXT_LIMIT
;
220 data
->down_dress
= ADG_DRESS_TEXT_LIMIT
;
221 data
->note_dress
= ADG_DRESS_TEXT_VALUE
;
222 data
->line_dress
= ADG_DRESS_LINE_DIMENSION
;
223 data
->marker_dress
= ADG_DRESS_UNDEFINED
;
224 data
->from_offset
= 6;
227 data
->baseline_spacing
= 30;
228 data
->tolerance_spacing
= 1;
229 data
->quote_shift
.x
= 0;
230 data
->quote_shift
.y
= -4;
231 data
->tolerance_shift
.x
= +2;
232 data
->tolerance_shift
.y
= -2;
233 data
->note_shift
.x
= +4;
234 data
->note_shift
.y
= 0;
235 data
->number_format
= g_strdup("%-.7g");
236 data
->number_tag
= g_strdup("<>");
238 dim_style
->data
= data
;
242 get_property(GObject
*object
, guint prop_id
, GValue
*value
, GParamSpec
*pspec
)
244 AdgDimStylePrivate
*data
= ((AdgDimStyle
*) object
)->data
;
247 case PROP_VALUE_DRESS
:
248 g_value_set_int(value
, data
->value_dress
);
251 g_value_set_int(value
, data
->up_dress
);
253 case PROP_DOWN_DRESS
:
254 g_value_set_int(value
, data
->down_dress
);
256 case PROP_NOTE_DRESS
:
257 g_value_set_int(value
, data
->note_dress
);
259 case PROP_LINE_DRESS
:
260 g_value_set_int(value
, data
->line_dress
);
262 case PROP_FROM_OFFSET
:
263 g_value_set_double(value
, data
->from_offset
);
266 g_value_set_double(value
, data
->to_offset
);
269 g_value_set_double(value
, data
->beyond
);
271 case PROP_BASELINE_SPACING
:
272 g_value_set_double(value
, data
->baseline_spacing
);
274 case PROP_TOLERANCE_SPACING
:
275 g_value_set_double(value
, data
->tolerance_spacing
);
277 case PROP_QUOTE_SHIFT
:
278 g_value_set_boxed(value
, &data
->quote_shift
);
280 case PROP_TOLERANCE_SHIFT
:
281 g_value_set_boxed(value
, &data
->tolerance_shift
);
283 case PROP_NOTE_SHIFT
:
284 g_value_set_boxed(value
, &data
->note_shift
);
286 case PROP_NUMBER_FORMAT
:
287 g_value_set_string(value
, data
->number_format
);
289 case PROP_NUMBER_TAG
:
290 g_value_set_string(value
, data
->number_tag
);
293 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
299 set_property(GObject
*object
,
300 guint prop_id
, const GValue
*value
, GParamSpec
*pspec
)
302 AdgDimStyle
*dim_style
;
303 AdgDimStylePrivate
*data
;
305 dim_style
= (AdgDimStyle
*) object
;
306 data
= dim_style
->data
;
309 case PROP_VALUE_DRESS
:
310 adg_dress_set(&data
->value_dress
, g_value_get_int(value
));
313 adg_dress_set(&data
->up_dress
, g_value_get_int(value
));
315 case PROP_DOWN_DRESS
:
316 adg_dress_set(&data
->down_dress
, g_value_get_int(value
));
318 case PROP_NOTE_DRESS
:
319 adg_dress_set(&data
->note_dress
, g_value_get_int(value
));
321 case PROP_LINE_DRESS
:
322 adg_dress_set(&data
->line_dress
, g_value_get_int(value
));
324 case PROP_FROM_OFFSET
:
325 data
->from_offset
= g_value_get_double(value
);
328 data
->to_offset
= g_value_get_double(value
);
331 data
->beyond
= g_value_get_double(value
);
333 case PROP_BASELINE_SPACING
:
334 data
->baseline_spacing
= g_value_get_double(value
);
336 case PROP_TOLERANCE_SPACING
:
337 data
->tolerance_spacing
= g_value_get_double(value
);
339 case PROP_QUOTE_SHIFT
:
340 set_quote_shift(dim_style
, g_value_get_boxed(value
));
342 case PROP_TOLERANCE_SHIFT
:
343 set_tolerance_shift(dim_style
, g_value_get_boxed(value
));
345 case PROP_NOTE_SHIFT
:
346 set_note_shift(dim_style
, g_value_get_boxed(value
));
348 case PROP_NUMBER_FORMAT
:
349 set_number_format(dim_style
, g_value_get_string(value
));
351 case PROP_NUMBER_TAG
:
352 set_number_tag(dim_style
, g_value_get_string(value
));
355 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
364 * Constructs a new dimension style initialized with default params.
366 * Returns: a new dimension style
369 adg_dim_style_new(void)
371 return g_object_new(ADG_TYPE_DIM_STYLE
, NULL
);
375 * adg_dim_style_get_value_dress:
376 * @dim_style: an #AdgDimStyle object
378 * Gets the @dim_style dress to be used for the basic value.
380 * Returns: the basic value dress
383 adg_dim_style_get_value_dress(AdgDimStyle
*dim_style
)
385 AdgDimStylePrivate
*data
;
387 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
389 data
= dim_style
->data
;
391 return data
->value_dress
;
395 * adg_dim_style_set_value_dress:
396 * @dim_style: an #AdgDimStyle object
397 * @style: the new basic value font style
399 * Sets a new dress on @dim_style for the basic value.
402 adg_dim_style_set_value_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
404 AdgDimStylePrivate
*data
;
406 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
408 data
= dim_style
->data
;
410 if (adg_dress_set(&data
->value_dress
, dress
))
411 g_object_notify((GObject
*) dim_style
, "value-dress");
415 * adg_dim_style_get_up_dress:
416 * @dim_style: an #AdgDimStyle object
418 * Gets the @dim_style dress to be used for the upper limit.
420 * Returns: the upper limit dress
423 adg_dim_style_get_up_dress(AdgDimStyle
*dim_style
)
425 AdgDimStylePrivate
*data
;
427 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
429 data
= dim_style
->data
;
431 return data
->up_dress
;
435 * adg_dim_style_set_up_dress:
436 * @dim_style: an #AdgDimStyle object
437 * @dress: the new upper limit dress
439 * Sets a new dress on @dim_style for the upper limit value.
442 adg_dim_style_set_up_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
444 AdgDimStylePrivate
*data
;
446 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
448 data
= dim_style
->data
;
450 if (adg_dress_set(&data
->up_dress
, dress
))
451 g_object_notify((GObject
*) dim_style
, "up-dress");
455 * adg_dim_style_get_down_dress:
456 * @dim_style: an #AdgDimStyle object
458 * Gets the @dim_style dress to be used for the lower limit.
460 * Returns: the lower limit dress
463 adg_dim_style_get_down_dress(AdgDimStyle
*dim_style
)
465 AdgDimStylePrivate
*data
;
467 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
469 data
= dim_style
->data
;
471 return data
->down_dress
;
475 * adg_dim_style_set_down_dress:
476 * @dim_style: an #AdgDimStyle object
477 * @dress: the new lower limit dress
479 * Sets a new dress on @dim_style for the lower limit value.
482 adg_dim_style_set_down_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
484 AdgDimStylePrivate
*data
;
486 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
488 data
= dim_style
->data
;
490 if (adg_dress_set(&data
->down_dress
, dress
))
491 g_object_notify((GObject
*) dim_style
, "down-dress");
495 * adg_dim_style_get_note_dress:
496 * @dim_style: an #AdgDimStyle object
498 * Gets the @dim_style dress to be used for the note text.
500 * Returns: the note dress
503 adg_dim_style_get_note_dress(AdgDimStyle
*dim_style
)
505 AdgDimStylePrivate
*data
;
507 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
509 data
= dim_style
->data
;
511 return data
->note_dress
;
515 * adg_dim_style_set_note_dress:
516 * @dim_style: an #AdgDimStyle object
517 * @style: the new note style
519 * Sets a new dress on @dim_style for the note text.
522 adg_dim_style_set_note_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
524 AdgDimStylePrivate
*data
;
526 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
528 data
= dim_style
->data
;
530 if (adg_dress_set(&data
->note_dress
, dress
))
531 g_object_notify((GObject
*) dim_style
, "note-dress");
535 * adg_dim_style_get_line_dress:
536 * @dim_style: an #AdgDimStyle object
538 * Gets the @dim_style dress to be used for rendering the baseline and
539 * the extension lines.
541 * Returns: the line dress
544 adg_dim_style_get_line_dress(AdgDimStyle
*dim_style
)
546 AdgDimStylePrivate
*data
;
548 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), ADG_DRESS_UNDEFINED
);
550 data
= dim_style
->data
;
552 return data
->line_dress
;
556 * adg_dim_style_set_line_dress:
557 * @dim_style: an #AdgDimStyle object
558 * @dress: the new line dress
560 * Sets a new line dress on @dim_style.
563 adg_dim_style_set_line_dress(AdgDimStyle
*dim_style
, AdgDress dress
)
565 AdgDimStylePrivate
*data
;
567 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
569 data
= dim_style
->data
;
571 if (adg_dress_set(&data
->line_dress
, dress
))
572 g_object_notify((GObject
*) dim_style
, "line-dress");
576 * adg_dim_style_get_from_offset:
577 * @dim_style: an #AdgDimStyle object
579 * Gets the distance (in global space) the extension lines must keep from the
582 * Returns: the requested distance
585 adg_dim_style_get_from_offset(AdgDimStyle
*dim_style
)
587 AdgDimStylePrivate
*data
;
589 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
591 data
= dim_style
->data
;
593 return data
->from_offset
;
597 * adg_dim_style_set_from_offset:
598 * @dim_style: an #AdgDimStyle object
599 * @offset: the new offset
601 * Sets a new "from-offset" value.
604 adg_dim_style_set_from_offset(AdgDimStyle
*dim_style
, gdouble offset
)
606 AdgDimStylePrivate
*data
;
608 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
610 data
= dim_style
->data
;
611 data
->from_offset
= offset
;
613 g_object_notify((GObject
*) dim_style
, "from-offset");
617 * adg_dim_style_get_to_offset:
618 * @dim_style: an #AdgDimStyle object
620 * Gets how much (in global space) the extension lines must extend after
621 * crossing the baseline.
623 * Returns: the requested distance
626 adg_dim_style_get_to_offset(AdgDimStyle
*dim_style
)
628 AdgDimStylePrivate
*data
;
630 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
632 data
= dim_style
->data
;
634 return data
->to_offset
;
638 * adg_dim_style_set_to_offset:
639 * @dim_style: an #AdgDimStyle object
640 * @offset: the new offset
642 * Sets a new "to-offset" value.
645 adg_dim_style_set_to_offset(AdgDimStyle
*dim_style
, gdouble offset
)
647 AdgDimStylePrivate
*data
;
649 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
651 data
= dim_style
->data
;
652 data
->to_offset
= offset
;
654 g_object_notify((GObject
*) dim_style
, "to-offset");
658 * adg_dim_style_beyond:
659 * @dim_style: an #AdgDimStyle object
661 * Gets how much (in global space) the baseline should extend beyound
662 * the extension lines when a dimension has outside markers. If the
663 * underlying AdgDimStyle:beyond property is %0, this function returns
664 * the 3*"marker-size", where "marker-size" is the value returned by
665 * adg_marker_style_get_size() on #AdgMarkerStyle binded to @dim_style.
667 * Returns: the requested lenght
670 adg_dim_style_beyond(AdgDimStyle
*dim_style
)
672 AdgDimStylePrivate
*data
;
675 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
677 data
= dim_style
->data
;
680 if (data
->beyond
> 0)
683 return marker_size
* 3;
687 * adg_dim_style_get_beyond:
688 * @dim_style: an #AdgDimStyle object
690 * Gets how much (in global space) the baseline should extend beyound
691 * the extension lines on dimension with outside markers. This is an
692 * accessor method: if you need AdgDimStyle:beyond for rendering purpose,
693 * use adg_dim_style_beyond() instead.
695 * Returns: the requested lenght or %0 for automatic computation
698 adg_dim_style_get_beyond(AdgDimStyle
*dim_style
)
700 AdgDimStylePrivate
*data
;
702 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
704 data
= dim_style
->data
;
710 * adg_dim_style_set_beyond:
711 * @dim_style: an #AdgDimStyle object
712 * @length: the new length
714 * Sets a new "beyond" value.
717 adg_dim_style_set_beyond(AdgDimStyle
*dim_style
, gdouble length
)
719 AdgDimStylePrivate
*data
;
721 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
723 data
= dim_style
->data
;
724 data
->beyond
= length
;
726 g_object_notify((GObject
*) dim_style
, "beyond");
730 * adg_dim_style_get_baseline_spacing:
731 * @dim_style: an #AdgDimStyle object
733 * Gets the distance between two consecutive baselines
734 * while stacking dimensions.
736 * Returns: the requested spacing
739 adg_dim_style_get_baseline_spacing(AdgDimStyle
*dim_style
)
741 AdgDimStylePrivate
*data
;
743 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
745 data
= dim_style
->data
;
747 return data
->baseline_spacing
;
751 * adg_dim_style_set_baseline_spacing:
752 * @dim_style: an #AdgDimStyle object
753 * @spacing: the new spacing
755 * Sets a new "baseline-spacing" value.
758 adg_dim_style_set_baseline_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
760 AdgDimStylePrivate
*data
;
762 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
764 data
= dim_style
->data
;
765 data
->baseline_spacing
= spacing
;
767 g_object_notify((GObject
*) dim_style
, "baseline-spacing");
771 * adg_dim_style_get_tolerance_spacing:
772 * @dim_style: an #AdgDimStyle object
774 * Gets the distance (in global space) between up and down tolerances.
776 * Returns: the requested spacing
779 adg_dim_style_get_tolerance_spacing(AdgDimStyle
*dim_style
)
781 AdgDimStylePrivate
*data
;
783 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0);
785 data
= dim_style
->data
;
787 return data
->tolerance_spacing
;
791 * adg_dim_style_set_tolerance_spacing:
792 * @dim_style: an #AdgDimStyle object
793 * @spacing: the new spacing
795 * Sets a new "tolerance-spacing" value.
798 adg_dim_style_set_tolerance_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
800 AdgDimStylePrivate
*data
;
802 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
804 data
= dim_style
->data
;
805 data
->tolerance_spacing
= spacing
;
807 g_object_notify((GObject
*) dim_style
, "tolerance-spacing");
811 * adg_dim_style_get_quote_shift:
812 * @dim_style: an #AdgDimStyle object
814 * Gets the smooth displacement of the quote. The returned pointer refers
815 * to an internal allocated struct and must not be modified or freed.
817 * Returns: the requested shift
820 adg_dim_style_get_quote_shift(AdgDimStyle
*dim_style
)
822 AdgDimStylePrivate
*data
;
824 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
826 data
= dim_style
->data
;
828 return &data
->quote_shift
;
832 * adg_dim_style_set_quote_shift:
833 * @dim_style: an #AdgDimStyle object
834 * @shift: the new displacement
836 * Sets a new "quote-shift" value.
839 adg_dim_style_set_quote_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
841 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
843 set_quote_shift(dim_style
, shift
);
844 g_object_notify((GObject
*) dim_style
, "quote-shift");
848 * adg_dim_style_get_tolerance_shift:
849 * @dim_style: an #AdgDimStyle object
851 * Gets the smooth displacement of the tolerance text. The returned pointer
852 * refers to an internal allocated struct and must not be modified or freed.
854 * Returns: the requested shift
857 adg_dim_style_get_tolerance_shift(AdgDimStyle
*dim_style
)
859 AdgDimStylePrivate
*data
;
861 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
863 data
= dim_style
->data
;
865 return &data
->tolerance_shift
;
869 * adg_dim_style_set_tolerance_shift:
870 * @dim_style: an #AdgDimStyle object
871 * @shift: the new displacement
873 * Sets a new "tolerance-shift" value.
876 adg_dim_style_set_tolerance_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
878 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
880 set_tolerance_shift(dim_style
, shift
);
881 g_object_notify((GObject
*) dim_style
, "tolerance-shift");
885 * adg_dim_style_get_note_shift:
886 * @dim_style: an #AdgDimStyle object
888 * Gets the smooth displacement of the note text. The returned pointer
889 * refers to an internal allocated struct and must not be modified or freed.
891 * Returns: the requested shift
894 adg_dim_style_get_note_shift(AdgDimStyle
*dim_style
)
896 AdgDimStylePrivate
*data
;
898 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
900 data
= dim_style
->data
;
902 return &data
->note_shift
;
906 * adg_dim_style_set_note_shift:
907 * @dim_style: an #AdgDimStyle object
908 * @shift: the new displacement
910 * Sets a new "note-shift" value.
913 adg_dim_style_set_note_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
915 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
917 set_note_shift(dim_style
, shift
);
918 g_object_notify((GObject
*) dim_style
, "note-shift");
922 * adg_dim_style_get_number_format:
923 * @dim_style: an #AdgDimStyle object
925 * Gets the number format (in printf style) of this quoting style. The
926 * returned pointer refers to internally managed text that must not be
929 * Returns: the requested format
932 adg_dim_style_get_number_format(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
->number_format
;
944 * adg_dim_style_set_number_format:
945 * @dim_style: an #AdgDimStyle object
946 * @format: the new format to adopt
948 * Sets a new "number-format" value.
951 adg_dim_style_set_number_format(AdgDimStyle
*dim_style
, const gchar
*format
)
953 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
955 set_number_format(dim_style
, format
);
956 g_object_notify((GObject
*) dim_style
, "number-format");
960 * adg_dim_style_get_number_tag:
961 * @dim_style: an #AdgDimStyle object
963 * Gets the number tag to substitute while building the basic value. The
964 * returned pointer refers to internally managed text that must not be
967 * Returns: the requested tag
970 adg_dim_style_get_number_tag(AdgDimStyle
*dim_style
)
972 AdgDimStylePrivate
*data
;
974 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
976 data
= dim_style
->data
;
978 return data
->number_tag
;
982 * adg_dim_style_set_number_tag:
983 * @dim_style: an #AdgDimStyle object
986 * Sets a new "number-tag" value.
989 adg_dim_style_set_number_tag(AdgDimStyle
*dim_style
, const gchar
*tag
)
991 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
993 set_number_tag(dim_style
, tag
);
994 g_object_notify((GObject
*) dim_style
, "number-tag");
999 apply(AdgStyle
*style
, cairo_t
*cr
)
1004 set_quote_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
1006 AdgDimStylePrivate
*data
= dim_style
->data
;
1008 cpml_pair_copy(&data
->quote_shift
, shift
);
1012 set_tolerance_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
1014 AdgDimStylePrivate
*data
= dim_style
->data
;
1016 cpml_pair_copy(&data
->tolerance_shift
, shift
);
1020 set_note_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
1022 AdgDimStylePrivate
*data
= dim_style
->data
;
1024 cpml_pair_copy(&data
->note_shift
, shift
);
1028 set_number_format(AdgDimStyle
*dim_style
, const gchar
*format
)
1030 AdgDimStylePrivate
*data
= dim_style
->data
;
1032 g_free(data
->number_format
);
1033 data
->number_format
= g_strdup(format
);
1037 set_number_tag(AdgDimStyle
*dim_style
, const gchar
*tag
)
1039 AdgDimStylePrivate
*data
= dim_style
->data
;
1041 g_free(data
->number_tag
);
1042 data
->number_tag
= g_strdup(tag
);