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.
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"
39 #define PARENT_CLASS ((AdgStyleClass *) adg_dim_style_parent_class)
52 PROP_BASELINE_SPACING
,
53 PROP_TOLERANCE_SPACING
,
62 static void get_property (GObject
*object
,
66 static void set_property (GObject
*object
,
71 static void set_quote_style (AdgDimStyle
*dim_style
,
73 static void set_tolerance_style (AdgDimStyle
*dim_style
,
75 static void set_note_style (AdgDimStyle
*dim_style
,
77 static void set_line_style (AdgDimStyle
*dim_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
,
89 static void set_number_tag (AdgDimStyle
*dim_style
,
93 G_DEFINE_TYPE (AdgDimStyle
, adg_dim_style
, ADG_TYPE_STYLE
)
97 adg_dim_style_class_init (AdgDimStyleClass
*klass
)
99 GObjectClass
*gobject_class
;
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",
111 P_("Font style for the quote"),
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"),
121 g_object_class_install_property (gobject_class
, PROP_TOLERANCE_STYLE
, param
);
123 param
= g_param_spec_object ("note-style",
125 P_("Font style for the note (the text after or under the quote)"),
128 g_object_class_install_property (gobject_class
, PROP_NOTE_STYLE
, param
);
130 param
= g_param_spec_object ("line-style",
132 P_("Line style for the baseline and the extension lines"),
135 g_object_class_install_property (gobject_class
, PROP_LINE_STYLE
, param
);
137 param
= g_param_spec_object ("arrow-style",
139 P_("Arrow style to use on the baseline"),
142 g_object_class_install_property (gobject_class
, PROP_ARROW_STYLE
, param
);
144 param
= g_param_spec_double ("from-offset",
146 P_("Offset (in paper space) of the extension lines from the path to quote"),
149 g_object_class_install_property (gobject_class
, PROP_FROM_OFFSET
, param
);
151 param
= g_param_spec_double ("to-offset",
153 P_("How many extend (in paper space) the extension lines after hitting the baseline"),
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.,
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"),
170 g_object_class_install_property (gobject_class
, PROP_TOLERANCE_SPACING
, param
);
172 param
= g_param_spec_boxed ("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)"),
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"),
184 g_object_class_install_property (gobject_class
, PROP_TOLERANCE_SHIFT
, param
);
186 param
= g_param_spec_boxed ("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"),
191 g_object_class_install_property (gobject_class
, PROP_NOTE_SHIFT
, param
);
193 param
= g_param_spec_string ("number-format",
195 P_("The format (in printf style) of the numeric component of the quote"),
198 g_object_class_install_property (gobject_class
, PROP_NUMBER_FORMAT
, param
);
200 param
= g_param_spec_string ("number-tag",
202 P_("The tag to substitute inside the quote pattern"),
205 g_object_class_install_property (gobject_class
, PROP_NUMBER_TAG
, param
);
209 adg_dim_style_init (AdgDimStyle
*dim_style
)
211 AdgDimStylePrivate
*priv
= G_TYPE_INSTANCE_GET_PRIVATE (dim_style
,
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
;
237 get_property (GObject
*object
,
242 AdgDimStyle
*dim_style
= (AdgDimStyle
*) object
;
246 case PROP_QUOTE_STYLE
:
247 g_value_set_object (value
, dim_style
->priv
->quote_style
);
249 case PROP_TOLERANCE_STYLE
:
250 g_value_set_object (value
, dim_style
->priv
->tolerance_style
);
252 case PROP_NOTE_STYLE
:
253 g_value_set_object (value
, dim_style
->priv
->note_style
);
255 case PROP_LINE_STYLE
:
256 g_value_set_object (value
, dim_style
->priv
->line_style
);
258 case PROP_ARROW_STYLE
:
259 g_value_set_object (value
, dim_style
->priv
->arrow_style
);
261 case PROP_FROM_OFFSET
:
262 g_value_set_double (value
, dim_style
->priv
->from_offset
);
265 g_value_set_double (value
, dim_style
->priv
->to_offset
);
267 case PROP_BASELINE_SPACING
:
268 g_value_set_double (value
, dim_style
->priv
->baseline_spacing
);
270 case PROP_TOLERANCE_SPACING
:
271 g_value_set_double (value
, dim_style
->priv
->tolerance_spacing
);
273 case PROP_QUOTE_SHIFT
:
274 g_value_set_boxed (value
, &dim_style
->priv
->quote_shift
);
276 case PROP_TOLERANCE_SHIFT
:
277 g_value_set_boxed (value
, &dim_style
->priv
->tolerance_shift
);
279 case PROP_NOTE_SHIFT
:
280 g_value_set_boxed (value
, &dim_style
->priv
->note_shift
);
282 case PROP_NUMBER_FORMAT
:
283 g_value_set_string (value
, dim_style
->priv
->number_format
);
285 case PROP_NUMBER_TAG
:
286 g_value_set_string (value
, dim_style
->priv
->number_tag
);
289 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
295 set_property (GObject
*object
,
300 AdgDimStyle
*dim_style
= (AdgDimStyle
*) object
;
304 case PROP_QUOTE_STYLE
:
305 set_quote_style (dim_style
, g_value_get_object (value
));
307 case PROP_TOLERANCE_STYLE
:
308 set_tolerance_style (dim_style
, g_value_get_object (value
));
310 case PROP_NOTE_STYLE
:
311 set_note_style (dim_style
, g_value_get_object (value
));
313 case PROP_LINE_STYLE
:
314 set_line_style (dim_style
, g_value_get_object (value
));
316 case PROP_ARROW_STYLE
:
317 set_arrow_style (dim_style
, g_value_get_object (value
));
319 case PROP_FROM_OFFSET
:
320 dim_style
->priv
->from_offset
= g_value_get_double (value
);
323 dim_style
->priv
->to_offset
= g_value_get_double (value
);
325 case PROP_BASELINE_SPACING
:
326 dim_style
->priv
->baseline_spacing
= g_value_get_double (value
);
328 case PROP_TOLERANCE_SPACING
:
329 dim_style
->priv
->tolerance_spacing
= g_value_get_double (value
);
331 case PROP_QUOTE_SHIFT
:
332 set_quote_shift (dim_style
, g_value_get_boxed (value
));
334 case PROP_TOLERANCE_SHIFT
:
335 set_tolerance_shift (dim_style
, g_value_get_boxed (value
));
337 case PROP_NOTE_SHIFT
:
338 set_note_shift (dim_style
, g_value_get_boxed (value
));
340 case PROP_NUMBER_FORMAT
:
341 set_number_format (dim_style
, g_value_get_string (value
));
343 case PROP_NUMBER_TAG
:
344 set_number_tag (dim_style
, g_value_get_string (value
));
347 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, prop_id
, pspec
);
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
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
);
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
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.
404 adg_dim_style_set_quote_style (AdgDimStyle
*dim_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
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.
440 adg_dim_style_set_tolerance_style (AdgDimStyle
*dim_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
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.
476 adg_dim_style_set_note_style (AdgDimStyle
*dim_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
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.
512 adg_dim_style_set_line_style (AdgDimStyle
*dim_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
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.
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
565 * Return value: the requested distance
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.
583 adg_dim_style_set_from_offset (AdgDimStyle
*dim_style
,
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
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.
617 adg_dim_style_set_to_offset (AdgDimStyle
*dim_style
,
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
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.
651 adg_dim_style_set_baseline_spacing (AdgDimStyle
*dim_style
,
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
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.
684 adg_dim_style_set_tolerance_spacing (AdgDimStyle
*dim_style
,
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
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.
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
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.
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
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.
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
803 * Return value: the requested format
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.
821 adg_dim_style_set_number_format (AdgDimStyle
*dim_style
,
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
838 * Return value: the requested tag
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
853 * Sets a new "number-tag" value.
856 adg_dim_style_set_number_tag (AdgDimStyle
*dim_style
,
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");
867 set_quote_style (AdgDimStyle
*dim_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
;
878 set_tolerance_style (AdgDimStyle
*dim_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
;
889 set_note_style (AdgDimStyle
*dim_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
;
900 set_line_style (AdgDimStyle
*dim_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
;
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
;
922 set_quote_shift (AdgDimStyle
*dim_style
,
923 const AdgPair
*offset
)
925 cpml_pair_copy (&dim_style
->priv
->quote_shift
, offset
);
929 set_tolerance_shift (AdgDimStyle
*dim_style
,
930 const AdgPair
*offset
)
932 cpml_pair_copy (&dim_style
->priv
->tolerance_shift
, offset
);
936 set_note_shift (AdgDimStyle
*dim_style
,
937 const AdgPair
*offset
)
939 cpml_pair_copy (&dim_style
->priv
->note_shift
, offset
);
943 set_number_format (AdgDimStyle
*dim_style
,
946 g_free (dim_style
->priv
->number_format
);
947 dim_style
->priv
->number_format
= g_strdup (format
);
951 set_number_tag (AdgDimStyle
*dim_style
,
954 g_free (dim_style
->priv
->number_tag
);
955 dim_style
->priv
->number_tag
= g_strdup (tag
);