Code

Make grouped 3D boxes work correctly when transformed (fixes: LP 188991)
[inkscape.git] / src / box3d-context.cpp
1 #define __SP_BOX3D_CONTEXT_C__
3 /*
4  * 3D box drawing context
5  *
6  * Author:
7  *   Lauris Kaplinski <lauris@kaplinski.com>
8  *   bulia byak <buliabyak@users.sf.net>
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 "prefs-utils.h"
42 #include "context-fns.h"
43 #include "inkscape.h"
44 #include "desktop-style.h"
45 #include "transf_mat_3x4.h"
46 #include "perspective-line.h"
47 #include "persp3d.h"
48 #include "box3d-side.h"
49 #include "document-private.h"
50 #include "line-geometry.h"
52 static void sp_box3d_context_class_init(Box3DContextClass *klass);
53 static void sp_box3d_context_init(Box3DContext *box3d_context);
54 static void sp_box3d_context_dispose(GObject *object);
56 static void sp_box3d_context_setup(SPEventContext *ec);
58 static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEvent *event);
59 static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
61 static void sp_box3d_drag(Box3DContext &bc, guint state);
62 static void sp_box3d_finish(Box3DContext *bc);
64 static SPEventContextClass *parent_class;
66 GtkType sp_box3d_context_get_type()
67 {
68     static GType type = 0;
69     if (!type) {
70         GTypeInfo info = {
71             sizeof(Box3DContextClass),
72             NULL, NULL,
73             (GClassInitFunc) sp_box3d_context_class_init,
74             NULL, NULL,
75             sizeof(Box3DContext),
76             4,
77             (GInstanceInitFunc) sp_box3d_context_init,
78             NULL,    /* value_table */
79         };
80         type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "Box3DContext", &info, (GTypeFlags) 0);
81     }
82     return type;
83 }
85 static void sp_box3d_context_class_init(Box3DContextClass *klass)
86 {
87     GObjectClass *object_class = (GObjectClass *) klass;
88     SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
90     parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass);
92     object_class->dispose = sp_box3d_context_dispose;
94     event_context_class->setup = sp_box3d_context_setup;
95     event_context_class->root_handler  = sp_box3d_context_root_handler;
96     event_context_class->item_handler  = sp_box3d_context_item_handler;
97 }
99 static void sp_box3d_context_init(Box3DContext *box3d_context)
101     SPEventContext *event_context = SP_EVENT_CONTEXT(box3d_context);
103     event_context->cursor_shape = cursor_3dbox_xpm;
104     event_context->hot_x = 4;
105     event_context->hot_y = 4;
106     event_context->xp = 0;
107     event_context->yp = 0;
108     event_context->tolerance = 0;
109     event_context->within_tolerance = false;
110     event_context->item_to_select = NULL;
112     event_context->shape_repr = NULL;
113     event_context->shape_knot_holder = NULL;
115     box3d_context->item = NULL;
117     box3d_context->ctrl_dragged = false;
118     box3d_context->extruded = false;
119     
120     box3d_context->_vpdrag = NULL;
122     new (&box3d_context->sel_changed_connection) sigc::connection();
125 static void sp_box3d_context_dispose(GObject *object)
127     Box3DContext *bc = SP_BOX3D_CONTEXT(object);
128     SPEventContext *ec = SP_EVENT_CONTEXT(object);
130     ec->enableGrDrag(false);
132     delete (bc->_vpdrag);
133     bc->_vpdrag = NULL;
135     bc->sel_changed_connection.disconnect();
136     bc->sel_changed_connection.~connection();
138     /* fixme: This is necessary because we do not grab */
139     if (bc->item) {
140         sp_box3d_finish(bc);
141     }
143     if (ec->shape_knot_holder) {
144         sp_knot_holder_destroy(ec->shape_knot_holder);
145         ec->shape_knot_holder = NULL;
146     }
148     if (ec->shape_repr) { // remove old listener
149         sp_repr_remove_listener_by_data(ec->shape_repr, ec);
150         Inkscape::GC::release(ec->shape_repr);
151         ec->shape_repr = 0;
152     }
154     if (bc->_message_context) {
155         delete bc->_message_context;
156     }
158     G_OBJECT_CLASS(parent_class)->dispose(object);
161 static Inkscape::XML::NodeEventVector ec_shape_repr_events = {
162     NULL, /* child_added */
163     NULL, /* child_removed */
164     ec_shape_event_attr_changed,
165     NULL, /* content_changed */
166     NULL  /* order_changed */
167 };
169 /**
170 \brief  Callback that processes the "changed" signal on the selection;
171 destroys old and creates new knotholder
172 */
173 static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, gpointer data)
175     Box3DContext *bc = SP_BOX3D_CONTEXT(data);
176     SPEventContext *ec = SP_EVENT_CONTEXT(bc);
178     if (ec->shape_knot_holder) { // destroy knotholder
179         sp_knot_holder_destroy(ec->shape_knot_holder);
180         ec->shape_knot_holder = NULL;
181     }
183     if (ec->shape_repr) { // remove old listener
184         sp_repr_remove_listener_by_data(ec->shape_repr, ec);
185         Inkscape::GC::release(ec->shape_repr);
186         ec->shape_repr = 0;
187     }
189     SPItem *item = selection->singleItem();
190     if (item) {
191         ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
192         Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
193         if (shape_repr) {
194             ec->shape_repr = shape_repr;
195             Inkscape::GC::anchor(shape_repr);
196             sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
197         }
198     }
200     if (selection->perspList().size() == 1) {
201         // selecting a single box changes the current perspective
202         ec->desktop->doc()->current_persp3d = selection->perspList().front();
203     }
206 /* create a default perspective in document defs if none is present
207    (can happen after 'vacuum defs' or when a pre-0.46 file is opened) */   
208 static void sp_box3d_context_check_for_persp_in_defs(SPDocument *document) {
209     SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
211     bool has_persp = false;
212     for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) {
213         if (SP_IS_PERSP3D(child)) {
214             has_persp = true;
215             break;
216         }
217     }
219     if (!has_persp) {
220         document->current_persp3d = persp3d_create_xml_element (document);
221     }
224 static void sp_box3d_context_setup(SPEventContext *ec)
226     Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
228     if (((SPEventContextClass *) parent_class)->setup) {
229         ((SPEventContextClass *) parent_class)->setup(ec);
230     }
232     sp_box3d_context_check_for_persp_in_defs(sp_desktop_document (ec->desktop));
234     SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
235     if (item) {
236         ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
237         Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
238         if (shape_repr) {
239             ec->shape_repr = shape_repr;
240             Inkscape::GC::anchor(shape_repr);
241             sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
242         }
243     }
245     bc->sel_changed_connection.disconnect();
246     bc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(
247         sigc::bind(sigc::ptr_fun(&sp_box3d_context_selection_changed), (gpointer)bc)
248     );
250     bc->_vpdrag = new Box3D::VPDrag(sp_desktop_document (ec->desktop));
252     if (prefs_get_int_attribute("tools.shapes", "selcue", 0) != 0) {
253         ec->enableSelectionCue();
254     }
256     if (prefs_get_int_attribute("tools.shapes", "gradientdrag", 0) != 0) {
257         ec->enableGrDrag();
258     }
260     bc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
263 static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
265     SPDesktop *desktop = event_context->desktop;
267     gint ret = FALSE;
269     switch (event->type) {
270     case GDK_BUTTON_PRESS:
271         if ( event->button.button == 1 && !event_context->space_panning) {
272             Inkscape::setup_for_drag_start(desktop, event_context, event);
273             ret = TRUE;
274         }
275         break;
276         // motion and release are always on root (why?)
277     default:
278         break;
279     }
281     if (((SPEventContextClass *) parent_class)->item_handler) {
282         ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event);
283     }
285     return ret;
288 static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEvent *event)
290     static bool dragging;
292     SPDesktop *desktop = event_context->desktop;
293     Inkscape::Selection *selection = sp_desktop_selection (desktop);
294     int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
296     Box3DContext *bc = SP_BOX3D_CONTEXT(event_context);
297     g_assert (SP_ACTIVE_DOCUMENT->current_persp3d);
298     Persp3D *cur_persp = SP_ACTIVE_DOCUMENT->current_persp3d;
300     event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
302     gint ret = FALSE;
303     switch (event->type) {
304     case GDK_BUTTON_PRESS:
305         if ( event->button.button == 1  && !event_context->space_panning) {
306             NR::Point const button_w(event->button.x,
307                                      event->button.y);
309             // save drag origin
310             event_context->xp = (gint) button_w[NR::X];
311             event_context->yp = (gint) button_w[NR::Y];
312             event_context->within_tolerance = true;
313             
314             // remember clicked item, *not* disregarding groups (since a 3D box is a group), honoring Alt
315             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);
317             dragging = true;
318             
319             /*  */
320             NR::Point const button_dt(desktop->w2d(button_w));
321             bc->drag_origin = button_dt;
322             bc->drag_ptB = button_dt;
323             bc->drag_ptC = button_dt;
325             /* Projective preimages of clicked point under current perspective */
326             bc->drag_origin_proj = cur_persp->tmat.preimage (button_dt, 0, Proj::Z);
327             bc->drag_ptB_proj = bc->drag_origin_proj;
328             bc->drag_ptC_proj = bc->drag_origin_proj;
329             bc->drag_ptC_proj.normalize();
330             bc->drag_ptC_proj[Proj::Z] = 0.25;
332             /* Snap center */
333             SnapManager const &m = desktop->namedview->snap_manager;
334             bc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE,
335                                     button_dt, bc->item).getPoint();
337             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
338                                 ( GDK_KEY_PRESS_MASK |
339                                   GDK_BUTTON_RELEASE_MASK       |
340                                   GDK_POINTER_MOTION_MASK       |
341                                   GDK_BUTTON_PRESS_MASK ),
342                                 NULL, event->button.time);
343             ret = TRUE;
344         }
345         break;
346     case GDK_MOTION_NOTIFY:
347         if ( dragging
348              && ( event->motion.state & GDK_BUTTON1_MASK )  && !event_context->space_panning)
349         {
350             if ( event_context->within_tolerance
351                  && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
352                  && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
353                 break; // do not drag if we're within tolerance from origin
354             }
355             // Once the user has moved farther than tolerance from the original location
356             // (indicating they intend to draw, not click), then always process the
357             // motion notify coordinates as given (no snapping back to origin)
358             event_context->within_tolerance = false;
360             NR::Point const motion_w(event->motion.x,
361                                      event->motion.y);
362             NR::Point motion_dt(desktop->w2d(motion_w));
364             SnapManager const &m = desktop->namedview->snap_manager;
365             motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, bc->item).getPoint();
367             bc->ctrl_dragged  = event->motion.state & GDK_CONTROL_MASK;
369             if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded && bc->item) {
370                 // once shift is pressed, set bc->extruded
371                 bc->extruded = true;
372             }
374             if (!bc->extruded) {
375                 bc->drag_ptB = motion_dt;
376                 bc->drag_ptC = motion_dt;
378                 bc->drag_ptB_proj = cur_persp->tmat.preimage (motion_dt, 0, Proj::Z);
379                 bc->drag_ptC_proj = bc->drag_ptB_proj;
380                 bc->drag_ptC_proj.normalize();
381                 bc->drag_ptC_proj[Proj::Z] = 0.25;
382             } else {
383                 // Without Ctrl, motion of the extruded corner is constrained to the
384                 // perspective line from drag_ptB to vanishing point Y.
385                 if (!bc->ctrl_dragged) {
386                     /* snapping */
387                     Box3D::PerspectiveLine pline (bc->drag_ptB, Proj::Z, SP_ACTIVE_DOCUMENT->current_persp3d);
388                     bc->drag_ptC = pline.closest_to (motion_dt);
390                     bc->drag_ptB_proj.normalize();
391                     bc->drag_ptC_proj = cur_persp->tmat.preimage (bc->drag_ptC, bc->drag_ptB_proj[Proj::X], Proj::X);
392                 } else {
393                     bc->drag_ptC = motion_dt;
395                     bc->drag_ptB_proj.normalize();
396                     bc->drag_ptC_proj = cur_persp->tmat.preimage (motion_dt, bc->drag_ptB_proj[Proj::X], Proj::X);
397                 }
398                 bc->drag_ptC = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC, bc->item).getPoint();
399             }
401             sp_box3d_drag(*bc, event->motion.state);
403             ret = TRUE;
404         }
405         break;
406     case GDK_BUTTON_RELEASE:
407         event_context->xp = event_context->yp = 0;
408         if ( event->button.button == 1  && !event_context->space_panning) {
409             dragging = false;
411             if (!event_context->within_tolerance) {
412                 // we've been dragging, finish the box
413                 sp_box3d_finish(bc);
414             } else if (event_context->item_to_select) {
415                 // no dragging, select clicked item if any
416                 if (event->button.state & GDK_SHIFT_MASK) {
417                     selection->toggle(event_context->item_to_select);
418                 } else {
419                     selection->set(event_context->item_to_select);
420                 }
421             } else {
422                 // click in an empty space
423                 selection->clear();
424             }
426             event_context->item_to_select = NULL;
427             ret = TRUE;
428             sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
429                                   event->button.time);
430         }
431         break;
432     case GDK_KEY_PRESS:
433         switch (get_group0_keyval (&event->key)) {
434         case GDK_Up:
435         case GDK_Down:
436         case GDK_KP_Up:
437         case GDK_KP_Down:
438             // prevent the zoom field from activation
439             if (!MOD__CTRL_ONLY)
440                 ret = TRUE;
441             break;
443         case GDK_bracketright:
444             persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::X, -180/snaps, MOD__ALT);
445             sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
446                              _("Change perspective (angle of PLs)"));
447             ret = true;
448             break;
450         case GDK_bracketleft:
451             persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::X, 180/snaps, MOD__ALT);
452             sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
453                              _("Change perspective (angle of PLs)"));
454             ret = true;
455             break;
457         case GDK_parenright:
458             persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Y, -180/snaps, MOD__ALT);
459             sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
460                              _("Change perspective (angle of PLs)"));
461             ret = true;
462             break;
464         case GDK_parenleft:
465             persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Y, 180/snaps, MOD__ALT);
466             sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
467                              _("Change perspective (angle of PLs)"));
468             ret = true;
469             break;
471         case GDK_braceright:
472             persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Z, -180/snaps, MOD__ALT);
473             sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
474                              _("Change perspective (angle of PLs)"));
475             ret = true;
476             break;
478         case GDK_braceleft:
479             persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Z, 180/snaps, MOD__ALT);
480             sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
481                              _("Change perspective (angle of PLs)"));
482             ret = true;
483             break;
485         case GDK_O:
486             if (MOD__CTRL && MOD__SHIFT) {
487                 Box3D::create_canvas_point(persp3d_get_VP(inkscape_active_document()->current_persp3d, Proj::W).affine(),
488                                            6, 0xff00ff00);
489             }
490             ret = true;
491             break;
493         case GDK_g:
494         case GDK_G:
495             if (MOD__SHIFT_ONLY) {
496                 sp_selection_to_guides();
497                 ret = true;
498             }
499             break;
501         case GDK_x:
502         case GDK_X:
503             if (MOD__ALT_ONLY) {
504                 desktop->setToolboxFocusTo ("altx-box3d");
505                 ret = TRUE;
506             }
507             if (MOD__SHIFT_ONLY) {
508                 persp3d_toggle_VPs(selection->perspList(), Proj::X);
509                 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
510                 ret = true;
511             }
512             break;
514         case GDK_y:
515         case GDK_Y:
516             if (MOD__SHIFT_ONLY) {
517                 persp3d_toggle_VPs(selection->perspList(), Proj::Y);
518                 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
519                 ret = true;
520             }
521             break;
523         case GDK_z:
524         case GDK_Z:
525             if (MOD__SHIFT_ONLY) {
526                 persp3d_toggle_VPs(selection->perspList(), Proj::Z);
527                 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
528                 ret = true;
529             }
530             break;
532         case GDK_Escape:
533             sp_desktop_selection(desktop)->clear();
534             //TODO: make dragging escapable by Esc
535             break;
537         case GDK_space:
538             if (dragging) {
539                 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
540                                       event->button.time);
541                 dragging = false;
542                 if (!event_context->within_tolerance) {
543                     // we've been dragging, finish the box
544                     sp_box3d_finish(bc);
545                 }
546                 // do not return true, so that space would work switching to selector
547             }
548             break;
550         default:
551             break;
552         }
553         break;
554     default:
555         break;
556     }
558     if (!ret) {
559         if (((SPEventContextClass *) parent_class)->root_handler) {
560             ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
561         }
562     }
564     return ret;
567 static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
569     SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop;
571     if (!bc.item) {
573         if (Inkscape::have_viable_layer(desktop, bc._message_context) == false) {
574             return;
575         }
577         /* Create object */
578         Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
579         Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
580         repr->setAttribute("sodipodi:type", "inkscape:box3d");
582         /* Set style */
583         sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.3dbox", false);
585         bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
586         Inkscape::GC::release(repr);
587         Inkscape::XML::Node *repr_side;
588         // TODO: Incorporate this in box3d-side.cpp!
589         for (int i = 0; i < 6; ++i) {
590             repr_side = xml_doc->createElement("svg:path");
591             repr_side->setAttribute("sodipodi:type", "inkscape:box3dside");
592             repr->addChild(repr_side, NULL);
594             Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side));
596             guint desc = Box3D::int_to_face(i);
598             Box3D::Axis plane = (Box3D::Axis) (desc & 0x7);
599             plane = (Box3D::is_plane(plane) ? plane : Box3D::orth_plane_or_axis(plane));
600             side->dir1 = Box3D::extract_first_axis_direction(plane);
601             side->dir2 = Box3D::extract_second_axis_direction(plane);
602             side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8);
604             /* Set style */
605             box3d_side_apply_style(side);
607             SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
608         }
610         box3d_set_z_orders(SP_BOX3D(bc.item));
611         bc.item->updateRepr();
613         // TODO: It would be nice to show the VPs during dragging, but since there is no selection
614         //       at this point (only after finishing the box), we must do this "manually"
615         /**** bc._vpdrag->updateDraggers(); ****/
617         sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
618     }
620     g_assert(bc.item);
622     SPBox3D *box = SP_BOX3D(bc.item);
624     box->orig_corner0 = bc.drag_origin_proj;
625     box->orig_corner7 = bc.drag_ptC_proj;
627     box3d_check_for_swapped_coords(box);
629     /* we need to call this from here (instead of from box3d_position_set(), for example)
630        because z-order setting must not interfere with display updates during undo/redo */
631     box3d_set_z_orders (box);
633     box3d_position_set(box);
635     // status text
636     bc._message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
639 static void sp_box3d_finish(Box3DContext *bc)
641     bc->_message_context->clear();
642     g_assert (SP_ACTIVE_DOCUMENT->current_persp3d);
644     if ( bc->item != NULL ) {
645         SPDesktop * desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
647         SPBox3D *box = SP_BOX3D(bc->item);
649         box->orig_corner0 = bc->drag_origin_proj;
650         box->orig_corner7 = bc->drag_ptC_proj;
652         box->updateRepr();
654         box3d_relabel_corners(box);
656         sp_canvas_end_forced_full_redraws(desktop->canvas);
658         sp_desktop_selection(desktop)->set(bc->item);
659         sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
660                          _("Create 3D box"));
662         bc->item = NULL;
663     }
665     bc->ctrl_dragged = false;
666     bc->extruded = false;
669 void sp_box3d_context_update_lines(SPEventContext *ec) {
670     /*  update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
671     if (SP_IS_BOX3D_CONTEXT (ec)) {
672         Box3DContext *bc = SP_BOX3D_CONTEXT (ec);
673         bc->_vpdrag->updateLines();
674     }
677 /*
678   Local Variables:
679   mode:c++
680   c-file-style:"stroustrup"
681   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
682   indent-tabs-mode:nil
683   fill-column:99
684   End:
685 */
686 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :