summaryrefslogtreecommitdiffstats
path: root/src/desktop.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2007-08-06 06:51:01 +0000
committercilix42 <cilix42@users.sourceforge.net>2007-08-06 06:51:01 +0000
commit090f7cc9a4990377510d794b7a9556d4ce4cec64 (patch)
treeb86779c1a0ad075e0e4bfad19e53c36c9dca7390 /src/desktop.cpp
parentPreparatory stuff to combine VPs in draggers (diff)
downloadinkscape-090f7cc9a4990377510d794b7a9556d4ce4cec64.tar.gz
inkscape-090f7cc9a4990377510d794b7a9556d4ce4cec64.zip
Write/read perspectives to/from SVG; store ratios of the distances from corners to VPs (preparation for dragging)
(bzr r3388)
Diffstat (limited to 'src/desktop.cpp')
-rw-r--r--src/desktop.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 6314621c1..f58864955 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -720,7 +720,13 @@ void SPDesktop::set_display_area(NR::Rect const &a, NR::Coord b, bool log)
void
SPDesktop::add_perspective (Box3D::Perspective3D * const persp)
{
+ // check that the perspective is not yet linked to another desktop
+ if (persp->desktop != NULL) {
+ g_assert (persp->desktop == this);
+ }
+
// FIXME: Should we handle the case that the perspectives have equal VPs but are not identical?
+ // If so, we need to take care of relinking the boxes, etc.
if (persp == NULL || g_slist_find (this->perspectives, persp)) return;
this->perspectives = g_slist_prepend (this->perspectives, persp);
persp->desktop = this;
@@ -729,15 +735,24 @@ SPDesktop::add_perspective (Box3D::Perspective3D * const persp)
void SPDesktop::remove_perspective (Box3D::Perspective3D * const persp)
{
if (persp == NULL) return;
-
if (!g_slist_find (this->perspectives, persp)) {
g_warning ("Could not find perspective in current desktop. Not removed.\n");
return;
}
-
this->perspectives = g_slist_remove (this->perspectives, persp);
}
+// find an existing perspective whose VPs are equal to those of persp
+Box3D::Perspective3D * SPDesktop::find_perspective (Box3D::Perspective3D * const persp)
+{
+ for (GSList *p = this->perspectives; p != NULL; p = p->next) {
+ if (*((Box3D::Perspective3D *) p->data) == *persp) {
+ return ((Box3D::Perspective3D *) p->data);
+ }
+ }
+ return NULL; // perspective was not found
+}
+
/**
* Return viewbox dimensions.
*/