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 delete 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 delete 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 }
204 }
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 }
222 }
224 static void sp_box3d_context_setup(SPEventContext *ec)
225 {
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());
261 }
263 static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
264 {
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;
286 }
288 static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEvent *event)
289 {
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;
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;
319 /* */
320 NR::Point 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 &m = desktop->namedview->snap_manager;
334 m.setup(desktop, bc->item);
335 m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, button_dt);
336 bc->center = button_dt;
338 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
339 ( GDK_KEY_PRESS_MASK |
340 GDK_BUTTON_RELEASE_MASK |
341 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
342 GDK_BUTTON_PRESS_MASK ),
343 NULL, event->button.time);
344 ret = TRUE;
345 }
346 break;
347 case GDK_MOTION_NOTIFY:
348 if ( dragging
349 && ( event->motion.state & GDK_BUTTON1_MASK ) && !event_context->space_panning)
350 {
351 if ( event_context->within_tolerance
352 && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
353 && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
354 break; // do not drag if we're within tolerance from origin
355 }
356 // Once the user has moved farther than tolerance from the original location
357 // (indicating they intend to draw, not click), then always process the
358 // motion notify coordinates as given (no snapping back to origin)
359 event_context->within_tolerance = false;
361 NR::Point const motion_w(event->motion.x,
362 event->motion.y);
363 NR::Point motion_dt(desktop->w2d(motion_w));
365 SnapManager &m = desktop->namedview->snap_manager;
366 m.setup(desktop, bc->item);
367 m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt);
369 bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK;
371 if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded && bc->item) {
372 // once shift is pressed, set bc->extruded
373 bc->extruded = true;
374 }
376 if (!bc->extruded) {
377 bc->drag_ptB = motion_dt;
378 bc->drag_ptC = motion_dt;
380 bc->drag_ptB_proj = cur_persp->tmat.preimage (motion_dt, 0, Proj::Z);
381 bc->drag_ptC_proj = bc->drag_ptB_proj;
382 bc->drag_ptC_proj.normalize();
383 bc->drag_ptC_proj[Proj::Z] = 0.25;
384 } else {
385 // Without Ctrl, motion of the extruded corner is constrained to the
386 // perspective line from drag_ptB to vanishing point Y.
387 if (!bc->ctrl_dragged) {
388 /* snapping */
389 Box3D::PerspectiveLine pline (bc->drag_ptB, Proj::Z, SP_ACTIVE_DOCUMENT->current_persp3d);
390 bc->drag_ptC = pline.closest_to (motion_dt);
392 bc->drag_ptB_proj.normalize();
393 bc->drag_ptC_proj = cur_persp->tmat.preimage (bc->drag_ptC, bc->drag_ptB_proj[Proj::X], Proj::X);
394 } else {
395 bc->drag_ptC = motion_dt;
397 bc->drag_ptB_proj.normalize();
398 bc->drag_ptC_proj = cur_persp->tmat.preimage (motion_dt, bc->drag_ptB_proj[Proj::X], Proj::X);
399 }
400 m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, bc->drag_ptC);
401 }
403 sp_box3d_drag(*bc, event->motion.state);
405 ret = TRUE;
406 }
407 break;
408 case GDK_BUTTON_RELEASE:
409 event_context->xp = event_context->yp = 0;
410 if ( event->button.button == 1 && !event_context->space_panning) {
411 dragging = false;
413 if (!event_context->within_tolerance) {
414 // we've been dragging, finish the box
415 sp_box3d_finish(bc);
416 } else if (event_context->item_to_select) {
417 // no dragging, select clicked item if any
418 if (event->button.state & GDK_SHIFT_MASK) {
419 selection->toggle(event_context->item_to_select);
420 } else {
421 selection->set(event_context->item_to_select);
422 }
423 } else {
424 // click in an empty space
425 selection->clear();
426 }
428 event_context->item_to_select = NULL;
429 ret = TRUE;
430 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
431 event->button.time);
432 }
433 break;
434 case GDK_KEY_PRESS:
435 switch (get_group0_keyval (&event->key)) {
436 case GDK_Up:
437 case GDK_Down:
438 case GDK_KP_Up:
439 case GDK_KP_Down:
440 // prevent the zoom field from activation
441 if (!MOD__CTRL_ONLY)
442 ret = TRUE;
443 break;
445 case GDK_bracketright:
446 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::X, -180/snaps, MOD__ALT);
447 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
448 _("Change perspective (angle of PLs)"));
449 ret = true;
450 break;
452 case GDK_bracketleft:
453 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::X, 180/snaps, MOD__ALT);
454 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
455 _("Change perspective (angle of PLs)"));
456 ret = true;
457 break;
459 case GDK_parenright:
460 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Y, -180/snaps, MOD__ALT);
461 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
462 _("Change perspective (angle of PLs)"));
463 ret = true;
464 break;
466 case GDK_parenleft:
467 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Y, 180/snaps, MOD__ALT);
468 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
469 _("Change perspective (angle of PLs)"));
470 ret = true;
471 break;
473 case GDK_braceright:
474 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Z, -180/snaps, MOD__ALT);
475 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
476 _("Change perspective (angle of PLs)"));
477 ret = true;
478 break;
480 case GDK_braceleft:
481 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Z, 180/snaps, MOD__ALT);
482 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
483 _("Change perspective (angle of PLs)"));
484 ret = true;
485 break;
487 case GDK_O:
488 if (MOD__CTRL && MOD__SHIFT) {
489 Box3D::create_canvas_point(persp3d_get_VP(inkscape_active_document()->current_persp3d, Proj::W).affine(),
490 6, 0xff00ff00);
491 }
492 ret = true;
493 break;
495 case GDK_g:
496 case GDK_G:
497 if (MOD__SHIFT_ONLY) {
498 sp_selection_to_guides();
499 ret = true;
500 }
501 break;
503 case GDK_x:
504 case GDK_X:
505 if (MOD__ALT_ONLY) {
506 desktop->setToolboxFocusTo ("altx-box3d");
507 ret = TRUE;
508 }
509 if (MOD__SHIFT_ONLY) {
510 persp3d_toggle_VPs(selection->perspList(), Proj::X);
511 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
512 ret = true;
513 }
514 break;
516 case GDK_y:
517 case GDK_Y:
518 if (MOD__SHIFT_ONLY) {
519 persp3d_toggle_VPs(selection->perspList(), Proj::Y);
520 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
521 ret = true;
522 }
523 break;
525 case GDK_z:
526 case GDK_Z:
527 if (MOD__SHIFT_ONLY) {
528 persp3d_toggle_VPs(selection->perspList(), Proj::Z);
529 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
530 ret = true;
531 }
532 break;
534 case GDK_Escape:
535 sp_desktop_selection(desktop)->clear();
536 //TODO: make dragging escapable by Esc
537 break;
539 case GDK_space:
540 if (dragging) {
541 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
542 event->button.time);
543 dragging = false;
544 if (!event_context->within_tolerance) {
545 // we've been dragging, finish the box
546 sp_box3d_finish(bc);
547 }
548 // do not return true, so that space would work switching to selector
549 }
550 break;
552 default:
553 break;
554 }
555 break;
556 default:
557 break;
558 }
560 if (!ret) {
561 if (((SPEventContextClass *) parent_class)->root_handler) {
562 ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
563 }
564 }
566 return ret;
567 }
569 static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
570 {
571 SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop;
573 if (!bc.item) {
575 if (Inkscape::have_viable_layer(desktop, bc._message_context) == false) {
576 return;
577 }
579 /* Create object */
580 Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
581 Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
582 repr->setAttribute("sodipodi:type", "inkscape:box3d");
584 /* Set style */
585 sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.3dbox", false);
587 bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
588 Inkscape::GC::release(repr);
589 Inkscape::XML::Node *repr_side;
590 // TODO: Incorporate this in box3d-side.cpp!
591 for (int i = 0; i < 6; ++i) {
592 repr_side = xml_doc->createElement("svg:path");
593 repr_side->setAttribute("sodipodi:type", "inkscape:box3dside");
594 repr->addChild(repr_side, NULL);
596 Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side));
598 guint desc = Box3D::int_to_face(i);
600 Box3D::Axis plane = (Box3D::Axis) (desc & 0x7);
601 plane = (Box3D::is_plane(plane) ? plane : Box3D::orth_plane_or_axis(plane));
602 side->dir1 = Box3D::extract_first_axis_direction(plane);
603 side->dir2 = Box3D::extract_second_axis_direction(plane);
604 side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8);
606 /* Set style */
607 box3d_side_apply_style(side);
609 SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
610 }
612 box3d_set_z_orders(SP_BOX3D(bc.item));
613 bc.item->updateRepr();
615 // TODO: It would be nice to show the VPs during dragging, but since there is no selection
616 // at this point (only after finishing the box), we must do this "manually"
617 /**** bc._vpdrag->updateDraggers(); ****/
619 sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
620 }
622 g_assert(bc.item);
624 SPBox3D *box = SP_BOX3D(bc.item);
626 box->orig_corner0 = bc.drag_origin_proj;
627 box->orig_corner7 = bc.drag_ptC_proj;
629 box3d_check_for_swapped_coords(box);
631 /* we need to call this from here (instead of from box3d_position_set(), for example)
632 because z-order setting must not interfere with display updates during undo/redo */
633 box3d_set_z_orders (box);
635 box3d_position_set(box);
637 // status text
638 bc._message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
639 }
641 static void sp_box3d_finish(Box3DContext *bc)
642 {
643 bc->_message_context->clear();
644 g_assert (SP_ACTIVE_DOCUMENT->current_persp3d);
646 if ( bc->item != NULL ) {
647 SPDesktop * desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
649 SPBox3D *box = SP_BOX3D(bc->item);
651 box->orig_corner0 = bc->drag_origin_proj;
652 box->orig_corner7 = bc->drag_ptC_proj;
654 box->updateRepr();
656 box3d_relabel_corners(box);
658 sp_canvas_end_forced_full_redraws(desktop->canvas);
660 sp_desktop_selection(desktop)->set(bc->item);
661 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
662 _("Create 3D box"));
664 bc->item = NULL;
665 }
667 bc->ctrl_dragged = false;
668 bc->extruded = false;
669 }
671 void sp_box3d_context_update_lines(SPEventContext *ec) {
672 /* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
673 if (SP_IS_BOX3D_CONTEXT (ec)) {
674 Box3DContext *bc = SP_BOX3D_CONTEXT (ec);
675 bc->_vpdrag->updateLines();
676 }
677 }
679 /*
680 Local Variables:
681 mode:c++
682 c-file-style:"stroustrup"
683 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
684 indent-tabs-mode:nil
685 fill-column:99
686 End:
687 */
688 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :