Exemple #1
0
int ElbowGrabber::getZone(QPointF pos)
{
    qreal xDist = distanceX(this->pos(), pos);
    qreal yDist = distanceY(this->pos(), pos);

    bool xCross = xDist <= SNAP_DISTANCE;
    bool yCross = yDist <= SNAP_DISTANCE;

    if(xCross&&yCross)
    {
        if(xDist < yDist)
            return Zone::VERTICAL;
        else
            return Zone::FLAT;

    }
    else if(xCross )
    {
        // check if it is within a range
        return Zone::VERTICAL;
    }
    else if(yCross)
    {
        return Zone::FLAT;
    }
    else
    {
        return Zone::ANGLED;
    }
}
Exemple #2
0
void analyseCoastline(Way* w, Map* map){
	ListNode * ln = w->listNd;
	Node * first = searchNode(map->avl,w->listNd->firstRef->nd);
	Node* last = searchNode(map->avl,w->listNd->lastRef->nd);
	float dx = distanceX(last->c->x, first->c->x);
	float dy = distanceY(last->c->y, first->c->y);
	float a = (last->c->x - first->c->x)/ (last->c->y - first->c->y);

	if((dx >= map->bounds->max->x) && (dy < map->bounds->max->y) && (last->c->x <= 0) && (first->c->x >= map->bounds->max->x) && a > 0){ // horizontale bas
		w->listNd = addRefListNode((unsigned long)0, ln);
		w->listNd = addRefListNode((unsigned long)3, ln);
		w->size = w->size + 2;
	}
	else if((dx >= map->bounds->max->x) && (dy >= map->bounds->max->y) && (last->c->x <= 0) && (first->c->x >= map->bounds->max->x) && a < 0){ // horizontale bas
		w->listNd = addRefListNode((unsigned long)0, ln);
		w->listNd = addRefListNode((unsigned long)3, ln);
		w->size = w->size + 2;
	}
	else if((dx >= map->bounds->max->x) && (dy < map->bounds->max->y) && (first->c->x <= 0) && (last->c->x >= map->bounds->max->x) && a > 0){ // horizontale haut
		w->listNd = addRefListNode((unsigned long)2, ln);
		w->listNd = addRefListNode((unsigned long)1, ln);
		w->size = w->size + 2;
	}
	else if((dx >= map->bounds->max->x) && (dy >= map->bounds->max->y) && (first->c->x <= 0) && (last->c->x >= map->bounds->max->x) && a < 0){ // horizontale haut
		w->listNd = addRefListNode((unsigned long)2, ln);
		w->listNd = addRefListNode((unsigned long)1, ln);
		w->size = w->size + 2;
	}
	else if((dx >= map->bounds->max->x) && (dy >= map->bounds->max->y) && (first->c->x <= 0) && (last->c->y <0) && a < 0){ // horizontale haut
		w->listNd = addRefListNode((unsigned long)3, ln);
		w->listNd = addRefListNode((unsigned long)2, ln);
		w->size = w->size + 2;
	}

	else if((dy >= map->bounds->max->y) && (dx < map->bounds->max->x) && (last->c->y <= 0) && (first->c->y >= map->bounds->max->y) && a < 0){ // verticale
		w->listNd = addRefListNode((unsigned long)3, ln);
		w->listNd = addRefListNode((unsigned long)2, ln);
		w->size = w->size + 2;
	}
	else if((dy >= map->bounds->max->y) && (dx >= map->bounds->max->x) && (last->c->y <= 0) && (first->c->y >= map->bounds->max->y) && a > 0){ // verticale
		w->listNd = addRefListNode((unsigned long)3, ln);
		w->listNd = addRefListNode((unsigned long)2, ln);
		w->size = w->size + 2;
	}

	else if((dy >= map->bounds->max->y) && (dx < map->bounds->max->x) && (first->c->y <= 0) && (last->c->y >= map->bounds->max->y) && a > 0){ // verticale
		w->listNd = addRefListNode((unsigned long)1, ln);
		w->listNd = addRefListNode((unsigned long)0, ln);
		w->size = w->size + 2;
	}
	else if((dy >= map->bounds->max->y) && (dx >= map->bounds->max->x) && (first->c->y <= 0) && (last->c->y >= map->bounds->max->y) && a < 0){ // verticale
		w->listNd = addRefListNode((unsigned long)1, ln);
		w->listNd = addRefListNode((unsigned long)0, ln);
		w->size = w->size + 2;
	}
	else if(dx == 0 && dy == 0){		printf("null \n");
	return;
}
else if((first->c->x) > 0 && (last->c->x) > 0){
	if(((first->c->y) > (last->c->y))) { // haut droite
		w->listNd = addRefListNode((unsigned long)2, ln);
		w->size ++;
	}
}
else if((first->c->y) > 0 && (last->c->y) > 0){
	if((first->c->x)>(last->c->x)){ // haut gauche
		w->listNd = addRefListNode((unsigned long)1, ln);
		w->size ++;
	}
	else if((first->c->x) > (last->c->x)){ // bas droite
		w->listNd = addRefListNode((unsigned long)3, ln);
		w->size ++;
	}
}
else if(((first->c->x) < -(last->c->x)) && ((last->c->y) < -(first->c->y))){ //bas gauche
	w->listNd = addRefListNode((unsigned long)0, ln);
	w->size ++;
}
}