Code

Fix fallback icon loading order for icons with legacy names.
[inkscape.git] / src / box3d-context.cpp
1 /*
2  * 3D box drawing context
3  *
4  * Author:
5  *   Lauris Kaplinski <lauris@kaplinski.com>
6  *   bulia byak <buliabyak@users.sf.net>
7  *   Jon A. Cruz <jon@joncruz.org>
8  *   Abhishek Sharma
9  *
10  * Copyright (C) 2007      Maximilian Albert <Anhalter42@gmx.de>
11  * Copyright (C) 2006      Johan Engelen <johan@shouraizou.nl>
12  * Copyright (C) 2000-2005 authors
13  * Copyright (C) 2000-2001 Ximian, Inc.
14  *
15  * Released under GNU GPL, read the file 'COPYING' for more information
16  */
18 #include "config.h"
20 #include <gdk/gdkkeysyms.h>
22 #include "macros.h"
23 #include "display/sp-canvas.h"
24 #include "document.h"
25 #include "sp-namedview.h"
26 #include "selection.h"
27 #include "selection-chemistry.h"
28 #include "desktop-handles.h"
29 #include "snap.h"
30 #include "display/curve.h"
31 #include "desktop.h"
32 #include "message-context.h"
33 #include "pixmaps/cursor-3dbox.xpm"
34 #include "box3d.h"
35 #include "box3d-context.h"
36 #include "sp-metrics.h"
37 #include <glibmm/i18n.h>
38 #include "object-edit.h"
39 #include "xml/repr.h"
40 #include "xml/node-event-vector.h"
41 #include "preferences.h"
42 #include "context-fns.h"
43 #include "desktop-style.h"
44 #include "transf_mat_3x4.h"
45 #include "perspective-line.h"
46 #include "persp3d.h"
47 #include "box3d-side.h"
48 #include "document-private.h"
49 #include "line-geometry.h"
50 #include "shape-editor.h"
52 using Inkscape::DocumentUndo;
54 static void sp_box3d_context_class_init(Box3DContextClass *klass);
55 static void sp_box3d_context_init(Box3DContext *box3d_context);
56 static void sp_box3d_context_dispose(GObject *object);
58 static void sp_box3d_context_setup(SPEventContext *ec);
59 static void sp_box3d_context_finish(SPEventContext *ec);
61 static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEvent *event);
62 static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
64 static void sp_box3d_drag(Box3DContext &bc, guint state);
65 static void sp_box3d_finish(Box3DContext *bc);
67 static SPEventContextClass *parent_class;
69 GtkType sp_box3d_context_get_type()
70 {
71     static GType type = 0;
72     if (!type) {
73         GTypeInfo info = {
74             sizeof(Box3DContextClass),
75             NULL, NULL,
76             (GClassInitFunc) sp_box3d_context_class_init,
77             NULL, NULL,
78             sizeof(Box3DContext),
79             4,
80             (GInstanceInitFunc) sp_box3d_context_init,
81             NULL,    /* value_table */
82         };
83         type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "Box3DContext", &info, (GTypeFlags) 0);
84     }
85     return type;
86 }
88 static void sp_box3d_context_class_init(Box3DContextClass *klass)
89 {
90     GObjectClass *object_class = (GObjectClass *) klass;
91     SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
93     parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass);
95     object_class->dispose = sp_box3d_context_dispose;
97     event_context_class->setup = sp_box3d_context_setup;
98     event_context_class->finish = sp_box3d_context_finish;
99     event_context_class->root_handler  = sp_box3d_context_root_handler;
100     event_context_class->item_handler  = sp_box3d_context_item_handler;
103 static void sp_box3d_context_init(Box3DContext *box3d_context)
105     SPEventContext *event_context = SP_EVENT_CONTEXT(box3d_context);
107     event_context->cursor_shape = cursor_3dbox_xpm;
108     event_context->hot_x = 4;
109     event_context->hot_y = 4;
110     event_context->xp = 0;
111     event_context->yp = 0;
112     event_context->tolerance = 0;
113     event_context->within_tolerance = false;
114     event_context->item_to_select = NULL;
116     box3d_context->item = NULL;
118     box3d_context->ctrl_dragged = false;
119     box3d_context->extruded = false;
121     box3d_context->_vpdrag = NULL;
123     new (&box3d_context->sel_changed_connection) sigc::connection();
126 static void sp_box3d_context_finish(SPEventContext *ec)
128     Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
129     SPDesktop *desktop = ec->desktop;
131     sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
132     sp_box3d_finish(bc);
133     bc->sel_changed_connection.disconnect();
134 //    sp_repr_remove_listener_by_data(cc->active_shape_repr, cc);
136     if (((SPEventContextClass *) parent_class)->finish) {
137         ((SPEventContextClass *) parent_class)->finish(ec);
138     }
142 static void sp_box3d_context_dispose(GObject *object)
144     Box3DContext *bc = SP_BOX3D_CONTEXT(object);
145     SPEventContext *ec = SP_EVENT_CONTEXT(object);
147     ec->enableGrDrag(false);
149     delete (bc->_vpdrag);
150     bc->_vpdrag = NULL;
152     bc->sel_changed_connection.disconnect();
153     bc->sel_changed_connection.~connection();
155     delete ec->shape_editor;
156     ec->shape_editor = NULL;
158     /* fixme: This is necessary because we do not grab */
159     if (bc->item) {
160         sp_box3d_finish(bc);
161     }
163     if (bc->_message_context) {
164         delete bc->_message_context;
165     }
167     G_OBJECT_CLASS(parent_class)->dispose(object);
170 /**
171 \brief  Callback that processes the "changed" signal on the selection;
172 destroys old and creates new knotholder
173 */
174 static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, gpointer data)
176     Box3DContext *bc = SP_BOX3D_CONTEXT(data);
177     SPEventContext *ec = SP_EVENT_CONTEXT(bc);
179     ec->shape_editor->unset_item(SH_KNOTHOLDER);
180     SPItem *item = selection->singleItem();
181     ec->shape_editor->set_item(item, SH_KNOTHOLDER);
183     if (selection->perspList().size() == 1) {
184         // selecting a single box changes the current perspective
185         ec->desktop->doc()->setCurrentPersp3D(selection->perspList().front());
186     }
189 /* Create a default perspective in document defs if none is present (which can happen, among other
190  * circumstances, after 'vacuum defs' or when a pre-0.46 file is opened).
191  */
192 static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) {
193     SPDefs *defs = reinterpret_cast<SPDefs *>(SP_DOCUMENT_DEFS(document));
195     bool has_persp = false;
196     for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) {
197         if (SP_IS_PERSP3D(child)) {
198             has_persp = true;
199             break;
200         }
201     }
203     if (!has_persp) {
204         document->setCurrentPersp3D(persp3d_create_xml_element (document));
205     }
208 static void sp_box3d_context_setup(SPEventContext *ec)
210     Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
212     if (((SPEventContextClass *) parent_class)->setup) {
213         ((SPEventContextClass *) parent_class)->setup(ec);
214     }
216     ec->shape_editor = new ShapeEditor(ec->desktop);
218     SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
219     if (item) {
220         ec->shape_editor->set_item(item, SH_KNOTHOLDER);
221     }
223     bc->sel_changed_connection.disconnect();
224     bc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(
225         sigc::bind(sigc::ptr_fun(&sp_box3d_context_selection_changed), (gpointer)bc)
226     );
228     bc->_vpdrag = new Box3D::VPDrag(sp_desktop_document (ec->desktop));
229     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
231     if (prefs->getBool("/tools/shapes/selcue")) {
232         ec->enableSelectionCue();
233     }
235     if (prefs->getBool("/tools/shapes/gradientdrag")) {
236         ec->enableGrDrag();
237     }
239     bc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
242 static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
244     SPDesktop *desktop = event_context->desktop;
246     gint ret = FALSE;
248     switch (event->type) {
249     case GDK_BUTTON_PRESS:
250         if ( event->button.button == 1 && !event_context->space_panning) {
251             Inkscape::setup_for_drag_start(desktop, event_context, event);
252             ret = TRUE;
253         }
254         break;
255         // motion and release are always on root (why?)
256     default:
257         break;
258     }
260     if (((SPEventContextClass *) parent_class)->item_handler) {
261         ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event);
262     }
264     return ret;
267 static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEvent *event)
269     static bool dragging;
271     SPDesktop *desktop = event_context->desktop;
272     SPDocument *document = sp_desktop_document (desktop);
273     Inkscape::Selection *selection = sp_desktop_selection (desktop);
274     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
275     int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
277     Box3DContext *bc = SP_BOX3D_CONTEXT(event_context);
278     Persp3D *cur_persp = document->getCurrentPersp3D();
280     event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
282     gint ret = FALSE;
283     switch (event->type) {
284     case GDK_BUTTON_PRESS:
285         if ( event->button.button == 1  && !event_context->space_panning) {
286             Geom::Point const button_w(event->button.x,
287                                        event->button.y);
288             Geom::Point button_dt(desktop->w2d(button_w));
290             // save drag origin
291             event_context->xp = (gint) button_w[Geom::X];
292             event_context->yp = (gint) button_w[Geom::Y];
293             event_context->within_tolerance = true;
295             // remember clicked item, *not* disregarding groups (since a 3D box is a group), honoring Alt
296             event_context->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, event->button.state & GDK_CONTROL_MASK);
298             dragging = true;
300             SnapManager &m = desktop->namedview->snap_manager;
301             m.setup(desktop, true, bc->item);
302             m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
303             m.unSetup();
304             bc->center = from_2geom(button_dt);
306             bc->drag_origin = from_2geom(button_dt);
307             bc->drag_ptB = from_2geom(button_dt);
308             bc->drag_ptC = from_2geom(button_dt);
310             // This can happen after saving when the last remaining perspective was purged and must be recreated.
311             if (!cur_persp) {
312                 sp_box3d_context_ensure_persp_in_defs(document);
313                 cur_persp = document->getCurrentPersp3D();
314             }
316             /* Projective preimages of clicked point under current perspective */
317             bc->drag_origin_proj = cur_persp->perspective_impl->tmat.preimage (from_2geom(button_dt), 0, Proj::Z);
318             bc->drag_ptB_proj = bc->drag_origin_proj;
319             bc->drag_ptC_proj = bc->drag_origin_proj;
320             bc->drag_ptC_proj.normalize();
321             bc->drag_ptC_proj[Proj::Z] = 0.25;
323             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
324                                 ( GDK_KEY_PRESS_MASK |
325                                   GDK_BUTTON_RELEASE_MASK       |
326                                   GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK       |
327                                   GDK_BUTTON_PRESS_MASK ),
328                                 NULL, event->button.time);
329             ret = TRUE;
330         }
331         break;
332     case GDK_MOTION_NOTIFY:
333         if ( dragging
334              && ( event->motion.state & GDK_BUTTON1_MASK )  && !event_context->space_panning)
335         {
336             if ( event_context->within_tolerance
337                  && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
338                  && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
339                 break; // do not drag if we're within tolerance from origin
340             }
341             // Once the user has moved farther than tolerance from the original location
342             // (indicating they intend to draw, not click), then always process the
343             // motion notify coordinates as given (no snapping back to origin)
344             event_context->within_tolerance = false;
346             Geom::Point const motion_w(event->motion.x,
347                                        event->motion.y);
348             Geom::Point motion_dt(desktop->w2d(motion_w));
350             SnapManager &m = desktop->namedview->snap_manager;
351             m.setup(desktop, true, bc->item);
352             m.freeSnapReturnByRef(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
353             bc->ctrl_dragged  = event->motion.state & GDK_CONTROL_MASK;
355             if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded && bc->item) {
356                 // once shift is pressed, set bc->extruded
357                 bc->extruded = true;
358             }
360             if (!bc->extruded) {
361                 bc->drag_ptB = from_2geom(motion_dt);
362                 bc->drag_ptC = from_2geom(motion_dt);
364                 bc->drag_ptB_proj = cur_persp->perspective_impl->tmat.preimage (from_2geom(motion_dt), 0, Proj::Z);
365                 bc->drag_ptC_proj = bc->drag_ptB_proj;
366                 bc->drag_ptC_proj.normalize();
367                 bc->drag_ptC_proj[Proj::Z] = 0.25;
368             } else {
369                 // Without Ctrl, motion of the extruded corner is constrained to the
370                 // perspective line from drag_ptB to vanishing point Y.
371                 if (!bc->ctrl_dragged) {
372                     /* snapping */
373                     Box3D::PerspectiveLine pline (bc->drag_ptB, Proj::Z, document->getCurrentPersp3D());
374                     bc->drag_ptC = pline.closest_to (from_2geom(motion_dt));
376                     bc->drag_ptB_proj.normalize();
377                     bc->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (bc->drag_ptC, bc->drag_ptB_proj[Proj::X], Proj::X);
378                 } else {
379                     bc->drag_ptC = from_2geom(motion_dt);
381                     bc->drag_ptB_proj.normalize();
382                     bc->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (from_2geom(motion_dt), bc->drag_ptB_proj[Proj::X], Proj::X);
383                 }
384                 m.freeSnapReturnByRef(bc->drag_ptC, Inkscape::SNAPSOURCE_NODE_HANDLE);
385             }
386             m.unSetup();
388             sp_box3d_drag(*bc, event->motion.state);
390             ret = TRUE;
391         } else if (!sp_event_context_knot_mouseover(bc)) {
392             SnapManager &m = desktop->namedview->snap_manager;
393             m.setup(desktop);
395             Geom::Point const motion_w(event->motion.x, event->motion.y);
396             Geom::Point motion_dt(desktop->w2d(motion_w));
397             m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE));
398             m.unSetup();
399         }
400         break;
401     case GDK_BUTTON_RELEASE:
402         event_context->xp = event_context->yp = 0;
403         if ( event->button.button == 1  && !event_context->space_panning) {
404             dragging = false;
405             sp_event_context_discard_delayed_snap_event(event_context);
407             if (!event_context->within_tolerance) {
408                 // we've been dragging, finish the box
409                 sp_box3d_finish(bc);
410             } else if (event_context->item_to_select) {
411                 // no dragging, select clicked item if any
412                 if (event->button.state & GDK_SHIFT_MASK) {
413                     selection->toggle(event_context->item_to_select);
414                 } else {
415                     selection->set(event_context->item_to_select);
416                 }
417             } else {
418                 // click in an empty space
419                 selection->clear();
420             }
422             event_context->item_to_select = NULL;
423             ret = TRUE;
424             sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
425                                   event->button.time);
426         }
427         break;
428     case GDK_KEY_PRESS:
429         switch (get_group0_keyval (&event->key)) {
430         case GDK_Up:
431         case GDK_Down:
432         case GDK_KP_Up:
433         case GDK_KP_Down:
434             // prevent the zoom field from activation
435             if (!MOD__CTRL_ONLY)
436                 ret = TRUE;
437             break;
439         case GDK_bracketright:
440             persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, -180/snaps, MOD__ALT);
441             DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX,
442                              _("Change perspective (angle of PLs)"));
443             ret = true;
444             break;
446         case GDK_bracketleft:
447             persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::X, 180/snaps, MOD__ALT);
448             DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX,
449                              _("Change perspective (angle of PLs)"));
450             ret = true;
451             break;
453         case GDK_parenright:
454             persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, -180/snaps, MOD__ALT);
455             DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX,
456                              _("Change perspective (angle of PLs)"));
457             ret = true;
458             break;
460         case GDK_parenleft:
461             persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Y, 180/snaps, MOD__ALT);
462             DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX,
463                              _("Change perspective (angle of PLs)"));
464             ret = true;
465             break;
467         case GDK_braceright:
468             persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, -180/snaps, MOD__ALT);
469             DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX,
470                              _("Change perspective (angle of PLs)"));
471             ret = true;
472             break;
474         case GDK_braceleft:
475             persp3d_rotate_VP (document->getCurrentPersp3D(), Proj::Z, 180/snaps, MOD__ALT);
476             DocumentUndo::done(document, SP_VERB_CONTEXT_3DBOX,
477                              _("Change perspective (angle of PLs)"));
478             ret = true;
479             break;
481         /* TODO: what is this???
482         case GDK_O:
483             if (MOD__CTRL && MOD__SHIFT) {
484                 Box3D::create_canvas_point(persp3d_get_VP(document()->getCurrentPersp3D(), Proj::W).affine(),
485                                            6, 0xff00ff00);
486             }
487             ret = true;
488             break;
489         */
491         case GDK_g:
492         case GDK_G:
493             if (MOD__SHIFT_ONLY) {
494                 sp_selection_to_guides(desktop);
495                 ret = true;
496             }
497             break;
499         case GDK_p:
500         case GDK_P:
501             if (MOD__SHIFT_ONLY) {
502                 if (document->getCurrentPersp3D()) {
503                     persp3d_print_debugging_info (document->getCurrentPersp3D());
504                 }
505                 ret = true;
506             }
507             break;
509         case GDK_x:
510         case GDK_X:
511             if (MOD__ALT_ONLY) {
512                 desktop->setToolboxFocusTo ("altx-box3d");
513                 ret = TRUE;
514             }
515             if (MOD__SHIFT_ONLY) {
516                 persp3d_toggle_VPs(selection->perspList(), Proj::X);
517                 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
518                 ret = true;
519             }
520             break;
522         case GDK_y:
523         case GDK_Y:
524             if (MOD__SHIFT_ONLY) {
525                 persp3d_toggle_VPs(selection->perspList(), Proj::Y);
526                 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
527                 ret = true;
528             }
529             break;
531         case GDK_z:
532         case GDK_Z:
533             if (MOD__SHIFT_ONLY) {
534                 persp3d_toggle_VPs(selection->perspList(), Proj::Z);
535                 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
536                 ret = true;
537             }
538             break;
540         case GDK_Escape:
541             sp_desktop_selection(desktop)->clear();
542             //TODO: make dragging escapable by Esc
543             break;
545         case GDK_space:
546             if (dragging) {
547                 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
548                                       event->button.time);
549                 dragging = false;
550                 sp_event_context_discard_delayed_snap_event(event_context);
551                 if (!event_context->within_tolerance) {
552                     // we've been dragging, finish the box
553                     sp_box3d_finish(bc);
554                 }
555                 // do not return true, so that space would work switching to selector
556             }
557             break;
559         default:
560             break;
561         }
562         break;
563     default:
564         break;
565     }
567     if (!ret) {
568         if (((SPEventContextClass *) parent_class)->root_handler) {
569             ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
570         }
571     }
573     return ret;
576 static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
578     SPDesktop *desktop = bc.desktop;
580     if (!bc.item) {
582         if (Inkscape::have_viable_layer(desktop, bc._message_context) == false) {
583             return;
584         }
586         // Create object
587         SPBox3D *box3d = 0;
588         box3d = SPBox3D::createBox3D((SPItem *)desktop->currentLayer());
590         // Set style
591         desktop->applyCurrentOrToolStyle(box3d, "/tools/shapes/3dbox", false);
592         
593         bc.item = box3d;
595         // TODO: Incorporate this in box3d-side.cpp!
596         for (int i = 0; i < 6; ++i) {
597             Box3DSide *side = Box3DSide::createBox3DSide(box3d);
598             
599             guint desc = Box3D::int_to_face(i);
601             Box3D::Axis plane = (Box3D::Axis) (desc & 0x7);
602             plane = (Box3D::is_plane(plane) ? plane : Box3D::orth_plane_or_axis(plane));
603             side->dir1 = Box3D::extract_first_axis_direction(plane);
604             side->dir2 = Box3D::extract_second_axis_direction(plane);
605             side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8);
607             // Set style
608             Inkscape::Preferences *prefs = Inkscape::Preferences::get();
610             Glib::ustring descr = "/desktop/";
611             descr += box3d_side_axes_string(side);
612             descr += "/style";
613             Glib::ustring cur_style = prefs->getString(descr);    
614     
615             bool use_current = prefs->getBool("/tools/shapes/3dbox/usecurrent", false);
616             if (use_current && !cur_style.empty()) {
617                 // use last used style 
618                 side->setAttribute("style", cur_style.data());
619                                 
620             } else {
621                 // use default style 
622                 GString *pstring = g_string_new("");
623                 g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side));
624                 desktop->applyCurrentOrToolStyle (side, pstring->str, false);
625             }
627             side->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
628         }
630         box3d_set_z_orders(SP_BOX3D(bc.item));
631         bc.item->updateRepr();
633         // TODO: It would be nice to show the VPs during dragging, but since there is no selection
634         //       at this point (only after finishing the box), we must do this "manually"
635         /* bc._vpdrag->updateDraggers(); */
637         sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
638     }
640     g_assert(bc.item);
642     SPBox3D *box = SP_BOX3D(bc.item);
644     box->orig_corner0 = bc.drag_origin_proj;
645     box->orig_corner7 = bc.drag_ptC_proj;
647     box3d_check_for_swapped_coords(box);
649     /* we need to call this from here (instead of from box3d_position_set(), for example)
650        because z-order setting must not interfere with display updates during undo/redo */
651     box3d_set_z_orders (box);
653     box3d_position_set(box);
655     // status text
656     bc._message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
659 static void sp_box3d_finish(Box3DContext *bc)
661     bc->_message_context->clear();
662     bc->ctrl_dragged = false;
663     bc->extruded = false;
665     if ( bc->item != NULL ) {
666         SPDesktop * desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
667         SPDocument *doc = sp_desktop_document(desktop);
668         if (!doc || !doc->getCurrentPersp3D())
669             return;
671         SPBox3D *box = SP_BOX3D(bc->item);
673         box->orig_corner0 = bc->drag_origin_proj;
674         box->orig_corner7 = bc->drag_ptC_proj;
676         box->updateRepr();
678         box3d_relabel_corners(box);
680         sp_canvas_end_forced_full_redraws(desktop->canvas);
682         sp_desktop_selection(desktop)->set(bc->item);
683         DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
684                          _("Create 3D box"));
686         bc->item = NULL;
687     }
690 void sp_box3d_context_update_lines(SPEventContext *ec) {
691     /*  update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
692     if (SP_IS_BOX3D_CONTEXT (ec)) {
693         Box3DContext *bc = SP_BOX3D_CONTEXT (ec);
694         bc->_vpdrag->updateLines();
695     }
698 /*
699   Local Variables:
700   mode:c++
701   c-file-style:"stroustrup"
702   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
703   indent-tabs-mode:nil
704   fill-column:99
705   End:
706 */
707 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :