/*
* 3D box drawing context
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 2007 Maximilian Albert <Anhalter42@gmx.de>
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 2000-2005 authors
* Copyright (C) 2000-2001 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "config.h"
#include <gdk/gdkkeysyms.h>
#include "macros.h"
#include "display/sp-canvas.h"
#include "document.h"
#include "document-undo.h"
#include "sp-namedview.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "snap.h"
#include "display/sp-canvas-item.h"
#include "desktop.h"
#include "message-context.h"
#include "pixmaps/cursor-3dbox.xpm"
#include "box3d.h"
#include "ui/tools/box3d-tool.h"
#include "xml/node-event-vector.h"
#include "preferences.h"
#include "context-fns.h"
#include "desktop-style.h"
#include "transf_mat_3x4.h"
#include "perspective-line.h"
#include "persp3d.h"
#include "box3d-side.h"
#include "document-private.h"
#include "line-geometry.h"
#include "ui/shape-editor.h"
#include "verbs.h"
using Inkscape::DocumentUndo;
namespace Inkscape {
namespace UI {
namespace Tools {
}
, ctrl_dragged(false)
, extruded(false)
{
}
this->finishItem();
this->sel_changed_connection.disconnect();
}
this->enableGrDrag(false);
delete (this->_vpdrag);
this->sel_changed_connection.disconnect();
delete this->shape_editor;
this->shape_editor = NULL;
/* fixme: This is necessary because we do not grab */
if (this->box3d) {
this->finishItem();
}
}
/**
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
this->shape_editor->unset_item();
// selecting a single box changes the current perspective
}
}
/* Create a default perspective in document defs if none is present (which can happen, among other
* circumstances, after 'vacuum defs' or when a pre-0.46 file is opened).
*/
bool has_persp = false;
if (SP_IS_PERSP3D(child)) {
has_persp = true;
break;
}
}
if (!has_persp) {
}
}
if (item) {
}
this->sel_changed_connection.disconnect();
);
this->enableSelectionCue();
}
this->enableGrDrag();
}
}
case GDK_BUTTON_PRESS:
//ret = TRUE;
}
break;
// motion and release are always on root (why?)
default:
break;
}
// if (((ToolBaseClass *) sp_box3d_context_parent_class)->item_handler) {
// ret = ((ToolBaseClass *) sp_box3d_context_parent_class)->item_handler(event_context, item, event);
// }
// CPPIFY: ret is always overwritten...
return ret;
}
static bool dragging;
case GDK_BUTTON_PRESS:
// save drag origin
this->within_tolerance = true;
// remember clicked box3d, *not* disregarding groups (since a 3D box is a group), honoring Alt
this->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, event->button.state & GDK_CONTROL_MASK);
dragging = true;
m.unSetup();
this->drag_origin = button_dt;
// This can happen after saving when the last remaining perspective was purged and must be recreated.
if (!cur_persp) {
}
/* Projective preimages of clicked point under current perspective */
this->drag_ptB_proj = this->drag_origin_proj;
this->drag_ptC_proj = this->drag_origin_proj;
this->drag_ptC_proj.normalize();
}
break;
case GDK_MOTION_NOTIFY:
if ( this->within_tolerance
break; // do not drag if we're within tolerance from origin
}
// Once the user has moved farther than tolerance from the original location
// (indicating they intend to draw, not click), then always process the
// motion notify coordinates as given (no snapping back to origin)
this->within_tolerance = false;
// once shift is pressed, set this->extruded
this->extruded = true;
}
if (!this->extruded) {
this->drag_ptC_proj = this->drag_ptB_proj;
this->drag_ptC_proj.normalize();
} else {
// Without Ctrl, motion of the extruded corner is constrained to the
// perspective line from drag_ptB to vanishing point Y.
if (!this->ctrl_dragged) {
/* snapping */
this->drag_ptB_proj.normalize();
this->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (this->drag_ptC, this->drag_ptB_proj[Proj::X], Proj::X);
} else {
this->drag_ptB_proj.normalize();
this->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (motion_dt, this->drag_ptB_proj[Proj::X], Proj::X);
}
}
m.unSetup();
} else if (!this->sp_event_context_knot_mouseover()) {
m.unSetup();
}
break;
case GDK_BUTTON_RELEASE:
dragging = false;
if (!this->within_tolerance) {
// we've been dragging, finish the box
this->finishItem();
} else if (this->item_to_select) {
// no dragging, select clicked box3d if any
} else {
}
} else {
// click in an empty space
}
this->item_to_select = NULL;
}
break;
case GDK_KEY_PRESS:
case GDK_KEY_Up:
case GDK_KEY_Down:
case GDK_KEY_KP_Up:
case GDK_KEY_KP_Down:
// prevent the zoom field from activation
if (!MOD__CTRL_ONLY(event))
break;
case GDK_KEY_bracketright:
_("Change perspective (angle of PLs)"));
ret = true;
break;
case GDK_KEY_bracketleft:
_("Change perspective (angle of PLs)"));
ret = true;
break;
case GDK_KEY_parenright:
_("Change perspective (angle of PLs)"));
ret = true;
break;
case GDK_KEY_parenleft:
_("Change perspective (angle of PLs)"));
ret = true;
break;
case GDK_KEY_braceright:
_("Change perspective (angle of PLs)"));
ret = true;
break;
case GDK_KEY_braceleft:
_("Change perspective (angle of PLs)"));
ret = true;
break;
/* TODO: what is this???
case GDK_O:
if (MOD__CTRL(event) && MOD__SHIFT(event)) {
Box3D::create_canvas_point(persp3d_get_VP(document()->getCurrentPersp3D(), Proj::W).affine(),
6, 0xff00ff00);
}
ret = true;
break;
*/
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
ret = true;
}
break;
case GDK_KEY_p:
case GDK_KEY_P:
if (MOD__SHIFT_ONLY(event)) {
if (document->getCurrentPersp3D()) {
}
ret = true;
}
break;
case GDK_KEY_x:
case GDK_KEY_X:
if (MOD__ALT_ONLY(event)) {
}
if (MOD__SHIFT_ONLY(event)) {
ret = true;
}
break;
case GDK_KEY_y:
case GDK_KEY_Y:
if (MOD__SHIFT_ONLY(event)) {
ret = true;
}
break;
case GDK_KEY_z:
case GDK_KEY_Z:
if (MOD__SHIFT_ONLY(event)) {
ret = true;
}
break;
case GDK_KEY_Escape:
//TODO: make dragging escapable by Esc
break;
case GDK_KEY_space:
if (dragging) {
dragging = false;
if (!this->within_tolerance) {
// we've been dragging, finish the box
this->finishItem();
}
// do not return true, so that space would work switching to selector
}
break;
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
case GDK_KEY_BackSpace:
break;
default:
break;
}
break;
default:
break;
}
if (!ret) {
}
return ret;
}
if (!this->box3d) {
return;
}
// Create object
// Set style
// TODO: Incorporate this in box3d-side.cpp!
for (int i = 0; i < 6; ++i) {
// Set style
descr += "/style";
// use last used style
} else {
// use default style
}
}
box3d_set_z_orders(this->box3d);
this->box3d->updateRepr();
// TODO: It would be nice to show the VPs during dragging, but since there is no selection
// at this point (only after finishing the box), we must do this "manually"
/* this._vpdrag->updateDraggers(); */
}
box3d_check_for_swapped_coords(this->box3d);
/* we need to call this from here (instead of from box3d_position_set(), for example)
box3d_set_z_orders (this->box3d);
box3d_position_set(this->box3d);
// status text
this->message_context->setF(Inkscape::NORMAL_MESSAGE, "%s", _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
}
this->message_context->clear();
this->ctrl_dragged = false;
this->extruded = false;
return;
}
this->box3d->updateRepr();
box3d_relabel_corners(this->box3d);
_("Create 3D box"));
}
}
}
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :