diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2009-12-26 00:32:25 +0000 |
|---|---|---|
| committer | Maximilian Albert <maximilian.albert@gmail.com> | 2009-12-26 00:32:25 +0000 |
| commit | bcef1f768feeb937aa0e86842871f0b479ec284a (patch) | |
| tree | b366d30c7f66943631ea5db34565dd4bfa1648b9 /src/selection.cpp | |
| parent | Refactoring of 3D box tool, mainly to avoid unnecessary creation of perspecti... (diff) | |
| download | inkscape-bcef1f768feeb937aa0e86842871f0b479ec284a.tar.gz inkscape-bcef1f768feeb937aa0e86842871f0b479ec284a.zip | |
Major simplification of 3D box code.
(bzr r8911)
Diffstat (limited to 'src/selection.cpp')
| -rw-r--r-- | src/selection.cpp | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/src/selection.cpp b/src/selection.cpp index ed8a9d57b..828a96968 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -162,24 +162,12 @@ void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) _emitChanged(persist_selection_context); } -void Selection::add_box_perspective(SPBox3D *box) { - Persp3D *persp = box3d_get_perspective(box); - std::map<Persp3D *, unsigned int>::iterator p = _persps.find(persp); - if (p != _persps.end()) { - (*p).second++; - } else { - _persps[persp] = 1; - } -} - void Selection::add_3D_boxes_recursively(SPObject *obj) { std::list<SPBox3D *> boxes = box3d_extract_boxes(obj); for (std::list<SPBox3D *>::iterator i = boxes.begin(); i != boxes.end(); ++i) { SPBox3D *box = *i; - box3d_add_to_selection(box); _3dboxes.push_back(box); - add_box_perspective(box); } } @@ -220,33 +208,17 @@ void Selection::remove(SPObject *obj) { _emitChanged(); } -void Selection::remove_box_perspective(SPBox3D *box) { - Persp3D *persp = box3d_get_perspective(box); - std::map<Persp3D *, unsigned int>::iterator p = _persps.find(persp); - if (p == _persps.end()) { - //g_print ("Warning! Trying to remove unselected perspective from selection!\n"); - return; - } - if ((*p).second > 1) { - _persps[persp]--; - } else { - _persps.erase(p); - } -} - void Selection::remove_3D_boxes_recursively(SPObject *obj) { std::list<SPBox3D *> boxes = box3d_extract_boxes(obj); for (std::list<SPBox3D *>::iterator i = boxes.begin(); i != boxes.end(); ++i) { SPBox3D *box = *i; - box3d_remove_from_selection(box); std::list<SPBox3D *>::iterator b = std::find(_3dboxes.begin(), _3dboxes.end(), box); if (b == _3dboxes.end()) { g_print ("Warning! Trying to remove unselected box from selection.\n"); return; } _3dboxes.erase(b); - remove_box_perspective(box); } } @@ -344,14 +316,27 @@ GSList const *Selection::reprList() { std::list<Persp3D *> const Selection::perspList() { std::list<Persp3D *> pl; - for (std::map<Persp3D *, unsigned int>::iterator p = _persps.begin(); p != _persps.end(); ++p) { - pl.push_back((*p).first); + for (std::list<SPBox3D *>::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { + Persp3D *persp = box3d_get_perspective(*i); + if (std::find(pl.begin(), pl.end(), persp) == pl.end()) + pl.push_back(persp); } return pl; } -std::list<SPBox3D *> const Selection::box3DList() { - return _3dboxes; +std::list<SPBox3D *> const Selection::box3DList(Persp3D *persp) { + std::list<SPBox3D *> boxes; + if (persp) { + SPBox3D *box; + for (std::list<SPBox3D *>::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { + box = *i; + if (persp == box3d_get_perspective(box)) + boxes.push_back(box); + } + } else { + boxes = _3dboxes; + } + return boxes; } SPObject *Selection::single() { |
