97aeb187720916a0403d1baf4377ef6a9a2d3d90
1 #define __SP_ITEM_C__
3 /** \file
4 * Base class for visual SVG elements
5 */
6 /*
7 * Authors:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 * bulia byak <buliabyak@users.sf.net>
10 *
11 * Copyright (C) 2001-2005 authors
12 * Copyright (C) 2001 Ximian, Inc.
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 /** \class SPItem
18 *
19 * SPItem is an abstract base class for all graphic (visible) SVG nodes. It
20 * is a subclass of SPObject, with great deal of specific functionality.
21 */
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
29 #include "svg/svg.h"
30 #include "print.h"
31 #include "display/nr-arena.h"
32 #include "display/nr-arena-item.h"
33 #include "attributes.h"
34 #include "document.h"
35 #include "uri.h"
37 #include "style.h"
38 #include <glibmm/i18n.h>
39 #include "sp-root.h"
40 #include "sp-clippath.h"
41 #include "sp-mask.h"
42 #include "sp-rect.h"
43 #include "sp-use.h"
44 #include "sp-text.h"
45 #include "sp-item-rm-unsatisfied-cns.h"
46 #include "sp-pattern.h"
47 #include "gradient-chemistry.h"
48 #include "prefs-utils.h"
49 #include "conn-avoid-ref.h"
51 #include "libnr/nr-matrix-div.h"
52 #include "libnr/nr-matrix-fns.h"
53 #include "libnr/nr-matrix-scale-ops.h"
54 #include "libnr/nr-matrix-translate-ops.h"
55 #include "libnr/nr-scale-translate-ops.h"
56 #include "libnr/nr-translate-scale-ops.h"
57 #include "algorithms/find-last-if.h"
58 #include "util/reverse-list.h"
60 #include "xml/repr.h"
62 #define noSP_ITEM_DEBUG_IDLE
64 static void sp_item_class_init(SPItemClass *klass);
65 static void sp_item_init(SPItem *item);
67 static void sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
68 static void sp_item_release(SPObject *object);
69 static void sp_item_set(SPObject *object, unsigned key, gchar const *value);
70 static void sp_item_update(SPObject *object, SPCtx *ctx, guint flags);
71 static Inkscape::XML::Node *sp_item_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
73 static gchar *sp_item_private_description(SPItem *item);
74 static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p);
76 static SPItemView *sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem);
77 static SPItemView *sp_item_view_list_remove(SPItemView *list, SPItemView *view);
79 static SPObjectClass *parent_class;
81 static void clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item);
82 static void mask_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item);
84 /**
85 * Registers SPItem class and returns its type number.
86 */
87 GType
88 sp_item_get_type(void)
89 {
90 static GType type = 0;
91 if (!type) {
92 GTypeInfo info = {
93 sizeof(SPItemClass),
94 NULL, NULL,
95 (GClassInitFunc) sp_item_class_init,
96 NULL, NULL,
97 sizeof(SPItem),
98 16,
99 (GInstanceInitFunc) sp_item_init,
100 NULL, /* value_table */
101 };
102 type = g_type_register_static(SP_TYPE_OBJECT, "SPItem", &info, (GTypeFlags)0);
103 }
104 return type;
105 }
107 /**
108 * SPItem vtable initialization.
109 */
110 static void
111 sp_item_class_init(SPItemClass *klass)
112 {
113 SPObjectClass *sp_object_class = (SPObjectClass *) klass;
115 parent_class = (SPObjectClass *)g_type_class_ref(SP_TYPE_OBJECT);
117 sp_object_class->build = sp_item_build;
118 sp_object_class->release = sp_item_release;
119 sp_object_class->set = sp_item_set;
120 sp_object_class->update = sp_item_update;
121 sp_object_class->write = sp_item_write;
123 klass->description = sp_item_private_description;
124 klass->snappoints = sp_item_private_snappoints;
125 }
127 /**
128 * Callback for SPItem object initialization.
129 */
130 static void
131 sp_item_init(SPItem *item)
132 {
133 SPObject *object = SP_OBJECT(item);
135 item->sensitive = TRUE;
137 item->r_cx = 0;
138 item->r_cx = 0;
140 item->transform = NR::identity();
142 item->display = NULL;
144 item->clip_ref = new SPClipPathReference(SP_OBJECT(item));
145 {
146 sigc::signal<void, SPObject *, SPObject *> cs1=item->clip_ref->changedSignal();
147 sigc::slot2<void,SPObject*, SPObject *> sl1=sigc::bind(sigc::ptr_fun(clip_ref_changed), item);
148 cs1.connect(sl1);
149 }
151 item->mask_ref = new SPMaskReference(SP_OBJECT(item));
152 sigc::signal<void, SPObject *, SPObject *> cs2=item->mask_ref->changedSignal();
153 sigc::slot2<void,SPObject*, SPObject *> sl2=sigc::bind(sigc::ptr_fun(mask_ref_changed), item);
154 cs2.connect(sl2);
156 if (!object->style) object->style = sp_style_new_from_object(SP_OBJECT(item));
158 item->avoidRef = new SPAvoidRef(item);
160 new (&item->_transformed_signal) sigc::signal<void, NR::Matrix const *, SPItem *>();
161 }
163 bool SPItem::isVisibleAndUnlocked() const {
164 return (!isHidden() && !isLocked());
165 }
167 bool SPItem::isVisibleAndUnlocked(unsigned display_key) const {
168 return (!isHidden(display_key) && !isLocked());
169 }
171 bool SPItem::isLocked() const {
172 for (SPObject *o = SP_OBJECT(this); o != NULL; o = SP_OBJECT_PARENT(o)) {
173 if (SP_IS_ITEM(o) && !(SP_ITEM(o)->sensitive))
174 return true;
175 }
176 return false;
177 }
179 void SPItem::setLocked(bool locked) {
180 SP_OBJECT_REPR(this)->setAttribute("sodipodi:insensitive",
181 ( locked ? "1" : NULL ));
182 updateRepr();
183 }
185 bool SPItem::isHidden() const {
186 return style->display.computed == SP_CSS_DISPLAY_NONE;
187 }
189 void SPItem::setHidden(bool hide) {
190 style->display.set = TRUE;
191 style->display.value = ( hide ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE );
192 style->display.computed = style->display.value;
193 style->display.inherit = FALSE;
194 updateRepr();
195 }
197 bool SPItem::isHidden(unsigned display_key) const {
198 for ( SPItemView *view(display) ; view ; view = view->next ) {
199 if ( view->key == display_key ) {
200 g_assert(view->arenaitem != NULL);
201 for ( NRArenaItem *arenaitem = view->arenaitem ;
202 arenaitem ; arenaitem = arenaitem->parent )
203 {
204 if (!arenaitem->visible) {
205 return true;
206 }
207 }
208 return false;
209 }
210 }
211 return true;
212 }
214 /**
215 * Returns something suitable for the `Hide' checkbox in the Object Properties dialog box.
216 * Corresponds to setExplicitlyHidden.
217 */
218 bool
219 SPItem::isExplicitlyHidden() const
220 {
221 return (this->style->display.set
222 && this->style->display.value == SP_CSS_DISPLAY_NONE);
223 }
225 /**
226 * Sets the display CSS property to `hidden' if \a val is true,
227 * otherwise makes it unset
228 */
229 void
230 SPItem::setExplicitlyHidden(bool const val) {
231 this->style->display.set = val;
232 this->style->display.value = ( val ? SP_CSS_DISPLAY_NONE : SP_CSS_DISPLAY_INLINE );
233 this->style->display.computed = this->style->display.value;
234 this->updateRepr();
235 }
237 namespace {
239 bool is_item(SPObject const &object) {
240 return SP_IS_ITEM(&object);
241 }
243 }
245 void SPItem::raiseToTop() {
246 using Inkscape::Algorithms::find_last_if;
248 SPObject *topmost=find_last_if<SPObject::SiblingIterator>(
249 SP_OBJECT_NEXT(this), NULL, &is_item
250 );
251 if (topmost) {
252 Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
253 sp_repr_parent(repr)->changeOrder(repr, SP_OBJECT_REPR(topmost));
254 }
255 }
257 void SPItem::raiseOne() {
258 SPObject *next_higher=std::find_if<SPObject::SiblingIterator>(
259 SP_OBJECT_NEXT(this), NULL, &is_item
260 );
261 if (next_higher) {
262 Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
263 Inkscape::XML::Node *ref=SP_OBJECT_REPR(next_higher);
264 sp_repr_parent(repr)->changeOrder(repr, ref);
265 }
266 }
268 void SPItem::lowerOne() {
269 using Inkscape::Util::MutableList;
270 using Inkscape::Util::reverse_list;
272 MutableList<SPObject &> next_lower=std::find_if(
273 reverse_list<SPObject::SiblingIterator>(
274 SP_OBJECT_PARENT(this)->firstChild(), this
275 ),
276 MutableList<SPObject &>(),
277 &is_item
278 );
279 if (next_lower) {
280 ++next_lower;
281 Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
282 Inkscape::XML::Node *ref=( next_lower ? SP_OBJECT_REPR(&*next_lower) : NULL );
283 sp_repr_parent(repr)->changeOrder(repr, ref);
284 }
285 }
287 void SPItem::lowerToBottom() {
288 using Inkscape::Algorithms::find_last_if;
289 using Inkscape::Util::MutableList;
290 using Inkscape::Util::reverse_list;
292 MutableList<SPObject &> bottom=find_last_if(
293 reverse_list<SPObject::SiblingIterator>(
294 SP_OBJECT_PARENT(this)->firstChild(), this
295 ),
296 MutableList<SPObject &>(),
297 &is_item
298 );
299 if (bottom) {
300 ++bottom;
301 Inkscape::XML::Node *repr=SP_OBJECT_REPR(this);
302 Inkscape::XML::Node *ref=( bottom ? SP_OBJECT_REPR(&*bottom) : NULL );
303 sp_repr_parent(repr)->changeOrder(repr, ref);
304 }
305 }
307 static void
308 sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
309 {
310 sp_object_read_attr(object, "style");
311 sp_object_read_attr(object, "transform");
312 sp_object_read_attr(object, "clip-path");
313 sp_object_read_attr(object, "mask");
314 sp_object_read_attr(object, "sodipodi:insensitive");
315 sp_object_read_attr(object, "sodipodi:nonprintable");
316 sp_object_read_attr(object, "inkscape:r_cx");
317 sp_object_read_attr(object, "inkscape:r_cy");
318 sp_object_read_attr(object, "inkscape:connector-avoid");
320 if (((SPObjectClass *) (parent_class))->build) {
321 (* ((SPObjectClass *) (parent_class))->build)(object, document, repr);
322 }
323 }
325 static void
326 sp_item_release(SPObject *object)
327 {
328 SPItem *item = (SPItem *) object;
330 if (item->clip_ref) {
331 item->clip_ref->detach();
332 delete item->clip_ref;
333 item->clip_ref = NULL;
334 }
336 if (item->mask_ref) {
337 item->mask_ref->detach();
338 delete item->mask_ref;
339 item->mask_ref = NULL;
340 }
342 if (item->avoidRef) {
343 delete item->avoidRef;
344 item->avoidRef = NULL;
345 }
347 if (((SPObjectClass *) (parent_class))->release) {
348 ((SPObjectClass *) parent_class)->release(object);
349 }
351 while (item->display) {
352 nr_arena_item_unparent(item->display->arenaitem);
353 item->display = sp_item_view_list_remove(item->display, item->display);
354 }
356 item->_transformed_signal.~signal();
357 }
359 static void
360 sp_item_set(SPObject *object, unsigned key, gchar const *value)
361 {
362 SPItem *item = (SPItem *) object;
364 switch (key) {
365 case SP_ATTR_TRANSFORM: {
366 NR::Matrix t;
367 if (value && sp_svg_transform_read(value, &t)) {
368 sp_item_set_item_transform(item, t);
369 } else {
370 sp_item_set_item_transform(item, NR::identity());
371 }
372 break;
373 }
374 case SP_PROP_CLIP_PATH: {
375 gchar *uri = Inkscape::parse_css_url(value);
376 if (uri) {
377 try {
378 item->clip_ref->attach(Inkscape::URI(uri));
379 } catch (Inkscape::BadURIException &e) {
380 g_warning("%s", e.what());
381 item->clip_ref->detach();
382 }
383 g_free(uri);
384 } else {
385 item->clip_ref->detach();
386 }
388 break;
389 }
390 case SP_PROP_MASK: {
391 gchar *uri=Inkscape::parse_css_url(value);
392 if (uri) {
393 try {
394 item->mask_ref->attach(Inkscape::URI(uri));
395 } catch (Inkscape::BadURIException &e) {
396 g_warning("%s", e.what());
397 item->mask_ref->detach();
398 }
399 g_free(uri);
400 } else {
401 item->mask_ref->detach();
402 }
404 break;
405 }
406 case SP_ATTR_SODIPODI_INSENSITIVE:
407 item->sensitive = !value;
408 for (SPItemView *v = item->display; v != NULL; v = v->next) {
409 nr_arena_item_set_sensitive(v->arenaitem, item->sensitive);
410 }
411 break;
412 case SP_ATTR_STYLE:
413 sp_style_read_from_object(object->style, object);
414 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
415 break;
416 case SP_ATTR_CONNECTOR_AVOID:
417 item->avoidRef->setAvoid(value);
418 break;
419 default:
420 if (SP_ATTRIBUTE_IS_CSS(key)) {
421 sp_style_read_from_object(object->style, object);
422 object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
423 } else {
424 if (((SPObjectClass *) (parent_class))->set) {
425 (* ((SPObjectClass *) (parent_class))->set)(object, key, value);
426 }
427 }
428 break;
429 }
430 }
432 static void
433 clip_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item)
434 {
435 if (old_clip) {
436 SPItemView *v;
437 /* Hide clippath */
438 for (v = item->display; v != NULL; v = v->next) {
439 sp_clippath_hide(SP_CLIPPATH(old_clip), NR_ARENA_ITEM_GET_KEY(v->arenaitem));
440 nr_arena_item_set_clip(v->arenaitem, NULL);
441 }
442 }
443 if (SP_IS_CLIPPATH(clip)) {
444 NRRect bbox;
445 sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
446 for (SPItemView *v = item->display; v != NULL; v = v->next) {
447 if (!v->arenaitem->key) {
448 NR_ARENA_ITEM_SET_KEY(v->arenaitem, sp_item_display_key_new(3));
449 }
450 NRArenaItem *ai = sp_clippath_show(SP_CLIPPATH(clip),
451 NR_ARENA_ITEM_ARENA(v->arenaitem),
452 NR_ARENA_ITEM_GET_KEY(v->arenaitem));
453 nr_arena_item_set_clip(v->arenaitem, ai);
454 nr_arena_item_unref(ai);
455 sp_clippath_set_bbox(SP_CLIPPATH(clip), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
456 }
457 }
458 }
460 static void
461 mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item)
462 {
463 if (old_mask) {
464 /* Hide mask */
465 for (SPItemView *v = item->display; v != NULL; v = v->next) {
466 sp_mask_hide(SP_MASK(old_mask), NR_ARENA_ITEM_GET_KEY(v->arenaitem));
467 nr_arena_item_set_mask(v->arenaitem, NULL);
468 }
469 }
470 if (SP_IS_MASK(mask)) {
471 NRRect bbox;
472 sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
473 for (SPItemView *v = item->display; v != NULL; v = v->next) {
474 if (!v->arenaitem->key) {
475 NR_ARENA_ITEM_SET_KEY(v->arenaitem, sp_item_display_key_new(3));
476 }
477 NRArenaItem *ai = sp_mask_show(SP_MASK(mask),
478 NR_ARENA_ITEM_ARENA(v->arenaitem),
479 NR_ARENA_ITEM_GET_KEY(v->arenaitem));
480 nr_arena_item_set_mask(v->arenaitem, ai);
481 nr_arena_item_unref(ai);
482 sp_mask_set_bbox(SP_MASK(mask), NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
483 }
484 }
485 }
487 static void
488 sp_item_update(SPObject *object, SPCtx *ctx, guint flags)
489 {
490 SPItem *item = SP_ITEM(object);
492 if (((SPObjectClass *) (parent_class))->update)
493 (* ((SPObjectClass *) (parent_class))->update)(object, ctx, flags);
495 if (flags & (SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG)) {
496 if (flags & SP_OBJECT_MODIFIED_FLAG) {
497 for (SPItemView *v = item->display; v != NULL; v = v->next) {
498 nr_arena_item_set_transform(v->arenaitem, item->transform);
499 }
500 }
502 SPClipPath *clip_path = item->clip_ref->getObject();
503 SPMask *mask = item->mask_ref->getObject();
505 if ( clip_path || mask ) {
506 NRRect bbox;
507 sp_item_invoke_bbox(item, &bbox, NR::identity(), TRUE);
508 if (clip_path) {
509 for (SPItemView *v = item->display; v != NULL; v = v->next) {
510 sp_clippath_set_bbox(clip_path, NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
511 }
512 }
513 if (mask) {
514 for (SPItemView *v = item->display; v != NULL; v = v->next) {
515 sp_mask_set_bbox(mask, NR_ARENA_ITEM_GET_KEY(v->arenaitem), &bbox);
516 }
517 }
518 }
520 if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
521 for (SPItemView *v = item->display; v != NULL; v = v->next) {
522 nr_arena_item_set_opacity(v->arenaitem, SP_SCALE24_TO_FLOAT(object->style->opacity.value));
523 nr_arena_item_set_visible(v->arenaitem, !item->isHidden());
524 }
525 }
526 }
528 // Update libavoid with item geometry (for connector routing).
529 item->avoidRef->handleSettingChange();
530 }
532 static Inkscape::XML::Node *
533 sp_item_write(SPObject *const object, Inkscape::XML::Node *repr, guint flags)
534 {
535 SPItem *item = SP_ITEM(object);
537 gchar c[256];
538 if (sp_svg_transform_write(c, 256, item->transform)) {
539 repr->setAttribute("transform", c);
540 } else {
541 repr->setAttribute("transform", NULL);
542 }
544 SPObject const *const parent = SP_OBJECT_PARENT(object);
545 /** \todo Can someone please document why this is conditional on having
546 * a parent? The only parentless thing I can think of is the top-level
547 * <svg> element (SPRoot). SPRoot is derived from SPGroup, and can have
548 * style. I haven't looked at callers.
549 */
550 if (parent) {
551 SPStyle const *const obj_style = SP_OBJECT_STYLE(object);
552 if (obj_style) {
553 gchar *s = sp_style_write_string(obj_style, SP_STYLE_FLAG_IFSET);
554 repr->setAttribute("style", ( *s ? s : NULL ));
555 g_free(s);
556 } else {
557 /** \todo I'm not sure what to do in this case. Bug #1165868
558 * suggests that it can arise, but the submitter doesn't know
559 * how to do so reliably. The main two options are either
560 * leave repr's style attribute unchanged, or explicitly clear it.
561 * Must also consider what to do with property attributes for
562 * the element; see below.
563 */
564 char const *style_str = repr->attribute("style");
565 if (!style_str) {
566 style_str = "NULL";
567 }
568 g_warning("Item's style is NULL; repr style attribute is %s", style_str);
569 }
571 /** \note We treat object->style as authoritative. Its effects have
572 * been written to the style attribute above; any properties that are
573 * unset we take to be deliberately unset (e.g. so that clones can
574 * override the property).
575 *
576 * Note that the below has an undesirable consequence of changing the
577 * appearance on renderers that lack CSS support (e.g. SVG tiny);
578 * possibly we should write property attributes instead of a style
579 * attribute.
580 */
581 sp_style_unset_property_attrs (object);
582 }
584 if (flags & SP_OBJECT_WRITE_EXT) {
585 repr->setAttribute("sodipodi:insensitive", ( item->sensitive ? NULL : "true" ));
586 repr->setAttribute("inkscape:r_cx", ( item->r_cx ? NULL : "true" ));
587 repr->setAttribute("inkscape:r_cy", ( item->r_cy ? NULL : "true" ));
588 }
590 if (((SPObjectClass *) (parent_class))->write) {
591 ((SPObjectClass *) (parent_class))->write(object, repr, flags);
592 }
594 return repr;
595 }
597 NR::Rect SPItem::invokeBbox(NR::Matrix const &transform) const
598 {
599 NRRect r;
600 sp_item_invoke_bbox_full(this, &r, transform, 0, TRUE);
601 return NR::Rect(r);
602 }
604 void
605 sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const clear)
606 {
607 sp_item_invoke_bbox_full(item, bbox, transform, 0, clear);
608 }
610 void
611 sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags, unsigned const clear)
612 {
613 g_assert(item != NULL);
614 g_assert(SP_IS_ITEM(item));
615 g_assert(bbox != NULL);
617 if (clear) {
618 bbox->x0 = bbox->y0 = 1e18;
619 bbox->x1 = bbox->y1 = -1e18;
620 }
622 if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) {
623 ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, bbox, transform, flags);
624 }
625 }
627 unsigned sp_item_pos_in_parent(SPItem *item)
628 {
629 g_assert(item != NULL);
630 g_assert(SP_IS_ITEM(item));
632 SPObject *parent = SP_OBJECT_PARENT(item);
633 g_assert(parent != NULL);
634 g_assert(SP_IS_OBJECT(parent));
636 SPObject *object = SP_OBJECT(item);
638 unsigned pos=0;
639 for ( SPObject *iter = sp_object_first_child(parent) ; iter ; iter = SP_OBJECT_NEXT(iter)) {
640 if ( iter == object ) {
641 return pos;
642 }
643 if (SP_IS_ITEM(iter)) {
644 pos++;
645 }
646 }
648 g_assert_not_reached();
649 return 0;
650 }
652 void
653 sp_item_bbox_desktop(SPItem *item, NRRect *bbox)
654 {
655 g_assert(item != NULL);
656 g_assert(SP_IS_ITEM(item));
657 g_assert(bbox != NULL);
659 sp_item_invoke_bbox(item, bbox, sp_item_i2d_affine(item), TRUE);
660 }
662 NR::Rect sp_item_bbox_desktop(SPItem *item)
663 {
664 NRRect ret;
665 sp_item_bbox_desktop(item, &ret);
666 return NR::Rect(ret);
667 }
669 static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p)
670 {
671 NR::Rect const bbox = item->invokeBbox(sp_item_i2d_affine(item));
672 /* Just a pair of opposite corners of the bounding box suffices given that we don't yet
673 support angled guide lines. */
675 *p = bbox.min();
676 *p = bbox.max();
677 }
679 void sp_item_snappoints(SPItem const *item, SnapPointsIter p)
680 {
681 g_assert (item != NULL);
682 g_assert (SP_IS_ITEM(item));
684 SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(item);
685 if (item_class.snappoints) {
686 item_class.snappoints(item, p);
687 }
688 }
690 void
691 sp_item_invoke_print(SPItem *item, SPPrintContext *ctx)
692 {
693 if (!item->isHidden()) {
694 if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->print) {
695 if (!item->transform.test_identity()
696 || SP_OBJECT_STYLE(item)->opacity.value != SP_SCALE24_MAX)
697 {
698 sp_print_bind(ctx, item->transform, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value));
699 ((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx);
700 sp_print_release(ctx);
701 } else {
702 ((SPItemClass *) G_OBJECT_GET_CLASS(item))->print(item, ctx);
703 }
704 }
705 }
706 }
708 static gchar *
709 sp_item_private_description(SPItem *item)
710 {
711 return g_strdup(_("Object"));
712 }
714 /**
715 * Returns a string suitable for status bar, formatted in pango markup language.
716 *
717 * Must be freed by caller.
718 */
719 gchar *
720 sp_item_description(SPItem *item)
721 {
722 g_assert(item != NULL);
723 g_assert(SP_IS_ITEM(item));
725 if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->description) {
726 return ((SPItemClass *) G_OBJECT_GET_CLASS(item))->description(item);
727 }
729 g_assert_not_reached();
730 return NULL;
731 }
733 /**
734 * Allocates unique integer keys.
735 * \param numkeys Number of keys required.
736 * \return First allocated key; hence if the returned key is n
737 * you can use n, n + 1, ..., n + (numkeys - 1)
738 */
739 unsigned
740 sp_item_display_key_new(unsigned numkeys)
741 {
742 static unsigned dkey = 0;
744 dkey += numkeys;
746 return dkey - numkeys;
747 }
749 NRArenaItem *
750 sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags)
751 {
752 g_assert(item != NULL);
753 g_assert(SP_IS_ITEM(item));
754 g_assert(arena != NULL);
755 g_assert(NR_IS_ARENA(arena));
757 NRArenaItem *ai = NULL;
758 if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->show) {
759 ai = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->show(item, arena, key, flags);
760 }
762 if (ai != NULL) {
763 item->display = sp_item_view_new_prepend(item->display, item, flags, key, ai);
764 nr_arena_item_set_transform(ai, item->transform);
765 nr_arena_item_set_opacity(ai, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value));
766 nr_arena_item_set_visible(ai, !item->isHidden());
767 nr_arena_item_set_sensitive(ai, item->sensitive);
768 if (item->clip_ref->getObject()) {
769 NRArenaItem *ac;
770 if (!item->display->arenaitem->key) NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
771 ac = sp_clippath_show(item->clip_ref->getObject(), arena, NR_ARENA_ITEM_GET_KEY(item->display->arenaitem));
772 nr_arena_item_set_clip(ai, ac);
773 nr_arena_item_unref(ac);
774 }
775 if (item->mask_ref->getObject()) {
776 NRArenaItem *ac;
777 if (!item->display->arenaitem->key) NR_ARENA_ITEM_SET_KEY(item->display->arenaitem, sp_item_display_key_new(3));
778 ac = sp_mask_show(item->mask_ref->getObject(), arena, NR_ARENA_ITEM_GET_KEY(item->display->arenaitem));
779 nr_arena_item_set_mask(ai, ac);
780 nr_arena_item_unref(ac);
781 }
782 NR_ARENA_ITEM_SET_DATA(ai, item);
783 }
785 return ai;
786 }
788 void
789 sp_item_invoke_hide(SPItem *item, unsigned key)
790 {
791 g_assert(item != NULL);
792 g_assert(SP_IS_ITEM(item));
794 if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide) {
795 ((SPItemClass *) G_OBJECT_GET_CLASS(item))->hide(item, key);
796 }
798 SPItemView *ref = NULL;
799 SPItemView *v = item->display;
800 while (v != NULL) {
801 SPItemView *next = v->next;
802 if (v->key == key) {
803 if (item->clip_ref->getObject()) {
804 sp_clippath_hide(item->clip_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem));
805 nr_arena_item_set_clip(v->arenaitem, NULL);
806 }
807 if (item->mask_ref->getObject()) {
808 sp_mask_hide(item->mask_ref->getObject(), NR_ARENA_ITEM_GET_KEY(v->arenaitem));
809 nr_arena_item_set_mask(v->arenaitem, NULL);
810 }
811 if (!ref) {
812 item->display = v->next;
813 } else {
814 ref->next = v->next;
815 }
816 nr_arena_item_unparent(v->arenaitem);
817 nr_arena_item_unref(v->arenaitem);
818 g_free(v);
819 } else {
820 ref = v;
821 }
822 v = next;
823 }
824 }
826 // Adjusters
828 void
829 sp_item_adjust_pattern (SPItem *item, NR::Matrix const &postmul, bool set)
830 {
831 SPStyle *style = SP_OBJECT_STYLE (item);
833 if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
834 SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
835 if (SP_IS_PATTERN (server)) {
836 SPPattern *pattern = sp_pattern_clone_if_necessary (item, SP_PATTERN (server), "fill");
837 sp_pattern_transform_multiply (pattern, postmul, set);
838 }
839 }
841 if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
842 SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
843 if (SP_IS_PATTERN (server)) {
844 SPPattern *pattern = sp_pattern_clone_if_necessary (item, SP_PATTERN (server), "stroke");
845 sp_pattern_transform_multiply (pattern, postmul, set);
846 }
847 }
849 }
851 void
852 sp_item_adjust_gradient (SPItem *item, NR::Matrix const &postmul, bool set)
853 {
854 SPStyle *style = SP_OBJECT_STYLE (item);
856 if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
857 SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
858 if (SP_IS_GRADIENT (server)) {
860 /**
861 * \note Bbox units for a gradient are generally a bad idea because
862 * with them, you cannot preserve the relative position of the
863 * object and its gradient after rotation or skew. So now we
864 * convert them to userspace units which are easy to keep in sync
865 * just by adding the object's transform to gradientTransform.
866 * \todo FIXME: convert back to bbox units after transforming with
867 * the item, so as to preserve the original units.
868 */
869 SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), item, "fill");
871 sp_gradient_transform_multiply (gradient, postmul, set);
872 }
873 }
875 if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
876 SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item);
877 if (SP_IS_GRADIENT (server)) {
878 SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), item, "stroke");
879 sp_gradient_transform_multiply (gradient, postmul, set);
880 }
881 }
882 }
884 void
885 sp_item_adjust_stroke (SPItem *item, gdouble ex)
886 {
887 SPStyle *style = SP_OBJECT_STYLE (item);
889 if (style && style->stroke.type != SP_PAINT_TYPE_NONE && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) {
891 style->stroke_width.computed *= ex;
892 style->stroke_width.set = TRUE;
894 if (style->stroke_dash.n_dash != 0) {
895 int i;
896 for (i = 0; i < style->stroke_dash.n_dash; i++) {
897 style->stroke_dash.dash[i] *= ex;
898 }
899 style->stroke_dash.offset *= ex;
900 }
902 SP_OBJECT(item)->updateRepr();
903 }
904 }
906 /**
907 * Find out the inverse of previous transform of an item (from its repr)
908 */
909 NR::Matrix
910 sp_item_transform_repr (SPItem *item)
911 {
912 NR::Matrix t_old(NR::identity());
913 gchar const *t_attr = SP_OBJECT_REPR(item)->attribute("transform");
914 if (t_attr) {
915 NR::Matrix t;
916 if (sp_svg_transform_read(t_attr, &t)) {
917 t_old = t;
918 }
919 }
921 return t_old;
922 }
925 /**
926 * Recursively scale stroke width in \a item and its children by \a expansion.
927 */
928 void
929 sp_item_adjust_stroke_width_recursive(SPItem *item, double expansion)
930 {
931 sp_item_adjust_stroke (item, expansion);
933 for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) {
934 if (SP_IS_ITEM(o))
935 sp_item_adjust_stroke_width_recursive(SP_ITEM(o), expansion);
936 }
937 }
939 /**
940 * Recursively adjust rx and ry of rects.
941 */
942 void
943 sp_item_adjust_rects_recursive(SPItem *item, NR::Matrix advertized_transform)
944 {
945 if (SP_IS_RECT (item)) {
946 sp_rect_compensate_rxry (SP_RECT(item), advertized_transform);
947 }
949 for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) {
950 if (SP_IS_ITEM(o))
951 sp_item_adjust_rects_recursive(SP_ITEM(o), advertized_transform);
952 }
953 }
955 /**
956 * Recursively compensate pattern or gradient transform.
957 */
958 void
959 sp_item_adjust_paint_recursive (SPItem *item, NR::Matrix advertized_transform, NR::Matrix t_ancestors, bool is_pattern)
960 {
961 // A clone must not touch the style (it's that of its parent!) and has no children, so quit now
962 if (item && SP_IS_USE(item))
963 return;
965 // _Before_ full pattern/gradient transform: t_paint * t_item * t_ancestors
966 // _After_ full pattern/gradient transform: t_paint_new * t_item * t_ancestors * advertised_transform
967 // By equating these two expressions we get t_paint_new = t_paint * paint_delta, where:
968 NR::Matrix t_item = sp_item_transform_repr (item);
969 NR::Matrix paint_delta = t_item * t_ancestors * advertized_transform * t_ancestors.inverse() * t_item.inverse();
971 if (is_pattern)
972 sp_item_adjust_pattern (item, paint_delta);
973 else
974 sp_item_adjust_gradient (item, paint_delta);
976 // Within text, we do not fork gradients, and so must not recurse to avoid double compensation
977 if (item && SP_IS_TEXT(item))
978 return;
980 for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) {
981 if (SP_IS_ITEM(o)) {
982 // At the level of the transformed item, t_ancestors is identity;
983 // below it, it is the accmmulated chain of transforms from this level to the top level
984 sp_item_adjust_paint_recursive (SP_ITEM(o), advertized_transform, t_item * t_ancestors, is_pattern);
985 }
986 }
987 }
989 /**
990 * A temporary wrapper for the next function accepting the NRMatrix
991 * instead of NR::Matrix
992 */
993 void
994 sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NRMatrix const *transform, NR::Matrix const *adv)
995 {
996 if (transform == NULL)
997 sp_item_write_transform(item, repr, NR::identity(), adv);
998 else
999 sp_item_write_transform(item, repr, NR::Matrix (transform), adv);
1000 }
1002 /**
1003 * Set a new transform on an object.
1004 *
1005 * Compensate for stroke scaling and gradient/pattern fill transform, if
1006 * necessary. Call the object's set_transform method if transforms are
1007 * stored optimized. Send _transformed_signal. Invoke _write method so that
1008 * the repr is updated with the new transform.
1009 */
1010 void
1011 sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix const &transform, NR::Matrix const *adv)
1012 {
1013 g_return_if_fail(item != NULL);
1014 g_return_if_fail(SP_IS_ITEM(item));
1015 g_return_if_fail(repr != NULL);
1017 // calculate the relative transform, if not given by the adv attribute
1018 NR::Matrix advertized_transform;
1019 if (adv != NULL) {
1020 advertized_transform = *adv;
1021 } else {
1022 advertized_transform = sp_item_transform_repr (item).inverse() * transform;
1023 }
1025 // recursively compensate for stroke scaling, depending on user preference
1026 if (prefs_get_int_attribute("options.transform", "stroke", 1) == 0) {
1027 double const expansion = 1. / NR::expansion(advertized_transform);
1028 sp_item_adjust_stroke_width_recursive(item, expansion);
1029 }
1031 // recursively compensate rx/ry of a rect if requested
1032 if (prefs_get_int_attribute("options.transform", "rectcorners", 1) == 0) {
1033 sp_item_adjust_rects_recursive(item, advertized_transform);
1034 }
1036 // recursively compensate pattern fill if it's not to be transformed
1037 if (prefs_get_int_attribute("options.transform", "pattern", 1) == 0) {
1038 sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), true);
1039 }
1040 /// \todo FIXME: add the same else branch as for gradients below, to convert patterns to userSpaceOnUse as well
1041 /// recursively compensate gradient fill if it's not to be transformed
1042 if (prefs_get_int_attribute("options.transform", "gradient", 1) == 0) {
1043 sp_item_adjust_paint_recursive (item, advertized_transform.inverse(), NR::identity(), false);
1044 } else {
1045 // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
1046 // it here _before_ the new transform is set, so as to use the pre-transform bbox
1047 sp_item_adjust_paint_recursive (item, NR::identity(), NR::identity(), false);
1048 }
1050 // run the object's set_transform if transforms are stored optimized
1051 gint preserve = prefs_get_int_attribute("options.preservetransform", "value", 0);
1052 NR::Matrix transform_attr (transform);
1053 if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform && !preserve) {
1054 transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform(item, transform);
1055 }
1056 sp_item_set_item_transform(item, transform_attr);
1058 // Note: updateRepr comes before emitting the transformed signal since
1059 // it causes clone SPUse's copy of the original object to brought up to
1060 // date with the original. Otherwise, sp_use_bbox returns incorrect
1061 // values if called in code handling the transformed signal.
1062 SP_OBJECT(item)->updateRepr();
1064 // send the relative transform with a _transformed_signal
1065 item->_transformed_signal.emit(&advertized_transform, item);
1066 }
1068 gint
1069 sp_item_event(SPItem *item, SPEvent *event)
1070 {
1071 g_return_val_if_fail(item != NULL, FALSE);
1072 g_return_val_if_fail(SP_IS_ITEM(item), FALSE);
1073 g_return_val_if_fail(event != NULL, FALSE);
1075 if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->event)
1076 return ((SPItemClass *) G_OBJECT_GET_CLASS(item))->event(item, event);
1078 return FALSE;
1079 }
1081 /**
1082 * Sets item private transform (not propagated to repr), without compensating stroke widths,
1083 * gradients, patterns as sp_item_write_transform does.
1084 */
1085 void
1086 sp_item_set_item_transform(SPItem *item, NR::Matrix const &transform)
1087 {
1088 g_return_if_fail(item != NULL);
1089 g_return_if_fail(SP_IS_ITEM(item));
1091 if (!matrix_equalp(transform, item->transform, NR_EPSILON)) {
1092 item->transform = transform;
1093 /* The SP_OBJECT_USER_MODIFIED_FLAG_B is used to mark the fact that it's only a
1094 transformation. It's apparently not used anywhere else. */
1095 item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_USER_MODIFIED_FLAG_B);
1096 sp_item_rm_unsatisfied_cns(*item);
1097 }
1098 }
1101 /**
1102 * \pre \a ancestor really is an ancestor (\>=) of \a object, or NULL.
1103 * ("Ancestor (\>=)" here includes as far as \a object itself.)
1104 */
1105 NR::Matrix
1106 i2anc_affine(SPObject const *object, SPObject const *const ancestor) {
1107 NR::Matrix ret(NR::identity());
1108 g_return_val_if_fail(object != NULL, ret);
1110 /* stop at first non-renderable ancestor */
1111 while ( object != ancestor && SP_IS_ITEM(object) ) {
1112 if (SP_IS_ROOT(object)) {
1113 ret *= SP_ROOT(object)->c2p;
1114 }
1115 ret *= SP_ITEM(object)->transform;
1116 object = SP_OBJECT_PARENT(object);
1117 }
1118 return ret;
1119 }
1121 NR::Matrix
1122 i2i_affine(SPObject const *src, SPObject const *dest) {
1123 g_return_val_if_fail(src != NULL && dest != NULL, NR::identity());
1124 SPObject const *ancestor = src->nearestCommonAncestor(dest);
1125 return i2anc_affine(src, ancestor) / i2anc_affine(dest, ancestor);
1126 }
1128 NR::Matrix SPItem::getRelativeTransform(SPObject const *dest) const {
1129 return i2i_affine(this, dest);
1130 }
1132 /**
1133 * Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
1134 * \pre (item != NULL) and SP_IS_ITEM(item).
1135 */
1136 NR::Matrix sp_item_i2doc_affine(SPItem const *item)
1137 {
1138 return i2anc_affine(item, NULL);
1139 }
1141 /**
1142 * Returns the accumulated transformation of the item and all its ancestors, but excluding root's viewport.
1143 * Used in path operations mostly.
1144 * \pre (item != NULL) and SP_IS_ITEM(item).
1145 */
1146 NR::Matrix sp_item_i2root_affine(SPItem const *item)
1147 {
1148 g_assert(item != NULL);
1149 g_assert(SP_IS_ITEM(item));
1151 NR::Matrix ret(NR::identity());
1152 g_assert(ret.test_identity());
1153 while ( NULL != SP_OBJECT_PARENT(item) ) {
1154 ret *= item->transform;
1155 item = SP_ITEM(SP_OBJECT_PARENT(item));
1156 }
1157 g_assert(SP_IS_ROOT(item));
1159 ret *= item->transform;
1161 return ret;
1162 }
1164 /* fixme: This is EVIL!!! */
1166 NR::Matrix sp_item_i2d_affine(SPItem const *item)
1167 {
1168 g_assert(item != NULL);
1169 g_assert(SP_IS_ITEM(item));
1171 NR::Matrix const ret( sp_item_i2doc_affine(item)
1172 * NR::scale(1, -1)
1173 * NR::translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item))) );
1174 return ret;
1175 }
1177 // same as i2d but with i2root instead of i2doc
1178 NR::Matrix sp_item_i2r_affine(SPItem const *item)
1179 {
1180 g_assert(item != NULL);
1181 g_assert(SP_IS_ITEM(item));
1183 NR::Matrix const ret( sp_item_i2root_affine(item)
1184 * NR::scale(1, -1)
1185 * NR::translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item))) );
1186 return ret;
1187 }
1189 /**
1190 * Converts a matrix \a m into the desktop coords of the \a item.
1191 * Will become a noop when we eliminate the coordinate flipping.
1192 */
1193 NR::Matrix matrix_to_desktop(NR::Matrix const m, SPItem const *item)
1194 {
1195 NR::Matrix const ret(m
1196 * NR::translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item)))
1197 * NR::scale(1, -1));
1198 return ret;
1199 }
1201 /**
1202 * Converts a matrix \a m from the desktop coords of the \a item.
1203 * Will become a noop when we eliminate the coordinate flipping.
1204 */
1205 NR::Matrix matrix_from_desktop(NR::Matrix const m, SPItem const *item)
1206 {
1207 NR::Matrix const ret(NR::scale(1, -1)
1208 * NR::translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item)))
1209 * m);
1210 return ret;
1211 }
1213 void sp_item_set_i2d_affine(SPItem *item, NR::Matrix const &i2dt)
1214 {
1215 g_return_if_fail( item != NULL );
1216 g_return_if_fail( SP_IS_ITEM(item) );
1218 NR::Matrix dt2p; /* desktop to item parent transform */
1219 if (SP_OBJECT_PARENT(item)) {
1220 dt2p = sp_item_i2d_affine((SPItem *) SP_OBJECT_PARENT(item)).inverse();
1221 } else {
1222 dt2p = ( NR::translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item)))
1223 * NR::scale(1, -1) );
1224 }
1226 NR::Matrix const i2p( i2dt * dt2p );
1227 sp_item_set_item_transform(item, i2p);
1228 }
1231 NR::Matrix
1232 sp_item_dt2i_affine(SPItem const *item)
1233 {
1234 /* fixme: Implement the right way (Lauris) */
1235 return sp_item_i2d_affine(item).inverse();
1236 }
1238 /* Item views */
1240 static SPItemView *
1241 sp_item_view_new_prepend(SPItemView *list, SPItem *item, unsigned flags, unsigned key, NRArenaItem *arenaitem)
1242 {
1243 SPItemView *new_view;
1245 g_assert(item != NULL);
1246 g_assert(SP_IS_ITEM(item));
1247 g_assert(arenaitem != NULL);
1248 g_assert(NR_IS_ARENA_ITEM(arenaitem));
1250 new_view = g_new(SPItemView, 1);
1252 new_view->next = list;
1253 new_view->flags = flags;
1254 new_view->key = key;
1255 new_view->arenaitem = nr_arena_item_ref(arenaitem);
1257 return new_view;
1258 }
1260 static SPItemView *
1261 sp_item_view_list_remove(SPItemView *list, SPItemView *view)
1262 {
1263 if (view == list) {
1264 list = list->next;
1265 } else {
1266 SPItemView *prev;
1267 prev = list;
1268 while (prev->next != view) prev = prev->next;
1269 prev->next = view->next;
1270 }
1272 nr_arena_item_unref(view->arenaitem);
1273 g_free(view);
1275 return list;
1276 }
1278 /**
1279 * Return the arenaitem corresponding to the given item in the display
1280 * with the given key
1281 */
1282 NRArenaItem *
1283 sp_item_get_arenaitem(SPItem *item, unsigned key)
1284 {
1285 for ( SPItemView *iv = item->display ; iv ; iv = iv->next ) {
1286 if ( iv->key == key ) {
1287 return iv->arenaitem;
1288 }
1289 }
1291 return NULL;
1292 }
1294 int
1295 sp_item_repr_compare_position(SPItem *first, SPItem *second)
1296 {
1297 return sp_repr_compare_position(SP_OBJECT_REPR(first),
1298 SP_OBJECT_REPR(second));
1299 }
1301 SPItem *
1302 sp_item_first_item_child (SPObject *obj)
1303 {
1304 for ( SPObject *iter = sp_object_first_child(obj) ; iter ; iter = SP_OBJECT_NEXT(iter)) {
1305 if (SP_IS_ITEM (iter))
1306 return SP_ITEM (iter);
1307 }
1308 return NULL;
1309 }
1312 /*
1313 Local Variables:
1314 mode:c++
1315 c-file-style:"stroustrup"
1316 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1317 indent-tabs-mode:nil
1318 fill-column:99
1319 End:
1320 */
1321 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :