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)
100 {
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;
120 box3d_context->_vpdrag = NULL;
122 new (&box3d_context->sel_changed_connection) sigc::connection();
123 }
125 static void sp_box3d_context_dispose(GObject *object)
126 {
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);
159 }
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)
174 {
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 SPDocument *doc = sp_desktop_document(bc->desktop);
190 doc->persps_sel.clear();
191 doc->persps_sel = persp3d_currently_selected_persps();
193 SPItem *item = selection->singleItem();
194 if (item) {
195 ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
196 Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
197 if (shape_repr) {
198 ec->shape_repr = shape_repr;
199 Inkscape::GC::anchor(shape_repr);
200 sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
201 }
202 }
204 if (doc->persps_sel.size() == 1) {
205 // selecting a single box changes the current perspective
206 doc->current_persp3d = *(doc->persps_sel.begin());
207 }
208 }
210 /* create a default perspective in document defs if none is present
211 (can happen after 'vacuum defs' or when a pre-0.46 file is opened) */
212 static void sp_box3d_context_check_for_persp_in_defs(SPDocument *document) {
213 SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
215 bool has_persp = false;
216 for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) {
217 if (SP_IS_PERSP3D(child)) {
218 has_persp = true;
219 break;
220 }
221 }
223 if (!has_persp) {
224 document->current_persp3d = persp3d_create_xml_element (document);
225 }
226 }
228 static void sp_box3d_context_setup(SPEventContext *ec)
229 {
230 Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
232 if (((SPEventContextClass *) parent_class)->setup) {
233 ((SPEventContextClass *) parent_class)->setup(ec);
234 }
236 sp_box3d_context_check_for_persp_in_defs(sp_desktop_document (ec->desktop));
238 SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
239 if (item) {
240 ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
241 Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
242 if (shape_repr) {
243 ec->shape_repr = shape_repr;
244 Inkscape::GC::anchor(shape_repr);
245 sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
246 }
247 }
249 bc->sel_changed_connection.disconnect();
250 bc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(
251 sigc::bind(sigc::ptr_fun(&sp_box3d_context_selection_changed), (gpointer)bc)
252 );
254 bc->_vpdrag = new Box3D::VPDrag(sp_desktop_document (ec->desktop));
256 if (prefs_get_int_attribute("tools.shapes", "selcue", 0) != 0) {
257 ec->enableSelectionCue();
258 }
260 if (prefs_get_int_attribute("tools.shapes", "gradientdrag", 0) != 0) {
261 ec->enableGrDrag();
262 }
264 bc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
265 }
267 static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
268 {
269 SPDesktop *desktop = event_context->desktop;
271 gint ret = FALSE;
273 switch (event->type) {
274 case GDK_BUTTON_PRESS:
275 if ( event->button.button == 1 && !event_context->space_panning) {
276 Inkscape::setup_for_drag_start(desktop, event_context, event);
277 ret = TRUE;
278 }
279 break;
280 // motion and release are always on root (why?)
281 default:
282 break;
283 }
285 if (((SPEventContextClass *) parent_class)->item_handler) {
286 ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event);
287 }
289 return ret;
290 }
292 static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEvent *event)
293 {
294 static bool dragging;
296 SPDesktop *desktop = event_context->desktop;
297 Inkscape::Selection *selection = sp_desktop_selection (desktop);
298 int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12);
300 Box3DContext *bc = SP_BOX3D_CONTEXT(event_context);
301 g_assert (SP_ACTIVE_DOCUMENT->current_persp3d);
302 Persp3D *cur_persp = SP_ACTIVE_DOCUMENT->current_persp3d;
304 event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
306 gint ret = FALSE;
307 switch (event->type) {
308 case GDK_BUTTON_PRESS:
309 if ( event->button.button == 1 && !event_context->space_panning) {
310 NR::Point const button_w(event->button.x,
311 event->button.y);
313 // save drag origin
314 event_context->xp = (gint) button_w[NR::X];
315 event_context->yp = (gint) button_w[NR::Y];
316 event_context->within_tolerance = true;
318 // remember clicked item, *not* disregarding groups (since a 3D box is a group), honoring Alt
319 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);
321 dragging = true;
323 /* */
324 NR::Point const button_dt(desktop->w2d(button_w));
325 bc->drag_origin = button_dt;
326 bc->drag_ptB = button_dt;
327 bc->drag_ptC = button_dt;
329 /* Projective preimages of clicked point under current perspective */
330 bc->drag_origin_proj = cur_persp->tmat.preimage (button_dt, 0, Proj::Z);
331 bc->drag_ptB_proj = bc->drag_origin_proj;
332 bc->drag_ptC_proj = bc->drag_origin_proj;
333 bc->drag_ptC_proj.normalize();
334 bc->drag_ptC_proj[Proj::Z] = 0.25;
336 /* Snap center */
337 SnapManager const &m = desktop->namedview->snap_manager;
338 bc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE,
339 button_dt, bc->item).getPoint();
341 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
342 ( GDK_KEY_PRESS_MASK |
343 GDK_BUTTON_RELEASE_MASK |
344 GDK_POINTER_MOTION_MASK |
345 GDK_BUTTON_PRESS_MASK ),
346 NULL, event->button.time);
347 ret = TRUE;
348 }
349 break;
350 case GDK_MOTION_NOTIFY:
351 if ( dragging
352 && ( event->motion.state & GDK_BUTTON1_MASK ) && !event_context->space_panning)
353 {
354 if ( event_context->within_tolerance
355 && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
356 && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
357 break; // do not drag if we're within tolerance from origin
358 }
359 // Once the user has moved farther than tolerance from the original location
360 // (indicating they intend to draw, not click), then always process the
361 // motion notify coordinates as given (no snapping back to origin)
362 event_context->within_tolerance = false;
364 NR::Point const motion_w(event->motion.x,
365 event->motion.y);
366 NR::Point motion_dt(desktop->w2d(motion_w));
368 SnapManager const &m = desktop->namedview->snap_manager;
369 motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, bc->item).getPoint();
371 bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK;
373 if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded && bc->item) {
374 // once shift is pressed, set bc->extruded
375 bc->extruded = true;
376 }
378 if (!bc->extruded) {
379 bc->drag_ptB = motion_dt;
380 bc->drag_ptC = motion_dt;
382 bc->drag_ptB_proj = cur_persp->tmat.preimage (motion_dt, 0, Proj::Z);
383 bc->drag_ptC_proj = bc->drag_ptB_proj;
384 bc->drag_ptC_proj.normalize();
385 bc->drag_ptC_proj[Proj::Z] = 0.25;
386 } else {
387 // Without Ctrl, motion of the extruded corner is constrained to the
388 // perspective line from drag_ptB to vanishing point Y.
389 if (!bc->ctrl_dragged) {
390 /* snapping */
391 Box3D::PerspectiveLine pline (bc->drag_ptB, Proj::Z, SP_ACTIVE_DOCUMENT->current_persp3d);
392 bc->drag_ptC = pline.closest_to (motion_dt);
394 bc->drag_ptB_proj.normalize();
395 bc->drag_ptC_proj = cur_persp->tmat.preimage (bc->drag_ptC, bc->drag_ptB_proj[Proj::X], Proj::X);
396 } else {
397 bc->drag_ptC = motion_dt;
399 bc->drag_ptB_proj.normalize();
400 bc->drag_ptC_proj = cur_persp->tmat.preimage (motion_dt, bc->drag_ptB_proj[Proj::X], Proj::X);
401 }
402 bc->drag_ptC = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC, bc->item).getPoint();
403 }
405 sp_box3d_drag(*bc, event->motion.state);
407 ret = TRUE;
408 }
409 break;
410 case GDK_BUTTON_RELEASE:
411 event_context->xp = event_context->yp = 0;
412 if ( event->button.button == 1 && !event_context->space_panning) {
413 dragging = false;
415 if (!event_context->within_tolerance) {
416 // we've been dragging, finish the box
417 sp_box3d_finish(bc);
418 } else if (event_context->item_to_select) {
419 // no dragging, select clicked item if any
420 if (event->button.state & GDK_SHIFT_MASK) {
421 selection->toggle(event_context->item_to_select);
422 } else {
423 selection->set(event_context->item_to_select);
424 }
425 } else {
426 // click in an empty space
427 selection->clear();
428 }
430 event_context->item_to_select = NULL;
431 ret = TRUE;
432 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
433 event->button.time);
434 }
435 break;
436 case GDK_KEY_PRESS:
437 switch (get_group0_keyval (&event->key)) {
438 case GDK_Up:
439 case GDK_Down:
440 case GDK_KP_Up:
441 case GDK_KP_Down:
442 // prevent the zoom field from activation
443 if (!MOD__CTRL_ONLY)
444 ret = TRUE;
445 break;
447 case GDK_bracketright:
448 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::X, -180/snaps, MOD__ALT);
449 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
450 _("Change perspective (angle of PLs)"));
451 ret = true;
452 break;
454 case GDK_bracketleft:
455 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::X, 180/snaps, MOD__ALT);
456 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
457 _("Change perspective (angle of PLs)"));
458 ret = true;
459 break;
461 case GDK_parenright:
462 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Y, -180/snaps, MOD__ALT);
463 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
464 _("Change perspective (angle of PLs)"));
465 ret = true;
466 break;
468 case GDK_parenleft:
469 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Y, 180/snaps, MOD__ALT);
470 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
471 _("Change perspective (angle of PLs)"));
472 ret = true;
473 break;
475 case GDK_braceright:
476 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Z, -180/snaps, MOD__ALT);
477 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
478 _("Change perspective (angle of PLs)"));
479 ret = true;
480 break;
482 case GDK_braceleft:
483 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Z, 180/snaps, MOD__ALT);
484 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
485 _("Change perspective (angle of PLs)"));
486 ret = true;
487 break;
489 case GDK_O:
490 if (MOD__CTRL && MOD__SHIFT) {
491 Box3D::create_canvas_point(persp3d_get_VP(inkscape_active_document()->current_persp3d, Proj::W).affine(),
492 6, 0xff00ff00);
493 }
494 ret = true;
495 break;
497 case GDK_g:
498 case GDK_G:
499 if (MOD__SHIFT_ONLY) {
500 sp_selection_to_guides();
501 ret = true;
502 }
503 break;
505 case GDK_x:
506 case GDK_X:
507 if (MOD__ALT_ONLY) {
508 desktop->setToolboxFocusTo ("altx-box3d");
509 ret = TRUE;
510 }
511 if (MOD__SHIFT_ONLY) {
512 persp3d_toggle_VPs(persp3d_currently_selected_persps(), Proj::X);
513 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
514 ret = true;
515 }
516 break;
518 case GDK_y:
519 case GDK_Y:
520 if (MOD__SHIFT_ONLY) {
521 persp3d_toggle_VPs(persp3d_currently_selected_persps(), Proj::Y);
522 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
523 ret = true;
524 }
525 break;
527 case GDK_z:
528 case GDK_Z:
529 if (MOD__SHIFT_ONLY) {
530 persp3d_toggle_VPs(persp3d_currently_selected_persps(), Proj::Z);
531 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
532 ret = true;
533 }
534 break;
536 case GDK_Escape:
537 sp_desktop_selection(desktop)->clear();
538 //TODO: make dragging escapable by Esc
539 break;
541 case GDK_space:
542 if (dragging) {
543 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
544 event->button.time);
545 dragging = false;
546 if (!event_context->within_tolerance) {
547 // we've been dragging, finish the box
548 sp_box3d_finish(bc);
549 }
550 // do not return true, so that space would work switching to selector
551 }
552 break;
554 default:
555 break;
556 }
557 break;
558 default:
559 break;
560 }
562 if (!ret) {
563 if (((SPEventContextClass *) parent_class)->root_handler) {
564 ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
565 }
566 }
568 return ret;
569 }
571 static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
572 {
573 SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop;
575 if (!bc.item) {
577 if (Inkscape::have_viable_layer(desktop, bc._message_context) == false) {
578 return;
579 }
581 /* Create object */
582 Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
583 Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
584 repr->setAttribute("sodipodi:type", "inkscape:box3d");
586 /* Set style */
587 sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.3dbox", false);
589 bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
590 Inkscape::GC::release(repr);
591 Inkscape::XML::Node *repr_side;
592 // TODO: Incorporate this in box3d-side.cpp!
593 for (int i = 0; i < 6; ++i) {
594 repr_side = xml_doc->createElement("svg:path");
595 repr_side->setAttribute("sodipodi:type", "inkscape:box3dside");
596 repr->addChild(repr_side, NULL);
598 Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side));
600 guint desc = Box3D::int_to_face(i);
602 Box3D::Axis plane = (Box3D::Axis) (desc & 0x7);
603 plane = (Box3D::is_plane(plane) ? plane : Box3D::orth_plane_or_axis(plane));
604 side->dir1 = Box3D::extract_first_axis_direction(plane);
605 side->dir2 = Box3D::extract_second_axis_direction(plane);
606 side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8);
608 /* Set style */
609 box3d_side_apply_style(side);
611 SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
612 }
614 box3d_set_z_orders(SP_BOX3D(bc.item));
615 bc.item->updateRepr();
617 // TODO: It would be nice to show the VPs during dragging, but since there is no selection
618 // at this point (only after finishing the box), we must do this "manually"
619 /**** bc._vpdrag->updateDraggers(); ****/
621 sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
622 }
624 g_assert(bc.item);
626 SPBox3D *box = SP_BOX3D(bc.item);
628 box->orig_corner0 = bc.drag_origin_proj;
629 box->orig_corner7 = bc.drag_ptC_proj;
631 box3d_check_for_swapped_coords(box);
633 /* we need to call this from here (instead of from box3d_position_set(), for example)
634 because z-order setting must not interfere with display updates during undo/redo */
635 box3d_set_z_orders (box);
637 box3d_position_set(box);
639 // status text
640 bc._message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
641 }
643 static void sp_box3d_finish(Box3DContext *bc)
644 {
645 bc->_message_context->clear();
646 g_assert (SP_ACTIVE_DOCUMENT->current_persp3d);
648 if ( bc->item != NULL ) {
649 SPDesktop * desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
651 SPBox3D *box = SP_BOX3D(bc->item);
653 box->orig_corner0 = bc->drag_origin_proj;
654 box->orig_corner7 = bc->drag_ptC_proj;
656 box->updateRepr();
658 box3d_relabel_corners(box);
660 sp_canvas_end_forced_full_redraws(desktop->canvas);
662 sp_desktop_selection(desktop)->set(bc->item);
663 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
664 _("Create 3D box"));
666 bc->item = NULL;
667 }
669 bc->ctrl_dragged = false;
670 bc->extruded = false;
671 }
673 /*
674 Local Variables:
675 mode:c++
676 c-file-style:"stroustrup"
677 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
678 indent-tabs-mode:nil
679 fill-column:99
680 End:
681 */
682 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :