~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/removeoverlap/removeoverlap.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Ted Gould, Kees Cook
  • Date: 2009-06-24 14:00:43 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624140043-07stp20mry48hqup
Tags: 0.47~pre0-0ubuntu1
* New upstream release

[ Ted Gould ]
* debian/control: Adding libgsl0 and removing version specifics on boost

[ Kees Cook ]
* debian/watch: updated to run uupdate and mangle pre-release versions.
* Dropped patches that have been taken upstream:
  - 01_mips
  - 02-poppler-0.8.3
  - 03-chinese-inkscape
  - 05_fix_latex_patch
  - 06_gcc-4.4
  - 07_cdr2svg
  - 08_skip-bad-utf-on-pdf-import
  - 09_gtk-clist
  - 10_belarussian
  - 11_libpng
  - 12_desktop
  - 13_slider
  - 100_svg_import_improvements
  - 102_sp_pattern_painter_free
  - 103_bitmap_type_print

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
namespace {
22
22
        struct Record {
23
23
                SPItem *item;
24
 
                NR::Point midpoint;
 
24
                Geom::Point midpoint;
25
25
                Rectangle *vspc_rect;
26
26
 
27
27
                Record() {}
28
 
                Record(SPItem *i, NR::Point m, Rectangle *r)
 
28
                Record(SPItem *i, Geom::Point m, Rectangle *r)
29
29
                : item(i), midpoint(m), vspc_rect(r) {}
30
30
        };
31
31
}
42
42
        std::vector<Record> records;
43
43
        std::vector<Rectangle *> rs;
44
44
 
45
 
        NR::Point const gap(xGap, yGap);
 
45
        Geom::Point const gap(xGap, yGap);
46
46
        for (std::list<SPItem *>::iterator it(selected.begin());
47
47
                it != selected.end();
48
48
                ++it)
49
49
        {
50
 
                using NR::X; using NR::Y;
51
 
                NR::Maybe<NR::Rect> item_box(sp_item_bbox_desktop(*it));
 
50
                using Geom::X; using Geom::Y;
 
51
                Geom::OptRect item_box(sp_item_bbox_desktop(*it));
52
52
                if (item_box) {
53
 
                        NR::Point min(item_box->min() - .5*gap);
54
 
                        NR::Point max(item_box->max() + .5*gap);
 
53
                        Geom::Point min(item_box->min() - .5*gap);
 
54
                        Geom::Point max(item_box->max() + .5*gap);
 
55
                        // A negative gap is allowed, but will lead to problems when the gap is larger than
 
56
                        // the bounding box (in either X or Y direction, or both); min will have become max
 
57
                        // now, which cannot be handled by Rectangle() which is called below. And how will
 
58
                        // removeRectangleOverlap handle such a case?
 
59
                        // That's why we will enforce some boundaries on min and max here:
 
60
                        if (max[X] < min[X]) {
 
61
                                min[X] = max[X] = (min[X] + max[X])/2;
 
62
                        }
 
63
                        if (max[Y] < min[Y]) {
 
64
                                min[Y] = max[Y] = (min[Y] + max[Y])/2;
 
65
                        }
55
66
                        Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]);
56
67
                        records.push_back(Record(*it, item_box->midpoint(), vspc_rect));
57
68
                        rs.push_back(vspc_rect);
64
75
              it != records.end();
65
76
              ++it )
66
77
        {
67
 
                NR::Point const curr = it->midpoint;
68
 
                NR::Point const dest(it->vspc_rect->getCentreX(),
 
78
                Geom::Point const curr = it->midpoint;
 
79
                Geom::Point const dest(it->vspc_rect->getCentreX(),
69
80
                                     it->vspc_rect->getCentreY());
70
 
                sp_item_move_rel(it->item, NR::translate(dest - curr));
 
81
                sp_item_move_rel(it->item, Geom::Translate(dest - curr));
71
82
                delete it->vspc_rect;
72
83
        }
73
84
}