From: cilix42 Date: Mon, 6 Aug 2007 07:10:50 +0000 (+0000) Subject: Convenience for debugging X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1423c02f5f579ff35d29755089334211f6a0645d;p=inkscape.git Convenience for debugging --- diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index c82728c97..749087593 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -429,6 +429,11 @@ static gint sp_3dbox_context_root_handler(SPEventContext *event_context, GdkEven ret = TRUE; break; + case GDK_I: + Box3D::Perspective3D::print_debugging_info(); + ret = true; + break; + case GDK_x: case GDK_X: if (MOD__ALT_ONLY) { diff --git a/src/box3d.cpp b/src/box3d.cpp index 44b2c9bbe..fbf7fb15d 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -42,6 +42,8 @@ static gchar * sp_3dbox_get_perspective_string (SP3DBox *box); static SPGroupClass *parent_class; +static gint counter = 0; + GType sp_3dbox_get_type(void) { @@ -99,6 +101,8 @@ sp_3dbox_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr SP3DBox *box = SP_3DBOX (object); + box->my_counter = counter++; + if (repr->attribute ("inkscape:perspective") == NULL) { // we are creating a new box; link it to the current perspective Box3D::Perspective3D::current_perspective->add_box (box); diff --git a/src/box3d.h b/src/box3d.h index 1b40afa76..d72c6eb9c 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -42,6 +42,8 @@ struct SP3DBox : public SPGroup { double ratio_x; double ratio_y; double ratio_z; + + gint my_counter; // for testing only }; struct SP3DBoxClass { diff --git a/src/perspective3d.cpp b/src/perspective3d.cpp index d4990fd39..8188a1ed2 100644 --- a/src/perspective3d.cpp +++ b/src/perspective3d.cpp @@ -23,6 +23,8 @@ namespace Box3D { +gint Perspective3D::counter = 0; + Perspective3D * get_persp_of_box (const SP3DBox *box) { @@ -68,6 +70,8 @@ Perspective3D::Perspective3D (VanishingPoint const &pt_x, VanishingPoint const & vp_x = new VanishingPoint (pt_x); vp_y = new VanishingPoint (pt_y); vp_z = new VanishingPoint (pt_z); + + my_counter = Perspective3D::counter++; } Perspective3D::Perspective3D (Perspective3D &other) @@ -77,6 +81,8 @@ Perspective3D::Perspective3D (Perspective3D &other) vp_x = new VanishingPoint (*other.vp_x); vp_y = new VanishingPoint (*other.vp_y); vp_z = new VanishingPoint (*other.vp_z); + + my_counter = Perspective3D::counter++; } @@ -248,6 +254,45 @@ Perspective3D::svg_string () } ***/ +void +Perspective3D::print_debugging_info () +{ + g_print ("====================================================\n"); + SPDesktop *desktop = inkscape_active_desktop(); + for (GSList *i = desktop->perspectives; i != NULL; i = i->next) { + Perspective3D *persp = (Perspective3D *) i->data; + g_print ("Perspective %d:\n", persp->my_counter); + //g_print ("Perspective:\n"); + + VanishingPoint * vp = persp->get_vanishing_point(Box3D::X); + g_print (" VP X: (%f,%f) ", (*vp)[NR::X], (*vp)[NR::Y]); + g_print ((vp->is_finite()) ? "(finite)\n" : "(infinite)\n"); + + vp = persp->get_vanishing_point(Box3D::Y); + g_print (" VP Y: (%f,%f) ", (*vp)[NR::X], (*vp)[NR::Y]); + g_print ((vp->is_finite()) ? "(finite)\n" : "(infinite)\n"); + + vp = persp->get_vanishing_point(Box3D::Z); + g_print (" VP Z: (%f,%f) ", (*vp)[NR::X], (*vp)[NR::Y]); + g_print ((vp->is_finite()) ? "(finite)\n" : "(infinite)\n"); + + g_print ("\nBoxes: "); + if (persp->boxes == NULL) { + g_print ("none"); + } else { + GSList *j; + for (j = persp->boxes; j != NULL; j = j->next) { + if (j->next == NULL) break; + g_print ("%d, ", SP_3DBOX (j->data)->my_counter); + } + if (j != NULL) { + g_print ("%d", SP_3DBOX (j->data)->my_counter); + } + } + } + g_print ("\n====================================================\n"); +} + } // namespace Box3D /* diff --git a/src/perspective3d.h b/src/perspective3d.h index 2cffd3419..4211c7b3b 100644 --- a/src/perspective3d.h +++ b/src/perspective3d.h @@ -38,6 +38,10 @@ public: void reshape_boxes (Box3D::Axis axes); void update_box_reprs (); + static gint counter; // for testing only + gint my_counter; // for testing only + + static void print_debugging_info(); static Perspective3D * current_perspective; // should current_perspective be moved to desktop.h? SPDesktop * desktop; // we need to store the perspective's desktop to be able to access it in the destructor