[docs] Included AdgColorStyle
[adg.git] / adg / adg-dim-style.c
blobdf3b8eb0fe7b39bab612a44c723a03bd19fd99c6
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.
21 /**
22 * SECTION:adg-dim-style
23 * @short_description: Dimension style related stuff
25 * Contains parameters on how to build dimensions such as the different font
26 * styles (for value, tolerance and note), line style, offsets of the various
27 * dimension components etc...
30 /**
31 * AdgDimStyle:
33 * All fields are private and should not be used directly.
34 * Use its public methods instead.
35 **/
38 #include "adg-dim-style.h"
39 #include "adg-dim-style-private.h"
40 #include "adg-font-style.h"
41 #include "adg-line-style.h"
42 #include "adg-intl.h"
43 #include "adg-util.h"
46 enum {
47 PROP_0,
48 PROP_VALUE_DRESS,
49 PROP_UP_DRESS,
50 PROP_DOWN_DRESS,
51 PROP_NOTE_DRESS,
52 PROP_LINE_DRESS,
53 PROP_FROM_OFFSET,
54 PROP_TO_OFFSET,
55 PROP_BEYOND,
56 PROP_BASELINE_SPACING,
57 PROP_TOLERANCE_SPACING,
58 PROP_QUOTE_SHIFT,
59 PROP_TOLERANCE_SHIFT,
60 PROP_NOTE_SHIFT,
61 PROP_NUMBER_FORMAT,
62 PROP_NUMBER_TAG
66 static void get_property (GObject *object,
67 guint prop_id,
68 GValue *value,
69 GParamSpec *pspec);
70 static void set_property (GObject *object,
71 guint prop_id,
72 const GValue *value,
73 GParamSpec *pspec);
74 static void apply (AdgStyle *style,
75 cairo_t *cr);
76 static void set_quote_shift (AdgDimStyle *dim_style,
77 const AdgPair *shift);
78 static void set_tolerance_shift (AdgDimStyle *dim_style,
79 const AdgPair *shift);
80 static void set_note_shift (AdgDimStyle *dim_style,
81 const AdgPair *shift);
82 static void set_number_format (AdgDimStyle *dim_style,
83 const gchar *format);
84 static void set_number_tag (AdgDimStyle *dim_style,
85 const gchar *tag);
88 G_DEFINE_TYPE(AdgDimStyle, adg_dim_style, ADG_TYPE_STYLE);
91 static void
92 adg_dim_style_class_init(AdgDimStyleClass *klass)
94 GObjectClass *gobject_class;
95 AdgStyleClass *style_class;
96 GParamSpec *param;
98 gobject_class = (GObjectClass *) klass;
99 style_class = (AdgStyleClass *) klass;
101 g_type_class_add_private(klass, sizeof(AdgDimStylePrivate));
103 gobject_class->get_property = get_property;
104 gobject_class->set_property = set_property;
106 style_class->apply = apply;
108 param = adg_param_spec_dress("value-dress",
109 P_("Value Dress"),
110 P_("Font dress for the nominal value of the dimension"),
111 ADG_DRESS_TEXT_VALUE,
112 G_PARAM_READWRITE);
113 g_object_class_install_property(gobject_class, PROP_VALUE_DRESS, param);
115 param = adg_param_spec_dress("up-dress",
116 P_("Up-limit Dress"),
117 P_("Font dress for the upper limit value"),
118 ADG_DRESS_TEXT_LIMIT,
119 G_PARAM_READWRITE);
120 g_object_class_install_property(gobject_class, PROP_UP_DRESS, param);
122 param = adg_param_spec_dress("down-dress",
123 P_("Down-limit Dress"),
124 P_("Font dress for the lower limit value"),
125 ADG_DRESS_TEXT_LIMIT,
126 G_PARAM_READWRITE);
127 g_object_class_install_property(gobject_class, PROP_DOWN_DRESS, param);
129 param = adg_param_spec_dress("note-dress",
130 P_("Note Dress"),
131 P_("Font dress for the note"),
132 ADG_DRESS_TEXT_VALUE,
133 G_PARAM_READWRITE);
134 g_object_class_install_property(gobject_class, PROP_NOTE_DRESS, param);
136 param = adg_param_spec_dress("line-dress",
137 P_("Line Dress"),
138 P_("Line dress for the baseline and the extension lines"),
139 ADG_DRESS_LINE_DIMENSION,
140 G_PARAM_READWRITE);
141 g_object_class_install_property(gobject_class, PROP_LINE_DRESS, param);
143 param = g_param_spec_double("from-offset",
144 P_("From Offset"),
145 P_("Offset (in global space) of the extension lines from the path to the quote"),
146 0, G_MAXDOUBLE, 5,
147 G_PARAM_READWRITE);
148 g_object_class_install_property(gobject_class, PROP_FROM_OFFSET, param);
150 param = g_param_spec_double("to-offset",
151 P_("To Offset"),
152 P_("How many extend (in global space) the extension lines after hitting the baseline"),
153 0, G_MAXDOUBLE, 5,
154 G_PARAM_READWRITE);
155 g_object_class_install_property(gobject_class, PROP_TO_OFFSET, param);
157 param = g_param_spec_double("beyond",
158 P_("Beyond Length"),
159 P_("How much the baseline should be extended (in global space) beyond the extension lines on dimensions with outside markers: 0 means to automatically compute this value at run-time as 3*marker-size (got from the binded array-style)"),
160 0, G_MAXDOUBLE, 0,
161 G_PARAM_READWRITE);
162 g_object_class_install_property(gobject_class, PROP_BEYOND, param);
164 param = g_param_spec_double("baseline-spacing",
165 P_("Baseline Spacing"),
166 P_("Distance between two consecutive baselines while stacking dimensions"),
167 0, G_MAXDOUBLE, 30,
168 G_PARAM_READWRITE);
169 g_object_class_install_property(gobject_class, PROP_BASELINE_SPACING, param);
171 param = g_param_spec_double("tolerance-spacing",
172 P_("Tolerance Spacing"),
173 P_("Distance between up and down tolerance text"),
174 0, G_MAXDOUBLE, 2,
175 G_PARAM_READWRITE);
176 g_object_class_install_property(gobject_class, PROP_TOLERANCE_SPACING, param);
178 param = g_param_spec_boxed("quote-shift",
179 P_("Quote Shift"),
180 P_("Used to specify a smooth displacement (in global space) of the quote by taking as reference the perfect compact position (the middle of the baseline on common linear dimension, for instance)"),
181 ADG_TYPE_PAIR, G_PARAM_READWRITE);
182 g_object_class_install_property(gobject_class, PROP_QUOTE_SHIFT, param);
184 param = g_param_spec_boxed("tolerance-shift",
185 P_("Tolerance Shift"),
186 P_("Used to specify a smooth displacement (in global space) for the tolerance text by taking as reference the perfect compact position"),
187 ADG_TYPE_PAIR, G_PARAM_READWRITE);
188 g_object_class_install_property(gobject_class, PROP_TOLERANCE_SHIFT,
189 param);
191 param = g_param_spec_boxed("note-shift",
192 P_("Note Shift"),
193 P_("Used to specify a smooth displacement (in global space) for the note text by taking as reference the perfect compact position"),
194 ADG_TYPE_PAIR, G_PARAM_READWRITE);
195 g_object_class_install_property(gobject_class, PROP_NOTE_SHIFT, param);
197 param = g_param_spec_string("number-format",
198 P_("Number Format"),
199 P_("The format (in printf style) of the numeric component of the basic value"),
200 "%-.7g", G_PARAM_READWRITE);
201 g_object_class_install_property(gobject_class, PROP_NUMBER_FORMAT,
202 param);
204 param = g_param_spec_string("number-tag",
205 P_("Number Tag"),
206 P_("The tag to substitute inside the basic value pattern"),
207 "<>", G_PARAM_READWRITE);
208 g_object_class_install_property(gobject_class, PROP_NUMBER_TAG, param);
211 static void
212 adg_dim_style_init(AdgDimStyle *dim_style)
214 AdgDimStylePrivate *data = G_TYPE_INSTANCE_GET_PRIVATE(dim_style,
215 ADG_TYPE_DIM_STYLE,
216 AdgDimStylePrivate);
218 data->value_dress = ADG_DRESS_TEXT_VALUE;
219 data->up_dress = ADG_DRESS_TEXT_LIMIT;
220 data->down_dress = ADG_DRESS_TEXT_LIMIT;
221 data->note_dress = ADG_DRESS_TEXT_VALUE;
222 data->line_dress = ADG_DRESS_LINE_DIMENSION;
223 data->marker_dress = ADG_DRESS_UNDEFINED;
224 data->from_offset = 6;
225 data->to_offset = 6;
226 data->beyond = 0;
227 data->baseline_spacing = 30;
228 data->tolerance_spacing = 1;
229 data->quote_shift.x = 0;
230 data->quote_shift.y = -4;
231 data->tolerance_shift.x = +2;
232 data->tolerance_shift.y = -2;
233 data->note_shift.x = +4;
234 data->note_shift.y = 0;
235 data->number_format = g_strdup("%-.7g");
236 data->number_tag = g_strdup("<>");
238 dim_style->data = data;
241 static void
242 get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
244 AdgDimStylePrivate *data = ((AdgDimStyle *) object)->data;
246 switch (prop_id) {
247 case PROP_VALUE_DRESS:
248 g_value_set_int(value, data->value_dress);
249 break;
250 case PROP_UP_DRESS:
251 g_value_set_int(value, data->up_dress);
252 break;
253 case PROP_DOWN_DRESS:
254 g_value_set_int(value, data->down_dress);
255 break;
256 case PROP_NOTE_DRESS:
257 g_value_set_int(value, data->note_dress);
258 break;
259 case PROP_LINE_DRESS:
260 g_value_set_int(value, data->line_dress);
261 break;
262 case PROP_FROM_OFFSET:
263 g_value_set_double(value, data->from_offset);
264 break;
265 case PROP_TO_OFFSET:
266 g_value_set_double(value, data->to_offset);
267 break;
268 case PROP_BEYOND:
269 g_value_set_double(value, data->beyond);
270 break;
271 case PROP_BASELINE_SPACING:
272 g_value_set_double(value, data->baseline_spacing);
273 break;
274 case PROP_TOLERANCE_SPACING:
275 g_value_set_double(value, data->tolerance_spacing);
276 break;
277 case PROP_QUOTE_SHIFT:
278 g_value_set_boxed(value, &data->quote_shift);
279 break;
280 case PROP_TOLERANCE_SHIFT:
281 g_value_set_boxed(value, &data->tolerance_shift);
282 break;
283 case PROP_NOTE_SHIFT:
284 g_value_set_boxed(value, &data->note_shift);
285 break;
286 case PROP_NUMBER_FORMAT:
287 g_value_set_string(value, data->number_format);
288 break;
289 case PROP_NUMBER_TAG:
290 g_value_set_string(value, data->number_tag);
291 break;
292 default:
293 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
294 break;
298 static void
299 set_property(GObject *object,
300 guint prop_id, const GValue *value, GParamSpec *pspec)
302 AdgDimStyle *dim_style;
303 AdgDimStylePrivate *data;
305 dim_style = (AdgDimStyle *) object;
306 data = dim_style->data;
308 switch (prop_id) {
309 case PROP_VALUE_DRESS:
310 adg_dress_set(&data->value_dress, g_value_get_int(value));
311 break;
312 case PROP_UP_DRESS:
313 adg_dress_set(&data->up_dress, g_value_get_int(value));
314 break;
315 case PROP_DOWN_DRESS:
316 adg_dress_set(&data->down_dress, g_value_get_int(value));
317 break;
318 case PROP_NOTE_DRESS:
319 adg_dress_set(&data->note_dress, g_value_get_int(value));
320 break;
321 case PROP_LINE_DRESS:
322 adg_dress_set(&data->line_dress, g_value_get_int(value));
323 break;
324 case PROP_FROM_OFFSET:
325 data->from_offset = g_value_get_double(value);
326 break;
327 case PROP_TO_OFFSET:
328 data->to_offset = g_value_get_double(value);
329 break;
330 case PROP_BEYOND:
331 data->beyond = g_value_get_double(value);
332 break;
333 case PROP_BASELINE_SPACING:
334 data->baseline_spacing = g_value_get_double(value);
335 break;
336 case PROP_TOLERANCE_SPACING:
337 data->tolerance_spacing = g_value_get_double(value);
338 break;
339 case PROP_QUOTE_SHIFT:
340 set_quote_shift(dim_style, g_value_get_boxed(value));
341 break;
342 case PROP_TOLERANCE_SHIFT:
343 set_tolerance_shift(dim_style, g_value_get_boxed(value));
344 break;
345 case PROP_NOTE_SHIFT:
346 set_note_shift(dim_style, g_value_get_boxed(value));
347 break;
348 case PROP_NUMBER_FORMAT:
349 set_number_format(dim_style, g_value_get_string(value));
350 break;
351 case PROP_NUMBER_TAG:
352 set_number_tag(dim_style, g_value_get_string(value));
353 break;
354 default:
355 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
356 break;
362 * adg_dim_style_new:
364 * Constructs a new dimension style initialized with default params.
366 * Returns: a new dimension style
368 AdgStyle *
369 adg_dim_style_new(void)
371 return g_object_new(ADG_TYPE_DIM_STYLE, NULL);
375 * adg_dim_style_get_value_style:
376 * @dim_style: an #AdgDimStyle object
378 * Gets the basic value font style of @dim_style. No reference will
379 * be added to the returned style; it should not be unreferenced.
381 * Returns: the basic value style or %NULL on errors
383 AdgDress
384 adg_dim_style_get_value_dress(AdgDimStyle *dim_style)
386 AdgDimStylePrivate *data;
388 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), ADG_DRESS_UNDEFINED);
390 data = dim_style->data;
392 return data->value_dress;
396 * adg_dim_style_set_value_dress:
397 * @dim_style: an #AdgDimStyle object
398 * @style: the new basic value font style
400 * Sets a new font style on @dim_style for basic values. The old
401 * font style (if any) will be unreferenced while a new reference
402 * will be added to @style.
404 void
405 adg_dim_style_set_value_style(AdgDimStyle *dim_style, AdgDress dress)
407 AdgDimStylePrivate *data;
409 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
411 data = dim_style->data;
413 if (adg_dress_set(&data->value_dress, dress))
414 g_object_notify((GObject *) dim_style, "value-dress");
418 * adg_dim_style_get_up_dress:
419 * @dim_style: an #AdgDimStyle object
421 * Gets the tolerance style of @dim_style. No reference will be added to the
422 * returned style; it should not be unreferenced.
424 * Returns: the tolerance style or %NULL on errors
426 AdgDress
427 adg_dim_style_get_up_dress(AdgDimStyle *dim_style)
429 AdgDimStylePrivate *data;
431 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), ADG_DRESS_UNDEFINED);
433 data = dim_style->data;
435 return data->up_dress;
439 * adg_dim_style_set_up_dress:
440 * @dim_style: an #AdgDimStyle object
441 * @dress: the new upper limit dress
443 * Sets a new tolerance style on @dim_style. The old tolerance style (if any)
444 * will be unreferenced while a new reference will be added to @style.
446 void
447 adg_dim_style_set_up_dress(AdgDimStyle *dim_style, AdgDress dress)
449 AdgDimStylePrivate *data;
451 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
453 data = dim_style->data;
455 if (adg_dress_set(&data->up_dress, dress))
456 g_object_notify((GObject *) dim_style, "up-dress");
460 * adg_dim_style_get_note_dress:
461 * @dim_style: an #AdgDimStyle object
463 * Gets the note style of @dim_style. No reference will be added to the
464 * returned style; it should not be unreferenced.
466 * Returns: the note style or %NULL on errors
468 AdgDress
469 adg_dim_style_get_note_dress(AdgDimStyle *dim_style)
471 AdgDimStylePrivate *data;
473 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), ADG_DRESS_UNDEFINED);
475 data = dim_style->data;
477 return data->note_dress;
481 * adg_dim_style_set_note_dress:
482 * @dim_style: an #AdgDimStyle object
483 * @style: the new note style
485 * Sets a new note style on @dim_style. The old note style (if any) will be
486 * unreferenced while a new reference will be added to @style.
488 void
489 adg_dim_style_set_note_dress(AdgDimStyle *dim_style, AdgDress dress)
491 AdgDimStylePrivate *data;
493 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
495 data = dim_style->data;
497 if (adg_dress_set(&data->note_dress, dress))
498 g_object_notify((GObject *) dim_style, "note-dress");
502 * adg_dim_style_get_line_dress:
503 * @dim_style: an #AdgDimStyle object
505 * Gets the line style of @dim_style. No reference will be added to the
506 * returned style; it should not be unreferenced.
508 * Returns: the line style or %NULL on errors
510 AdgDress
511 adg_dim_style_get_line_dress(AdgDimStyle *dim_style)
513 AdgDimStylePrivate *data;
515 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), ADG_DRESS_UNDEFINED);
517 data = dim_style->data;
519 return data->line_dress;
523 * adg_dim_style_set_line_dress:
524 * @dim_style: an #AdgDimStyle object
525 * @dress: the new line dress
527 * Sets a new line dress on @dim_style.
529 void
530 adg_dim_style_set_line_dress(AdgDimStyle *dim_style, AdgDress dress)
532 AdgDimStylePrivate *data;
534 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
536 data = dim_style->data;
538 if (adg_dress_set(&data->line_dress, dress))
539 g_object_notify((GObject *) dim_style, "line-dress");
543 * adg_dim_style_get_from_offset:
544 * @dim_style: an #AdgDimStyle object
546 * Gets the distance (in global space) the extension lines must keep from the
547 * sensed points.
549 * Returns: the requested distance
551 gdouble
552 adg_dim_style_get_from_offset(AdgDimStyle *dim_style)
554 AdgDimStylePrivate *data;
556 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), 0);
558 data = dim_style->data;
560 return data->from_offset;
564 * adg_dim_style_set_from_offset:
565 * @dim_style: an #AdgDimStyle object
566 * @offset: the new offset
568 * Sets a new "from-offset" value.
570 void
571 adg_dim_style_set_from_offset(AdgDimStyle *dim_style, gdouble offset)
573 AdgDimStylePrivate *data;
575 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
577 data = dim_style->data;
578 data->from_offset = offset;
580 g_object_notify((GObject *) dim_style, "from-offset");
584 * adg_dim_style_get_to_offset:
585 * @dim_style: an #AdgDimStyle object
587 * Gets how much (in global space) the extension lines must extend after
588 * crossing the baseline.
590 * Returns: the requested distance
592 gdouble
593 adg_dim_style_get_to_offset(AdgDimStyle *dim_style)
595 AdgDimStylePrivate *data;
597 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), 0);
599 data = dim_style->data;
601 return data->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.
611 void
612 adg_dim_style_set_to_offset(AdgDimStyle *dim_style, gdouble offset)
614 AdgDimStylePrivate *data;
616 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
618 data = dim_style->data;
619 data->to_offset = offset;
621 g_object_notify((GObject *) dim_style, "to-offset");
625 * adg_dim_style_beyond:
626 * @dim_style: an #AdgDimStyle object
628 * Gets how much (in global space) the baseline should extend beyound
629 * the extension lines when a dimension has outside markers. If the
630 * underlying AdgDimStyle:beyond property is %0, this function returns
631 * the 3*"marker-size", where "marker-size" is the value returned by
632 * adg_marker_style_get_size() on #AdgMarkerStyle binded to @dim_style.
634 * Returns: the requested lenght
636 gdouble
637 adg_dim_style_beyond(AdgDimStyle *dim_style)
639 AdgDimStylePrivate *data;
640 gdouble marker_size;
642 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), 0);
644 data = dim_style->data;
645 marker_size = 10;
647 if (data->beyond > 0)
648 return data->beyond;
650 return marker_size * 3;
654 * adg_dim_style_get_beyond:
655 * @dim_style: an #AdgDimStyle object
657 * Gets how much (in global space) the baseline should extend beyound
658 * the extension lines on dimension with outside markers. This is an
659 * accessor method: if you need AdgDimStyle:beyond for rendering purpose,
660 * use adg_dim_style_beyond() instead.
662 * Returns: the requested lenght or %0 for automatic computation
664 gdouble
665 adg_dim_style_get_beyond(AdgDimStyle *dim_style)
667 AdgDimStylePrivate *data;
669 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), 0);
671 data = dim_style->data;
673 return data->beyond;
677 * adg_dim_style_set_beyond:
678 * @dim_style: an #AdgDimStyle object
679 * @length: the new length
681 * Sets a new "beyond" value.
683 void
684 adg_dim_style_set_beyond(AdgDimStyle *dim_style, gdouble length)
686 AdgDimStylePrivate *data;
688 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
690 data = dim_style->data;
691 data->beyond = length;
693 g_object_notify((GObject *) dim_style, "beyond");
697 * adg_dim_style_get_baseline_spacing:
698 * @dim_style: an #AdgDimStyle object
700 * Gets the distance between two consecutive baselines
701 * while stacking dimensions.
703 * Returns: the requested spacing
705 gdouble
706 adg_dim_style_get_baseline_spacing(AdgDimStyle *dim_style)
708 AdgDimStylePrivate *data;
710 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), 0);
712 data = dim_style->data;
714 return data->baseline_spacing;
718 * adg_dim_style_set_baseline_spacing:
719 * @dim_style: an #AdgDimStyle object
720 * @spacing: the new spacing
722 * Sets a new "baseline-spacing" value.
724 void
725 adg_dim_style_set_baseline_spacing(AdgDimStyle *dim_style, gdouble spacing)
727 AdgDimStylePrivate *data;
729 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
731 data = dim_style->data;
732 data->baseline_spacing = spacing;
734 g_object_notify((GObject *) dim_style, "baseline-spacing");
738 * adg_dim_style_get_tolerance_spacing:
739 * @dim_style: an #AdgDimStyle object
741 * Gets the distance (in global space) between up and down tolerances.
743 * Returns: the requested spacing
745 gdouble
746 adg_dim_style_get_tolerance_spacing(AdgDimStyle *dim_style)
748 AdgDimStylePrivate *data;
750 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), 0);
752 data = dim_style->data;
754 return data->tolerance_spacing;
758 * adg_dim_style_set_tolerance_spacing:
759 * @dim_style: an #AdgDimStyle object
760 * @spacing: the new spacing
762 * Sets a new "tolerance-spacing" value.
764 void
765 adg_dim_style_set_tolerance_spacing(AdgDimStyle *dim_style, gdouble spacing)
767 AdgDimStylePrivate *data;
769 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
771 data = dim_style->data;
772 data->tolerance_spacing = spacing;
774 g_object_notify((GObject *) dim_style, "tolerance-spacing");
778 * adg_dim_style_get_quote_shift:
779 * @dim_style: an #AdgDimStyle object
781 * Gets the smooth displacement of the quote. The returned pointer refers
782 * to an internal allocated struct and must not be modified or freed.
784 * Returns: the requested shift
786 const AdgPair *
787 adg_dim_style_get_quote_shift(AdgDimStyle *dim_style)
789 AdgDimStylePrivate *data;
791 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), NULL);
793 data = dim_style->data;
795 return &data->quote_shift;
799 * adg_dim_style_set_quote_shift:
800 * @dim_style: an #AdgDimStyle object
801 * @shift: the new displacement
803 * Sets a new "quote-shift" value.
805 void
806 adg_dim_style_set_quote_shift(AdgDimStyle *dim_style, const AdgPair *shift)
808 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
810 set_quote_shift(dim_style, shift);
811 g_object_notify((GObject *) dim_style, "quote-shift");
815 * adg_dim_style_get_tolerance_shift:
816 * @dim_style: an #AdgDimStyle object
818 * Gets the smooth displacement of the tolerance text. The returned pointer
819 * refers to an internal allocated struct and must not be modified or freed.
821 * Returns: the requested shift
823 const AdgPair *
824 adg_dim_style_get_tolerance_shift(AdgDimStyle *dim_style)
826 AdgDimStylePrivate *data;
828 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), NULL);
830 data = dim_style->data;
832 return &data->tolerance_shift;
836 * adg_dim_style_set_tolerance_shift:
837 * @dim_style: an #AdgDimStyle object
838 * @shift: the new displacement
840 * Sets a new "tolerance-shift" value.
842 void
843 adg_dim_style_set_tolerance_shift(AdgDimStyle *dim_style, const AdgPair *shift)
845 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
847 set_tolerance_shift(dim_style, shift);
848 g_object_notify((GObject *) dim_style, "tolerance-shift");
852 * adg_dim_style_get_note_shift:
853 * @dim_style: an #AdgDimStyle object
855 * Gets the smooth displacement of the note text. The returned pointer
856 * refers to an internal allocated struct and must not be modified or freed.
858 * Returns: the requested shift
860 const AdgPair *
861 adg_dim_style_get_note_shift(AdgDimStyle *dim_style)
863 AdgDimStylePrivate *data;
865 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), NULL);
867 data = dim_style->data;
869 return &data->note_shift;
873 * adg_dim_style_set_note_shift:
874 * @dim_style: an #AdgDimStyle object
875 * @shift: the new displacement
877 * Sets a new "note-shift" value.
879 void
880 adg_dim_style_set_note_shift(AdgDimStyle *dim_style, const AdgPair *shift)
882 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
884 set_note_shift(dim_style, shift);
885 g_object_notify((GObject *) dim_style, "note-shift");
889 * adg_dim_style_get_number_format:
890 * @dim_style: an #AdgDimStyle object
892 * Gets the number format (in printf style) of this quoting style. The
893 * returned pointer refers to internally managed text that must not be
894 * modified or freed.
896 * Returns: the requested format
898 const gchar *
899 adg_dim_style_get_number_format(AdgDimStyle *dim_style)
901 AdgDimStylePrivate *data;
903 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), NULL);
905 data = dim_style->data;
907 return data->number_format;
911 * adg_dim_style_set_number_format:
912 * @dim_style: an #AdgDimStyle object
913 * @format: the new format to adopt
915 * Sets a new "number-format" value.
917 void
918 adg_dim_style_set_number_format(AdgDimStyle *dim_style, const gchar *format)
920 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
922 set_number_format(dim_style, format);
923 g_object_notify((GObject *) dim_style, "number-format");
927 * adg_dim_style_get_number_tag:
928 * @dim_style: an #AdgDimStyle object
930 * Gets the number tag to substitute while building the basic value. The
931 * returned pointer refers to internally managed text that must not be
932 * modified or freed.
934 * Returns: the requested tag
936 const gchar *
937 adg_dim_style_get_number_tag(AdgDimStyle *dim_style)
939 AdgDimStylePrivate *data;
941 g_return_val_if_fail(ADG_IS_DIM_STYLE(dim_style), NULL);
943 data = dim_style->data;
945 return data->number_tag;
949 * adg_dim_style_set_number_tag:
950 * @dim_style: an #AdgDimStyle object
951 * @tag: the new tag
953 * Sets a new "number-tag" value.
955 void
956 adg_dim_style_set_number_tag(AdgDimStyle *dim_style, const gchar *tag)
958 g_return_if_fail(ADG_IS_DIM_STYLE(dim_style));
960 set_number_tag(dim_style, tag);
961 g_object_notify((GObject *) dim_style, "number-tag");
965 static void
966 apply(AdgStyle *style, cairo_t *cr)
970 static void
971 set_quote_shift(AdgDimStyle *dim_style, const AdgPair *shift)
973 AdgDimStylePrivate *data = dim_style->data;
975 cpml_pair_copy(&data->quote_shift, shift);
978 static void
979 set_tolerance_shift(AdgDimStyle *dim_style, const AdgPair *shift)
981 AdgDimStylePrivate *data = dim_style->data;
983 cpml_pair_copy(&data->tolerance_shift, shift);
986 static void
987 set_note_shift(AdgDimStyle *dim_style, const AdgPair *shift)
989 AdgDimStylePrivate *data = dim_style->data;
991 cpml_pair_copy(&data->note_shift, shift);
994 static void
995 set_number_format(AdgDimStyle *dim_style, const gchar *format)
997 AdgDimStylePrivate *data = dim_style->data;
999 g_free(data->number_format);
1000 data->number_format = g_strdup(format);
1003 static void
1004 set_number_tag(AdgDimStyle *dim_style, const gchar *tag)
1006 AdgDimStylePrivate *data = dim_style->data;
1008 g_free(data->number_tag);
1009 data->number_tag = g_strdup(tag);