diff options
Diffstat (limited to 'src/perspective3d.cpp')
| -rw-r--r-- | src/perspective3d.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/src/perspective3d.cpp b/src/perspective3d.cpp index e5b1f6212..213744937 100644 --- a/src/perspective3d.cpp +++ b/src/perspective3d.cpp @@ -144,12 +144,18 @@ Perspective3D::~Perspective3D () } bool -Perspective3D::operator==(Perspective3D const &other) +Perspective3D::operator==(Perspective3D const &other) const { // Two perspectives are equal iff their vanishing points coincide and have identical states return (*vp_x == *other.vp_x && *vp_y == *other.vp_y && *vp_z == *other.vp_z); } +bool +Perspective3D::has_vanishing_point (VanishingPoint *vp) +{ + return (vp == vp_x || vp == vp_y || vp == vp_z); +} + VanishingPoint * Perspective3D::get_vanishing_point (Box3D::Axis const dir) { @@ -249,11 +255,35 @@ Perspective3D::remove_box (const SP3DBox *box) } bool -Perspective3D::has_box (const SP3DBox *box) +Perspective3D::has_box (const SP3DBox *box) const { return (g_slist_find (this->boxes, box) != NULL); } +bool +Perspective3D::all_boxes_occur_in_list (GSList *boxes_to_do) +{ + for (GSList *i = boxes; i != NULL; i = i->next) { + if (!g_slist_find (boxes_to_do, i->data)) { + return false; + } + } + return true; +} + +GSList * +Perspective3D::boxes_occurring_in_list (GSList * list_of_boxes) +{ + GSList * result = NULL; + for (GSList *i = list_of_boxes; i != NULL; i = i->next) { + if (this->has_box (SP_3DBOX (i->data))) { + result = g_slist_prepend (result, i->data); + } + } + // we reverse so as to retain the same order as in list_of_boxes + return g_slist_reverse (result); +} + /** * Update the shape of a box after a handle was dragged or a VP was changed, according to the stored ratios. */ @@ -300,6 +330,20 @@ Perspective3D::update_box_reprs () } } +// swallow the list of boxes from the other perspective and delete it +void +Perspective3D::absorb (Perspective3D *other) +{ + g_return_if_fail (*this == *other); + + // FIXME: Is copying necessary? Is other->boxes invalidated when other is deleted below? + this->boxes = g_slist_concat (this->boxes, g_slist_copy (other->boxes)); + + // Should we delete the other perspective here or at the place from where absorb() is called? + delete other; + other = NULL; +} + // FIXME: We get compiler errors when we try to move the code from sp_3dbox_get_perspective_string to this function /*** gchar * |
