added elevator support
This commit is contained in:
@@ -122,7 +122,10 @@ HEADERS += MainWindow.h \
|
||||
mapview/elements/HasMoveableNodes.h \
|
||||
mapview/2D/MapView2D.h \
|
||||
mapview/2D/Painter.h \
|
||||
mapview/2D/Scaler.h
|
||||
mapview/2D/Scaler.h \
|
||||
mapview/2D/MV2DElementElevator.h \
|
||||
mapview/model/MMFloorElevators.h \
|
||||
mapview/model/MMFloorElevator.h
|
||||
|
||||
|
||||
FORMS += MainWindow.ui
|
||||
|
||||
@@ -85,8 +85,13 @@ MainController::MainController() {
|
||||
//mapModel->load("../IndoorMap/maps/test.xml");
|
||||
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/CAR/CAR9.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UAH/UAH7_test.xml");
|
||||
mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UJI-TI/UJI-TI4.xml");
|
||||
mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UAH/UAH9.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UJI-TI/UJI-TI4.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UJI-UB/UJI-UB4.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/Indoor/tests/data/WalkHeadingMap.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/test.xml");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
111
mapview/2D/MV2DElementElevator.h
Normal file
111
mapview/2D/MV2DElementElevator.h
Normal file
@@ -0,0 +1,111 @@
|
||||
#ifndef MV2DELEMENTELEVATOR_H
|
||||
#define MV2DELEMENTELEVATOR_H
|
||||
|
||||
#include "MV2DElement.h"
|
||||
#include "HasMoveableNodes.h"
|
||||
|
||||
#include "MapViewElementHelper.h"
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include "../../UIHelper.h"
|
||||
|
||||
class MV2DElementElevator : public MV2DElement, public HasMoveableNodes {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::Elevator* elevator;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the AP to render/edit */
|
||||
MV2DElementElevator(Floorplan::Elevator* elevator) : elevator(elevator) {;}
|
||||
|
||||
|
||||
BBox2 getBoundingBox() const override {
|
||||
BBox2 bbox;
|
||||
const float max = std::max(elevator->width, elevator->depth);
|
||||
bbox.add(Point2(elevator->center.x, elevator->center.y));
|
||||
bbox.grow(Point2(max/2, max/2));
|
||||
return bbox;
|
||||
}
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
float getMinDistanceXY(const Point2 p) const override {
|
||||
// std::vector<Point2> points = elevator->getPoints().points;
|
||||
// points.push_back(elevator->center);
|
||||
// auto it minEl = std::min_element(points.begin(), points.end(),
|
||||
return p.getDistance(elevator->center);
|
||||
}
|
||||
|
||||
/** repaint me */
|
||||
void paint(Painter& p) override {
|
||||
|
||||
// area
|
||||
const Floorplan::Polygon2 poly = elevator->getPoints();
|
||||
p.setPenBrush(Qt::gray, Qt::lightGray);
|
||||
p.drawPolygon(poly.points);
|
||||
|
||||
// outline
|
||||
QPen pen; pen.setWidth(2); pen.setColor(QColor(0,0,0));
|
||||
p.setPenBrush(pen, Qt::NoBrush);
|
||||
//p.drawLine(poly.points[0], poly.points[1]);
|
||||
p.drawLine(poly.points[1], poly.points[2]);
|
||||
p.drawLine(poly.points[2], poly.points[3]);
|
||||
p.drawLine(poly.points[3], poly.points[0]);
|
||||
|
||||
if (selectedUserIdx == 0) {
|
||||
p.setPenBrush(Qt::black, CFG::SEL_COLOR);
|
||||
p.drawCircle(elevator->center);
|
||||
} else if (hasFocus()) {
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
p.drawCircle(elevator->center);
|
||||
} else {
|
||||
//p.setPenBrush(Qt::gray, Qt::NoBrush);
|
||||
//p.drawCircle(elevator->center);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
virtual std::vector<MoveableNode> getMoveableNodes() const override {
|
||||
return { MoveableNode(0, elevator->center) };
|
||||
}
|
||||
|
||||
virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override {
|
||||
(void) v;
|
||||
if (userIdx == 0) {elevator->center.x = newPos.x; elevator->center.y = newPos.y;}
|
||||
}
|
||||
|
||||
|
||||
virtual void mousePressed(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
virtual void mouseMove(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
virtual void mouseReleased(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
virtual bool keyPressEvent(MapView2D* v, QKeyEvent *e) override {
|
||||
(void) v;
|
||||
(void) e;
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void onFocus() override {
|
||||
;
|
||||
}
|
||||
|
||||
virtual void onUnfocus() override {
|
||||
;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // MV2DELEMENTELEVATOR_H
|
||||
@@ -15,6 +15,8 @@ class MV2DElementFloorUnderlay : public MV2DElement {
|
||||
private:
|
||||
|
||||
QImage img;
|
||||
QImage imgScaled;
|
||||
|
||||
std::string tmpFile;
|
||||
Floorplan::UnderlayImage* underlay;
|
||||
BBox2 bbox;
|
||||
@@ -58,9 +60,8 @@ public:
|
||||
|
||||
if (tmpFile != underlay->filename) {
|
||||
img = QImage(underlay->filename.c_str());
|
||||
if (img.size().width() == 0) {
|
||||
missing();
|
||||
}
|
||||
if (img.size().width() == 0) { missing(); }
|
||||
img = img.convertToFormat(QImage::Format_Grayscale8); // saves a huge amount of memory and should suffice
|
||||
tmpFile = underlay->filename;
|
||||
}
|
||||
|
||||
@@ -79,17 +80,39 @@ public:
|
||||
float sy1 = p.s.yms(my1);
|
||||
float sx2 = p.s.xms(mx2);
|
||||
float sy2 = p.s.yms(my2);
|
||||
float sw = std::abs(sx1-sx2);
|
||||
float sh = std::abs(sy1-sy2);
|
||||
float sw = std::round(std::abs(sx1-sx2));
|
||||
float sh = std::round(std::abs(sy1-sy2));
|
||||
|
||||
const float origArea = img.width() * img.height();
|
||||
const float scaledArea = sw*sh;
|
||||
|
||||
bbox = BBox2();
|
||||
bbox.add(Point2(mx1, my1));
|
||||
bbox.add(Point2(mx2, my2));
|
||||
|
||||
|
||||
// if the to-be-displayed image is smaller than the input-one, use a pre-computed downscaled version
|
||||
if (scaledArea < origArea) {
|
||||
// does the cached downscaled image needs rebuild? (size changed)
|
||||
if (imgScaled.width() != sw || imgScaled.height() != sh) {
|
||||
imgScaled = img.scaled(sw, sh, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
} else {
|
||||
imgScaled = QImage();
|
||||
}
|
||||
|
||||
|
||||
float opacity = p.p->opacity();
|
||||
p.p->setOpacity(0.50f);
|
||||
p.p->drawImage(QRectF(sx1, sy1-sh, sw, sh), img, QRectF(0,0,img.width(),img.height()));
|
||||
|
||||
// render downscaled image from cache? or use live-upscaling (faster, eats up less memory, ...)
|
||||
if (imgScaled.width() > 0) {
|
||||
p.p->drawImage(sx1, sy1-sh, imgScaled);
|
||||
} else {
|
||||
p.p->setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
p.p->drawImage(QRectF(sx1, sy1-sh, sw, sh), img, QRectF(0,0,img.width(),img.height()));
|
||||
}
|
||||
|
||||
p.p->setOpacity(opacity);
|
||||
|
||||
// selected endpoint(s)?
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
GridFactory<MyNode> fac(grid);
|
||||
fac.build(im, &l);
|
||||
|
||||
Importance::addImportance(grid);
|
||||
Importance::addImportance(grid, &l);
|
||||
//Importance::addImportance(grid, 400);
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "MMFloorUnderlays.h"
|
||||
#include "MMFloorPOIs.h"
|
||||
#include "MMFloorStairs.h"
|
||||
#include "MMFloorElevators.h"
|
||||
|
||||
#include "IHasParams.h"
|
||||
|
||||
@@ -39,7 +40,7 @@ public:
|
||||
new MMFloorBeacons(this, floor);
|
||||
new MMFloorPOIs(this, floor);
|
||||
new MMFloorStairs(this, floor);
|
||||
|
||||
new MMFloorElevators(this, floor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
68
mapview/model/MMFloorElevator.h
Normal file
68
mapview/model/MMFloorElevator.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef MMFLOORELEVATOR_H
|
||||
#define MMFLOORELEVATOR_H
|
||||
|
||||
#include "MapModelElement.h"
|
||||
#include "IHasParams.h"
|
||||
|
||||
#include "../2D/MV2DElementElevator.h"
|
||||
//#include "../3D/MV3DElementElevator.h" TODO
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
class MMFloorElevator : public MapModelElement, public IHasParams {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::Floor* floor;
|
||||
Floorplan::Elevator* elevator;
|
||||
MV2DElementElevator mv2d;
|
||||
//MV3DElementElevator mv3d; TODO
|
||||
|
||||
public:
|
||||
|
||||
MMFloorElevator(MapLayer* parent, Floorplan::Floor* floor, Floorplan::Elevator* elevator) :
|
||||
MapModelElement(parent), floor(floor), elevator(elevator), mv2d(elevator) {
|
||||
|
||||
}
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 3;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("width", ParamType::FLOAT);
|
||||
case 1: return Param("depth", ParamType::FLOAT);
|
||||
case 2: return Param("rotation", ParamType::FLOAT);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return elevator->width;
|
||||
case 1: return elevator->depth;
|
||||
case 2: return (elevator->rotation * 180.0f / (float)M_PI);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
switch(idx) {
|
||||
case 0: elevator->width = val.toFloat(); break;
|
||||
case 1: elevator->depth = val.toFloat(); break;
|
||||
case 2: elevator->rotation = val.toFloat() / 180.0f * (float)M_PI; break;
|
||||
}
|
||||
}
|
||||
|
||||
MV2DElement* getMV2D() const override {return (MV2DElement*) &mv2d;}
|
||||
MV3DElement* getMV3D() const override {return nullptr;} // TODO
|
||||
|
||||
void deleteMe() const override {
|
||||
parent->removeElement(this);
|
||||
floor->elevators.erase(std::remove(floor->elevators.begin(), floor->elevators.end(), elevator), floor->elevators.end());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOORELEVATOR_H
|
||||
47
mapview/model/MMFloorElevators.h
Normal file
47
mapview/model/MMFloorElevators.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef MMFLOORELEVATORS_H
|
||||
#define MMFLOORELEVATORS_H
|
||||
|
||||
|
||||
#include "MapLayer.h"
|
||||
#include "MMFloorElevator.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
/**
|
||||
* layer containing one floor's elevators
|
||||
*/
|
||||
class MMFloorElevators : public MapLayer {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::Floor* floor;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the underlying model */
|
||||
MMFloorElevators(MapLayer* parent, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR_ELEVATORS), floor(floor) {
|
||||
|
||||
// add all elevators
|
||||
for (Floorplan::Elevator* elevator : floor->elevators) {
|
||||
elements.push_back(new MMFloorElevator(this, floor, elevator));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string getLayerName() const override {return "Elevators";}
|
||||
|
||||
//TODO: check
|
||||
void create(Floorplan::Elevator* elevator) {
|
||||
|
||||
// add to underlying model
|
||||
floor->elevators.push_back(elevator);
|
||||
|
||||
// add to myself as element
|
||||
elements.push_back(new MMFloorElevator(this, floor, elevator));
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // MMFLOORELEVATORS_H
|
||||
@@ -17,6 +17,7 @@ enum class MapLayerType {
|
||||
FLOOR_OBSTACLES,
|
||||
FLOOR_BEACONS,
|
||||
FLOOR_ACCESS_POINTS,
|
||||
FLOOR_ELEVATORS,
|
||||
FLOOR_UNDERLAYS,
|
||||
FLOOR_POIS,
|
||||
FLOOR_STAIRS,
|
||||
|
||||
@@ -57,6 +57,11 @@ ToolBoxWidget::ToolBoxWidget(MapView2D* view, QWidget *parent) : QWidget(parent)
|
||||
lay->addWidget(btnStair, r++, 0, 1,1,Qt::AlignTop);
|
||||
connect(btnStair, SIGNAL(clicked(bool)), this, SLOT(onNewStair()));
|
||||
|
||||
btnElevator = new QPushButton(UIHelper::getIcon("elevator"), "");
|
||||
btnElevator->setMinimumSize(s,s);
|
||||
lay->addWidget(btnElevator, r++, 0, 1,1,Qt::AlignTop);
|
||||
connect(btnElevator, SIGNAL(clicked(bool)), this, SLOT(onNewElevator()));
|
||||
|
||||
|
||||
// TRANSMITTERS
|
||||
btnWifi = new QPushButton(UIHelper::getIcon("wifi"), "");
|
||||
@@ -100,6 +105,7 @@ void ToolBoxWidget::setSelectedLayer(MapLayer *ml) {
|
||||
btnDoor->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_OBSTACLES));
|
||||
|
||||
btnStair->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_STAIRS));
|
||||
btnElevator->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_ELEVATORS));
|
||||
|
||||
btnWifi->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_ACCESS_POINTS));
|
||||
btnBeacon->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_BEACONS));
|
||||
@@ -491,9 +497,6 @@ void ToolBoxWidget::onNewStair() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
|
||||
// Floorplan::Stair* stair = new Floorplan::StairNormal(center, 0, 0, 3, 2, 6);
|
||||
// stair->center = center;
|
||||
|
||||
Floorplan::StairFreeform* stair = new Floorplan::StairFreeform();
|
||||
Floorplan::StairPart part(Point3(center.x-3, center.y, 0), Point3(center.x+3, center.y, 3), 3);
|
||||
stair->parts.push_back( part );
|
||||
@@ -505,6 +508,19 @@ void ToolBoxWidget::onNewStair() {
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewElevator() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
|
||||
Floorplan::Elevator* elevator = new Floorplan::Elevator(center);
|
||||
|
||||
MMFloorElevators* elevators = (MMFloorElevators*)curLayer;
|
||||
elevators->create(elevator);
|
||||
|
||||
//view->getModel()->reselect();
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewAccessPoint() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
|
||||
@@ -38,6 +38,7 @@ private:
|
||||
QPushButton* btnPillar;
|
||||
QPushButton* btnDoor;
|
||||
QPushButton* btnStair;
|
||||
QPushButton* btnElevator;
|
||||
|
||||
QPushButton* btnWifi;
|
||||
QPushButton* btnBeacon;
|
||||
@@ -54,6 +55,7 @@ private slots:
|
||||
void onNewPillar();
|
||||
void onNewDoor();
|
||||
void onNewStair();
|
||||
void onNewElevator();
|
||||
|
||||
void onNewAccessPoint();
|
||||
void onNewBeacon();
|
||||
|
||||
1
res.qrc
1
res.qrc
@@ -13,5 +13,6 @@
|
||||
<file>res/icons/stair.svg</file>
|
||||
<file>res/icons/door.svg</file>
|
||||
<file>res/icons/cursor.svg</file>
|
||||
<file>res/icons/elevator.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
61
res/icons/elevator.svg
Normal file
61
res/icons/elevator.svg
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 300.806 300.806" style="enable-background:new 0 0 300.806 300.806;" xml:space="preserve">
|
||||
<g id="XMLID_1240_">
|
||||
<g>
|
||||
<g>
|
||||
<path d="M196.874,149.219c0,0,0.225,34.08,0.225,129.928h2.96c5.241,0,9.49-4.248,9.49-9.489V159.66
|
||||
C203.752,157.985,199.811,154.398,196.874,149.219z"/>
|
||||
<path d="M116.783,269.211c-2.825,0-5.115-2.29-5.115-5.115v-53.747c-8.657-2.332-15.235-10.283-15.187-19.961l0.381-75.962
|
||||
c0.058-11.647,5.913-21.958,14.805-28.214V43.172c0-2.825,2.29-5.115,5.115-5.115c2.825,0,5.115,2.29,5.115,5.115v38.114
|
||||
c5.124-1.494,8.866-1.385,11.471-1.385c-3.561-5.121-5.658-11.334-5.658-18.03c0-17.458,14.203-31.66,31.66-31.66
|
||||
c17.457,0,31.66,14.203,31.66,31.66c0,6.696-2.095,12.91-5.657,18.03h2.732c8.267,0,16.05,3.584,21.441,9.62V34.585
|
||||
c0-5.24-4.248-9.489-9.49-9.489h-58.18C141.876,11.236,130.64,0,116.78,0c-13.86,0-25.096,11.236-25.096,25.096H33.507
|
||||
c-5.241,0-9.49,4.248-9.49,9.489v235.074c0,5.24,4.248,9.489,9.49,9.489h88.142v-13.48
|
||||
C120.986,267.723,119.059,269.211,116.783,269.211z"/>
|
||||
<path d="M267.599,100.471h-16.556c-5.075,0-9.189,4.114-9.189,9.189v4.439c7.292-1.339,8.165-1.589,10.528-1.589
|
||||
c9.922,0,18.426,7.089,20.22,16.856c2.049,11.155-5.36,21.898-16.516,23.947l-14.126,2.594c0.644,4.446,4.459,7.865,9.083,7.865
|
||||
h16.556c5.075,0,9.189-4.114,9.189-9.189v-44.923C276.788,104.585,272.674,100.471,267.599,100.471z"/>
|
||||
<path d="M262.539,131.215c-1.032-5.615-6.421-9.334-12.038-8.302l-29.899,5.492l-16.396-28.897
|
||||
c-3.282-5.784-9.451-9.376-16.1-9.376c-6.764,0-50.442,0-56.544,0c-13.425,0-24.402,10.921-24.469,24.345l-0.382,75.963
|
||||
c-0.029,5.71,4.577,10.363,10.287,10.392c0.018,0,0.035,0,0.053,0c5.686,0,10.31-4.595,10.338-10.287l0.382-75.963
|
||||
c0.011-2.078,1.71-3.77,3.79-3.77h0.313l0.005,177.588c0,6.852,5.555,12.407,12.408,12.407s12.408-5.555,12.408-12.407v-99.177
|
||||
h5.357v99.177c0,6.857,5.56,12.407,12.408,12.407c6.853,0,12.408-5.555,12.408-12.407c0-47.305-0.225-130.277-0.225-177.588h0.2
|
||||
l19.401,34.194c2.17,3.825,6.526,5.863,10.861,5.067l37.132-6.82C259.854,142.22,263.571,136.831,262.539,131.215z"/>
|
||||
<path d="M137.942,61.87c0,11.898,9.67,21.43,21.43,21.43c11.828,0,21.43-9.589,21.43-21.43c0-11.835-9.594-21.43-21.43-21.43
|
||||
C147.537,40.441,137.942,50.035,137.942,61.87z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
Reference in New Issue
Block a user