summaryrefslogtreecommitdiffstats
path: root/src/perspective3d.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2007-08-06 07:49:54 +0000
committercilix42 <cilix42@users.sourceforge.net>2007-08-06 07:49:54 +0000
commit2e55ba0bc498a1f2b8d5ed55c7b877da7a85c785 (patch)
treed0524ee0e37df3f2dd21004d44b12c06f7793e7c /src/perspective3d.cpp
parentFirst stage of draggable vanishing points (no snapping/unsnapping yet) (diff)
downloadinkscape-2e55ba0bc498a1f2b8d5ed55c7b877da7a85c785.tar.gz
inkscape-2e55ba0bc498a1f2b8d5ed55c7b877da7a85c785.zip
(Un-)Snapping of VPs by Shift-dragging; this makes it possible to separate perspectives and thus create new ones interactively
(bzr r3392)
Diffstat (limited to 'src/perspective3d.cpp')
-rw-r--r--src/perspective3d.cpp48
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 *