summaryrefslogtreecommitdiffstats
path: root/src/vanishing-point.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2015-12-06 14:01:35 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2015-12-06 14:01:35 +0000
commit05e90b229e833b64bee150810953cf1328621b99 (patch)
tree68badf210187134c3c54335a92ba70da9a7ea748 /src/vanishing-point.cpp
parentcppification: GSList replaced by vectors (mostly related to gradients and mes... (diff)
downloadinkscape-05e90b229e833b64bee150810953cf1328621b99.tar.gz
inkscape-05e90b229e833b64bee150810953cf1328621b99.zip
cppification: GSList replaced by vectors (vanishing points)
(bzr r14504.1.3)
Diffstat (limited to '')
-rw-r--r--src/vanishing-point.cpp66
1 files changed, 30 insertions, 36 deletions
diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp
index 553e3a31d..295854787 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;
@@ -494,8 +494,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 +520,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 +537,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 +553,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,11 +569,10 @@ 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);
@@ -603,11 +598,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;
@@ -651,8 +645,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 +656,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 +752,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 +763,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 +784,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