summaryrefslogtreecommitdiffstats
path: root/src/box3d-context.cpp
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-04-21 21:58:15 +0000
committerMarkus Engel <markus.engel@tum.de>2013-04-21 21:58:15 +0000
commitbdde74bbab299f2ee448f1c55469c56a66fb01f7 (patch)
tree45bccef1ec815708f9b54171e2d567344f155074 /src/box3d-context.cpp
parentMore cleaning. (diff)
downloadinkscape-bdde74bbab299f2ee448f1c55469c56a66fb01f7.tar.gz
inkscape-bdde74bbab299f2ee448f1c55469c56a66fb01f7.zip
Removed some unused files; more refactoring in EventContext tree.
(bzr r11608.1.104)
Diffstat (limited to 'src/box3d-context.cpp')
-rw-r--r--src/box3d-context.cpp349
1 files changed, 146 insertions, 203 deletions
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index dea91185a..c009dc699 100644
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -53,10 +53,6 @@
using Inkscape::DocumentUndo;
-static void sp_box3d_drag(Box3DContext &bc, guint state);
-static void sp_box3d_finish(Box3DContext *bc);
-
-
#include "tool-factory.h"
namespace {
@@ -74,92 +70,66 @@ const std::string& Box3DContext::getPrefsPath() {
const std::string Box3DContext::prefsPath = "/tools/shapes/3dbox";
Box3DContext::Box3DContext() : SPEventContext() {
- Box3DContext* box3d_context = this;
-
- box3d_context->_message_context = 0;
-
- SPEventContext *event_context = SP_EVENT_CONTEXT(box3d_context);
-
- event_context->cursor_shape = cursor_3dbox_xpm;
- event_context->hot_x = 4;
- event_context->hot_y = 4;
- event_context->xp = 0;
- event_context->yp = 0;
- event_context->tolerance = 0;
- event_context->within_tolerance = false;
- event_context->item_to_select = NULL;
+ this->_message_context = 0;
- box3d_context->item = NULL;
+ this->cursor_shape = cursor_3dbox_xpm;
+ this->hot_x = 4;
+ this->hot_y = 4;
+ this->xp = 0;
+ this->yp = 0;
+ this->tolerance = 0;
+ this->within_tolerance = false;
+ this->item_to_select = NULL;
- box3d_context->ctrl_dragged = false;
- box3d_context->extruded = false;
+ this->box3d = NULL;
- box3d_context->_vpdrag = NULL;
+ this->ctrl_dragged = false;
+ this->extruded = false;
- //new (&box3d_context->sel_changed_connection) sigc::connection();
+ this->_vpdrag = NULL;
}
void Box3DContext::finish() {
- SPEventContext* ec = this;
-
- Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
- SPDesktop *desktop = ec->desktop;
-
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
- sp_box3d_finish(bc);
- bc->sel_changed_connection.disconnect();
-// sp_repr_remove_listener_by_data(cc->active_shape_repr, cc);
+ this->finishItem();
+ this->sel_changed_connection.disconnect();
-// if (((SPEventContextClass *) sp_box3d_context_parent_class)->finish) {
-// ((SPEventContextClass *) sp_box3d_context_parent_class)->finish(ec);
-// }
SPEventContext::finish();
}
Box3DContext::~Box3DContext() {
- Box3DContext *bc = SP_BOX3D_CONTEXT(this);
- SPEventContext *ec = SP_EVENT_CONTEXT(this);
+ this->enableGrDrag(false);
- ec->enableGrDrag(false);
+ delete (this->_vpdrag);
+ this->_vpdrag = NULL;
- delete (bc->_vpdrag);
- bc->_vpdrag = NULL;
+ this->sel_changed_connection.disconnect();
- bc->sel_changed_connection.disconnect();
- //bc->sel_changed_connection.~connection();
-
- delete ec->shape_editor;
- ec->shape_editor = NULL;
+ delete this->shape_editor;
+ this->shape_editor = NULL;
/* fixme: This is necessary because we do not grab */
- if (bc->item) {
- sp_box3d_finish(bc);
+ if (this->box3d) {
+ this->finishItem();
}
- if (bc->_message_context) {
- delete bc->_message_context;
+ if (this->_message_context) {
+ delete this->_message_context;
}
-
- //G_OBJECT_CLASS(sp_box3d_context_parent_class)->dispose(object);
}
/**
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, gpointer data)
-{
- Box3DContext *bc = SP_BOX3D_CONTEXT(data);
- SPEventContext *ec = SP_EVENT_CONTEXT(bc);
-
- ec->shape_editor->unset_item(SH_KNOTHOLDER);
- SPItem *item = selection->singleItem();
- ec->shape_editor->set_item(item, SH_KNOTHOLDER);
+void Box3DContext::selection_changed(Inkscape::Selection* selection) {
+ this->shape_editor->unset_item(SH_KNOTHOLDER);
+ this->shape_editor->set_item(selection->singleItem(), SH_KNOTHOLDER);
if (selection->perspList().size() == 1) {
// selecting a single box changes the current perspective
- ec->desktop->doc()->setCurrentPersp3D(selection->perspList().front());
+ this->desktop->doc()->setCurrentPersp3D(selection->perspList().front());
}
}
@@ -183,52 +153,42 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) {
}
void Box3DContext::setup() {
- SPEventContext* ec = this;
-
- Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
-
-// if (((SPEventContextClass *) sp_box3d_context_parent_class)->setup) {
-// ((SPEventContextClass *) sp_box3d_context_parent_class)->setup(ec);
-// }
SPEventContext::setup();
- ec->shape_editor = new ShapeEditor(ec->desktop);
+ this->shape_editor = new ShapeEditor(this->desktop);
- SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
+ SPItem *item = sp_desktop_selection(this->desktop)->singleItem();
if (item) {
- ec->shape_editor->set_item(item, SH_KNOTHOLDER);
+ this->shape_editor->set_item(item, SH_KNOTHOLDER);
}
- bc->sel_changed_connection.disconnect();
- bc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(
- sigc::bind(sigc::ptr_fun(&sp_box3d_context_selection_changed), (gpointer)bc)
+ this->sel_changed_connection.disconnect();
+ this->sel_changed_connection = sp_desktop_selection(this->desktop)->connectChanged(
+ sigc::mem_fun(this, &Box3DContext::selection_changed)
);
- bc->_vpdrag = new Box3D::VPDrag(sp_desktop_document (ec->desktop));
+ this->_vpdrag = new Box3D::VPDrag(sp_desktop_document(this->desktop));
+
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/shapes/selcue")) {
- ec->enableSelectionCue();
+ this->enableSelectionCue();
}
if (prefs->getBool("/tools/shapes/gradientdrag")) {
- ec->enableGrDrag();
+ this->enableGrDrag();
}
- bc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
+ this->_message_context = new Inkscape::MessageContext(this->desktop->messageStack());
}
gint Box3DContext::item_handler(SPItem* item, GdkEvent* event) {
- SPEventContext* event_context = this;
-
- SPDesktop *desktop = event_context->desktop;
-
gint ret = FALSE;
switch (event->type) {
case GDK_BUTTON_PRESS:
- if ( event->button.button == 1 && !event_context->space_panning) {
- Inkscape::setup_for_drag_start(desktop, event_context, event);
+ if ( event->button.button == 1 && !this->space_panning) {
+ Inkscape::setup_for_drag_start(desktop, this, event);
ret = TRUE;
}
break;
@@ -247,48 +207,43 @@ gint Box3DContext::item_handler(SPItem* item, GdkEvent* event) {
}
gint Box3DContext::root_handler(GdkEvent* event) {
- SPEventContext* event_context = this;
-
static bool dragging;
- SPDesktop *desktop = event_context->desktop;
SPDocument *document = sp_desktop_document (desktop);
Inkscape::Selection *selection = sp_desktop_selection (desktop);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
- Box3DContext *bc = SP_BOX3D_CONTEXT(event_context);
Persp3D *cur_persp = document->getCurrentPersp3D();
- event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
+ this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
gint ret = FALSE;
switch (event->type) {
case GDK_BUTTON_PRESS:
- if ( event->button.button == 1 && !event_context->space_panning) {
- Geom::Point const button_w(event->button.x,
- event->button.y);
+ if ( event->button.button == 1 && !this->space_panning) {
+ Geom::Point const button_w(event->button.x, event->button.y);
Geom::Point button_dt(desktop->w2d(button_w));
// save drag origin
- event_context->xp = (gint) button_w[Geom::X];
- event_context->yp = (gint) button_w[Geom::Y];
- event_context->within_tolerance = true;
+ this->xp = (gint) button_w[Geom::X];
+ this->yp = (gint) button_w[Geom::Y];
+ this->within_tolerance = true;
- // remember clicked item, *not* disregarding groups (since a 3D box is a group), honoring Alt
- 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);
+ // 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;
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, true, bc->item);
+ m.setup(desktop, true, this->box3d);
m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
m.unSetup();
- bc->center = button_dt;
+ this->center = button_dt;
- bc->drag_origin = button_dt;
- bc->drag_ptB = button_dt;
- bc->drag_ptC = button_dt;
+ this->drag_origin = button_dt;
+ this->drag_ptB = button_dt;
+ this->drag_ptC = button_dt;
// This can happen after saving when the last remaining perspective was purged and must be recreated.
if (!cur_persp) {
@@ -297,11 +252,11 @@ gint Box3DContext::root_handler(GdkEvent* event) {
}
/* Projective preimages of clicked point under current perspective */
- bc->drag_origin_proj = cur_persp->perspective_impl->tmat.preimage (button_dt, 0, Proj::Z);
- bc->drag_ptB_proj = bc->drag_origin_proj;
- bc->drag_ptC_proj = bc->drag_origin_proj;
- bc->drag_ptC_proj.normalize();
- bc->drag_ptC_proj[Proj::Z] = 0.25;
+ this->drag_origin_proj = cur_persp->perspective_impl->tmat.preimage (button_dt, 0, Proj::Z);
+ this->drag_ptB_proj = this->drag_origin_proj;
+ this->drag_ptC_proj = this->drag_origin_proj;
+ this->drag_ptC_proj.normalize();
+ this->drag_ptC_proj[Proj::Z] = 0.25;
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
( GDK_KEY_PRESS_MASK |
@@ -312,66 +267,67 @@ gint Box3DContext::root_handler(GdkEvent* event) {
ret = TRUE;
}
break;
+
case GDK_MOTION_NOTIFY:
- if ( dragging
- && ( event->motion.state & GDK_BUTTON1_MASK ) && !event_context->space_panning)
- {
- if ( event_context->within_tolerance
- && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
- && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
+ if (dragging && ( event->motion.state & GDK_BUTTON1_MASK ) && !this->space_panning) {
+ if ( this->within_tolerance
+ && ( abs( (gint) event->motion.x - this->xp ) < this->tolerance )
+ && ( abs( (gint) event->motion.y - this->yp ) < this->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)
- event_context->within_tolerance = false;
+ this->within_tolerance = false;
Geom::Point const motion_w(event->motion.x,
event->motion.y);
Geom::Point motion_dt(desktop->w2d(motion_w));
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, true, bc->item);
+ m.setup(desktop, true, this->box3d);
m.freeSnapReturnByRef(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE);
- bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK;
+ this->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK;
- if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded && bc->item) {
- // once shift is pressed, set bc->extruded
- bc->extruded = true;
+ if ((event->motion.state & GDK_SHIFT_MASK) && !this->extruded && this->box3d) {
+ // once shift is pressed, set this->extruded
+ this->extruded = true;
}
- if (!bc->extruded) {
- bc->drag_ptB = motion_dt;
- bc->drag_ptC = motion_dt;
+ if (!this->extruded) {
+ this->drag_ptB = motion_dt;
+ this->drag_ptC = motion_dt;
- bc->drag_ptB_proj = cur_persp->perspective_impl->tmat.preimage (motion_dt, 0, Proj::Z);
- bc->drag_ptC_proj = bc->drag_ptB_proj;
- bc->drag_ptC_proj.normalize();
- bc->drag_ptC_proj[Proj::Z] = 0.25;
+ this->drag_ptB_proj = cur_persp->perspective_impl->tmat.preimage (motion_dt, 0, Proj::Z);
+ this->drag_ptC_proj = this->drag_ptB_proj;
+ this->drag_ptC_proj.normalize();
+ this->drag_ptC_proj[Proj::Z] = 0.25;
} else {
// Without Ctrl, motion of the extruded corner is constrained to the
// perspective line from drag_ptB to vanishing point Y.
- if (!bc->ctrl_dragged) {
+ if (!this->ctrl_dragged) {
/* snapping */
- Box3D::PerspectiveLine pline (bc->drag_ptB, Proj::Z, document->getCurrentPersp3D());
- bc->drag_ptC = pline.closest_to (motion_dt);
+ Box3D::PerspectiveLine pline (this->drag_ptB, Proj::Z, document->getCurrentPersp3D());
+ this->drag_ptC = pline.closest_to (motion_dt);
- bc->drag_ptB_proj.normalize();
- bc->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (bc->drag_ptC, bc->drag_ptB_proj[Proj::X], Proj::X);
+ 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 {
- bc->drag_ptC = motion_dt;
+ this->drag_ptC = motion_dt;
- bc->drag_ptB_proj.normalize();
- bc->drag_ptC_proj = cur_persp->perspective_impl->tmat.preimage (motion_dt, bc->drag_ptB_proj[Proj::X], Proj::X);
+ 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.freeSnapReturnByRef(bc->drag_ptC, Inkscape::SNAPSOURCE_NODE_HANDLE);
+
+ m.freeSnapReturnByRef(this->drag_ptC, Inkscape::SNAPSOURCE_NODE_HANDLE);
}
+
m.unSetup();
- sp_box3d_drag(*bc, event->motion.state);
+ this->drag(event->motion.state);
ret = TRUE;
- } else if (!sp_event_context_knot_mouseover(bc)) {
+ } else if (!sp_event_context_knot_mouseover(this)) {
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
@@ -381,33 +337,36 @@ gint Box3DContext::root_handler(GdkEvent* event) {
m.unSetup();
}
break;
+
case GDK_BUTTON_RELEASE:
- event_context->xp = event_context->yp = 0;
- if ( event->button.button == 1 && !event_context->space_panning) {
+ this->xp = this->yp = 0;
+
+ if (event->button.button == 1 && !this->space_panning) {
dragging = false;
- sp_event_context_discard_delayed_snap_event(event_context);
+ sp_event_context_discard_delayed_snap_event(this);
- if (!event_context->within_tolerance) {
+ if (!this->within_tolerance) {
// we've been dragging, finish the box
- sp_box3d_finish(bc);
- } else if (event_context->item_to_select) {
- // no dragging, select clicked item if any
+ this->finishItem();
+ } else if (this->item_to_select) {
+ // no dragging, select clicked box3d if any
if (event->button.state & GDK_SHIFT_MASK) {
- selection->toggle(event_context->item_to_select);
+ selection->toggle(this->item_to_select);
} else {
- selection->set(event_context->item_to_select);
+ selection->set(this->item_to_select);
}
} else {
// click in an empty space
selection->clear();
}
- event_context->item_to_select = NULL;
+ this->item_to_select = NULL;
ret = TRUE;
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
event->button.time);
}
break;
+
case GDK_KEY_PRESS:
switch (get_group0_keyval (&event->key)) {
case GDK_KEY_Up:
@@ -495,9 +454,10 @@ gint Box3DContext::root_handler(GdkEvent* event) {
desktop->setToolboxFocusTo ("altx-box3d");
ret = TRUE;
}
+
if (MOD__SHIFT_ONLY) {
persp3d_toggle_VPs(selection->perspList(), Proj::X);
- bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
+ this->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
ret = true;
}
break;
@@ -506,7 +466,7 @@ gint Box3DContext::root_handler(GdkEvent* event) {
case GDK_KEY_Y:
if (MOD__SHIFT_ONLY) {
persp3d_toggle_VPs(selection->perspList(), Proj::Y);
- bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
+ this->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
ret = true;
}
break;
@@ -515,7 +475,7 @@ gint Box3DContext::root_handler(GdkEvent* event) {
case GDK_KEY_Z:
if (MOD__SHIFT_ONLY) {
persp3d_toggle_VPs(selection->perspList(), Proj::Z);
- bc->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
+ this->_vpdrag->updateLines(); // FIXME: Shouldn't this be done automatically?
ret = true;
}
break;
@@ -530,56 +490,50 @@ gint Box3DContext::root_handler(GdkEvent* event) {
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
event->button.time);
dragging = false;
- sp_event_context_discard_delayed_snap_event(event_context);
- if (!event_context->within_tolerance) {
+ sp_event_context_discard_delayed_snap_event(this);
+ if (!this->within_tolerance) {
// we've been dragging, finish the box
- sp_box3d_finish(bc);
+ 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:
- ret = event_context->deleteSelectedDrag(MOD__CTRL_ONLY);
+ ret = this->deleteSelectedDrag(MOD__CTRL_ONLY);
break;
default:
break;
}
break;
+
default:
break;
}
if (!ret) {
-// if (((SPEventContextClass *) sp_box3d_context_parent_class)->root_handler) {
-// ret = ((SPEventContextClass *) sp_box3d_context_parent_class)->root_handler(event_context, event);
-// }
ret = SPEventContext::root_handler(event);
}
return ret;
}
-static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
-{
- SPDesktop *desktop = bc.desktop;
-
- if (!bc.item) {
-
- if (Inkscape::have_viable_layer(desktop, bc._message_context) == false) {
+void Box3DContext::drag(guint state) {
+ if (!this->box3d) {
+ if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) {
return;
}
// Create object
- SPBox3D *box3d = 0;
- box3d = SPBox3D::createBox3D((SPItem *)desktop->currentLayer());
+ SPBox3D *box3d = SPBox3D::createBox3D((SPItem*)desktop->currentLayer());
// Set style
desktop->applyCurrentOrToolStyle(box3d, "/tools/shapes/3dbox", false);
- bc.item = box3d;
+ this->box3d = box3d;
// TODO: Incorporate this in box3d-side.cpp!
for (int i = 0; i < 6; ++i) {
@@ -599,13 +553,14 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
Glib::ustring descr = "/desktop/";
descr += box3d_side_axes_string(side);
descr += "/style";
+
Glib::ustring cur_style = prefs->getString(descr);
bool use_current = prefs->getBool("/tools/shapes/3dbox/usecurrent", false);
+
if (use_current && !cur_style.empty()) {
// use last used style
side->setAttribute("style", cur_style.data());
-
} else {
// use default style
GString *pstring = g_string_new("");
@@ -616,71 +571,59 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
side->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
}
- box3d_set_z_orders(SP_BOX3D(bc.item));
- bc.item->updateRepr();
+ 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"
- /* bc._vpdrag->updateDraggers(); */
+ /* this._vpdrag->updateDraggers(); */
desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
- g_assert(bc.item);
-
- SPBox3D *box = SP_BOX3D(bc.item);
+ g_assert(this->box3d);
- box->orig_corner0 = bc.drag_origin_proj;
- box->orig_corner7 = bc.drag_ptC_proj;
+ this->box3d->orig_corner0 = this->drag_origin_proj;
+ this->box3d->orig_corner7 = this->drag_ptC_proj;
- box3d_check_for_swapped_coords(box);
+ box3d_check_for_swapped_coords(this->box3d);
/* we need to call this from here (instead of from box3d_position_set(), for example)
because z-order setting must not interfere with display updates during undo/redo */
- box3d_set_z_orders (box);
+ box3d_set_z_orders (this->box3d);
- box3d_position_set(box);
+ box3d_position_set(this->box3d);
// status text
- bc._message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
+ this->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
}
-static void sp_box3d_finish(Box3DContext *bc)
-{
- bc->_message_context->clear();
- bc->ctrl_dragged = false;
- bc->extruded = false;
+void Box3DContext::finishItem() {
+ this->_message_context->clear();
+ this->ctrl_dragged = false;
+ this->extruded = false;
- if ( bc->item != NULL ) {
- SPDesktop * desktop = SP_EVENT_CONTEXT_DESKTOP(bc);
- SPDocument *doc = sp_desktop_document(desktop);
- if (!doc || !doc->getCurrentPersp3D())
- return;
+ if (this->box3d != NULL) {
+ SPDocument *doc = sp_desktop_document(this->desktop);
- SPBox3D *box = SP_BOX3D(bc->item);
+ if (!doc || !doc->getCurrentPersp3D()) {
+ return;
+ }
- box->orig_corner0 = bc->drag_origin_proj;
- box->orig_corner7 = bc->drag_ptC_proj;
+ this->box3d->orig_corner0 = this->drag_origin_proj;
+ this->box3d->orig_corner7 = this->drag_ptC_proj;
- box->updateRepr();
+ this->box3d->updateRepr();
- box3d_relabel_corners(box);
+ box3d_relabel_corners(this->box3d);
desktop->canvas->endForcedFullRedraws();
- sp_desktop_selection(desktop)->set(bc->item);
+ sp_desktop_selection(desktop)->set(this->box3d);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_3DBOX,
_("Create 3D box"));
- bc->item = NULL;
- }
-}
-
-void sp_box3d_context_update_lines(SPEventContext *ec) {
- /* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
- if (SP_IS_BOX3D_CONTEXT (ec)) {
- Box3DContext *bc = SP_BOX3D_CONTEXT (ec);
- bc->_vpdrag->updateLines();
+ this->box3d = NULL;
}
}