Code

Enable 3D box toolbar
[inkscape.git] / src / persp3d.cpp
1 #define __PERSP3D_C__
3 /*
4  * Class modelling a 3D perspective as an SPObject
5  *
6  * Authors:
7  *   Maximilian Albert <Anhalter42@gmx.de>
8  *
9  * Copyright (C) 2007 authors
10  *
11  * Released under GNU GPL, read the file 'COPYING' for more information
12  */
14 #include "persp3d.h"
15 #include "perspective-line.h"
16 #include "attributes.h"
17 #include "document-private.h"
18 #include "vanishing-point.h"
19 #include "box3d-context.h"
20 #include "box3d.h"
21 #include "xml/document.h"
22 #include "xml/node-event-vector.h"
23 #include "desktop-handles.h"
24 #include <glibmm/i18n.h>
26 static void persp3d_class_init(Persp3DClass *klass);
27 static void persp3d_init(Persp3D *stop);
29 static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
30 static void persp3d_release(SPObject *object);
31 static void persp3d_set(SPObject *object, unsigned key, gchar const *value);
32 static void persp3d_update(SPObject *object, SPCtx *ctx, guint flags);
33 static Inkscape::XML::Node *persp3d_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
35 static void persp3d_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
37 static SPObjectClass *persp3d_parent_class;
39 static int global_counter = 0;
41 /**
42  * Registers Persp3d class and returns its type.
43  */
44 GType
45 persp3d_get_type()
46 {
47     static GType type = 0;
48     if (!type) {
49         GTypeInfo info = {
50             sizeof(Persp3DClass),
51             NULL, NULL,
52             (GClassInitFunc) persp3d_class_init,
53             NULL, NULL,
54             sizeof(Persp3D),
55             16,
56             (GInstanceInitFunc) persp3d_init,
57             NULL,   /* value_table */
58         };
59         type = g_type_register_static(SP_TYPE_OBJECT, "Persp3D", &info, (GTypeFlags)0);
60     }
61     return type;
62 }
64 static Inkscape::XML::NodeEventVector const persp3d_repr_events = {
65     NULL, /* child_added */
66     NULL, /* child_removed */
67     persp3d_on_repr_attr_changed,
68     NULL, /* content_changed */
69     NULL  /* order_changed */
70 };
72 /**
73  * Callback to initialize Persp3D vtable.
74  */
75 static void persp3d_class_init(Persp3DClass *klass)
76 {
77     SPObjectClass *sp_object_class = (SPObjectClass *) klass;
79     persp3d_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
81     sp_object_class->build = persp3d_build;
82     sp_object_class->release = persp3d_release;
83     sp_object_class->set = persp3d_set;
84     sp_object_class->update = persp3d_update;
85     sp_object_class->write = persp3d_write;
86 }
88 /**
89  * Callback to initialize Persp3D object.
90  */
91 static void
92 persp3d_init(Persp3D *persp)
93 {
94     persp->tmat = Proj::TransfMat3x4 ();
96     //persp->boxes = NULL;
97     persp->boxes_transformed.clear();
98     persp->document = NULL;
100     persp->my_counter = global_counter++;
103 /**
104  * Virtual build: set persp3d attributes from its associated XML node.
105  */
106 static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
108     if (((SPObjectClass *) persp3d_parent_class)->build)
109         (* ((SPObjectClass *) persp3d_parent_class)->build)(object, document, repr);
111     /* calls sp_object_set for the respective attributes */
112     // The transformation matrix is updated according to the values we read for the VPs
113     sp_object_read_attr(object, "inkscape:vp_x");
114     sp_object_read_attr(object, "inkscape:vp_y");
115     sp_object_read_attr(object, "inkscape:vp_z");
116     sp_object_read_attr(object, "inkscape:persp3d-origin");
118     if (repr) {
119         repr->addListener (&persp3d_repr_events, object);
120     }
122     // FIXME: What precisely does this do and is it necessary for perspectives?
123     /* Register ourselves */
124     //sp_document_add_resource(document, "persp3d", object);
127 /**
128  * Virtual release of Persp3D members before destruction.
129  */
130 static void persp3d_release(SPObject *object) {
131     //Persp3D *persp = (Persp3D *) object;
133     SP_OBJECT_REPR(object)->removeListenerByData(object);
135     // FIXME: What precisely does this do and is it necessary for perspectives?
136     /**
137     if (SP_OBJECT_DOCUMENT(object)) {
138         // Unregister ourselves
139         sp_document_remove_resource(SP_OBJECT_DOCUMENT(object), "persp3d", SP_OBJECT(object));
140     }
141     **/
145 /**
146  * Virtual set: set attribute to value.
147  */
148 // FIXME: Currently we only read the finite positions of vanishing points;
149 //        should we move VPs into their own repr (as it's done for SPStop, e.g.)?
150 static void
151 persp3d_set(SPObject *object, unsigned key, gchar const *value)
153     Persp3D *persp = SP_PERSP3D (object);
155     switch (key) {
156         case SP_ATTR_INKSCAPE_PERSP3D_VP_X: {
157             if (value) {
158                 Proj::Pt2 new_image (value);
159                 persp3d_update_with_point (persp, Proj::X, new_image);
160             }
161             break;
162         }
163         case SP_ATTR_INKSCAPE_PERSP3D_VP_Y: {
164             if (value) {
165                 Proj::Pt2 new_image (value);
166                 persp3d_update_with_point (persp, Proj::Y, new_image);
167                 break;
168             }
169         }
170         case SP_ATTR_INKSCAPE_PERSP3D_VP_Z: {
171             if (value) {
172                 Proj::Pt2 new_image (value);
173                 persp3d_update_with_point (persp, Proj::Z, new_image);
174                 break;
175             }
176         }
177         case SP_ATTR_INKSCAPE_PERSP3D_ORIGIN: {
178             if (value) {
179                 Proj::Pt2 new_image (value);
180                 persp3d_update_with_point (persp, Proj::W, new_image);
181                 break;
182             }
183         }
184         default: {
185             if (((SPObjectClass *) persp3d_parent_class)->set)
186                 (* ((SPObjectClass *) persp3d_parent_class)->set)(object, key, value);
187             break;
188         }
189     }
191     // FIXME: Is this the right place for resetting the draggers?
192     SPEventContext *ec = inkscape_active_event_context();
193     if (SP_IS_BOX3D_CONTEXT(ec)) {
194         Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
195         bc->_vpdrag->updateDraggers();
196         bc->_vpdrag->updateLines();
197         bc->_vpdrag->updateBoxHandles();
198         bc->_vpdrag->updateBoxReprs();
199     }
202 static void
203 persp3d_update(SPObject *object, SPCtx *ctx, guint flags)
205     if (flags & SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG) {
207         /* TODO: Should we update anything here? */
209     }
211     if (((SPObjectClass *) persp3d_parent_class)->update)
212         ((SPObjectClass *) persp3d_parent_class)->update(object, ctx, flags);
215 Persp3D *
216 persp3d_create_xml_element (SPDocument *document, Persp3D *dup) {// if dup is given, copy the attributes over
217     SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
218     Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
219     Inkscape::XML::Node *repr;
220     if (dup) {
221         repr = SP_OBJECT_REPR(dup)->duplicate (xml_doc);
222     } else {
223         repr = xml_doc->createElement("inkscape:perspective");
224         repr->setAttribute("sodipodi:type", "inkscape:persp3d");
225     }
227     /* Append the new persp3d to defs */
228     SP_OBJECT_REPR(defs)->addChild(repr, NULL);
229     Inkscape::GC::release(repr);
231     return (Persp3D *) sp_object_get_child_by_repr (SP_OBJECT(defs), repr);
234 /**
235  * Virtual write: write object attributes to repr.
236  */
237 static Inkscape::XML::Node *
238 persp3d_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
240     Persp3D *persp = SP_PERSP3D(object);
242     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
243         // this is where we end up when saving as plain SVG (also in other circumstances?);
244         // hence we don't set the sodipodi:type attribute
245         Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
246         repr = xml_doc->createElement("inkscape:perspective");
247     }
249     if (flags & SP_OBJECT_WRITE_EXT) {
250         gchar *str = NULL; // FIXME: Should this be freed each time we set an attribute or only in the end or at all?
251         str = persp3d_pt_to_str (persp, Proj::X);
252         repr->setAttribute("inkscape:vp_x", str);
254         str = persp3d_pt_to_str (persp, Proj::Y);
255         repr->setAttribute("inkscape:vp_y", str);
257         str = persp3d_pt_to_str (persp, Proj::Z);
258         repr->setAttribute("inkscape:vp_z", str);
260         str = persp3d_pt_to_str (persp, Proj::W);
261         repr->setAttribute("inkscape:persp3d-origin", str);
262     }
264     if (((SPObjectClass *) persp3d_parent_class)->write)
265         (* ((SPObjectClass *) persp3d_parent_class)->write)(object, repr, flags);
267     return repr;
270 /* convenience wrapper around persp3d_get_finite_dir() and persp3d_get_infinite_dir() */
271 NR::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, NR::Point const &pt, Proj::Axis axis) {
272     if (persp3d_VP_is_finite(persp, axis)) {
273         return persp3d_get_finite_dir(persp, pt, axis);
274     } else {
275         return persp3d_get_infinite_dir(persp, axis);
276     }
279 NR::Point
280 persp3d_get_finite_dir (Persp3D *persp, NR::Point const &pt, Proj::Axis axis) {
281     Box3D::PerspectiveLine pl(pt, axis, persp);
282     return pl.direction();
285 NR::Point
286 persp3d_get_infinite_dir (Persp3D *persp, Proj::Axis axis) {
287     Proj::Pt2 vp(persp3d_get_VP(persp, axis));
288     if (vp[2] != 0.0) {
289         g_print ("VP should be infinite but is (%f : %f : %f)\n", vp[0], vp[1], vp[2]);
290         g_return_val_if_fail(vp[2] != 0.0, NR::Point(0.0, 0.0));
291     }
292     return NR::Point(vp[0], vp[1]);
295 double
296 persp3d_get_infinite_angle (Persp3D *persp, Proj::Axis axis) {
297     return persp->tmat.get_infinite_angle(axis);
300 bool
301 persp3d_VP_is_finite (Persp3D *persp, Proj::Axis axis) {
302     return persp->tmat.has_finite_image(axis);
305 void
306 persp3d_toggle_VP (Persp3D *persp, Proj::Axis axis, bool set_undo) {
307     persp->tmat.toggle_finite(axis);
308     // FIXME: Remove this repr update and rely on vp_drag_sel_modified() to do this for us
309     //        On the other hand, vp_drag_sel_modified() would update all boxes;
310     //        here we can confine ourselves to the boxes of this particular perspective.
311     persp3d_update_box_reprs (persp);
312     //persp3d_update_z_orders (persp);
313     SP_OBJECT(persp)->updateRepr(SP_OBJECT_WRITE_EXT);
314     if (set_undo) {
315         sp_document_done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
316                          _("Toggle vanishing point"));
317     }
320 /* toggle VPs for the same axis in all perspectives of a given list */
321 void
322 persp3d_toggle_VPs (std::set<Persp3D *> p, Proj::Axis axis) {
323     for (std::set<Persp3D *>::iterator i = p.begin(); i != p.end(); ++i) {
324         persp3d_toggle_VP((*i), axis, false);
325     }
326     sp_document_done(sp_desktop_document(inkscape_active_desktop()), SP_VERB_CONTEXT_3DBOX,
327                      _("Toggle multiple vanishing points"));
330 void
331 persp3d_set_VP_state (Persp3D *persp, Proj::Axis axis, Proj::VPState state) {
332     if (persp3d_VP_is_finite(persp, axis) != (state == Proj::FINITE)) {
333         persp3d_toggle_VP(persp, axis);
334     }
337 void
338 persp3d_rotate_VP (Persp3D *persp, Proj::Axis axis, double angle, bool alt_pressed) { // angle is in degrees
339     // FIXME: Most of this functionality should be moved to trans_mat_3x4.(h|cpp)
340     if (persp->tmat.has_finite_image(axis)) {
341         // don't rotate anything for finite VPs
342         return;
343     }
344     Proj::Pt2 v_dir_proj (persp->tmat.column(axis));
345     NR::Point v_dir (v_dir_proj[0], v_dir_proj[1]);
346     double a = NR::atan2 (v_dir) * 180/M_PI;
347     a += alt_pressed ? 0.5 * ((angle > 0 ) - (angle < 0)) : angle; // the r.h.s. yields +/-0.5 or angle
348     persp->tmat.set_infinite_direction (axis, a);
350     persp3d_update_box_reprs (persp);
351     //persp3d_update_z_orders (persp);
352     SP_OBJECT(persp)->updateRepr(SP_OBJECT_WRITE_EXT);
355 void
356 persp3d_update_with_point (Persp3D *persp, Proj::Axis const axis, Proj::Pt2 const &new_image) {
357     persp->tmat.set_image_pt (axis, new_image);
360 void
361 persp3d_apply_affine_transformation (Persp3D *persp, NR::Matrix const &xform) {
362     persp->tmat *= xform;
363     persp3d_update_box_reprs(persp);
364     SP_OBJECT(persp)->updateRepr(SP_OBJECT_WRITE_EXT);
367 gchar *
368 persp3d_pt_to_str (Persp3D *persp, Proj::Axis const axis)
370     return persp->tmat.pt_to_str(axis);
373 void
374 persp3d_add_box (Persp3D *persp, SPBox3D *box) {
375     if (!box) {
376         //g_warning ("Trying to add NULL box to perspective.\n");
377         return;
378     }
379     if (std::find (persp->boxes.begin(), persp->boxes.end(), box) != persp->boxes.end()) {
380         //g_warning ("Attempting to add already existent box to perspective.\n");
381         return;
382     }
383     persp->boxes.push_back(box);
384     //SP_OBJECT_REPR(box)->setAttribute("inkscape:perspectiveID", SP_OBJECT_REPR(persp)->attribute("id"));
387 void
388 persp3d_remove_box (Persp3D *persp, SPBox3D *box) {
389     std::vector<SPBox3D *>::iterator i = std::find (persp->boxes.begin(), persp->boxes.end(), box);
390     if (i != persp->boxes.end()) {
391         persp->boxes.erase(i);
392     }
395 bool
396 persp3d_has_box (Persp3D *persp, SPBox3D *box) {
397     // FIXME: For some reason, std::find() does not seem to compare pointers "correctly" (or do we need to
398     //        provide a proper comparison function?), so we manually traverse the list.
399     for (std::vector<SPBox3D *>::iterator i = persp->boxes.begin(); i != persp->boxes.end(); ++i) {
400         if ((*i) == box) {
401             return true;
402         }
403     }
404     return false;
407 void
408 persp3d_add_box_transform (Persp3D *persp, SPBox3D *box) {
409     std::map<SPBox3D *, bool>::iterator i = persp->boxes_transformed.find(box);
410     if (i != persp->boxes_transformed.end() && (*i).second == true) {
411         g_print ("Warning! In %s (%d): trying to add transform status for box %d twice when it's already listed as true.\n", SP_OBJECT_REPR(persp)->attribute("id"), persp->my_counter, box->my_counter);
412         return;
413     }
414  
415     persp->boxes_transformed[box] = false;
418 void
419 persp3d_remove_box_transform (Persp3D *persp, SPBox3D *box) {
420     persp->boxes_transformed.erase(box);
423 void
424 persp3d_set_box_transformed (Persp3D *persp, SPBox3D *box, bool transformed) {
425     if (persp->boxes_transformed.find(box) == persp->boxes_transformed.end()) {
426         g_print ("Warning! In %s (%d): trying to set transform status for box %d, but it is not listed in the perspective!! Aborting.\n",
427                  SP_OBJECT_REPR(persp)->attribute("id"), persp->my_counter,
428                  box->my_counter);
429         return;
430     }
432     persp->boxes_transformed[box] = transformed;
435 bool
436 persp3d_was_transformed (Persp3D *persp) {
437     if (persp->boxes_transformed.size() == 1) {
438         /* either the transform has not been applied to the single box associated to this perspective yet
439            or the transform was already reset; in both cases we need to return false because upcoming
440            transforms need to be applied */
441         (*persp->boxes_transformed.begin()).second = false; // make sure the box is marked as untransformed (in case more boxes are added later)
442         return false;
443     }
445     for (std::map<SPBox3D *, bool>::iterator i = persp->boxes_transformed.begin();
446          i != persp->boxes_transformed.end(); ++i) {
447         if ((*i).second == true) {
448             // at least one of the boxes in the perspective has already been transformed;
449             return true;
450         }
451     }
452     return false; // all boxes in the perspective are still untransformed; a pending transformation should be applied
455 bool
456 persp3d_all_transformed(Persp3D *persp) {
457     for (std::map<SPBox3D *, bool>::iterator i = persp->boxes_transformed.begin();
458          i != persp->boxes_transformed.end(); ++i) {
459         if ((*i).second == false) {
460             return false;
461         }
462     }
463     return true;
466 void
467 persp3d_unset_transforms(Persp3D *persp) {
468     for (std::map<SPBox3D *, bool>::iterator i = persp->boxes_transformed.begin();
469          i != persp->boxes_transformed.end(); ++i) {
470         (*i).second = false;
471     }
474 void
475 persp3d_update_box_displays (Persp3D *persp) {
476     if (persp->boxes.empty())
477         return;
478     //g_print ("Requesting display update for %d boxes in the perspective.\n", persp->boxes.size());
479     for (std::vector<SPBox3D *>::iterator i = persp->boxes.begin(); i != persp->boxes.end(); ++i) {
480         box3d_position_set(*i);
481     }
484 void
485 persp3d_update_box_reprs (Persp3D *persp) {
486     if (persp->boxes.empty())
487         return;
488     //g_print ("Requesting repr update for %d boxes in the perspective.\n", persp->boxes.size());
489     for (std::vector<SPBox3D *>::iterator i = persp->boxes.begin(); i != persp->boxes.end(); ++i) {
490         SP_OBJECT(*i)->updateRepr(SP_OBJECT_WRITE_EXT);
491         box3d_set_z_orders(*i);
492     }
495 void
496 persp3d_update_z_orders (Persp3D *persp) {
497     if (persp->boxes.empty())
498         return;
499     for (std::vector<SPBox3D *>::iterator i = persp->boxes.begin(); i != persp->boxes.end(); ++i) {
500         box3d_set_z_orders(*i);
501     }
504 // FIXME: For some reason we seem to require a vector instead of a list in Persp3D, but in vp_knot_moved_handler()
505 //        we need a list of boxes. If we can store a list in Persp3D right from the start, this function becomes
506 //        obsolete. We should do this.
507 std::list<SPBox3D *>
508 persp3d_list_of_boxes(Persp3D *persp) {
509     std::list<SPBox3D *> bx_lst;
510     for (std::vector<SPBox3D *>::iterator i = persp->boxes.begin(); i != persp->boxes.end(); ++i) {
511         bx_lst.push_back(*i);
512     }
513     return bx_lst;
516 bool
517 persp3d_perspectives_coincide(const Persp3D *lhs, const Persp3D *rhs)
519     return lhs->tmat == rhs->tmat;
522 void
523 persp3d_absorb(Persp3D *persp1, Persp3D *persp2) {
524     /* double check if we are called in sane situations */
525     g_return_if_fail (persp3d_perspectives_coincide(persp1, persp2) && persp1 != persp2);
527     std::vector<SPBox3D *>::iterator boxes;
529     // Note: We first need to copy the boxes of persp2 into a separate list;
530     //       otherwise the loop below gets confused when perspectives are reattached.
531     std::list<SPBox3D *> boxes_of_persp2 = persp3d_list_of_boxes(persp2);
533     for (std::list<SPBox3D *>::iterator i = boxes_of_persp2.begin(); i != boxes_of_persp2.end(); ++i) {
534         box3d_switch_perspectives((*i), persp2, persp1, true);
535         SP_OBJECT(*i)->updateRepr(SP_OBJECT_WRITE_EXT); // so that undo/redo can do its job properly
536     }
539 static void
540 persp3d_on_repr_attr_changed ( Inkscape::XML::Node * /*repr*/,
541                                const gchar */*key*/,
542                                const gchar */*oldval*/,
543                                const gchar */*newval*/,
544                                bool /*is_interactive*/,
545                                void * data )
547     //g_print("persp3d_on_repr_attr_changed!!!! TODO: Do we need to trigger any further updates than the box reprs?");
549     if (!data)
550         return;
552     Persp3D *persp = (Persp3D*) data;
553     persp3d_update_box_displays (persp);
555     //lpeobj->requestModified(SP_OBJECT_MODIFIED_FLAG);
558 /* returns a std::set() of all perspectives of the currently selected boxes */
559 std::set<Persp3D *>
560 persp3d_currently_selected_persps (SPEventContext *ec) {
561     Inkscape::Selection *selection = sp_desktop_selection (ec->desktop);
563     std::set<Persp3D *> p;
564     for (GSList *i = (GSList *) selection->itemList(); i != NULL; i = i->next) {
565         if (SP_IS_BOX3D (i->data)) {
566             p.insert(box3d_get_perspective(SP_BOX3D(i->data)));
567         }
568     }
569     return p;
572 /* checks whether all boxes linked to this perspective are currently selected */
573 bool
574 persp3d_has_all_boxes_in_selection (Persp3D *persp) {
575     const GSList *selection = sp_desktop_selection (inkscape_active_desktop())->itemList();
577     for (std::vector<SPBox3D *>::iterator i = persp->boxes.begin(); i != persp->boxes.end(); ++i) {
578         if (g_slist_find((GSList *) selection, *i) == NULL) {
579             // we have an unselected box in the perspective
580             return false;
581         }
582     }
583     return true;
586 std::list<SPBox3D *>
587 persp3d_selected_boxes (Persp3D *persp) {
588     const GSList *selection = sp_desktop_selection (inkscape_active_desktop())->itemList();
589     std::list<SPBox3D *> sel;
591     for (std::vector<SPBox3D *>::iterator i = persp->boxes.begin(); i != persp->boxes.end(); ++i) {
592         if (g_slist_find((GSList *) selection, *i) != NULL) {
593             sel.push_back(SP_BOX3D(*i));
594         }
595     }
596     return sel;
599 void
600 persp3d_print_debugging_info (Persp3D *persp) {
601     g_print ("=== Info for Persp3D %d ===\n", persp->my_counter);
602     gchar * cstr;
603     for (int i = 0; i < 4; ++i) {
604         cstr = persp3d_get_VP(persp, Proj::axes[i]).coord_string();
605         g_print ("  VP %s:   %s\n", Proj::string_from_axis(Proj::axes[i]), cstr);
606         g_free(cstr);
607     }
608     cstr = persp3d_get_VP(persp, Proj::W).coord_string();
609     g_print ("  Origin: %s\n", cstr);
610     g_free(cstr);
612     g_print ("  Boxes: ");
613     for (std::vector<SPBox3D *>::iterator i = persp->boxes.begin(); i != persp->boxes.end(); ++i) {
614         g_print ("%d (%d)  ", (*i)->my_counter, box3d_get_perspective(*i)->my_counter);
615     }
616     g_print ("\n");
617     g_print ("========================\n");
620 void
621 persp3d_print_debugging_info_all(SPDocument *document) {
622     SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
623     Inkscape::XML::Node *repr;
624     for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) {
625         repr = SP_OBJECT_REPR(child);
626         if (SP_IS_PERSP3D(child)) {
627             persp3d_print_debugging_info(SP_PERSP3D(child));
628         }
629     }
630     persp3d_print_all_selected();
633 void
634 persp3d_print_all_selected() {
635     /**
636     if (persp3d->boxes_transformed.empty()) {
637         g_print ("No selected perspectives in document\n");
638         return;
639     }
640     **/
641     g_print ("\n======================================\n");
642     g_print ("Selected perspectives and their boxes:\n");
644     std::set<Persp3D *> sel_persps = persp3d_currently_selected_persps (inkscape_active_event_context());
646     for (std::set<Persp3D *>::iterator j = sel_persps.begin(); j != sel_persps.end(); ++j) {
647         Persp3D *persp = SP_PERSP3D(*j);
648         g_print ("  %s (%d):  ", SP_OBJECT_REPR(persp)->attribute("id"), persp->my_counter);
649         for (std::map<SPBox3D *, bool>::iterator i = persp->boxes_transformed.begin();
650              i != persp->boxes_transformed.end(); ++i) {
651             g_print ("<%d,%d> ", (*i).first->my_counter, (*i).second);
652         }
653         g_print ("\n");
654     }
655     g_print ("======================================\n\n");
656  }
658 /*
659   Local Variables:
660   mode:c++
661   c-file-style:"stroustrup"
662   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
663   indent-tabs-mode:nil
664   fill-column:99
665   End:
666 */
667 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :