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 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.
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)
51 PROP_BASELINE_SPACING
,
52 PROP_TOLERANCE_SPACING
,
61 static void get_property (GObject
*object
,
65 static void set_property (GObject
*object
,
69 static GPtrArray
* get_pool (void);
70 static void set_quote_style (AdgDimStyle
*dim_style
,
72 static void set_tolerance_style (AdgDimStyle
*dim_style
,
74 static void set_note_style (AdgDimStyle
*dim_style
,
76 static void set_line_style (AdgDimStyle
*dim_style
,
78 static void set_arrow_style (AdgDimStyle
*dim_style
,
79 AdgArrowStyle
*style
);
80 static void set_quote_shift (AdgDimStyle
*dim_style
,
81 const AdgPair
*shift
);
82 static void set_tolerance_shift (AdgDimStyle
*dim_style
,
83 const AdgPair
*shift
);
84 static void set_note_shift (AdgDimStyle
*dim_style
,
85 const AdgPair
*shift
);
86 static void set_number_format (AdgDimStyle
*dim_style
,
88 static void set_number_tag (AdgDimStyle
*dim_style
,
92 G_DEFINE_TYPE(AdgDimStyle
, adg_dim_style
, ADG_TYPE_STYLE
)
96 adg_dim_style_class_init(AdgDimStyleClass
*klass
)
98 GObjectClass
*gobject_class
;
99 AdgStyleClass
*style_class
;
102 gobject_class
= (GObjectClass
*) klass
;
103 style_class
= (AdgStyleClass
*) klass
;
105 g_type_class_add_private(klass
, sizeof(AdgDimStylePrivate
));
107 gobject_class
->get_property
= get_property
;
108 gobject_class
->set_property
= set_property
;
110 style_class
->get_pool
= get_pool
;
112 param
= g_param_spec_object("quote-style",
114 P_("Font style for the quote"),
115 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
116 g_object_class_install_property(gobject_class
, PROP_QUOTE_STYLE
,
119 param
= g_param_spec_object("tolerance-style",
120 P_("Tolerance Style"),
121 P_("Font style for the tolerances"),
122 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
123 g_object_class_install_property(gobject_class
, PROP_TOLERANCE_STYLE
,
126 param
= g_param_spec_object("note-style",
128 P_("Font style for the note (the text after or under the quote)"),
129 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
130 g_object_class_install_property(gobject_class
, PROP_NOTE_STYLE
, param
);
132 param
= g_param_spec_object("line-style",
134 P_("Line style for the baseline and the extension lines"),
135 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
136 g_object_class_install_property(gobject_class
, PROP_LINE_STYLE
, param
);
138 param
= g_param_spec_object("arrow-style",
140 P_("Arrow style to use on the baseline"),
141 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
142 g_object_class_install_property(gobject_class
, PROP_ARROW_STYLE
,
145 param
= g_param_spec_double("from-offset",
147 P_("Offset (in paper space) of the extension lines from the path to quote"),
148 0., G_MAXDOUBLE
, 5., G_PARAM_READWRITE
);
149 g_object_class_install_property(gobject_class
, PROP_FROM_OFFSET
,
152 param
= g_param_spec_double("to-offset",
154 P_("How many extend (in paper space) the extension lines after hitting the baseline"),
155 0., G_MAXDOUBLE
, 5., 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., G_PARAM_READWRITE
);
162 g_object_class_install_property(gobject_class
, PROP_BASELINE_SPACING
,
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., G_PARAM_READWRITE
);
169 g_object_class_install_property(gobject_class
, PROP_TOLERANCE_SPACING
,
172 param
= g_param_spec_boxed("quote-shift",
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
, G_PARAM_READWRITE
);
176 g_object_class_install_property(gobject_class
, PROP_QUOTE_SHIFT
,
179 param
= g_param_spec_boxed("tolerance-shift",
180 P_("Tolerance Shift"),
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
, G_PARAM_READWRITE
);
183 g_object_class_install_property(gobject_class
, PROP_TOLERANCE_SHIFT
,
186 param
= g_param_spec_boxed("note-shift",
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
, G_PARAM_READWRITE
);
190 g_object_class_install_property(gobject_class
, PROP_NOTE_SHIFT
, param
);
192 param
= g_param_spec_string("number-format",
194 P_("The format (in printf style) of the numeric component of the quote"),
195 "%-.7g", G_PARAM_READWRITE
);
196 g_object_class_install_property(gobject_class
, PROP_NUMBER_FORMAT
,
199 param
= g_param_spec_string("number-tag",
201 P_("The tag to substitute inside the quote pattern"),
202 "<>", G_PARAM_READWRITE
);
203 g_object_class_install_property(gobject_class
, PROP_NUMBER_TAG
, param
);
207 adg_dim_style_init(AdgDimStyle
*dim_style
)
209 AdgDimStylePrivate
*priv
= G_TYPE_INSTANCE_GET_PRIVATE(dim_style
,
213 priv
->quote_style
= adg_style_from_id(ADG_TYPE_FONT_STYLE
,
214 ADG_FONT_STYLE_QUOTE
);
215 priv
->tolerance_style
= adg_style_from_id(ADG_TYPE_FONT_STYLE
,
216 ADG_FONT_STYLE_TOLERANCE
);
217 priv
->note_style
= adg_style_from_id(ADG_TYPE_FONT_STYLE
,
218 ADG_FONT_STYLE_NOTE
);
219 priv
->line_style
= adg_style_from_id(ADG_TYPE_LINE_STYLE
,
221 priv
->arrow_style
= adg_style_from_id(ADG_TYPE_ARROW_STYLE
,
222 ADG_ARROW_STYLE_ARROW
);
223 priv
->from_offset
= 5.;
224 priv
->to_offset
= 5.;
225 priv
->baseline_spacing
= 30.;
226 priv
->tolerance_spacing
= 2.;
227 priv
->quote_shift
.x
= 0.;
228 priv
->quote_shift
.y
= -3.;
229 priv
->tolerance_shift
.x
= +5.;
230 priv
->tolerance_shift
.y
= -4.;
231 priv
->note_shift
.x
= +5.;
232 priv
->note_shift
.y
= 0.;
233 priv
->number_format
= g_strdup("%-.7g");
234 priv
->number_tag
= g_strdup("<>");
236 dim_style
->priv
= priv
;
240 get_property(GObject
*object
, guint prop_id
, GValue
*value
, GParamSpec
*pspec
)
242 AdgDimStyle
*dim_style
= (AdgDimStyle
*) object
;
245 case PROP_QUOTE_STYLE
:
246 g_value_set_object(value
, dim_style
->priv
->quote_style
);
248 case PROP_TOLERANCE_STYLE
:
249 g_value_set_object(value
, dim_style
->priv
->tolerance_style
);
251 case PROP_NOTE_STYLE
:
252 g_value_set_object(value
, dim_style
->priv
->note_style
);
254 case PROP_LINE_STYLE
:
255 g_value_set_object(value
, dim_style
->priv
->line_style
);
257 case PROP_ARROW_STYLE
:
258 g_value_set_object(value
, dim_style
->priv
->arrow_style
);
260 case PROP_FROM_OFFSET
:
261 g_value_set_double(value
, dim_style
->priv
->from_offset
);
264 g_value_set_double(value
, dim_style
->priv
->to_offset
);
266 case PROP_BASELINE_SPACING
:
267 g_value_set_double(value
, dim_style
->priv
->baseline_spacing
);
269 case PROP_TOLERANCE_SPACING
:
270 g_value_set_double(value
, dim_style
->priv
->tolerance_spacing
);
272 case PROP_QUOTE_SHIFT
:
273 g_value_set_boxed(value
, &dim_style
->priv
->quote_shift
);
275 case PROP_TOLERANCE_SHIFT
:
276 g_value_set_boxed(value
, &dim_style
->priv
->tolerance_shift
);
278 case PROP_NOTE_SHIFT
:
279 g_value_set_boxed(value
, &dim_style
->priv
->note_shift
);
281 case PROP_NUMBER_FORMAT
:
282 g_value_set_string(value
, dim_style
->priv
->number_format
);
284 case PROP_NUMBER_TAG
:
285 g_value_set_string(value
, dim_style
->priv
->number_tag
);
288 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
294 set_property(GObject
*object
,
295 guint prop_id
, const GValue
*value
, GParamSpec
*pspec
)
297 AdgDimStyle
*dim_style
= (AdgDimStyle
*) object
;
300 case PROP_QUOTE_STYLE
:
301 set_quote_style(dim_style
, g_value_get_object(value
));
303 case PROP_TOLERANCE_STYLE
:
304 set_tolerance_style(dim_style
, g_value_get_object(value
));
306 case PROP_NOTE_STYLE
:
307 set_note_style(dim_style
, g_value_get_object(value
));
309 case PROP_LINE_STYLE
:
310 set_line_style(dim_style
, g_value_get_object(value
));
312 case PROP_ARROW_STYLE
:
313 set_arrow_style(dim_style
, g_value_get_object(value
));
315 case PROP_FROM_OFFSET
:
316 dim_style
->priv
->from_offset
= g_value_get_double(value
);
319 dim_style
->priv
->to_offset
= g_value_get_double(value
);
321 case PROP_BASELINE_SPACING
:
322 dim_style
->priv
->baseline_spacing
= g_value_get_double(value
);
324 case PROP_TOLERANCE_SPACING
:
325 dim_style
->priv
->tolerance_spacing
= g_value_get_double(value
);
327 case PROP_QUOTE_SHIFT
:
328 set_quote_shift(dim_style
, g_value_get_boxed(value
));
330 case PROP_TOLERANCE_SHIFT
:
331 set_tolerance_shift(dim_style
, g_value_get_boxed(value
));
333 case PROP_NOTE_SHIFT
:
334 set_note_shift(dim_style
, g_value_get_boxed(value
));
336 case PROP_NUMBER_FORMAT
:
337 set_number_format(dim_style
, g_value_get_string(value
));
339 case PROP_NUMBER_TAG
:
340 set_number_tag(dim_style
, g_value_get_string(value
));
343 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
350 * adg_dim_style_get_slot:
352 * Gets the slot id for this style class.
354 * Return value: the slot
357 adg_dim_style_get_slot(void)
359 static AdgStyleSlot slot
= -1;
361 if (G_UNLIKELY(slot
< 0))
362 slot
= adg_context_get_slot(ADG_TYPE_DIM_STYLE
);
370 * Constructs a new dimension style initialized with default params.
372 * Return value: a new dimension style
375 adg_dim_style_new(void)
377 return g_object_new(ADG_TYPE_DIM_STYLE
, NULL
);
381 * adg_dim_style_get_quote_style:
382 * @dim_style: an #AdgDimStyle object
384 * Gets the quote style of @dim_style. No reference will be added to the
385 * returned style; it should not be unreferenced.
387 * Return value: the quote style or %NULL on errors
390 adg_dim_style_get_quote_style(AdgDimStyle
*dim_style
)
392 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
394 return dim_style
->priv
->quote_style
;
398 * adg_dim_style_set_quote_style:
399 * @dim_style: an #AdgDimStyle object
400 * @style: the new quote style
402 * Sets a new quote style on @dim_style. The old quote style (if any) will be
403 * unreferenced while a new reference will be added to @style.
406 adg_dim_style_set_quote_style(AdgDimStyle
*dim_style
, AdgFontStyle
*style
)
408 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
409 g_return_if_fail(ADG_IS_FONT_STYLE(style
));
411 set_quote_style(dim_style
, style
);
412 g_object_notify((GObject
*) dim_style
, "quote-style");
416 * adg_dim_style_get_tolerance_style:
417 * @dim_style: an #AdgDimStyle object
419 * Gets the tolerance style of @dim_style. No reference will be added to the
420 * returned style; it should not be unreferenced.
422 * Return value: the tolerance style or %NULL on errors
425 adg_dim_style_get_tolerance_style(AdgDimStyle
*dim_style
)
427 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
429 return dim_style
->priv
->tolerance_style
;
433 * adg_dim_style_set_tolerance_style:
434 * @dim_style: an #AdgDimStyle object
435 * @style: the new tolerance style
437 * Sets a new tolerance style on @dim_style. The old tolerance style (if any)
438 * will be unreferenced while a new reference will be added to @style.
441 adg_dim_style_set_tolerance_style(AdgDimStyle
*dim_style
, 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
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
, AdgFontStyle
*style
)
478 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
479 g_return_if_fail(ADG_IS_FONT_STYLE(style
));
481 set_note_style(dim_style
, style
);
482 g_object_notify((GObject
*) dim_style
, "note-style");
486 * adg_dim_style_get_line_style:
487 * @dim_style: an #AdgDimStyle object
489 * Gets the line style of @dim_style. No reference will be added to the
490 * returned style; it should not be unreferenced.
492 * Return value: the line style or %NULL on errors
495 adg_dim_style_get_line_style(AdgDimStyle
*dim_style
)
497 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
499 return dim_style
->priv
->line_style
;
503 * adg_dim_style_set_line_style:
504 * @dim_style: an #AdgDimStyle object
505 * @style: the new line style
507 * Sets a new line style on @dim_style. The old line style (if any) will be
508 * unreferenced while a new reference will be added to @style.
511 adg_dim_style_set_line_style(AdgDimStyle
*dim_style
, AdgLineStyle
*style
)
513 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
514 g_return_if_fail(ADG_IS_LINE_STYLE(style
));
516 set_line_style(dim_style
, style
);
517 g_object_notify((GObject
*) dim_style
, "line-style");
521 * adg_dim_style_get_arrow_style:
522 * @dim_style: an #AdgDimStyle object
524 * Gets the arrow style of @dim_style. No reference will be added to the
525 * returned style; it should not be unreferenced.
527 * Return value: the arrow style or %NULL on errors
530 adg_dim_style_get_arrow_style(AdgDimStyle
*dim_style
)
532 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
534 return dim_style
->priv
->arrow_style
;
538 * adg_dim_style_set_arrow_style:
539 * @dim_style: an #AdgDimStyle object
540 * @style: the new arrow style
542 * Sets a new arrow style on @dim_style. The old arrow style (if any) will be
543 * unreferenced while a new reference will be added to @style.
546 adg_dim_style_set_arrow_style(AdgDimStyle
*dim_style
, AdgArrowStyle
*style
)
548 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
549 g_return_if_fail(ADG_IS_ARROW_STYLE(style
));
551 set_arrow_style(dim_style
, style
);
552 g_object_notify((GObject
*) dim_style
, "arrow-style");
556 * adg_dim_style_get_from_offset:
557 * @dim_style: an #AdgDimStyle object
559 * Gets the distance (in paper space) the extension lines must keep from the
562 * Return value: the requested distance
565 adg_dim_style_get_from_offset(AdgDimStyle
*dim_style
)
567 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0.);
569 return dim_style
->priv
->from_offset
;
573 * adg_dim_style_set_from_offset:
574 * @dim_style: an #AdgDimStyle object
575 * @offset: the new offset
577 * Sets a new "from-offset" value.
580 adg_dim_style_set_from_offset(AdgDimStyle
*dim_style
, gdouble offset
)
582 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
584 dim_style
->priv
->from_offset
= offset
;
585 g_object_notify((GObject
*) dim_style
, "from-offset");
589 * adg_dim_style_get_to_offset:
590 * @dim_style: an #AdgDimStyle object
592 * Gets how much (in paper space) the extension lines must extend after
593 * crossing the baseline.
595 * Return value: the requested distance
598 adg_dim_style_get_to_offset(AdgDimStyle
*dim_style
)
600 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0.);
602 return dim_style
->priv
->to_offset
;
606 * adg_dim_style_set_to_offset:
607 * @dim_style: an #AdgDimStyle object
608 * @offset: the new offset
610 * Sets a new "to-offset" value.
613 adg_dim_style_set_to_offset(AdgDimStyle
*dim_style
, gdouble offset
)
615 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
617 dim_style
->priv
->to_offset
= offset
;
618 g_object_notify((GObject
*) dim_style
, "to-offset");
622 * adg_dim_style_get_baseline_spacing:
623 * @dim_style: an #AdgDimStyle object
625 * Gets the distance between two consecutive baselines
626 * while stacking dimensions.
628 * Return value: the requested spacing
631 adg_dim_style_get_baseline_spacing(AdgDimStyle
*dim_style
)
633 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0.);
635 return dim_style
->priv
->baseline_spacing
;
639 * adg_dim_style_set_baseline_spacing:
640 * @dim_style: an #AdgDimStyle object
641 * @spacing: the new spacing
643 * Sets a new "baseline-spacing" value.
646 adg_dim_style_set_baseline_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
648 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
650 dim_style
->priv
->baseline_spacing
= spacing
;
651 g_object_notify((GObject
*) dim_style
, "baseline-spacing");
655 * adg_dim_style_get_tolerance_spacing:
656 * @dim_style: an #AdgDimStyle object
658 * Gets the distance (in paper space) between up and down tolerances.
660 * Return value: the requested spacing
663 adg_dim_style_get_tolerance_spacing(AdgDimStyle
*dim_style
)
665 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0.);
667 return dim_style
->priv
->tolerance_spacing
;
671 * adg_dim_style_set_tolerance_spacing:
672 * @dim_style: an #AdgDimStyle object
673 * @spacing: the new spacing
675 * Sets a new "tolerance-spacing" value.
678 adg_dim_style_set_tolerance_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
680 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
682 dim_style
->priv
->tolerance_spacing
= spacing
;
683 g_object_notify((GObject
*) dim_style
, "tolerance-spacing");
687 * adg_dim_style_get_quote_shift:
688 * @dim_style: an #AdgDimStyle object
690 * Gets the smooth displacement of the quote text. The returned pointer
691 * refers to an internal allocated struct and must not be modified or freed.
693 * Return value: the requested shift
696 adg_dim_style_get_quote_shift(AdgDimStyle
*dim_style
)
698 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
700 return &dim_style
->priv
->quote_shift
;
704 * adg_dim_style_set_quote_shift:
705 * @dim_style: an #AdgDimStyle object
706 * @shift: the new displacement
708 * Sets a new "quote-shift" value.
711 adg_dim_style_set_quote_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
713 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
715 set_quote_shift(dim_style
, shift
);
716 g_object_notify((GObject
*) dim_style
, "quote-shift");
720 * adg_dim_style_get_tolerance_shift:
721 * @dim_style: an #AdgDimStyle object
723 * Gets the smooth displacement of the tolerance text. The returned pointer
724 * refers to an internal allocated struct and must not be modified or freed.
726 * Return value: the requested shift
729 adg_dim_style_get_tolerance_shift(AdgDimStyle
*dim_style
)
731 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
733 return &dim_style
->priv
->tolerance_shift
;
737 * adg_dim_style_set_tolerance_shift:
738 * @dim_style: an #AdgDimStyle object
739 * @shift: the new displacement
741 * Sets a new "tolerance-shift" value.
744 adg_dim_style_set_tolerance_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
746 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
748 set_tolerance_shift(dim_style
, shift
);
749 g_object_notify((GObject
*) dim_style
, "tolerance-shift");
753 * adg_dim_style_get_note_shift:
754 * @dim_style: an #AdgDimStyle object
756 * Gets the smooth displacement of the note text. The returned pointer
757 * refers to an internal allocated struct and must not be modified or freed.
759 * Return value: the requested shift
762 adg_dim_style_get_note_shift(AdgDimStyle
*dim_style
)
764 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
766 return &dim_style
->priv
->note_shift
;
770 * adg_dim_style_set_note_shift:
771 * @dim_style: an #AdgDimStyle object
772 * @shift: the new displacement
774 * Sets a new "note-shift" value.
777 adg_dim_style_set_note_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
779 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
781 set_note_shift(dim_style
, shift
);
782 g_object_notify((GObject
*) dim_style
, "note-shift");
786 * adg_dim_style_get_number_format:
787 * @dim_style: an #AdgDimStyle object
789 * Gets the number format (in printf style) of this quoting style. The
790 * returned pointer refers to internally managed text that must not be
793 * Return value: the requested format
796 adg_dim_style_get_number_format(AdgDimStyle
*dim_style
)
798 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
800 return dim_style
->priv
->number_format
;
804 * adg_dim_style_set_number_format:
805 * @dim_style: an #AdgDimStyle object
806 * @format: the new format to adopt
808 * Sets a new "number-format" value.
811 adg_dim_style_set_number_format(AdgDimStyle
*dim_style
, const gchar
*format
)
813 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
815 set_number_format(dim_style
, format
);
816 g_object_notify((GObject
*) dim_style
, "number-format");
820 * adg_dim_style_get_number_tag:
821 * @dim_style: an #AdgDimStyle object
823 * Gets the number tag to substitute while building the quote text. The
824 * returned pointer refers to internally managed text that must not be
827 * Return value: the requested tag
830 adg_dim_style_get_number_tag(AdgDimStyle
*dim_style
)
832 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
834 return dim_style
->priv
->number_tag
;
838 * adg_dim_style_set_number_tag:
839 * @dim_style: an #AdgDimStyle object
842 * Sets a new "number-tag" value.
845 adg_dim_style_set_number_tag(AdgDimStyle
*dim_style
, const gchar
*tag
)
847 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
849 set_number_tag(dim_style
, tag
);
850 g_object_notify((GObject
*) dim_style
, "number-tag");
857 static GPtrArray
*pool
= NULL
;
859 if (G_UNLIKELY(pool
== NULL
)) {
860 cairo_pattern_t
*pattern
;
862 pool
= g_ptr_array_sized_new(ADG_DIM_STYLE_LAST
);
864 /* No need to specify further params: the default is already ISO */
865 pattern
= cairo_pattern_create_rgb(1., 0., 0.);
866 pool
->pdata
[ADG_DIM_STYLE_ISO
] = g_object_new(ADG_TYPE_DIM_STYLE
,
869 cairo_pattern_destroy(pattern
);
871 pool
->len
= ADG_DIM_STYLE_LAST
;
878 set_quote_style(AdgDimStyle
*dim_style
, AdgFontStyle
*style
)
880 if (dim_style
->priv
->quote_style
)
881 g_object_unref(dim_style
->priv
->quote_style
);
884 dim_style
->priv
->quote_style
= (AdgStyle
*) style
;
888 set_tolerance_style(AdgDimStyle
*dim_style
, AdgFontStyle
*style
)
890 if (dim_style
->priv
->tolerance_style
)
891 g_object_unref(dim_style
->priv
->tolerance_style
);
894 dim_style
->priv
->tolerance_style
= (AdgStyle
*) style
;
898 set_note_style(AdgDimStyle
*dim_style
, AdgFontStyle
*style
)
900 if (dim_style
->priv
->note_style
)
901 g_object_unref(dim_style
->priv
->note_style
);
904 dim_style
->priv
->note_style
= (AdgStyle
*) style
;
908 set_line_style(AdgDimStyle
*dim_style
, AdgLineStyle
*style
)
910 if (dim_style
->priv
->line_style
)
911 g_object_unref(dim_style
->priv
->line_style
);
914 dim_style
->priv
->line_style
= (AdgStyle
*) style
;
918 set_arrow_style(AdgDimStyle
*dim_style
, AdgArrowStyle
*style
)
920 if (dim_style
->priv
->arrow_style
)
921 g_object_unref(dim_style
->priv
->arrow_style
);
924 dim_style
->priv
->arrow_style
= (AdgStyle
*) style
;
928 set_quote_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
930 cpml_pair_copy(&dim_style
->priv
->quote_shift
, shift
);
934 set_tolerance_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
936 cpml_pair_copy(&dim_style
->priv
->tolerance_shift
, shift
);
940 set_note_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
942 cpml_pair_copy(&dim_style
->priv
->note_shift
, shift
);
946 set_number_format(AdgDimStyle
*dim_style
, const gchar
*format
)
948 g_free(dim_style
->priv
->number_format
);
949 dim_style
->priv
->number_format
= g_strdup(format
);
953 set_number_tag(AdgDimStyle
*dim_style
, const gchar
*tag
)
955 g_free(dim_style
->priv
->number_tag
);
956 dim_style
->priv
->number_tag
= g_strdup(tag
);