Code

Update current perspective when selection changes
[inkscape.git] / src / box3d-context.cpp
1 #define __SP_3DBOX_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 "desktop-handles.h"
28 #include "snap.h"
29 #include "display/curve.h"
30 #include "desktop.h"
31 #include "message-context.h"
32 #include "pixmaps/cursor-rect.xpm"
33 #include "box3d.h"
34 #include "box3d-context.h"
35 #include "sp-metrics.h"
36 #include <glibmm/i18n.h>
37 #include "object-edit.h"
38 #include "xml/repr.h"
39 #include "xml/node-event-vector.h"
40 #include "prefs-utils.h"
41 #include "context-fns.h"
43 static void sp_3dbox_context_class_init(SP3DBoxContextClass *klass);
44 static void sp_3dbox_context_init(SP3DBoxContext *box3d_context);
45 static void sp_3dbox_context_dispose(GObject *object);
47 static void sp_3dbox_context_setup(SPEventContext *ec);
48 static void sp_3dbox_context_set(SPEventContext *ec, gchar const *key, gchar const *val);
50 static gint sp_3dbox_context_root_handler(SPEventContext *event_context, GdkEvent *event);
51 static gint sp_3dbox_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
53 static void sp_3dbox_drag(SP3DBoxContext &bc, guint state);
54 static void sp_3dbox_finish(SP3DBoxContext *bc);
56 static SPEventContextClass *parent_class;
59 GtkType sp_3dbox_context_get_type()
60 {
61     static GType type = 0;
62     if (!type) {
63         GTypeInfo info = {
64             sizeof(SP3DBoxContextClass),
65             NULL, NULL,
66             (GClassInitFunc) sp_3dbox_context_class_init,
67             NULL, NULL,
68             sizeof(SP3DBoxContext),
69             4,
70             (GInstanceInitFunc) sp_3dbox_context_init,
71             NULL,    /* value_table */
72         };
73         type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SP3DBoxContext", &info, (GTypeFlags) 0);
74     }
75     return type;
76 }
78 static void sp_3dbox_context_class_init(SP3DBoxContextClass *klass)
79 {
80     GObjectClass *object_class = (GObjectClass *) klass;
81     SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
83     parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass);
85     object_class->dispose = sp_3dbox_context_dispose;
87     event_context_class->setup = sp_3dbox_context_setup;
88     event_context_class->set = sp_3dbox_context_set;
89     event_context_class->root_handler  = sp_3dbox_context_root_handler;
90     event_context_class->item_handler  = sp_3dbox_context_item_handler;
91 }
93 guint SP3DBoxContext::number_of_handles = 3;
95 static void sp_3dbox_context_init(SP3DBoxContext *box3d_context)
96 {
97     SPEventContext *event_context = SP_EVENT_CONTEXT(box3d_context);
99     event_context->cursor_shape = cursor_rect_xpm;
100     event_context->hot_x = 4;
101     event_context->hot_y = 4;
102     event_context->xp = 0;
103     event_context->yp = 0;
104     event_context->tolerance = 0;
105     event_context->within_tolerance = false;
106     event_context->item_to_select = NULL;
108     event_context->shape_repr = NULL;
109     event_context->shape_knot_holder = NULL;
111     box3d_context->item = NULL;
113     box3d_context->ctrl_dragged = false;
114     box3d_context->extruded = false;
115     
116     box3d_context->_vpdrag = NULL;
118     new (&box3d_context->sel_changed_connection) sigc::connection();
121 static void sp_3dbox_context_dispose(GObject *object)
123     SP3DBoxContext *bc = SP_3DBOX_CONTEXT(object);
124     SPEventContext *ec = SP_EVENT_CONTEXT(object);
126     ec->enableGrDrag(false);
128     delete (bc->_vpdrag);
129     bc->_vpdrag = NULL;
131     bc->sel_changed_connection.disconnect();
132     bc->sel_changed_connection.~connection();
134     /* fixme: This is necessary because we do not grab */
135     if (bc->item) {
136         sp_3dbox_finish(bc);
137     }
139     if (ec->shape_knot_holder) {
140         sp_knot_holder_destroy(ec->shape_knot_holder);
141         ec->shape_knot_holder = NULL;
142     }
144     if (ec->shape_repr) { // remove old listener
145         sp_repr_remove_listener_by_data(ec->shape_repr, ec);
146         Inkscape::GC::release(ec->shape_repr);
147         ec->shape_repr = 0;
148     }
150     if (bc->_message_context) {
151         delete bc->_message_context;
152     }
154     G_OBJECT_CLASS(parent_class)->dispose(object);
157 static Inkscape::XML::NodeEventVector ec_shape_repr_events = {
158     NULL, /* child_added */
159     NULL, /* child_removed */
160     ec_shape_event_attr_changed,
161     NULL, /* content_changed */
162     NULL  /* order_changed */
163 };
165 /**
166 \brief  Callback that processes the "changed" signal on the selection;
167 destroys old and creates new knotholder
168 */
169 void sp_3dbox_context_selection_changed(Inkscape::Selection *selection, gpointer data)
171     SP3DBoxContext *bc = SP_3DBOX_CONTEXT(data);
172     SPEventContext *ec = SP_EVENT_CONTEXT(bc);
174     if (ec->shape_knot_holder) { // destroy knotholder
175         sp_knot_holder_destroy(ec->shape_knot_holder);
176         ec->shape_knot_holder = NULL;
177     }
179     if (ec->shape_repr) { // remove old listener
180         sp_repr_remove_listener_by_data(ec->shape_repr, ec);
181         Inkscape::GC::release(ec->shape_repr);
182         ec->shape_repr = 0;
183     }
185     SPItem *item = selection->singleItem();
186     if (item) {
187         ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
188         Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
189         if (shape_repr) {
190             ec->shape_repr = shape_repr;
191             Inkscape::GC::anchor(shape_repr);
192             sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
193         }
194         if (SP_IS_3DBOX (item)) {
195             Box3D::Perspective3D::current_perspective = Box3D::get_persp_of_box (SP_3DBOX (item));
196         }
197     } else {
198         /* If several boxes sharing the same perspective are selected,
199            we can still set the current selection accordingly */
200         std::set<Box3D::Perspective3D *> perspectives;
201         for (GSList *i = (GSList *) selection->itemList(); i != NULL; i = i->next) {
202             if (SP_IS_3DBOX (i->data)) {
203                 perspectives.insert (Box3D::get_persp_of_box (SP_3DBOX (i->data)));
204             }
205         }
206         if (perspectives.size() == 1) {
207             Box3D::Perspective3D::current_perspective = *(perspectives.begin());
208         }
209         // TODO: What to do if several boxes with different perspectives are selected?
210     }
213 static void sp_3dbox_context_setup(SPEventContext *ec)
215     SP3DBoxContext *bc = SP_3DBOX_CONTEXT(ec);
217     if (((SPEventContextClass *) parent_class)->setup) {
218         ((SPEventContextClass *) parent_class)->setup(ec);
219     }
221     SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
222     if (item) {
223         ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
224         Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
225         if (shape_repr) {
226             ec->shape_repr = shape_repr;
227             Inkscape::GC::anchor(shape_repr);
228             sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
229         }
230     }
232     bc->sel_changed_connection.disconnect();
233     bc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(
234         sigc::bind(sigc::ptr_fun(&sp_3dbox_context_selection_changed), (gpointer)bc)
235     );
237     bc->_vpdrag = new Box3D::VPDrag(ec->desktop);
239     if (prefs_get_int_attribute("tools.shapes", "selcue", 0) != 0) {
240         ec->enableSelectionCue();
241     }
243     if (prefs_get_int_attribute("tools.shapes", "gradientdrag", 0) != 0) {
244         ec->enableGrDrag();
245     }
247     bc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
250 static void sp_3dbox_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
252     //SP3DBoxContext *bc = SP_3DBOX_CONTEXT(ec);
254     /* fixme: Proper error handling for non-numeric data.  Use a locale-independent function like
255      * g_ascii_strtod (or a thin wrapper that does the right thing for invalid values inf/nan). */
256     /**
257     if ( strcmp(key, "rx") == 0 ) {
258         bc->rx = ( val
259                          ? g_ascii_strtod (val, NULL)
260                          : 0.0 );
261     } else if ( strcmp(key, "ry") == 0 ) {
262         bc->ry = ( val
263                          ? g_ascii_strtod (val, NULL)
264                          : 0.0 );
265     }
266     **/
269 static gint sp_3dbox_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
271     SPDesktop *desktop = event_context->desktop;
273     gint ret = FALSE;
275     switch (event->type) {
276     case GDK_BUTTON_PRESS:
277         if ( event->button.button == 1 && !event_context->space_panning) {
278             Inkscape::setup_for_drag_start(desktop, event_context, event);
279             ret = TRUE;
280         }
281         break;
282         // motion and release are always on root (why?)
283     default:
284         break;
285     }
287     if (((SPEventContextClass *) parent_class)->item_handler) {
288         ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event);
289     }
291     return ret;
294 static gint sp_3dbox_context_root_handler(SPEventContext *event_context, GdkEvent *event)
296     static bool dragging;
298     SPDesktop *desktop = event_context->desktop;
299     Inkscape::Selection *selection = sp_desktop_selection (desktop);
301     SP3DBoxContext *bc = SP_3DBOX_CONTEXT(event_context);
303     event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
305     gint ret = FALSE;
306     switch (event->type) {
307     case GDK_BUTTON_PRESS:
308         if ( event->button.button == 1  && !event_context->space_panning) {
309             NR::Point const button_w(event->button.x,
310                                      event->button.y);
312             // save drag origin
313             event_context->xp = (gint) button_w[NR::X];
314             event_context->yp = (gint) button_w[NR::Y];
315             event_context->within_tolerance = true;
316             
317             // remember clicked item, disregarding groups, honoring Alt
318             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);
320             dragging = true;
321             
322             /* Position center */
323             NR::Point const button_dt(desktop->w2d(button_w));
324             bc->drag_origin = button_dt;
325             bc->drag_ptB = button_dt;
326             bc->drag_ptC = button_dt;
328             /* Snap center */
329             SnapManager const &m = desktop->namedview->snap_manager;
330             bc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE | Inkscape::Snapper::SNAPPOINT_BBOX,
331                                     button_dt, bc->item).getPoint();
333             sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
334                                 ( GDK_KEY_PRESS_MASK |
335                                   GDK_BUTTON_RELEASE_MASK       |
336                                   GDK_POINTER_MOTION_MASK       |
337                                   GDK_BUTTON_PRESS_MASK ),
338                                 NULL, event->button.time);
339             ret = TRUE;
340         }
341         break;
342     case GDK_MOTION_NOTIFY:
343         if ( dragging
344              && ( event->motion.state & GDK_BUTTON1_MASK )  && !event_context->space_panning)
345         {
346             if ( event_context->within_tolerance
347                  && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
348                  && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
349                 break; // do not drag if we're within tolerance from origin
350             }
351             // Once the user has moved farther than tolerance from the original location
352             // (indicating they intend to draw, not click), then always process the
353             // motion notify coordinates as given (no snapping back to origin)
354             event_context->within_tolerance = false;
356             NR::Point const motion_w(event->motion.x,
357                                      event->motion.y);
358             NR::Point motion_dt(desktop->w2d(motion_w));
360             SnapManager const &m = desktop->namedview->snap_manager;
361             motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_BBOX | Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, bc->item).getPoint();
363             bc->ctrl_dragged  = event->motion.state & GDK_CONTROL_MASK;
365             if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded) {
366                 /* once shift is pressed, set bc->extruded (no need to create further faces;
367                    all of them are already created in sp_3dbox_init) */
368                 bc->extruded = true;
369             }
371             if (!bc->extruded) {
372                 bc->drag_ptB = motion_dt;
373                 bc->drag_ptC = motion_dt;
374             } else {
375                 // Without Ctrl, motion of the extruded corner is constrained to the
376                 // perspective line from drag_ptB to vanishing point Y.
377                 if (!bc->ctrl_dragged) {
378                         bc->drag_ptC = Box3D::perspective_line_snap (bc->drag_ptB, Box3D::Z, motion_dt, Box3D::Perspective3D::current_perspective);
379                 } else {
380                     bc->drag_ptC = motion_dt;
381                 }
382                 bc->drag_ptC = m.freeSnap(Inkscape::Snapper::SNAPPOINT_BBOX | Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC, bc->item).getPoint();
383                 if (bc->ctrl_dragged) {
384                         Box3D::PerspectiveLine pl1 (NR::Point (event_context->xp, event_context->yp), Box3D::Y, Box3D::Perspective3D::current_perspective);
385                         Box3D::PerspectiveLine pl2 (bc->drag_ptB, Box3D::X, Box3D::Perspective3D::current_perspective);
386                         NR::Point corner1 = pl1.meet(pl2);
387                         
388                         Box3D::PerspectiveLine pl3 (corner1, Box3D::X, Box3D::Perspective3D::current_perspective);
389                         Box3D::PerspectiveLine pl4 (bc->drag_ptC, Box3D::Z, Box3D::Perspective3D::current_perspective);
390                         bc->drag_ptB = pl3.meet(pl4);
391                 }
392             }
393             
394             
395             sp_3dbox_drag(*bc, event->motion.state);
396             
397             ret = TRUE;
398         }
399         break;
400     case GDK_BUTTON_RELEASE:
401         event_context->xp = event_context->yp = 0;
402         if ( event->button.button == 1  && !event_context->space_panning) {
403             dragging = false;
405             if (!event_context->within_tolerance) {
406                 // we've been dragging, finish the box
407                 sp_3dbox_finish(bc);
408             } else if (event_context->item_to_select) {
409                 // no dragging, select clicked item if any
410                 if (event->button.state & GDK_SHIFT_MASK) {
411                     selection->toggle(event_context->item_to_select);
412                 } else {
413                     selection->set(event_context->item_to_select);
414                 }
415             } else {
416                 // click in an empty space
417                 selection->clear();
418             }
420             event_context->item_to_select = NULL;
421             ret = TRUE;
422             sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
423                                   event->button.time);
424         }
425         break;
426     case GDK_KEY_PRESS:
427         switch (get_group0_keyval (&event->key)) {
428         case GDK_Alt_L:
429         case GDK_Alt_R:
430         case GDK_Control_L:
431         case GDK_Control_R:
432         case GDK_Shift_L:
433         case GDK_Shift_R:
434         case GDK_Meta_L:  // Meta is when you press Shift+Alt (at least on my machine)
435         case GDK_Meta_R:
436             /***
437             if (!dragging){
438                 sp_event_show_modifier_tip (event_context->defaultMessageContext(), event,
439                                             _("<b>Ctrl</b>: make square or integer-ratio rect, lock a rounded corner circular"),
440                                             _("<b>Shift</b>: draw around the starting point"),
441                                             NULL);
442             }
443             ***/
444             break;
445         case GDK_Up:
446         case GDK_Down:
447         case GDK_KP_Up:
448         case GDK_KP_Down:
449             // prevent the zoom field from activation
450             if (!MOD__CTRL_ONLY)
451                 ret = TRUE;
452             break;
454         case GDK_I:
455             Box3D::Perspective3D::print_debugging_info();
456             ret = true;
457             break;
459         case GDK_L:
460         case GDK_l:
461             bc->_vpdrag->show_lines = !bc->_vpdrag->show_lines;
462             bc->_vpdrag->updateLines();
463             ret = true;
464             break;
466         case GDK_A:
467         case GDK_a:
468             if (MOD__CTRL) break; // Don't catch Ctrl+A ("select all")
469             if (bc->_vpdrag->show_lines) {
470                 bc->_vpdrag->front_or_rear_lines = bc->_vpdrag->front_or_rear_lines ^ 0x2; // toggle rear PLs
471             }
472             bc->_vpdrag->updateLines();
473             ret = true;
474             break;
476         case GDK_x:
477         case GDK_X:
478         {
479             if (MOD__CTRL) break; // Don't catch Ctrl+X ('cut') and Ctrl+Shift+X ('open XML editor')
480             // FIXME: Shouldn't we access _vpdrag->selection instead?
481             Inkscape::Selection *selection = sp_desktop_selection (bc->_vpdrag->desktop);
482             for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
483                 if (!SP_IS_3DBOX (i->data)) continue;
484                 sp_3dbox_switch_front_face (SP_3DBOX (i->data), Box3D::X);
485              }
486             bc->_vpdrag->updateLines();
487             ret = true;
488             break;
489         }
490  
491         case GDK_y:
492         case GDK_Y:
493         {
494             if (MOD__CTRL) break; // Don't catch Ctrl+Y ("redo")
495             // FIXME: Shouldn't we access _vpdrag->selection instead?
496             Inkscape::Selection *selection = sp_desktop_selection (bc->_vpdrag->desktop);
497             for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
498                 if (!SP_IS_3DBOX (i->data)) continue;
499                 sp_3dbox_switch_front_face (SP_3DBOX (i->data), Box3D::Y);
500             }
501             bc->_vpdrag->updateLines();
502             ret = true;
503             break;
504         }
506         case GDK_z:
507         case GDK_Z:
508         {
509             if (MOD__CTRL) break; // Don't catch Ctrl+Z ("undo")
510             // FIXME: Shouldn't we access _vpdrag->selection instead?
511             Inkscape::Selection *selection = sp_desktop_selection (bc->_vpdrag->desktop);
512             for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
513                 if (!SP_IS_3DBOX (i->data)) continue;
514                 sp_3dbox_switch_front_face (SP_3DBOX (i->data), Box3D::Z);
515             }
516             bc->_vpdrag->updateLines();
517             ret = true;
518             break;
519         }
521         case GDK_Escape:
522             sp_desktop_selection(desktop)->clear();
523             //TODO: make dragging escapable by Esc
524             break;
526         case GDK_space:
527             if (dragging) {
528                 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
529                                       event->button.time);
530                 dragging = false;
531                 if (!event_context->within_tolerance) {
532                     // we've been dragging, finish the box
533                     sp_3dbox_finish(bc);
534                 }
535                 // do not return true, so that space would work switching to selector
536             }
537             break;
539         default:
540             break;
541         }
542         break;
543     case GDK_KEY_RELEASE:
544         switch (get_group0_keyval (&event->key)) {
545         case GDK_Alt_L:
546         case GDK_Alt_R:
547         case GDK_Control_L:
548         case GDK_Control_R:
549         case GDK_Shift_L:
550         case GDK_Shift_R:
551         case GDK_Meta_L:  // Meta is when you press Shift+Alt
552         case GDK_Meta_R:
553             event_context->defaultMessageContext()->clear();
554             break;
555         default:
556             break;
557         }
558         break;
559     default:
560         break;
561     }
563     if (!ret) {
564         if (((SPEventContextClass *) parent_class)->root_handler) {
565             ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
566         }
567     }
569     return ret;
572 static void sp_3dbox_drag(SP3DBoxContext &bc, guint state)
574     SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop;
576     if (!bc.item) {
578         if (Inkscape::have_viable_layer(desktop, bc._message_context) == false) {
579             return;
580         }
582         /* Create object */
583         Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
584         Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
585         repr->setAttribute("sodipodi:type", "inkscape:3dbox");
587         /* Set style */
588         sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.3dbox", false);
590         bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
591         Inkscape::GC::release(repr);
592         bc.item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer());
594         /* Hook paths to the faces of the box */
595         for (int i = 0; i < 6; ++i) {
596             SP_3DBOX(bc.item)->faces[i]->hook_path_to_3dbox();
597         }
599         bc.item->updateRepr();
600         sp_3dbox_set_z_orders (SP_3DBOX (bc.item));
602         // TODO: It would be nice to show the VPs during dragging, but since there is no selection
603         //       at this point (only after finishing the box), we must do this "manually"
604         bc._vpdrag->updateDraggers();
606         sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
607     }
609     // FIXME: remove these extra points
610     NR::Point pt = bc.drag_ptB;
611     NR::Point shift_pt = bc.drag_ptC;
613     NR::Rect r;
614     if (!(state & GDK_SHIFT_MASK)) {
615         r = Inkscape::snap_rectangular_box(desktop, bc.item, pt, bc.center, state);
616     } else {
617         r = Inkscape::snap_rectangular_box(desktop, bc.item, shift_pt, bc.center, state);
618     }
620     SPEventContext *ec = SP_EVENT_CONTEXT(&bc);
621     NR::Point origin_w(ec->xp, ec->yp);
622     NR::Point origin(desktop->w2d(origin_w));
623     sp_3dbox_position_set(bc);
624     sp_3dbox_set_z_orders (SP_3DBOX (bc.item));
626     // status text
627     //GString *Ax = SP_PX_TO_METRIC_STRING(origin[NR::X], desktop->namedview->getDefaultMetric());
628     //GString *Ay = SP_PX_TO_METRIC_STRING(origin[NR::Y], desktop->namedview->getDefaultMetric());
629     bc._message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
630     //g_string_free(Ax, FALSE);
631     //g_string_free(Ay, FALSE);
634 static void sp_3dbox_finish(SP3DBoxContext *bc)
636     bc->_message_context->clear();
638     if ( bc->item != NULL ) {
639         SPDesktop * desktop;
641         desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
643         SP_OBJECT(bc->item)->updateRepr();
644         sp_3dbox_set_ratios(SP_3DBOX(bc->item));
646         sp_canvas_end_forced_full_redraws(desktop->canvas);
648         sp_desktop_selection(desktop)->set(bc->item);
649         sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
650                          _("Create 3D box"));
652         bc->item = NULL;
653     }
655     bc->ctrl_dragged = false;
656     bc->extruded = false;
659 /*
660   Local Variables:
661   mode:c++
662   c-file-style:"stroustrup"
663   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
664   indent-tabs-mode:nil
665   fill-column:99
666   End:
667 */
668 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :