diff options
Diffstat (limited to 'src/vanishing-point.cpp')
| -rw-r--r-- | src/vanishing-point.cpp | 358 |
1 files changed, 170 insertions, 188 deletions
diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index d849b35d9..b4808d484 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -20,12 +20,12 @@ #include "desktop.h" #include "display/sp-canvas-item.h" #include "display/sp-ctrlline.h" -#include "ui/tools/tool-base.h" +#include "document-undo.h" #include "perspective-line.h" -#include "ui/shape-editor.h" #include "snap.h" #include "sp-namedview.h" -#include "document-undo.h" +#include "ui/shape-editor.h" +#include "ui/tools/tool-base.h" #include "verbs.h" using Inkscape::CTLINE_PRIMARY; @@ -48,45 +48,41 @@ namespace Box3D { #define MERGE_DIST 0.1 // knot shapes corresponding to GrPointType enum -SPKnotShapeType vp_knot_shapes [] = { - SP_KNOT_SHAPE_SQUARE, // VP_FINITE - SP_KNOT_SHAPE_CIRCLE //VP_INFINITE +SPKnotShapeType vp_knot_shapes[] = { + SP_KNOT_SHAPE_SQUARE, // VP_FINITE + SP_KNOT_SHAPE_CIRCLE // VP_INFINITE }; -static void -vp_drag_sel_changed(Inkscape::Selection */*selection*/, gpointer data) +static void vp_drag_sel_changed(Inkscape::Selection * /*selection*/, gpointer data) { - VPDrag *drag = (VPDrag *) data; + VPDrag *drag = (VPDrag *)data; drag->updateDraggers(); drag->updateLines(); drag->updateBoxReprs(); } -static void -vp_drag_sel_modified (Inkscape::Selection */*selection*/, guint /*flags*/, gpointer data) +static void vp_drag_sel_modified(Inkscape::Selection * /*selection*/, guint /*flags*/, gpointer data) { - VPDrag *drag = (VPDrag *) data; - drag->updateLines (); - //drag->updateBoxReprs(); - drag->updateBoxHandles (); // FIXME: Only update the handles of boxes on this dragger (not on all) - drag->updateDraggers (); + VPDrag *drag = (VPDrag *)data; + drag->updateLines(); + // drag->updateBoxReprs(); + drag->updateBoxHandles(); // FIXME: Only update the handles of boxes on this dragger (not on all) + drag->updateDraggers(); } -static bool -have_VPs_of_same_perspective (VPDragger *dr1, VPDragger *dr2) +static bool have_VPs_of_same_perspective(VPDragger *dr1, VPDragger *dr2) { for (std::list<VanishingPoint>::iterator i = dr1->vps.begin(); i != dr1->vps.end(); ++i) { - if (dr2->hasPerspective ((*i).get_perspective())) { + if (dr2->hasPerspective((*i).get_perspective())) { return true; } } return false; } -static void -vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, gpointer data) +static void vp_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gpointer data) { - VPDragger *dragger = (VPDragger *) data; + VPDragger *dragger = (VPDragger *)data; VPDrag *drag = dragger->parent; Geom::Point p = ppointer; @@ -102,16 +98,16 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g /* with Shift; if there is more than one box linked to this VP we need to split it and create a new perspective */ if (dragger->numberOfBoxes() > 1) { // FIXME: Don't do anything if *all* boxes of a VP are selected - std::set<VanishingPoint*, less_ptr> sel_vps = dragger->VPsOfSelectedBoxes(); + std::set<VanishingPoint *, less_ptr> sel_vps = dragger->VPsOfSelectedBoxes(); std::list<SPBox3D *> sel_boxes; - for (std::set<VanishingPoint*, less_ptr>::iterator vp = sel_vps.begin(); vp != sel_vps.end(); ++vp) { + for (std::set<VanishingPoint *, less_ptr>::iterator vp = sel_vps.begin(); vp != sel_vps.end(); ++vp) { // for each VP that has selected boxes: Persp3D *old_persp = (*vp)->get_perspective(); sel_boxes = (*vp)->selectedBoxes(SP_ACTIVE_DESKTOP->getSelection()); // we create a new perspective ... - Persp3D *new_persp = persp3d_create_xml_element (dragger->parent->document, old_persp->perspective_impl); + Persp3D *new_persp = persp3d_create_xml_element(dragger->parent->document, old_persp->perspective_impl); /* ... unlink the boxes from the old one and FIXME: We need to unlink the _un_selected boxes of each VP so that @@ -126,19 +122,19 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g } } // FIXME: Do we need to create a new dragger as well? - dragger->updateZOrders (); - DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_3DBOX, - _("Split vanishing points")); + dragger->updateZOrders(); + DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_3DBOX, _("Split vanishing points")); return; } } if (!(state & GDK_SHIFT_MASK)) { // without Shift; see if we need to snap to another dragger - for (std::vector<VPDragger *>::const_iterator di = dragger->parent->draggers.begin(); di != dragger->parent->draggers.end(); ++di) { - VPDragger *d_new = *di; - if ((d_new != dragger) && (Geom::L2 (d_new->point - p) < snap_dist)) { - if (have_VPs_of_same_perspective (dragger, d_new)) { + for (std::vector<VPDragger *>::const_iterator di = dragger->parent->draggers.begin(); + di != dragger->parent->draggers.end(); ++di) { + VPDragger *d_new = *di; + if ((d_new != dragger) && (Geom::L2(d_new->point - p) < snap_dist)) { + if (have_VPs_of_same_perspective(dragger, d_new)) { // this would result in degenerate boxes, which we disallow for the time being continue; } @@ -153,7 +149,8 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g d_new->vps.merge(dragger->vps); // ... delete old dragger ... - drag->draggers.erase(std::remove(drag->draggers.begin(), drag->draggers.end(), dragger),drag->draggers.end()); + drag->draggers.erase(std::remove(drag->draggers.begin(), drag->draggers.end(), dragger), + drag->draggers.end()); delete dragger; dragger = NULL; @@ -163,25 +160,27 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g // TODO: Update the new merged dragger d_new->updateTip(); - d_new->parent->updateBoxDisplays (); // FIXME: Only update boxes in current dragger! - d_new->updateZOrders (); + d_new->parent->updateBoxDisplays(); // FIXME: Only update boxes in current dragger! + d_new->updateZOrders(); - drag->updateLines (); + drag->updateLines(); // TODO: Undo machinery; this doesn't work yet because perspectives must be created and // deleted according to changes in the svg representation, not based on any user input // as is currently the case. DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_3DBOX, - _("Merge vanishing points")); + _("Merge vanishing points")); return; } } } - // We didn't hit the return statement above, so we didn't snap to another dragger. Therefore we'll now try a regular snap - // Regardless of the status of the SHIFT key, we will try to snap; Here SHIFT does not disable snapping, as the shift key + // We didn't hit the return statement above, so we didn't snap to another dragger. Therefore we'll now try a regular + // snap + // Regardless of the status of the SHIFT key, we will try to snap; Here SHIFT does not disable snapping, as the + // shift key // has a different purpose in this context (see above) SPDesktop *desktop = SP_ACTIVE_DESKTOP; SnapManager &m = desktop->namedview->snap_manager; @@ -197,7 +196,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g dragger->updateVPs(p); dragger->updateBoxDisplays(); - dragger->parent->updateBoxHandles (); // FIXME: Only update the handles of boxes on this dragger (not on all) + dragger->parent->updateBoxHandles(); // FIXME: Only update the handles of boxes on this dragger (not on all) dragger->updateZOrders(); drag->updateLines(); @@ -205,59 +204,56 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g dragger->dragging_started = true; } -static void -vp_knot_grabbed_handler (SPKnot */*knot*/, unsigned int /*state*/, gpointer data) +static void vp_knot_grabbed_handler(SPKnot * /*knot*/, unsigned int /*state*/, gpointer data) { - VPDragger *dragger = (VPDragger *) data; + VPDragger *dragger = (VPDragger *)data; VPDrag *drag = dragger->parent; drag->dragging = true; } -static void -vp_knot_ungrabbed_handler (SPKnot *knot, guint /*state*/, gpointer data) +static void vp_knot_ungrabbed_handler(SPKnot *knot, guint /*state*/, gpointer data) { - VPDragger *dragger = (VPDragger *) data; + VPDragger *dragger = (VPDragger *)data; dragger->point_original = dragger->point = knot->pos; dragger->dragging_started = false; for (std::list<VanishingPoint>::iterator i = dragger->vps.begin(); i != dragger->vps.end(); ++i) { - (*i).set_pos (knot->pos); + (*i).set_pos(knot->pos); (*i).updateBoxReprs(); (*i).updatePerspRepr(); } - dragger->parent->updateDraggers (); - dragger->parent->updateLines (); - dragger->parent->updateBoxHandles (); + dragger->parent->updateDraggers(); + dragger->parent->updateLines(); + dragger->parent->updateBoxHandles(); // TODO: Update box's paths and svg representation dragger->parent->dragging = false; // TODO: Undo machinery!! - g_return_if_fail (dragger->parent); - g_return_if_fail (dragger->parent->document); - DocumentUndo::done(dragger->parent->document, SP_VERB_CONTEXT_3DBOX, - _("3D box: Move vanishing point")); + g_return_if_fail(dragger->parent); + g_return_if_fail(dragger->parent->document); + DocumentUndo::done(dragger->parent->document, SP_VERB_CONTEXT_3DBOX, _("3D box: Move vanishing point")); } unsigned int VanishingPoint::global_counter = 0; // FIXME: Rename to something more meaningful! -void -VanishingPoint::set_pos(Proj::Pt2 const &pt) { - g_return_if_fail (_persp); - _persp->perspective_impl->tmat.set_image_pt (_axis, pt); +void VanishingPoint::set_pos(Proj::Pt2 const &pt) +{ + g_return_if_fail(_persp); + _persp->perspective_impl->tmat.set_image_pt(_axis, pt); } -std::list<SPBox3D *> -VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { +std::list<SPBox3D *> VanishingPoint::selectedBoxes(Inkscape::Selection *sel) +{ std::list<SPBox3D *> sel_boxes; - auto itemlist= sel->items(); - for (auto i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist = sel->items(); + for (auto i = itemlist.begin(); i != itemlist.end(); ++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box && this->hasBox(box)) { @@ -267,13 +263,13 @@ VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { return sel_boxes; } -VPDragger::VPDragger(VPDrag *parent, Geom::Point p, VanishingPoint &vp) : - parent(parent), - knot(NULL), - point(p), - point_original(p), - dragging_started(false), - vps() +VPDragger::VPDragger(VPDrag *parent, Geom::Point p, VanishingPoint &vp) + : parent(parent) + , knot(NULL) + , point(p) + , point_original(p) + , dragging_started(false) + , vps() { if (vp.is_finite()) { // create the knot @@ -290,12 +286,15 @@ VPDragger::VPDragger(VPDrag *parent, Geom::Point p, VanishingPoint &vp) : this->knot->show(); // connect knot's signals - this->_moved_connection = this->knot->moved_signal.connect(sigc::bind(sigc::ptr_fun(vp_knot_moved_handler), this)); - this->_grabbed_connection = this->knot->grabbed_signal.connect(sigc::bind(sigc::ptr_fun(vp_knot_grabbed_handler), this)); - this->_ungrabbed_connection = this->knot->ungrabbed_signal.connect(sigc::bind(sigc::ptr_fun(vp_knot_ungrabbed_handler), this)); + this->_moved_connection = + this->knot->moved_signal.connect(sigc::bind(sigc::ptr_fun(vp_knot_moved_handler), this)); + this->_grabbed_connection = + this->knot->grabbed_signal.connect(sigc::bind(sigc::ptr_fun(vp_knot_grabbed_handler), this)); + this->_ungrabbed_connection = + this->knot->ungrabbed_signal.connect(sigc::bind(sigc::ptr_fun(vp_knot_ungrabbed_handler), this)); // add the initial VP (which may be NULL!) - this->addVP (vp); + this->addVP(vp); } } @@ -313,39 +312,42 @@ VPDragger::~VPDragger() /** Updates the statusbar tip of the dragger knot, based on its draggables */ -void -VPDragger::updateTip () +void VPDragger::updateTip() { if (this->knot && this->knot->tip) { - g_free (this->knot->tip); + g_free(this->knot->tip); this->knot->tip = NULL; } guint num = this->numberOfBoxes(); if (this->vps.size() == 1) { if (this->vps.front().is_finite()) { - this->knot->tip = g_strdup_printf (ngettext("<b>Finite</b> vanishing point shared by <b>%d</b> box", - "<b>Finite</b> vanishing point shared by <b>%d</b> boxes; drag with <b>Shift</b> to separate selected box(es)", - num), - num); - } else { + this->knot->tip = g_strdup_printf(ngettext("<b>Finite</b> vanishing point shared by <b>%d</b> box", + "<b>Finite</b> vanishing point shared by <b>%d</b> boxes; drag " + "with <b>Shift</b> to separate selected box(es)", + num), + num); + } + else { // This won't make sense any more when infinite VPs are not shown on the canvas, // but currently we update the status message anyway - this->knot->tip = g_strdup_printf (ngettext("<b>Infinite</b> vanishing point shared by <b>%d</b> box", - "<b>Infinite</b> vanishing point shared by <b>%d</b> boxes; drag with <b>Shift</b> to separate selected box(es)", - num), - num); + this->knot->tip = g_strdup_printf(ngettext("<b>Infinite</b> vanishing point shared by <b>%d</b> box", + "<b>Infinite</b> vanishing point shared by <b>%d</b> boxes; " + "drag with <b>Shift</b> to separate selected box(es)", + num), + num); } - } else { + } + else { int length = this->vps.size(); - char *desc1 = g_strdup_printf ("Collection of <b>%d</b> vanishing points ", length); - char *desc2 = g_strdup_printf (ngettext("shared by <b>%d</b> box; drag with <b>Shift</b> to separate selected box(es)", - "shared by <b>%d</b> boxes; drag with <b>Shift</b> to separate selected box(es)", - num), - num); + char *desc1 = g_strdup_printf("Collection of <b>%d</b> vanishing points ", length); + char *desc2 = g_strdup_printf( + ngettext("shared by <b>%d</b> box; drag with <b>Shift</b> to separate selected box(es)", + "shared by <b>%d</b> boxes; drag with <b>Shift</b> to separate selected box(es)", num), + num); this->knot->tip = g_strconcat(desc1, desc2, NULL); - g_free (desc1); - g_free (desc2); + g_free(desc1); + g_free(desc2); } } @@ -353,34 +355,32 @@ VPDragger::updateTip () * Adds a vanishing point to the dragger (also updates the position if necessary); * the perspective is stored separately, too, for efficiency in updating boxes. */ -void -VPDragger::addVP (VanishingPoint &vp, bool update_pos) +void VPDragger::addVP(VanishingPoint &vp, bool update_pos) { - if (!vp.is_finite() || std::find (vps.begin(), vps.end(), vp) != vps.end()) { + if (!vp.is_finite() || std::find(vps.begin(), vps.end(), vp) != vps.end()) { // don't add infinite VPs; don't add the same VP twice return; } if (update_pos) { - vp.set_pos (this->point); + vp.set_pos(this->point); } - this->vps.push_front (vp); + this->vps.push_front(vp); this->updateTip(); } -void -VPDragger::removeVP (VanishingPoint const &vp) +void VPDragger::removeVP(VanishingPoint const &vp) { - std::list<VanishingPoint>::iterator i = std::find (this->vps.begin(), this->vps.end(), vp); + std::list<VanishingPoint>::iterator i = std::find(this->vps.begin(), this->vps.end(), vp); if (i != this->vps.end()) { - this->vps.erase (i); + this->vps.erase(i); } this->updateTip(); } -VanishingPoint * -VPDragger::findVPWithBox (SPBox3D *box) { +VanishingPoint *VPDragger::findVPWithBox(SPBox3D *box) +{ for (std::list<VanishingPoint>::iterator vp = vps.begin(); vp != vps.end(); ++vp) { if ((*vp).hasBox(box)) { return &(*vp); @@ -389,28 +389,27 @@ VPDragger::findVPWithBox (SPBox3D *box) { return NULL; } -std::set<VanishingPoint*, less_ptr> -VPDragger::VPsOfSelectedBoxes() { - std::set<VanishingPoint*, less_ptr> sel_vps; +std::set<VanishingPoint *, less_ptr> VPDragger::VPsOfSelectedBoxes() +{ + std::set<VanishingPoint *, less_ptr> sel_vps; VanishingPoint *vp; // FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference. Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); - auto itemlist= sel->items(); - for (auto i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist = sel->items(); + for (auto i = itemlist.begin(); i != itemlist.end(); ++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { vp = this->findVPWithBox(box); if (vp) { - sel_vps.insert (vp); + sel_vps.insert(vp); } } } return sel_vps; } -guint -VPDragger::numberOfBoxes () +guint VPDragger::numberOfBoxes() { guint num = 0; for (std::list<VanishingPoint>::iterator vp = vps.begin(); vp != vps.end(); ++vp) { @@ -419,8 +418,7 @@ VPDragger::numberOfBoxes () return num; } -bool -VPDragger::hasPerspective (const Persp3D *persp) +bool VPDragger::hasPerspective(const Persp3D *persp) { for (std::list<VanishingPoint>::iterator i = vps.begin(); i != vps.end(); ++i) { if (persp3d_perspectives_coincide(persp, (*i).get_perspective())) { @@ -430,8 +428,7 @@ VPDragger::hasPerspective (const Persp3D *persp) return false; } -void -VPDragger::mergePerspectives () +void VPDragger::mergePerspectives() { Persp3D *persp1, *persp2; for (std::list<VanishingPoint>::iterator i = vps.begin(); i != vps.end(); ++i) { @@ -442,7 +439,7 @@ VPDragger::mergePerspectives () /* don't merge a perspective with itself */ continue; } - if (persp3d_perspectives_coincide(persp1,persp2)) { + if (persp3d_perspectives_coincide(persp1, persp2)) { /* if perspectives coincide but are not the same, merge them */ persp3d_absorb(persp1, persp2); @@ -454,39 +451,36 @@ VPDragger::mergePerspectives () } } -void -VPDragger::updateBoxDisplays () +void VPDragger::updateBoxDisplays() { for (std::list<VanishingPoint>::iterator i = this->vps.begin(); i != this->vps.end(); ++i) { (*i).updateBoxDisplays(); } } -void -VPDragger::updateVPs (Geom::Point const &pt) +void VPDragger::updateVPs(Geom::Point const &pt) { for (std::list<VanishingPoint>::iterator i = this->vps.begin(); i != this->vps.end(); ++i) { - (*i).set_pos (pt); + (*i).set_pos(pt); } } -void -VPDragger::updateZOrders () +void VPDragger::updateZOrders() { for (std::list<VanishingPoint>::iterator i = this->vps.begin(); i != this->vps.end(); ++i) { persp3d_update_z_orders((*i).get_perspective()); } } -void -VPDragger::printVPs() { - g_print ("VPDragger at position (%f, %f):\n", point[Geom::X], point[Geom::Y]); +void VPDragger::printVPs() +{ + g_print("VPDragger at position (%f, %f):\n", point[Geom::X], point[Geom::Y]); for (std::list<VanishingPoint>::iterator i = this->vps.begin(); i != this->vps.end(); ++i) { - g_print (" VP %s\n", (*i).axisString()); + g_print(" VP %s\n", (*i).axisString()); } } -VPDrag::VPDrag (SPDocument *document) +VPDrag::VPDrag(SPDocument *document) { this->document = document; this->selection = SP_ACTIVE_DESKTOP->getSelection(); @@ -496,20 +490,15 @@ VPDrag::VPDrag (SPDocument *document) this->dragging = false; - this->sel_changed_connection = this->selection->connectChanged( - sigc::bind ( - sigc::ptr_fun(&vp_drag_sel_changed), - (gpointer)this ) + this->sel_changed_connection = + this->selection->connectChanged(sigc::bind(sigc::ptr_fun(&vp_drag_sel_changed), (gpointer) this) - ); - this->sel_modified_connection = this->selection->connectModified( - sigc::bind( - sigc::ptr_fun(&vp_drag_sel_modified), - (gpointer)this ) - ); + ); + this->sel_modified_connection = + this->selection->connectModified(sigc::bind(sigc::ptr_fun(&vp_drag_sel_modified), (gpointer) this)); - this->updateDraggers (); - this->updateLines (); + this->updateDraggers(); + this->updateLines(); } VPDrag::~VPDrag() @@ -525,14 +514,13 @@ VPDrag::~VPDrag() for (std::vector<SPCtrlLine *>::const_iterator i = this->lines.begin(); i != this->lines.end(); ++i) { sp_canvas_item_destroy(SP_CANVAS_ITEM(*i)); } - this->lines.clear(); + this->lines.clear(); } /** * Select the dragger that has the given VP. */ -VPDragger * -VPDrag::getDraggerFor (VanishingPoint const &vp) +VPDragger *VPDrag::getDraggerFor(VanishingPoint const &vp) { for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { VPDragger *dragger = *i; @@ -546,22 +534,20 @@ VPDrag::getDraggerFor (VanishingPoint const &vp) return NULL; } -void -VPDrag::printDraggers () +void VPDrag::printDraggers() { - g_print ("=== VPDrag info: =================================\n"); + g_print("=== VPDrag info: =================================\n"); for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { (*i)->printVPs(); - g_print ("========\n"); + g_print("========\n"); } - g_print ("=================================================\n"); + g_print("=================================================\n"); } /** * Regenerates the draggers list from the current selection; is called when selection is changed or modified */ -void -VPDrag::updateDraggers () +void VPDrag::updateDraggers() { if (this->dragging) return; @@ -571,17 +557,17 @@ VPDrag::updateDraggers () } this->draggers.clear(); - g_return_if_fail (this->selection != NULL); + g_return_if_fail(this->selection != NULL); - auto itemlist= this->selection->items(); - for (auto i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist = this->selection->items(); + for (auto i = itemlist.begin(); i != itemlist.end(); ++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { VanishingPoint vp; for (int i = 0; i < 3; ++i) { vp.set(box3d_get_perspective(box), Proj::axes[i]); - addDragger (vp); + addDragger(vp); } } } @@ -591,8 +577,7 @@ VPDrag::updateDraggers () Regenerates the lines list from the current selection; is called on each move of a dragger, so that lines are always in sync with the actual perspective */ -void -VPDrag::updateLines () +void VPDrag::updateLines() { // delete old lines for (std::vector<SPCtrlLine *>::const_iterator i = this->lines.begin(); i != this->lines.end(); ++i) { @@ -601,24 +586,24 @@ VPDrag::updateLines () this->lines.clear(); // do nothing if perspective lines are currently disabled - if (this->show_lines == 0) return; + if (this->show_lines == 0) + return; - g_return_if_fail (this->selection != NULL); + g_return_if_fail(this->selection != NULL); - auto itemlist= this->selection->items(); - for (auto i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist = this->selection->items(); + for (auto i = itemlist.begin(); i != itemlist.end(); ++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { - this->drawLinesForFace (box, Proj::X); - this->drawLinesForFace (box, Proj::Y); - this->drawLinesForFace (box, Proj::Z); + this->drawLinesForFace(box, Proj::X); + this->drawLinesForFace(box, Proj::Y); + this->drawLinesForFace(box, Proj::Z); } } } -void -VPDrag::updateBoxHandles () +void VPDrag::updateBoxHandles() { // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? @@ -633,14 +618,13 @@ VPDrag::updateBoxHandles () } Inkscape::UI::Tools::ToolBase *ec = INKSCAPE.active_event_context(); - g_assert (ec != NULL); + g_assert(ec != NULL); if (ec->shape_editor != NULL) { ec->shape_editor->update_knotholder(); } } -void -VPDrag::updateBoxReprs () +void VPDrag::updateBoxReprs() { for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { VPDragger *dragger = *i; @@ -650,8 +634,7 @@ VPDrag::updateBoxReprs () } } -void -VPDrag::updateBoxDisplays () +void VPDrag::updateBoxDisplays() { for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { VPDragger *dragger = *i; @@ -665,7 +648,8 @@ VPDrag::updateBoxDisplays () /** * Depending on the value of all_lines, draw the front and/or rear perspective lines starting from the given corners. */ -void VPDrag::drawLinesForFace(const SPBox3D *box, Proj::Axis axis) //, guint corner1, guint corner2, guint corner3, guint corner4) +void VPDrag::drawLinesForFace(const SPBox3D *box, + Proj::Axis axis) //, guint corner1, guint corner2, guint corner3, guint corner4) { CtrlLineType type = CTLINE_PRIMARY; switch (axis) { @@ -684,10 +668,10 @@ void VPDrag::drawLinesForFace(const SPBox3D *box, Proj::Axis axis) //, guint cor } Geom::Point corner1, corner2, corner3, corner4; - box3d_corners_for_PLs (box, axis, corner1, corner2, corner3, corner4); + box3d_corners_for_PLs(box, axis, corner1, corner2, corner3, corner4); - g_return_if_fail (box3d_get_perspective(box)); - Proj::Pt2 vp = persp3d_get_VP (box3d_get_perspective(box), axis); + g_return_if_fail(box3d_get_perspective(box)); + Proj::Pt2 vp = persp3d_get_VP(box3d_get_perspective(box), axis); if (vp.is_finite()) { // draw perspective lines for finite VPs Geom::Point pt = vp.affine(); @@ -701,21 +685,22 @@ void VPDrag::drawLinesForFace(const SPBox3D *box, Proj::Axis axis) //, guint cor this->addLine(corner3, pt, type); this->addLine(corner4, pt, type); } - } else { + } + else { // draw perspective lines for infinite VPs boost::optional<Geom::Point> pt1, pt2, pt3, pt4; Persp3D *persp = box3d_get_perspective(box); SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: Store the desktop in VPDrag - Box3D::PerspectiveLine pl (corner1, axis, persp); + Box3D::PerspectiveLine pl(corner1, axis, persp); pt1 = pl.intersection_with_viewbox(desktop); - pl = Box3D::PerspectiveLine (corner2, axis, persp); + pl = Box3D::PerspectiveLine(corner2, axis, persp); pt2 = pl.intersection_with_viewbox(desktop); - pl = Box3D::PerspectiveLine (corner3, axis, persp); + pl = Box3D::PerspectiveLine(corner3, axis, persp); pt3 = pl.intersection_with_viewbox(desktop); - pl = Box3D::PerspectiveLine (corner4, axis, persp); + pl = Box3D::PerspectiveLine(corner4, axis, persp); pt4 = pl.intersection_with_viewbox(desktop); if (!pt1 || !pt2 || !pt3 || !pt4) { @@ -740,8 +725,7 @@ void VPDrag::drawLinesForFace(const SPBox3D *box, Proj::Axis axis) //, guint cor * otherwise create new dragger and add it to draggers list * We also store the corresponding perspective in case it is not already present. */ -void -VPDrag::addDragger (VanishingPoint &vp) +void VPDrag::addDragger(VanishingPoint &vp) { if (!vp.is_finite()) { // don't create draggers for infinite vanishing points @@ -751,9 +735,9 @@ VPDrag::addDragger (VanishingPoint &vp) for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { VPDragger *dragger = *i; - if (Geom::L2 (dragger->point - p) < MERGE_DIST) { + if (Geom::L2(dragger->point - p) < MERGE_DIST) { // distance is small, merge this draggable into dragger, no need to create new dragger - dragger->addVP (vp); + dragger->addVP(vp); return; } } @@ -763,13 +747,11 @@ VPDrag::addDragger (VanishingPoint &vp) this->draggers.push_back(new_dragger); } -void -VPDrag::swap_perspectives_of_VPs(Persp3D *persp2, Persp3D *persp1) +void VPDrag::swap_perspectives_of_VPs(Persp3D *persp2, Persp3D *persp1) { // iterate over all VP in all draggers and replace persp2 with persp1 for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { - for (std::list<VanishingPoint>::iterator j = (*i)->vps.begin(); - j != (*i)->vps.end(); ++j) { + for (std::list<VanishingPoint>::iterator j = (*i)->vps.begin(); j != (*i)->vps.end(); ++j) { if ((*j).get_perspective() == persp2) { (*j).set_perspective(persp1); } |
