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 "preferences.h"
42 #include "context-fns.h"
43 #include "desktop-style.h"
44 #include "transf_mat_3x4.h"
45 #include "perspective-line.h"
46 #include "persp3d.h"
47 #include "box3d-side.h"
48 #include "document-private.h"
49 #include "line-geometry.h"
50 #include "shape-editor.h"
52 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);
57 static void sp_box3d_context_finish(SPEventContext *ec);
59 static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEvent *event);
60 static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
62 static void sp_box3d_drag(Box3DContext &bc, guint state);
63 static void sp_box3d_finish(Box3DContext *bc);
65 static SPEventContextClass *parent_class;
67 GtkType sp_box3d_context_get_type()
68 {
69 static GType type = 0;
70 if (!type) {
71 GTypeInfo info = {
72 sizeof(Box3DContextClass),
73 NULL, NULL,
74 (GClassInitFunc) sp_box3d_context_class_init,
75 NULL, NULL,
76 sizeof(Box3DContext),
77 4,
78 (GInstanceInitFunc) sp_box3d_context_init,
79 NULL, /* value_table */
80 };
81 type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "Box3DContext", &info, (GTypeFlags) 0);
82 }
83 return type;
84 }
86 static void sp_box3d_context_class_init(Box3DContextClass *klass)
87 {
88 GObjectClass *object_class = (GObjectClass *) klass;
89 SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
91 parent_class = (SPEventContextClass *) g_type_class_peek_parent(klass);
93 object_class->dispose = sp_box3d_context_dispose;
95 event_context_class->setup = sp_box3d_context_setup;
96 event_context_class->finish = sp_box3d_context_finish;
97 event_context_class->root_handler = sp_box3d_context_root_handler;
98 event_context_class->item_handler = sp_box3d_context_item_handler;
99 }
101 static void sp_box3d_context_init(Box3DContext *box3d_context)
102 {
103 SPEventContext *event_context = SP_EVENT_CONTEXT(box3d_context);
105 event_context->cursor_shape = cursor_3dbox_xpm;
106 event_context->hot_x = 4;
107 event_context->hot_y = 4;
108 event_context->xp = 0;
109 event_context->yp = 0;
110 event_context->tolerance = 0;
111 event_context->within_tolerance = false;
112 event_context->item_to_select = NULL;
114 box3d_context->item = NULL;
116 box3d_context->ctrl_dragged = false;
117 box3d_context->extruded = false;
119 box3d_context->_vpdrag = NULL;
121 new (&box3d_context->sel_changed_connection) sigc::connection();
122 }
124 static void sp_box3d_context_finish(SPEventContext *ec)
125 {
126 Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
127 SPDesktop *desktop = ec->desktop;
129 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
130 sp_box3d_finish(bc);
131 bc->sel_changed_connection.disconnect();
133 if (((SPEventContextClass *) parent_class)->finish) {
134 ((SPEventContextClass *) parent_class)->finish(ec);
135 }
136 }
139 static void sp_box3d_context_dispose(GObject *object)
140 {
141 Box3DContext *bc = SP_BOX3D_CONTEXT(object);
142 SPEventContext *ec = SP_EVENT_CONTEXT(object);
144 ec->enableGrDrag(false);
146 delete (bc->_vpdrag);
147 bc->_vpdrag = NULL;
149 bc->sel_changed_connection.disconnect();
150 bc->sel_changed_connection.~connection();
152 delete ec->shape_editor;
153 ec->shape_editor = NULL;
155 /* fixme: This is necessary because we do not grab */
156 if (bc->item) {
157 sp_box3d_finish(bc);
158 }
160 if (bc->_message_context) {
161 delete bc->_message_context;
162 }
164 G_OBJECT_CLASS(parent_class)->dispose(object);
165 }
167 /**
168 \brief Callback that processes the "changed" signal on the selection;
169 destroys old and creates new knotholder
170 */
171 static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, gpointer data)
172 {
173 Box3DContext *bc = SP_BOX3D_CONTEXT(data);
174 SPEventContext *ec = SP_EVENT_CONTEXT(bc);
176 ec->shape_editor->unset_item(SH_KNOTHOLDER);
177 SPItem *item = selection->singleItem();
178 ec->shape_editor->set_item(item, SH_KNOTHOLDER);
180 if (selection->perspList().size() == 1) {
181 // selecting a single box changes the current perspective
182 ec->desktop->doc()->current_persp3d = selection->perspList().front();
183 }
184 }
186 /* create a default perspective in document defs if none is present
187 (can happen after 'vacuum defs' or when a pre-0.46 file is opened) */
188 static void sp_box3d_context_check_for_persp_in_defs(SPDocument *document) {
189 SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
191 bool has_persp = false;
192 for (SPObject *child = sp_object_first_child(defs); child != NULL; child = SP_OBJECT_NEXT(child) ) {
193 if (SP_IS_PERSP3D(child)) {
194 has_persp = true;
195 break;
196 }
197 }
199 if (!has_persp) {
200 document->current_persp3d = persp3d_create_xml_element (document);
201 }
202 }
204 static void sp_box3d_context_setup(SPEventContext *ec)
205 {
206 Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
208 if (((SPEventContextClass *) parent_class)->setup) {
209 ((SPEventContextClass *) parent_class)->setup(ec);
210 }
212 sp_box3d_context_check_for_persp_in_defs(sp_desktop_document (ec->desktop));
214 ec->shape_editor = new ShapeEditor(ec->desktop);
216 SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
217 if (item) {
218 ec->shape_editor->set_item(item, SH_KNOTHOLDER);
219 }
221 bc->sel_changed_connection.disconnect();
222 bc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(
223 sigc::bind(sigc::ptr_fun(&sp_box3d_context_selection_changed), (gpointer)bc)
224 );
226 bc->_vpdrag = new Box3D::VPDrag(sp_desktop_document (ec->desktop));
227 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
229 if (prefs->getBool("/tools/shapes/selcue")) {
230 ec->enableSelectionCue();
231 }
233 if (prefs->getBool("/tools/shapes/gradientdrag")) {
234 ec->enableGrDrag();
235 }
237 bc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
238 }
240 static gint sp_box3d_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
241 {
242 SPDesktop *desktop = event_context->desktop;
244 gint ret = FALSE;
246 switch (event->type) {
247 case GDK_BUTTON_PRESS:
248 if ( event->button.button == 1 && !event_context->space_panning) {
249 Inkscape::setup_for_drag_start(desktop, event_context, event);
250 ret = TRUE;
251 }
252 break;
253 // motion and release are always on root (why?)
254 default:
255 break;
256 }
258 if (((SPEventContextClass *) parent_class)->item_handler) {
259 ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event);
260 }
262 return ret;
263 }
265 static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEvent *event)
266 {
267 static bool dragging;
269 SPDesktop *desktop = event_context->desktop;
270 Inkscape::Selection *selection = sp_desktop_selection (desktop);
271 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
272 int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
274 Box3DContext *bc = SP_BOX3D_CONTEXT(event_context);
275 g_assert (SP_ACTIVE_DOCUMENT->current_persp3d);
276 Persp3D *cur_persp = SP_ACTIVE_DOCUMENT->current_persp3d;
278 event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
280 gint ret = FALSE;
281 switch (event->type) {
282 case GDK_BUTTON_PRESS:
283 if ( event->button.button == 1 && !event_context->space_panning) {
284 Geom::Point const button_w(event->button.x,
285 event->button.y);
287 // save drag origin
288 event_context->xp = (gint) button_w[Geom::X];
289 event_context->yp = (gint) button_w[Geom::Y];
290 event_context->within_tolerance = true;
292 // remember clicked item, *not* disregarding groups (since a 3D box is a group), honoring Alt
293 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);
295 dragging = true;
297 /* */
298 Geom::Point button_dt(desktop->w2d(button_w));
299 bc->drag_origin = from_2geom(button_dt);
300 bc->drag_ptB = from_2geom(button_dt);
301 bc->drag_ptC = from_2geom(button_dt);
303 /* Projective preimages of clicked point under current perspective */
304 bc->drag_origin_proj = cur_persp->tmat.preimage (from_2geom(button_dt), 0, Proj::Z);
305 bc->drag_ptB_proj = bc->drag_origin_proj;
306 bc->drag_ptC_proj = bc->drag_origin_proj;
307 bc->drag_ptC_proj.normalize();
308 bc->drag_ptC_proj[Proj::Z] = 0.25;
310 /* Snap center */
311 SnapManager &m = desktop->namedview->snap_manager;
312 m.setup(desktop, true, bc->item);
313 m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, button_dt, Inkscape::SNAPSOURCE_HANDLE);
314 bc->center = from_2geom(button_dt);
316 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
317 ( GDK_KEY_PRESS_MASK |
318 GDK_BUTTON_RELEASE_MASK |
319 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
320 GDK_BUTTON_PRESS_MASK ),
321 NULL, event->button.time);
322 ret = TRUE;
323 }
324 break;
325 case GDK_MOTION_NOTIFY:
326 if ( dragging
327 && ( event->motion.state & GDK_BUTTON1_MASK ) && !event_context->space_panning)
328 {
329 if ( event_context->within_tolerance
330 && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
331 && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
332 break; // do not drag if we're within tolerance from origin
333 }
334 // Once the user has moved farther than tolerance from the original location
335 // (indicating they intend to draw, not click), then always process the
336 // motion notify coordinates as given (no snapping back to origin)
337 event_context->within_tolerance = false;
339 Geom::Point const motion_w(event->motion.x,
340 event->motion.y);
341 Geom::Point motion_dt(desktop->w2d(motion_w));
343 SnapManager &m = desktop->namedview->snap_manager;
344 m.setup(desktop, true, bc->item);
345 m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, motion_dt, Inkscape::SNAPSOURCE_HANDLE);
347 bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK;
349 if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded && bc->item) {
350 // once shift is pressed, set bc->extruded
351 bc->extruded = true;
352 }
354 if (!bc->extruded) {
355 bc->drag_ptB = from_2geom(motion_dt);
356 bc->drag_ptC = from_2geom(motion_dt);
358 bc->drag_ptB_proj = cur_persp->tmat.preimage (from_2geom(motion_dt), 0, Proj::Z);
359 bc->drag_ptC_proj = bc->drag_ptB_proj;
360 bc->drag_ptC_proj.normalize();
361 bc->drag_ptC_proj[Proj::Z] = 0.25;
362 } else {
363 // Without Ctrl, motion of the extruded corner is constrained to the
364 // perspective line from drag_ptB to vanishing point Y.
365 if (!bc->ctrl_dragged) {
366 /* snapping */
367 Box3D::PerspectiveLine pline (bc->drag_ptB, Proj::Z, SP_ACTIVE_DOCUMENT->current_persp3d);
368 bc->drag_ptC = pline.closest_to (from_2geom(motion_dt));
370 bc->drag_ptB_proj.normalize();
371 bc->drag_ptC_proj = cur_persp->tmat.preimage (bc->drag_ptC, bc->drag_ptB_proj[Proj::X], Proj::X);
372 } else {
373 bc->drag_ptC = from_2geom(motion_dt);
375 bc->drag_ptB_proj.normalize();
376 bc->drag_ptC_proj = cur_persp->tmat.preimage (from_2geom(motion_dt), bc->drag_ptB_proj[Proj::X], Proj::X);
377 }
378 Geom::Point pt2g = to_2geom(bc->drag_ptC);
379 m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g, Inkscape::SNAPSOURCE_HANDLE);
380 bc->drag_ptC = from_2geom(pt2g);
381 }
383 sp_box3d_drag(*bc, event->motion.state);
385 ret = TRUE;
386 }
387 break;
388 case GDK_BUTTON_RELEASE:
389 event_context->xp = event_context->yp = 0;
390 if ( event->button.button == 1 && !event_context->space_panning) {
391 dragging = false;
392 sp_event_context_discard_delayed_snap_event(event_context);
394 if (!event_context->within_tolerance) {
395 // we've been dragging, finish the box
396 sp_box3d_finish(bc);
397 } else if (event_context->item_to_select) {
398 // no dragging, select clicked item if any
399 if (event->button.state & GDK_SHIFT_MASK) {
400 selection->toggle(event_context->item_to_select);
401 } else {
402 selection->set(event_context->item_to_select);
403 }
404 } else {
405 // click in an empty space
406 selection->clear();
407 }
409 event_context->item_to_select = NULL;
410 ret = TRUE;
411 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
412 event->button.time);
413 }
414 break;
415 case GDK_KEY_PRESS:
416 switch (get_group0_keyval (&event->key)) {
417 case GDK_Up:
418 case GDK_Down:
419 case GDK_KP_Up:
420 case GDK_KP_Down:
421 // prevent the zoom field from activation
422 if (!MOD__CTRL_ONLY)
423 ret = TRUE;
424 break;
426 case GDK_bracketright:
427 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::X, -180/snaps, MOD__ALT);
428 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
429 _("Change perspective (angle of PLs)"));
430 ret = true;
431 break;
433 case GDK_bracketleft:
434 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::X, 180/snaps, MOD__ALT);
435 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
436 _("Change perspective (angle of PLs)"));
437 ret = true;
438 break;
440 case GDK_parenright:
441 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Y, -180/snaps, MOD__ALT);
442 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
443 _("Change perspective (angle of PLs)"));
444 ret = true;
445 break;
447 case GDK_parenleft:
448 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Y, 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_braceright:
455 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Z, -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_braceleft:
462 persp3d_rotate_VP (inkscape_active_document()->current_persp3d, Proj::Z, 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 /* TODO: what is this???
469 case GDK_O:
470 if (MOD__CTRL && MOD__SHIFT) {
471 Box3D::create_canvas_point(persp3d_get_VP(inkscape_active_document()->current_persp3d, Proj::W).affine(),
472 6, 0xff00ff00);
473 }
474 ret = true;
475 break;
476 */
478 case GDK_g:
479 case GDK_G:
480 if (MOD__SHIFT_ONLY) {
481 sp_selection_to_guides(desktop);
482 ret = true;
483 }
484 break;
486 case GDK_x:
487 case GDK_X:
488 if (MOD__ALT_ONLY) {
489 desktop->setToolboxFocusTo ("altx-box3d");
490 ret = TRUE;
491 }
492 if (MOD__SHIFT_ONLY) {
493 persp3d_toggle_VPs(selection->perspList(), Proj::X);
494 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
495 ret = true;
496 }
497 break;
499 case GDK_y:
500 case GDK_Y:
501 if (MOD__SHIFT_ONLY) {
502 persp3d_toggle_VPs(selection->perspList(), Proj::Y);
503 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
504 ret = true;
505 }
506 break;
508 case GDK_z:
509 case GDK_Z:
510 if (MOD__SHIFT_ONLY) {
511 persp3d_toggle_VPs(selection->perspList(), Proj::Z);
512 bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
513 ret = true;
514 }
515 break;
517 case GDK_Escape:
518 sp_desktop_selection(desktop)->clear();
519 //TODO: make dragging escapable by Esc
520 break;
522 case GDK_space:
523 if (dragging) {
524 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
525 event->button.time);
526 dragging = false;
527 sp_event_context_discard_delayed_snap_event(event_context);
528 if (!event_context->within_tolerance) {
529 // we've been dragging, finish the box
530 sp_box3d_finish(bc);
531 }
532 // do not return true, so that space would work switching to selector
533 }
534 break;
536 default:
537 break;
538 }
539 break;
540 default:
541 break;
542 }
544 if (!ret) {
545 if (((SPEventContextClass *) parent_class)->root_handler) {
546 ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
547 }
548 }
550 return ret;
551 }
553 static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
554 {
555 SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop;
557 if (!bc.item) {
559 if (Inkscape::have_viable_layer(desktop, bc._message_context) == false) {
560 return;
561 }
563 /* Create object */
564 Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
565 Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
566 repr->setAttribute("sodipodi:type", "inkscape:box3d");
568 /* Set style */
569 sp_desktop_apply_style_tool (desktop, repr, "/tools/shapes/3dbox", false);
571 bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
572 Inkscape::GC::release(repr);
573 Inkscape::XML::Node *repr_side;
574 // TODO: Incorporate this in box3d-side.cpp!
575 for (int i = 0; i < 6; ++i) {
576 repr_side = xml_doc->createElement("svg:path");
577 repr_side->setAttribute("sodipodi:type", "inkscape:box3dside");
578 repr->addChild(repr_side, NULL);
580 Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side));
582 guint desc = Box3D::int_to_face(i);
584 Box3D::Axis plane = (Box3D::Axis) (desc & 0x7);
585 plane = (Box3D::is_plane(plane) ? plane : Box3D::orth_plane_or_axis(plane));
586 side->dir1 = Box3D::extract_first_axis_direction(plane);
587 side->dir2 = Box3D::extract_second_axis_direction(plane);
588 side->front_or_rear = (Box3D::FrontOrRear) (desc & 0x8);
590 /* Set style */
591 box3d_side_apply_style(side);
593 SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
594 }
596 box3d_set_z_orders(SP_BOX3D(bc.item));
597 bc.item->updateRepr();
599 // TODO: It would be nice to show the VPs during dragging, but since there is no selection
600 // at this point (only after finishing the box), we must do this "manually"
601 /**** bc._vpdrag->updateDraggers(); ****/
603 sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
604 }
606 g_assert(bc.item);
608 SPBox3D *box = SP_BOX3D(bc.item);
610 box->orig_corner0 = bc.drag_origin_proj;
611 box->orig_corner7 = bc.drag_ptC_proj;
613 box3d_check_for_swapped_coords(box);
615 /* we need to call this from here (instead of from box3d_position_set(), for example)
616 because z-order setting must not interfere with display updates during undo/redo */
617 box3d_set_z_orders (box);
619 box3d_position_set(box);
621 // status text
622 bc._message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
623 }
625 static void sp_box3d_finish(Box3DContext *bc)
626 {
627 bc->_message_context->clear();
628 bc->ctrl_dragged = false;
629 bc->extruded = false;
631 if ( bc->item != NULL ) {
632 SPDesktop * desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
633 SPDocument *doc = sp_desktop_document(desktop);
634 if (!doc || !doc->current_persp3d)
635 return;
637 SPBox3D *box = SP_BOX3D(bc->item);
639 box->orig_corner0 = bc->drag_origin_proj;
640 box->orig_corner7 = bc->drag_ptC_proj;
642 box->updateRepr();
644 box3d_relabel_corners(box);
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 }
654 }
656 void sp_box3d_context_update_lines(SPEventContext *ec) {
657 /* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
658 if (SP_IS_BOX3D_CONTEXT (ec)) {
659 Box3DContext *bc = SP_BOX3D_CONTEXT (ec);
660 bc->_vpdrag->updateLines();
661 }
662 }
664 /*
665 Local Variables:
666 mode:c++
667 c-file-style:"stroustrup"
668 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
669 indent-tabs-mode:nil
670 fill-column:99
671 End:
672 */
673 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :