From ea6e0e4d2cd55a2b851a8504a68afff34fc6a683 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Mon, 6 Aug 2007 00:07:25 +0000 Subject: Store a global list of existing perspectives; for each perspective hold a list of associated boxes; explicitly pass perspectives as arguments when creating PLs (bzr r3380) --- src/desktop.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/desktop.cpp') diff --git a/src/desktop.cpp b/src/desktop.cpp index e785aab6d..6314621c1 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -132,6 +132,7 @@ SPDesktop::SPDesktop() : window_state(0), interaction_disabled_counter( 0 ), waiting_cursor( false ), + perspectives (NULL), guides_active( false ), gr_item( 0 ), gr_point_type( 0 ), @@ -309,6 +310,21 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas) layer_manager = new Inkscape::LayerManager( this ); grids_visible = true; + + /* Create initial perspective, append it to the list of existing perspectives + and make it the current perspective */ + Box3D::Perspective3D *initial_persp = new Box3D::Perspective3D ( + // VP in x-direction + Box3D::VanishingPoint( NR::Point(-50.0, 600.0), + NR::Point( -1.0, 0.0), Box3D::VP_FINITE), + // VP in y-direction + Box3D::VanishingPoint( NR::Point(500.0,1000.0), + NR::Point( 0.0, 1.0), Box3D::VP_INFINITE), + // VP in z-direction + Box3D::VanishingPoint( NR::Point(700.0, 600.0), + NR::Point(sqrt(3.0),1.0), Box3D::VP_FINITE)); + this->add_perspective (initial_persp); + Box3D::Perspective3D::current_perspective = (Box3D::Perspective3D *) perspectives->data; } @@ -352,6 +368,11 @@ void SPDesktop::destroy() g_list_free (zooms_past); g_list_free (zooms_future); + + for (GSList *p = this->perspectives; p != NULL; p = p->next) { + delete ((Box3D::Perspective3D *) p->data); + } + g_slist_free (perspectives); } SPDesktop::~SPDesktop() {} @@ -693,6 +714,30 @@ void SPDesktop::set_display_area(NR::Rect const &a, NR::Coord b, bool log) set_display_area(a.min()[NR::X], a.min()[NR::Y], a.max()[NR::X], a.max()[NR::Y], b, log); } +/** + * Add a perspective to the desktop if it doesn't exist yet + */ +void +SPDesktop::add_perspective (Box3D::Perspective3D * const persp) +{ + // FIXME: Should we handle the case that the perspectives have equal VPs but are not identical? + if (persp == NULL || g_slist_find (this->perspectives, persp)) return; + this->perspectives = g_slist_prepend (this->perspectives, persp); + persp->desktop = this; +} + +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); +} + /** * Return viewbox dimensions. */ -- cgit v1.2.3