This commit is contained in:
2017-03-12 16:49:12 +01:00
18 changed files with 531 additions and 81 deletions

View File

@@ -86,6 +86,82 @@ public:
}
float snap(const float val) {
const float s = 0.1;
return std::round(val / s) * s;
}
/** resize everything within the floorplay by the given factor */
void resize(const float sx, const float sy, const float sz, const float ox, const float oy, const float oz) {
for (Floorplan::Floor* f : im->floors) {
f->atHeight = snap(f->atHeight * sz);
f->height = snap(f->height * sz);
for (Floorplan::FloorOutlinePolygon* poly : f->outline) {
for (Point2& p : poly->poly.points) {
p.x = snap(p.x * sx + ox);
p.y = snap(p.y * sy + oy);
}
}
for (Floorplan::AccessPoint* ap : f->accesspoints) {
ap->pos.x = snap(ap->pos.x * sx + ox);
ap->pos.y = snap(ap->pos.y * sy + oy);
ap->pos.z = snap(ap->pos.z * sz + oz);
}
for (Floorplan::Beacon* b : f->beacons) {
b->pos.x = snap(b->pos.x * sx + ox);
b->pos.y = snap(b->pos.y * sy + oy);
b->pos.z = snap(b->pos.z * sz + oz);
}
for (Floorplan::POI* p : f->pois) {
p->pos.x = snap(p->pos.x * sx + ox);
p->pos.y = snap(p->pos.y * sy + oy);
}
for (Floorplan::FingerprintLocation* fpl : f->fpLocations) {
fpl->posOnFloor.x = snap(fpl->posOnFloor.x * sx + ox);
fpl->posOnFloor.y = snap(fpl->posOnFloor.y * sy + oy);
fpl->heightAboveFloor = snap(fpl->heightAboveFloor * sz + oz);
}
for (Floorplan::FloorObstacle* o : f->obstacles) {
Floorplan::FloorObstacleLine* line = dynamic_cast<Floorplan::FloorObstacleLine*>(o);
Floorplan::FloorObstacleDoor* door = dynamic_cast<Floorplan::FloorObstacleDoor*>(o);
if (line) {
line->from.x = snap(line->from.x * sx + ox);
line->from.y = snap(line->from.y * sy + oy);
line->to.x = snap(line->to.x * sx + ox);
line->to.y = snap(line->to.y * sy + oy);
} else if (door) {
door->from.x = snap(door->from.x * sx + ox);
door->from.y = snap(door->from.y * sy + oy);
door->to.x = snap(door->to.x * sx + ox);
door->to.y = snap(door->to.y * sy + oy);
}
}
for (Floorplan::Stair* s : f->stairs) {
Floorplan::StairFreeform* stair = dynamic_cast<Floorplan::StairFreeform*>(s);
for (Floorplan::StairPart& sp : stair->parts) {
sp.width = snap(sp.width * sx);
sp.end.x = snap(sp.end.x * sx + ox);
sp.end.y = snap(sp.end.y * sy + oy);
sp.end.z = snap(sp.end.z * sz + oz);
sp.start.x = snap(sp.start.x * sx + ox);
sp.start.y = snap(sp.start.y * sy + oy);
sp.start.z = snap(sp.start.z * sz + oz);
}
}
for (Floorplan::Elevator* e : f->elevators) {
e->center.x = snap(e->center.x * sx + ox);
e->center.y = snap(e->center.y * sy + oy);
e->width = snap(e->width * sx);
e->depth = snap(e->depth * sx);
}
}
}
void onLayerChanged(MapLayer* layer) override {
for (MapModelListener* l : listeners) {l->onLayerChanged(layer);}
}