818a87c6c6d0a32ae56c85c10d32c9b65b6bad76
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 static void sp_3dbox_context_init(SP3DBoxContext *box3d_context)
94 {
95 SPEventContext *event_context = SP_EVENT_CONTEXT(box3d_context);
97 event_context->cursor_shape = cursor_rect_xpm;
98 event_context->hot_x = 4;
99 event_context->hot_y = 4;
100 event_context->xp = 0;
101 event_context->yp = 0;
102 event_context->tolerance = 0;
103 event_context->within_tolerance = false;
104 event_context->item_to_select = NULL;
106 event_context->shape_repr = NULL;
107 event_context->shape_knot_holder = NULL;
109 box3d_context->item = NULL;
111 box3d_context->ctrl_dragged = false;
112 box3d_context->extruded = false;
114 box3d_context->_vpdrag = NULL;
116 new (&box3d_context->sel_changed_connection) sigc::connection();
117 }
119 static void sp_3dbox_context_dispose(GObject *object)
120 {
121 SP3DBoxContext *bc = SP_3DBOX_CONTEXT(object);
122 SPEventContext *ec = SP_EVENT_CONTEXT(object);
124 ec->enableGrDrag(false);
126 delete (bc->_vpdrag);
127 bc->_vpdrag = NULL;
129 bc->sel_changed_connection.disconnect();
130 bc->sel_changed_connection.~connection();
132 /* fixme: This is necessary because we do not grab */
133 if (bc->item) {
134 sp_3dbox_finish(bc);
135 }
137 if (ec->shape_knot_holder) {
138 sp_knot_holder_destroy(ec->shape_knot_holder);
139 ec->shape_knot_holder = NULL;
140 }
142 if (ec->shape_repr) { // remove old listener
143 sp_repr_remove_listener_by_data(ec->shape_repr, ec);
144 Inkscape::GC::release(ec->shape_repr);
145 ec->shape_repr = 0;
146 }
148 if (bc->_message_context) {
149 delete bc->_message_context;
150 }
152 G_OBJECT_CLASS(parent_class)->dispose(object);
153 }
155 static Inkscape::XML::NodeEventVector ec_shape_repr_events = {
156 NULL, /* child_added */
157 NULL, /* child_removed */
158 ec_shape_event_attr_changed,
159 NULL, /* content_changed */
160 NULL /* order_changed */
161 };
163 /**
164 \brief Callback that processes the "changed" signal on the selection;
165 destroys old and creates new knotholder
166 */
167 void sp_3dbox_context_selection_changed(Inkscape::Selection *selection, gpointer data)
168 {
169 SP3DBoxContext *bc = SP_3DBOX_CONTEXT(data);
170 SPEventContext *ec = SP_EVENT_CONTEXT(bc);
172 if (ec->shape_knot_holder) { // destroy knotholder
173 sp_knot_holder_destroy(ec->shape_knot_holder);
174 ec->shape_knot_holder = NULL;
175 }
177 if (ec->shape_repr) { // remove old listener
178 sp_repr_remove_listener_by_data(ec->shape_repr, ec);
179 Inkscape::GC::release(ec->shape_repr);
180 ec->shape_repr = 0;
181 }
183 SPItem *item = selection->singleItem();
184 if (item) {
185 ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
186 Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
187 if (shape_repr) {
188 ec->shape_repr = shape_repr;
189 Inkscape::GC::anchor(shape_repr);
190 sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
191 }
192 if (SP_IS_3DBOX (item)) {
193 bc->_vpdrag->document->current_perspective = bc->_vpdrag->document->get_persp_of_box (SP_3DBOX (item));
194 }
195 } else {
196 /* If several boxes sharing the same perspective are selected,
197 we can still set the current selection accordingly */
198 std::set<Box3D::Perspective3D *> perspectives;
199 for (GSList *i = (GSList *) selection->itemList(); i != NULL; i = i->next) {
200 if (SP_IS_3DBOX (i->data)) {
201 perspectives.insert (bc->_vpdrag->document->get_persp_of_box (SP_3DBOX (i->data)));
202 }
203 }
204 if (perspectives.size() == 1) {
205 bc->_vpdrag->document->current_perspective = *(perspectives.begin());
206 }
207 // TODO: What to do if several boxes with different perspectives are selected?
208 }
209 }
211 static void sp_3dbox_context_setup(SPEventContext *ec)
212 {
213 SP3DBoxContext *bc = SP_3DBOX_CONTEXT(ec);
215 if (((SPEventContextClass *) parent_class)->setup) {
216 ((SPEventContextClass *) parent_class)->setup(ec);
217 }
219 SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
220 if (item) {
221 ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
222 Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
223 if (shape_repr) {
224 ec->shape_repr = shape_repr;
225 Inkscape::GC::anchor(shape_repr);
226 sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
227 }
228 }
230 bc->sel_changed_connection.disconnect();
231 bc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(
232 sigc::bind(sigc::ptr_fun(&sp_3dbox_context_selection_changed), (gpointer)bc)
233 );
235 bc->_vpdrag = new Box3D::VPDrag(sp_desktop_document (ec->desktop));
237 if (prefs_get_int_attribute("tools.shapes", "selcue", 0) != 0) {
238 ec->enableSelectionCue();
239 }
241 if (prefs_get_int_attribute("tools.shapes", "gradientdrag", 0) != 0) {
242 ec->enableGrDrag();
243 }
245 bc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
246 }
248 static void sp_3dbox_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
249 {
250 //SP3DBoxContext *bc = SP_3DBOX_CONTEXT(ec);
252 /* fixme: Proper error handling for non-numeric data. Use a locale-independent function like
253 * g_ascii_strtod (or a thin wrapper that does the right thing for invalid values inf/nan). */
254 /**
255 if ( strcmp(key, "rx") == 0 ) {
256 bc->rx = ( val
257 ? g_ascii_strtod (val, NULL)
258 : 0.0 );
259 } else if ( strcmp(key, "ry") == 0 ) {
260 bc->ry = ( val
261 ? g_ascii_strtod (val, NULL)
262 : 0.0 );
263 }
264 **/
265 }
267 static gint sp_3dbox_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_3dbox_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);
299 SP3DBoxContext *bc = SP_3DBOX_CONTEXT(event_context);
301 event_context->tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
303 gint ret = FALSE;
304 switch (event->type) {
305 case GDK_BUTTON_PRESS:
306 if ( event->button.button == 1 && !event_context->space_panning) {
307 NR::Point const button_w(event->button.x,
308 event->button.y);
310 // save drag origin
311 event_context->xp = (gint) button_w[NR::X];
312 event_context->yp = (gint) button_w[NR::Y];
313 event_context->within_tolerance = true;
315 // remember clicked item, disregarding groups, honoring Alt
316 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);
318 dragging = true;
320 /* Position center */
321 NR::Point const button_dt(desktop->w2d(button_w));
322 bc->drag_origin = button_dt;
323 bc->drag_ptB = button_dt;
324 bc->drag_ptC = button_dt;
326 /* Snap center */
327 SnapManager const &m = desktop->namedview->snap_manager;
328 bc->center = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE,
329 button_dt, bc->item).getPoint();
331 sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
332 ( GDK_KEY_PRESS_MASK |
333 GDK_BUTTON_RELEASE_MASK |
334 GDK_POINTER_MOTION_MASK |
335 GDK_BUTTON_PRESS_MASK ),
336 NULL, event->button.time);
337 ret = TRUE;
338 }
339 break;
340 case GDK_MOTION_NOTIFY:
341 if ( dragging
342 && ( event->motion.state & GDK_BUTTON1_MASK ) && !event_context->space_panning)
343 {
344 if ( event_context->within_tolerance
345 && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
346 && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
347 break; // do not drag if we're within tolerance from origin
348 }
349 // Once the user has moved farther than tolerance from the original location
350 // (indicating they intend to draw, not click), then always process the
351 // motion notify coordinates as given (no snapping back to origin)
352 event_context->within_tolerance = false;
354 NR::Point const motion_w(event->motion.x,
355 event->motion.y);
356 NR::Point motion_dt(desktop->w2d(motion_w));
358 SnapManager const &m = desktop->namedview->snap_manager;
359 motion_dt = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, motion_dt, bc->item).getPoint();
361 bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK;
363 if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded && bc->item) {
364 /* once shift is pressed, set bc->extruded (no need to create further faces;
365 all of them are already created in sp_3dbox_init); since we made the rear face
366 invisible in the beginning to avoid "flashing", we must set its correct style now */
367 bc->extruded = true;
368 SP_3DBOX (bc->item)->faces[5]->set_style (NULL, 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, bc->_vpdrag->document->current_perspective);
379 } else {
380 bc->drag_ptC = motion_dt;
381 }
382 bc->drag_ptC = m.freeSnap(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, bc->_vpdrag->document->current_perspective);
385 Box3D::PerspectiveLine pl2 (bc->drag_ptB, Box3D::X, bc->_vpdrag->document->current_perspective);
386 NR::Point corner1 = pl1.meet(pl2);
388 Box3D::PerspectiveLine pl3 (corner1, Box3D::X, bc->_vpdrag->document->current_perspective);
389 Box3D::PerspectiveLine pl4 (bc->drag_ptC, Box3D::Z, bc->_vpdrag->document->current_perspective);
390 bc->drag_ptB = pl3.meet(pl4);
391 }
392 }
395 sp_3dbox_drag(*bc, event->motion.state);
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_bracketright:
455 inkscape_active_document()->current_perspective->rotate (Box3D::X, -10);
456 ret = true;
457 break;
459 case GDK_bracketleft:
460 inkscape_active_document()->current_perspective->rotate (Box3D::X, 10);
461 ret = true;
462 break;
464 case GDK_parenright:
465 inkscape_active_document()->current_perspective->rotate (Box3D::Y, -10);
466 ret = true;
467 break;
469 case GDK_parenleft:
470 inkscape_active_document()->current_perspective->rotate (Box3D::Y, 10);
471 ret = true;
472 break;
474 case GDK_braceright:
475 inkscape_active_document()->current_perspective->rotate (Box3D::Z, -10);
476 ret = true;
477 break;
479 case GDK_braceleft:
480 inkscape_active_document()->current_perspective->rotate (Box3D::Z, 10);
481 ret = true;
482 break;
484 case GDK_I:
485 Box3D::Perspective3D::print_debugging_info();
486 ret = true;
487 break;
489 case GDK_L:
490 if (MOD__CTRL) break; // Don't catch Shift+Ctrl+L (Layers dialog)
491 bc->_vpdrag->show_lines = !bc->_vpdrag->show_lines;
492 bc->_vpdrag->updateLines();
493 ret = true;
494 break;
496 case GDK_A:
497 if (MOD__CTRL) break; // Don't catch Ctrl+A ("select all")
498 if (bc->_vpdrag->show_lines) {
499 bc->_vpdrag->front_or_rear_lines = bc->_vpdrag->front_or_rear_lines ^ 0x2; // toggle rear PLs
500 }
501 bc->_vpdrag->updateLines();
502 ret = true;
503 break;
505 case GDK_X:
506 {
507 if (MOD__CTRL) break; // Don't catch Ctrl+X ('cut') and Ctrl+Shift+X ('open XML editor')
508 Inkscape::Selection *selection = sp_desktop_selection (inkscape_active_desktop());
509 for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
510 if (!SP_IS_3DBOX (i->data)) continue;
511 sp_3dbox_switch_front_face (SP_3DBOX (i->data), Box3D::X);
512 }
513 bc->_vpdrag->updateLines();
514 ret = true;
515 break;
516 }
518 case GDK_Y:
519 {
520 if (MOD__CTRL) break; // Don't catch Ctrl+Y ("redo")
521 Inkscape::Selection *selection = sp_desktop_selection (inkscape_active_desktop());
522 for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
523 if (!SP_IS_3DBOX (i->data)) continue;
524 sp_3dbox_switch_front_face (SP_3DBOX (i->data), Box3D::Y);
525 }
526 bc->_vpdrag->updateLines();
527 ret = true;
528 break;
529 }
531 case GDK_Z:
532 {
533 if (MOD__CTRL) break; // Don't catch Ctrl+Z ("undo")
534 Inkscape::Selection *selection = sp_desktop_selection (inkscape_active_desktop());
535 for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
536 if (!SP_IS_3DBOX (i->data)) continue;
537 sp_3dbox_switch_front_face (SP_3DBOX (i->data), Box3D::Z);
538 }
539 bc->_vpdrag->updateLines();
540 ret = true;
541 break;
542 }
544 case GDK_Escape:
545 sp_desktop_selection(desktop)->clear();
546 //TODO: make dragging escapable by Esc
547 break;
549 case GDK_space:
550 if (dragging) {
551 sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
552 event->button.time);
553 dragging = false;
554 if (!event_context->within_tolerance) {
555 // we've been dragging, finish the box
556 sp_3dbox_finish(bc);
557 }
558 // do not return true, so that space would work switching to selector
559 }
560 break;
562 default:
563 break;
564 }
565 break;
566 case GDK_KEY_RELEASE:
567 switch (get_group0_keyval (&event->key)) {
568 case GDK_Alt_L:
569 case GDK_Alt_R:
570 case GDK_Control_L:
571 case GDK_Control_R:
572 case GDK_Shift_L:
573 case GDK_Shift_R:
574 case GDK_Meta_L: // Meta is when you press Shift+Alt
575 case GDK_Meta_R:
576 event_context->defaultMessageContext()->clear();
577 break;
578 default:
579 break;
580 }
581 break;
582 default:
583 break;
584 }
586 if (!ret) {
587 if (((SPEventContextClass *) parent_class)->root_handler) {
588 ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
589 }
590 }
592 return ret;
593 }
595 static void sp_3dbox_drag(SP3DBoxContext &bc, guint state)
596 {
597 SPDesktop *desktop = SP_EVENT_CONTEXT(&bc)->desktop;
599 if (!bc.item) {
601 if (Inkscape::have_viable_layer(desktop, bc._message_context) == false) {
602 return;
603 }
605 /* Create object */
606 Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
607 Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
608 repr->setAttribute("sodipodi:type", "inkscape:3dbox");
610 /* Set style */
611 sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.3dbox", false);
613 bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
614 Inkscape::GC::release(repr);
615 bc.item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer());
617 /* Hook paths to the faces of the box (applies last used style if necessary) */
618 for (int i = 0; i < 6; ++i) {
619 SP_3DBOX(bc.item)->faces[i]->hook_path_to_3dbox();
620 }
621 // make rear face invisible in the beginning to avoid "flashing"
622 SP_3DBOX (bc.item)->faces[5]->set_style (NULL, false);
624 bc.item->updateRepr();
625 sp_3dbox_set_z_orders_in_the_first_place (SP_3DBOX (bc.item));
627 // TODO: It would be nice to show the VPs during dragging, but since there is no selection
628 // at this point (only after finishing the box), we must do this "manually"
629 bc._vpdrag->updateDraggers();
631 sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
632 }
634 // FIXME: remove these extra points
635 NR::Point pt = bc.drag_ptB;
636 NR::Point shift_pt = bc.drag_ptC;
638 NR::Rect r;
639 if (!(state & GDK_SHIFT_MASK)) {
640 r = Inkscape::snap_rectangular_box(desktop, bc.item, pt, bc.center, state);
641 } else {
642 r = Inkscape::snap_rectangular_box(desktop, bc.item, shift_pt, bc.center, state);
643 }
645 SPEventContext *ec = SP_EVENT_CONTEXT(&bc);
646 NR::Point origin_w(ec->xp, ec->yp);
647 NR::Point origin(desktop->w2d(origin_w));
648 sp_3dbox_position_set(bc);
649 sp_3dbox_set_z_orders_in_the_first_place (SP_3DBOX (bc.item));
651 // status text
652 //GString *Ax = SP_PX_TO_METRIC_STRING(origin[NR::X], desktop->namedview->getDefaultMetric());
653 //GString *Ay = SP_PX_TO_METRIC_STRING(origin[NR::Y], desktop->namedview->getDefaultMetric());
654 bc._message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
655 //g_string_free(Ax, FALSE);
656 //g_string_free(Ay, FALSE);
657 }
659 static void sp_3dbox_finish(SP3DBoxContext *bc)
660 {
661 bc->_message_context->clear();
663 if ( bc->item != NULL ) {
664 SPDesktop * desktop;
666 desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
668 SP_OBJECT(bc->item)->updateRepr();
669 sp_3dbox_set_ratios(SP_3DBOX(bc->item));
671 sp_canvas_end_forced_full_redraws(desktop->canvas);
673 sp_desktop_selection(desktop)->set(bc->item);
674 sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
675 _("Create 3D box"));
677 bc->item = NULL;
678 }
680 bc->ctrl_dragged = false;
681 bc->extruded = false;
682 }
684 /*
685 Local Variables:
686 mode:c++
687 c-file-style:"stroustrup"
688 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
689 indent-tabs-mode:nil
690 fill-column:99
691 End:
692 */
693 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :