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.
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-context.h"
50 PROP_BASELINE_SPACING
,
51 PROP_TOLERANCE_SPACING
,
60 static void get_property (GObject
*object
,
64 static void set_property (GObject
*object
,
68 static GPtrArray
* get_pool (void);
69 static void set_quote_style (AdgDimStyle
*dim_style
,
71 static void set_tolerance_style (AdgDimStyle
*dim_style
,
73 static void set_note_style (AdgDimStyle
*dim_style
,
75 static void set_line_style (AdgDimStyle
*dim_style
,
77 static void set_arrow_style (AdgDimStyle
*dim_style
,
78 AdgArrowStyle
*style
);
79 static void set_quote_shift (AdgDimStyle
*dim_style
,
80 const AdgPair
*shift
);
81 static void set_tolerance_shift (AdgDimStyle
*dim_style
,
82 const AdgPair
*shift
);
83 static void set_note_shift (AdgDimStyle
*dim_style
,
84 const AdgPair
*shift
);
85 static void set_number_format (AdgDimStyle
*dim_style
,
87 static void set_number_tag (AdgDimStyle
*dim_style
,
91 G_DEFINE_TYPE(AdgDimStyle
, adg_dim_style
, ADG_TYPE_STYLE
)
95 adg_dim_style_class_init(AdgDimStyleClass
*klass
)
97 GObjectClass
*gobject_class
;
98 AdgStyleClass
*style_class
;
101 gobject_class
= (GObjectClass
*) klass
;
102 style_class
= (AdgStyleClass
*) 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 style_class
->get_pool
= get_pool
;
111 param
= g_param_spec_object("quote-style",
113 P_("Font style for the quote"),
114 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
115 g_object_class_install_property(gobject_class
, PROP_QUOTE_STYLE
,
118 param
= g_param_spec_object("tolerance-style",
119 P_("Tolerance Style"),
120 P_("Font style for the tolerances"),
121 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
122 g_object_class_install_property(gobject_class
, PROP_TOLERANCE_STYLE
,
125 param
= g_param_spec_object("note-style",
127 P_("Font style for the note (the text after or under the quote)"),
128 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
129 g_object_class_install_property(gobject_class
, PROP_NOTE_STYLE
, param
);
131 param
= g_param_spec_object("line-style",
133 P_("Line style for the baseline and the extension lines"),
134 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
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"),
140 ADG_TYPE_STYLE
, G_PARAM_READWRITE
);
141 g_object_class_install_property(gobject_class
, PROP_ARROW_STYLE
,
144 param
= g_param_spec_double("from-offset",
146 P_("Offset (in paper space) of the extension lines from the path to quote"),
147 0., G_MAXDOUBLE
, 5., G_PARAM_READWRITE
);
148 g_object_class_install_property(gobject_class
, PROP_FROM_OFFSET
,
151 param
= g_param_spec_double("to-offset",
153 P_("How many extend (in paper space) the extension lines after hitting the baseline"),
154 0., G_MAXDOUBLE
, 5., G_PARAM_READWRITE
);
155 g_object_class_install_property(gobject_class
, PROP_TO_OFFSET
, param
);
157 param
= g_param_spec_double("baseline-spacing",
158 P_("Baseline Spacing"),
159 P_("Distance between two consecutive baselines while stacking dimensions"),
160 0., G_MAXDOUBLE
, 30., G_PARAM_READWRITE
);
161 g_object_class_install_property(gobject_class
, PROP_BASELINE_SPACING
,
164 param
= g_param_spec_double("tolerance-spacing",
165 P_("Tolerance Spacing"),
166 P_("Distance between up and down tolerance text"),
167 0., G_MAXDOUBLE
, 2., G_PARAM_READWRITE
);
168 g_object_class_install_property(gobject_class
, PROP_TOLERANCE_SPACING
,
171 param
= g_param_spec_boxed("quote-shift",
173 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)"),
174 ADG_TYPE_PAIR
, G_PARAM_READWRITE
);
175 g_object_class_install_property(gobject_class
, PROP_QUOTE_SHIFT
,
178 param
= g_param_spec_boxed("tolerance-shift",
179 P_("Tolerance Shift"),
180 P_("Used to specify a smooth displacement (in paper units) for the tolerance text by taking as reference the perfect compact position"),
181 ADG_TYPE_PAIR
, G_PARAM_READWRITE
);
182 g_object_class_install_property(gobject_class
, PROP_TOLERANCE_SHIFT
,
185 param
= g_param_spec_boxed("note-shift",
187 P_("Used to specify a smooth displacement (in paper units) for the note text by taking as reference the perfect compact position"),
188 ADG_TYPE_PAIR
, G_PARAM_READWRITE
);
189 g_object_class_install_property(gobject_class
, PROP_NOTE_SHIFT
, param
);
191 param
= g_param_spec_string("number-format",
193 P_("The format (in printf style) of the numeric component of the quote"),
194 "%-.7g", G_PARAM_READWRITE
);
195 g_object_class_install_property(gobject_class
, PROP_NUMBER_FORMAT
,
198 param
= g_param_spec_string("number-tag",
200 P_("The tag to substitute inside the quote pattern"),
201 "<>", G_PARAM_READWRITE
);
202 g_object_class_install_property(gobject_class
, PROP_NUMBER_TAG
, param
);
206 adg_dim_style_init(AdgDimStyle
*dim_style
)
208 AdgDimStylePrivate
*priv
= G_TYPE_INSTANCE_GET_PRIVATE(dim_style
,
212 priv
->quote_style
= adg_style_from_id(ADG_TYPE_FONT_STYLE
,
213 ADG_FONT_STYLE_QUOTE
);
214 priv
->tolerance_style
= adg_style_from_id(ADG_TYPE_FONT_STYLE
,
215 ADG_FONT_STYLE_TOLERANCE
);
216 priv
->note_style
= adg_style_from_id(ADG_TYPE_FONT_STYLE
,
217 ADG_FONT_STYLE_NOTE
);
218 priv
->line_style
= adg_style_from_id(ADG_TYPE_LINE_STYLE
,
220 priv
->arrow_style
= adg_style_from_id(ADG_TYPE_ARROW_STYLE
,
221 ADG_ARROW_STYLE_ARROW
);
222 priv
->from_offset
= 5.;
223 priv
->to_offset
= 5.;
224 priv
->baseline_spacing
= 30.;
225 priv
->tolerance_spacing
= 2.;
226 priv
->quote_shift
.x
= 0.;
227 priv
->quote_shift
.y
= -3.;
228 priv
->tolerance_shift
.x
= +5.;
229 priv
->tolerance_shift
.y
= -4.;
230 priv
->note_shift
.x
= +5.;
231 priv
->note_shift
.y
= 0.;
232 priv
->number_format
= g_strdup("%-.7g");
233 priv
->number_tag
= g_strdup("<>");
235 dim_style
->priv
= priv
;
239 get_property(GObject
*object
, guint prop_id
, GValue
*value
, GParamSpec
*pspec
)
241 AdgDimStyle
*dim_style
= (AdgDimStyle
*) object
;
244 case PROP_QUOTE_STYLE
:
245 g_value_set_object(value
, dim_style
->priv
->quote_style
);
247 case PROP_TOLERANCE_STYLE
:
248 g_value_set_object(value
, dim_style
->priv
->tolerance_style
);
250 case PROP_NOTE_STYLE
:
251 g_value_set_object(value
, dim_style
->priv
->note_style
);
253 case PROP_LINE_STYLE
:
254 g_value_set_object(value
, dim_style
->priv
->line_style
);
256 case PROP_ARROW_STYLE
:
257 g_value_set_object(value
, dim_style
->priv
->arrow_style
);
259 case PROP_FROM_OFFSET
:
260 g_value_set_double(value
, dim_style
->priv
->from_offset
);
263 g_value_set_double(value
, dim_style
->priv
->to_offset
);
265 case PROP_BASELINE_SPACING
:
266 g_value_set_double(value
, dim_style
->priv
->baseline_spacing
);
268 case PROP_TOLERANCE_SPACING
:
269 g_value_set_double(value
, dim_style
->priv
->tolerance_spacing
);
271 case PROP_QUOTE_SHIFT
:
272 g_value_set_boxed(value
, &dim_style
->priv
->quote_shift
);
274 case PROP_TOLERANCE_SHIFT
:
275 g_value_set_boxed(value
, &dim_style
->priv
->tolerance_shift
);
277 case PROP_NOTE_SHIFT
:
278 g_value_set_boxed(value
, &dim_style
->priv
->note_shift
);
280 case PROP_NUMBER_FORMAT
:
281 g_value_set_string(value
, dim_style
->priv
->number_format
);
283 case PROP_NUMBER_TAG
:
284 g_value_set_string(value
, dim_style
->priv
->number_tag
);
287 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
293 set_property(GObject
*object
,
294 guint prop_id
, const GValue
*value
, GParamSpec
*pspec
)
296 AdgDimStyle
*dim_style
= (AdgDimStyle
*) object
;
299 case PROP_QUOTE_STYLE
:
300 set_quote_style(dim_style
, g_value_get_object(value
));
302 case PROP_TOLERANCE_STYLE
:
303 set_tolerance_style(dim_style
, g_value_get_object(value
));
305 case PROP_NOTE_STYLE
:
306 set_note_style(dim_style
, g_value_get_object(value
));
308 case PROP_LINE_STYLE
:
309 set_line_style(dim_style
, g_value_get_object(value
));
311 case PROP_ARROW_STYLE
:
312 set_arrow_style(dim_style
, g_value_get_object(value
));
314 case PROP_FROM_OFFSET
:
315 dim_style
->priv
->from_offset
= g_value_get_double(value
);
318 dim_style
->priv
->to_offset
= g_value_get_double(value
);
320 case PROP_BASELINE_SPACING
:
321 dim_style
->priv
->baseline_spacing
= g_value_get_double(value
);
323 case PROP_TOLERANCE_SPACING
:
324 dim_style
->priv
->tolerance_spacing
= g_value_get_double(value
);
326 case PROP_QUOTE_SHIFT
:
327 set_quote_shift(dim_style
, g_value_get_boxed(value
));
329 case PROP_TOLERANCE_SHIFT
:
330 set_tolerance_shift(dim_style
, g_value_get_boxed(value
));
332 case PROP_NOTE_SHIFT
:
333 set_note_shift(dim_style
, g_value_get_boxed(value
));
335 case PROP_NUMBER_FORMAT
:
336 set_number_format(dim_style
, g_value_get_string(value
));
338 case PROP_NUMBER_TAG
:
339 set_number_tag(dim_style
, g_value_get_string(value
));
342 G_OBJECT_WARN_INVALID_PROPERTY_ID(object
, prop_id
, pspec
);
349 * adg_dim_style_get_slot:
351 * Gets the slot id for this style class.
353 * Return value: the slot
356 adg_dim_style_get_slot(void)
358 static AdgStyleSlot slot
= -1;
360 if (G_UNLIKELY(slot
< 0))
361 slot
= adg_context_get_slot(ADG_TYPE_DIM_STYLE
);
369 * Constructs a new dimension style initialized with default params.
371 * Return value: a new dimension style
374 adg_dim_style_new(void)
376 return g_object_new(ADG_TYPE_DIM_STYLE
, NULL
);
380 * adg_dim_style_get_quote_style:
381 * @dim_style: an #AdgDimStyle object
383 * Gets the quote style of @dim_style. No reference will be added to the
384 * returned style; it should not be unreferenced.
386 * Return value: the quote style or %NULL on errors
389 adg_dim_style_get_quote_style(AdgDimStyle
*dim_style
)
391 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
393 return dim_style
->priv
->quote_style
;
397 * adg_dim_style_set_quote_style:
398 * @dim_style: an #AdgDimStyle object
399 * @style: the new quote style
401 * Sets a new quote style on @dim_style. The old quote style (if any) will be
402 * unreferenced while a new reference will be added to @style.
405 adg_dim_style_set_quote_style(AdgDimStyle
*dim_style
, 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
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
, AdgFontStyle
*style
)
442 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
443 g_return_if_fail(ADG_IS_FONT_STYLE(style
));
445 set_tolerance_style(dim_style
, style
);
446 g_object_notify((GObject
*) dim_style
, "tolerance-style");
450 * adg_dim_style_get_note_style:
451 * @dim_style: an #AdgDimStyle object
453 * Gets the note style of @dim_style. No reference will be added to the
454 * returned style; it should not be unreferenced.
456 * Return value: the note style or %NULL on errors
459 adg_dim_style_get_note_style(AdgDimStyle
*dim_style
)
461 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
463 return dim_style
->priv
->note_style
;
467 * adg_dim_style_set_note_style:
468 * @dim_style: an #AdgDimStyle object
469 * @style: the new note style
471 * Sets a new note style on @dim_style. The old note style (if any) will be
472 * unreferenced while a new reference will be added to @style.
475 adg_dim_style_set_note_style(AdgDimStyle
*dim_style
, AdgFontStyle
*style
)
477 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
478 g_return_if_fail(ADG_IS_FONT_STYLE(style
));
480 set_note_style(dim_style
, style
);
481 g_object_notify((GObject
*) dim_style
, "note-style");
485 * adg_dim_style_get_line_style:
486 * @dim_style: an #AdgDimStyle object
488 * Gets the line style of @dim_style. No reference will be added to the
489 * returned style; it should not be unreferenced.
491 * Return value: the line style or %NULL on errors
494 adg_dim_style_get_line_style(AdgDimStyle
*dim_style
)
496 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
498 return dim_style
->priv
->line_style
;
502 * adg_dim_style_set_line_style:
503 * @dim_style: an #AdgDimStyle object
504 * @style: the new line style
506 * Sets a new line style on @dim_style. The old line style (if any) will be
507 * unreferenced while a new reference will be added to @style.
510 adg_dim_style_set_line_style(AdgDimStyle
*dim_style
, AdgLineStyle
*style
)
512 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
513 g_return_if_fail(ADG_IS_LINE_STYLE(style
));
515 set_line_style(dim_style
, style
);
516 g_object_notify((GObject
*) dim_style
, "line-style");
520 * adg_dim_style_get_arrow_style:
521 * @dim_style: an #AdgDimStyle object
523 * Gets the arrow style of @dim_style. No reference will be added to the
524 * returned style; it should not be unreferenced.
526 * Return value: the arrow style or %NULL on errors
529 adg_dim_style_get_arrow_style(AdgDimStyle
*dim_style
)
531 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
533 return dim_style
->priv
->arrow_style
;
537 * adg_dim_style_set_arrow_style:
538 * @dim_style: an #AdgDimStyle object
539 * @style: the new arrow style
541 * Sets a new arrow style on @dim_style. The old arrow style (if any) will be
542 * unreferenced while a new reference will be added to @style.
545 adg_dim_style_set_arrow_style(AdgDimStyle
*dim_style
, AdgArrowStyle
*style
)
547 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
548 g_return_if_fail(ADG_IS_ARROW_STYLE(style
));
550 set_arrow_style(dim_style
, style
);
551 g_object_notify((GObject
*) dim_style
, "arrow-style");
555 * adg_dim_style_get_from_offset:
556 * @dim_style: an #AdgDimStyle object
558 * Gets the distance (in paper space) the extension lines must keep from the
561 * Return value: the requested distance
564 adg_dim_style_get_from_offset(AdgDimStyle
*dim_style
)
566 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0.);
568 return dim_style
->priv
->from_offset
;
572 * adg_dim_style_set_from_offset:
573 * @dim_style: an #AdgDimStyle object
574 * @offset: the new offset
576 * Sets a new "from-offset" value.
579 adg_dim_style_set_from_offset(AdgDimStyle
*dim_style
, gdouble offset
)
581 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
583 dim_style
->priv
->from_offset
= offset
;
584 g_object_notify((GObject
*) dim_style
, "from-offset");
588 * adg_dim_style_get_to_offset:
589 * @dim_style: an #AdgDimStyle object
591 * Gets how much (in paper space) the extension lines must extend after
592 * crossing the baseline.
594 * Return value: the requested distance
597 adg_dim_style_get_to_offset(AdgDimStyle
*dim_style
)
599 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0.);
601 return dim_style
->priv
->to_offset
;
605 * adg_dim_style_set_to_offset:
606 * @dim_style: an #AdgDimStyle object
607 * @offset: the new offset
609 * Sets a new "to-offset" value.
612 adg_dim_style_set_to_offset(AdgDimStyle
*dim_style
, gdouble offset
)
614 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
616 dim_style
->priv
->to_offset
= offset
;
617 g_object_notify((GObject
*) dim_style
, "to-offset");
621 * adg_dim_style_get_baseline_spacing:
622 * @dim_style: an #AdgDimStyle object
624 * Gets the distance between two consecutive baselines
625 * while stacking dimensions.
627 * Return value: the requested spacing
630 adg_dim_style_get_baseline_spacing(AdgDimStyle
*dim_style
)
632 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0.);
634 return dim_style
->priv
->baseline_spacing
;
638 * adg_dim_style_set_baseline_spacing:
639 * @dim_style: an #AdgDimStyle object
640 * @spacing: the new spacing
642 * Sets a new "baseline-spacing" value.
645 adg_dim_style_set_baseline_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
647 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
649 dim_style
->priv
->baseline_spacing
= spacing
;
650 g_object_notify((GObject
*) dim_style
, "baseline-spacing");
654 * adg_dim_style_get_tolerance_spacing:
655 * @dim_style: an #AdgDimStyle object
657 * Gets the distance (in paper space) between up and down tolerances.
659 * Return value: the requested spacing
662 adg_dim_style_get_tolerance_spacing(AdgDimStyle
*dim_style
)
664 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), 0.);
666 return dim_style
->priv
->tolerance_spacing
;
670 * adg_dim_style_set_tolerance_spacing:
671 * @dim_style: an #AdgDimStyle object
672 * @spacing: the new spacing
674 * Sets a new "tolerance-spacing" value.
677 adg_dim_style_set_tolerance_spacing(AdgDimStyle
*dim_style
, gdouble spacing
)
679 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
681 dim_style
->priv
->tolerance_spacing
= spacing
;
682 g_object_notify((GObject
*) dim_style
, "tolerance-spacing");
686 * adg_dim_style_get_quote_shift:
687 * @dim_style: an #AdgDimStyle object
689 * Gets the smooth displacement of the quote text. The returned pointer
690 * refers to an internal allocated struct and must not be modified or freed.
692 * Return value: the requested shift
695 adg_dim_style_get_quote_shift(AdgDimStyle
*dim_style
)
697 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
699 return &dim_style
->priv
->quote_shift
;
703 * adg_dim_style_set_quote_shift:
704 * @dim_style: an #AdgDimStyle object
705 * @shift: the new displacement
707 * Sets a new "quote-shift" value.
710 adg_dim_style_set_quote_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
712 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
714 set_quote_shift(dim_style
, shift
);
715 g_object_notify((GObject
*) dim_style
, "quote-shift");
719 * adg_dim_style_get_tolerance_shift:
720 * @dim_style: an #AdgDimStyle object
722 * Gets the smooth displacement of the tolerance text. The returned pointer
723 * refers to an internal allocated struct and must not be modified or freed.
725 * Return value: the requested shift
728 adg_dim_style_get_tolerance_shift(AdgDimStyle
*dim_style
)
730 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
732 return &dim_style
->priv
->tolerance_shift
;
736 * adg_dim_style_set_tolerance_shift:
737 * @dim_style: an #AdgDimStyle object
738 * @shift: the new displacement
740 * Sets a new "tolerance-shift" value.
743 adg_dim_style_set_tolerance_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
745 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
747 set_tolerance_shift(dim_style
, shift
);
748 g_object_notify((GObject
*) dim_style
, "tolerance-shift");
752 * adg_dim_style_get_note_shift:
753 * @dim_style: an #AdgDimStyle object
755 * Gets the smooth displacement of the note text. The returned pointer
756 * refers to an internal allocated struct and must not be modified or freed.
758 * Return value: the requested shift
761 adg_dim_style_get_note_shift(AdgDimStyle
*dim_style
)
763 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
765 return &dim_style
->priv
->note_shift
;
769 * adg_dim_style_set_note_shift:
770 * @dim_style: an #AdgDimStyle object
771 * @shift: the new displacement
773 * Sets a new "note-shift" value.
776 adg_dim_style_set_note_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
778 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
780 set_note_shift(dim_style
, shift
);
781 g_object_notify((GObject
*) dim_style
, "note-shift");
785 * adg_dim_style_get_number_format:
786 * @dim_style: an #AdgDimStyle object
788 * Gets the number format (in printf style) of this quoting style. The
789 * returned pointer refers to internally managed text that must not be
792 * Return value: the requested format
795 adg_dim_style_get_number_format(AdgDimStyle
*dim_style
)
797 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
799 return dim_style
->priv
->number_format
;
803 * adg_dim_style_set_number_format:
804 * @dim_style: an #AdgDimStyle object
805 * @format: the new format to adopt
807 * Sets a new "number-format" value.
810 adg_dim_style_set_number_format(AdgDimStyle
*dim_style
, const gchar
*format
)
812 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
814 set_number_format(dim_style
, format
);
815 g_object_notify((GObject
*) dim_style
, "number-format");
819 * adg_dim_style_get_number_tag:
820 * @dim_style: an #AdgDimStyle object
822 * Gets the number tag to substitute while building the quote text. The
823 * returned pointer refers to internally managed text that must not be
826 * Return value: the requested tag
829 adg_dim_style_get_number_tag(AdgDimStyle
*dim_style
)
831 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style
), NULL
);
833 return dim_style
->priv
->number_tag
;
837 * adg_dim_style_set_number_tag:
838 * @dim_style: an #AdgDimStyle object
841 * Sets a new "number-tag" value.
844 adg_dim_style_set_number_tag(AdgDimStyle
*dim_style
, const gchar
*tag
)
846 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style
));
848 set_number_tag(dim_style
, tag
);
849 g_object_notify((GObject
*) dim_style
, "number-tag");
856 static GPtrArray
*pool
= NULL
;
858 if (G_UNLIKELY(pool
== NULL
)) {
859 cairo_pattern_t
*pattern
;
861 pool
= g_ptr_array_sized_new(ADG_DIM_STYLE_LAST
);
863 /* No need to specify further params: the default is already ISO */
864 pattern
= cairo_pattern_create_rgb(1., 0., 0.);
865 pool
->pdata
[ADG_DIM_STYLE_ISO
] = g_object_new(ADG_TYPE_DIM_STYLE
,
868 cairo_pattern_destroy(pattern
);
870 pool
->len
= ADG_DIM_STYLE_LAST
;
877 set_quote_style(AdgDimStyle
*dim_style
, AdgFontStyle
*style
)
879 if (dim_style
->priv
->quote_style
)
880 g_object_unref(dim_style
->priv
->quote_style
);
883 dim_style
->priv
->quote_style
= (AdgStyle
*) style
;
887 set_tolerance_style(AdgDimStyle
*dim_style
, AdgFontStyle
*style
)
889 if (dim_style
->priv
->tolerance_style
)
890 g_object_unref(dim_style
->priv
->tolerance_style
);
893 dim_style
->priv
->tolerance_style
= (AdgStyle
*) style
;
897 set_note_style(AdgDimStyle
*dim_style
, AdgFontStyle
*style
)
899 if (dim_style
->priv
->note_style
)
900 g_object_unref(dim_style
->priv
->note_style
);
903 dim_style
->priv
->note_style
= (AdgStyle
*) style
;
907 set_line_style(AdgDimStyle
*dim_style
, AdgLineStyle
*style
)
909 if (dim_style
->priv
->line_style
)
910 g_object_unref(dim_style
->priv
->line_style
);
913 dim_style
->priv
->line_style
= (AdgStyle
*) style
;
917 set_arrow_style(AdgDimStyle
*dim_style
, AdgArrowStyle
*style
)
919 if (dim_style
->priv
->arrow_style
)
920 g_object_unref(dim_style
->priv
->arrow_style
);
923 dim_style
->priv
->arrow_style
= (AdgStyle
*) style
;
927 set_quote_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
929 cpml_pair_copy(&dim_style
->priv
->quote_shift
, shift
);
933 set_tolerance_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
935 cpml_pair_copy(&dim_style
->priv
->tolerance_shift
, shift
);
939 set_note_shift(AdgDimStyle
*dim_style
, const AdgPair
*shift
)
941 cpml_pair_copy(&dim_style
->priv
->note_shift
, shift
);
945 set_number_format(AdgDimStyle
*dim_style
, const gchar
*format
)
947 g_free(dim_style
->priv
->number_format
);
948 dim_style
->priv
->number_format
= g_strdup(format
);
952 set_number_tag(AdgDimStyle
*dim_style
, const gchar
*tag
)
954 g_free(dim_style
->priv
->number_tag
);
955 dim_style
->priv
->number_tag
= g_strdup(tag
);