summaryrefslogtreecommitdiffstats
path: root/src/vanishing-point.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-03-15 21:57:03 +0000
committerJabiertxof <jtx@jtx.marker.es>2016-03-15 21:57:03 +0000
commit6bd1c2a30b66e15fe055b22bd47dadb771f7fae2 (patch)
tree1b991cc2736f84fb069666802d485bd29cff6394 /src/vanishing-point.cpp
parentUpdate to limit options to radius = 0, radious > 0 or both (diff)
parentfix-bug-1557192. paint-order crash with multiple items (diff)
downloadinkscape-6bd1c2a30b66e15fe055b22bd47dadb771f7fae2.tar.gz
inkscape-6bd1c2a30b66e15fe055b22bd47dadb771f7fae2.zip
Update to trunk
(bzr r13645.1.119)
Diffstat (limited to 'src/vanishing-point.cpp')
-rw-r--r--src/vanishing-point.cpp89
1 files changed, 41 insertions, 48 deletions
diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp
index 553e3a31d..32ccbad93 100644
--- a/src/vanishing-point.cpp
+++ b/src/vanishing-point.cpp
@@ -137,8 +137,8 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g
if (!(state & GDK_SHIFT_MASK)) {
// without Shift; see if we need to snap to another dragger
- for (GList *di = dragger->parent->draggers; di != NULL; di = di->next) {
- VPDragger *d_new = (VPDragger *) di->data;
+ 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
@@ -155,7 +155,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g
d_new->vps.merge(dragger->vps);
// ... delete old dragger ...
- drag->draggers = g_list_remove (drag->draggers, dragger);
+ drag->draggers.erase(std::remove(drag->draggers.begin(), drag->draggers.end(), dragger),drag->draggers.end());
delete dragger;
dragger = NULL;
@@ -259,7 +259,7 @@ std::list<SPBox3D *>
VanishingPoint::selectedBoxes(Inkscape::Selection *sel) {
std::list<SPBox3D *> sel_boxes;
std::vector<SPItem*> itemlist=sel->itemList();
- for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) {
+ for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) {
SPItem *item = *i;
SPBox3D *box = dynamic_cast<SPBox3D *>(item);
if (box && this->hasBox(box)) {
@@ -269,15 +269,14 @@ VanishingPoint::selectedBoxes(Inkscape::Selection *sel) {
return sel_boxes;
}
-VPDragger::VPDragger(VPDrag *parent, Geom::Point p, VanishingPoint &vp)
+VPDragger::VPDragger(VPDrag *parent, Geom::Point p, VanishingPoint &vp) :
+ parent(parent),
+ knot(NULL),
+ point(p),
+ point_original(p),
+ dragging_started(false),
+ vps()
{
- this->parent = parent;
-
- this->point = p;
- this->point_original = p;
-
- this->dragging_started = false;
-
if (vp.is_finite()) {
// create the knot
this->knot = new SPKnot(SP_ACTIVE_DESKTOP, NULL);
@@ -399,7 +398,7 @@ VPDragger::VPsOfSelectedBoxes() {
// 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();
std::vector<SPItem*> itemlist=sel->itemList();
- for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) {
+ for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) {
SPItem *item = *i;
SPBox3D *box = dynamic_cast<SPBox3D *>(item);
if (box) {
@@ -494,8 +493,6 @@ VPDrag::VPDrag (SPDocument *document)
this->document = document;
this->selection = SP_ACTIVE_DESKTOP->getSelection();
- this->draggers = NULL;
- this->lines = NULL;
this->show_lines = true;
this->front_or_rear_lines = 0x1;
@@ -522,17 +519,15 @@ VPDrag::~VPDrag()
this->sel_changed_connection.disconnect();
this->sel_modified_connection.disconnect();
- for (GList *l = this->draggers; l != NULL; l = l->next) {
- delete ((VPDragger *) l->data);
+ for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) {
+ delete (*i);
}
- g_list_free (this->draggers);
- this->draggers = NULL;
+ this->draggers.clear();
- for (GSList const *i = this->lines; i != NULL; i = i->next) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(i->data));
+ for (std::vector<SPCtrlLine *>::const_iterator i = this->lines.begin(); i != this->lines.end(); ++i) {
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(*i));
}
- g_slist_free (this->lines);
- this->lines = NULL;
+ this->lines.clear();
}
/**
@@ -541,8 +536,8 @@ VPDrag::~VPDrag()
VPDragger *
VPDrag::getDraggerFor (VanishingPoint const &vp)
{
- for (GList const* i = this->draggers; i != NULL; i = i->next) {
- VPDragger *dragger = (VPDragger *) i->data;
+ for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) {
+ VPDragger *dragger = *i;
for (std::list<VanishingPoint>::iterator j = dragger->vps.begin(); j != dragger->vps.end(); ++j) {
// TODO: Should we compare the pointers or the VPs themselves!?!?!?!
if (*j == vp) {
@@ -557,8 +552,8 @@ void
VPDrag::printDraggers ()
{
g_print ("=== VPDrag info: =================================\n");
- for (GList const* i = this->draggers; i != NULL; i = i->next) {
- ((VPDragger *) i->data)->printVPs();
+ for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) {
+ (*i)->printVPs();
g_print ("========\n");
}
g_print ("=================================================\n");
@@ -573,16 +568,15 @@ VPDrag::updateDraggers ()
if (this->dragging)
return;
// delete old draggers
- for (GList const* i = this->draggers; i != NULL; i = i->next) {
- delete ((VPDragger *) i->data);
+ for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) {
+ delete (*i);
}
- g_list_free (this->draggers);
- this->draggers = NULL;
+ this->draggers.clear();
g_return_if_fail (this->selection != NULL);
std::vector<SPItem*> itemlist=this->selection->itemList();
- for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) {
+ for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) {
SPItem *item = *i;
SPBox3D *box = dynamic_cast<SPBox3D *>(item);
if (box) {
@@ -603,11 +597,10 @@ void
VPDrag::updateLines ()
{
// delete old lines
- for (GSList const *i = this->lines; i != NULL; i = i->next) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(i->data));
+ for (std::vector<SPCtrlLine *>::const_iterator i = this->lines.begin(); i != this->lines.end(); ++i) {
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(*i));
}
- g_slist_free (this->lines);
- this->lines = NULL;
+ this->lines.clear();
// do nothing if perspective lines are currently disabled
if (this->show_lines == 0) return;
@@ -615,7 +608,7 @@ VPDrag::updateLines ()
g_return_if_fail (this->selection != NULL);
std::vector<SPItem*> itemlist=this->selection->itemList();
- for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) {
+ for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) {
SPItem *item = *i;
SPBox3D *box = dynamic_cast<SPBox3D *>(item);
if (box) {
@@ -651,8 +644,8 @@ VPDrag::updateBoxHandles ()
void
VPDrag::updateBoxReprs ()
{
- for (GList *i = this->draggers; i != NULL; i = i->next) {
- VPDragger *dragger = (VPDragger *) i->data;
+ for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) {
+ VPDragger *dragger = *i;
for (std::list<VanishingPoint>::iterator i = dragger->vps.begin(); i != dragger->vps.end(); ++i) {
(*i).updateBoxReprs();
}
@@ -662,8 +655,8 @@ VPDrag::updateBoxReprs ()
void
VPDrag::updateBoxDisplays ()
{
- for (GList *i = this->draggers; i != NULL; i = i->next) {
- VPDragger *dragger = (VPDragger *) i->data;
+ for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) {
+ VPDragger *dragger = *i;
for (std::list<VanishingPoint>::iterator i = dragger->vps.begin(); i != dragger->vps.end(); ++i) {
(*i).updateBoxDisplays();
}
@@ -758,8 +751,8 @@ VPDrag::addDragger (VanishingPoint &vp)
}
Geom::Point p = vp.get_pos();
- for (GList *i = this->draggers; i != NULL; i = i->next) {
- VPDragger *dragger = (VPDragger *) i->data;
+ 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) {
// distance is small, merge this draggable into dragger, no need to create new dragger
dragger->addVP (vp);
@@ -769,16 +762,16 @@ VPDrag::addDragger (VanishingPoint &vp)
VPDragger *new_dragger = new VPDragger(this, p, vp);
// fixme: draggers should be added AFTER the last one: this way tabbing through them will be from begin to end.
- this->draggers = g_list_append (this->draggers, new_dragger);
+ this->draggers.push_back(new_dragger);
}
void
VPDrag::swap_perspectives_of_VPs(Persp3D *persp2, Persp3D *persp1)
{
// iterate over all VP in all draggers and replace persp2 with persp1
- for (GList *i = this->draggers; i != NULL; i = i->next) {
- for (std::list<VanishingPoint>::iterator j = ((VPDragger *) (i->data))->vps.begin();
- j != ((VPDragger *) (i->data))->vps.end(); ++j) {
+ 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) {
if ((*j).get_perspective() == persp2) {
(*j).set_perspective(persp1);
}
@@ -790,7 +783,7 @@ void VPDrag::addLine(Geom::Point const &p1, Geom::Point const &p2, Inkscape::Ctr
{
SPCtrlLine *line = ControlManager::getManager().createControlLine(SP_ACTIVE_DESKTOP->getControls(), p1, p2, type);
sp_canvas_item_show(line);
- this->lines = g_slist_append(this->lines, line);
+ this->lines.push_back(line);
}
} // namespace Box3D