// FIXME: This should rather be put into persp3d-reference.cpp or something similar so that it reacts upon each // Change of the perspective, and not of the current selection (but how to refer to the toolbar then?) static void box3d_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) { // Here the following should be done: If all selected boxes have finite VPs in a certain direction, // disable the angle entry fields for this direction (otherwise entering a value in them should only // update the perspectives with infinite VPs and leave the other ones untouched). Inkscape::XML::Node *persp_repr = NULL; purge_repr_listener(tbl, tbl); SPItem *item = selection->singleItem(); if (item && SP_IS_BOX3D(item)) { // FIXME: Also deal with multiple selected boxes SPBox3D *box = SP_BOX3D(item); Persp3D *persp = box3d_get_perspective(box); persp_repr = persp->getRepr(); if (persp_repr) { g_object_set_data(tbl, "repr", persp_repr); Inkscape::GC::anchor(persp_repr); sp_repr_add_listener(persp_repr, &box3d_persp_tb_repr_events, tbl); sp_repr_synthesize_events(persp_repr, &box3d_persp_tb_repr_events, tbl); } inkscape_active_document()->setCurrentPersp3D(persp3d_get_from_repr(persp_repr)); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setString("/tools/shapes/3dbox/persp", persp_repr->attribute("id")); g_object_set_data(tbl, "freeze", GINT_TO_POINTER(TRUE)); box3d_resync_toolbar(persp_repr, tbl); g_object_set_data(tbl, "freeze", GINT_TO_POINTER(FALSE)); } }
static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, Proj::Axis axis) { SPDesktop *desktop = (SPDesktop *) g_object_get_data( dataKludge, "desktop" ); SPDocument *document = sp_desktop_document(desktop); // quit if run by the attr_changed or selection changed listener if (g_object_get_data( dataKludge, "freeze" )) { return; } // in turn, prevent listener from responding g_object_set_data(dataKludge, "freeze", GINT_TO_POINTER(TRUE)); std::list<Persp3D *> sel_persps = sp_desktop_selection(desktop)->perspList(); if (sel_persps.empty()) { // this can happen when the document is created; we silently ignore it return; } Persp3D *persp = sel_persps.front(); persp->perspective_impl->tmat.set_infinite_direction (axis, gtk_adjustment_get_value(adj)); persp->updateRepr(); // TODO: use the correct axis here, too DocumentUndo::maybeDone(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)")); g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(FALSE) ); }
void persp3d_print_all_selected() { g_print ("\n======================================\n"); g_print ("Selected perspectives and their boxes:\n"); std::list<Persp3D *> sel_persps = SP_ACTIVE_DESKTOP->getSelection()->perspList(); for (std::list<Persp3D *>::iterator j = sel_persps.begin(); j != sel_persps.end(); ++j) { Persp3D *persp = SP_PERSP3D(*j); Persp3DImpl *persp_impl = persp->perspective_impl; g_print (" %s (%d): ", persp->getRepr()->attribute("id"), persp->perspective_impl->my_counter); for (std::vector<SPBox3D *>::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { g_print ("%d ", (*i)->my_counter); } g_print ("\n"); } g_print ("======================================\n\n"); }