Added accessors to AdgLineStyle
[adg.git] / adg / adg-dim-style.c
blob66592b73e2c0c565cb41b4fadaf1091403231ff9
1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007-2008, Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 /**
22 * SECTION:dim-style
23 * @title: AdgDimStyle
24 * @short_description: Dimension style related stuff
26 * Contains parameters on how to build dimensions such as the different font
27 * styles (for quote, tolerance and note), line style, offsets of the various
28 * dimension components etc...
31 #include "adg-dim-style.h"
32 #include "adg-dim-style-private.h"
33 #include "adg-font-style.h"
34 #include "adg-line-style.h"
35 #include "adg-arrow-style.h"
36 #include "adg-intl.h"
37 #include "adg-util.h"
39 #define PARENT_CLASS ((AdgStyleClass *) adg_dim_style_parent_class)
42 enum
44 PROP_0,
45 PROP_QUOTE_STYLE,
46 PROP_TOLERANCE_STYLE,
47 PROP_NOTE_STYLE,
48 PROP_LINE_STYLE,
49 PROP_ARROW_STYLE,
50 PROP_FROM_OFFSET,
51 PROP_TO_OFFSET,
52 PROP_BASELINE_SPACING,
53 PROP_TOLERANCE_SPACING,
54 PROP_QUOTE_SHIFT,
55 PROP_TOLERANCE_SHIFT,
56 PROP_NOTE_SHIFT,
57 PROP_NUMBER_FORMAT,
58 PROP_NUMBER_TAG
62 static void get_property (GObject *object,
63 guint prop_id,
64 GValue *value,
65 GParamSpec *pspec);
66 static void set_property (GObject *object,
67 guint prop_id,
68 const GValue *value,
69 GParamSpec *pspec);
71 static void set_quote_style (AdgDimStyle *dim_style,
72 AdgFontStyle *style);
73 static void set_tolerance_style (AdgDimStyle *dim_style,
74 AdgFontStyle *style);
75 static void set_note_style (AdgDimStyle *dim_style,
76 AdgFontStyle *style);
77 static void set_line_style (AdgDimStyle *dim_style,
78 AdgLineStyle *style);
79 static void set_arrow_style (AdgDimStyle *dim_style,
80 AdgArrowStyle *style);
81 static void set_quote_shift (AdgDimStyle *dim_style,
82 const AdgPair *offset);
83 static void set_tolerance_shift (AdgDimStyle *dim_style,
84 const AdgPair *offset);
85 static void set_note_shift (AdgDimStyle *dim_style,
86 const AdgPair *offset);
87 static void set_number_format (AdgDimStyle *dim_style,
88 const gchar *format);
89 static void set_number_tag (AdgDimStyle *dim_style,
90 const gchar *tag);
93 G_DEFINE_TYPE (AdgDimStyle, adg_dim_style, ADG_TYPE_STYLE)
96 static void
97 adg_dim_style_class_init (AdgDimStyleClass *klass)
99 GObjectClass *gobject_class;
100 GParamSpec *param;
102 gobject_class = (GObjectClass *) klass;
104 g_type_class_add_private (klass, sizeof (AdgDimStylePrivate));
106 gobject_class->get_property = get_property;
107 gobject_class->set_property = set_property;
109 param = g_param_spec_object ("quote-style",
110 P_("Quote Style"),
111 P_("Font style for the quote"),
112 ADG_TYPE_STYLE,
113 G_PARAM_READWRITE);
114 g_object_class_install_property (gobject_class, PROP_QUOTE_STYLE, param);
116 param = g_param_spec_object ("tolerance-style",
117 P_("Tolerance Style"),
118 P_("Font style for the tolerances"),
119 ADG_TYPE_STYLE,
120 G_PARAM_READWRITE);
121 g_object_class_install_property (gobject_class, PROP_TOLERANCE_STYLE, param);
123 param = g_param_spec_object ("note-style",
124 P_("Note Style"),
125 P_("Font style for the note (the text after or under the quote)"),
126 ADG_TYPE_STYLE,
127 G_PARAM_READWRITE);
128 g_object_class_install_property (gobject_class, PROP_NOTE_STYLE, param);
130 param = g_param_spec_object ("line-style",
131 P_("Line Style"),
132 P_("Line style for the baseline and the extension lines"),
133 ADG_TYPE_STYLE,
134 G_PARAM_READWRITE);
135 g_object_class_install_property (gobject_class, PROP_LINE_STYLE, param);
137 param = g_param_spec_object ("arrow-style",
138 P_("Arrow Style"),
139 P_("Arrow style to use on the baseline"),
140 ADG_TYPE_STYLE,
141 G_PARAM_READWRITE);
142 g_object_class_install_property (gobject_class, PROP_ARROW_STYLE, param);
144 param = g_param_spec_double ("from-offset",
145 P_("From Offset"),
146 P_("Offset (in paper space) of the extension lines from the path to quote"),
147 0., G_MAXDOUBLE, 5.,
148 G_PARAM_READWRITE);
149 g_object_class_install_property (gobject_class, PROP_FROM_OFFSET, param);
151 param = g_param_spec_double ("to-offset",
152 P_("To Offset"),
153 P_("How many extend (in paper space) the extension lines after hitting the baseline"),
154 0., G_MAXDOUBLE, 5.,
155 G_PARAM_READWRITE);
156 g_object_class_install_property (gobject_class, PROP_TO_OFFSET, param);
158 param = g_param_spec_double ("baseline-spacing",
159 P_("Baseline Spacing"),
160 P_("Distance between two consecutive baselines while stacking dimensions"),
161 0., G_MAXDOUBLE, 30.,
162 G_PARAM_READWRITE);
163 g_object_class_install_property (gobject_class, PROP_BASELINE_SPACING, param);
165 param = g_param_spec_double ("tolerance-spacing",
166 P_("Tolerance Spacing"),
167 P_("Distance between up and down tolerance text"),
168 0., G_MAXDOUBLE, 2.,
169 G_PARAM_READWRITE);
170 g_object_class_install_property (gobject_class, PROP_TOLERANCE_SPACING, param);
172 param = g_param_spec_boxed ("quote-offset",
173 P_("Quote Offset"),
174 P_("Used to specify a smooth displacement (in paper units) for the quote text by taking as reference the perfect compact position (the middle of the baseline on common linear quotes, for instance)"),
175 ADG_TYPE_PAIR,
176 G_PARAM_READWRITE);
177 g_object_class_install_property (gobject_class, PROP_QUOTE_SHIFT, param);
179 param = g_param_spec_boxed ("tolerance-offset",
180 P_("Tolerance Offset"),
181 P_("Used to specify a smooth displacement (in paper units) for the tolerance text by taking as reference the perfect compact position"),
182 ADG_TYPE_PAIR,
183 G_PARAM_READWRITE);
184 g_object_class_install_property (gobject_class, PROP_TOLERANCE_SHIFT, param);
186 param = g_param_spec_boxed ("note-offset",
187 P_("Note Offset"),
188 P_("Used to specify a smooth displacement (in paper units) for the note text by taking as reference the perfect compact position"),
189 ADG_TYPE_PAIR,
190 G_PARAM_READWRITE);
191 g_object_class_install_property (gobject_class, PROP_NOTE_SHIFT, param);
193 param = g_param_spec_string ("number-format",
194 P_("Number Format"),
195 P_("The format (in printf style) of the numeric component of the quote"),
196 "%-.7g",
197 G_PARAM_READWRITE);
198 g_object_class_install_property (gobject_class, PROP_NUMBER_FORMAT, param);
200 param = g_param_spec_string ("number-tag",
201 P_("Number Tag"),
202 P_("The tag to substitute inside the quote pattern"),
203 "<>",
204 G_PARAM_READWRITE);
205 g_object_class_install_property (gobject_class, PROP_NUMBER_TAG, param);
208 static void
209 adg_dim_style_init (AdgDimStyle *dim_style)
211 AdgDimStylePrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (dim_style,
212 ADG_TYPE_DIM_STYLE,
213 AdgDimStylePrivate);
215 priv->quote_style = adg_font_style_from_id (ADG_FONT_STYLE_QUOTE);
216 priv->tolerance_style = adg_font_style_from_id (ADG_FONT_STYLE_TOLERANCE);
217 priv->note_style = adg_font_style_from_id (ADG_FONT_STYLE_NOTE);
218 priv->line_style = adg_line_style_from_id (ADG_LINE_STYLE_DIM);
219 priv->arrow_style = adg_arrow_style_from_id (ADG_ARROW_STYLE_ARROW);
220 priv->from_offset = 5.;
221 priv->to_offset = 5.;
222 priv->baseline_spacing = 30.;
223 priv->tolerance_spacing = 2.;
224 priv->quote_shift.x = 0.;
225 priv->quote_shift.y = -3.;
226 priv->tolerance_shift.x = +5.;
227 priv->tolerance_shift.y = -4.;
228 priv->note_shift.x = +5.;
229 priv->note_shift.y = 0.;
230 priv->number_format = g_strdup ("%-.7g");
231 priv->number_tag = g_strdup ("<>");
233 dim_style->priv = priv;
236 static void
237 get_property (GObject *object,
238 guint prop_id,
239 GValue *value,
240 GParamSpec *pspec)
242 AdgDimStyle *dim_style = (AdgDimStyle *) object;
244 switch (prop_id)
246 case PROP_QUOTE_STYLE:
247 g_value_set_object (value, dim_style->priv->quote_style);
248 break;
249 case PROP_TOLERANCE_STYLE:
250 g_value_set_object (value, dim_style->priv->tolerance_style);
251 break;
252 case PROP_NOTE_STYLE:
253 g_value_set_object (value, dim_style->priv->note_style);
254 break;
255 case PROP_LINE_STYLE:
256 g_value_set_object (value, dim_style->priv->line_style);
257 break;
258 case PROP_ARROW_STYLE:
259 g_value_set_object (value, dim_style->priv->arrow_style);
260 break;
261 case PROP_FROM_OFFSET:
262 g_value_set_double (value, dim_style->priv->from_offset);
263 break;
264 case PROP_TO_OFFSET:
265 g_value_set_double (value, dim_style->priv->to_offset);
266 break;
267 case PROP_BASELINE_SPACING:
268 g_value_set_double (value, dim_style->priv->baseline_spacing);
269 break;
270 case PROP_TOLERANCE_SPACING:
271 g_value_set_double (value, dim_style->priv->tolerance_spacing);
272 break;
273 case PROP_QUOTE_SHIFT:
274 g_value_set_boxed (value, &dim_style->priv->quote_shift);
275 break;
276 case PROP_TOLERANCE_SHIFT:
277 g_value_set_boxed (value, &dim_style->priv->tolerance_shift);
278 break;
279 case PROP_NOTE_SHIFT:
280 g_value_set_boxed (value, &dim_style->priv->note_shift);
281 break;
282 case PROP_NUMBER_FORMAT:
283 g_value_set_string (value, dim_style->priv->number_format);
284 break;
285 case PROP_NUMBER_TAG:
286 g_value_set_string (value, dim_style->priv->number_tag);
287 break;
288 default:
289 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
290 break;
294 static void
295 set_property (GObject *object,
296 guint prop_id,
297 const GValue *value,
298 GParamSpec *pspec)
300 AdgDimStyle *dim_style = (AdgDimStyle *) object;
302 switch (prop_id)
304 case PROP_QUOTE_STYLE:
305 set_quote_style (dim_style, g_value_get_object (value));
306 break;
307 case PROP_TOLERANCE_STYLE:
308 set_tolerance_style (dim_style, g_value_get_object (value));
309 break;
310 case PROP_NOTE_STYLE:
311 set_note_style (dim_style, g_value_get_object (value));
312 break;
313 case PROP_LINE_STYLE:
314 set_line_style (dim_style, g_value_get_object (value));
315 break;
316 case PROP_ARROW_STYLE:
317 set_arrow_style (dim_style, g_value_get_object (value));
318 break;
319 case PROP_FROM_OFFSET:
320 dim_style->priv->from_offset = g_value_get_double (value);
321 break;
322 case PROP_TO_OFFSET:
323 dim_style->priv->to_offset = g_value_get_double (value);
324 break;
325 case PROP_BASELINE_SPACING:
326 dim_style->priv->baseline_spacing = g_value_get_double (value);
327 break;
328 case PROP_TOLERANCE_SPACING:
329 dim_style->priv->tolerance_spacing = g_value_get_double (value);
330 break;
331 case PROP_QUOTE_SHIFT:
332 set_quote_shift (dim_style, g_value_get_boxed (value));
333 break;
334 case PROP_TOLERANCE_SHIFT:
335 set_tolerance_shift (dim_style, g_value_get_boxed (value));
336 break;
337 case PROP_NOTE_SHIFT:
338 set_note_shift (dim_style, g_value_get_boxed (value));
339 break;
340 case PROP_NUMBER_FORMAT:
341 set_number_format (dim_style, g_value_get_string (value));
342 break;
343 case PROP_NUMBER_TAG:
344 set_number_tag (dim_style, g_value_get_string (value));
345 break;
346 default:
347 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
348 break;
354 * adg_dim_style_from_id:
355 * @id: a dimension style identifier
357 * Gets a predefined style from an #AdgDimStyleId identifier.
359 * Return value: the requested style or %NULL if not found
361 AdgStyle *
362 adg_dim_style_from_id (AdgDimStyleId id)
364 static AdgStyle **builtins = NULL;
366 if G_UNLIKELY (builtins == NULL)
368 builtins = g_new (AdgStyle *, ADG_DIM_STYLE_LAST);
370 /* The default is yet the ISO style */
371 builtins[ADG_DIM_STYLE_ISO] = g_object_new (ADG_TYPE_DIM_STYLE, NULL);
374 g_return_val_if_fail (id < ADG_DIM_STYLE_LAST, NULL);
375 return builtins[id];
379 * adg_dim_style_get_quote_style:
380 * @dim_style: an #AdgDimStyle object
382 * Gets the quote style of @dim_style. No reference will be added to the
383 * returned style; it should not be unreferenced.
385 * Return value: the quote style or %NULL on errors
387 AdgStyle *
388 adg_dim_style_get_quote_style (AdgDimStyle *dim_style)
390 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
392 return dim_style->priv->quote_style;
396 * adg_dim_style_set_quote_style:
397 * @dim_style: an #AdgDimStyle object
398 * @style: the new quote style
400 * Sets a new quote style on @dim_style. The old quote style (if any) will be
401 * unreferenced while a new reference will be added to @style.
403 void
404 adg_dim_style_set_quote_style (AdgDimStyle *dim_style,
405 AdgFontStyle *style)
407 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
408 g_return_if_fail (ADG_IS_FONT_STYLE (style));
410 set_quote_style (dim_style, style);
411 g_object_notify ((GObject *) dim_style, "quote-style");
415 * adg_dim_style_get_tolerance_style:
416 * @dim_style: an #AdgDimStyle object
418 * Gets the tolerance style of @dim_style. No reference will be added to the
419 * returned style; it should not be unreferenced.
421 * Return value: the tolerance style or %NULL on errors
423 AdgStyle *
424 adg_dim_style_get_tolerance_style (AdgDimStyle *dim_style)
426 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
428 return dim_style->priv->tolerance_style;
432 * adg_dim_style_set_tolerance_style:
433 * @dim_style: an #AdgDimStyle object
434 * @style: the new tolerance style
436 * Sets a new tolerance style on @dim_style. The old tolerance style (if any)
437 * will be unreferenced while a new reference will be added to @style.
439 void
440 adg_dim_style_set_tolerance_style (AdgDimStyle *dim_style,
441 AdgFontStyle *style)
443 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
444 g_return_if_fail (ADG_IS_FONT_STYLE (style));
446 set_tolerance_style (dim_style, style);
447 g_object_notify ((GObject *) dim_style, "tolerance-style");
451 * adg_dim_style_get_note_style:
452 * @dim_style: an #AdgDimStyle object
454 * Gets the note style of @dim_style. No reference will be added to the
455 * returned style; it should not be unreferenced.
457 * Return value: the note style or %NULL on errors
459 AdgStyle *
460 adg_dim_style_get_note_style (AdgDimStyle *dim_style)
462 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
464 return dim_style->priv->note_style;
468 * adg_dim_style_set_note_style:
469 * @dim_style: an #AdgDimStyle object
470 * @style: the new note style
472 * Sets a new note style on @dim_style. The old note style (if any) will be
473 * unreferenced while a new reference will be added to @style.
475 void
476 adg_dim_style_set_note_style (AdgDimStyle *dim_style,
477 AdgFontStyle *style)
479 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
480 g_return_if_fail (ADG_IS_FONT_STYLE (style));
482 set_note_style (dim_style, style);
483 g_object_notify ((GObject *) dim_style, "note-style");
487 * adg_dim_style_get_line_style:
488 * @dim_style: an #AdgDimStyle object
490 * Gets the line style of @dim_style. No reference will be added to the
491 * returned style; it should not be unreferenced.
493 * Return value: the line style or %NULL on errors
495 AdgStyle *
496 adg_dim_style_get_line_style (AdgDimStyle *dim_style)
498 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
500 return dim_style->priv->line_style;
504 * adg_dim_style_set_line_style:
505 * @dim_style: an #AdgDimStyle object
506 * @style: the new line style
508 * Sets a new line style on @dim_style. The old line style (if any) will be
509 * unreferenced while a new reference will be added to @style.
511 void
512 adg_dim_style_set_line_style (AdgDimStyle *dim_style,
513 AdgLineStyle *style)
515 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
516 g_return_if_fail (ADG_IS_LINE_STYLE (style));
518 set_line_style (dim_style, style);
519 g_object_notify ((GObject *) dim_style, "line-style");
523 * adg_dim_style_get_arrow_style:
524 * @dim_style: an #AdgDimStyle object
526 * Gets the arrow style of @dim_style. No reference will be added to the
527 * returned style; it should not be unreferenced.
529 * Return value: the arrow style or %NULL on errors
531 AdgStyle *
532 adg_dim_style_get_arrow_style (AdgDimStyle *dim_style)
534 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
536 return dim_style->priv->arrow_style;
540 * adg_dim_style_set_arrow_style:
541 * @dim_style: an #AdgDimStyle object
542 * @style: the new arrow style
544 * Sets a new arrow style on @dim_style. The old arrow style (if any) will be
545 * unreferenced while a new reference will be added to @style.
547 void
548 adg_dim_style_set_arrow_style (AdgDimStyle *dim_style,
549 AdgArrowStyle *style)
551 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
552 g_return_if_fail (ADG_IS_ARROW_STYLE (style));
554 set_arrow_style (dim_style, style);
555 g_object_notify ((GObject *) dim_style, "arrow-style");
559 * adg_dim_style_get_from_offset:
560 * @dim_style: an #AdgDimStyle object
562 * Gets the distance (in paper space) the extension lines must keep from the
563 * sensed points.
565 * Return value: the requested distance
567 gdouble
568 adg_dim_style_get_from_offset (AdgDimStyle *dim_style)
570 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), 0.);
572 return dim_style->priv->from_offset;
576 * adg_dim_style_set_from_offset:
577 * @dim_style: an #AdgDimStyle object
578 * @offset: the new offset
580 * Sets a new "from-offset" value.
582 void
583 adg_dim_style_set_from_offset (AdgDimStyle *dim_style,
584 gdouble offset)
586 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
588 dim_style->priv->from_offset = offset;
589 g_object_notify ((GObject *) dim_style, "from-offset");
593 * adg_dim_style_get_to_offset:
594 * @dim_style: an #AdgDimStyle object
596 * Gets how much (in paper space) the extension lines must extend after
597 * crossing the baseline.
599 * Return value: the requested distance
601 gdouble
602 adg_dim_style_get_to_offset (AdgDimStyle *dim_style)
604 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), 0.);
606 return dim_style->priv->to_offset;
610 * adg_dim_style_set_to_offset:
611 * @dim_style: an #AdgDimStyle object
612 * @offset: the new offset
614 * Sets a new "to-offset" value.
616 void
617 adg_dim_style_set_to_offset (AdgDimStyle *dim_style,
618 gdouble offset)
620 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
622 dim_style->priv->to_offset = offset;
623 g_object_notify ((GObject *) dim_style, "to-offset");
627 * adg_dim_style_get_baseline_spacing:
628 * @dim_style: an #AdgDimStyle object
630 * Gets the distance between two consecutive baselines
631 * while stacking dimensions.
633 * Return value: the requested spacing
635 gdouble
636 adg_dim_style_get_baseline_spacing (AdgDimStyle *dim_style)
638 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), 0.);
640 return dim_style->priv->baseline_spacing;
644 * adg_dim_style_set_baseline_spacing:
645 * @dim_style: an #AdgDimStyle object
646 * @spacing: the new spacing
648 * Sets a new "baseline-spacing" value.
650 void
651 adg_dim_style_set_baseline_spacing (AdgDimStyle *dim_style,
652 gdouble spacing)
654 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
656 dim_style->priv->baseline_spacing = spacing;
657 g_object_notify ((GObject *) dim_style, "baseline-spacing");
661 * adg_dim_style_get_tolerance_spacing:
662 * @dim_style: an #AdgDimStyle object
664 * Gets the distance (in paper space) between up and down tolerances.
666 * Return value: the requested spacing
668 gdouble
669 adg_dim_style_get_tolerance_spacing (AdgDimStyle *dim_style)
671 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), 0.);
673 return dim_style->priv->tolerance_spacing;
677 * adg_dim_style_set_tolerance_spacing:
678 * @dim_style: an #AdgDimStyle object
679 * @spacing: the new spacing
681 * Sets a new "tolerance-spacing" value.
683 void
684 adg_dim_style_set_tolerance_spacing (AdgDimStyle *dim_style,
685 gdouble spacing)
687 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
689 dim_style->priv->tolerance_spacing = spacing;
690 g_object_notify ((GObject *) dim_style, "tolerance-spacing");
694 * adg_dim_style_get_quote_shift:
695 * @dim_style: an #AdgDimStyle object
697 * Gets the smooth displacement of the quote text. The returned pointer
698 * refers to an internal allocated struct and must not be modified or freed.
700 * Return value: the requested offset
702 const AdgPair *
703 adg_dim_style_get_quote_shift (AdgDimStyle *dim_style)
705 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
707 return &dim_style->priv->quote_shift;
711 * adg_dim_style_set_quote_shift:
712 * @dim_style: an #AdgDimStyle object
713 * @shift: the new displacement
715 * Sets a new "quote-offset" value.
717 void
718 adg_dim_style_set_quote_shift (AdgDimStyle *dim_style,
719 const AdgPair *shift)
721 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
723 set_quote_shift (dim_style, shift);
724 g_object_notify ((GObject *) dim_style, "quote-offset");
728 * adg_dim_style_get_tolerance_shift:
729 * @dim_style: an #AdgDimStyle object
731 * Gets the smooth displacement of the tolerance text. The returned pointer
732 * refers to an internal allocated struct and must not be modified or freed.
734 * Return value: the requested offset
736 const AdgPair *
737 adg_dim_style_get_tolerance_shift (AdgDimStyle *dim_style)
739 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
741 return &dim_style->priv->tolerance_shift;
745 * adg_dim_style_set_tolerance_shift:
746 * @dim_style: an #AdgDimStyle object
747 * @shift: the new displacement
749 * Sets a new "tolerance-offset" value.
751 void
752 adg_dim_style_set_tolerance_shift (AdgDimStyle *dim_style,
753 const AdgPair *shift)
755 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
757 set_tolerance_shift (dim_style, shift);
758 g_object_notify ((GObject *) dim_style, "tolerance-offset");
762 * adg_dim_style_get_note_shift:
763 * @dim_style: an #AdgDimStyle object
765 * Gets the smooth displacement of the note text. The returned pointer
766 * refers to an internal allocated struct and must not be modified or freed.
768 * Return value: the requested offset
770 const AdgPair *
771 adg_dim_style_get_note_shift (AdgDimStyle *dim_style)
773 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
775 return &dim_style->priv->note_shift;
779 * adg_dim_style_set_note_shift:
780 * @dim_style: an #AdgDimStyle object
781 * @shift: the new displacement
783 * Sets a new "note-offset" value.
785 void
786 adg_dim_style_set_note_shift (AdgDimStyle *dim_style,
787 const AdgPair *shift)
789 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
791 set_note_shift (dim_style, shift);
792 g_object_notify ((GObject *) dim_style, "note-offset");
796 * adg_dim_style_get_number_format:
797 * @dim_style: an #AdgDimStyle object
799 * Gets the number format (in printf style) of this quoting style. The
800 * returned pointer refers to internally managed text that must not be
801 * modified or freed.
803 * Return value: the requested format
805 const gchar *
806 adg_dim_style_get_number_format (AdgDimStyle *dim_style)
808 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
810 return dim_style->priv->number_format;
814 * adg_dim_style_set_number_format:
815 * @dim_style: an #AdgDimStyle object
816 * @format: the new format to adopt
818 * Sets a new "number-format" value.
820 void
821 adg_dim_style_set_number_format (AdgDimStyle *dim_style,
822 const gchar *format)
824 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
826 set_number_format (dim_style, format);
827 g_object_notify ((GObject *) dim_style, "number-format");
831 * adg_dim_style_get_number_tag:
832 * @dim_style: an #AdgDimStyle object
834 * Gets the number tag to substitute while building the quote text. The
835 * returned pointer refers to internally managed text that must not be
836 * modified or freed.
838 * Return value: the requested tag
840 const gchar *
841 adg_dim_style_get_number_tag (AdgDimStyle *dim_style)
843 g_return_val_if_fail (ADG_IS_DIM_STYLE (dim_style), NULL);
845 return dim_style->priv->number_tag;
849 * adg_dim_style_set_number_tag:
850 * @dim_style: an #AdgDimStyle object
851 * @tag: the new tag
853 * Sets a new "number-tag" value.
855 void
856 adg_dim_style_set_number_tag (AdgDimStyle *dim_style,
857 const gchar *tag)
859 g_return_if_fail (ADG_IS_DIM_STYLE (dim_style));
861 set_number_tag (dim_style, tag);
862 g_object_notify ((GObject *) dim_style, "number-tag");
866 static void
867 set_quote_style (AdgDimStyle *dim_style,
868 AdgFontStyle *style)
870 if (dim_style->priv->quote_style)
871 g_object_unref (dim_style->priv->quote_style);
873 g_object_ref (style);
874 dim_style->priv->quote_style = (AdgStyle *) style;
877 static void
878 set_tolerance_style (AdgDimStyle *dim_style,
879 AdgFontStyle *style)
881 if (dim_style->priv->tolerance_style)
882 g_object_unref (dim_style->priv->tolerance_style);
884 g_object_ref (style);
885 dim_style->priv->tolerance_style = (AdgStyle *) style;
888 static void
889 set_note_style (AdgDimStyle *dim_style,
890 AdgFontStyle *style)
892 if (dim_style->priv->note_style)
893 g_object_unref (dim_style->priv->note_style);
895 g_object_ref (style);
896 dim_style->priv->note_style = (AdgStyle *) style;
899 static void
900 set_line_style (AdgDimStyle *dim_style,
901 AdgLineStyle *style)
903 if (dim_style->priv->line_style)
904 g_object_unref (dim_style->priv->line_style);
906 g_object_ref (style);
907 dim_style->priv->line_style = (AdgStyle *) style;
910 static void
911 set_arrow_style (AdgDimStyle *dim_style,
912 AdgArrowStyle *style)
914 if (dim_style->priv->arrow_style)
915 g_object_unref (dim_style->priv->arrow_style);
917 g_object_ref (style);
918 dim_style->priv->arrow_style = (AdgStyle *) style;
921 static void
922 set_quote_shift (AdgDimStyle *dim_style,
923 const AdgPair *offset)
925 cpml_pair_copy (&dim_style->priv->quote_shift, offset);
928 static void
929 set_tolerance_shift (AdgDimStyle *dim_style,
930 const AdgPair *offset)
932 cpml_pair_copy (&dim_style->priv->tolerance_shift, offset);
935 static void
936 set_note_shift (AdgDimStyle *dim_style,
937 const AdgPair *offset)
939 cpml_pair_copy (&dim_style->priv->note_shift, offset);
942 static void
943 set_number_format (AdgDimStyle *dim_style,
944 const gchar *format)
946 g_free (dim_style->priv->number_format);
947 dim_style->priv->number_format = g_strdup (format);
950 static void
951 set_number_tag (AdgDimStyle *dim_style,
952 const gchar *tag)
954 g_free (dim_style->priv->number_tag);
955 dim_style->priv->number_tag = g_strdup (tag);